From d1010825b23f85676f171867dfa24d6d3d580a19 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Wed, 13 Nov 2019 22:12:47 -0800 Subject: [PATCH] Split simple partial test classes Closes #18786 --- ...hwindAggregateOperatorsQueryCosmosTest.cs} | 67 +- ...s => NorthwindFunctionsQueryCosmosTest.cs} | 25 +- ... NorthwindJoinGroupJoinQueryCosmosTest.cs} | 49 +- ...orthwindKeylessEntitiesQueryCosmosTest.cs} | 25 +- ... NorthwindMiscellaneousQueryCosmosTest.cs} | 225 +------ ...t.cs => NorthwindSelectQueryCosmosTest.cs} | 118 +++- ... NorthwindSetOperationsQueryCosmosTest.cs} | 19 +- ...re.cs => NorthwindWhereQueryCosmosTest.cs} | 43 +- ...windAggregateOperatorsQueryInMemoryTest.cs | 58 ++ ...orthwindMiscellaneousQueryInMemoryTest.cs} | 77 +-- .../Query/NorthwindSelectQueryInMemoryTest.cs | 42 ++ .../Query/NorthwindWhereQueryInMemoryTest.cs | 45 ++ ...rthwindAggregateOperatorsQueryTestBase.cs} | 36 +- ....cs => NorthwindFunctionsQueryTestBase.cs} | 15 +- ...=> NorthwindJoinGroupJoinQueryTestBase.cs} | 20 +- ... NorthwindKeylessEntitiesQueryTestBase.cs} | 15 +- ...=> NorthwindMiscellaneousQueryTestBase.cs} | 80 +-- ...ect.cs => NorthwindSelectQueryTestBase.cs} | 95 ++- ...=> NorthwindSetOperationsQueryTestBase.cs} | 35 +- ...here.cs => NorthwindWhereQueryTestBase.cs} | 23 +- ...ndAggregateOperatorsQuerySqlServerTest.cs} | 20 +- ...> NorthwindFunctionsQuerySqlServerTest.cs} | 17 +- ...rthwindJoinGroupJoinQuerySqlServerTest.cs} | 17 +- ...hwindKeylessEntitiesQuerySqlServerTest.cs} | 17 +- ...rthwindMiscellaneousQuerySqlServerTest.cs} | 26 +- ...s => NorthwindSelectQuerySqlServerTest.cs} | 33 +- ...rthwindSetOperationsQuerySqlServerTest.cs} | 17 +- ...cs => NorthwindWhereQuerySqlServerTest.cs} | 51 +- ...thwindAggregateOperatorsQuerySqliteTest.cs | 61 ++ ...s => NorthwindFunctionsQuerySqliteTest.cs} | 630 +----------------- .../NorthwindMiscellaneousQuerySqliteTest.cs | 258 +++++++ .../Query/NorthwindSelectQuerySqliteTest.cs | 174 +++++ .../Query/NorthwindWhereQuerySqliteTest.cs | 227 +++++++ 33 files changed, 1583 insertions(+), 1077 deletions(-) rename test/EFCore.Cosmos.FunctionalTests/Query/{SimpleQueryCosmosTest.ResultOperators.cs => NorthwindAggregateOperatorsQueryCosmosTest.cs} (95%) rename test/EFCore.Cosmos.FunctionalTests/Query/{SimpleQueryCosmosTest.Functions.cs => NorthwindFunctionsQueryCosmosTest.cs} (96%) rename test/EFCore.Cosmos.FunctionalTests/Query/{SimpleQueryCosmosTest.JoinGroupJoin.cs => NorthwindJoinGroupJoinQueryCosmosTest.cs} (91%) rename test/EFCore.Cosmos.FunctionalTests/Query/{SimpleQueryCosmosTest.KeylessEntities.cs => NorthwindKeylessEntitiesQueryCosmosTest.cs} (81%) rename test/EFCore.Cosmos.FunctionalTests/Query/{SimpleQueryCosmosTest.cs => NorthwindMiscellaneousQueryCosmosTest.cs} (93%) rename test/EFCore.Cosmos.FunctionalTests/Query/{SimpleQueryCosmosTest.Select.cs => NorthwindSelectQueryCosmosTest.cs} (86%) rename test/EFCore.Cosmos.FunctionalTests/Query/{SimpleQueryCosmosTest.SetOperations.cs => NorthwindSetOperationsQueryCosmosTest.cs} (81%) rename test/EFCore.Cosmos.FunctionalTests/Query/{SimpleQueryCosmosTest.Where.cs => NorthwindWhereQueryCosmosTest.cs} (97%) create mode 100644 test/EFCore.InMemory.FunctionalTests/Query/NorthwindAggregateOperatorsQueryInMemoryTest.cs rename test/EFCore.InMemory.FunctionalTests/Query/{SimpleQueryInMemoryTest.cs => NorthwindMiscellaneousQueryInMemoryTest.cs} (61%) create mode 100644 test/EFCore.InMemory.FunctionalTests/Query/NorthwindSelectQueryInMemoryTest.cs create mode 100644 test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs rename test/EFCore.Specification.Tests/Query/{SimpleQueryTestBase.ResultOperators.cs => NorthwindAggregateOperatorsQueryTestBase.cs} (98%) rename test/EFCore.Specification.Tests/Query/{SimpleQueryTestBase.Functions.cs => NorthwindFunctionsQueryTestBase.cs} (99%) rename test/EFCore.Specification.Tests/Query/{SimpleQueryTestBase.JoinGroupJoin.cs => NorthwindJoinGroupJoinQueryTestBase.cs} (98%) rename test/EFCore.Specification.Tests/Query/{SimpleQueryTestBase.KeylessEntities.cs => NorthwindKeylessEntitiesQueryTestBase.cs} (92%) rename test/EFCore.Specification.Tests/Query/{SimpleQueryTestBase.cs => NorthwindMiscellaneousQueryTestBase.cs} (98%) rename test/EFCore.Specification.Tests/Query/{SimpleQueryTestBase.Select.cs => NorthwindSelectQueryTestBase.cs} (93%) rename test/EFCore.Specification.Tests/Query/{SimpleQueryTestBase.SetOperations.cs => NorthwindSetOperationsQueryTestBase.cs} (95%) rename test/EFCore.Specification.Tests/Query/{SimpleQueryTestBase.Where.cs => NorthwindWhereQueryTestBase.cs} (98%) rename test/EFCore.SqlServer.FunctionalTests/Query/{SimpleQuerySqlServerTest.ResultOperators.cs => NorthwindAggregateOperatorsQuerySqlServerTest.cs} (98%) rename test/EFCore.SqlServer.FunctionalTests/Query/{SimpleQuerySqlServerTest.Functions.cs => NorthwindFunctionsQuerySqlServerTest.cs} (98%) rename test/EFCore.SqlServer.FunctionalTests/Query/{SimpleQuerySqlServerTest.JoinGroupJoin.cs => NorthwindJoinGroupJoinQuerySqlServerTest.cs} (97%) rename test/EFCore.SqlServer.FunctionalTests/Query/{SimpleQuerySqlServerTest.KeylessEntities.cs => NorthwindKeylessEntitiesQuerySqlServerTest.cs} (88%) rename test/EFCore.SqlServer.FunctionalTests/Query/{SimpleQuerySqlServerTest.cs => NorthwindMiscellaneousQuerySqlServerTest.cs} (99%) rename test/EFCore.SqlServer.FunctionalTests/Query/{SimpleQuerySqlServerTest.Select.cs => NorthwindSelectQuerySqlServerTest.cs} (97%) rename test/EFCore.SqlServer.FunctionalTests/Query/{SimpleQuerySqlServerTest.SetOperations.cs => NorthwindSetOperationsQuerySqlServerTest.cs} (96%) rename test/EFCore.SqlServer.FunctionalTests/Query/{SimpleQuerySqlServerTest.Where.cs => NorthwindWhereQuerySqlServerTest.cs} (98%) create mode 100644 test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs rename test/EFCore.Sqlite.FunctionalTests/Query/{SimpleQuerySqliteTest.cs => NorthwindFunctionsQuerySqliteTest.cs} (53%) create mode 100644 test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs create mode 100644 test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSelectQuerySqliteTest.cs create mode 100644 test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.ResultOperators.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs similarity index 95% rename from test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.ResultOperators.cs rename to test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs index a5adfea211a..28eb88226e6 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.ResultOperators.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs @@ -3,15 +3,24 @@ using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Diagnostics.Internal; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; +using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQueryCosmosTest + public class NorthwindAggregateOperatorsQueryCosmosTest : NorthwindAggregateOperatorsQueryTestBase> { + public NorthwindAggregateOperatorsQueryCosmosTest( + NorthwindQueryCosmosFixture fixture, + ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + [ConditionalFact(Skip = "Issue#17246")] public override void Select_All() { @@ -51,6 +60,18 @@ FROM root c WHERE (c[""Discriminator""] = ""Order"")"); } + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Sum_with_no_arg_empty(bool async) + { + return base.Sum_with_no_arg_empty(async); + } + + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Sum_with_no_data_nullable(bool async) + { + return base.Sum_with_no_data_nullable(async); + } + [ConditionalTheory(Skip = "Issue#16146")] public override async Task Sum_with_arg(bool async) { @@ -559,6 +580,12 @@ FROM root c WHERE ((c[""Discriminator""] = ""Customer"") AND (c[""CustomerID""] = ""CENTC""))"); } + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Count_with_no_predicate(bool async) + { + return base.Count_with_no_predicate(async); + } + [ConditionalTheory(Skip = "Issue#16146")] public override async Task Count_with_predicate(bool async) { @@ -570,6 +597,12 @@ FROM root c WHERE ((c[""Discriminator""] = ""Order"") AND (c[""CustomerID""] = ""ALFKI""))"); } + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Count_with_order_by(bool async) + { + return base.Count_with_order_by(async); + } + [ConditionalTheory(Skip = "Issue#16146")] public override async Task Where_OrderBy_Count(bool async) { @@ -823,6 +856,12 @@ FROM root c WHERE (c[""Discriminator""] = ""Customer"")"); } + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Multiple_collection_navigation_with_FirstOrDefault_chained_projecting_scalar(bool async) + { + return base.Multiple_collection_navigation_with_FirstOrDefault_chained_projecting_scalar(async); + } + [ConditionalTheory(Skip = "Issue#17246")] public override async Task First_inside_subquery_gets_client_evaluated(bool async) { @@ -1464,6 +1503,24 @@ FROM root c WHERE (c[""Discriminator""] = ""Customer"")"); } + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Cast_before_aggregate_is_preserved(bool async) + { + return base.Cast_before_aggregate_is_preserved(async); + } + + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Enumerable_min_is_mapped_to_Queryable_1(bool async) + { + return base.Enumerable_min_is_mapped_to_Queryable_1(async); + } + + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Enumerable_min_is_mapped_to_Queryable_2(bool async) + { + return base.Enumerable_min_is_mapped_to_Queryable_2(async); + } + [ConditionalTheory(Skip = "Issue#17246")] public override Task DefaultIfEmpty_selects_only_required_columns(bool async) { @@ -1487,5 +1544,11 @@ public override Task Sum_over_explicit_cast_over_column(bool async) { return base.Sum_over_explicit_cast_over_column(async); } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); } } diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Functions.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs similarity index 96% rename from test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Functions.cs rename to test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs index 0e5804b8cf3..3fe74c7f6cc 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Functions.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs @@ -2,12 +2,23 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; +using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQueryCosmosTest + public class NorthwindFunctionsQueryCosmosTest : NorthwindFunctionsQueryTestBase> { + public NorthwindFunctionsQueryCosmosTest( + NorthwindQueryCosmosFixture fixture, + ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + [ConditionalTheory(Skip = "Issue #17246")] public override async Task String_StartsWith_Literal(bool async) { @@ -779,6 +790,12 @@ FROM root c WHERE (c[""Discriminator""] = ""Customer"")"); } + [ConditionalTheory(Skip = "Issue #17246")] + public override Task IsNullOrWhiteSpace_in_predicate_on_non_nullable_column(bool async) + { + return base.IsNullOrWhiteSpace_in_predicate_on_non_nullable_column(async); + } + public override void IsNullOrEmpty_in_projection() { base.IsNullOrEmpty_in_projection(); @@ -1013,5 +1030,11 @@ public override Task Int_Compare_to_simple_zero(bool async) { return base.Int_Compare_to_simple_zero(async); } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); } } diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.JoinGroupJoin.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindJoinGroupJoinQueryCosmosTest.cs similarity index 91% rename from test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.JoinGroupJoin.cs rename to test/EFCore.Cosmos.FunctionalTests/Query/NorthwindJoinGroupJoinQueryCosmosTest.cs index c9d336134f4..eb796104497 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.JoinGroupJoin.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindJoinGroupJoinQueryCosmosTest.cs @@ -4,12 +4,23 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; +using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQueryCosmosTest + public class NorthwindJoinGroupJoinQueryCosmosTest : NorthwindJoinGroupJoinQueryTestBase> { + public NorthwindJoinGroupJoinQueryCosmosTest( + NorthwindQueryCosmosFixture fixture, + ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + [ConditionalTheory(Skip = "Issue#17246")] public override async Task Join_customers_orders_projection(bool async) { @@ -32,6 +43,12 @@ FROM root c WHERE (c[""Discriminator""] = ""Customer"")"); } + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Join_customers_orders_entities_same_entity_twice(bool async) + { + return base.Join_customers_orders_entities_same_entity_twice(async); + } + [ConditionalTheory(Skip = "Issue#17246")] public override async Task Join_select_many(bool async) { @@ -259,6 +276,30 @@ FROM root c WHERE ((c[""Discriminator""] = ""Customer"") AND ((c[""CustomerID""] != ""VAFFE"") AND (c[""CustomerID""] != ""DRACD"")))"); } + [ConditionalTheory(Skip = "Issue#17246")] + public override Task GroupJoin_customers_employees_shadow(bool async) + { + return base.GroupJoin_customers_employees_shadow(async); + } + + [ConditionalTheory(Skip = "Issue#17246")] + public override Task GroupJoin_customers_employees_subquery_shadow(bool async) + { + return base.GroupJoin_customers_employees_subquery_shadow(async); + } + + [ConditionalTheory(Skip = "Issue#17246")] + public override Task GroupJoin_customers_employees_subquery_shadow_take(bool async) + { + return base.GroupJoin_customers_employees_subquery_shadow_take(async); + } + + [ConditionalTheory(Skip = "Issue#17246")] + public override Task GroupJoin_projection(bool async) + { + return base.GroupJoin_projection(async); + } + [ConditionalTheory(Skip = "Issue#17246")] public override async Task GroupJoin_simple(bool async) { @@ -632,5 +673,11 @@ public override Task GroupJoin_Subquery_with_Take_Then_SelectMany_Where(bool asy { return base.GroupJoin_Subquery_with_Take_Then_SelectMany_Where(async); } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); } } diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.KeylessEntities.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindKeylessEntitiesQueryCosmosTest.cs similarity index 81% rename from test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.KeylessEntities.cs rename to test/EFCore.Cosmos.FunctionalTests/Query/NorthwindKeylessEntitiesQueryCosmosTest.cs index 54bd41e8312..39ed34c5526 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.KeylessEntities.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindKeylessEntitiesQueryCosmosTest.cs @@ -4,12 +4,23 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; +using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQueryCosmosTest + public class NorthwindKeylessEntitiesQueryCosmosTest : NorthwindKeylessEntitiesQueryTestBase> { + public NorthwindKeylessEntitiesQueryCosmosTest( + NorthwindQueryCosmosFixture fixture, + ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + [ConditionalTheory] public override async Task KeylessEntity_simple(bool async) { @@ -43,6 +54,12 @@ FROM root c WHERE ((c[""Discriminator""] = ""Product"") AND NOT(c[""Discontinued""]))"); } + [ConditionalFact(Skip = "See issue#13857")] + public override void Auto_initialized_view_set() + { + base.Auto_initialized_view_set(); + } + [ConditionalFact(Skip = "issue #12086")] // collection support public override void KeylessEntity_with_nav_defining_query() { @@ -121,5 +138,11 @@ public override async Task KeylesEntity_groupby(bool async) AssertSql(@""); } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); } } diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs similarity index 93% rename from test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.cs rename to test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs index fb577ceb292..cd61faffb03 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs @@ -14,9 +14,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQueryCosmosTest : SimpleQueryTestBase> + public class NorthwindMiscellaneousQueryCosmosTest : NorthwindMiscellaneousQueryTestBase> { - public SimpleQueryCosmosTest( + public NorthwindMiscellaneousQueryCosmosTest( NorthwindQueryCosmosFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -25,12 +25,6 @@ public SimpleQueryCosmosTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - [ConditionalFact(Skip = "See issue#13857")] - public override void Auto_initialized_view_set() - { - base.Auto_initialized_view_set(); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Simple_IQueryable(bool async) @@ -3824,90 +3818,18 @@ public override async Task Entity_equality_through_DTO_projection(bool async) await base.Entity_equality_through_DTO_projection(async); } - [ConditionalTheory(Skip = "Issue#17246")] - public override Task GroupJoin_customers_employees_shadow(bool async) - { - return base.GroupJoin_customers_employees_shadow(async); - } - - [ConditionalTheory(Skip = "Issue#17246")] - public override Task GroupJoin_customers_employees_subquery_shadow(bool async) - { - return base.GroupJoin_customers_employees_subquery_shadow(async); - } - - [ConditionalTheory(Skip = "Issue#17246")] - public override Task GroupJoin_customers_employees_subquery_shadow_take(bool async) - { - return base.GroupJoin_customers_employees_subquery_shadow_take(async); - } - - [ConditionalTheory(Skip = "Issue#17246")] - public override Task GroupJoin_projection(bool async) - { - return base.GroupJoin_projection(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Cast_before_aggregate_is_preserved(bool async) - { - return base.Cast_before_aggregate_is_preserved(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Decimal_cast_to_double_works(bool async) - { - return base.Decimal_cast_to_double_works(async); - } - [ConditionalTheory(Skip = "Issue #17246")] public override Task Entity_equality_through_subquery(bool async) { return base.Entity_equality_through_subquery(async); } - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Enumerable_min_is_mapped_to_Queryable_1(bool async) - { - return base.Enumerable_min_is_mapped_to_Queryable_1(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Enumerable_min_is_mapped_to_Queryable_2(bool async) - { - return base.Enumerable_min_is_mapped_to_Queryable_2(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Join_customers_orders_entities_same_entity_twice(bool async) - { - return base.Join_customers_orders_entities_same_entity_twice(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Multiple_collection_navigation_with_FirstOrDefault_chained_projecting_scalar(bool async) - { - return base.Multiple_collection_navigation_with_FirstOrDefault_chained_projecting_scalar(async); - } - [ConditionalFact(Skip = "Issue #17246")] public override void Can_convert_manually_build_expression_with_default() { base.Can_convert_manually_build_expression_with_default(); } - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Count_with_no_predicate(bool async) - { - return base.Count_with_no_predicate(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Count_with_order_by(bool async) - { - return base.Count_with_order_by(async); - } - [ConditionalTheory(Skip = "Issue #17246")] public override Task Entity_equality_orderby_descending_composite_key(bool async) { @@ -3992,42 +3914,12 @@ public override Task Skip_orderby_const(bool async) return base.Skip_orderby_const(async); } - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Sum_with_no_arg_empty(bool async) - { - return base.Sum_with_no_arg_empty(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Sum_with_no_data_nullable(bool async) - { - return base.Sum_with_no_data_nullable(async); - } - [ConditionalTheory(Skip = "Issue #17246")] public override Task Where_Property_when_shadow_unconstrained_generic_method(bool async) { return base.Where_Property_when_shadow_unconstrained_generic_method(async); } - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Where_concat_string_int_comparison4(bool async) - { - return base.Where_concat_string_int_comparison4(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Where_simple_shadow_subquery(bool async) - { - return base.Where_simple_shadow_subquery(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Where_string_concat_method_comparison(bool async) - { - return base.Where_string_concat_method_comparison(async); - } - [ConditionalTheory(Skip = "Issue #17246")] public override Task Inner_parameter_in_nested_lambdas_gets_preserved(bool async) { @@ -4046,60 +3938,6 @@ public override Task Select_DTO_with_member_init_distinct_in_subquery_translated return base.Select_DTO_with_member_init_distinct_in_subquery_translated_to_server_2(async); } - [ConditionalTheory(Skip = "Issue #17246")] - public override Task SelectMany_without_result_selector_naked_collection_navigation(bool async) - { - return base.SelectMany_without_result_selector_naked_collection_navigation(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task SelectMany_without_result_selector_collection_navigation_composed(bool async) - { - return base.SelectMany_without_result_selector_collection_navigation_composed(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task SelectMany_correlated_subquery_simple(bool async) - { - return base.SelectMany_correlated_subquery_simple(async); - } - - [ConditionalTheory(Skip = "Issue#17246")] - public override Task Multiple_select_many_with_predicate(bool async) - { - return base.Multiple_select_many_with_predicate(async); - } - - [ConditionalTheory(Skip = "Issue#17246")] - public override Task SelectMany_correlated_with_outer_1(bool async) - { - return base.SelectMany_correlated_with_outer_1(async); - } - - [ConditionalTheory(Skip = "Issue#17246")] - public override Task SelectMany_correlated_with_outer_2(bool async) - { - return base.SelectMany_correlated_with_outer_2(async); - } - - [ConditionalTheory(Skip = "Issue#17246")] - public override Task SelectMany_correlated_with_outer_3(bool async) - { - return base.SelectMany_correlated_with_outer_3(async); - } - - [ConditionalTheory(Skip = "Issue#17246")] - public override Task SelectMany_correlated_with_outer_4(bool async) - { - return base.SelectMany_correlated_with_outer_4(async); - } - - [ConditionalTheory(Skip = "Issue#17246")] - public override Task FirstOrDefault_over_empty_collection_of_value_type_returns_correct_results(bool async) - { - return base.FirstOrDefault_over_empty_collection_of_value_type_returns_correct_results(async); - } - [ConditionalTheory(Skip = "Issue #17246")] public override Task All_client(bool async) => base.All_client(async); @@ -4114,11 +3952,6 @@ public override Task Subquery_member_pushdown_does_not_change_original_subquery_ [ConditionalTheory(Skip = "Issue #17246")] public override Task Where_query_composition3(bool async) => base.Where_query_composition3(async); - public override Task Member_binding_after_ctor_arguments_fails_with_client_eval(bool async) - { - return AssertTranslationFailed(() => base.Member_binding_after_ctor_arguments_fails_with_client_eval(async)); - } - [ConditionalTheory(Skip = "Issue #17246")] public override Task OrderBy_object_type_server_evals(bool async) { @@ -4132,61 +3965,15 @@ public override Task AsQueryable_in_query_server_evals(bool async) } [ConditionalTheory(Skip = "Issue #17246")] - public override Task SelectMany_correlated_subquery_hard(bool async) - { - return base.SelectMany_correlated_subquery_hard(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task SelectMany_with_collection_being_correlated_subquery_which_references_inner_and_outer_entity(bool async) - { - return base.SelectMany_with_collection_being_correlated_subquery_which_references_inner_and_outer_entity(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Select_chained_entity_navigation_doesnt_materialize_intermittent_entities(bool async) - { - return base.Select_chained_entity_navigation_doesnt_materialize_intermittent_entities(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Select_entity_compared_to_null(bool async) - { - return base.Select_entity_compared_to_null(async); - } - - public override async Task Explicit_cast_in_arithmatic_operation_is_preserved(bool async) - { - await base.Explicit_cast_in_arithmatic_operation_is_preserved(async); - - AssertSql( - @"SELECT c[""OrderID""], (c[""OrderID""] + 1000) AS c -FROM root c -WHERE ((c[""Discriminator""] = ""Order"") AND (c[""OrderID""] = 10243))"); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task SelectMany_whose_selector_references_outer_source(bool async) - { - return base.SelectMany_whose_selector_references_outer_source(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Collection_FirstOrDefault_with_entity_equality_check_in_projection(bool async) - { - return base.Collection_FirstOrDefault_with_entity_equality_check_in_projection(async); - } - - [ConditionalTheory(Skip = "Issue #17246")] - public override Task Collection_FirstOrDefault_with_nullable_unsigned_int_column(bool async) + public override Task SelectMany_correlated_subquery_simple(bool async) { - return base.Collection_FirstOrDefault_with_nullable_unsigned_int_column(async); + return base.SelectMany_correlated_subquery_simple(async); } [ConditionalTheory(Skip = "Issue #17246")] - public override Task IsNullOrWhiteSpace_in_predicate_on_non_nullable_column(bool async) + public override Task SelectMany_correlated_subquery_hard(bool async) { - return base.IsNullOrWhiteSpace_in_predicate_on_non_nullable_column(async); + return base.SelectMany_correlated_subquery_hard(async); } private void AssertSql(params string[] expected) diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Select.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs similarity index 86% rename from test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Select.cs rename to test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs index 2a516e06b3a..0b1d636f3bc 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Select.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs @@ -4,12 +4,23 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; +using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQueryCosmosTest + public class NorthwindSelectQueryCosmosTest : NorthwindSelectQueryTestBase> { + public NorthwindSelectQueryCosmosTest( + NorthwindQueryCosmosFixture fixture, + ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + public override async Task Projection_when_arithmetic_expression_precedence(bool async) { await base.Projection_when_arithmetic_expression_precedence(async); @@ -892,12 +903,65 @@ public override Task Client_method_in_projection_requiring_materialization_2(boo return base.Client_method_in_projection_requiring_materialization_2(async); } + [ConditionalTheory(Skip = "Issue#17246")] + public override Task Multiple_select_many_with_predicate(bool async) + { + return base.Multiple_select_many_with_predicate(async); + } + + [ConditionalTheory(Skip = "Issue #17246")] + public override Task SelectMany_without_result_selector_naked_collection_navigation(bool async) + { + return base.SelectMany_without_result_selector_naked_collection_navigation(async); + } + + [ConditionalTheory(Skip = "Issue #17246")] + public override Task SelectMany_without_result_selector_collection_navigation_composed(bool async) + { + return base.SelectMany_without_result_selector_collection_navigation_composed(async); + } + + [ConditionalTheory(Skip = "Issue#17246")] + public override Task SelectMany_correlated_with_outer_1(bool async) + { + return base.SelectMany_correlated_with_outer_1(async); + } + + [ConditionalTheory(Skip = "Issue#17246")] + public override Task SelectMany_correlated_with_outer_2(bool async) + { + return base.SelectMany_correlated_with_outer_2(async); + } + + [ConditionalTheory(Skip = "Issue#17246")] + public override Task SelectMany_correlated_with_outer_3(bool async) + { + return base.SelectMany_correlated_with_outer_3(async); + } + + [ConditionalTheory(Skip = "Issue#17246")] + public override Task SelectMany_correlated_with_outer_4(bool async) + { + return base.SelectMany_correlated_with_outer_4(async); + } + + [ConditionalTheory(Skip = "Issue#17246")] + public override Task FirstOrDefault_over_empty_collection_of_value_type_returns_correct_results(bool async) + { + return base.FirstOrDefault_over_empty_collection_of_value_type_returns_correct_results(async); + } + [ConditionalTheory(Skip = "Issue#17246")] public override Task Project_non_nullable_value_after_FirstOrDefault_on_empty_collection(bool async) { return base.Project_non_nullable_value_after_FirstOrDefault_on_empty_collection(async); } + public override Task Member_binding_after_ctor_arguments_fails_with_client_eval(bool async) + { + return AssertTranslationFailed(() => base.Member_binding_after_ctor_arguments_fails_with_client_eval(async)); + } + [ConditionalTheory(Skip = "Issue#17246")] public override Task Filtered_collection_projection_is_tracked(bool async) { @@ -910,6 +974,52 @@ public override Task Filtered_collection_projection_with_to_list_is_tracked(bool return base.Filtered_collection_projection_with_to_list_is_tracked(async); } + [ConditionalTheory(Skip = "Issue #17246")] + public override Task SelectMany_with_collection_being_correlated_subquery_which_references_inner_and_outer_entity(bool async) + { + return base.SelectMany_with_collection_being_correlated_subquery_which_references_inner_and_outer_entity(async); + } + + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Select_chained_entity_navigation_doesnt_materialize_intermittent_entities(bool async) + { + return base.Select_chained_entity_navigation_doesnt_materialize_intermittent_entities(async); + } + + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Select_entity_compared_to_null(bool async) + { + return base.Select_entity_compared_to_null(async); + } + + public override async Task Explicit_cast_in_arithmetic_operation_is_preserved(bool async) + { + await base.Explicit_cast_in_arithmetic_operation_is_preserved(async); + + AssertSql( + @"SELECT c[""OrderID""], (c[""OrderID""] + 1000) AS c +FROM root c +WHERE ((c[""Discriminator""] = ""Order"") AND (c[""OrderID""] = 10243))"); + } + + [ConditionalTheory(Skip = "Issue #17246")] + public override Task SelectMany_whose_selector_references_outer_source(bool async) + { + return base.SelectMany_whose_selector_references_outer_source(async); + } + + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Collection_FirstOrDefault_with_entity_equality_check_in_projection(bool async) + { + return base.Collection_FirstOrDefault_with_entity_equality_check_in_projection(async); + } + + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Collection_FirstOrDefault_with_nullable_unsigned_int_column(bool async) + { + return base.Collection_FirstOrDefault_with_nullable_unsigned_int_column(async); + } + [ConditionalTheory(Skip = "Issue#17246")] public override Task ToList_Count_in_projection_works(bool async) { @@ -921,5 +1031,11 @@ public override Task LastOrDefault_member_access_in_projection_translates_to_ser { return base.LastOrDefault_member_access_in_projection_translates_to_server(async); } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); } } diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.SetOperations.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSetOperationsQueryCosmosTest.cs similarity index 81% rename from test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.SetOperations.cs rename to test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSetOperationsQueryCosmosTest.cs index 5e856c7d525..b8fa624db28 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.SetOperations.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSetOperationsQueryCosmosTest.cs @@ -2,11 +2,22 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQueryCosmosTest + public class NorthwindSetOperationsQueryCosmosTest : NorthwindSetOperationsQueryTestBase> { + public NorthwindSetOperationsQueryCosmosTest( + NorthwindQueryCosmosFixture fixture, + ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + // Set operations aren't supported on Cosmos public override Task Concat(bool async) => Task.CompletedTask; public override Task Concat_nested(bool async) => Task.CompletedTask; @@ -44,5 +55,11 @@ public override void Include_Union_different_includes_throws() { } public override Task Union_over_columns_with_different_nullability(bool async) => Task.CompletedTask; public override Task Union_over_different_projection_types(bool async, string leftType, string rightType) => Task.CompletedTask; public override Task OrderBy_Take_Union(bool async) => Task.CompletedTask; + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); } } diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Where.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs similarity index 97% rename from test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Where.cs rename to test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs index 454da1827e4..315a149e2df 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Where.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs @@ -6,12 +6,23 @@ using System.Linq.Expressions; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; +using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQueryCosmosTest + public class NorthwindWhereQueryCosmosTest : NorthwindWhereQueryTestBase> { + public NorthwindWhereQueryCosmosTest( + NorthwindQueryCosmosFixture fixture, + ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Where_add(bool async) @@ -697,6 +708,12 @@ FROM root c WHERE ((c[""Discriminator""] = ""Employee"") AND (c[""Title""] = ""Sales Representative""))"); } + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Where_simple_shadow_subquery(bool async) + { + return base.Where_simple_shadow_subquery(async); + } + [ConditionalTheory(Skip = "Issue #17246")] public override async Task Where_shadow_subquery_FirstOrDefault(bool async) { @@ -1576,6 +1593,18 @@ FROM root c WHERE ((c[""Discriminator""] = ""Customer"") AND ((((@__p_0 + c[""CustomerID""]) || @__j_1) || 42) = c[""CompanyName""]))"); } + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Where_concat_string_int_comparison4(bool async) + { + return base.Where_concat_string_int_comparison4(async); + } + + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Where_string_concat_method_comparison(bool async) + { + return base.Where_string_concat_method_comparison(async); + } + public override async Task Where_ternary_boolean_condition_true(bool async) { await base.Where_ternary_boolean_condition_true(async); @@ -1872,6 +1901,12 @@ FROM root c WHERE ((c[""Discriminator""] = ""Order"") AND @__p_0)"); } + [ConditionalTheory(Skip = "Issue #17246")] + public override Task Decimal_cast_to_double_works(bool async) + { + return base.Decimal_cast_to_double_works(async); + } + [ConditionalTheory(Skip = "Issue#16391")] public override Task Where_is_conditional(bool async) { @@ -1903,5 +1938,11 @@ public override async Task Using_same_parameter_twice_in_query_generates_one_sql AssertSql(" "); } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAggregateOperatorsQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAggregateOperatorsQueryInMemoryTest.cs new file mode 100644 index 00000000000..3cd63b141d2 --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAggregateOperatorsQueryInMemoryTest.cs @@ -0,0 +1,58 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class NorthwindAggregateOperatorsQueryInMemoryTest : NorthwindAggregateOperatorsQueryTestBase> + { + public NorthwindAggregateOperatorsQueryInMemoryTest( + NorthwindQueryInMemoryFixture fixture, +#pragma warning disable IDE0060 // Remove unused parameter + ITestOutputHelper testOutputHelper) +#pragma warning restore IDE0060 // Remove unused parameter + : base(fixture) + { + //TestLoggerFactory.TestOutputHelper = testOutputHelper; + } + + // InMemory can throw server side exception + public override void Average_no_data_subquery() + { + Assert.Throws(() => base.Average_no_data_subquery()); + } + + public override void Max_no_data_subquery() + { + Assert.Throws(() => base.Max_no_data_subquery()); + } + + public override void Min_no_data_subquery() + { + Assert.Throws(() => base.Min_no_data_subquery()); + } + + public override Task Collection_Last_member_access_in_projection_translated(bool async) + { + return Assert.ThrowsAsync( + () => base.Collection_Last_member_access_in_projection_translated(async)); + } + + [ConditionalTheory(Skip = "Issue#17386")] + public override Task Contains_with_local_tuple_array_closure(bool async) + { + return base.Contains_with_local_tuple_array_closure(async); + } + + [ConditionalTheory(Skip = "Issue#17386")] + public override Task Last_when_no_order_by(bool async) + { + return base.Last_when_no_order_by(async); + } + } +} diff --git a/test/EFCore.InMemory.FunctionalTests/Query/SimpleQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindMiscellaneousQueryInMemoryTest.cs similarity index 61% rename from test/EFCore.InMemory.FunctionalTests/Query/SimpleQueryInMemoryTest.cs rename to test/EFCore.InMemory.FunctionalTests/Query/NorthwindMiscellaneousQueryInMemoryTest.cs index 22cbbedbbf7..38dc9462e88 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/SimpleQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindMiscellaneousQueryInMemoryTest.cs @@ -9,9 +9,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class SimpleQueryInMemoryTest : SimpleQueryTestBase> + public class NorthwindMiscellaneousQueryInMemoryTest : NorthwindMiscellaneousQueryTestBase> { - public SimpleQueryInMemoryTest( + public NorthwindMiscellaneousQueryInMemoryTest( NorthwindQueryInMemoryFixture fixture, #pragma warning disable IDE0060 // Remove unused parameter ITestOutputHelper testOutputHelper) @@ -21,22 +21,6 @@ public SimpleQueryInMemoryTest( //TestLoggerFactory.TestOutputHelper = testOutputHelper; } - // InMemory can throw server side exception - public override void Average_no_data_subquery() - { - Assert.Throws(() => base.Average_no_data_subquery()); - } - - public override void Max_no_data_subquery() - { - Assert.Throws(() => base.Max_no_data_subquery()); - } - - public override void Min_no_data_subquery() - { - Assert.Throws(() => base.Min_no_data_subquery()); - } - public override Task Where_query_composition_entity_equality_one_element_Single(bool async) { return Assert.ThrowsAsync( @@ -73,12 +57,6 @@ public override Task Where_query_composition_entity_equality_multiple_elements_S () => base.Where_query_composition_entity_equality_multiple_elements_Single(async)); } - public override Task Collection_Last_member_access_in_projection_translated(bool async) - { - return Assert.ThrowsAsync( - () => base.Collection_Last_member_access_in_projection_translated(async)); - } - // Sending client code to server [ConditionalFact(Skip = "Issue#17050")] public override void Client_code_using_instance_in_anonymous_type() @@ -98,18 +76,6 @@ public override void Client_code_using_instance_method_throws() base.Client_code_using_instance_method_throws(); } - [ConditionalTheory(Skip = "Issue#17386")] - public override Task Contains_with_local_tuple_array_closure(bool async) - { - return base.Contains_with_local_tuple_array_closure(async); - } - - [ConditionalTheory(Skip = "Issue#17386")] - public override Task Last_when_no_order_by(bool async) - { - return base.Last_when_no_order_by(async); - } - [ConditionalTheory(Skip = "Issue#17386")] public override Task OrderBy_multiple_queries(bool async) { @@ -152,49 +118,10 @@ public override Task Random_next_is_not_funcletized_6(bool async) return base.Random_next_is_not_funcletized_6(async); } - [ConditionalTheory(Skip = "Issue#17386")] - public override Task Select_bool_closure_with_order_by_property_with_cast_to_nullable(bool async) - { - return base.Select_bool_closure_with_order_by_property_with_cast_to_nullable(async); - } - - [ConditionalTheory(Skip = "Issue#17386")] - public override Task Where_bool_client_side_negated(bool async) - { - return base.Where_bool_client_side_negated(async); - } - - [ConditionalTheory(Skip = "Issue#17386")] - public override Task Projection_when_arithmetic_mixed_subqueries(bool async) - { - return base.Projection_when_arithmetic_mixed_subqueries(async); - } - - [ConditionalTheory(Skip = "Issue#17386")] - public override Task Where_equals_method_string_with_ignore_case(bool async) - { - return base.Where_equals_method_string_with_ignore_case(async); - } - - [ConditionalTheory(Skip = "Issue#17536")] - public override Task SelectMany_correlated_with_outer_3(bool async) - { - return base.SelectMany_correlated_with_outer_3(async); - } - [ConditionalTheory] public override Task DefaultIfEmpty_in_subquery_nested(bool async) { return base.DefaultIfEmpty_in_subquery_nested(async); } - - [ConditionalTheory(Skip = "issue #17386")] - public override Task Where_equals_on_null_nullable_int_types(bool async) - { - return base.Where_equals_on_null_nullable_int_types(async); - } - - // Casting int to object to string is invalid for InMemory - public override Task Like_with_non_string_column_using_double_cast(bool async) => Task.CompletedTask; } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindSelectQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindSelectQueryInMemoryTest.cs new file mode 100644 index 00000000000..3abc4f6119b --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindSelectQueryInMemoryTest.cs @@ -0,0 +1,42 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class NorthwindSelectQueryInMemoryTest : NorthwindSelectQueryTestBase> + { + public NorthwindSelectQueryInMemoryTest( + NorthwindQueryInMemoryFixture fixture, +#pragma warning disable IDE0060 // Remove unused parameter + ITestOutputHelper testOutputHelper) +#pragma warning restore IDE0060 // Remove unused parameter + : base(fixture) + { + //TestLoggerFactory.TestOutputHelper = testOutputHelper; + } + + [ConditionalTheory(Skip = "Issue#17386")] + public override Task Select_bool_closure_with_order_by_property_with_cast_to_nullable(bool async) + { + return base.Select_bool_closure_with_order_by_property_with_cast_to_nullable(async); + } + + [ConditionalTheory(Skip = "Issue#17386")] + public override Task Projection_when_arithmetic_mixed_subqueries(bool async) + { + return base.Projection_when_arithmetic_mixed_subqueries(async); + } + + [ConditionalTheory(Skip = "Issue#17536")] + public override Task SelectMany_correlated_with_outer_3(bool async) + { + return base.SelectMany_correlated_with_outer_3(async); + } + } +} diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs new file mode 100644 index 00000000000..5bacb2662b3 --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs @@ -0,0 +1,45 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class NorthwindWhereQueryInMemoryTest : NorthwindWhereQueryTestBase> + { + public NorthwindWhereQueryInMemoryTest( + NorthwindQueryInMemoryFixture fixture, +#pragma warning disable IDE0060 // Remove unused parameter + ITestOutputHelper testOutputHelper) +#pragma warning restore IDE0060 // Remove unused parameter + : base(fixture) + { + //TestLoggerFactory.TestOutputHelper = testOutputHelper; + } + + [ConditionalTheory(Skip = "Issue#17386")] + public override Task Where_bool_client_side_negated(bool async) + { + return base.Where_bool_client_side_negated(async); + } + + [ConditionalTheory(Skip = "Issue#17386")] + public override Task Where_equals_method_string_with_ignore_case(bool async) + { + return base.Where_equals_method_string_with_ignore_case(async); + } + + [ConditionalTheory(Skip = "issue #17386")] + public override Task Where_equals_on_null_nullable_int_types(bool async) + { + return base.Where_equals_on_null_nullable_int_types(async); + } + + // Casting int to object to string is invalid for InMemory + public override Task Like_with_non_string_column_using_double_cast(bool async) => Task.CompletedTask; + } +} diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.ResultOperators.cs b/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs similarity index 98% rename from test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.ResultOperators.cs rename to test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs index 571aedac10d..dde6db6b327 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.ResultOperators.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; #pragma warning disable RCS1202 // Avoid NullReferenceException. @@ -15,26 +16,18 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public abstract partial class SimpleQueryTestBase + public abstract class NorthwindAggregateOperatorsQueryTestBase : QueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() { - public class CustomerDeets + protected NorthwindAggregateOperatorsQueryTestBase(TFixture fixture) + : base(fixture) { - public string Id { get; set; } - - public override bool Equals(object obj) - { - if (obj is null) - { - return false; - } + } - return ReferenceEquals(this, obj) - ? true - : obj.GetType() == GetType() - && string.Equals(Id, ((CustomerDeets)obj).Id); - } + protected NorthwindContext CreateContext() => Fixture.CreateContext(); - public override int GetHashCode() => Id != null ? Id.GetHashCode() : 0; + protected virtual void ClearLog() + { } [ConditionalFact] @@ -723,14 +716,10 @@ public virtual Task OrderBy_client_Take(bool async) entryCount: 9); } - public static bool ClientEvalPredicateStateless() => true; - protected static bool ClientEvalPredicate(Order order) => order.OrderID > 10000; private static int ClientEvalSelectorStateless() => 42; - protected internal uint ClientEvalSelector(Order order) => order.EmployeeID % 10 ?? 0; - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Distinct(bool async) @@ -1851,5 +1840,12 @@ 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/SimpleQueryTestBase.Functions.cs b/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs similarity index 99% rename from test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Functions.cs rename to test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs index 2ce97498b59..44c13919cfc 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Functions.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs @@ -7,6 +7,7 @@ using System.Linq.Expressions; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; // ReSharper disable InconsistentNaming @@ -22,8 +23,20 @@ namespace Microsoft.EntityFrameworkCore.Query { // ReSharper disable once UnusedTypeParameter - public abstract partial class SimpleQueryTestBase + public abstract class NorthwindFunctionsQueryTestBase : QueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() { + protected NorthwindFunctionsQueryTestBase(TFixture fixture) + : base(fixture) + { + } + + protected NorthwindContext CreateContext() => Fixture.CreateContext(); + + protected virtual void ClearLog() + { + } + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task String_StartsWith_Literal(bool async) diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.JoinGroupJoin.cs b/test/EFCore.Specification.Tests/Query/NorthwindJoinGroupJoinQueryTestBase.cs similarity index 98% rename from test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.JoinGroupJoin.cs rename to test/EFCore.Specification.Tests/Query/NorthwindJoinGroupJoinQueryTestBase.cs index 480b7d06e0b..043b1d76e4e 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.JoinGroupJoin.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindJoinGroupJoinQueryTestBase.cs @@ -5,13 +5,26 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public abstract partial class SimpleQueryTestBase + public abstract class NorthwindJoinGroupJoinQueryTestBase : QueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() { + protected NorthwindJoinGroupJoinQueryTestBase(TFixture fixture) + : base(fixture) + { + } + + protected NorthwindContext CreateContext() => Fixture.CreateContext(); + + protected virtual void ClearLog() + { + } + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Join_customers_orders_projection(bool async) @@ -254,6 +267,11 @@ from c in ss.Set() e => e.c.CustomerID); } + private class Foo + { + public string Bar { get; set; } + } + [ConditionalTheory(Skip = "Issue #17068")] [MemberData(nameof(IsAsyncData))] public virtual async Task Join_local_collection_int_closure_is_cached_correctly(bool async) diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.KeylessEntities.cs b/test/EFCore.Specification.Tests/Query/NorthwindKeylessEntitiesQueryTestBase.cs similarity index 92% rename from test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.KeylessEntities.cs rename to test/EFCore.Specification.Tests/Query/NorthwindKeylessEntitiesQueryTestBase.cs index e64f84e9354..9bfeedee2dd 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.KeylessEntities.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindKeylessEntitiesQueryTestBase.cs @@ -5,13 +5,26 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public abstract partial class SimpleQueryTestBase + public abstract class NorthwindKeylessEntitiesQueryTestBase : QueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() { + protected NorthwindKeylessEntitiesQueryTestBase(TFixture fixture) + : base(fixture) + { + } + + protected NorthwindContext CreateContext() => Fixture.CreateContext(); + + protected virtual void ClearLog() + { + } + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task KeylessEntity_simple(bool async) diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs similarity index 98% rename from test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs rename to test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs index e17d0552e59..b3ffa070ead 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs @@ -19,10 +19,10 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public abstract partial class SimpleQueryTestBase : QueryTestBase + public abstract class NorthwindMiscellaneousQueryTestBase : QueryTestBase where TFixture : NorthwindQueryFixtureBase, new() { - protected SimpleQueryTestBase(TFixture fixture) + protected NorthwindMiscellaneousQueryTestBase(TFixture fixture) : base(fixture) { } @@ -1143,76 +1143,6 @@ public virtual Task All_client_or_server_top_level(bool async) predicate: c => c.CustomerID != "Foo" || c.IsLondon)); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Projection_when_arithmetic_expressions(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Select( - o => new - { - o.OrderID, - Double = o.OrderID * 2, - Add = o.OrderID + 23, - Sub = 100000 - o.OrderID, - Divide = o.OrderID / (o.OrderID / 2), - Literal = 42, - o - }), - elementSorter: e => e.OrderID, - entryCount: 830); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Projection_when_arithmetic_mixed(bool async) - { - return AssertQuery( - async, - ss => - from o in ss.Set().OrderBy(o => o.OrderID).Take(10) - from e in ss.Set().OrderBy(e => e.EmployeeID).Take(5) - select new - { - Add = e.EmployeeID + o.OrderID, - o.OrderID, - o, - Literal = 42, - e.EmployeeID, - e - }, - elementSorter: e => e.OrderID + " " + e.EmployeeID, - entryCount: 15); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Projection_when_arithmetic_mixed_subqueries(bool async) - { - Assert.Equal( - "Unsupported Binary operator type specified.", - (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => - from o in ss.Set().OrderBy(o => o.OrderID).Take(3).Select( - o2 => new { o2, Mod = o2.OrderID % 2 }) - from e in ss.Set().OrderBy(e => e.EmployeeID).Take(2).Select( - e2 => new { e2, Square = e2.EmployeeID ^ 2 }) - select new - { - Add = e.e2.EmployeeID + o.o2.OrderID, - e.Square, - e.e2, - Literal = 42, - o.o2, - o.Mod - }, - elementSorter: e => (e.e2.EmployeeID, e.o2.OrderID), - entryCount: 3))).Message); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Take_with_single(bool async) @@ -5396,6 +5326,10 @@ select g.OrderByDescending(x => x.OrderID), elementAsserter: (e, a) => AssertCollection(e, a, ordered: true))); } + protected static bool ClientEvalPredicate(Order order) => order.OrderID > 10000; + + protected internal uint ClientEvalSelector(Order order) => order.EmployeeID % 10 ?? 0; + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Collection_navigation_equal_to_null_for_subquery(bool async) @@ -5484,7 +5418,7 @@ public virtual void Client_code_using_instance_in_static_method() () => context.Customers.Select(c => StaticMethod(this, c)).ToList()).Message); } - private static string StaticMethod(SimpleQueryTestBase containingClass, Customer c) => c.City; + private static string StaticMethod(NorthwindMiscellaneousQueryTestBase containingClass, Customer c) => c.City; [ConditionalFact] public virtual void Client_code_using_instance_in_anonymous_type() diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Select.cs b/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs similarity index 93% rename from test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Select.cs rename to test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs index 705e08253b3..7c825cca693 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Select.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs @@ -5,7 +5,9 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; #pragma warning disable RCS1202 // Avoid NullReferenceException. @@ -13,8 +15,20 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public abstract partial class SimpleQueryTestBase + public abstract class NorthwindSelectQueryTestBase : QueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() { + protected NorthwindSelectQueryTestBase(TFixture fixture) + : base(fixture) + { + } + + protected NorthwindContext CreateContext() => Fixture.CreateContext(); + + protected virtual void ClearLog() + { + } + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Select_into(bool async) @@ -38,6 +52,76 @@ public virtual Task Projection_when_arithmetic_expression_precedence(bool async) e => (e.A, e.B)); } + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Projection_when_arithmetic_expressions(bool async) + { + return AssertQuery( + async, + ss => ss.Set().Select( + o => new + { + o.OrderID, + Double = o.OrderID * 2, + Add = o.OrderID + 23, + Sub = 100000 - o.OrderID, + Divide = o.OrderID / (o.OrderID / 2), + Literal = 42, + o + }), + elementSorter: e => e.OrderID, + entryCount: 830); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Projection_when_arithmetic_mixed(bool async) + { + return AssertQuery( + async, + ss => + from o in ss.Set().OrderBy(o => o.OrderID).Take(10) + from e in ss.Set().OrderBy(e => e.EmployeeID).Take(5) + select new + { + Add = e.EmployeeID + o.OrderID, + o.OrderID, + o, + Literal = 42, + e.EmployeeID, + e + }, + elementSorter: e => e.OrderID + " " + e.EmployeeID, + entryCount: 15); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Projection_when_arithmetic_mixed_subqueries(bool async) + { + Assert.Equal( + "Unsupported Binary operator type specified.", + (await Assert.ThrowsAsync( + () => AssertQuery( + async, + ss => + from o in ss.Set().OrderBy(o => o.OrderID).Take(3).Select( + o2 => new { o2, Mod = o2.OrderID % 2 }) + from e in ss.Set().OrderBy(e => e.EmployeeID).Take(2).Select( + e2 => new { e2, Square = e2.EmployeeID ^ 2 }) + select new + { + Add = e.e2.EmployeeID + o.o2.OrderID, + e.Square, + e.e2, + Literal = 42, + o.o2, + o.Mod + }, + elementSorter: e => (e.e2.EmployeeID, e.o2.OrderID), + entryCount: 3))).Message); + } + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Projection_when_null_value(bool async) @@ -1372,7 +1456,7 @@ public virtual Task Select_entity_compared_to_null(bool async) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Explicit_cast_in_arithmatic_operation_is_preserved(bool async) + public virtual Task Explicit_cast_in_arithmetic_operation_is_preserved(bool async) { return AssertQueryScalar( async, @@ -1441,5 +1525,12 @@ public virtual Task LastOrDefault_member_access_in_projection_translates_to_serv .Select(c => new { c, c.Orders.OrderByDescending(o => o.OrderID).LastOrDefault().OrderDate }), entryCount: 4); } + + 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/SimpleQueryTestBase.SetOperations.cs b/test/EFCore.Specification.Tests/Query/NorthwindSetOperationsQueryTestBase.cs similarity index 95% rename from test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.SetOperations.cs rename to test/EFCore.Specification.Tests/Query/NorthwindSetOperationsQueryTestBase.cs index b9ca49c3625..3c803aac9bc 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.SetOperations.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindSetOperationsQueryTestBase.cs @@ -6,13 +6,26 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public abstract partial class SimpleQueryTestBase + public abstract class NorthwindSetOperationsQueryTestBase : QueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() { + protected NorthwindSetOperationsQueryTestBase(TFixture fixture) + : base(fixture) + { + } + + protected NorthwindContext CreateContext() => Fixture.CreateContext(); + + protected virtual void ClearLog() + { + } + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Concat(bool async) @@ -306,6 +319,26 @@ public virtual Task Union_with_anonymous_type_projection(bool async) .Select(c => new CustomerDeets { Id = c.CustomerID })); } + public class CustomerDeets + { + public string Id { get; set; } + + public override bool Equals(object obj) + { + if (obj is null) + { + return false; + } + + return ReferenceEquals(this, obj) + ? true + : obj.GetType() == GetType() + && string.Equals(Id, ((CustomerDeets)obj).Id); + } + + public override int GetHashCode() => Id != null ? Id.GetHashCode() : 0; + } + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Select_Union_unrelated(bool async) diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Where.cs b/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs similarity index 98% rename from test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Where.cs rename to test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs index 3f7a4009841..344f8547aeb 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Where.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs @@ -6,15 +6,29 @@ using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; // ReSharper disable RedundantBoolCompare // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public abstract partial class SimpleQueryTestBase + public abstract class NorthwindWhereQueryTestBase : QueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() { + protected NorthwindWhereQueryTestBase(TFixture fixture) + : base(fixture) + { + } + + protected NorthwindContext CreateContext() => Fixture.CreateContext(); + + protected virtual void ClearLog() + { + } + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_simple(bool async) @@ -1981,5 +1995,12 @@ 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.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.ResultOperators.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs similarity index 98% rename from test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.ResultOperators.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs index 36ac9f3537b..492b324ab54 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.ResultOperators.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs @@ -1,17 +1,21 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Diagnostics.Internal; -using Microsoft.EntityFrameworkCore.SqlServer.Diagnostics.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; -using Xunit; +using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQuerySqlServerTest + public class NorthwindAggregateOperatorsQuerySqlServerTest : NorthwindAggregateOperatorsQueryTestBase> { + public NorthwindAggregateOperatorsQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + public override void Select_All() { base.Select_All(); @@ -1370,5 +1374,11 @@ public override async Task Count_on_projection_with_client_eval(bool async) @"SELECT COUNT(*) FROM [Orders] AS [o]"); } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Functions.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs similarity index 98% rename from test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Functions.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs index 03e70d98247..46c50276930 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Functions.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs @@ -4,12 +4,21 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; +using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQuerySqlServerTest + public class NorthwindFunctionsQuerySqlServerTest : NorthwindFunctionsQueryTestBase> { + public NorthwindFunctionsQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + public override async Task String_StartsWith_Literal(bool async) { await base.String_StartsWith_Literal(async); @@ -1438,5 +1447,11 @@ public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice3(bo //WHERE [o].[OrderID] < 10250 //ORDER BY [A] DESC"); } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.JoinGroupJoin.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinGroupJoinQuerySqlServerTest.cs similarity index 97% rename from test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.JoinGroupJoin.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinGroupJoinQuerySqlServerTest.cs index f2927f1b7a5..e0a727dfd5f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.JoinGroupJoin.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinGroupJoinQuerySqlServerTest.cs @@ -2,11 +2,20 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQuerySqlServerTest + public class NorthwindJoinGroupJoinQuerySqlServerTest : NorthwindJoinGroupJoinQueryTestBase> { + public NorthwindJoinGroupJoinQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + public override async Task Join_customers_orders_projection(bool async) { await base.Join_customers_orders_projection(async); @@ -578,5 +587,11 @@ ORDER BY [o].[OrderID] WHERE [t].[CustomerID] IS NOT NULL AND ([t].[CustomerID] LIKE N'A%') ) AS [t0] ON [c].[CustomerID] = [t0].[CustomerID]"); } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.KeylessEntities.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqlServerTest.cs similarity index 88% rename from test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.KeylessEntities.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqlServerTest.cs index 8bdae37b4f5..23e65a56f3a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.KeylessEntities.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqlServerTest.cs @@ -2,12 +2,21 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; +using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQuerySqlServerTest + public class NorthwindKeylessEntitiesQuerySqlServerTest : NorthwindKeylessEntitiesQueryTestBase> { + public NorthwindKeylessEntitiesQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + [ConditionalTheory] public override async Task KeylessEntity_simple(bool async) { @@ -152,5 +161,11 @@ public override async Task KeylesEntity_groupby(bool async) ) AS [c] GROUP BY [c].[City]"); } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs similarity index 99% rename from test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs index 25dacb9791f..e7047d92c54 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs @@ -13,9 +13,9 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQuerySqlServerTest : SimpleQueryTestBase> + public class NorthwindMiscellaneousQuerySqlServerTest : NorthwindMiscellaneousQueryTestBase> { - public SimpleQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindMiscellaneousQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { ClearLog(); @@ -1058,6 +1058,28 @@ ORDER BY [o].[OrderID] OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY"); } + public override async Task Ternary_should_not_evaluate_both_sides(bool async) + { + await base.Ternary_should_not_evaluate_both_sides(async); + + AssertSql( + @"@__p_0='none' (Size = 4000) +@__p_1='none' (Size = 4000) +@__p_2='none' (Size = 4000) + +SELECT [c].[CustomerID], @__p_0 AS [Data1], @__p_1 AS [Data2], @__p_2 AS [Data3] +FROM [Customers] AS [c]"); + } + + public override async Task Ternary_should_not_evaluate_both_sides_with_parameter(bool async) + { + await base.Ternary_should_not_evaluate_both_sides_with_parameter(async); + + AssertSql( + @"SELECT CAST(1 AS bit) AS [Data1] +FROM [Orders] AS [o]"); + } + [SqlServerCondition(SqlServerCondition.SupportsOffset)] public override async Task Take_Skip(bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Select.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs similarity index 97% rename from test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Select.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs index fffb6be63d0..1f0197ca8dc 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Select.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs @@ -2,11 +2,20 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQuerySqlServerTest + public class NorthwindSelectQuerySqlServerTest : NorthwindSelectQueryTestBase> { + public NorthwindSelectQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + public override async Task Projection_when_arithmetic_expression_precedence(bool async) { await base.Projection_when_arithmetic_expression_precedence(async); @@ -1054,6 +1063,18 @@ FROM [Customers] AS [c] WHERE [c].[CustomerID] = N'FISSA'"); } + public override async Task Project_non_nullable_value_after_FirstOrDefault_on_empty_collection(bool async) + { + await base.Project_non_nullable_value_after_FirstOrDefault_on_empty_collection(async); + + AssertSql( + @"SELECT ( + SELECT TOP(1) CAST(LEN([o].[CustomerID]) AS int) + FROM [Orders] AS [o] + WHERE [o].[CustomerID] = N'John Doe') +FROM [Customers] AS [c]"); + } + public override Task Member_binding_after_ctor_arguments_fails_with_client_eval(bool async) { return AssertTranslationFailed(() => base.Member_binding_after_ctor_arguments_fails_with_client_eval(async)); @@ -1157,9 +1178,9 @@ FROM [Orders] AS [o] WHERE [o].[CustomerID] = N'ALFKI'"); } - public override async Task Explicit_cast_in_arithmatic_operation_is_preserved(bool async) + public override async Task Explicit_cast_in_arithmetic_operation_is_preserved(bool async) { - await base.Explicit_cast_in_arithmatic_operation_is_preserved(async); + await base.Explicit_cast_in_arithmetic_operation_is_preserved(async); AssertSql( @"SELECT CAST([o].[OrderID] AS decimal(18,2)) / CAST(([o].[OrderID] + 1000) AS decimal(18,2)) @@ -1227,5 +1248,11 @@ FROM [Orders] AS [o] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%'"); } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.SetOperations.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSetOperationsQuerySqlServerTest.cs similarity index 96% rename from test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.SetOperations.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSetOperationsQuerySqlServerTest.cs index 44941e4f649..b5ebe9e7814 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.SetOperations.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSetOperationsQuerySqlServerTest.cs @@ -3,12 +3,21 @@ using System; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; +using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQuerySqlServerTest + public class NorthwindSetOperationsQuerySqlServerTest : NorthwindSetOperationsQueryTestBase> { + public NorthwindSetOperationsQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + public override async Task Union(bool async) { await base.Union(async); @@ -512,5 +521,11 @@ FROM [Customers] AS [c0] ORDER BY [c0].[ContactName] ) AS [t0]"); } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Where.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs similarity index 98% rename from test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Where.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs index 801bbba17ac..a9c72b33b48 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Where.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs @@ -2,11 +2,20 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public partial class SimpleQuerySqlServerTest + public class NorthwindWhereQuerySqlServerTest : NorthwindWhereQueryTestBase> { + public NorthwindWhereQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + public override async Task Where_simple(bool async) { await base.Where_simple(async); @@ -1400,28 +1409,6 @@ public override async Task Where_compare_constructed_equal(bool async) FROM [Customers] AS [c]"); } - public override async Task Ternary_should_not_evaluate_both_sides(bool async) - { - await base.Ternary_should_not_evaluate_both_sides(async); - - AssertSql( - @"@__p_0='none' (Size = 4000) -@__p_1='none' (Size = 4000) -@__p_2='none' (Size = 4000) - -SELECT [c].[CustomerID], @__p_0 AS [Data1], @__p_1 AS [Data2], @__p_2 AS [Data3] -FROM [Customers] AS [c]"); - } - - public override async Task Ternary_should_not_evaluate_both_sides_with_parameter(bool async) - { - await base.Ternary_should_not_evaluate_both_sides_with_parameter(async); - - AssertSql( - @"SELECT CAST(1 AS bit) AS [Data1] -FROM [Orders] AS [o]"); - } - public override async Task Where_compare_constructed_multi_value_equal(bool async) { await base.Where_compare_constructed_multi_value_equal(async); @@ -1723,18 +1710,6 @@ FROM [Customers] AS [c] WHERE [c].[City] IN (N'Seattle')"); } - public override async Task Project_non_nullable_value_after_FirstOrDefault_on_empty_collection(bool async) - { - await base.Project_non_nullable_value_after_FirstOrDefault_on_empty_collection(async); - - AssertSql( - @"SELECT ( - SELECT TOP(1) CAST(LEN([o].[CustomerID]) AS int) - FROM [Orders] AS [o] - WHERE [o].[CustomerID] = N'John Doe') -FROM [Customers] AS [c]"); - } - public override async Task Filter_non_nullable_value_after_FirstOrDefault_on_empty_collection(bool async) { await base.Filter_non_nullable_value_after_FirstOrDefault_on_empty_collection(async); @@ -1779,5 +1754,11 @@ SELECT [c].[CustomerID] FROM [Customers] AS [c] WHERE ((CAST(@__i_0 AS nchar(5)) + [c].[CustomerID]) + CAST(@__i_0 AS nchar(5))) = [c].[CompanyName]"); } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs new file mode 100644 index 00000000000..3c23a1a82a2 --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs @@ -0,0 +1,61 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class NorthwindAggregateOperatorsQuerySqliteTest : NorthwindAggregateOperatorsQueryTestBase> + { + public NorthwindAggregateOperatorsQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + // SQLite client-eval + public override async Task Sum_with_division_on_decimal(bool async) + { + Assert.StartsWith( + "The LINQ expression", + (await Assert.ThrowsAsync( + () => base.Sum_with_division_on_decimal(async))) + .Message); + } + + // 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); + } + + // 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); + } + + // 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); + } + } +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/SimpleQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs similarity index 53% rename from test/EFCore.Sqlite.FunctionalTests/Query/SimpleQuerySqliteTest.cs rename to test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs index 18967fd5555..6050ea6059e 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/SimpleQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs @@ -1,66 +1,23 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public class SimpleQuerySqliteTest : SimpleQueryTestBase> + public class NorthwindFunctionsQuerySqliteTest : NorthwindFunctionsQueryTestBase> { - // ReSharper disable once UnusedParameter.Local - public SimpleQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindFunctionsQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { - Fixture.TestSqlLoggerFactory.Clear(); + ClearLog(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - // SQLite client-eval - public override async Task Sum_with_division_on_decimal(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Sum_with_division_on_decimal(async))) - .Message); - } - - // 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); - } - - // 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); - } - - // 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); - } - // SQLite client-eval public override async Task Convert_ToByte(bool async) { @@ -161,36 +118,6 @@ public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice3(bo .Message); } - // SQLite client-eval - public override async Task Query_expression_with_to_string_and_contains(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Query_expression_with_to_string_and_contains(async))) - .Message); - } - - // SQLite client-eval - public override async Task Where_datetimeoffset_now_component(bool async) - { - Assert.StartsWith( - "The LINQ expression", - (await Assert.ThrowsAsync( - () => base.Where_datetimeoffset_now_component(async))) - .Message); - } - - // 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); - } - // SQLite client-eval public override async Task Where_functions_nested(bool async) { @@ -421,152 +348,6 @@ public override async Task Where_math_truncate(bool async) .Message); } - public override async Task Take_Skip(bool async) - { - await base.Take_Skip(async); - - AssertSql( - @"@__p_0='10' (DbType = String) -@__p_1='5' (DbType = String) - -SELECT ""t"".""CustomerID"", ""t"".""Address"", ""t"".""City"", ""t"".""CompanyName"", ""t"".""ContactName"", ""t"".""ContactTitle"", ""t"".""Country"", ""t"".""Fax"", ""t"".""Phone"", ""t"".""PostalCode"", ""t"".""Region"" -FROM ( - SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" - FROM ""Customers"" AS ""c"" - ORDER BY ""c"".""ContactName"" - LIMIT @__p_0 -) AS ""t"" -ORDER BY ""t"".""ContactName"" -LIMIT -1 OFFSET @__p_1"); - } - - public override async Task Where_datetime_now(bool async) - { - await base.Where_datetime_now(async); - - AssertSql( - @"@__myDatetime_0='2015-04-10T00:00:00' (DbType = String) - -SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" -FROM ""Customers"" AS ""c"" -WHERE (rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime'), '0'), '.') <> @__myDatetime_0) OR rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime'), '0'), '.') IS NULL"); - } - - public override async Task Where_datetime_utcnow(bool async) - { - await base.Where_datetime_utcnow(async); - - AssertSql( - @"@__myDatetime_0='2015-04-10T00:00:00' (DbType = String) - -SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" -FROM ""Customers"" AS ""c"" -WHERE (rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now'), '0'), '.') <> @__myDatetime_0) OR rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now'), '0'), '.') IS NULL"); - } - - public override async Task Where_datetime_today(bool async) - { - await base.Where_datetime_today(async); - - AssertSql( - @"SELECT ""e"".""EmployeeID"", ""e"".""City"", ""e"".""Country"", ""e"".""FirstName"", ""e"".""ReportsTo"", ""e"".""Title"" -FROM ""Employees"" AS ""e"" -WHERE (rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day'), '0'), '.') = rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day'), '0'), '.')) OR rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day'), '0'), '.') IS NULL"); - } - - public override async Task Where_datetime_date_component(bool async) - { - await base.Where_datetime_date_component(async); - - AssertSql( - @"@__myDatetime_0='1998-05-04T00:00:00' (DbType = String) - -SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", 'start of day'), '0'), '.') = @__myDatetime_0"); - } - - public override async Task Where_datetime_year_component(bool async) - { - await base.Where_datetime_year_component(async); - - AssertSql( - @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE CAST(strftime('%Y', ""o"".""OrderDate"") AS INTEGER) = 1998"); - } - - public override async Task Where_datetime_month_component(bool async) - { - await base.Where_datetime_month_component(async); - - AssertSql( - @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE CAST(strftime('%m', ""o"".""OrderDate"") AS INTEGER) = 4"); - } - - public override async Task Where_datetime_dayOfYear_component(bool async) - { - await base.Where_datetime_dayOfYear_component(async); - - AssertSql( - @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE CAST(strftime('%j', ""o"".""OrderDate"") AS INTEGER) = 68"); - } - - public override async Task Where_datetime_day_component(bool async) - { - await base.Where_datetime_day_component(async); - - AssertSql( - @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE CAST(strftime('%d', ""o"".""OrderDate"") AS INTEGER) = 4"); - } - - public override async Task Where_datetime_hour_component(bool async) - { - await base.Where_datetime_hour_component(async); - - AssertSql( - @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE CAST(strftime('%H', ""o"".""OrderDate"") AS INTEGER) = 14"); - } - - public override async Task Where_datetime_minute_component(bool async) - { - await base.Where_datetime_minute_component(async); - - AssertSql( - @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE CAST(strftime('%M', ""o"".""OrderDate"") AS INTEGER) = 23"); - } - - public override async Task Where_datetime_second_component(bool async) - { - await base.Where_datetime_second_component(async); - - AssertSql( - @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE CAST(strftime('%S', ""o"".""OrderDate"") AS INTEGER) = 44"); - } - - [ConditionalTheory(Skip = "Issue#15586")] - public override async Task Where_datetime_millisecond_component(bool async) - { - await base.Where_datetime_millisecond_component(async); - - AssertSql( - @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE ((CAST(strftime('%f', ""o"".""OrderDate"") AS REAL) * 1000) % 1000) = 88"); - } - public override async Task String_StartsWith_Literal(bool async) { await base.String_StartsWith_Literal(async); @@ -697,26 +478,6 @@ public override async Task IsNullOrWhiteSpace_in_predicate(bool async) WHERE ""c"".""Region"" IS NULL OR (trim(""c"".""Region"") = '')"); } - public override async Task Where_string_length(bool async) - { - await base.Where_string_length(async); - - AssertSql( - @"SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" -FROM ""Customers"" AS ""c"" -WHERE length(""c"".""City"") = 6"); - } - - public override async Task Where_string_indexof(bool async) - { - await base.Where_string_indexof(async); - - AssertSql( - @"SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" -FROM ""Customers"" AS ""c"" -WHERE ((instr(""c"".""City"", 'Sea') - 1) <> -1) OR instr(""c"".""City"", 'Sea') IS NULL"); - } - public override async Task Indexof_with_emptystring(bool async) { await base.Indexof_with_emptystring(async); @@ -727,15 +488,6 @@ public override async Task Indexof_with_emptystring(bool async) WHERE ""c"".""CustomerID"" = 'ALFKI'"); } - public override async Task Where_string_replace(bool async) - { - await base.Where_string_replace(async); - - AssertSql( - @"SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" -FROM ""Customers"" AS ""c"" -WHERE replace(""c"".""City"", 'Sea', 'Rea') = 'Reattle'"); - } public override async Task Replace_with_emptystring(bool async) { @@ -747,16 +499,6 @@ public override async Task Replace_with_emptystring(bool async) WHERE ""c"".""CustomerID"" = 'ALFKI'"); } - public override async Task Where_string_substring(bool async) - { - await base.Where_string_substring(async); - - AssertSql( - @"SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" -FROM ""Customers"" AS ""c"" -WHERE substr(""c"".""City"", 1 + 1, 2) = 'ea'"); - } - public override async Task Substring_with_zero_startindex(bool async) { await base.Substring_with_zero_startindex(async); @@ -979,370 +721,6 @@ public override async Task Trim_with_char_array_argument_in_predicate(bool async WHERE trim(""c"".""ContactTitle"", 'Or') = 'wne'"); } - public override async Task Select_datetime_year_component(bool async) - { - await base.Select_datetime_year_component(async); - - AssertSql( - @"SELECT CAST(strftime('%Y', ""o"".""OrderDate"") AS INTEGER) -FROM ""Orders"" AS ""o"""); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Select_datetime_year_component_composed(bool async) - { - await AssertQueryScalar( - async, - ss => ss.Set().Select(o => o.OrderDate.Value.AddYears(1).Year)); - - AssertSql( - @"SELECT CAST(strftime('%Y', ""o"".""OrderDate"", CAST(1 AS TEXT) || ' years') AS INTEGER) -FROM ""Orders"" AS ""o"""); - } - - public override async Task Select_datetime_month_component(bool async) - { - await base.Select_datetime_month_component(async); - - AssertSql( - @"SELECT CAST(strftime('%m', ""o"".""OrderDate"") AS INTEGER) -FROM ""Orders"" AS ""o"""); - } - - public override async Task Select_datetime_day_of_year_component(bool async) - { - await base.Select_datetime_day_of_year_component(async); - - AssertSql( - @"SELECT CAST(strftime('%j', ""o"".""OrderDate"") AS INTEGER) -FROM ""Orders"" AS ""o"""); - } - - public override async Task Select_datetime_day_component(bool async) - { - await base.Select_datetime_day_component(async); - - AssertSql( - @"SELECT CAST(strftime('%d', ""o"".""OrderDate"") AS INTEGER) -FROM ""Orders"" AS ""o"""); - } - - public override async Task Select_datetime_hour_component(bool async) - { - await base.Select_datetime_hour_component(async); - - AssertSql( - @"SELECT CAST(strftime('%H', ""o"".""OrderDate"") AS INTEGER) -FROM ""Orders"" AS ""o"""); - } - - public override async Task Select_datetime_minute_component(bool async) - { - await base.Select_datetime_minute_component(async); - - AssertSql( - @"SELECT CAST(strftime('%M', ""o"".""OrderDate"") AS INTEGER) -FROM ""Orders"" AS ""o"""); - } - - public override async Task Select_datetime_second_component(bool async) - { - await base.Select_datetime_second_component(async); - - AssertSql( - @"SELECT CAST(strftime('%S', ""o"".""OrderDate"") AS INTEGER) -FROM ""Orders"" AS ""o"""); - } - - public override async Task Select_datetime_millisecond_component(bool async) - { - await base.Select_datetime_millisecond_component(async); - - AssertSql( - @"SELECT (CAST(strftime('%f', ""o"".""OrderDate"") AS REAL) * 1000.0) % 1000.0 -FROM ""Orders"" AS ""o"""); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Select_datetime_millisecond_component_composed(bool async) - { - await AssertQueryScalar( - async, - ss => ss.Set().Select(o => o.OrderDate.Value.AddYears(1).Millisecond)); - - AssertSql( - @"SELECT (CAST(strftime('%f', ""o"".""OrderDate"", CAST(1 AS TEXT) || ' years') AS REAL) * 1000.0) % 1000.0 -FROM ""Orders"" AS ""o"""); - } - - public override async Task Select_datetime_DayOfWeek_component(bool async) - { - await base.Select_datetime_DayOfWeek_component(async); - - AssertSql( - @"SELECT CAST(CAST(strftime('%w', ""o"".""OrderDate"") AS INTEGER) AS INTEGER) -FROM ""Orders"" AS ""o"""); - } - - public override async Task Select_datetime_Ticks_component(bool async) - { - await base.Select_datetime_Ticks_component(async); - - AssertSql( - @"SELECT CAST(((julianday(""o"".""OrderDate"") - 1721425.5) * 864000000000.0) AS INTEGER) -FROM ""Orders"" AS ""o"""); - } - - public override async Task Select_datetime_TimeOfDay_component(bool async) - { - await base.Select_datetime_TimeOfDay_component(async); - - AssertSql( - @"SELECT rtrim(rtrim(strftime('%H:%M:%f', ""o"".""OrderDate""), '0'), '.') -FROM ""Orders"" AS ""o"""); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Select_datetime_TimeOfDay_component_composed(bool async) - { - await AssertQueryScalar( - async, - ss => ss.Set().Select(o => o.OrderDate.Value.AddYears(1).TimeOfDay)); - - AssertSql( - @"SELECT rtrim(rtrim(strftime('%H:%M:%f', ""o"".""OrderDate"", CAST(1 AS TEXT) || ' years'), '0'), '.') -FROM ""Orders"" AS ""o"""); - } - - public override async Task Select_expression_date_add_year(bool async) - { - await base.Select_expression_date_add_year(async); - - AssertSql( - @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST(1 AS TEXT) || ' years'), '0'), '.') AS ""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE ""o"".""OrderDate"" IS NOT NULL"); - } - - public override async Task Select_expression_datetime_add_month(bool async) - { - await base.Select_expression_datetime_add_month(async); - - AssertSql( - @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST(1 AS TEXT) || ' months'), '0'), '.') AS ""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE ""o"".""OrderDate"" IS NOT NULL"); - } - - public override async Task Select_expression_datetime_add_hour(bool async) - { - await base.Select_expression_datetime_add_hour(async); - - AssertSql( - @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST(1.0 AS TEXT) || ' hours'), '0'), '.') AS ""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE ""o"".""OrderDate"" IS NOT NULL"); - } - - public override async Task Select_expression_datetime_add_minute(bool async) - { - await base.Select_expression_datetime_add_minute(async); - - AssertSql( - @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST(1.0 AS TEXT) || ' minutes'), '0'), '.') AS ""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE ""o"".""OrderDate"" IS NOT NULL"); - } - - public override async Task Select_expression_datetime_add_second(bool async) - { - await base.Select_expression_datetime_add_second(async); - - AssertSql( - @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST(1.0 AS TEXT) || ' seconds'), '0'), '.') AS ""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE ""o"".""OrderDate"" IS NOT NULL"); - } - - public override async Task Select_expression_datetime_add_ticks(bool async) - { - await base.Select_expression_datetime_add_ticks(async); - - AssertSql( - @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST((10000 / 864000000000) AS TEXT) || ' seconds'), '0'), '.') AS ""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE ""o"".""OrderDate"" IS NOT NULL"); - } - - public override async Task Select_expression_date_add_milliseconds_above_the_range(bool async) - { - await base.Select_expression_date_add_milliseconds_above_the_range(async); - - AssertSql( - @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST((1000000000000.0 / 1000.0) AS TEXT) || ' seconds'), '0'), '.') AS ""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE ""o"".""OrderDate"" IS NOT NULL"); - } - - public override async Task Select_expression_date_add_milliseconds_below_the_range(bool async) - { - await base.Select_expression_date_add_milliseconds_below_the_range(async); - - AssertSql( - @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST((-1000000000000.0 / 1000.0) AS TEXT) || ' seconds'), '0'), '.') AS ""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE ""o"".""OrderDate"" IS NOT NULL"); - } - - public override async Task Select_expression_date_add_milliseconds_large_number_divided(bool async) - { - await base.Select_expression_date_add_milliseconds_large_number_divided(async); - - AssertSql( - @"@__millisecondsPerDay_0='86400000' (DbType = String) - -SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST(CAST((CAST(((CAST(strftime('%f', ""o"".""OrderDate"") AS REAL) * 1000.0) % 1000.0) AS INTEGER) / @__millisecondsPerDay_0) AS REAL) AS TEXT) || ' days', CAST((CAST((CAST(((CAST(strftime('%f', ""o"".""OrderDate"") AS REAL) * 1000.0) % 1000.0) AS INTEGER) % @__millisecondsPerDay_0) AS REAL) / 1000.0) AS TEXT) || ' seconds'), '0'), '.') AS ""OrderDate"" -FROM ""Orders"" AS ""o"" -WHERE ""o"".""OrderDate"" IS NOT NULL"); - } - - public override async Task Decimal_cast_to_double_works(bool async) - { - await base.Decimal_cast_to_double_works(async); - - AssertSql( - @"SELECT ""p"".""ProductID"", ""p"".""Discontinued"", ""p"".""ProductName"", ""p"".""SupplierID"", ""p"".""UnitPrice"", ""p"".""UnitsInStock"" -FROM ""Products"" AS ""p"" -WHERE CAST(""p"".""UnitPrice"" AS REAL) > 100.0"); - } - - public override async Task Select_distinct_long_count(bool async) - { - await base.Select_distinct_long_count(async); - - AssertSql( - @"SELECT COUNT(*) -FROM ( - SELECT DISTINCT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" - FROM ""Customers"" AS ""c"" -) AS ""t"""); - } - - public override async Task Select_orderBy_skip_long_count(bool async) - { - await base.Select_orderBy_skip_long_count(async); - - AssertSql( - @"@__p_0='7' (DbType = String) - -SELECT COUNT(*) -FROM ( - SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" - FROM ""Customers"" AS ""c"" - ORDER BY ""c"".""Country"" - LIMIT -1 OFFSET @__p_0 -) AS ""t"""); - } - - public override async Task Select_orderBy_take_long_count(bool async) - { - await base.Select_orderBy_take_long_count(async); - - AssertSql( - @"@__p_0='7' (DbType = String) - -SELECT COUNT(*) -FROM ( - SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" - FROM ""Customers"" AS ""c"" - ORDER BY ""c"".""Country"" - LIMIT @__p_0 -) AS ""t"""); - } - - public override async Task Select_skip_long_count(bool async) - { - await base.Select_skip_long_count(async); - - AssertSql( - @"@__p_0='7' (DbType = String) - -SELECT COUNT(*) -FROM ( - SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" - FROM ""Customers"" AS ""c"" - ORDER BY (SELECT 1) - LIMIT -1 OFFSET @__p_0 -) AS ""t"""); - } - - public override async Task Select_take_long_count(bool async) - { - await base.Select_take_long_count(async); - - AssertSql( - @"@__p_0='7' (DbType = String) - -SELECT COUNT(*) -FROM ( - SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" - FROM ""Customers"" AS ""c"" - LIMIT @__p_0 -) AS ""t"""); - } - - [ConditionalTheory(Skip = "SQLite bug")] - public override Task Project_single_element_from_collection_with_multiple_OrderBys_Take_and_FirstOrDefault_2(bool async) - => base.Project_single_element_from_collection_with_multiple_OrderBys_Take_and_FirstOrDefault_2(async); - - // Sqlite does not support cross/outer apply - public override void Select_nested_collection_multi_level() - { - } - - public override Task SelectMany_correlated_with_outer_1(bool async) => null; - - public override Task SelectMany_correlated_with_outer_2(bool async) => null; - - public override Task SelectMany_correlated_with_outer_3(bool async) => null; - - public override Task SelectMany_correlated_with_outer_4(bool async) => null; - - public override Task Complex_nested_query_doesnt_try_binding_to_grandparent_when_parent_returns_complex_result(bool async) - => null; - - public override Task SelectMany_correlated_subquery_hard(bool async) => null; - - public override Task SelectMany_whose_selector_references_outer_source(bool async) => null; - - public override Task AsQueryable_in_query_server_evals(bool async) => null; - - [ConditionalTheory(Skip = "Issue#17324")] - public override Task Project_single_element_from_collection_with_OrderBy_over_navigation_Take_and_FirstOrDefault_2(bool async) - { - return base.Project_single_element_from_collection_with_OrderBy_over_navigation_Take_and_FirstOrDefault_2(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); - } - - public override Task Member_binding_after_ctor_arguments_fails_with_client_eval(bool async) - { - return AssertTranslationFailed(() => base.Member_binding_after_ctor_arguments_fails_with_client_eval(async)); - } - - [ConditionalTheory(Skip = "Issue#17230")] - public override Task SelectMany_with_collection_being_correlated_subquery_which_references_inner_and_outer_entity(bool async) - { - return base.SelectMany_with_collection_being_correlated_subquery_which_references_inner_and_outer_entity(async); - } - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs new file mode 100644 index 00000000000..dd233cfa219 --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs @@ -0,0 +1,258 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class NorthwindMiscellaneousQuerySqliteTest : NorthwindMiscellaneousQueryTestBase> + { + // ReSharper disable once UnusedParameter.Local + public NorthwindMiscellaneousQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + + // SQLite client-eval + public override async Task Query_expression_with_to_string_and_contains(bool async) + { + Assert.StartsWith( + "The LINQ expression", + (await Assert.ThrowsAsync( + () => base.Query_expression_with_to_string_and_contains(async))) + .Message); + } + + + public override async Task Take_Skip(bool async) + { + await base.Take_Skip(async); + + AssertSql( + @"@__p_0='10' (DbType = String) +@__p_1='5' (DbType = String) + +SELECT ""t"".""CustomerID"", ""t"".""Address"", ""t"".""City"", ""t"".""CompanyName"", ""t"".""ContactName"", ""t"".""ContactTitle"", ""t"".""Country"", ""t"".""Fax"", ""t"".""Phone"", ""t"".""PostalCode"", ""t"".""Region"" +FROM ( + SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" + FROM ""Customers"" AS ""c"" + ORDER BY ""c"".""ContactName"" + LIMIT @__p_0 +) AS ""t"" +ORDER BY ""t"".""ContactName"" +LIMIT -1 OFFSET @__p_1"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Select_datetime_millisecond_component_composed(bool async) + { + await AssertQueryScalar( + async, + ss => ss.Set().Select(o => o.OrderDate.Value.AddYears(1).Millisecond)); + + AssertSql( + @"SELECT (CAST(strftime('%f', ""o"".""OrderDate"", CAST(1 AS TEXT) || ' years') AS REAL) * 1000.0) % 1000.0 +FROM ""Orders"" AS ""o"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Select_datetime_TimeOfDay_component_composed(bool async) + { + await AssertQueryScalar( + async, + ss => ss.Set().Select(o => o.OrderDate.Value.AddYears(1).TimeOfDay)); + + AssertSql( + @"SELECT rtrim(rtrim(strftime('%H:%M:%f', ""o"".""OrderDate"", CAST(1 AS TEXT) || ' years'), '0'), '.') +FROM ""Orders"" AS ""o"""); + } + + public override async Task Select_expression_date_add_year(bool async) + { + await base.Select_expression_date_add_year(async); + + AssertSql( + @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST(1 AS TEXT) || ' years'), '0'), '.') AS ""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE ""o"".""OrderDate"" IS NOT NULL"); + } + + public override async Task Select_expression_datetime_add_month(bool async) + { + await base.Select_expression_datetime_add_month(async); + + AssertSql( + @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST(1 AS TEXT) || ' months'), '0'), '.') AS ""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE ""o"".""OrderDate"" IS NOT NULL"); + } + + public override async Task Select_expression_datetime_add_hour(bool async) + { + await base.Select_expression_datetime_add_hour(async); + + AssertSql( + @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST(1.0 AS TEXT) || ' hours'), '0'), '.') AS ""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE ""o"".""OrderDate"" IS NOT NULL"); + } + + public override async Task Select_expression_datetime_add_minute(bool async) + { + await base.Select_expression_datetime_add_minute(async); + + AssertSql( + @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST(1.0 AS TEXT) || ' minutes'), '0'), '.') AS ""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE ""o"".""OrderDate"" IS NOT NULL"); + } + + public override async Task Select_expression_datetime_add_second(bool async) + { + await base.Select_expression_datetime_add_second(async); + + AssertSql( + @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST(1.0 AS TEXT) || ' seconds'), '0'), '.') AS ""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE ""o"".""OrderDate"" IS NOT NULL"); + } + + public override async Task Select_expression_datetime_add_ticks(bool async) + { + await base.Select_expression_datetime_add_ticks(async); + + AssertSql( + @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST((10000 / 864000000000) AS TEXT) || ' seconds'), '0'), '.') AS ""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE ""o"".""OrderDate"" IS NOT NULL"); + } + + public override async Task Select_expression_date_add_milliseconds_above_the_range(bool async) + { + await base.Select_expression_date_add_milliseconds_above_the_range(async); + + AssertSql( + @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST((1000000000000.0 / 1000.0) AS TEXT) || ' seconds'), '0'), '.') AS ""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE ""o"".""OrderDate"" IS NOT NULL"); + } + + public override async Task Select_expression_date_add_milliseconds_below_the_range(bool async) + { + await base.Select_expression_date_add_milliseconds_below_the_range(async); + + AssertSql( + @"SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST((-1000000000000.0 / 1000.0) AS TEXT) || ' seconds'), '0'), '.') AS ""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE ""o"".""OrderDate"" IS NOT NULL"); + } + + public override async Task Select_expression_date_add_milliseconds_large_number_divided(bool async) + { + await base.Select_expression_date_add_milliseconds_large_number_divided(async); + + AssertSql( + @"@__millisecondsPerDay_0='86400000' (DbType = String) + +SELECT rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", CAST(CAST((CAST(((CAST(strftime('%f', ""o"".""OrderDate"") AS REAL) * 1000.0) % 1000.0) AS INTEGER) / @__millisecondsPerDay_0) AS REAL) AS TEXT) || ' days', CAST((CAST((CAST(((CAST(strftime('%f', ""o"".""OrderDate"") AS REAL) * 1000.0) % 1000.0) AS INTEGER) % @__millisecondsPerDay_0) AS REAL) / 1000.0) AS TEXT) || ' seconds'), '0'), '.') AS ""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE ""o"".""OrderDate"" IS NOT NULL"); + } + + public override async Task Select_distinct_long_count(bool async) + { + await base.Select_distinct_long_count(async); + + AssertSql( + @"SELECT COUNT(*) +FROM ( + SELECT DISTINCT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" + FROM ""Customers"" AS ""c"" +) AS ""t"""); + } + + public override async Task Select_orderBy_skip_long_count(bool async) + { + await base.Select_orderBy_skip_long_count(async); + + AssertSql( + @"@__p_0='7' (DbType = String) + +SELECT COUNT(*) +FROM ( + SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" + FROM ""Customers"" AS ""c"" + ORDER BY ""c"".""Country"" + LIMIT -1 OFFSET @__p_0 +) AS ""t"""); + } + + public override async Task Select_orderBy_take_long_count(bool async) + { + await base.Select_orderBy_take_long_count(async); + + AssertSql( + @"@__p_0='7' (DbType = String) + +SELECT COUNT(*) +FROM ( + SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" + FROM ""Customers"" AS ""c"" + ORDER BY ""c"".""Country"" + LIMIT @__p_0 +) AS ""t"""); + } + + public override async Task Select_skip_long_count(bool async) + { + await base.Select_skip_long_count(async); + + AssertSql( + @"@__p_0='7' (DbType = String) + +SELECT COUNT(*) +FROM ( + SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" + FROM ""Customers"" AS ""c"" + ORDER BY (SELECT 1) + LIMIT -1 OFFSET @__p_0 +) AS ""t"""); + } + + public override async Task Select_take_long_count(bool async) + { + await base.Select_take_long_count(async); + + AssertSql( + @"@__p_0='7' (DbType = String) + +SELECT COUNT(*) +FROM ( + SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" + FROM ""Customers"" AS ""c"" + LIMIT @__p_0 +) AS ""t"""); + } + + public override Task Complex_nested_query_doesnt_try_binding_to_grandparent_when_parent_returns_complex_result(bool async) + => null; + + public override Task SelectMany_correlated_subquery_hard(bool async) => null; + + public override Task AsQueryable_in_query_server_evals(bool async) => null; + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + } +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSelectQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSelectQuerySqliteTest.cs new file mode 100644 index 00000000000..162a869e0ab --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSelectQuerySqliteTest.cs @@ -0,0 +1,174 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class NorthwindSelectQuerySqliteTest : NorthwindSelectQueryTestBase> + { + public NorthwindSelectQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Select_datetime_year_component(bool async) + { + await base.Select_datetime_year_component(async); + + AssertSql( + @"SELECT CAST(strftime('%Y', ""o"".""OrderDate"") AS INTEGER) +FROM ""Orders"" AS ""o"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Select_datetime_year_component_composed(bool async) + { + await AssertQueryScalar( + async, + ss => ss.Set().Select(o => o.OrderDate.Value.AddYears(1).Year)); + + AssertSql( + @"SELECT CAST(strftime('%Y', ""o"".""OrderDate"", CAST(1 AS TEXT) || ' years') AS INTEGER) +FROM ""Orders"" AS ""o"""); + } + + public override async Task Select_datetime_month_component(bool async) + { + await base.Select_datetime_month_component(async); + + AssertSql( + @"SELECT CAST(strftime('%m', ""o"".""OrderDate"") AS INTEGER) +FROM ""Orders"" AS ""o"""); + } + + public override async Task Select_datetime_day_of_year_component(bool async) + { + await base.Select_datetime_day_of_year_component(async); + + AssertSql( + @"SELECT CAST(strftime('%j', ""o"".""OrderDate"") AS INTEGER) +FROM ""Orders"" AS ""o"""); + } + + public override async Task Select_datetime_day_component(bool async) + { + await base.Select_datetime_day_component(async); + + AssertSql( + @"SELECT CAST(strftime('%d', ""o"".""OrderDate"") AS INTEGER) +FROM ""Orders"" AS ""o"""); + } + + public override async Task Select_datetime_hour_component(bool async) + { + await base.Select_datetime_hour_component(async); + + AssertSql( + @"SELECT CAST(strftime('%H', ""o"".""OrderDate"") AS INTEGER) +FROM ""Orders"" AS ""o"""); + } + + public override async Task Select_datetime_minute_component(bool async) + { + await base.Select_datetime_minute_component(async); + + AssertSql( + @"SELECT CAST(strftime('%M', ""o"".""OrderDate"") AS INTEGER) +FROM ""Orders"" AS ""o"""); + } + + public override async Task Select_datetime_second_component(bool async) + { + await base.Select_datetime_second_component(async); + + AssertSql( + @"SELECT CAST(strftime('%S', ""o"".""OrderDate"") AS INTEGER) +FROM ""Orders"" AS ""o"""); + } + + public override async Task Select_datetime_millisecond_component(bool async) + { + await base.Select_datetime_millisecond_component(async); + + AssertSql( + @"SELECT (CAST(strftime('%f', ""o"".""OrderDate"") AS REAL) * 1000.0) % 1000.0 +FROM ""Orders"" AS ""o"""); + } + + public override async Task Select_datetime_DayOfWeek_component(bool async) + { + await base.Select_datetime_DayOfWeek_component(async); + + AssertSql( + @"SELECT CAST(CAST(strftime('%w', ""o"".""OrderDate"") AS INTEGER) AS INTEGER) +FROM ""Orders"" AS ""o"""); + } + + public override async Task Select_datetime_Ticks_component(bool async) + { + await base.Select_datetime_Ticks_component(async); + + AssertSql( + @"SELECT CAST(((julianday(""o"".""OrderDate"") - 1721425.5) * 864000000000.0) AS INTEGER) +FROM ""Orders"" AS ""o"""); + } + + public override async Task Select_datetime_TimeOfDay_component(bool async) + { + await base.Select_datetime_TimeOfDay_component(async); + + AssertSql( + @"SELECT rtrim(rtrim(strftime('%H:%M:%f', ""o"".""OrderDate""), '0'), '.') +FROM ""Orders"" AS ""o"""); + } + + [ConditionalTheory(Skip = "SQLite bug")] + public override Task Project_single_element_from_collection_with_multiple_OrderBys_Take_and_FirstOrDefault_2(bool async) + => base.Project_single_element_from_collection_with_multiple_OrderBys_Take_and_FirstOrDefault_2(async); + + // Sqlite does not support cross/outer apply + public override void Select_nested_collection_multi_level() + { + } + + public override Task SelectMany_correlated_with_outer_1(bool async) => null; + + public override Task SelectMany_correlated_with_outer_2(bool async) => null; + + public override Task SelectMany_correlated_with_outer_3(bool async) => null; + + public override Task SelectMany_correlated_with_outer_4(bool async) => null; + + public override Task SelectMany_whose_selector_references_outer_source(bool async) => null; + + [ConditionalTheory(Skip = "Issue#17324")] + public override Task Project_single_element_from_collection_with_OrderBy_over_navigation_Take_and_FirstOrDefault_2(bool async) + { + return base.Project_single_element_from_collection_with_OrderBy_over_navigation_Take_and_FirstOrDefault_2(async); + } + + public override Task Member_binding_after_ctor_arguments_fails_with_client_eval(bool async) + { + return AssertTranslationFailed(() => base.Member_binding_after_ctor_arguments_fails_with_client_eval(async)); + } + + [ConditionalTheory(Skip = "Issue#17230")] + public override Task SelectMany_with_collection_being_correlated_subquery_which_references_inner_and_outer_entity(bool async) + { + return base.SelectMany_with_collection_being_correlated_subquery_which_references_inner_and_outer_entity(async); + } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + } +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs new file mode 100644 index 00000000000..28b72801742 --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs @@ -0,0 +1,227 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class NorthwindWhereQuerySqliteTest : NorthwindWhereQueryTestBase> + { + public NorthwindWhereQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + // SQLite client-eval + public override async Task Where_datetimeoffset_now_component(bool async) + { + Assert.StartsWith( + "The LINQ expression", + (await Assert.ThrowsAsync( + () => base.Where_datetimeoffset_now_component(async))) + .Message); + } + + // 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 async Task Where_datetime_now(bool async) + { + await base.Where_datetime_now(async); + + AssertSql( + @"@__myDatetime_0='2015-04-10T00:00:00' (DbType = String) + +SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" +FROM ""Customers"" AS ""c"" +WHERE (rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime'), '0'), '.') <> @__myDatetime_0) OR rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime'), '0'), '.') IS NULL"); + } + + public override async Task Where_datetime_utcnow(bool async) + { + await base.Where_datetime_utcnow(async); + + AssertSql( + @"@__myDatetime_0='2015-04-10T00:00:00' (DbType = String) + +SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" +FROM ""Customers"" AS ""c"" +WHERE (rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now'), '0'), '.') <> @__myDatetime_0) OR rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now'), '0'), '.') IS NULL"); + } + + public override async Task Where_datetime_today(bool async) + { + await base.Where_datetime_today(async); + + AssertSql( + @"SELECT ""e"".""EmployeeID"", ""e"".""City"", ""e"".""Country"", ""e"".""FirstName"", ""e"".""ReportsTo"", ""e"".""Title"" +FROM ""Employees"" AS ""e"" +WHERE (rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day'), '0'), '.') = rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day'), '0'), '.')) OR rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day'), '0'), '.') IS NULL"); + } + + public override async Task Where_datetime_date_component(bool async) + { + await base.Where_datetime_date_component(async); + + AssertSql( + @"@__myDatetime_0='1998-05-04T00:00:00' (DbType = String) + +SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', ""o"".""OrderDate"", 'start of day'), '0'), '.') = @__myDatetime_0"); + } + + public override async Task Where_datetime_year_component(bool async) + { + await base.Where_datetime_year_component(async); + + AssertSql( + @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE CAST(strftime('%Y', ""o"".""OrderDate"") AS INTEGER) = 1998"); + } + + public override async Task Where_datetime_month_component(bool async) + { + await base.Where_datetime_month_component(async); + + AssertSql( + @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE CAST(strftime('%m', ""o"".""OrderDate"") AS INTEGER) = 4"); + } + + public override async Task Where_datetime_dayOfYear_component(bool async) + { + await base.Where_datetime_dayOfYear_component(async); + + AssertSql( + @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE CAST(strftime('%j', ""o"".""OrderDate"") AS INTEGER) = 68"); + } + + public override async Task Where_datetime_day_component(bool async) + { + await base.Where_datetime_day_component(async); + + AssertSql( + @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE CAST(strftime('%d', ""o"".""OrderDate"") AS INTEGER) = 4"); + } + + public override async Task Where_datetime_hour_component(bool async) + { + await base.Where_datetime_hour_component(async); + + AssertSql( + @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE CAST(strftime('%H', ""o"".""OrderDate"") AS INTEGER) = 14"); + } + + public override async Task Where_datetime_minute_component(bool async) + { + await base.Where_datetime_minute_component(async); + + AssertSql( + @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE CAST(strftime('%M', ""o"".""OrderDate"") AS INTEGER) = 23"); + } + + public override async Task Where_datetime_second_component(bool async) + { + await base.Where_datetime_second_component(async); + + AssertSql( + @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE CAST(strftime('%S', ""o"".""OrderDate"") AS INTEGER) = 44"); + } + + [ConditionalTheory(Skip = "Issue#15586")] + public override async Task Where_datetime_millisecond_component(bool async) + { + await base.Where_datetime_millisecond_component(async); + + AssertSql( + @"SELECT ""o"".""OrderID"", ""o"".""CustomerID"", ""o"".""EmployeeID"", ""o"".""OrderDate"" +FROM ""Orders"" AS ""o"" +WHERE ((CAST(strftime('%f', ""o"".""OrderDate"") AS REAL) * 1000) % 1000) = 88"); + } + + public override async Task Where_string_length(bool async) + { + await base.Where_string_length(async); + + AssertSql( + @"SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" +FROM ""Customers"" AS ""c"" +WHERE length(""c"".""City"") = 6"); + } + + public override async Task Where_string_indexof(bool async) + { + await base.Where_string_indexof(async); + + AssertSql( + @"SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" +FROM ""Customers"" AS ""c"" +WHERE ((instr(""c"".""City"", 'Sea') - 1) <> -1) OR instr(""c"".""City"", 'Sea') IS NULL"); + } + + public override async Task Where_string_replace(bool async) + { + await base.Where_string_replace(async); + + AssertSql( + @"SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" +FROM ""Customers"" AS ""c"" +WHERE replace(""c"".""City"", 'Sea', 'Rea') = 'Reattle'"); + } + + public override async Task Where_string_substring(bool async) + { + await base.Where_string_substring(async); + + AssertSql( + @"SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" +FROM ""Customers"" AS ""c"" +WHERE substr(""c"".""City"", 1 + 1, 2) = 'ea'"); + } + + public override async Task Decimal_cast_to_double_works(bool async) + { + await base.Decimal_cast_to_double_works(async); + + AssertSql( + @"SELECT ""p"".""ProductID"", ""p"".""Discontinued"", ""p"".""ProductName"", ""p"".""SupplierID"", ""p"".""UnitPrice"", ""p"".""UnitsInStock"" +FROM ""Products"" AS ""p"" +WHERE CAST(""p"".""UnitPrice"" AS REAL) > 100.0"); + } + + [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); + } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + } +}