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/NorthwindJoinQueryCosmosTest.cs similarity index 91% rename from test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.JoinGroupJoin.cs rename to test/EFCore.Cosmos.FunctionalTests/Query/NorthwindJoinQueryCosmosTest.cs index c9d336134f4..c92175b9ae4 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.JoinGroupJoin.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindJoinQueryCosmosTest.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 NorthwindJoinQueryCosmosTest : NorthwindJoinQueryTestBase> { + public NorthwindJoinQueryCosmosTest( + 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/NorthwindAsNoTrackingQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsNoTrackingQueryInMemoryTest.cs new file mode 100644 index 00000000000..6a70fb8c485 --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsNoTrackingQueryInMemoryTest.cs @@ -0,0 +1,15 @@ +// 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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class NorthwindAsNoTrackingQueryInMemoryTest : NorthwindAsNoTrackingQueryTestBase> + { + public NorthwindAsNoTrackingQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) + : base(fixture) + { + } + } +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/AsNoTrackingSqliteTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsTrackingQueryInMemoryTest.cs similarity index 56% rename from test/EFCore.Sqlite.FunctionalTests/Query/AsNoTrackingSqliteTest.cs rename to test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsTrackingQueryInMemoryTest.cs index 8469e949b02..93eff3058ab 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/AsNoTrackingSqliteTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsTrackingQueryInMemoryTest.cs @@ -5,9 +5,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class AsNoTrackingSqliteTest : AsNoTrackingTestBase> + public class NorthwindAsTrackingQueryInMemoryTest : NorthwindAsTrackingQueryTestBase> { - public AsNoTrackingSqliteTest(NorthwindQuerySqliteFixture fixture) + public NorthwindAsTrackingQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) : base(fixture) { } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/AsyncSimpleQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsyncSimpleQueryInMemoryTest.cs similarity index 71% rename from test/EFCore.InMemory.FunctionalTests/Query/AsyncSimpleQueryInMemoryTest.cs rename to test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsyncSimpleQueryInMemoryTest.cs index 4221946bda0..1f50adc8c12 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/AsyncSimpleQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsyncSimpleQueryInMemoryTest.cs @@ -8,9 +8,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class AsyncSimpleQueryInMemoryTest : AsyncSimpleQueryTestBase> + public class NorthwindAsyncSimpleQueryInMemoryTest : NorthwindAsyncSimpleQueryTestBase> { - public AsyncSimpleQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) + public NorthwindAsyncSimpleQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) : base(fixture) { } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/ChangeTrackingInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindChangeTrackingQueryInMemoryTest.cs similarity index 58% rename from test/EFCore.InMemory.FunctionalTests/Query/ChangeTrackingInMemoryTest.cs rename to test/EFCore.InMemory.FunctionalTests/Query/NorthwindChangeTrackingQueryInMemoryTest.cs index 5fa20887545..6f8a2d3abea 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/ChangeTrackingInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindChangeTrackingQueryInMemoryTest.cs @@ -6,9 +6,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class ChangeTrackingInMemoryTest : ChangeTrackingTestBase> + public class NorthwindChangeTrackingQueryInMemoryTest : NorthwindChangeTrackingQueryTestBase> { - public ChangeTrackingInMemoryTest(NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindChangeTrackingQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { //TestLoggerFactory.TestOutputHelper = testOutputHelper; diff --git a/test/EFCore.InMemory.FunctionalTests/Query/CompiledQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindCompiledQueryInMemoryTest.cs similarity index 71% rename from test/EFCore.InMemory.FunctionalTests/Query/CompiledQueryInMemoryTest.cs rename to test/EFCore.InMemory.FunctionalTests/Query/NorthwindCompiledQueryInMemoryTest.cs index b1b5ce5456b..cb8179dd939 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/CompiledQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindCompiledQueryInMemoryTest.cs @@ -7,9 +7,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class CompiledQueryInMemoryTest : CompiledQueryTestBase> + public class NorthwindCompiledQueryInMemoryTest : NorthwindCompiledQueryTestBase> { - public CompiledQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) + public NorthwindCompiledQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) : base(fixture) { } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/DbFunctionsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindDbFunctionsQueryInMemoryTest.cs similarity index 59% rename from test/EFCore.InMemory.FunctionalTests/Query/DbFunctionsInMemoryTest.cs rename to test/EFCore.InMemory.FunctionalTests/Query/NorthwindDbFunctionsQueryInMemoryTest.cs index a8baeb17f29..b9e691000ba 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/DbFunctionsInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindDbFunctionsQueryInMemoryTest.cs @@ -6,9 +6,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class DbFunctionsInMemoryTest : DbFunctionsTestBase> + public class NorthwindDbFunctionsQueryInMemoryTest : NorthwindDbFunctionsQueryTestBase> { - public DbFunctionsInMemoryTest(NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindDbFunctionsQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { //TestSqlLoggerFactory.CaptureOutput(testOutputHelper); diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindFunctionsQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindFunctionsQueryInMemoryTest.cs new file mode 100644 index 00000000000..d7ccaaeaf3b --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindFunctionsQueryInMemoryTest.cs @@ -0,0 +1,24 @@ +// 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 NorthwindFunctionsQueryInMemoryTest : NorthwindFunctionsQueryTestBase> + { + public NorthwindFunctionsQueryInMemoryTest( + NorthwindQueryInMemoryFixture fixture, +#pragma warning disable IDE0060 // Remove unused parameter + ITestOutputHelper testOutputHelper) +#pragma warning restore IDE0060 // Remove unused parameter + : base(fixture) + { + //TestLoggerFactory.TestOutputHelper = testOutputHelper; + } + } +} diff --git a/test/EFCore.InMemory.FunctionalTests/Query/GroupByQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindGroupByQueryInMemoryTest.cs similarity index 76% rename from test/EFCore.InMemory.FunctionalTests/Query/GroupByQueryInMemoryTest.cs rename to test/EFCore.InMemory.FunctionalTests/Query/NorthwindGroupByQueryInMemoryTest.cs index 4396b58de5c..bb5a7838c0c 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/GroupByQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindGroupByQueryInMemoryTest.cs @@ -6,9 +6,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class GroupByQueryInMemoryTest : GroupByQueryTestBase> + public class NorthwindGroupByQueryInMemoryTest : NorthwindGroupByQueryTestBase> { - public GroupByQueryInMemoryTest( + public NorthwindGroupByQueryInMemoryTest( NorthwindQueryInMemoryFixture fixture, // ReSharper disable once UnusedParameter.Local ITestOutputHelper testOutputHelper) diff --git a/test/EFCore.InMemory.FunctionalTests/Query/IncludeAsyncInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeAsyncQueryInMemoryTest.cs similarity index 57% rename from test/EFCore.InMemory.FunctionalTests/Query/IncludeAsyncInMemoryTest.cs rename to test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeAsyncQueryInMemoryTest.cs index c278fc5708a..113cf5a9b89 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/IncludeAsyncInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeAsyncQueryInMemoryTest.cs @@ -3,9 +3,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class IncludeAsyncInMemoryTest : IncludeAsyncTestBase + public class NorthwindIncludeAsyncQueryInMemoryTest : NorthwindIncludeAsyncQueryTestBase { - public IncludeAsyncInMemoryTest(IncludeInMemoryFixture fixture) + public NorthwindIncludeAsyncQueryInMemoryTest(IncludeInMemoryFixture fixture) : base(fixture) { } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/IncludeInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeQueryInMemoryTest.cs similarity index 73% rename from test/EFCore.InMemory.FunctionalTests/Query/IncludeInMemoryTest.cs rename to test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeQueryInMemoryTest.cs index a76a6fbae84..c207cc9aa33 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/IncludeInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeQueryInMemoryTest.cs @@ -6,9 +6,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class IncludeInMemoryTest : IncludeTestBase + public class NorthwindIncludeQueryInMemoryTest : NorthwindIncludeQueryTestBase { - public IncludeInMemoryTest(IncludeInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindIncludeQueryInMemoryTest(IncludeInMemoryFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { //TestLoggerFactory.TestOutputHelper = testOutputHelper; diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindJoinQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindJoinQueryInMemoryTest.cs new file mode 100644 index 00000000000..b8c9a7c39f3 --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindJoinQueryInMemoryTest.cs @@ -0,0 +1,24 @@ +// 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 NorthwindJoinQueryInMemoryTest : NorthwindJoinQueryTestBase> + { + public NorthwindJoinQueryInMemoryTest( + NorthwindQueryInMemoryFixture fixture, +#pragma warning disable IDE0060 // Remove unused parameter + ITestOutputHelper testOutputHelper) +#pragma warning restore IDE0060 // Remove unused parameter + : base(fixture) + { + //TestLoggerFactory.TestOutputHelper = testOutputHelper; + } + } +} diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindKeylessEntitiesQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindKeylessEntitiesQueryInMemoryTest.cs new file mode 100644 index 00000000000..8b322663764 --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindKeylessEntitiesQueryInMemoryTest.cs @@ -0,0 +1,24 @@ +// 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 NorthwindKeylessEntitiesQueryInMemoryTest : NorthwindKeylessEntitiesQueryTestBase> + { + public NorthwindKeylessEntitiesQueryInMemoryTest( + NorthwindQueryInMemoryFixture fixture, +#pragma warning disable IDE0060 // Remove unused parameter + ITestOutputHelper testOutputHelper) +#pragma warning restore IDE0060 // Remove unused parameter + : base(fixture) + { + //TestLoggerFactory.TestOutputHelper = testOutputHelper; + } + } +} 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/QueryNavigationsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindNavigationsQueryInMemoryTest.cs similarity index 80% rename from test/EFCore.InMemory.FunctionalTests/Query/QueryNavigationsInMemoryTest.cs rename to test/EFCore.InMemory.FunctionalTests/Query/NorthwindNavigationsQueryInMemoryTest.cs index 8382435d4d9..b89249e5776 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/QueryNavigationsInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindNavigationsQueryInMemoryTest.cs @@ -8,9 +8,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class QueryNavigationsInMemoryTest : QueryNavigationsTestBase> + public class NorthwindNavigationsQueryInMemoryTest : NorthwindNavigationsQueryTestBase> { - public QueryNavigationsInMemoryTest( + public NorthwindNavigationsQueryInMemoryTest( NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { diff --git a/test/EFCore.InMemory.FunctionalTests/Query/FiltersInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryFiltersQueryInMemoryTest.cs similarity index 54% rename from test/EFCore.InMemory.FunctionalTests/Query/FiltersInMemoryTest.cs rename to test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryFiltersQueryInMemoryTest.cs index 2533808c696..6b6375b00f5 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/FiltersInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryFiltersQueryInMemoryTest.cs @@ -5,9 +5,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class FiltersInMemoryTest : FiltersTestBase> + public class NorthwindQueryFiltersQueryInMemoryTest : NorthwindQueryFiltersQueryTestBase> { - public FiltersInMemoryTest(NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindQueryFiltersQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { //TestLoggerFactory.TestOutputHelper = testOutputHelper; diff --git a/test/EFCore.InMemory.FunctionalTests/Query/QueryTaggingInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryTaggingQueryInMemoryTest.cs similarity index 69% rename from test/EFCore.InMemory.FunctionalTests/Query/QueryTaggingInMemoryTest.cs rename to test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryTaggingQueryInMemoryTest.cs index e89f48b3b25..62159b568e1 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/QueryTaggingInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryTaggingQueryInMemoryTest.cs @@ -6,9 +6,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class QueryTaggingInMemoryTest : QueryTaggingTestBase> + public class NorthwindQueryTaggingQueryInMemoryTest : NorthwindQueryTaggingQueryTestBase> { - public QueryTaggingInMemoryTest( + public NorthwindQueryTaggingQueryInMemoryTest( NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { 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/NorthwindSetOperationsQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindSetOperationsQueryInMemoryTest.cs new file mode 100644 index 00000000000..eb3bb8c052f --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindSetOperationsQueryInMemoryTest.cs @@ -0,0 +1,24 @@ +// 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 NorthwindSetOperationsQueryInMemoryTest : NorthwindSetOperationsQueryTestBase> + { + public NorthwindSetOperationsQueryInMemoryTest( + NorthwindQueryInMemoryFixture fixture, +#pragma warning disable IDE0060 // Remove unused parameter + ITestOutputHelper testOutputHelper) +#pragma warning restore IDE0060 // Remove unused parameter + : base(fixture) + { + //TestLoggerFactory.TestOutputHelper = testOutputHelper; + } + } +} 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/AsNoTrackingTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindAsNoTrackingQueryTestBase.cs similarity index 97% rename from test/EFCore.Specification.Tests/Query/AsNoTrackingTestBase.cs rename to test/EFCore.Specification.Tests/Query/NorthwindAsNoTrackingQueryTestBase.cs index 7ce878fb662..203c89ba461 100644 --- a/test/EFCore.Specification.Tests/Query/AsNoTrackingTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindAsNoTrackingQueryTestBase.cs @@ -11,10 +11,10 @@ // ReSharper disable AccessToDisposedClosure namespace Microsoft.EntityFrameworkCore.Query { - public abstract class AsNoTrackingTestBase : IClassFixture + public abstract class NorthwindAsNoTrackingQueryTestBase : IClassFixture where TFixture : NorthwindQueryFixtureBase, new() { - protected AsNoTrackingTestBase(TFixture fixture) => Fixture = fixture; + protected NorthwindAsNoTrackingQueryTestBase(TFixture fixture) => Fixture = fixture; protected TFixture Fixture { get; } diff --git a/test/EFCore.Specification.Tests/Query/AsTrackingTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindAsTrackingQueryTestBase.cs similarity index 95% rename from test/EFCore.Specification.Tests/Query/AsTrackingTestBase.cs rename to test/EFCore.Specification.Tests/Query/NorthwindAsTrackingQueryTestBase.cs index 701b6370793..b654342008d 100644 --- a/test/EFCore.Specification.Tests/Query/AsTrackingTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindAsTrackingQueryTestBase.cs @@ -9,10 +9,10 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public abstract class AsTrackingTestBase : IClassFixture + public abstract class NorthwindAsTrackingQueryTestBase : IClassFixture where TFixture : NorthwindQueryFixtureBase, new() { - protected AsTrackingTestBase(TFixture fixture) => Fixture = fixture; + protected NorthwindAsTrackingQueryTestBase(TFixture fixture) => Fixture = fixture; protected TFixture Fixture { get; } diff --git a/test/EFCore.Specification.Tests/Query/AsyncSimpleQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindAsyncSimpleQueryTestBase.cs similarity index 99% rename from test/EFCore.Specification.Tests/Query/AsyncSimpleQueryTestBase.cs rename to test/EFCore.Specification.Tests/Query/NorthwindAsyncSimpleQueryTestBase.cs index 4034fb3a138..b159a039edd 100644 --- a/test/EFCore.Specification.Tests/Query/AsyncSimpleQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindAsyncSimpleQueryTestBase.cs @@ -19,10 +19,10 @@ // ReSharper disable StringEndsWithIsCultureSpecific namespace Microsoft.EntityFrameworkCore.Query { - public abstract class AsyncSimpleQueryTestBase : QueryTestBase + public abstract class NorthwindAsyncSimpleQueryTestBase : QueryTestBase where TFixture : NorthwindQueryFixtureBase, new() { - protected AsyncSimpleQueryTestBase(TFixture fixture) + protected NorthwindAsyncSimpleQueryTestBase(TFixture fixture) : base(fixture) { } diff --git a/test/EFCore.Specification.Tests/Query/ChangeTrackingTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindChangeTrackingQueryTestBase.cs similarity index 98% rename from test/EFCore.Specification.Tests/Query/ChangeTrackingTestBase.cs rename to test/EFCore.Specification.Tests/Query/NorthwindChangeTrackingQueryTestBase.cs index 33bf01d48c5..70d6774ffab 100644 --- a/test/EFCore.Specification.Tests/Query/ChangeTrackingTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindChangeTrackingQueryTestBase.cs @@ -9,10 +9,10 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public abstract class ChangeTrackingTestBase : IClassFixture + public abstract class NorthwindChangeTrackingQueryTestBase : IClassFixture where TFixture : NorthwindQueryFixtureBase, new() { - protected ChangeTrackingTestBase(TFixture fixture) => Fixture = fixture; + protected NorthwindChangeTrackingQueryTestBase(TFixture fixture) => Fixture = fixture; protected TFixture Fixture { get; } diff --git a/test/EFCore.Specification.Tests/Query/CompiledQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindCompiledQueryTestBase.cs similarity index 99% rename from test/EFCore.Specification.Tests/Query/CompiledQueryTestBase.cs rename to test/EFCore.Specification.Tests/Query/NorthwindCompiledQueryTestBase.cs index df0ca35ad61..d33b08e7380 100644 --- a/test/EFCore.Specification.Tests/Query/CompiledQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindCompiledQueryTestBase.cs @@ -15,10 +15,10 @@ // ReSharper disable ConvertToExpressionBodyWhenPossible namespace Microsoft.EntityFrameworkCore.Query { - public abstract class CompiledQueryTestBase : IClassFixture + public abstract class NorthwindCompiledQueryTestBase : IClassFixture where TFixture : NorthwindQueryFixtureBase, new() { - protected CompiledQueryTestBase(TFixture fixture) => Fixture = fixture; + protected NorthwindCompiledQueryTestBase(TFixture fixture) => Fixture = fixture; protected TFixture Fixture { get; } diff --git a/test/EFCore.Specification.Tests/Query/DbFunctionsTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindDbFunctionsQueryTestBase.cs similarity index 88% rename from test/EFCore.Specification.Tests/Query/DbFunctionsTestBase.cs rename to test/EFCore.Specification.Tests/Query/NorthwindDbFunctionsQueryTestBase.cs index 094fc7048d8..ebb90634620 100644 --- a/test/EFCore.Specification.Tests/Query/DbFunctionsTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindDbFunctionsQueryTestBase.cs @@ -9,10 +9,10 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public abstract class DbFunctionsTestBase : IClassFixture + public abstract class NorthwindDbFunctionsQueryTestBase : IClassFixture where TFixture : NorthwindQueryFixtureBase, new() { - protected DbFunctionsTestBase(TFixture fixture) => Fixture = fixture; + protected NorthwindDbFunctionsQueryTestBase(TFixture fixture) => Fixture = fixture; protected TFixture Fixture { get; } 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/GroupByQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindGroupByQueryTestBase.cs similarity index 99% rename from test/EFCore.Specification.Tests/Query/GroupByQueryTestBase.cs rename to test/EFCore.Specification.Tests/Query/NorthwindGroupByQueryTestBase.cs index 7407dbc55f1..ff4d88e750d 100644 --- a/test/EFCore.Specification.Tests/Query/GroupByQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindGroupByQueryTestBase.cs @@ -10,10 +10,10 @@ namespace Microsoft.EntityFrameworkCore.Query { - public abstract class GroupByQueryTestBase : QueryTestBase + public abstract class NorthwindGroupByQueryTestBase : QueryTestBase where TFixture : NorthwindQueryFixtureBase, new() { - protected GroupByQueryTestBase(TFixture fixture) + protected NorthwindGroupByQueryTestBase(TFixture fixture) : base(fixture) { } diff --git a/test/EFCore.Specification.Tests/Query/IncludeAsyncTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindIncludeAsyncQueryTestBase.cs similarity index 99% rename from test/EFCore.Specification.Tests/Query/IncludeAsyncTestBase.cs rename to test/EFCore.Specification.Tests/Query/NorthwindIncludeAsyncQueryTestBase.cs index 8f699af5543..3ac2bb01a31 100644 --- a/test/EFCore.Specification.Tests/Query/IncludeAsyncTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindIncludeAsyncQueryTestBase.cs @@ -14,10 +14,10 @@ // ReSharper disable AccessToDisposedClosure namespace Microsoft.EntityFrameworkCore.Query { - public abstract class IncludeAsyncTestBase : IClassFixture + public abstract class NorthwindIncludeAsyncQueryTestBase : IClassFixture where TFixture : NorthwindQueryFixtureBase, new() { - protected IncludeAsyncTestBase(TFixture fixture) => Fixture = fixture; + protected NorthwindIncludeAsyncQueryTestBase(TFixture fixture) => Fixture = fixture; protected TFixture Fixture { get; } diff --git a/test/EFCore.Specification.Tests/Query/IncludeTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs similarity index 99% rename from test/EFCore.Specification.Tests/Query/IncludeTestBase.cs rename to test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs index 10ade87181f..cf38e01a075 100644 --- a/test/EFCore.Specification.Tests/Query/IncludeTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs @@ -20,10 +20,10 @@ namespace Microsoft.EntityFrameworkCore.Query { - public abstract class IncludeTestBase : IClassFixture + public abstract class NorthwindIncludeQueryTestBase : IClassFixture where TFixture : NorthwindQueryFixtureBase, new() { - protected IncludeTestBase(TFixture fixture) => Fixture = fixture; + protected NorthwindIncludeQueryTestBase(TFixture fixture) => Fixture = fixture; protected TFixture Fixture { get; } diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.JoinGroupJoin.cs b/test/EFCore.Specification.Tests/Query/NorthwindJoinQueryTestBase.cs similarity index 98% rename from test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.JoinGroupJoin.cs rename to test/EFCore.Specification.Tests/Query/NorthwindJoinQueryTestBase.cs index 480b7d06e0b..af3331f8ca2 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.JoinGroupJoin.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindJoinQueryTestBase.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 NorthwindJoinQueryTestBase : QueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() { + protected NorthwindJoinQueryTestBase(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/QueryNavigationsTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs similarity index 99% rename from test/EFCore.Specification.Tests/Query/QueryNavigationsTestBase.cs rename to test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs index d7a715523cc..f4eb1744a48 100644 --- a/test/EFCore.Specification.Tests/Query/QueryNavigationsTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs @@ -14,10 +14,10 @@ namespace Microsoft.EntityFrameworkCore.Query { - public abstract class QueryNavigationsTestBase : QueryTestBase + public abstract class NorthwindNavigationsQueryTestBase : QueryTestBase where TFixture : NorthwindQueryFixtureBase, new() { - protected QueryNavigationsTestBase(TFixture fixture) + protected NorthwindNavigationsQueryTestBase(TFixture fixture) : base(fixture) { } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindFiltersCustomizer.cs b/test/EFCore.Specification.Tests/Query/NorthwindQueryFiltersCustomizer.cs similarity index 88% rename from test/EFCore.Specification.Tests/Query/NorthwindFiltersCustomizer.cs rename to test/EFCore.Specification.Tests/Query/NorthwindQueryFiltersCustomizer.cs index aac277efcea..fa74b1c2483 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindFiltersCustomizer.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindQueryFiltersCustomizer.cs @@ -6,7 +6,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindFiltersCustomizer : IModelCustomizer + public class NorthwindQueryFiltersCustomizer : IModelCustomizer { public void Customize(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Specification.Tests/Query/FiltersTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindQueryFiltersQueryTestBase.cs similarity index 95% rename from test/EFCore.Specification.Tests/Query/FiltersTestBase.cs rename to test/EFCore.Specification.Tests/Query/NorthwindQueryFiltersQueryTestBase.cs index c887f0f66b2..e5f22feb4ee 100644 --- a/test/EFCore.Specification.Tests/Query/FiltersTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindQueryFiltersQueryTestBase.cs @@ -15,12 +15,12 @@ // ReSharper disable StringStartsWithIsCultureSpecific namespace Microsoft.EntityFrameworkCore.Query { - public abstract class FiltersTestBase : IClassFixture, IDisposable - where TFixture : NorthwindQueryFixtureBase, new() + public abstract class NorthwindQueryFiltersQueryTestBase : IClassFixture, IDisposable + where TFixture : NorthwindQueryFixtureBase, new() { private readonly NorthwindContext _context; - protected FiltersTestBase(TFixture fixture) + protected NorthwindQueryFiltersQueryTestBase(TFixture fixture) { Fixture = fixture; diff --git a/test/EFCore.Specification.Tests/Query/QueryTaggingTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindQueryTaggingQueryTestBase.cs similarity index 95% rename from test/EFCore.Specification.Tests/Query/QueryTaggingTestBase.cs rename to test/EFCore.Specification.Tests/Query/NorthwindQueryTaggingQueryTestBase.cs index ea3761c9a77..af8b88b197b 100644 --- a/test/EFCore.Specification.Tests/Query/QueryTaggingTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindQueryTaggingQueryTestBase.cs @@ -10,10 +10,10 @@ // ReSharper disable AccessToDisposedClosure namespace Microsoft.EntityFrameworkCore.Query { - public abstract class QueryTaggingTestBase : IClassFixture + public abstract class NorthwindQueryTaggingQueryTestBase : IClassFixture where TFixture : NorthwindQueryFixtureBase, new() { - protected QueryTaggingTestBase(TFixture fixture) => Fixture = fixture; + protected NorthwindQueryTaggingQueryTestBase(TFixture fixture) => Fixture = fixture; protected TFixture Fixture { get; } 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/AsNoTrackingSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqlServerTest.cs similarity index 74% rename from test/EFCore.SqlServer.FunctionalTests/Query/AsNoTrackingSqlServerTest.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqlServerTest.cs index e42dd474ebc..f517236a941 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AsNoTrackingSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqlServerTest.cs @@ -6,9 +6,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class AsNoTrackingSqlServerTest : AsNoTrackingTestBase> + public class NorthwindAsNoTrackingQuerySqlServerTest : NorthwindAsNoTrackingQueryTestBase> { - public AsNoTrackingSqlServerTest( + public NorthwindAsNoTrackingQuerySqlServerTest( NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsTrackingQuerySqlServerTest.cs new file mode 100644 index 00000000000..1dbfb6e4749 --- /dev/null +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsTrackingQuerySqlServerTest.cs @@ -0,0 +1,15 @@ +// 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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class NorthwindAsTrackingQuerySqlServerTest : NorthwindAsTrackingQueryTestBase> + { + public NorthwindAsTrackingQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture) + : base(fixture) + { + } + } +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AsyncSimpleQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqlServerTest.cs similarity index 96% rename from test/EFCore.SqlServer.FunctionalTests/Query/AsyncSimpleQuerySqlServerTest.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqlServerTest.cs index a184c5c0304..c10f0337802 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AsyncSimpleQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqlServerTest.cs @@ -15,10 +15,10 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public class AsyncSimpleQuerySqlServerTest : AsyncSimpleQueryTestBase> + public class NorthwindAsyncSimpleQuerySqlServerTest : NorthwindAsyncSimpleQueryTestBase> { // ReSharper disable once UnusedParameter.Local - public AsyncSimpleQuerySqlServerTest( + public NorthwindAsyncSimpleQuerySqlServerTest( NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ChangeTrackingSqliteTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindChangeTrackingQuerySqlServerTest.cs similarity index 71% rename from test/EFCore.Sqlite.FunctionalTests/Query/ChangeTrackingSqliteTest.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindChangeTrackingQuerySqlServerTest.cs index 8226499faaa..aece2e25e23 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ChangeTrackingSqliteTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindChangeTrackingQuerySqlServerTest.cs @@ -6,9 +6,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class ChangeTrackingSqliteTest : ChangeTrackingTestBase> + public class NorthwindChangeTrackingQuerySqlServerTest : NorthwindChangeTrackingQueryTestBase> { - public ChangeTrackingSqliteTest(NorthwindQuerySqliteFixture fixture) + public NorthwindChangeTrackingQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture) : base(fixture) { } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/CompiledQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindCompiledQuerySqlServerTest.cs similarity index 96% rename from test/EFCore.SqlServer.FunctionalTests/Query/CompiledQuerySqlServerTest.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindCompiledQuerySqlServerTest.cs index e7577467c9b..7bd7c9545d1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/CompiledQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindCompiledQuerySqlServerTest.cs @@ -7,9 +7,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class CompiledQuerySqlServerTest : CompiledQueryTestBase> + public class NorthwindCompiledQuerySqlServerTest : NorthwindCompiledQueryTestBase> { - public CompiledQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindCompiledQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/DbFunctionsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs similarity index 99% rename from test/EFCore.SqlServer.FunctionalTests/Query/DbFunctionsSqlServerTest.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs index 2bf897c08f9..c5bd122c50a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/DbFunctionsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs @@ -13,9 +13,9 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public class DbFunctionsSqlServerTest : DbFunctionsTestBase> + public class NorthwindDbFunctionsQuerySqlServerTest : NorthwindDbFunctionsQueryTestBase> { - public DbFunctionsSqlServerTest( + public NorthwindDbFunctionsQuerySqlServerTest( NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { 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/GroupByQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs similarity index 99% rename from test/EFCore.SqlServer.FunctionalTests/Query/GroupByQuerySqlServerTest.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs index bdf5f7b6603..fccc85c5817 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GroupByQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs @@ -10,10 +10,10 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class GroupByQuerySqlServerTest : GroupByQueryTestBase> + public class NorthwindGroupByQuerySqlServerTest : NorthwindGroupByQueryTestBase> { // ReSharper disable once UnusedParameter.Local - public GroupByQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindGroupByQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeAsyncSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeAsyncQuerySqlServerTest.cs similarity index 90% rename from test/EFCore.SqlServer.FunctionalTests/Query/IncludeAsyncSqlServerTest.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeAsyncQuerySqlServerTest.cs index 9d925cb4616..a2a9d7cb697 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeAsyncSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeAsyncQuerySqlServerTest.cs @@ -7,9 +7,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class IncludeAsyncSqlServerTest : IncludeAsyncTestBase> + public class NorthwindIncludeAsyncQuerySqlServerTest : NorthwindIncludeAsyncQueryTestBase> { - public IncludeAsyncSqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindIncludeAsyncQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs similarity index 99% rename from test/EFCore.SqlServer.FunctionalTests/Query/IncludeSqlServerTest.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs index 0720a5c8378..9b8421debc8 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs @@ -7,12 +7,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class IncludeSqlServerTest : IncludeTestBase> + public class NorthwindIncludeQuerySqlServerTest : NorthwindIncludeQueryTestBase> { private bool SupportsOffset => TestEnvironment.GetFlag(nameof(SqlServerCondition.SupportsOffset)) ?? true; // ReSharper disable once UnusedParameter.Local - public IncludeSqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindIncludeQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.JoinGroupJoin.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinQuerySqlServerTest.cs similarity index 97% rename from test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.JoinGroupJoin.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinQuerySqlServerTest.cs index f2927f1b7a5..a170c632f33 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.JoinGroupJoin.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinQuerySqlServerTest.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 NorthwindJoinQuerySqlServerTest : NorthwindJoinQueryTestBase> { + public NorthwindJoinQuerySqlServerTest(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/QueryNavigationsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs similarity index 99% rename from test/EFCore.SqlServer.FunctionalTests/Query/QueryNavigationsSqlServerTest.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs index b80c4747ea2..229abd44f1b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/QueryNavigationsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs @@ -7,9 +7,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class QueryNavigationsSqlServerTest : QueryNavigationsTestBase> + public class NorthwindNavigationsQuerySqlServerTest : NorthwindNavigationsQueryTestBase> { - public QueryNavigationsSqlServerTest( + public NorthwindNavigationsQuerySqlServerTest( NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/FiltersSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryFiltersQuerySqlServerTest.cs similarity index 97% rename from test/EFCore.SqlServer.FunctionalTests/Query/FiltersSqlServerTest.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryFiltersQuerySqlServerTest.cs index 6c4b6a6b75d..8e7f315f5da 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/FiltersSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryFiltersQuerySqlServerTest.cs @@ -8,9 +8,9 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public class FiltersSqlServerTest : FiltersTestBase> + public class NorthwindQueryFiltersQuerySqlServerTest : NorthwindQueryFiltersQueryTestBase> { - public FiltersSqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindQueryFiltersQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/QueryTaggingSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryTaggingQuerySqlServerTest.cs similarity index 96% rename from test/EFCore.SqlServer.FunctionalTests/Query/QueryTaggingSqlServerTest.cs rename to test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryTaggingQuerySqlServerTest.cs index 51bd59ef4c9..b6e5eb90b41 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/QueryTaggingSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryTaggingQuerySqlServerTest.cs @@ -6,9 +6,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class QueryTaggingSqlServerTest : QueryTaggingTestBase> + public class NorthwindQueryTaggingQuerySqlServerTest : NorthwindQueryTaggingQueryTestBase> { - public QueryTaggingSqlServerTest( + public NorthwindQueryTaggingQuerySqlServerTest( NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { 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/AsTrackingSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/AsTrackingSqliteTest.cs deleted file mode 100644 index 40768bf9d13..00000000000 --- a/test/EFCore.Sqlite.FunctionalTests/Query/AsTrackingSqliteTest.cs +++ /dev/null @@ -1,15 +0,0 @@ -// 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 Microsoft.EntityFrameworkCore.TestUtilities; - -namespace Microsoft.EntityFrameworkCore.Query -{ - public class AsTrackingSqliteTest : AsTrackingTestBase> - { - public AsTrackingSqliteTest(NorthwindQuerySqliteFixture fixture) - : base(fixture) - { - } - } -} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/CompiledQueryInMemoryTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/CompiledQueryInMemoryTest.cs index a1e28de4da0..2f63ebf89d3 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/CompiledQueryInMemoryTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/CompiledQueryInMemoryTest.cs @@ -5,9 +5,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class CompiledQuerySqliteTest : CompiledQueryTestBase> + public class NorthwindCompiledQuerySqliteTest : NorthwindCompiledQueryTestBase> { - public CompiledQuerySqliteTest(NorthwindQuerySqliteFixture fixture) + public NorthwindCompiledQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : base(fixture) { } 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.SqlServer.FunctionalTests/Query/AsTrackingSqlServerTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqliteTest.cs similarity index 56% rename from test/EFCore.SqlServer.FunctionalTests/Query/AsTrackingSqlServerTest.cs rename to test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqliteTest.cs index 47070398776..a5829492937 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AsTrackingSqlServerTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqliteTest.cs @@ -5,9 +5,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class AsTrackingSqlServerTest : AsTrackingTestBase> + public class NorthwindAsNoTrackingQuerySqliteTest : NorthwindAsNoTrackingQueryTestBase> { - public AsTrackingSqlServerTest(NorthwindQuerySqlServerFixture fixture) + public NorthwindAsNoTrackingQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : base(fixture) { } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/AsNoTrackingInMemoryTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsTrackingQuerySqliteTest.cs similarity index 57% rename from test/EFCore.InMemory.FunctionalTests/Query/AsNoTrackingInMemoryTest.cs rename to test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsTrackingQuerySqliteTest.cs index 55dd33c0fbd..f2a0cc4a1e3 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/AsNoTrackingInMemoryTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsTrackingQuerySqliteTest.cs @@ -5,9 +5,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class AsNoTrackingInMemoryTest : AsNoTrackingTestBase> + public class NorthwindAsTrackingQuerySqliteTest : NorthwindAsTrackingQueryTestBase> { - public AsNoTrackingInMemoryTest(NorthwindQueryInMemoryFixture fixture) + public NorthwindAsTrackingQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : base(fixture) { } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/AsyncSimpleQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqliteTest.cs similarity index 75% rename from test/EFCore.Sqlite.FunctionalTests/Query/AsyncSimpleQuerySqliteTest.cs rename to test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqliteTest.cs index da8c7072336..aec09bad88e 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/AsyncSimpleQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqliteTest.cs @@ -10,9 +10,9 @@ #pragma warning disable 1998 namespace Microsoft.EntityFrameworkCore.Query { - public class AsyncSimpleQuerySqliteTest : AsyncSimpleQueryTestBase> + public class NorthwindAsyncSimpleQuerySqliteTest : NorthwindAsyncSimpleQueryTestBase> { - public AsyncSimpleQuerySqliteTest(NorthwindQuerySqliteFixture fixture) + public NorthwindAsyncSimpleQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : base(fixture) { } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ChangeTrackingSqlServerTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindChangeTrackingQuerySqliteTest.cs similarity index 72% rename from test/EFCore.SqlServer.FunctionalTests/Query/ChangeTrackingSqlServerTest.cs rename to test/EFCore.Sqlite.FunctionalTests/Query/NorthwindChangeTrackingQuerySqliteTest.cs index ed0afee38a2..9e9dad0dbaa 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ChangeTrackingSqlServerTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindChangeTrackingQuerySqliteTest.cs @@ -6,9 +6,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class ChangeTrackingSqlServerTest : ChangeTrackingTestBase> + public class NorthwindChangeTrackingQuerySqliteTest : NorthwindChangeTrackingQueryTestBase> { - public ChangeTrackingSqlServerTest(NorthwindQuerySqlServerFixture fixture) + public NorthwindChangeTrackingQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : base(fixture) { } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/DbFunctionsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs similarity index 58% rename from test/EFCore.Sqlite.FunctionalTests/Query/DbFunctionsSqliteTest.cs rename to test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs index 4e724bd8809..a111e1136b0 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/DbFunctionsSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs @@ -6,9 +6,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class DbFunctionsSqliteTest : DbFunctionsTestBase> + public class NorthwindDbFunctionsQuerySqliteTest : NorthwindDbFunctionsQueryTestBase> { - public DbFunctionsSqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindDbFunctionsQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); 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..8c664e3d985 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(); //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/GroupByQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindGroupByQuerySqliteTest.cs similarity index 80% rename from test/EFCore.Sqlite.FunctionalTests/Query/GroupByQuerySqliteTest.cs rename to test/EFCore.Sqlite.FunctionalTests/Query/NorthwindGroupByQuerySqliteTest.cs index 7361c45bc41..68e32f087f2 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/GroupByQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindGroupByQuerySqliteTest.cs @@ -9,10 +9,10 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class GroupByQuerySqliteTest : GroupByQueryTestBase> + public class NorthwindGroupByQuerySqliteTest : NorthwindGroupByQueryTestBase> { // ReSharper disable once UnusedParameter.Local - public GroupByQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindGroupByQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/IncludeAsyncSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeAsyncQuerySqliteTest.cs similarity index 58% rename from test/EFCore.Sqlite.FunctionalTests/Query/IncludeAsyncSqliteTest.cs rename to test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeAsyncQuerySqliteTest.cs index 74566d82273..40878d6d907 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/IncludeAsyncSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeAsyncQuerySqliteTest.cs @@ -3,9 +3,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class IncludeAsyncSqliteTest : IncludeAsyncTestBase + public class NorthwindIncludeAsyncQuerySqliteTest : NorthwindIncludeAsyncQueryTestBase { - public IncludeAsyncSqliteTest(IncludeSqliteFixture fixture) + public NorthwindIncludeAsyncQuerySqliteTest(IncludeSqliteFixture fixture) : base(fixture) { } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/IncludeSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeQuerySqliteTest.cs similarity index 77% rename from test/EFCore.Sqlite.FunctionalTests/Query/IncludeSqliteTest.cs rename to test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeQuerySqliteTest.cs index c5965557e98..5aaabd9a616 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/IncludeSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeQuerySqliteTest.cs @@ -6,9 +6,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class IncludeSqliteTest : IncludeTestBase + public class NorthwindIncludeQuerySqliteTest : NorthwindIncludeQueryTestBase { - public IncludeSqliteTest(IncludeSqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindIncludeQuerySqliteTest(IncludeSqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { //TestSqlLoggerFactory.CaptureOutput(testOutputHelper); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindJoinQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindJoinQuerySqliteTest.cs new file mode 100644 index 00000000000..fe3fc757ba0 --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindJoinQuerySqliteTest.cs @@ -0,0 +1,23 @@ +// 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 NorthwindJoinQuerySqliteTest : NorthwindJoinQueryTestBase> + { + public NorthwindJoinQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + } +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqliteTest.cs new file mode 100644 index 00000000000..c460fc89202 --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqliteTest.cs @@ -0,0 +1,23 @@ +// 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 NorthwindKeylessEntitiesQuerySqliteTest : NorthwindKeylessEntitiesQueryTestBase> + { + public NorthwindKeylessEntitiesQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + } +} 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.InMemory.FunctionalTests/Query/AsTrackingInMemoryTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindNavigationsQuerySqliteTest.cs similarity index 57% rename from test/EFCore.InMemory.FunctionalTests/Query/AsTrackingInMemoryTest.cs rename to test/EFCore.Sqlite.FunctionalTests/Query/NorthwindNavigationsQuerySqliteTest.cs index b013c1d316b..93a1bf98ee4 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/AsTrackingInMemoryTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindNavigationsQuerySqliteTest.cs @@ -5,9 +5,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class AsTrackingInMemoryTest : AsTrackingTestBase> + public class NorthwindNavigationsQuerySqliteTest : NorthwindNavigationsQueryTestBase> { - public AsTrackingInMemoryTest(NorthwindQueryInMemoryFixture fixture) + public NorthwindNavigationsQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : base(fixture) { } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/FiltersSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQueryFiltersQuerySqliteTest.cs similarity index 77% rename from test/EFCore.Sqlite.FunctionalTests/Query/FiltersSqliteTest.cs rename to test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQueryFiltersQuerySqliteTest.cs index 3a516633f18..d1e0bff68e6 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/FiltersSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQueryFiltersQuerySqliteTest.cs @@ -5,9 +5,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class FiltersSqliteTest : FiltersTestBase> + public class NorthwindQueryFiltersQuerySqliteTest : NorthwindQueryFiltersQueryTestBase> { - public FiltersSqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindQueryFiltersQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/QueryTaggingSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQueryTaggingQuerySqliteTest.cs similarity index 70% rename from test/EFCore.Sqlite.FunctionalTests/Query/QueryTaggingSqliteTest.cs rename to test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQueryTaggingQuerySqliteTest.cs index db9a516aa80..c829da25c37 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/QueryTaggingSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQueryTaggingQuerySqliteTest.cs @@ -6,9 +6,9 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class QueryTaggingSqliteTest : QueryTaggingTestBase> + public class NorthwindQueryTaggingQuerySqliteTest : NorthwindQueryTaggingQueryTestBase> { - public QueryTaggingSqliteTest( + public NorthwindQueryTaggingQuerySqliteTest( NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSelectQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSelectQuerySqliteTest.cs new file mode 100644 index 00000000000..f4491cee215 --- /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) + { + Fixture.TestSqlLoggerFactory.Clear(); + //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/NorthwindSetOperationsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSetOperationsQuerySqliteTest.cs new file mode 100644 index 00000000000..3c06baed1df --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSetOperationsQuerySqliteTest.cs @@ -0,0 +1,23 @@ +// 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 NorthwindSetOperationsQuerySqliteTest : NorthwindSetOperationsQueryTestBase> + { + public NorthwindSetOperationsQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + } +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs new file mode 100644 index 00000000000..53e47aa6be9 --- /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) + { + Fixture.TestSqlLoggerFactory.Clear(); + //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); + } +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/QueryNavigationsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/QueryNavigationsSqliteTest.cs deleted file mode 100644 index 254af28e9c0..00000000000 --- a/test/EFCore.Sqlite.FunctionalTests/Query/QueryNavigationsSqliteTest.cs +++ /dev/null @@ -1,15 +0,0 @@ -// 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 Microsoft.EntityFrameworkCore.TestUtilities; - -namespace Microsoft.EntityFrameworkCore.Query -{ - public class QueryNavigationsSqliteTest : QueryNavigationsTestBase> - { - public QueryNavigationsSqliteTest(NorthwindQuerySqliteFixture fixture) - : base(fixture) - { - } - } -}