Skip to content

Commit

Permalink
Fixed test issue with not reseting AutoDetectChanges correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ajcvickers committed Jan 7, 2021
1 parent 4ae6175 commit 0b4e367
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions test/EFCore.Specification.Tests/ManyToManyTrackingTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,10 +1011,9 @@ void ValidateFixup(DbContext context, IList<EntityCompositeKey> leftEntities, IL
Assert.Contains(joinEntity, joinEntity.Three.JoinCompositeKeyFull);
}
// Issue #23814
//VerifyRelationshipSnapshots(context, joinEntities);
//VerifyRelationshipSnapshots(context, leftEntities);
//VerifyRelationshipSnapshots(context, rightEntities);
VerifyRelationshipSnapshots(context, joinEntities);
VerifyRelationshipSnapshots(context, leftEntities);
VerifyRelationshipSnapshots(context, rightEntities);
foreach (var entry in context.ChangeTracker.Entries())
{
Expand Down Expand Up @@ -1183,10 +1182,9 @@ void ValidateFixup(
var allLeft = context.ChangeTracker.Entries<EntityCompositeKey>().Select(e => e.Entity).OrderBy(e => e.Key2).ToList();
var allRight = context.ChangeTracker.Entries<EntityThree>().Select(e => e.Entity).OrderBy(e => e.Name).ToList();
// Issue #23814
// VerifyRelationshipSnapshots(context, joinEntries.Select(e => e.Entity));
// VerifyRelationshipSnapshots(context, allLeft);
// VerifyRelationshipSnapshots(context, allRight);
VerifyRelationshipSnapshots(context, joinEntries.Select(e => e.Entity));
VerifyRelationshipSnapshots(context, allLeft);
VerifyRelationshipSnapshots(context, allRight);
var count = 0;
foreach (var left in allLeft)
Expand Down Expand Up @@ -4553,6 +4551,7 @@ static void ValidateFixup(DbContext context, IList<EntityTwo> leftEntities, ILis

protected void VerifyRelationshipSnapshots(DbContext context, IEnumerable<object> entities)
{
var detectChanges = context.ChangeTracker.AutoDetectChangesEnabled;
try
{
context.ChangeTracker.AutoDetectChangesEnabled = false;
Expand Down Expand Up @@ -4614,10 +4613,7 @@ protected void VerifyRelationshipSnapshots(DbContext context, IEnumerable<object
}
finally
{
if (RequiresDetectChanges)
{
context.ChangeTracker.AutoDetectChangesEnabled = true;
}
context.ChangeTracker.AutoDetectChangesEnabled = detectChanges;
}
}

Expand Down

0 comments on commit 0b4e367

Please sign in to comment.