From 57f2d22ba7883160c9c3a51f461b48b4fb9afb2c Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Sun, 17 Nov 2019 11:44:53 -0800 Subject: [PATCH] DRY out query translation failure in tests --- .../Query/QueryNoClientEvalTestBase.cs | 4 +- .../Query/UdfDbFunctionTestBase.cs | 4 +- .../Query/GearsOfWarQueryTestBase.cs | 7 - ...orthwindAggregateOperatorsQueryTestBase.cs | 7 - .../NorthwindMiscellaneousQueryTestBase.cs | 7 - .../NorthwindNavigationsQueryTestBase.cs | 7 - .../Query/NorthwindSelectQueryTestBase.cs | 7 - .../Query/NorthwindWhereQueryTestBase.cs | 7 - .../Query/QueryTestBase.cs | 7 + .../BuiltInDataTypesSqliteTest.cs | 12 +- .../Query/GearsOfWarQuerySqliteTest.cs | 64 +-- ...thwindAggregateOperatorsQuerySqliteTest.cs | 44 +-- .../NorthwindFunctionsQuerySqliteTest.cs | 363 ++++-------------- .../NorthwindMiscellaneousQuerySqliteTest.cs | 13 +- .../Query/NorthwindWhereQuerySqliteTest.cs | 26 +- 15 files changed, 108 insertions(+), 471 deletions(-) diff --git a/test/EFCore.Relational.Specification.Tests/Query/QueryNoClientEvalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/QueryNoClientEvalTestBase.cs index 7277b06107a..8f88da66411 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/QueryNoClientEvalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/QueryNoClientEvalTestBase.cs @@ -204,11 +204,9 @@ private string NormalizeDelimitersInRawString(string sql) => Fixture.TestStore.NormalizeDelimitersInRawString(sql); private void AssertTranslationFailed(Action testCode) - { - Assert.Contains( + => Assert.Contains( CoreStrings.TranslationFailed("").Substring(21), Assert.Throws(testCode).Message); - } protected NorthwindContext CreateContext() => Fixture.CreateContext(); } diff --git a/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs index 6937212dcc6..4e089347708 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs @@ -1071,10 +1071,8 @@ public virtual void Scalar_Nested_Function_UDF_BCL_Instance() #endregion private void AssertTranslationFailed(Action testCode) - { - Assert.Contains( + => Assert.Contains( CoreStrings.TranslationFailed("").Substring(21), Assert.Throws(testCode).Message); - } } } diff --git a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs index d30377239c4..09db0d2da5b 100644 --- a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs @@ -7303,13 +7303,6 @@ public virtual Task Byte_array_contains_parameter(bool async) ss => ss.Set().Where(s => s.Banner != null && s.Banner.Contains(someByte))); } - protected async Task AssertTranslationFailed(Func testCode) - { - Assert.Contains( - CoreStrings.TranslationFailed("").Substring(21), - (await Assert.ThrowsAsync(testCode)).Message); - } - protected GearsOfWarContext CreateContext() => Fixture.CreateContext(); protected virtual void ClearLog() diff --git a/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs index 920337d34ce..8282423b577 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs @@ -1827,12 +1827,5 @@ private static string CodeFormat(int str) { return str.ToString(); } - - protected async Task AssertTranslationFailed(Func testCode) - { - Assert.Contains( - CoreStrings.TranslationFailed("").Substring(21), - (await Assert.ThrowsAsync(testCode)).Message); - } } } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs index d3af2d0ce10..8ab58b4a743 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs @@ -5462,13 +5462,6 @@ public virtual Task AsQueryable_in_query_server_evals(bool async) elementAsserter: (e, a) => AssertCollection(e, a, ordered: true)); } - protected async Task AssertTranslationFailed(Func testCode) - { - Assert.Contains( - CoreStrings.TranslationFailed("").Substring(21), - (await Assert.ThrowsAsync(testCode)).Message); - } - private static Expression> ValidYear => a => a.OrderDate.Value.Year == 1998; } } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs index d857501809a..8c39398326e 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs @@ -1123,12 +1123,5 @@ private class OrderDTO { public Customer Customer { get; set; } } - - private async Task AssertTranslationFailed(Func testCode) - { - Assert.Contains( - CoreStrings.TranslationFailed("").Substring(21), - (await Assert.ThrowsAsync(testCode)).Message); - } } } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs index 68df5835bac..57637167269 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs @@ -1593,12 +1593,5 @@ public CustomerWrapper(Customer customer) public string City { get; set; } public Customer Customer { get; } } - - protected async Task AssertTranslationFailed(Func testCode) - { - Assert.Contains( - CoreStrings.TranslationFailed("").Substring(21), - (await Assert.ThrowsAsync(testCode)).Message); - } } } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs index 0adc9be8688..58dcba53bcf 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs @@ -1991,12 +1991,5 @@ public virtual Task Using_same_parameter_twice_in_query_generates_one_sql_parame ss => ss.Set().Where(c => i + c.CustomerID + i == c.CompanyName) .Select(c => c.CustomerID)); } - - protected async Task AssertTranslationFailed(Func testCode) - { - Assert.Contains( - CoreStrings.TranslationFailed("").Substring(21), - (await Assert.ThrowsAsync(testCode)).Message); - } } } diff --git a/test/EFCore.Specification.Tests/Query/QueryTestBase.cs b/test/EFCore.Specification.Tests/Query/QueryTestBase.cs index c00bcf95e98..9a704b05549 100644 --- a/test/EFCore.Specification.Tests/Query/QueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/QueryTestBase.cs @@ -7,6 +7,7 @@ using System.Linq.Expressions; using System.Runtime.CompilerServices; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; @@ -1149,6 +1150,12 @@ protected static IEnumerable MaybeDefaultIfEmpty(IEnumerable query) + => Assert.Contains( + CoreStrings.TranslationFailed("").Substring(21), + (await Assert.ThrowsAsync(query)) + .Message); + #endregion } } diff --git a/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs index f05d3509300..6ece8108d87 100644 --- a/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs @@ -1019,13 +1019,6 @@ public virtual void Cant_query_Sum_of_converted_types() .Sum(e => e.TestDecimal)); } - private void AssertTranslationFailed(Action testCode) - { - Assert.Contains( - CoreStrings.TranslationFailed("").Substring(21), - Assert.Throws(testCode).Message); - } - [ConditionalFact] public virtual void Can_query_negation_of_converted_types() { @@ -1513,6 +1506,11 @@ public virtual void Cant_query_ThenBy_of_converted_types() Assert.Equal(SqliteStrings.OrderByNotSupported("ulong"), ex.Message); } + private void AssertTranslationFailed(Action testCode) + => Assert.Contains( + CoreStrings.TranslationFailed("").Substring(21), + Assert.Throws(testCode).Message); + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs index 24e19265f51..29c5c004a66 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs @@ -16,77 +16,41 @@ public GearsOfWarQuerySqliteTest(GearsOfWarQuerySqliteFixture fixture, ITestOutp //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - // SQLite client-eval public override Task Where_datetimeoffset_date_component(bool async) - { - return AssertTranslationFailed(() => base.Where_datetimeoffset_date_component(async)); - } + => AssertTranslationFailed(() => base.Where_datetimeoffset_date_component(async)); - // SQLite client-eval public override Task Where_datetimeoffset_day_component(bool async) - { - return AssertTranslationFailed(() => base.Where_datetimeoffset_date_component(async)); - } + => AssertTranslationFailed(() => base.Where_datetimeoffset_date_component(async)); - // SQLite client-eval public override Task Where_datetimeoffset_dayofyear_component(bool async) - { - return AssertTranslationFailed(() => base.Where_datetimeoffset_dayofyear_component(async)); - } + => AssertTranslationFailed(() => base.Where_datetimeoffset_dayofyear_component(async)); - // SQLite client-eval public override Task Where_datetimeoffset_hour_component(bool async) - { - return AssertTranslationFailed(() => base.Where_datetimeoffset_hour_component(async)); - } + => AssertTranslationFailed(() => base.Where_datetimeoffset_hour_component(async)); - // SQLite client-eval public override Task Where_datetimeoffset_millisecond_component(bool async) - { - return AssertTranslationFailed(() => base.Where_datetimeoffset_millisecond_component(async)); - } + => AssertTranslationFailed(() => base.Where_datetimeoffset_millisecond_component(async)); - // SQLite client-eval public override Task Where_datetimeoffset_minute_component(bool async) - { - return AssertTranslationFailed(() => base.Where_datetimeoffset_minute_component(async)); - } + => AssertTranslationFailed(() => base.Where_datetimeoffset_minute_component(async)); - // SQLite client-eval public override Task Where_datetimeoffset_month_component(bool async) - { - return AssertTranslationFailed(() => base.Where_datetimeoffset_month_component(async)); - } + => AssertTranslationFailed(() => base.Where_datetimeoffset_month_component(async)); - // SQLite client-eval public override Task Where_datetimeoffset_now(bool async) - { - return AssertTranslationFailed(() => base.Where_datetimeoffset_now(async)); - } + => AssertTranslationFailed(() => base.Where_datetimeoffset_now(async)); - // SQLite client-eval public override Task Where_datetimeoffset_second_component(bool async) - { - return AssertTranslationFailed(() => base.Where_datetimeoffset_second_component(async)); - } + => AssertTranslationFailed(() => base.Where_datetimeoffset_second_component(async)); - // SQLite client-eval public override Task Where_datetimeoffset_utcnow(bool async) - { - return AssertTranslationFailed(() => base.Where_datetimeoffset_utcnow(async)); - } + => AssertTranslationFailed(() => base.Where_datetimeoffset_utcnow(async)); - // SQLite client-eval public override Task Where_datetimeoffset_year_component(bool async) - { - return AssertTranslationFailed(() => base.Where_datetimeoffset_year_component(async)); - } + => AssertTranslationFailed(() => base.Where_datetimeoffset_year_component(async)); - // SQLite client-eval public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) - { - return AssertTranslationFailed(() => base.DateTimeOffset_Contains_Less_than_Greater_than(async)); - } + => AssertTranslationFailed(() => base.DateTimeOffset_Contains_Less_than_Greater_than(async)); // Sqlite does not support cross/outer apply public override Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool async) => null; @@ -105,9 +69,7 @@ public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) [ConditionalTheory(Skip = "Issue #17230")] public override Task Project_collection_navigation_nested_with_take_composite_key(bool async) - { - return base.Project_collection_navigation_nested_with_take_composite_key(async); - } + => base.Project_collection_navigation_nested_with_take_composite_key(async); public override async Task Select_datetimeoffset_comparison_in_projection(bool async) { diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs index 3c23a1a82a2..fb114a589ca 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs @@ -18,44 +18,16 @@ public NorthwindAggregateOperatorsQuerySqliteTest(NorthwindQuerySqliteFixture( - () => base.Sum_with_division_on_decimal(async))) - .Message); - } + public override Task Sum_with_division_on_decimal(bool async) + => AssertTranslationFailed(() => base.Sum_with_division_on_decimal(async)); - // SQLite client-eval - public override async Task Sum_with_division_on_decimal_no_significant_digits(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Sum_with_division_on_decimal_no_significant_digits(async))) - .Message); - } + public override Task Sum_with_division_on_decimal_no_significant_digits(bool async) + => AssertTranslationFailed(() => base.Sum_with_division_on_decimal_no_significant_digits(async)); - // SQLite client-eval - public override async Task Average_with_division_on_decimal(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Average_with_division_on_decimal(async))) - .Message); - } + public override Task Average_with_division_on_decimal(bool async) + => AssertTranslationFailed(() => base.Average_with_division_on_decimal(async)); - // SQLite client-eval - public override async Task Average_with_division_on_decimal_no_significant_digits(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Average_with_division_on_decimal_no_significant_digits(async))) - .Message); - } + public override Task Average_with_division_on_decimal_no_significant_digits(bool async) + => AssertTranslationFailed(() => base.Average_with_division_on_decimal_no_significant_digits(async)); } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs index 8c664e3d985..4b91cd4f9fa 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs @@ -18,335 +18,104 @@ public NorthwindFunctionsQuerySqliteTest(NorthwindQuerySqliteFixture( - () => base.Convert_ToByte(async))) - .Message); - } + public override Task Convert_ToByte(bool async) + => AssertTranslationFailed(() => base.Convert_ToByte(async)); - // SQLite client-eval - public override async Task Convert_ToDecimal(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Convert_ToDecimal(async))) - .Message); - } + public override Task Convert_ToDecimal(bool async) + => AssertTranslationFailed(() => base.Convert_ToDecimal(async)); - // SQLite client-eval - public override async Task Convert_ToDouble(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Convert_ToDouble(async))) - .Message); - } + public override Task Convert_ToDouble(bool async) + => AssertTranslationFailed(() => base.Convert_ToDouble(async)); - // SQLite client-eval - public override async Task Convert_ToInt16(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Convert_ToInt16(async))) - .Message); - } + public override Task Convert_ToInt16(bool async) + => AssertTranslationFailed(() => base.Convert_ToInt16(async)); - // SQLite client-eval - public override async Task Convert_ToInt32(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Convert_ToInt32(async))) - .Message); - } + public override Task Convert_ToInt32(bool async) + => AssertTranslationFailed(() => base.Convert_ToInt32(async)); - // SQLite client-eval - public override async Task Convert_ToInt64(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Convert_ToInt64(async))) - .Message); - } + public override Task Convert_ToInt64(bool async) + => AssertTranslationFailed(() => base.Convert_ToInt64(async)); - // SQLite client-eval - public override async Task Convert_ToString(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Convert_ToString(async))) - .Message); - } + public override Task Convert_ToString(bool async) + => AssertTranslationFailed(() => base.Convert_ToString(async)); - // SQLite client-eval - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Projecting_Math_Truncate_and_ordering_by_it_twice(async))) - .Message); - } + public override Task Projecting_Math_Truncate_and_ordering_by_it_twice(bool async) + => AssertTranslationFailed(() => base.Projecting_Math_Truncate_and_ordering_by_it_twice(async)); - // SQLite client-eval - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice2(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Projecting_Math_Truncate_and_ordering_by_it_twice2(async))) - .Message); - } + public override Task Projecting_Math_Truncate_and_ordering_by_it_twice2(bool async) + => AssertTranslationFailed(() => base.Projecting_Math_Truncate_and_ordering_by_it_twice2(async)); - // SQLite client-eval - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice3(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Projecting_Math_Truncate_and_ordering_by_it_twice3(async))) - .Message); - } + public override Task Projecting_Math_Truncate_and_ordering_by_it_twice3(bool async) + => AssertTranslationFailed(() => base.Projecting_Math_Truncate_and_ordering_by_it_twice3(async)); - // SQLite client-eval - public override async Task Where_functions_nested(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_functions_nested(async))) - .Message); - } + public override Task Where_functions_nested(bool async) + => AssertTranslationFailed(() => base.Where_functions_nested(async)); - // SQLite client-eval - public override async Task Where_guid_newguid(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_guid_newguid(async))) - .Message); - } + public override Task Where_guid_newguid(bool async) + => AssertTranslationFailed(() => base.Where_guid_newguid(async)); - // SQLite client-eval - public override async Task Where_math_abs3(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_abs3(async))) - .Message); - } + public override Task Where_math_abs3(bool async) + => AssertTranslationFailed(() => base.Where_math_abs3(async)); - // SQLite client-eval - public override async Task Where_math_acos(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_acos(async))) - .Message); - } + public override Task Where_math_acos(bool async) + => AssertTranslationFailed(() => base.Where_math_acos(async)); - // SQLite client-eval - public override async Task Where_math_asin(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_asin(async))) - .Message); - } + public override Task Where_math_asin(bool async) + => AssertTranslationFailed(() => base.Where_math_asin(async)); - // SQLite client-eval - public override async Task Where_math_atan(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_atan(async))) - .Message); - } + public override Task Where_math_atan(bool async) + => AssertTranslationFailed(() => base.Where_math_atan(async)); - // SQLite client-eval - public override async Task Where_math_atan2(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_atan2(async))) - .Message); - } + public override Task Where_math_atan2(bool async) + => AssertTranslationFailed(() => base.Where_math_atan2(async)); - // SQLite client-eval - public override async Task Where_math_ceiling1(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_ceiling1(async))) - .Message); - } + public override Task Where_math_ceiling1(bool async) + => AssertTranslationFailed(() => base.Where_math_ceiling1(async)); - // SQLite client-eval - public override async Task Where_math_ceiling2(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_ceiling2(async))) - .Message); - } + public override Task Where_math_ceiling2(bool async) + => AssertTranslationFailed(() => base.Where_math_ceiling2(async)); - // SQLite client-eval - public override async Task Where_math_cos(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_cos(async))) - .Message); - } + public override Task Where_math_cos(bool async) + => AssertTranslationFailed(() => base.Where_math_cos(async)); - // SQLite client-eval - public override async Task Where_math_exp(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_exp(async))) - .Message); - } + public override Task Where_math_exp(bool async) + => AssertTranslationFailed(() => base.Where_math_exp(async)); - // SQLite client-eval - public override async Task Where_math_floor(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_floor(async))) - .Message); - } + public override Task Where_math_floor(bool async) + => AssertTranslationFailed(() => base.Where_math_floor(async)); - // SQLite client-eval - public override async Task Where_math_log(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_log(async))) - .Message); - } + public override Task Where_math_log(bool async) + => AssertTranslationFailed(() => base.Where_math_log(async)); - // SQLite client-eval - public override async Task Where_math_log_new_base(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_log_new_base(async))) - .Message); - } + public override Task Where_math_log_new_base(bool async) + => AssertTranslationFailed(() => base.Where_math_log_new_base(async)); - // SQLite client-eval - public override async Task Where_math_log10(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_log10(async))) - .Message); - } + public override Task Where_math_log10(bool async) + => AssertTranslationFailed(() => base.Where_math_log10(async)); - // SQLite client-eval - public override async Task Where_math_power(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_power(async))) - .Message); - } + public override Task Where_math_power(bool async) + => AssertTranslationFailed(() => base.Where_math_power(async)); - // SQLite client-eval - public override async Task Where_math_round(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_round(async))) - .Message); - } + public override Task Where_math_round(bool async) + => AssertTranslationFailed(() => base.Where_math_round(async)); - // SQLite client-eval - public override async Task Where_math_round2(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_round2(async))) - .Message); - } + public override Task Where_math_round2(bool async) + => AssertTranslationFailed(() => base.Where_math_round2(async)); - // SQLite client-eval - public override async Task Where_math_sign(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_sign(async))) - .Message); - } + public override Task Where_math_sign(bool async) + => AssertTranslationFailed(() => base.Where_math_sign(async)); - // SQLite client-eval - public override async Task Where_math_sin(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_sin(async))) - .Message); - } + public override Task Where_math_sin(bool async) + => AssertTranslationFailed(() => base.Where_math_sin(async)); - // SQLite client-eval - public override async Task Where_math_sqrt(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_sqrt(async))) - .Message); - } + public override Task Where_math_sqrt(bool async) + => AssertTranslationFailed(() => base.Where_math_sqrt(async)); - // SQLite client-eval - public override async Task Where_math_tan(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_tan(async))) - .Message); - } + public override Task Where_math_tan(bool async) + => AssertTranslationFailed(() => base.Where_math_tan(async)); - // SQLite client-eval - public override async Task Where_math_truncate(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_math_truncate(async))) - .Message); - } + public override Task Where_math_truncate(bool async) + => AssertTranslationFailed(() => base.Where_math_truncate(async)); public override async Task String_StartsWith_Literal(bool async) { diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs index dd233cfa219..dd2fd6d83bf 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs @@ -21,17 +21,8 @@ public NorthwindMiscellaneousQuerySqliteTest(NorthwindQuerySqliteFixture( - () => base.Query_expression_with_to_string_and_contains(async))) - .Message); - } - + public override Task Query_expression_with_to_string_and_contains(bool async) + => AssertTranslationFailed(() => base.Query_expression_with_to_string_and_contains(async)); public override async Task Take_Skip(bool async) { diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs index 53e47aa6be9..126e3931fda 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs @@ -18,25 +18,11 @@ public NorthwindWhereQuerySqliteTest(NorthwindQuerySqliteFixture( - () => base.Where_datetimeoffset_now_component(async))) - .Message); - } + public override Task Where_datetimeoffset_now_component(bool async) + => AssertTranslationFailed(() => base.Where_datetimeoffset_now_component(async)); - // SQLite client-eval - public override async Task Where_datetimeoffset_utcnow_component(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_datetimeoffset_utcnow_component(async))) - .Message); - } + public override Task Where_datetimeoffset_utcnow_component(bool async) + => AssertTranslationFailed(() => base.Where_datetimeoffset_utcnow_component(async)); public override async Task Where_datetime_now(bool async) { @@ -217,9 +203,7 @@ public override async Task Decimal_cast_to_double_works(bool async) [ConditionalTheory(Skip = "Issue#17223")] public override Task Like_with_non_string_column_using_ToString(bool async) - { - return base.Like_with_non_string_column_using_ToString(async); - } + => base.Like_with_non_string_column_using_ToString(async); private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected);