From ddefb6f00865d6f69ba759368a171a5cf15d22f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jiri=20Cincura=20=E2=86=B9?= Date: Sat, 13 Mar 2021 21:16:02 +0100 Subject: [PATCH] Explicit order in case the database returns the records in different order. (#24234) * Explicit order in case the database returns the records in different order. * Rewrote tests using AssertQuery. --- .../Query/NorthwindWhereQueryTestBase.cs | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs index dba03acc24b..b5c030dd50b 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs @@ -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().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().Where(o => EF.Functions.Like(o.OrderID.ToString(), "%20%")), + ss => ss.Set().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().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().Where(o => EF.Functions.Like((string)(object)o.OrderID, "%20%")), + ss => ss.Set().Where(o => o.OrderID.ToString().Contains("20")), + entryCount: 8); } [ConditionalTheory]