Skip to content

Commit

Permalink
Fix non-deterministic tests that fail on postgres
Browse files Browse the repository at this point in the history
Fixes #27155
Fixes #27152
Fixes #27278
  • Loading branch information
maumar committed Jan 26, 2022
1 parent 3c7c302 commit 5b7744f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public override Task Average_Grouped_from_LINQ_101(bool 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) });
select new { Category = g.Key, AveragePrice = g.Average(p => p.UnitPrice) },
elementSorter: e => (e.Category, e.AveragePrice));

public class Ef6GroupByInMemoryFixture : Ef6GroupByFixtureBase
{
Expand Down
3 changes: 2 additions & 1 deletion test/EFCore.Specification.Tests/Query/Ef6GroupByTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ into g
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) });
select new { Category = g.Key, AveragePrice = Math.Round(g.Average(p => p.UnitPrice) - 0.0000005m, 6) },
elementSorter: e => (e.Category, e.AveragePrice));

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ public virtual Task Reverse_in_subquery_via_pushdown(bool async)
.Take(5)
.Distinct()
.Select(e => new { e.EmployeeID, e.City }),
assertOrder: true);
elementSorter: e => e.EmployeeID);

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
Expand Down
18 changes: 15 additions & 3 deletions test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,21 @@ public virtual async Task Aggregate_over_subquery_in_group_by_projection(bool as
? await query.ToListAsync()
: query.ToList();

Assert.Collection(orders,
t => Assert.Equal(10, t.CustomerMinHourlyRate),
t => Assert.Equal(20, t.CustomerMinHourlyRate));
Assert.Collection(orders.OrderBy(x => x.CustomerId),
t =>
{
Assert.Equal(1, t.CustomerId);
Assert.Equal(10, t.CustomerMinHourlyRate);
Assert.Equal(11, t.HourlyRate);
Assert.Equal(1, t.Count);
},
t =>
{
Assert.Equal(2, t.CustomerId);
Assert.Equal(20, t.CustomerMinHourlyRate);
Assert.Equal(20, t.HourlyRate);
Assert.Equal(1, t.Count);
});
}

protected class Context27083 : DbContext
Expand Down

0 comments on commit 5b7744f

Please sign in to comment.