Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to #27155 - Average_Grouped_from_LINQ_101 is non-deterministic #28650

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ public Ef6GroupByInMemoryTest(Ef6GroupByInMemoryFixture fixture, ITestOutputHelp
{
}

public override Task Average_Grouped_from_LINQ_101(bool async)
=> AssertQuery(
async,
ss => from p in ss.Set<ProductForLinq>()
group p by p.Category
into g
select new { Category = g.Key, AveragePrice = g.Average(p => p.UnitPrice) },
elementSorter: e => (e.Category, e.AveragePrice));

public class Ef6GroupByInMemoryFixture : Ef6GroupByFixtureBase
{
protected override ITestStoreFactory TestStoreFactory
Expand Down
13 changes: 7 additions & 6 deletions test/EFCore.Specification.Tests/Query/Ef6GroupByTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,12 @@ public virtual Task Average_Grouped_from_LINQ_101(bool async)
group p by p.Category
into g
select new { Category = g.Key, AveragePrice = g.Average(p => p.UnitPrice) },
ss => from p in ss.Set<ProductForLinq>()
group p by p.Category
into g
select new { Category = g.Key, AveragePrice = Math.Round(g.Average(p => p.UnitPrice) - 0.0000005m, 6) },
elementSorter: e => (e.Category, e.AveragePrice));
elementSorter: e => (e.Category, e.AveragePrice),
elementAsserter: (e, a) =>
{
AssertEqual(e.Category, a.Category);
Assert.Equal(e.AveragePrice, a.AveragePrice, 5);
});

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
Expand Down Expand Up @@ -644,7 +645,7 @@ in temp
Assert.Equal(l.Id, r.Id);
Assert.Equal(l.Age, r.Age);
Assert.Equal(l.Style, r.Style);
Assert.Equal(l.Values, r.Values);
AssertCollection(l.Values, r.Values, elementSorter: e => (e.Id, e.Style, e.Age));
});

[ConditionalTheory] // From #19506
Expand Down