Skip to content

Commit

Permalink
Explicit order in case the database returns the records in different …
Browse files Browse the repository at this point in the history
…order. (#24234)

* Explicit order in case the database returns the records in different order.

* Rewrote tests using AssertQuery.
  • Loading branch information
cincuranet authored Mar 13, 2021
1 parent f542f97 commit ddefb6f
Showing 1 changed file with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2039,26 +2039,24 @@ public virtual Task Filter_non_nullable_value_after_FirstOrDefault_on_empty_coll

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual async Task Like_with_non_string_column_using_ToString(bool async)
public virtual Task Like_with_non_string_column_using_ToString(bool async)
{
using var context = CreateContext();

var query = context.Set<Order>().Where(o => EF.Functions.Like(o.OrderID.ToString(), "%20%"));
var result = async ? await query.ToListAsync() : query.ToList();

Assert.Equal(new[] { 10320, 10420, 10520, 10620, 10720, 10820, 10920, 11020 }, result.Select(e => e.OrderID));
return AssertQuery(
async,
ss => ss.Set<Order>().Where(o => EF.Functions.Like(o.OrderID.ToString(), "%20%")),
ss => ss.Set<Order>().Where(o => o.OrderID.ToString().Contains("20")),
entryCount: 8);
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual async Task Like_with_non_string_column_using_double_cast(bool async)
public virtual Task Like_with_non_string_column_using_double_cast(bool async)
{
using var context = CreateContext();

var query = context.Set<Order>().Where(o => EF.Functions.Like((string)(object)o.OrderID, "%20%"));
var result = async ? await query.ToListAsync() : query.ToList();

Assert.Equal(new[] { 10320, 10420, 10520, 10620, 10720, 10820, 10920, 11020 }, result.Select(e => e.OrderID));
return AssertQuery(
async,
ss => ss.Set<Order>().Where(o => EF.Functions.Like((string)(object)o.OrderID, "%20%")),
ss => ss.Set<Order>().Where(o => o.OrderID.ToString().Contains("20")),
entryCount: 8);
}

[ConditionalTheory]
Expand Down

0 comments on commit ddefb6f

Please sign in to comment.