Skip to content

Commit

Permalink
Fix to #22293 - AssertIncludeCollection ordering of elements issue
Browse files Browse the repository at this point in the history
Adding sorting to the verification code for owned collections in the InheritanceRelationships query test infra.
  • Loading branch information
maumar committed Sep 1, 2020
1 parent c2610a5 commit 8b58b01
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,12 @@ public IReadOnlyDictionary<Type, object> GetEntityAsserters()
Assert.Equal(ee.OwnedCollectionOnBase?.Count, aa.OwnedCollectionOnBase?.Count);
if (ee.OwnedCollectionOnBase?.Count > 0)
{
for (var i = 0; i < ee.OwnedCollectionOnBase.Count; i++)
var orderedExpected = ee.OwnedCollectionOnBase.OrderBy(x => x.Id).ToList();
var orderedActual = aa.OwnedCollectionOnBase.OrderBy(x => x.Id).ToList();
for (var i = 0; i < orderedExpected.Count; i++)
{
Assert.Equal(ee.OwnedCollectionOnBase[i].Id, aa.OwnedCollectionOnBase[i].Id);
Assert.Equal(ee.OwnedCollectionOnBase[i].Name, aa.OwnedCollectionOnBase[i].Name);
Assert.Equal(orderedExpected[i].Id, orderedActual[i].Id);
Assert.Equal(orderedExpected[i].Name, orderedActual[i].Name);
}
}
}
Expand Down Expand Up @@ -166,20 +168,24 @@ public IReadOnlyDictionary<Type, object> GetEntityAsserters()
Assert.Equal(ee.OwnedCollectionOnBase?.Count, aa.OwnedCollectionOnBase?.Count);
if (ee.OwnedCollectionOnBase?.Count > 0)
{
for (var i = 0; i < ee.OwnedCollectionOnBase.Count; i++)
var orderedExpected = ee.OwnedCollectionOnBase.OrderBy(x => x.Id).ToList();
var orderedActual = aa.OwnedCollectionOnBase.OrderBy(x => x.Id).ToList();
for (var i = 0; i < orderedExpected.Count; i++)
{
Assert.Equal(ee.OwnedCollectionOnBase[i].Id, aa.OwnedCollectionOnBase[i].Id);
Assert.Equal(ee.OwnedCollectionOnBase[i].Name, aa.OwnedCollectionOnBase[i].Name);
Assert.Equal(orderedExpected[i].Id, orderedActual[i].Id);
Assert.Equal(orderedExpected[i].Name, orderedActual[i].Name);
}
}
Assert.Equal(ee.OwnedCollectionOnDerived?.Count, aa.OwnedCollectionOnDerived?.Count);
if (ee.OwnedCollectionOnDerived?.Count > 0)
{
for (var i = 0; i < ee.OwnedCollectionOnDerived.Count; i++)
var orderedExpected = ee.OwnedCollectionOnDerived.OrderBy(x => x.Id).ToList();
var orderedActual = aa.OwnedCollectionOnDerived.OrderBy(x => x.Id).ToList();
for (var i = 0; i < orderedExpected.Count; i++)
{
Assert.Equal(ee.OwnedCollectionOnDerived[i].Id, aa.OwnedCollectionOnDerived[i].Id);
Assert.Equal(ee.OwnedCollectionOnDerived[i].Name, aa.OwnedCollectionOnDerived[i].Name);
Assert.Equal(orderedExpected[i].Id, orderedActual[i].Id);
Assert.Equal(orderedExpected[i].Name, orderedActual[i].Name);
}
}
}
Expand Down Expand Up @@ -409,8 +415,6 @@ public IReadOnlyDictionary<Type, object> GetEntityAsserters()
}
}
},

//{ typeof(OwnedEntity), e => ((OwnedEntity)e)?.Id },
}.ToDictionary(e => e.Key, e => (object)e.Value);

protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
Expand Down

0 comments on commit 8b58b01

Please sign in to comment.