From bf22127f164c4cac76f6f1c3e0d5147d94a9b684 Mon Sep 17 00:00:00 2001 From: Smit Patel Date: Tue, 26 May 2020 14:26:41 -0700 Subject: [PATCH] Tests: Make QueryAsserter a combined form of TestBase & Fixture configuration - Introduce methods to rewrite server/expected queries on QueryTestBase - Introduce QueryTestBase.IgnoreEntryCount to run same query with tracking/no tracking via rewritten form - Introduce some relational test bases to verify execution of DbCommands - Merge include asserter into query asserter - Remove Include*Fixtures --- .../Query/IncludeInMemoryFixture.cs | 13 - .../NorthwindIncludeQueryInMemoryTest.cs | 5 +- .../AsyncGearsOfWarQueryRelationalTestBase.cs | 21 + ...exNavigationsQueryRelationalFixtureBase.cs | 16 +- ...mplexNavigationsQueryRelationalTestBase.cs | 21 + .../Query/GearsOfWarQueryRelationalFixture.cs | 15 +- .../GearsOfWarQueryRelationalTestBase.cs | 21 + .../Query/ManyToManyQueryRelationalFixture.cs | 13 - .../ManyToManyQueryRelationalTestBase.cs | 21 + ...gregateOperatorsQueryRelationalTestBase.cs | 21 + ...hwindAsyncSimpleQueryRelationalTestBase.cs | 21 + ...rthwindFunctionsQueryRelationalTestBase.cs | 21 + ...NorthwindGroupByQueryRelationalTestBase.cs | 21 + ...NorthwindIncludeQueryRelationalTestBase.cs | 21 + .../NorthwindJoinQueryRelationalTestBase.cs | 21 + ...dKeylessEntitiesQueryRelationalTestBase.cs | 21 + ...indMiscellaneousQueryRelationalTestBase.cs | 21 + ...hwindNavigationsQueryRelationalTestBase.cs | 21 + .../Query/NorthwindQueryRelationalFixture.cs | 11 - .../NorthwindSelectQueryRelationalTestBase.cs | 21 + ...indSetOperationsQueryRelationalTestBase.cs | 21 + .../NorthwindWhereQueryRelationalTestBase.cs | 21 + .../Query/NullSemanticsQueryFixtureBase.cs | 26 +- ...ase.cs => OwnedQueryRelationalTestBase.cs} | 21 +- ...tionalNorthwindDbFunctionsQueryTestBase.cs | 9 +- .../Query/SpatialQueryRelationalFixture.cs | 9 - .../Query/SpatialQueryRelationalTestBase.cs | 21 + .../TestUtilities/RelationalQueryAsserter.cs | 19 +- .../EFCore.Specification.Tests/FixtureBase.cs | 3 - .../ComplexNavigationsQueryFixtureBase.cs | 99 +-- .../Query/ComplexNavigationsQueryTestBase.cs | 86 +- .../ComplexNavigationsWeakQueryFixtureBase.cs | 11 +- .../Query/FunkyDataQueryTestBase.cs | 26 +- .../Query/GearsOfWarQueryFixtureBase.cs | 26 +- .../Query/IQueryFixtureBase.cs | 27 +- .../Query/ManyToManyQueryFixtureBase.cs | 30 +- .../Query/ManyToManyQueryTestBase.cs | 2 +- .../NorthwindMiscellaneousQueryTestBase.cs | 14 +- .../Query/NorthwindQueryFixtureBase.cs | 25 +- .../Query/OwnedQueryTestBase.cs | 30 +- .../Query/QueryTestBase.cs | 165 ++-- .../Query/SpatialQueryFixtureBase.cs | 18 +- .../ExpectedQueryRewritingVisitor.cs | 2 +- .../IncludeQueryResultAsserter.cs | 199 ----- .../TestUtilities/QueryAsserter.cs | 761 ++++++++++-------- .../TestUtilities/QueryAsserterBase.cs | 536 ------------ .../AsyncGearsOfWarQuerySqlServerTest.cs | 4 +- ...ComplexNavigationsQuerySqlServerFixture.cs | 2 - .../ComplexNavigationsQuerySqlServerTest.cs | 4 +- .../Query/FunkyDataQuerySqlServerTest.cs | 20 +- .../Query/GearsOfWarQuerySqlServerFixture.cs | 3 - .../Query/GearsOfWarQuerySqlServerTest.cs | 7 +- .../Query/ManyToManyQuerySqlServerTest.cs | 4 +- ...indAggregateOperatorsQuerySqlServerTest.cs | 4 +- .../NorthwindAsyncSimpleQuerySqlServerTest.cs | 4 +- .../NorthwindDbFunctionsQuerySqlServerTest.cs | 2 +- .../NorthwindFunctionsQuerySqlServerTest.cs | 4 +- .../NorthwindGroupByQuerySqlServerTest.cs | 4 +- .../NorthwindIncludeQuerySqlServerTest.cs | 4 +- .../Query/NorthwindJoinQuerySqlServerTest.cs | 4 +- ...thwindKeylessEntitiesQuerySqlServerTest.cs | 4 +- ...orthwindMiscellaneousQuerySqlServerTest.cs | 4 +- .../NorthwindNavigationsQuerySqlServerTest.cs | 4 +- .../Query/NorthwindQuerySqlServerFixture.cs | 2 - .../NorthwindSelectQuerySqlServerTest.cs | 4 +- ...orthwindSetOperationsQuerySqlServerTest.cs | 4 +- .../Query/NorthwindWhereQuerySqlServerTest.cs | 4 +- .../Query/OwnedQuerySqlServerTest.cs | 6 +- .../Query/SpatialQuerySqlServerFixture.cs | 2 - .../SpatialQuerySqlServerGeographyTest.cs | 4 +- .../SpatialQuerySqlServerGeometryTest.cs | 4 +- .../Query/AsyncGearsOfWarQuerySqliteTest.cs | 2 +- .../ComplexNavigationsQuerySqliteTest.cs | 2 +- .../Query/FunkyDataQuerySqliteTest.cs | 18 +- .../Query/GearsOfWarQuerySqliteTest.cs | 2 +- .../Query/IncludeSqliteFixture.cs | 13 - .../Query/ManyToManyQuerySqliteTest.cs | 2 +- ...thwindAggregateOperatorsQuerySqliteTest.cs | 2 +- .../NorthwindAsyncSimpleQuerySqliteTest.cs | 2 +- ...cs => NorthwindCompiledQuerySqliteTest.cs} | 0 .../NorthwindDbFunctionsQuerySqliteTest.cs | 2 +- .../NorthwindFunctionsQuerySqliteTest.cs | 2 +- .../Query/NorthwindGroupByQuerySqliteTest.cs | 2 +- .../Query/NorthwindIncludeQuerySqliteTest.cs | 5 +- .../Query/NorthwindJoinQuerySqliteTest.cs | 2 +- ...NorthwindKeylessEntitiesQuerySqliteTest.cs | 2 +- .../NorthwindMiscellaneousQuerySqliteTest.cs | 2 +- .../NorthwindNavigationsQuerySqliteTest.cs | 2 +- .../Query/NorthwindSelectQuerySqliteTest.cs | 2 +- .../NorthwindSetOperationsQuerySqliteTest.cs | 2 +- .../Query/NorthwindWhereQuerySqliteTest.cs | 2 +- .../Query/OwnedQuerySqliteTest.cs | 2 +- .../Query/SpatialQuerySqliteTest.cs | 2 +- 93 files changed, 1183 insertions(+), 1575 deletions(-) delete mode 100644 test/EFCore.InMemory.FunctionalTests/Query/IncludeInMemoryFixture.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/AsyncGearsOfWarQueryRelationalTestBase.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalTestBase.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalTestBase.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalTestBase.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/NorthwindAggregateOperatorsQueryRelationalTestBase.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/NorthwindAsyncSimpleQueryRelationalTestBase.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/NorthwindGroupByQueryRelationalTestBase.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/NorthwindIncludeQueryRelationalTestBase.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/NorthwindJoinQueryRelationalTestBase.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/NorthwindKeylessEntitiesQueryRelationalTestBase.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/NorthwindMiscellaneousQueryRelationalTestBase.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/NorthwindNavigationsQueryRelationalTestBase.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/NorthwindSelectQueryRelationalTestBase.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/NorthwindSetOperationsQueryRelationalTestBase.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/NorthwindWhereQueryRelationalTestBase.cs rename test/EFCore.Relational.Specification.Tests/Query/{RelationalOwnedQueryTestBase.cs => OwnedQueryRelationalTestBase.cs} (68%) create mode 100644 test/EFCore.Relational.Specification.Tests/Query/SpatialQueryRelationalTestBase.cs delete mode 100644 test/EFCore.Specification.Tests/TestUtilities/IncludeQueryResultAsserter.cs delete mode 100644 test/EFCore.Specification.Tests/TestUtilities/QueryAsserterBase.cs delete mode 100644 test/EFCore.Sqlite.FunctionalTests/Query/IncludeSqliteFixture.cs rename test/EFCore.Sqlite.FunctionalTests/Query/{CompiledQueryInMemoryTest.cs => NorthwindCompiledQuerySqliteTest.cs} (100%) diff --git a/test/EFCore.InMemory.FunctionalTests/Query/IncludeInMemoryFixture.cs b/test/EFCore.InMemory.FunctionalTests/Query/IncludeInMemoryFixture.cs deleted file mode 100644 index 7c703a70cc2..00000000000 --- a/test/EFCore.InMemory.FunctionalTests/Query/IncludeInMemoryFixture.cs +++ /dev/null @@ -1,13 +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 IncludeInMemoryFixture : NorthwindQueryInMemoryFixture - { - public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) - => base.AddOptions(builder); - } -} diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeQueryInMemoryTest.cs index 7022f4a9c0e..6bf8f70cf0b 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeQueryInMemoryTest.cs @@ -2,14 +2,15 @@ // 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 class NorthwindIncludeQueryInMemoryTest : NorthwindIncludeQueryTestBase + public class NorthwindIncludeQueryInMemoryTest : NorthwindIncludeQueryTestBase> { - public NorthwindIncludeQueryInMemoryTest(IncludeInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindIncludeQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { //TestLoggerFactory.TestOutputHelper = testOutputHelper; diff --git a/test/EFCore.Relational.Specification.Tests/Query/AsyncGearsOfWarQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/AsyncGearsOfWarQueryRelationalTestBase.cs new file mode 100644 index 00000000000..3292319e31e --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/AsyncGearsOfWarQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class AsyncGearsOfWarQueryRelationalTestBase : AsyncGearsOfWarQueryTestBase + where TFixture : GearsOfWarQueryFixtureBase, new() + { + protected AsyncGearsOfWarQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalFixtureBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalFixtureBase.cs index a61b4cf57bd..234440c588b 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalFixtureBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalFixtureBase.cs @@ -1,9 +1,6 @@ -// 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.Collections.Generic; -using Microsoft.EntityFrameworkCore.TestModels.ComplexNavigationsModel; using Microsoft.EntityFrameworkCore.TestUtilities; namespace Microsoft.EntityFrameworkCore.Query @@ -11,16 +8,5 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class ComplexNavigationsQueryRelationalFixtureBase : ComplexNavigationsQueryFixtureBase { public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - - protected override QueryAsserter CreateQueryAsserter( - Dictionary entitySorters, - Dictionary entityAsserters) - => new RelationalQueryAsserter( - CreateContext, - new ComplexNavigationsDefaultData(), - entitySorters, - entityAsserters, - CanExecuteQueryString, - CreateExpectedQueryRewritingVisitor()); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalTestBase.cs new file mode 100644 index 00000000000..c1dc9988fcf --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class ComplexNavigationsQueryRelationalTestBase : ComplexNavigationsQueryTestBase + where TFixture : ComplexNavigationsQueryFixtureBase, new() + { + protected ComplexNavigationsQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs index b7c4d06c0b2..192fa104000 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs @@ -1,9 +1,6 @@ -// 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.Collections.Generic; -using Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel; using Microsoft.EntityFrameworkCore.TestUtilities; namespace Microsoft.EntityFrameworkCore.Query @@ -16,15 +13,5 @@ public abstract class GearsOfWarQueryRelationalFixture : GearsOfWarQueryFixtureB protected override bool ShouldLogCategory(string logCategory) => logCategory == DbLoggerCategory.Query.Name; - - protected override QueryAsserter CreateQueryAsserter( - Dictionary entitySorters, - Dictionary entityAsserters) - => new RelationalQueryAsserter( - CreateContext, - new GearsOfWarData(), - entitySorters, - entityAsserters, - CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalTestBase.cs new file mode 100644 index 00000000000..bc861a5a56d --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class GearsOfWarQueryRelationalTestBase : GearsOfWarQueryTestBase + where TFixture : GearsOfWarQueryFixtureBase, new() + { + protected GearsOfWarQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalFixture.cs index 5a0371c2d31..85879b0abbd 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalFixture.cs @@ -1,9 +1,6 @@ // 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.Collections.Generic; -using Microsoft.EntityFrameworkCore.TestModels.ManyToManyModel; using Microsoft.EntityFrameworkCore.TestUtilities; namespace Microsoft.EntityFrameworkCore.Query @@ -11,15 +8,5 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class ManyToManyQueryRelationalFixture : ManyToManyQueryFixtureBase { public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - - protected override QueryAsserter CreateQueryAsserter( - Dictionary entitySorters, - Dictionary entityAsserters) - => new RelationalQueryAsserter( - CreateContext, - new ManyToManyData(), - entitySorters, - entityAsserters, - CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalTestBase.cs new file mode 100644 index 00000000000..fbc763b3ac3 --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class ManyToManyQueryRelationalTestBase : ManyToManyQueryTestBase + where TFixture : ManyToManyQueryFixtureBase, new() + { + protected ManyToManyQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindAggregateOperatorsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindAggregateOperatorsQueryRelationalTestBase.cs new file mode 100644 index 00000000000..9630e343e52 --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindAggregateOperatorsQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class NorthwindAggregateOperatorsQueryRelationalTestBase : NorthwindAggregateOperatorsQueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() + { + protected NorthwindAggregateOperatorsQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindAsyncSimpleQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindAsyncSimpleQueryRelationalTestBase.cs new file mode 100644 index 00000000000..f30fc44da96 --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindAsyncSimpleQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class NorthwindAsyncSimpleQueryRelationalTestBase : NorthwindAsyncSimpleQueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() + { + protected NorthwindAsyncSimpleQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs new file mode 100644 index 00000000000..71edfd71749 --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class NorthwindFunctionsQueryRelationalTestBase : NorthwindFunctionsQueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() + { + protected NorthwindFunctionsQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindGroupByQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindGroupByQueryRelationalTestBase.cs new file mode 100644 index 00000000000..5181fcbfb97 --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindGroupByQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class NorthwindGroupByQueryRelationalTestBase : NorthwindGroupByQueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() + { + protected NorthwindGroupByQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindIncludeQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindIncludeQueryRelationalTestBase.cs new file mode 100644 index 00000000000..feb20e86798 --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindIncludeQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class NorthwindIncludeQueryRelationalTestBase : NorthwindIncludeQueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() + { + protected NorthwindIncludeQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindJoinQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindJoinQueryRelationalTestBase.cs new file mode 100644 index 00000000000..959ecab376b --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindJoinQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class NorthwindJoinQueryRelationalTestBase : NorthwindJoinQueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() + { + protected NorthwindJoinQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindKeylessEntitiesQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindKeylessEntitiesQueryRelationalTestBase.cs new file mode 100644 index 00000000000..d33f91b0f55 --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindKeylessEntitiesQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class NorthwindKeylessEntitiesQueryRelationalTestBase : NorthwindKeylessEntitiesQueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() + { + protected NorthwindKeylessEntitiesQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindMiscellaneousQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindMiscellaneousQueryRelationalTestBase.cs new file mode 100644 index 00000000000..e75694a87a6 --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindMiscellaneousQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class NorthwindMiscellaneousQueryRelationalTestBase : NorthwindMiscellaneousQueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() + { + protected NorthwindMiscellaneousQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindNavigationsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindNavigationsQueryRelationalTestBase.cs new file mode 100644 index 00000000000..aa6a77c6058 --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindNavigationsQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class NorthwindNavigationsQueryRelationalTestBase : NorthwindNavigationsQueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() + { + protected NorthwindNavigationsQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindQueryRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindQueryRelationalFixture.cs index b291033b272..6dadb83e87a 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindQueryRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindQueryRelationalFixture.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.TestModels.Northwind; @@ -27,15 +26,5 @@ protected override bool ShouldLogCategory(string logCategory) => logCategory == DbLoggerCategory.Query.Name; protected override Type ContextType => typeof(NorthwindRelationalContext); - - protected override QueryAsserter CreateQueryAsserter( - Dictionary entitySorters, - Dictionary entityAsserters) - => new RelationalQueryAsserter( - CreateContext, - new NorthwindData(), - entitySorters, - entityAsserters, - CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindSelectQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindSelectQueryRelationalTestBase.cs new file mode 100644 index 00000000000..812b97a8183 --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindSelectQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class NorthwindSelectQueryRelationalTestBase : NorthwindSelectQueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() + { + protected NorthwindSelectQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindSetOperationsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindSetOperationsQueryRelationalTestBase.cs new file mode 100644 index 00000000000..05ebd6546f2 --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindSetOperationsQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class NorthwindSetOperationsQueryRelationalTestBase : NorthwindSetOperationsQueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() + { + protected NorthwindSetOperationsQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindWhereQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindWhereQueryRelationalTestBase.cs new file mode 100644 index 00000000000..6c04971c80a --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindWhereQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class NorthwindWhereQueryRelationalTestBase : NorthwindWhereQueryTestBase + where TFixture : NorthwindQueryFixtureBase, new() + { + protected NorthwindWhereQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryFixtureBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryFixtureBase.cs index 2ce9299cc51..4514bbeca97 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryFixtureBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryFixtureBase.cs @@ -12,15 +12,19 @@ namespace Microsoft.EntityFrameworkCore.Query { public abstract class NullSemanticsQueryFixtureBase : SharedStoreFixtureBase, IQueryFixtureBase { - public NullSemanticsQueryFixtureBase() - { - var entitySorters = new Dictionary> + public Func GetContextCreator() => () => CreateContext(); + + public ISetSource GetExpectedData() => new NullSemanticsData(); + + public IReadOnlyDictionary GetEntitySorters() + => new Dictionary> { { typeof(NullSemanticsEntity1), e => ((NullSemanticsEntity1)e)?.Id }, { typeof(NullSemanticsEntity2), e => ((NullSemanticsEntity2)e)?.Id } }.ToDictionary(e => e.Key, e => (object)e.Value); - var entityAsserters = new Dictionary> + public IReadOnlyDictionary GetEntityAsserters() + => new Dictionary> { { typeof(NullSemanticsEntity1), (e, a) => @@ -86,22 +90,8 @@ public NullSemanticsQueryFixtureBase() }, }.ToDictionary(e => e.Key, e => (object)e.Value); - QueryAsserter = CreateQueryAsserter(entitySorters, entityAsserters); - } - - protected virtual QueryAsserter CreateQueryAsserter( - Dictionary entitySorters, - Dictionary entityAsserters) - => new QueryAsserter( - CreateContext, - new NullSemanticsData(), - entitySorters, - entityAsserters); - protected override string StoreName { get; } = "NullSemanticsQueryTest"; - public QueryAsserterBase QueryAsserter { get; set; } - public new RelationalTestStore TestStore => (RelationalTestStore)base.TestStore; public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; diff --git a/test/EFCore.Relational.Specification.Tests/Query/RelationalOwnedQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/OwnedQueryRelationalTestBase.cs similarity index 68% rename from test/EFCore.Relational.Specification.Tests/Query/RelationalOwnedQueryTestBase.cs rename to test/EFCore.Relational.Specification.Tests/Query/OwnedQueryRelationalTestBase.cs index 5f8fc1b718c..56e0edd6692 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/RelationalOwnedQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/OwnedQueryRelationalTestBase.cs @@ -7,28 +7,23 @@ namespace Microsoft.EntityFrameworkCore.Query { - public abstract class RelationalOwnedQueryTestBase : OwnedQueryTestBase - where TFixture : RelationalOwnedQueryTestBase.RelationalOwnedQueryFixture, new() + public abstract class OwnedQueryRelationalTestBase : OwnedQueryTestBase + where TFixture : OwnedQueryRelationalTestBase.RelationalOwnedQueryFixture, new() { - protected RelationalOwnedQueryTestBase(TFixture fixture) + protected OwnedQueryRelationalTestBase(TFixture fixture) : base(fixture) { } + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + public abstract class RelationalOwnedQueryFixture : OwnedQueryFixtureBase { public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - protected override QueryAsserter CreateQueryAsserter( - Dictionary entitySorters, - Dictionary entityAsserters) - => new RelationalQueryAsserter( - CreateContext, - new OwnedQueryData(), - entitySorters, - entityAsserters, - CanExecuteQueryString); - protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { base.OnModelCreating(modelBuilder, context); diff --git a/test/EFCore.Relational.Specification.Tests/Query/RelationalNorthwindDbFunctionsQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/RelationalNorthwindDbFunctionsQueryTestBase.cs index e980d032a80..e567836a7d2 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/RelationalNorthwindDbFunctionsQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/RelationalNorthwindDbFunctionsQueryTestBase.cs @@ -9,14 +9,19 @@ namespace Microsoft.EntityFrameworkCore.Query { - public abstract class RelationalNorthwindDbFunctionsQueryTestBase : NorthwindDbFunctionsQueryTestBase + public abstract class NorthwindDbFunctionsQueryRelationalTestBase : NorthwindDbFunctionsQueryTestBase where TFixture : NorthwindQueryRelationalFixture, new() { - public RelationalNorthwindDbFunctionsQueryTestBase(TFixture fixture) + public NorthwindDbFunctionsQueryRelationalTestBase(TFixture fixture) : base(fixture) { } + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Collate_case_insensitive(bool async) diff --git a/test/EFCore.Relational.Specification.Tests/Query/SpatialQueryRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/Query/SpatialQueryRelationalFixture.cs index f9d4c96f35c..8d4861bef26 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/SpatialQueryRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/SpatialQueryRelationalFixture.cs @@ -1,7 +1,6 @@ // 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.TestModels.SpatialModel; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -18,13 +17,5 @@ public TestSqlLoggerFactory TestSqlLoggerFactory protected override bool ShouldLogCategory(string logCategory) => logCategory == DbLoggerCategory.Query.Name; - - protected override QueryAsserter CreateQueryAsserter() - => new RelationalQueryAsserter( - CreateContext, - new SpatialData(GeometryFactory), - entitySorters: null, - entityAsserters: null, - CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/SpatialQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/SpatialQueryRelationalTestBase.cs new file mode 100644 index 00000000000..745af1fe3bd --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/SpatialQueryRelationalTestBase.cs @@ -0,0 +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 Microsoft.EntityFrameworkCore.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class SpatialQueryRelationalTestBase : SpatialQueryTestBase + where TFixture : SpatialQueryFixtureBase, new() + { + protected SpatialQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(TFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + } +} diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalQueryAsserter.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalQueryAsserter.cs index 00f4256c46d..44f9e84e0ac 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalQueryAsserter.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalQueryAsserter.cs @@ -2,26 +2,25 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Data.Common; using System.Linq; +using System.Linq.Expressions; +using Microsoft.EntityFrameworkCore.Query; using Xunit; namespace Microsoft.EntityFrameworkCore.TestUtilities { - public class RelationalQueryAsserter : QueryAsserter - where TContext : DbContext + public class RelationalQueryAsserter : QueryAsserter { private readonly bool _canExecuteQueryString; public RelationalQueryAsserter( - Func contextCreator, - ISetSource expectedData, - Dictionary entitySorters, - Dictionary entityAsserters, - bool canExecuteQueryString, - ExpectedQueryRewritingVisitor expectedQueryRewritingVisitor = null) - : base(contextCreator, expectedData, entitySorters, entityAsserters, expectedQueryRewritingVisitor) + IQueryFixtureBase queryFixture, + Func rewriteExpectedQueryExpression, + Func rewriteServerQueryExpression, + bool ignoreEntryCount = false, + bool canExecuteQueryString = false) + : base(queryFixture, rewriteExpectedQueryExpression, rewriteServerQueryExpression, ignoreEntryCount) { _canExecuteQueryString = canExecuteQueryString; } diff --git a/test/EFCore.Specification.Tests/FixtureBase.cs b/test/EFCore.Specification.Tests/FixtureBase.cs index 495a20b55fc..d260734b6f0 100644 --- a/test/EFCore.Specification.Tests/FixtureBase.cs +++ b/test/EFCore.Specification.Tests/FixtureBase.cs @@ -20,9 +20,6 @@ public virtual DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builde .Log(CoreEventId.SensitiveDataLoggingEnabledWarning) .Log(CoreEventId.PossibleUnintendedReferenceComparisonWarning)); - - protected virtual bool CanExecuteQueryString => false; - protected virtual void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { } diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryFixtureBase.cs index 43c23901510..a249013c6e9 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryFixtureBase.cs @@ -16,9 +16,12 @@ public abstract class ComplexNavigationsQueryFixtureBase : SharedStoreFixtureBas { protected override string StoreName { get; } = "ComplexNavigations"; - protected ComplexNavigationsQueryFixtureBase() - { - var entitySorters = new Dictionary> + public Func GetContextCreator() => () => CreateContext(); + + public virtual ISetSource GetExpectedData() => new ComplexNavigationsDefaultData(); + + public IReadOnlyDictionary GetEntitySorters() + => new Dictionary> { { typeof(Level1), e => ((Level1)e)?.Id }, { typeof(Level2), e => ((Level2)e)?.Id }, @@ -32,7 +35,8 @@ protected ComplexNavigationsQueryFixtureBase() { typeof(InheritanceLeaf2), e => ((InheritanceLeaf2)e)?.Id } }.ToDictionary(e => e.Key, e => (object)e.Value); - var entityAsserters = new Dictionary> + public IReadOnlyDictionary GetEntityAsserters() + => new Dictionary> { { typeof(Level1), (e, a) => @@ -194,93 +198,6 @@ protected ComplexNavigationsQueryFixtureBase() } }.ToDictionary(e => e.Key, e => (object)e.Value); - QueryAsserter = CreateQueryAsserter(entitySorters, entityAsserters); - } - - protected virtual QueryAsserter CreateQueryAsserter( - Dictionary entitySorters, - Dictionary entityAsserters) - => new QueryAsserter( - CreateContext, - new ComplexNavigationsDefaultData(), - entitySorters, - entityAsserters, - CreateExpectedQueryRewritingVisitor()); - - private MemberInfo GetMemberInfo(Type sourceType, string name) - => sourceType.GetMember(name).Single(); - - protected virtual ExpectedQueryRewritingVisitor CreateExpectedQueryRewritingVisitor() - => new ExpectedQueryRewritingVisitor(new Dictionary<(Type, string), MemberInfo[]> - { - { - (typeof(Level1), "OneToMany_Optional_Self_Inverse1Id"), - new [] - { - GetMemberInfo(typeof(Level1), "OneToMany_Optional_Self_Inverse1"), - GetMemberInfo(typeof(Level1), "Id") - } - }, - { - (typeof(Level1), "OneToOne_Optional_Self1Id"), - new [] - { - GetMemberInfo(typeof(Level1), "OneToOne_Optional_Self1"), - GetMemberInfo(typeof(Level1), "Id") - } - }, - { - (typeof(Level2), "OneToMany_Optional_Self_Inverse2Id"), - new [] - { - GetMemberInfo(typeof(Level2), "OneToMany_Optional_Self_Inverse2"), - GetMemberInfo(typeof(Level2), "Id") - } - }, - { - (typeof(Level2), "OneToOne_Optional_Self2Id"), - new [] - { - GetMemberInfo(typeof(Level2), "OneToOne_Optional_Self2"), - GetMemberInfo(typeof(Level2), "Id") - } - }, - { - (typeof(Level3), "OneToMany_Optional_Self_Inverse3Id"), - new [] - { - GetMemberInfo(typeof(Level3), "OneToMany_Optional_Self_Inverse3"), - GetMemberInfo(typeof(Level3), "Id") - } - }, - { - (typeof(Level3), "OneToOne_Optional_Self3Id"), - new [] - { - GetMemberInfo(typeof(Level3), "OneToOne_Optional_Self3"), - GetMemberInfo(typeof(Level3), "Id") - } - }, - { - (typeof(Level4), "OneToMany_Optional_Self_Inverse4Id"), - new [] - { - GetMemberInfo(typeof(Level4), "OneToMany_Optional_Self_Inverse4"), - GetMemberInfo(typeof(Level4), "Id") - } - }, - { - (typeof(Level4), "OneToOne_Optional_Self4Id"), - new [] - { - GetMemberInfo(typeof(Level4), "OneToOne_Optional_Self4"), - GetMemberInfo(typeof(Level4), "Id") - } - }, - }); - - public QueryAsserterBase QueryAsserter { get; set; } - protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { modelBuilder.Entity().Property(e => e.Id).ValueGeneratedNever(); diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs index 0e541489641..70c02eb76eb 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs @@ -4,6 +4,8 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; +using System.Reflection; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.ComplexNavigationsModel; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -28,16 +30,88 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class ComplexNavigationsQueryTestBase : QueryTestBase where TFixture : ComplexNavigationsQueryFixtureBase, new() { - protected ComplexNavigationsContext CreateContext() - { - return Fixture.CreateContext(); - } + protected ComplexNavigationsContext CreateContext() => Fixture.CreateContext(); protected ComplexNavigationsQueryTestBase(TFixture fixture) : base(fixture) { } + protected override Expression RewriteExpectedQueryExpression(Expression expectedQueryExpression) + => CreateExpectedQueryRewritingVisitor().Visit(expectedQueryExpression); + + private MemberInfo GetMemberInfo(Type sourceType, string name) + => sourceType.GetMember(name).Single(); + + private ExpectedQueryRewritingVisitor CreateExpectedQueryRewritingVisitor() + => new ExpectedQueryRewritingVisitor(new Dictionary<(Type, string), MemberInfo[]> + { + { + (typeof(Level1), "OneToMany_Optional_Self_Inverse1Id"), + new [] + { + GetMemberInfo(typeof(Level1), "OneToMany_Optional_Self_Inverse1"), + GetMemberInfo(typeof(Level1), "Id") + } + }, + { + (typeof(Level1), "OneToOne_Optional_Self1Id"), + new [] + { + GetMemberInfo(typeof(Level1), "OneToOne_Optional_Self1"), + GetMemberInfo(typeof(Level1), "Id") + } + }, + { + (typeof(Level2), "OneToMany_Optional_Self_Inverse2Id"), + new [] + { + GetMemberInfo(typeof(Level2), "OneToMany_Optional_Self_Inverse2"), + GetMemberInfo(typeof(Level2), "Id") + } + }, + { + (typeof(Level2), "OneToOne_Optional_Self2Id"), + new [] + { + GetMemberInfo(typeof(Level2), "OneToOne_Optional_Self2"), + GetMemberInfo(typeof(Level2), "Id") + } + }, + { + (typeof(Level3), "OneToMany_Optional_Self_Inverse3Id"), + new [] + { + GetMemberInfo(typeof(Level3), "OneToMany_Optional_Self_Inverse3"), + GetMemberInfo(typeof(Level3), "Id") + } + }, + { + (typeof(Level3), "OneToOne_Optional_Self3Id"), + new [] + { + GetMemberInfo(typeof(Level3), "OneToOne_Optional_Self3"), + GetMemberInfo(typeof(Level3), "Id") + } + }, + { + (typeof(Level4), "OneToMany_Optional_Self_Inverse4Id"), + new [] + { + GetMemberInfo(typeof(Level4), "OneToMany_Optional_Self_Inverse4"), + GetMemberInfo(typeof(Level4), "Id") + } + }, + { + (typeof(Level4), "OneToOne_Optional_Self4Id"), + new [] + { + GetMemberInfo(typeof(Level4), "OneToOne_Optional_Self4"), + GetMemberInfo(typeof(Level4), "Id") + } + }, + }); + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Entity_equality_empty(bool async) @@ -3506,7 +3580,7 @@ public virtual void Entries_for_detached_entities_are_removed() { using var context = CreateContext(); context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.TrackAll; - var entity = Fixture.QueryAsserter.SetSourceCreator(context).Set().OrderBy(l2 => l2.Id).First(); + var entity = QueryAsserter.SetSourceCreator(context).Set().OrderBy(l2 => l2.Id).First(); var entry = context.ChangeTracker.Entries().Single(); Assert.Same(entity, entry.Entity); @@ -4864,7 +4938,7 @@ public virtual void Contains_over_optional_navigation_with_null_constant() { using var ctx = CreateContext(); var result = ctx.Set().Select(l1 => l1.OneToOne_Optional_FK1).Contains(null); - var expected = Fixture.QueryAsserter.ExpectedData.Set().Select(l1 => l1.OneToOne_Optional_FK1).Contains(null); + var expected = QueryAsserter.ExpectedData.Set().Select(l1 => l1.OneToOne_Optional_FK1).Contains(null); Assert.Equal(expected, result); } diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryFixtureBase.cs index 1db06c5941a..03046bfa7f0 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryFixtureBase.cs @@ -11,15 +11,14 @@ namespace Microsoft.EntityFrameworkCore.Query { - public abstract class ComplexNavigationsWeakQueryFixtureBase : ComplexNavigationsQueryFixtureBase + public abstract class ComplexNavigationsWeakQueryFixtureBase : ComplexNavigationsQueryFixtureBase, IQueryFixtureBase { protected override string StoreName { get; } = "ComplexNavigationsOwned"; - protected ComplexNavigationsWeakQueryFixtureBase() - { - QueryAsserter.SetSourceCreator = ctx => new ComplexNavigationsWeakSetExtractor(ctx); - QueryAsserter.ExpectedData = new ComplexNavigationsWeakData(); - } + public override ISetSource GetExpectedData() => new ComplexNavigationsWeakData(); + + Func IQueryFixtureBase.GetSetSourceCreator() + => context => new ComplexNavigationsWeakSetExtractor(context); protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs index 7cfc228a58a..d7e1afe4029 100644 --- a/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs @@ -543,12 +543,16 @@ protected virtual void ClearLog() public abstract class FunkyDataQueryFixtureBase : SharedStoreFixtureBase, IQueryFixtureBase { - public FunkyDataQueryFixtureBase() - { - var entitySorters = new Dictionary> { { typeof(FunkyCustomer), e => ((FunkyCustomer)e)?.Id } } + public Func GetContextCreator() => () => CreateContext(); + + public ISetSource GetExpectedData() => new FunkyDataData(); + + public IReadOnlyDictionary GetEntitySorters() + => new Dictionary> { { typeof(FunkyCustomer), e => ((FunkyCustomer)e)?.Id } } .ToDictionary(e => e.Key, e => (object)e.Value); - var entityAsserters = new Dictionary> + public IReadOnlyDictionary GetEntityAsserters() + => new Dictionary> { { typeof(FunkyCustomer), (e, a) => @@ -568,22 +572,8 @@ public FunkyDataQueryFixtureBase() } }.ToDictionary(e => e.Key, e => (object)e.Value); - QueryAsserter = CreateQueryAsserter(entitySorters, entityAsserters); - } - - protected virtual QueryAsserter CreateQueryAsserter( - Dictionary entitySorters, - Dictionary entityAsserters) - => new QueryAsserter( - CreateContext, - new FunkyDataData(), - entitySorters, - entityAsserters); - protected override string StoreName { get; } = "FunkyDataQueryTest"; - public QueryAsserterBase QueryAsserter { get; set; } - public override FunkyDataContext CreateContext() { var context = base.CreateContext(); diff --git a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs index 2884dd1fdc1..6a72612c078 100644 --- a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs @@ -14,9 +14,12 @@ public abstract class GearsOfWarQueryFixtureBase : SharedStoreFixtureBase> + public Func GetContextCreator() => () => CreateContext(); + + public ISetSource GetExpectedData() => new GearsOfWarData(); + + public IReadOnlyDictionary GetEntitySorters() + => new Dictionary> { { typeof(City), e => ((City)e)?.Name }, { typeof(CogTag), e => ((CogTag)e)?.Id }, @@ -33,7 +36,8 @@ protected GearsOfWarQueryFixtureBase() { typeof(LocustHighCommand), e => ((LocustHighCommand)e)?.Id } }.ToDictionary(e => e.Key, e => (object)e.Value); - var entityAsserters = new Dictionary> + public IReadOnlyDictionary GetEntityAsserters() + => new Dictionary> { { typeof(City), (e, a) => @@ -270,20 +274,6 @@ protected GearsOfWarQueryFixtureBase() } }.ToDictionary(e => e.Key, e => (object)e.Value); - QueryAsserter = CreateQueryAsserter(entitySorters, entityAsserters); - } - - protected virtual QueryAsserter CreateQueryAsserter( - Dictionary entitySorters, - Dictionary entityAsserters) - => new QueryAsserter( - CreateContext, - new GearsOfWarData(), - entitySorters, - entityAsserters); - - public QueryAsserterBase QueryAsserter { get; set; } - protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { modelBuilder.Entity( diff --git a/test/EFCore.Specification.Tests/Query/IQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/IQueryFixtureBase.cs index 8c68e1a109a..c7b91790236 100644 --- a/test/EFCore.Specification.Tests/Query/IQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/IQueryFixtureBase.cs @@ -1,12 +1,37 @@ // 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.Collections.Generic; +using System.Linq; using Microsoft.EntityFrameworkCore.TestUtilities; namespace Microsoft.EntityFrameworkCore.Query { public interface IQueryFixtureBase { - QueryAsserterBase QueryAsserter { get; set; } + Func GetContextCreator(); + + Func GetSetSourceCreator() => context => new DefaultSetSource(context); + + ISetSource GetExpectedData(); + + IReadOnlyDictionary GetEntitySorters(); + + IReadOnlyDictionary GetEntityAsserters(); + + private class DefaultSetSource : ISetSource + { + private readonly DbContext _context; + + public DefaultSetSource(DbContext context) + { + _context = context; + } + + public IQueryable Set() + where TEntity : class + => _context.Set(); + } } } diff --git a/test/EFCore.Specification.Tests/Query/ManyToManyQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/ManyToManyQueryFixtureBase.cs index a5a71baa3e0..c9f91f169c9 100644 --- a/test/EFCore.Specification.Tests/Query/ManyToManyQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/ManyToManyQueryFixtureBase.cs @@ -14,16 +14,20 @@ public abstract class ManyToManyQueryFixtureBase : SharedStoreFixtureBase> + public Func GetContextCreator() => () => CreateContext(); + + public ISetSource GetExpectedData() => new ManyToManyData(); + + public IReadOnlyDictionary GetEntitySorters() + => new Dictionary> { { typeof(EntityOne), e => ((EntityOne)e)?.Id }, { typeof(EntityTwo), e => ((EntityTwo)e)?.Id }, { typeof(EntityThree), e => ((EntityThree)e)?.Id }, - }.ToDictionary(e => e.Key, e => (object)e.Value); ; + }.ToDictionary(e => e.Key, e => (object)e.Value); - var entityAsserters = new Dictionary> + public IReadOnlyDictionary GetEntityAsserters() + => new Dictionary> { { typeof(EntityOne), (e, a) => @@ -70,21 +74,7 @@ public ManyToManyQueryFixtureBase() } } }, - }.ToDictionary(e => e.Key, e => (object)e.Value); ; - - QueryAsserter = CreateQueryAsserter(entitySorters, entityAsserters); - } - - protected virtual QueryAsserter CreateQueryAsserter( - Dictionary entitySorters, - Dictionary entityAsserters) - => new QueryAsserter( - CreateContext, - new ManyToManyData(), - entitySorters, - entityAsserters); - - public QueryAsserterBase QueryAsserter { get; set; } + }.ToDictionary(e => e.Key, e => (object)e.Value); protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Specification.Tests/Query/ManyToManyQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ManyToManyQueryTestBase.cs index b53ae55af3c..4a2fd28ae87 100644 --- a/test/EFCore.Specification.Tests/Query/ManyToManyQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ManyToManyQueryTestBase.cs @@ -11,7 +11,7 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class ManyToManyQueryTestBase : QueryTestBase where TFixture : ManyToManyQueryFixtureBase, new() { - public ManyToManyQueryTestBase(TFixture fixture) + protected ManyToManyQueryTestBase(TFixture fixture) : base(fixture) { } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs index bb2ed89ab58..fdaba5983d8 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs @@ -1387,7 +1387,7 @@ public virtual void Select_DTO_distinct_translated_to_server() .Select(o => new OrderCountDTO()) .Distinct().ToList().OrderBy(e => e.Id).ToList(); - var expected = Fixture.QueryAsserter.ExpectedData.Set() + var expected = QueryAsserter.ExpectedData.Set() .Where(o => o.OrderID < 10300) .Select(o => new OrderCountDTO()) .Distinct().ToList().OrderBy(e => e.Id).ToList(); @@ -1409,7 +1409,7 @@ public virtual void Select_DTO_constructor_distinct_translated_to_server() .Select(o => new OrderCountDTO(o.CustomerID)) .Distinct().ToList().OrderBy(e => e.Id).ToList(); - var expected = Fixture.QueryAsserter.ExpectedData.Set() + var expected = QueryAsserter.ExpectedData.Set() .Where(o => o.OrderID < 10300) .Select(o => new OrderCountDTO(o.CustomerID)) .Distinct().ToList().OrderBy(e => e.Id).ToList(); @@ -1431,7 +1431,7 @@ public virtual void Select_DTO_constructor_distinct_with_navigation_translated_t .Select(o => new OrderCountDTO(o.Customer.City)) .Distinct().ToList().OrderBy(e => e.Id).ToList(); - var expected = Fixture.QueryAsserter.ExpectedData.Set() + var expected = QueryAsserter.ExpectedData.Set() .Where(o => o.OrderID < 10300) .Select(o => new OrderCountDTO(o.Customer.City)) .Distinct().ToList().OrderBy(e => e.Id).ToList(); @@ -1454,7 +1454,7 @@ public virtual void Select_DTO_with_member_init_distinct_translated_to_server() o => new OrderCountDTO { Id = o.CustomerID, Count = o.OrderID }) .Distinct().ToList().OrderBy(e => e.Count).ToList(); - var expected = Fixture.QueryAsserter.ExpectedData.Set() + var expected = QueryAsserter.ExpectedData.Set() .Where(o => o.OrderID < 10300) .Select( o => new OrderCountDTO { Id = o.CustomerID, Count = o.OrderID }) @@ -1478,7 +1478,7 @@ public virtual void Select_nested_collection_count_using_DTO() c => new OrderCountDTO { Id = c.CustomerID, Count = c.Orders.Count }) .ToList().OrderBy(e => e.Id).ToList(); - var expected = Fixture.QueryAsserter.ExpectedData.Set() + var expected = QueryAsserter.ExpectedData.Set() .Where(c => c.CustomerID.StartsWith("A")) .Select( c => new OrderCountDTO { Id = c.CustomerID, Count = c.Orders.Count }) @@ -1534,8 +1534,8 @@ from o in context.Set().Where(o => o.OrderID < 10300) .Distinct() select new { c, o }).ToList().OrderBy(e => e.c.CustomerID + " " + e.o.Count).ToList(); - var expected = (from c in Fixture.QueryAsserter.ExpectedData.Set().Where(c => c.CustomerID.StartsWith("A")) - from o in Fixture.QueryAsserter.ExpectedData.Set().Where(o => o.OrderID < 10300) + var expected = (from c in QueryAsserter.ExpectedData.Set().Where(c => c.CustomerID.StartsWith("A")) + from o in QueryAsserter.ExpectedData.Set().Where(o => o.OrderID < 10300) .Select( o => new OrderCountDTO { Id = o.CustomerID, Count = o.OrderID }) .Distinct() diff --git a/test/EFCore.Specification.Tests/Query/NorthwindQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindQueryFixtureBase.cs index 1402d9d5681..5e37f4cce30 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindQueryFixtureBase.cs @@ -15,9 +15,12 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class NorthwindQueryFixtureBase : SharedStoreFixtureBase, IQueryFixtureBase where TModelCustomizer : IModelCustomizer, new() { - protected NorthwindQueryFixtureBase() - { - var entitySorters = new Dictionary> + public Func GetContextCreator() => () => CreateContext(); + + public ISetSource GetExpectedData() => new NorthwindData(); + + public IReadOnlyDictionary GetEntitySorters() + => new Dictionary> { { typeof(Customer), e => ((Customer)e)?.CustomerID }, { typeof(CustomerView), e => ((CustomerView)e)?.CompanyName }, @@ -28,26 +31,12 @@ protected NorthwindQueryFixtureBase() { typeof(OrderDetail), e => (((OrderDetail)e)?.OrderID.ToString(), ((OrderDetail)e)?.ProductID.ToString()) } }.ToDictionary(e => e.Key, e => (object)e.Value); - var entityAsserters = new Dictionary(); - - QueryAsserter = CreateQueryAsserter(entitySorters, entityAsserters); - } - - protected virtual QueryAsserter CreateQueryAsserter( - Dictionary entitySorters, - Dictionary entityAsserters) - => new QueryAsserter( - CreateContext, - new NorthwindData(), - entitySorters, - entityAsserters); + public IReadOnlyDictionary GetEntityAsserters() => null; protected override string StoreName { get; } = "Northwind"; protected override bool UsePooling => typeof(TModelCustomizer) == typeof(NoopModelCustomizer); - public QueryAsserterBase QueryAsserter { get; set; } - protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) => new TModelCustomizer().Customize(modelBuilder, context); diff --git a/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs index a53e4d1cce6..84d80499b01 100644 --- a/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs @@ -400,7 +400,7 @@ public virtual async Task Owned_entity_without_owner_does_not_throw_for_identity public virtual async Task Preserve_includes_when_applying_skip_take_after_anonymous_type_select(bool async) { using var context = CreateContext(); - var expectedQuery = Fixture.QueryAsserter.ExpectedData.Set().OrderBy(p => p.Id); + var expectedQuery = QueryAsserter.ExpectedData.Set().OrderBy(p => p.Id); var expectedResult = expectedQuery.Select(q => new { Query = q, Count = expectedQuery.Count() }).Skip(0).Take(100).ToList(); var baseQuery = context.Set().OrderBy(p => p.Id); @@ -823,9 +823,12 @@ private static void AssertOrders(ICollection expectedOrders, ICollection< } } - public OwnedQueryFixtureBase() - { - var entitySorters = new Dictionary> + public Func GetContextCreator() => () => CreateContext(); + + public ISetSource GetExpectedData() => new OwnedQueryData(); + + public IReadOnlyDictionary GetEntitySorters() + => new Dictionary> { { typeof(OwnedPerson), e => ((OwnedPerson)e)?.Id }, { typeof(Branch), e => ((Branch)e)?.Id }, @@ -844,9 +847,9 @@ public OwnedQueryFixtureBase() { typeof(Element), e => ((Element)e)?.Id }, { typeof(Throned), e => ((Throned)e)?.Property } }.ToDictionary(e => e.Key, e => (object)e.Value); - ; - var entityAsserters = new Dictionary> + public IReadOnlyDictionary GetEntityAsserters() + => new Dictionary> { { typeof(OwnedPerson), (e, a) => @@ -1066,24 +1069,9 @@ public OwnedQueryFixtureBase() } } }.ToDictionary(e => e.Key, e => (object)e.Value); - ; - - QueryAsserter = CreateQueryAsserter(entitySorters, entityAsserters); - } - - protected virtual QueryAsserter CreateQueryAsserter( - Dictionary entitySorters, - Dictionary entityAsserters) - => new QueryAsserter( - CreateContext, - new OwnedQueryData(), - entitySorters, - entityAsserters); protected override string StoreName { get; } = "OwnedQueryTest"; - public QueryAsserterBase QueryAsserter { get; set; } - protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { modelBuilder.Entity( diff --git a/test/EFCore.Specification.Tests/Query/QueryTestBase.cs b/test/EFCore.Specification.Tests/Query/QueryTestBase.cs index 8f526b8f179..ef9c6e9034b 100644 --- a/test/EFCore.Specification.Tests/Query/QueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/QueryTestBase.cs @@ -16,9 +16,24 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class QueryTestBase : IClassFixture where TFixture : class, IQueryFixtureBase, new() { - protected QueryTestBase(TFixture fixture) => Fixture = fixture; + protected QueryTestBase(TFixture fixture) + { + Fixture = fixture; + QueryAsserter = CreateQueryAsserter(fixture); + } protected TFixture Fixture { get; } + protected QueryAsserter QueryAsserter { get; } + + protected virtual QueryAsserter CreateQueryAsserter(TFixture fixture) + => new QueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, IgnoreEntryCount); + + protected virtual bool IgnoreEntryCount => false; + + protected virtual Expression RewriteServerQueryExpression(Expression serverQueryExpression) => serverQueryExpression; + + protected virtual Expression RewriteExpectedQueryExpression(Expression expectedQueryExpression) + => new ExpectedQueryRewritingVisitor().Visit(expectedQueryExpression); public static IEnumerable IsAsyncData = new[] { new object[] { false }, new object[] { true } }; @@ -43,7 +58,7 @@ public Task AssertQuery( int entryCount = 0, [CallerMemberName] string testMethodName = null) where TResult : class - => Fixture.QueryAsserter.AssertQuery( + => QueryAsserter.AssertQuery( actualQuery, expectedQuery, elementSorter, elementAsserter, assertOrder, entryCount, async, testMethodName); public Task AssertQueryScalar( @@ -61,7 +76,7 @@ public Task AssertQueryScalar( bool assertOrder = false, [CallerMemberName] string testMethodName = null) where TResult : struct - => Fixture.QueryAsserter.AssertQueryScalar(actualQuery, expectedQuery, assertOrder, async, testMethodName); + => QueryAsserter.AssertQueryScalar(actualQuery, expectedQuery, assertOrder, async, testMethodName); public Task AssertQueryScalar( bool async, @@ -78,16 +93,15 @@ public Task AssertQueryScalar( bool assertOrder = false, [CallerMemberName] string testMethodName = null) where TResult : struct - => Fixture.QueryAsserter.AssertQueryScalar(actualQuery, expectedQuery, assertOrder, async, testMethodName); + => QueryAsserter.AssertQueryScalar(actualQuery, expectedQuery, assertOrder, async, testMethodName); protected Task AssertSingleResult( bool async, Expression> syncQuery, Expression>> asyncQuery, Action asserter = null, - int entryCount = 0, - [CallerMemberName] string testMethodName = null) - => AssertSingleResult(async, syncQuery, asyncQuery, syncQuery, asserter, entryCount, testMethodName); + int entryCount = 0) + => AssertSingleResult(async, syncQuery, asyncQuery, syncQuery, asserter, entryCount); protected Task AssertSingleResult( bool async, @@ -95,10 +109,9 @@ protected Task AssertSingleResult( Expression>> actualAsyncQuery, Expression> expectedQuery, Action asserter = null, - int entryCount = 0, - [CallerMemberName] string testMethodName = null) - => Fixture.QueryAsserter.AssertSingleResult( - actualSyncQuery, actualAsyncQuery, expectedQuery, asserter, entryCount, async, testMethodName); + int entryCount = 0) + => QueryAsserter.AssertSingleResult( + actualSyncQuery, actualAsyncQuery, expectedQuery, asserter, entryCount, async); #region Assert termination operation methods @@ -111,7 +124,7 @@ protected Task AssertAny( bool async, Func> actualQuery, Func> expectedQuery) - => Fixture.QueryAsserter.AssertAny( + => QueryAsserter.AssertAny( actualQuery, expectedQuery, async); protected Task AssertAny( @@ -126,7 +139,7 @@ protected Task AssertAny( Func> expectedQuery, Expression> actualPredicate, Expression> expectedPredicate) - => Fixture.QueryAsserter.AssertAny( + => QueryAsserter.AssertAny( actualQuery, expectedQuery, actualPredicate, expectedPredicate, async); protected Task AssertAll( @@ -141,7 +154,7 @@ protected Task AssertAll( Func> expectedQuery, Expression> actualPredicate, Expression> expectedPredicate) - => Fixture.QueryAsserter.AssertAll( + => QueryAsserter.AssertAll( actualQuery, expectedQuery, actualPredicate, expectedPredicate, async); protected Task AssertFirst( @@ -157,7 +170,7 @@ protected Task AssertFirst( Func> expectedQuery, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertFirst( + => QueryAsserter.AssertFirst( actualQuery, expectedQuery, asserter, entryCount, async); protected Task AssertFirst( @@ -176,7 +189,7 @@ protected Task AssertFirst( Expression> expectedPredicate, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertFirst( + => QueryAsserter.AssertFirst( actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, entryCount, async); protected Task AssertFirstOrDefault( @@ -192,7 +205,7 @@ protected Task AssertFirstOrDefault( Func> expectedQuery, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertFirstOrDefault( + => QueryAsserter.AssertFirstOrDefault( actualQuery, expectedQuery, asserter, entryCount, async); protected Task AssertFirstOrDefault( @@ -211,7 +224,7 @@ protected Task AssertFirstOrDefault( Expression> expectedPredicate, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertFirstOrDefault( + => QueryAsserter.AssertFirstOrDefault( actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, entryCount, async); protected Task AssertSingle( @@ -227,7 +240,7 @@ protected Task AssertSingle( Func> expectedQuery, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertSingle( + => QueryAsserter.AssertSingle( actualQuery, expectedQuery, asserter, entryCount, async); protected Task AssertSingle( @@ -246,7 +259,7 @@ protected Task AssertSingle( Expression> expectedPredicate, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertSingle( + => QueryAsserter.AssertSingle( actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, entryCount, async); protected Task AssertSingleOrDefault( @@ -262,7 +275,7 @@ protected Task AssertSingleOrDefault( Func> expectedQuery, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertSingleOrDefault( + => QueryAsserter.AssertSingleOrDefault( actualQuery, expectedQuery, asserter, entryCount, async); protected Task AssertSingleOrDefault( @@ -281,7 +294,7 @@ protected Task AssertSingleOrDefault( Expression> expectedPredicate, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertSingleOrDefault( + => QueryAsserter.AssertSingleOrDefault( actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, entryCount, async); protected Task AssertLast( @@ -297,7 +310,7 @@ protected Task AssertLast( Func> expectedQuery, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertLast( + => QueryAsserter.AssertLast( actualQuery, expectedQuery, asserter, entryCount, async); protected Task AssertLast( @@ -316,7 +329,7 @@ protected Task AssertLast( Expression> expectedPredicate, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertLast( + => QueryAsserter.AssertLast( actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, entryCount, async); protected Task AssertLastOrDefault( @@ -332,7 +345,7 @@ protected Task AssertLastOrDefault( Func> expectedQuery, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertLastOrDefault( + => QueryAsserter.AssertLastOrDefault( actualQuery, expectedQuery, asserter, entryCount, async); protected Task AssertLastOrDefault( @@ -351,7 +364,7 @@ protected Task AssertLastOrDefault( Expression> expectedPredicate, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertLastOrDefault( + => QueryAsserter.AssertLastOrDefault( actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, entryCount, async); protected Task AssertCount( @@ -363,7 +376,7 @@ protected Task AssertCount( bool async, Func> actualQuery, Func> expectedQuery) - => Fixture.QueryAsserter.AssertCount(actualQuery, expectedQuery, async); + => QueryAsserter.AssertCount(actualQuery, expectedQuery, async); protected Task AssertCount( bool async, @@ -377,7 +390,7 @@ protected Task AssertCount( Func> expectedQuery, Expression> actualPredicate, Expression> expectedPredicate) - => Fixture.QueryAsserter.AssertCount( + => QueryAsserter.AssertCount( actualQuery, expectedQuery, actualPredicate, expectedPredicate, async); protected Task AssertLongCount( @@ -389,7 +402,7 @@ protected Task AssertLongCount( bool async, Func> actualQuery, Func> expectedQuery) - => Fixture.QueryAsserter.AssertLongCount(actualQuery, expectedQuery, async); + => QueryAsserter.AssertLongCount(actualQuery, expectedQuery, async); protected Task AssertMin( bool async, @@ -404,7 +417,7 @@ protected Task AssertMin( Func> expectedQuery, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertMin( + => QueryAsserter.AssertMin( actualQuery, expectedQuery, asserter, entryCount, async); protected Task AssertMin( @@ -423,7 +436,7 @@ protected Task AssertMin( Expression> expectedSelector, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertMin( + => QueryAsserter.AssertMin( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, entryCount, async); protected Task AssertMax( @@ -439,7 +452,7 @@ protected Task AssertMax( Func> expectedQuery, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertMax( + => QueryAsserter.AssertMax( actualQuery, expectedQuery, asserter, entryCount, async); protected Task AssertMax( @@ -458,7 +471,7 @@ protected Task AssertMax( Expression> expectedSelector, Action asserter = null, int entryCount = 0) - => Fixture.QueryAsserter.AssertMax( + => QueryAsserter.AssertMax( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, entryCount, async); protected Task AssertSum( @@ -472,7 +485,7 @@ protected Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); protected Task AssertSum( bool async, @@ -485,7 +498,7 @@ protected Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); protected Task AssertSum( bool async, @@ -498,7 +511,7 @@ protected Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); protected Task AssertSum( bool async, @@ -511,7 +524,7 @@ protected Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); protected Task AssertSum( bool async, @@ -524,7 +537,7 @@ protected Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); protected Task AssertSum( bool async, @@ -537,7 +550,7 @@ protected Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); protected Task AssertSum( bool async, @@ -550,7 +563,7 @@ protected Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); protected Task AssertSum( bool async, @@ -563,7 +576,7 @@ protected Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); protected Task AssertSum( bool async, @@ -576,7 +589,7 @@ protected Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); protected Task AssertSum( bool async, @@ -589,7 +602,7 @@ protected Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertSum(actualQuery, expectedQuery, asserter, async); protected Task AssertSum( bool async, @@ -605,7 +618,7 @@ protected Task AssertSum( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertSum( + => QueryAsserter.AssertSum( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertSum( @@ -622,7 +635,7 @@ protected Task AssertSum( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertSum( + => QueryAsserter.AssertSum( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertSum( @@ -639,7 +652,7 @@ protected Task AssertSum( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertSum( + => QueryAsserter.AssertSum( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertSum( @@ -656,7 +669,7 @@ protected Task AssertSum( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertSum( + => QueryAsserter.AssertSum( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertSum( @@ -673,7 +686,7 @@ protected Task AssertSum( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertSum( + => QueryAsserter.AssertSum( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertSum( @@ -690,7 +703,7 @@ protected Task AssertSum( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertSum( + => QueryAsserter.AssertSum( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertSum( @@ -707,7 +720,7 @@ protected Task AssertSum( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertSum( + => QueryAsserter.AssertSum( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertSum( @@ -724,7 +737,7 @@ protected Task AssertSum( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertSum( + => QueryAsserter.AssertSum( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertSum( @@ -741,7 +754,7 @@ protected Task AssertSum( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertSum( + => QueryAsserter.AssertSum( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertSum( @@ -758,7 +771,7 @@ protected Task AssertSum( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertSum( + => QueryAsserter.AssertSum( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertAverage( @@ -772,7 +785,7 @@ protected Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); protected Task AssertAverage( bool async, @@ -785,7 +798,7 @@ protected Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); protected Task AssertAverage( bool async, @@ -798,7 +811,7 @@ protected Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); protected Task AssertAverage( bool async, @@ -811,7 +824,7 @@ protected Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); protected Task AssertAverage( bool async, @@ -824,7 +837,7 @@ protected Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); protected Task AssertAverage( bool async, @@ -837,7 +850,7 @@ protected Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); protected Task AssertAverage( bool async, @@ -850,7 +863,7 @@ protected Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); protected Task AssertAverage( bool async, @@ -863,7 +876,7 @@ protected Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); protected Task AssertAverage( bool async, @@ -876,7 +889,7 @@ protected Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); protected Task AssertAverage( bool async, @@ -889,7 +902,7 @@ protected Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); + => QueryAsserter.AssertAverage(actualQuery, expectedQuery, asserter, async); protected Task AssertAverage( bool async, @@ -905,7 +918,7 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage( + => QueryAsserter.AssertAverage( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertAverage( @@ -922,7 +935,7 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage( + => QueryAsserter.AssertAverage( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertAverage( @@ -939,7 +952,7 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage( + => QueryAsserter.AssertAverage( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertAverage( @@ -956,7 +969,7 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage( + => QueryAsserter.AssertAverage( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertAverage( @@ -973,7 +986,7 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage( + => QueryAsserter.AssertAverage( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertAverage( @@ -990,7 +1003,7 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage( + => QueryAsserter.AssertAverage( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertAverage( @@ -1007,7 +1020,7 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage( + => QueryAsserter.AssertAverage( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertAverage( @@ -1024,7 +1037,7 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage( + => QueryAsserter.AssertAverage( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertAverage( @@ -1041,7 +1054,7 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage( + => QueryAsserter.AssertAverage( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); protected Task AssertAverage( @@ -1058,7 +1071,7 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action asserter = null) - => Fixture.QueryAsserter.AssertAverage( + => QueryAsserter.AssertAverage( actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async); #endregion @@ -1066,7 +1079,7 @@ protected Task AssertAverage( #region Helpers protected void AssertEqual(T expected, T actual, Action asserter = null) - => Fixture.QueryAsserter.AssertEqual(expected, actual, asserter); + => QueryAsserter.AssertEqual(expected, actual, asserter); protected void AssertCollection( IEnumerable expected, @@ -1074,13 +1087,13 @@ protected void AssertCollection( bool ordered = false, Func elementSorter = null, Action elementAsserter = null) - => Fixture.QueryAsserter.AssertCollection(expected, actual, ordered, elementSorter, elementAsserter); + => QueryAsserter.AssertCollection(expected, actual, ordered, elementSorter, elementAsserter); protected void AssertInclude( TEntity expected, TEntity actual, params IExpectedInclude[] expectedIncludes) - => Fixture.QueryAsserter.AssertInclude(expected, actual, expectedIncludes); + => QueryAsserter.AssertInclude(expected, actual, expectedIncludes); protected void AssertGrouping( IGrouping expected, diff --git a/test/EFCore.Specification.Tests/Query/SpatialQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/SpatialQueryFixtureBase.cs index d7fa8e3699b..1d8bdf96bef 100644 --- a/test/EFCore.Specification.Tests/Query/SpatialQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/SpatialQueryFixtureBase.cs @@ -1,6 +1,8 @@ // 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.Collections.Generic; using System.Threading; using Microsoft.EntityFrameworkCore.TestModels.SpatialModel; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -13,19 +15,13 @@ public abstract class SpatialQueryFixtureBase : SharedStoreFixtureBase GetContextCreator() => () => CreateContext(); + + public ISetSource GetExpectedData() => new SpatialData(GeometryFactory); - protected virtual QueryAsserter CreateQueryAsserter() - => new QueryAsserter( - CreateContext, - new SpatialData(GeometryFactory), - entitySorters: null, - entityAsserters: null); + public IReadOnlyDictionary GetEntitySorters() => null; - public QueryAsserterBase QueryAsserter { get; set; } + public IReadOnlyDictionary GetEntityAsserters() => null; public virtual GeometryFactory GeometryFactory => LazyInitializer.EnsureInitialized( diff --git a/test/EFCore.Specification.Tests/TestUtilities/ExpectedQueryRewritingVisitor.cs b/test/EFCore.Specification.Tests/TestUtilities/ExpectedQueryRewritingVisitor.cs index a0c0581817b..873fa4a56b1 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/ExpectedQueryRewritingVisitor.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/ExpectedQueryRewritingVisitor.cs @@ -64,7 +64,7 @@ protected override Expression VisitMember(MemberExpression memberExpression) if (!memberExpression.Type.IsValueType && !memberExpression.Type.IsNullableValueType() && memberExpression.Expression != null) - { + { var expression = Visit(memberExpression.Expression); var lambdaParameter = Expression.Parameter(expression.Type, "x"); diff --git a/test/EFCore.Specification.Tests/TestUtilities/IncludeQueryResultAsserter.cs b/test/EFCore.Specification.Tests/TestUtilities/IncludeQueryResultAsserter.cs deleted file mode 100644 index 4850068e191..00000000000 --- a/test/EFCore.Specification.Tests/TestUtilities/IncludeQueryResultAsserter.cs +++ /dev/null @@ -1,199 +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 System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Reflection; -using Xunit; - -namespace Microsoft.EntityFrameworkCore.TestUtilities -{ - public class IncludeQueryResultAsserter - { - private readonly MethodInfo _assertElementMethodInfo; - private readonly MethodInfo _assertCollectionMethodInfo; - private readonly Dictionary _entitySorters; - private readonly Dictionary _entityAsserters; - private readonly MethodInfo _filterMethodInfo; - - private List _path; - private Stack _fullPath; - - public IncludeQueryResultAsserter( - Dictionary entitySorters, - Dictionary entityAsserters) - { - _entitySorters = entitySorters ?? new Dictionary(); - _entityAsserters = entityAsserters ?? new Dictionary(); - - _assertElementMethodInfo = typeof(IncludeQueryResultAsserter).GetTypeInfo().GetDeclaredMethod(nameof(AssertElement)); - _assertCollectionMethodInfo = typeof(IncludeQueryResultAsserter).GetTypeInfo().GetDeclaredMethod(nameof(AssertCollection)); - _filterMethodInfo = typeof(IncludeQueryResultAsserter).GetTypeInfo().GetDeclaredMethod(nameof(Filter)); - } - - public virtual void AssertResult(object expected, object actual, IEnumerable expectedIncludes) - { - _path = new List(); - _fullPath = new Stack(); - _fullPath.Push("root"); - - AssertObject(expected, actual, expectedIncludes); - } - - protected virtual void AssertObject(object expected, object actual, IEnumerable expectedIncludes) - { - if (expected == null - && actual == null) - { - return; - } - - Assert.Equal(expected == null, actual == null); - - var expectedType = expected.GetType(); - if (expectedType.IsGenericType - && expectedType.GetTypeInfo().ImplementedInterfaces.Any( - i => i.IsConstructedGenericType && i.GetGenericTypeDefinition() == typeof(IEnumerable<>))) - { - var typeArgument = expectedType.GenericTypeArguments[0]; - var assertCollectionMethodInfo = _assertCollectionMethodInfo.MakeGenericMethod(typeArgument); - assertCollectionMethodInfo.Invoke(this, new[] { expected, actual, expectedIncludes }); - } - else - { - var assertElementMethodInfo = _assertElementMethodInfo.MakeGenericMethod(expectedType); - assertElementMethodInfo.Invoke(this, new[] { expected, actual, expectedIncludes }); - } - } - - protected virtual void AssertElement(TElement expected, TElement actual, IEnumerable expectedIncludes) - { - if (expected == null - && actual == null) - { - return; - } - - Assert.Equal(expected == null, actual == null); - - var expectedType = expected.GetType(); - - Assert.Equal(expectedType, actual.GetType()); - - if (_entityAsserters.TryGetValue(expectedType, out var asserter)) - { - ((Action)asserter)(expected, actual); - //asserter(expected, actual); - ProcessIncludes(expected, actual, expectedIncludes); - - return; - } - - var expectedTypeInfo = expectedType.GetTypeInfo(); - if (expectedTypeInfo.IsGenericType - && expectedTypeInfo.GetGenericTypeDefinition() == typeof(KeyValuePair<,>)) - { - var keyPropertyInfo = expectedTypeInfo.GetDeclaredProperty("Key"); - var expectedKeyProperty = keyPropertyInfo.GetValue(expected); - var actualKeyProperty = keyPropertyInfo.GetValue(actual); - - AssertObject(expectedKeyProperty, actualKeyProperty, expectedIncludes); - - var valuePropertyInfo = expectedTypeInfo.GetDeclaredProperty("Value"); - var expectedValueProperty = valuePropertyInfo.GetValue(expected); - var actualValueProperty = valuePropertyInfo.GetValue(actual); - - AssertObject(expectedValueProperty, actualValueProperty, expectedIncludes); - - return; - } - - Assert.Equal(expected, actual); - } - - protected virtual void AssertCollection( - IEnumerable expected, IEnumerable actual, IEnumerable expectedIncludes) - { - if (expected == null - && actual == null) - { - return; - } - - Assert.Equal(expected == null, actual == null); - - var expectedList = expected.ToList(); - var actualList = actual.ToList(); - - if (_entitySorters.TryGetValue(typeof(TElement), out var sorter)) - { - // TODO: fix/cleanup - var actualSorter = (Func)sorter; - expectedList = ((IEnumerable)expectedList).OrderBy(actualSorter).Cast().ToList(); - actualList = ((IEnumerable)actualList).OrderBy(actualSorter).Cast().ToList(); - } - - Assert.Equal(expectedList.Count, actualList.Count); - - for (var i = 0; i < expectedList.Count; i++) - { - _fullPath.Push("[" + i + "]"); - - var elementType = expectedList[i]?.GetType() ?? typeof(TElement); - var assertElementMethodInfo = _assertElementMethodInfo.MakeGenericMethod(elementType); - assertElementMethodInfo.Invoke(this, new object[] { expectedList[i], actualList[i], expectedIncludes }); - - _fullPath.Pop(); - } - } - - protected void ProcessIncludes(TEntity expected, TEntity actual, IEnumerable expectedIncludes) - { - var currentPath = string.Join(".", _path); - - foreach (var expectedInclude in expectedIncludes.OfType>().Where(i => i.NavigationPath == currentPath)) - { - var expectedIncludedNavigation = GetIncluded(expected, expectedInclude.IncludeMember); - if (expectedInclude.GetType().BaseType != typeof(object)) - { - var includedType = expectedInclude.GetType().GetGenericArguments()[1]; - var filterTypedMethod = _filterMethodInfo.MakeGenericMethod(typeof(TEntity), includedType); - expectedIncludedNavigation = filterTypedMethod.Invoke( - this, - BindingFlags.NonPublic, - null, - new object[] { expectedIncludedNavigation, expectedInclude }, - CultureInfo.CurrentCulture); - } - - var actualIncludedNavigation = GetIncluded(actual, expectedInclude.IncludeMember); - - _path.Add(expectedInclude.IncludeMember.Name); - _fullPath.Push("." + expectedInclude.IncludeMember.Name); - - AssertObject(expectedIncludedNavigation, actualIncludedNavigation, expectedIncludes); - - _path.RemoveAt(_path.Count - 1); - _fullPath.Pop(); - } - } - - private IEnumerable Filter( - IEnumerable expected, - ExpectedFilteredInclude expectedFilteredInclude) - => expectedFilteredInclude.IncludeFilter(expected); - - private object GetIncluded(TEntity entity, MemberInfo includeMember) - => includeMember switch - { - FieldInfo fieldInfo => fieldInfo.GetValue(entity), - PropertyInfo propertyInfo => propertyInfo.GetValue(entity), - _ => throw new InvalidOperationException(), - }; - - // for debugging purposes - protected string FullPath => string.Join(string.Empty, _fullPath.Reverse()); - } -} diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs index 78eff087cbb..fbd609aad57 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs @@ -3,77 +3,78 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Linq.Expressions; +using System.Reflection; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities.QueryTestGeneration; using Xunit; namespace Microsoft.EntityFrameworkCore.TestUtilities { - public class QueryAsserter : QueryAsserterBase - where TContext : DbContext + public class QueryAsserter { - private readonly Func _contextCreator; - private readonly Dictionary _entitySorters; - private readonly Dictionary _entityAsserters; - private readonly IncludeQueryResultAsserter _includeResultAsserter; - private readonly ExpectedQueryRewritingVisitor _expectedQueryRewritingVisitor; - + private static readonly MethodInfo _assertIncludeEntity = typeof(QueryAsserter).GetTypeInfo().GetDeclaredMethod(nameof(AssertIncludeEntity)); + private static readonly MethodInfo _assertIncludeCollectionMethodInfo = typeof(QueryAsserter).GetTypeInfo().GetDeclaredMethod(nameof(AssertIncludeCollection)); + private static readonly MethodInfo _filteredIncludeMethodInfo = typeof(QueryAsserter).GetTypeInfo().GetDeclaredMethod(nameof(FilteredInclude)); + + private readonly Func _contextCreator; + private readonly IReadOnlyDictionary _entitySorters; + private readonly IReadOnlyDictionary _entityAsserters; + private readonly Func _rewriteExpectedQueryExpression; + private readonly Func _rewriteServerQueryExpression; + private readonly bool _ignoreEntryCount; private const bool ProceduralQueryGeneration = false; + private readonly List _includePath = new List(); public QueryAsserter( - Func contextCreator, - ISetSource expectedData, - Dictionary entitySorters, - Dictionary entityAsserters, - ExpectedQueryRewritingVisitor expectedQueryRewritingVisitor = null) + IQueryFixtureBase queryFixture, + Func rewriteExpectedQueryExpression, + Func rewriteServerQueryExpression, + bool ignoreEntryCount = false) { - _contextCreator = contextCreator; - ExpectedData = expectedData; - _expectedQueryRewritingVisitor = expectedQueryRewritingVisitor ?? new ExpectedQueryRewritingVisitor(); - _entitySorters = entitySorters ?? new Dictionary(); - _entityAsserters = entityAsserters ?? new Dictionary(); + _contextCreator = queryFixture.GetContextCreator(); + ExpectedData = queryFixture.GetExpectedData(); + _entitySorters = queryFixture.GetEntitySorters() ?? new Dictionary(); + _entityAsserters = queryFixture.GetEntityAsserters() ?? new Dictionary(); + SetSourceCreator = queryFixture.GetSetSourceCreator(); - SetSourceCreator = ctx => new DefaultSetSource(ctx); - _includeResultAsserter = new IncludeQueryResultAsserter(_entitySorters, _entityAsserters); + _rewriteExpectedQueryExpression = rewriteExpectedQueryExpression; + _rewriteServerQueryExpression = rewriteServerQueryExpression; + _ignoreEntryCount = ignoreEntryCount; } + public virtual Func SetSourceCreator { get; } + + public virtual ISetSource ExpectedData { get; } + protected virtual void AssertRogueExecution(int expectedCount, IQueryable queryable) { } - public override async Task AssertSingleResult( + public async Task AssertSingleResult( Expression> actualSyncQuery, Expression>> actualAsyncQuery, Expression> expectedQuery, Action asserter, int entryCount, - bool async, - string testMethodName) + bool async) { using var context = _contextCreator(); var actual = async ? await actualAsyncQuery.Compile()(SetSourceCreator(context)) : actualSyncQuery.Compile()(SetSourceCreator(context)); - var rewrittenExpectedQueryExpression = (Expression>)_expectedQueryRewritingVisitor.Visit(expectedQuery); + var rewrittenExpectedQueryExpression = (Expression>)_rewriteExpectedQueryExpression(expectedQuery); var expected = rewrittenExpectedQueryExpression.Compile()(ExpectedData); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); - } - - private IQueryable GetExpectedResults(Func> expectedQueryFunc) - { - var expectedQuery = expectedQueryFunc(ExpectedData); - var expectedQueryExpression = expectedQuery.Expression; - var rewrittenExpectedQueryExpression = _expectedQueryRewritingVisitor.Visit(expectedQueryExpression); - - return expectedQuery.Provider.CreateQuery(rewrittenExpectedQueryExpression); + AssertEntryCount(context, entryCount); } - public override async Task AssertQuery( + public async Task AssertQuery( Func> actualQuery, Func> expectedQuery, Func elementSorter, @@ -84,7 +85,7 @@ public override async Task AssertQuery( string testMethodName) { using var context = _contextCreator(); - var query = actualQuery(SetSourceCreator(context)); + var query = RewriteServerQuery(actualQuery(SetSourceCreator(context))); if (ProceduralQueryGeneration && !async) { new ProcedurallyGeneratedQueryExecutor().Execute(query, context, testMethodName); @@ -100,7 +101,7 @@ public override async Task AssertQuery( AssertRogueExecution(actual.Count, query); - var expected = GetExpectedResults(expectedQuery).ToList(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).ToList(); if (!assertOrder && elementSorter == null) @@ -122,7 +123,7 @@ public override async Task AssertQuery( elementAsserter, assertOrder); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } private void OrderingSettingsVerifier(bool assertOrder, Type type, object elementSorter) @@ -142,7 +143,7 @@ private void OrderingSettingsVerifier(bool assertOrder, Type type, object elemen } } - public override async Task AssertQueryScalar( + public async Task AssertQueryScalar( Func> actualQuery, Func> expectedQuery, bool assertOrder, @@ -151,7 +152,7 @@ public override async Task AssertQueryScalar( where TResult : struct { using var context = _contextCreator(); - var query = actualQuery(SetSourceCreator(context)); + var query = RewriteServerQuery(actualQuery(SetSourceCreator(context))); if (ProceduralQueryGeneration && !async) { new ProcedurallyGeneratedQueryExecutor().Execute(query, context, testMethodName); @@ -167,7 +168,7 @@ public override async Task AssertQueryScalar( AssertRogueExecution(actual.Count, query); - var expected = GetExpectedResults(expectedQuery).ToList(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).ToList(); TestHelpers.AssertResults( expected, @@ -177,7 +178,7 @@ public override async Task AssertQueryScalar( assertOrder); } - public override async Task AssertQueryScalar( + public async Task AssertQueryScalar( Func> actualQuery, Func> expectedQuery, bool assertOrder, @@ -186,7 +187,7 @@ public override async Task AssertQueryScalar( where TResult : struct { using var context = _contextCreator(); - var query = actualQuery(SetSourceCreator(context)); + var query = RewriteServerQuery(actualQuery(SetSourceCreator(context))); if (ProceduralQueryGeneration && !async) { new ProcedurallyGeneratedQueryExecutor().Execute(query, context, testMethodName); @@ -202,7 +203,7 @@ public override async Task AssertQueryScalar( AssertRogueExecution(actual.Count, query); - var expected = GetExpectedResults(expectedQuery).ToList(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).ToList(); TestHelpers.AssertResults( expected, @@ -214,22 +215,22 @@ public override async Task AssertQueryScalar( #region Assert termination operation methods - public override async Task AssertAny( + public async Task AssertAny( Func> actualQuery, Func> expectedQuery, bool async = false) { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AnyAsync() - : actualQuery(SetSourceCreator(context)).Any(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AnyAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Any(); - var expected = GetExpectedResults(expectedQuery).Any(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Any(); Assert.Equal(expected, actual); } - public override async Task AssertAny( + public async Task AssertAny( Func> actualQuery, Func> expectedQuery, Expression> actualPredicate, @@ -239,11 +240,11 @@ public override async Task AssertAny( using (var context = _contextCreator()) { var actual = async - ? await actualQuery(SetSourceCreator(context)).AnyAsync(actualPredicate) - : actualQuery(SetSourceCreator(context)).Any(actualPredicate); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AnyAsync(actualPredicate) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Any(actualPredicate); var rewrittenExpectedPredicate = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedPredicate); - var expected = GetExpectedResults(expectedQuery).Any(rewrittenExpectedPredicate); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Any(rewrittenExpectedPredicate); Assert.Equal(expected, actual); } @@ -251,8 +252,8 @@ public override async Task AssertAny( using (var context = _contextCreator()) { var actual = async - ? await actualQuery(SetSourceCreator(context)).AnyAsync() - : actualQuery(SetSourceCreator(context)).Any(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AnyAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Any(); var expected = expectedQuery(ExpectedData).Any(); @@ -260,7 +261,7 @@ public override async Task AssertAny( } } - public override async Task AssertAll( + public async Task AssertAll( Func> actualQuery, Func> expectedQuery, Expression> actualPredicate, @@ -269,16 +270,16 @@ public override async Task AssertAll( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AllAsync(actualPredicate) - : actualQuery(SetSourceCreator(context)).All(actualPredicate); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AllAsync(actualPredicate) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).All(actualPredicate); var rewrittenExpectedPredicate = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedPredicate); - var expected = GetExpectedResults(expectedQuery).All(rewrittenExpectedPredicate); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).All(rewrittenExpectedPredicate); Assert.Equal(expected, actual); } - public override async Task AssertFirst( + public async Task AssertFirst( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -287,16 +288,16 @@ public override async Task AssertFirst( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).FirstAsync() - : actualQuery(SetSourceCreator(context)).First(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).FirstAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).First(); - var expected = GetExpectedResults(expectedQuery).First(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).First(); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertFirst( + public async Task AssertFirst( Func> actualQuery, Func> expectedQuery, Expression> actualPredicate, @@ -307,17 +308,17 @@ public override async Task AssertFirst( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).FirstAsync(actualPredicate) - : actualQuery(SetSourceCreator(context)).First(actualPredicate); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).FirstAsync(actualPredicate) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).First(actualPredicate); var rewrittenExpectedPredicate = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedPredicate); - var expected = GetExpectedResults(expectedQuery).First(rewrittenExpectedPredicate); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).First(rewrittenExpectedPredicate); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertFirstOrDefault( + public async Task AssertFirstOrDefault( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -326,16 +327,16 @@ public override async Task AssertFirstOrDefault( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).FirstOrDefaultAsync() - : actualQuery(SetSourceCreator(context)).FirstOrDefault(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).FirstOrDefaultAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).FirstOrDefault(); - var expected = GetExpectedResults(expectedQuery).FirstOrDefault(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).FirstOrDefault(); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertFirstOrDefault( + public async Task AssertFirstOrDefault( Func> actualQuery, Func> expectedQuery, Expression> actualPredicate, @@ -346,17 +347,17 @@ public override async Task AssertFirstOrDefault( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).FirstOrDefaultAsync(actualPredicate) - : actualQuery(SetSourceCreator(context)).FirstOrDefault(actualPredicate); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).FirstOrDefaultAsync(actualPredicate) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).FirstOrDefault(actualPredicate); var rewrittenExpectedPredicate = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedPredicate); - var expected = GetExpectedResults(expectedQuery).FirstOrDefault(rewrittenExpectedPredicate); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).FirstOrDefault(rewrittenExpectedPredicate); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertSingle( + public async Task AssertSingle( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -365,16 +366,16 @@ public override async Task AssertSingle( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SingleAsync() - : actualQuery(SetSourceCreator(context)).Single(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SingleAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Single(); - var expected = GetExpectedResults(expectedQuery).Single(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Single(); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertSingle( + public async Task AssertSingle( Func> actualQuery, Func> expectedQuery, Expression> actualPredicate, @@ -385,17 +386,17 @@ public override async Task AssertSingle( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SingleAsync(actualPredicate) - : actualQuery(SetSourceCreator(context)).Single(actualPredicate); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SingleAsync(actualPredicate) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Single(actualPredicate); var rewrittenExpectedPredicate = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedPredicate); - var expected = GetExpectedResults(expectedQuery).Single(rewrittenExpectedPredicate); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Single(rewrittenExpectedPredicate); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertSingleOrDefault( + public async Task AssertSingleOrDefault( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -404,16 +405,16 @@ public override async Task AssertSingleOrDefault( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SingleOrDefaultAsync() - : actualQuery(SetSourceCreator(context)).SingleOrDefault(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SingleOrDefaultAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).SingleOrDefault(); - var expected = GetExpectedResults(expectedQuery).SingleOrDefault(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).SingleOrDefault(); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertSingleOrDefault( + public async Task AssertSingleOrDefault( Func> actualQuery, Func> expectedQuery, Expression> actualPredicate, @@ -424,17 +425,17 @@ public override async Task AssertSingleOrDefault( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SingleOrDefaultAsync(actualPredicate) - : actualQuery(SetSourceCreator(context)).SingleOrDefault(actualPredicate); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SingleOrDefaultAsync(actualPredicate) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).SingleOrDefault(actualPredicate); var rewrittenExpectedPredicate = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedPredicate); - var expected = GetExpectedResults(expectedQuery).SingleOrDefault(rewrittenExpectedPredicate); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).SingleOrDefault(rewrittenExpectedPredicate); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertLast( + public async Task AssertLast( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -443,16 +444,16 @@ public override async Task AssertLast( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).LastAsync() - : actualQuery(SetSourceCreator(context)).Last(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).LastAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Last(); - var expected = GetExpectedResults(expectedQuery).Last(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Last(); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertLast( + public async Task AssertLast( Func> actualQuery, Func> expectedQuery, Expression> actualPredicate, @@ -463,17 +464,17 @@ public override async Task AssertLast( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).LastAsync(actualPredicate) - : actualQuery(SetSourceCreator(context)).Last(actualPredicate); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).LastAsync(actualPredicate) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Last(actualPredicate); var rewrittenExpectedPredicate = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedPredicate); - var expected = GetExpectedResults(expectedQuery).Last(rewrittenExpectedPredicate); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Last(rewrittenExpectedPredicate); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertLastOrDefault( + public async Task AssertLastOrDefault( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -482,16 +483,16 @@ public override async Task AssertLastOrDefault( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).LastOrDefaultAsync() - : actualQuery(SetSourceCreator(context)).LastOrDefault(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).LastOrDefaultAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).LastOrDefault(); - var expected = GetExpectedResults(expectedQuery).LastOrDefault(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).LastOrDefault(); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertLastOrDefault( + public async Task AssertLastOrDefault( Func> actualQuery, Func> expectedQuery, Expression> actualPredicate, @@ -502,33 +503,33 @@ public override async Task AssertLastOrDefault( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).LastOrDefaultAsync(actualPredicate) - : actualQuery(SetSourceCreator(context)).LastOrDefault(actualPredicate); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).LastOrDefaultAsync(actualPredicate) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).LastOrDefault(actualPredicate); var rewrittenExpectedPredicate = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedPredicate); - var expected = GetExpectedResults(expectedQuery).LastOrDefault(rewrittenExpectedPredicate); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).LastOrDefault(rewrittenExpectedPredicate); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertCount( + public async Task AssertCount( Func> actualQuery, Func> expectedQuery, bool async = false) { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).CountAsync() - : actualQuery(SetSourceCreator(context)).Count(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).CountAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Count(); - var expected = GetExpectedResults(expectedQuery).Count(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Count(); Assert.Equal(expected, actual); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertCount( + public async Task AssertCount( Func> actualQuery, Func> expectedQuery, Expression> actualPredicate, @@ -537,33 +538,33 @@ public override async Task AssertCount( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).CountAsync(actualPredicate) - : actualQuery(SetSourceCreator(context)).Count(actualPredicate); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).CountAsync(actualPredicate) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Count(actualPredicate); var rewrittenExpectedPredicate = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedPredicate); - var expected = GetExpectedResults(expectedQuery).Count(rewrittenExpectedPredicate); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Count(rewrittenExpectedPredicate); Assert.Equal(expected, actual); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertLongCount( + public async Task AssertLongCount( Func> actualQuery, Func> expectedQuery, bool async = false) { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).LongCountAsync() - : actualQuery(SetSourceCreator(context)).LongCount(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).LongCountAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).LongCount(); - var expected = GetExpectedResults(expectedQuery).LongCount(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).LongCount(); Assert.Equal(expected, actual); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertLongCount( + public async Task AssertLongCount( Func> actualQuery, Func> expectedQuery, Expression> actualPredicate, @@ -572,17 +573,17 @@ public override async Task AssertLongCount( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).LongCountAsync(actualPredicate) - : actualQuery(SetSourceCreator(context)).LongCount(actualPredicate); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).LongCountAsync(actualPredicate) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).LongCount(actualPredicate); var rewrittenExpectedPredicate = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedPredicate); - var expected = GetExpectedResults(expectedQuery).LongCount(rewrittenExpectedPredicate); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).LongCount(rewrittenExpectedPredicate); Assert.Equal(expected, actual); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertMin( + public async Task AssertMin( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -591,16 +592,16 @@ public override async Task AssertMin( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).MinAsync() - : actualQuery(SetSourceCreator(context)).Min(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).MinAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Min(); - var expected = GetExpectedResults(expectedQuery).Min(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Min(); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertMin( + public async Task AssertMin( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -611,17 +612,17 @@ public override async Task AssertMin( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).MinAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Min(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).MinAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Min(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Min(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Min(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertMax( + public async Task AssertMax( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -630,16 +631,16 @@ public override async Task AssertMax( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).MaxAsync() - : actualQuery(SetSourceCreator(context)).Max(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).MaxAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Max(); - var expected = GetExpectedResults(expectedQuery).Max(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Max(); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertMax( + public async Task AssertMax( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -650,17 +651,17 @@ public override async Task AssertMax( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).MaxAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Max(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).MaxAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Max(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Max(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Max(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); - Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + AssertEntryCount(context, entryCount); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -668,16 +669,16 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync() - : actualQuery(SetSourceCreator(context)).Sum(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(); - var expected = GetExpectedResults(expectedQuery).Sum(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -685,16 +686,16 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync() - : actualQuery(SetSourceCreator(context)).Sum(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(); - var expected = GetExpectedResults(expectedQuery).Sum(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -702,16 +703,16 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync() - : actualQuery(SetSourceCreator(context)).Sum(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(); - var expected = GetExpectedResults(expectedQuery).Sum(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -719,16 +720,16 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync() - : actualQuery(SetSourceCreator(context)).Sum(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(); - var expected = GetExpectedResults(expectedQuery).Sum(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -736,16 +737,16 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync() - : actualQuery(SetSourceCreator(context)).Sum(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(); - var expected = GetExpectedResults(expectedQuery).Sum(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -753,16 +754,16 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync() - : actualQuery(SetSourceCreator(context)).Sum(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(); - var expected = GetExpectedResults(expectedQuery).Sum(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -770,16 +771,16 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync() - : actualQuery(SetSourceCreator(context)).Sum(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(); - var expected = GetExpectedResults(expectedQuery).Sum(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -787,16 +788,16 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync() - : actualQuery(SetSourceCreator(context)).Sum(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(); - var expected = GetExpectedResults(expectedQuery).Sum(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -804,16 +805,16 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync() - : actualQuery(SetSourceCreator(context)).Sum(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(); - var expected = GetExpectedResults(expectedQuery).Sum(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -821,16 +822,16 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync() - : actualQuery(SetSourceCreator(context)).Sum(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(); - var expected = GetExpectedResults(expectedQuery).Sum(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -840,17 +841,17 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Sum(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Sum(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -860,17 +861,17 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Sum(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Sum(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -880,17 +881,17 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Sum(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Sum(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -900,17 +901,17 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Sum(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Sum(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -920,17 +921,17 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Sum(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Sum(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -940,17 +941,17 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Sum(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Sum(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -960,17 +961,17 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Sum(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Sum(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -980,17 +981,17 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Sum(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Sum(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -1000,17 +1001,17 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Sum(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Sum(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertSum( + public async Task AssertSum( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -1020,17 +1021,17 @@ public override async Task AssertSum( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).SumAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Sum(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Sum(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -1038,16 +1039,16 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync() - : actualQuery(SetSourceCreator(context)).Average(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(); - var expected = GetExpectedResults(expectedQuery).Average(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -1055,16 +1056,16 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync() - : actualQuery(SetSourceCreator(context)).Average(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(); - var expected = GetExpectedResults(expectedQuery).Average(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -1072,16 +1073,16 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync() - : actualQuery(SetSourceCreator(context)).Average(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(); - var expected = GetExpectedResults(expectedQuery).Average(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -1089,16 +1090,16 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync() - : actualQuery(SetSourceCreator(context)).Average(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(); - var expected = GetExpectedResults(expectedQuery).Average(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -1106,16 +1107,16 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync() - : actualQuery(SetSourceCreator(context)).Average(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(); - var expected = GetExpectedResults(expectedQuery).Average(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -1123,16 +1124,16 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync() - : actualQuery(SetSourceCreator(context)).Average(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(); - var expected = GetExpectedResults(expectedQuery).Average(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -1140,16 +1141,16 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync() - : actualQuery(SetSourceCreator(context)).Average(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(); - var expected = GetExpectedResults(expectedQuery).Average(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -1157,16 +1158,16 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync() - : actualQuery(SetSourceCreator(context)).Average(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(); - var expected = GetExpectedResults(expectedQuery).Average(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -1174,16 +1175,16 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync() - : actualQuery(SetSourceCreator(context)).Average(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(); - var expected = GetExpectedResults(expectedQuery).Average(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Action asserter = null, @@ -1191,16 +1192,16 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync() - : actualQuery(SetSourceCreator(context)).Average(); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync() + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(); - var expected = GetExpectedResults(expectedQuery).Average(); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -1210,17 +1211,17 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Average(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Average(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -1230,17 +1231,17 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Average(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Average(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -1250,17 +1251,17 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Average(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Average(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -1270,17 +1271,17 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Average(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Average(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -1290,17 +1291,17 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Average(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Average(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -1310,17 +1311,17 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Average(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Average(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -1330,17 +1331,17 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Average(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Average(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -1350,17 +1351,17 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Average(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Average(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -1370,17 +1371,17 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Average(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Average(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); } - public override async Task AssertAverage( + public async Task AssertAverage( Func> actualQuery, Func> expectedQuery, Expression> actualSelector, @@ -1390,11 +1391,11 @@ public override async Task AssertAverage( { using var context = _contextCreator(); var actual = async - ? await actualQuery(SetSourceCreator(context)).AverageAsync(actualSelector) - : actualQuery(SetSourceCreator(context)).Average(actualSelector); + ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync(actualSelector) + : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(actualSelector); var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); - var expected = GetExpectedResults(expectedQuery).Average(rewrittenExpectedSelector); + var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); Assert.Empty(context.ChangeTracker.Entries()); @@ -1404,7 +1405,7 @@ public override async Task AssertAverage( #region Helpers - public override void AssertEqual(T expected, T actual, Action asserter = null) + public void AssertEqual(T expected, T actual, Action asserter = null) { if (asserter == null && expected != null) @@ -1417,7 +1418,7 @@ public override void AssertEqual(T expected, T actual, Action asserter asserter(expected, actual); } - public override void AssertEqual(T? expected, T? actual, Action asserter = null) + public void AssertEqual(T? expected, T? actual, Action asserter = null) where T : struct { asserter ??= Assert.Equal; @@ -1425,7 +1426,7 @@ public override void AssertEqual(T? expected, T? actual, Action asser asserter(expected, actual); } - public override void AssertCollection( + public void AssertCollection( IEnumerable expected, IEnumerable actual, bool ordered = false, @@ -1488,23 +1489,129 @@ public override void AssertCollection( } } - public override void AssertInclude(TEntity expected, TEntity actual, IExpectedInclude[] expectedIncludes) - => _includeResultAsserter.AssertResult(expected, actual, expectedIncludes); + public void AssertInclude(TEntity expected, TEntity actual, IExpectedInclude[] expectedIncludes) + { + _includePath.Clear(); - #endregion + AssertIncludeObject(expected, actual, expectedIncludes); + } + + private void AssertIncludeObject(object expected, object actual, IEnumerable expectedIncludes) + { + if (expected == null + && actual == null) + { + return; + } + + Assert.Equal(expected == null, actual == null); + + var expectedType = expected.GetType(); + if (expectedType.IsGenericType + && expectedType.GetTypeInfo().ImplementedInterfaces.Any( + i => i.IsConstructedGenericType && i.GetGenericTypeDefinition() == typeof(IEnumerable<>))) + { + _assertIncludeCollectionMethodInfo.MakeGenericMethod(expectedType.GenericTypeArguments[0]) + .Invoke(this, new[] { expected, actual, expectedIncludes }); + } + else + { + _assertIncludeEntity.MakeGenericMethod(expectedType).Invoke(this, new[] { expected, actual, expectedIncludes }); + } + } + + private void AssertIncludeEntity(TElement expected, TElement actual, IEnumerable expectedIncludes) + { + Assert.Equal(expected.GetType(), actual.GetType()); + + if (_entityAsserters.TryGetValue(typeof(TElement), out var asserter)) + { + ((Action)asserter)(expected, actual); + ProcessIncludes(expected, actual, expectedIncludes); - private class DefaultSetSource : ISetSource + return; + } + } + + private void AssertIncludeCollection( + IEnumerable expected, IEnumerable actual, IEnumerable expectedIncludes) { - private readonly DbContext _context; + var expectedList = expected.ToList(); + var actualList = actual.ToList(); - public DefaultSetSource(DbContext context) + if (_entitySorters.TryGetValue(typeof(TElement), out var sorter)) { - _context = context; + var actualSorter = (Func)sorter; + expectedList = expectedList.OrderBy(actualSorter).ToList(); + actualList = actualList.OrderBy(actualSorter).ToList(); } - public IQueryable Set() - where TEntity : class - => _context.Set(); + Assert.Equal(expectedList.Count, actualList.Count); + + for (var i = 0; i < expectedList.Count; i++) + { + var elementType = expectedList[i].GetType(); + _assertIncludeEntity.MakeGenericMethod(elementType) + .Invoke(this, new object[] { expectedList[i], actualList[i], expectedIncludes }); + } } + + private void ProcessIncludes(TEntity expected, TEntity actual, IEnumerable expectedIncludes) + { + var currentPath = string.Join(".", _includePath); + + foreach (var expectedInclude in expectedIncludes.OfType>().Where(i => i.NavigationPath == currentPath)) + { + var expectedIncludedNavigation = GetIncluded(expected, expectedInclude.IncludeMember); + if (expectedInclude.GetType().BaseType != typeof(object)) + { + var includedType = expectedInclude.GetType().GetGenericArguments()[1]; + var filterTypedMethod = _filteredIncludeMethodInfo.MakeGenericMethod(typeof(TEntity), includedType); + expectedIncludedNavigation = filterTypedMethod.Invoke( + this, + BindingFlags.NonPublic, + null, + new object[] { expectedIncludedNavigation, expectedInclude }, + CultureInfo.CurrentCulture); + } + + var actualIncludedNavigation = GetIncluded(actual, expectedInclude.IncludeMember); + + _includePath.Add(expectedInclude.IncludeMember.Name); + + AssertIncludeObject(expectedIncludedNavigation, actualIncludedNavigation, expectedIncludes); + + _includePath.RemoveAt(_includePath.Count - 1); + } + } + + private IEnumerable FilteredInclude( + IEnumerable expected, + ExpectedFilteredInclude expectedFilteredInclude) + => expectedFilteredInclude.IncludeFilter(expected); + + private object GetIncluded(TEntity entity, MemberInfo includeMember) + => includeMember switch + { + FieldInfo fieldInfo => fieldInfo.GetValue(entity), + PropertyInfo propertyInfo => propertyInfo.GetValue(entity), + _ => throw new InvalidOperationException(), + }; + + private void AssertEntryCount(DbContext context, int entryCount) + { + if (!_ignoreEntryCount) + { + Assert.Equal(entryCount, context.ChangeTracker.Entries().Count()); + } + } + + private IQueryable RewriteServerQuery(IQueryable query) + => query.Provider.CreateQuery(_rewriteServerQueryExpression(query.Expression)); + + private IQueryable RewriteExpectedQuery(IQueryable query) + => query.Provider.CreateQuery(_rewriteExpectedQueryExpression(query.Expression)); + + #endregion } } diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryAsserterBase.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryAsserterBase.cs deleted file mode 100644 index c094bae47d0..00000000000 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryAsserterBase.cs +++ /dev/null @@ -1,536 +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 System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Threading.Tasks; - -namespace Microsoft.EntityFrameworkCore.TestUtilities -{ - public abstract class QueryAsserterBase - { - public virtual Func SetSourceCreator { get; set; } - - public virtual ISetSource ExpectedData { get; set; } - - public abstract Task AssertSingleResult( - Expression> actualSyncQuery, - Expression>> actualAsyncQuery, - Expression> expectedQuery, - Action asserter, - int entryCount, - bool async, - string testMethodName); - - public abstract Task AssertQuery( - Func> actualQuery, - Func> expectedQuery, - Func elementSorter, - Action elementAsserter, - bool assertOrder, - int entryCount, - bool async, - string testMethodName) - where TResult : class; - - public abstract Task AssertQueryScalar( - Func> actualQuery, - Func> expectedQuery, - bool assertOrder, - bool async, - string testMethodName) - where TResult : struct; - - public abstract Task AssertQueryScalar( - Func> actualQuery, - Func> expectedQuery, - bool assertOrder, - bool async, - string testMethodName) - where TResult : struct; - - #region Assert termination operation methods - - public abstract Task AssertAny( - Func> actualQuery, - Func> expectedQuery, - bool async = false); - - public abstract Task AssertAny( - Func> actualQuery, - Func> expectedQuery, - Expression> actualPredicate, - Expression> expectedPredicate, - bool async = false); - - public abstract Task AssertAll( - Func> actualQuery, - Func> expectedQuery, - Expression> actualPredicate, - Expression> expectedPredicate, - bool async = false); - - public abstract Task AssertFirst( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertFirst( - Func> actualQuery, - Func> expectedQuery, - Expression> actualPredicate, - Expression> expectedPredicate, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertFirstOrDefault( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertFirstOrDefault( - Func> actualQuery, - Func> expectedQuery, - Expression> actualPredicate, - Expression> expectedPredicate, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertSingle( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertSingle( - Func> actualQuery, - Func> expectedQuery, - Expression> actualPredicate, - Expression> expectedPredicate, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertSingleOrDefault( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertSingleOrDefault( - Func> actualQuery, - Func> expectedQuery, - Expression> actualPredicate, - Expression> expectedPredicate, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertLast( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertLast( - Func> actualQuery, - Func> expectedQuery, - Expression> actualPredicate, - Expression> expectedPredicate, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertLastOrDefault( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertLastOrDefault( - Func> actualQuery, - Func> expectedQuery, - Expression> actualPredicate, - Expression> expectedPredicate, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertCount( - Func> actualQuery, - Func> expectedQuery, - bool async = false); - - public abstract Task AssertCount( - Func> actualQuery, - Func> expectedQuery, - Expression> actualPredicate, - Expression> expectedPredicate, - bool async = false); - - public abstract Task AssertLongCount( - Func> actualQuery, - Func> expectedQuery, - bool async = false); - - public abstract Task AssertLongCount( - Func> actualQuery, - Func> expectedQuery, - Expression> actualPredicate, - Expression> expectedPredicate, - bool async = false); - - public abstract Task AssertMin( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertMin( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertMax( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertMax( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - int entryCount = 0, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertSum( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - public abstract Task AssertAverage( - Func> actualQuery, - Func> expectedQuery, - Expression> actualSelector, - Expression> expectedSelector, - Action asserter = null, - bool async = false); - - #endregion - - #region Helpers - - public abstract void AssertEqual( - T expected, - T actual, - Action asserter = null); - - public abstract void AssertEqual( - T? expected, - T? actual, - Action asserter = null) - where T : struct; - - public abstract void AssertCollection( - IEnumerable expected, - IEnumerable actual, - bool ordered = false, - Func elementSorter = null, - Action elementAsserter = null); - - public abstract void AssertInclude( - TEntity expected, - TEntity actual, - IExpectedInclude[] expectedIncludes); - - #endregion - } -} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AsyncGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AsyncGearsOfWarQuerySqlServerTest.cs index ca60f51dffd..b7bb3601bf0 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AsyncGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/AsyncGearsOfWarQuerySqlServerTest.cs @@ -5,7 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class AsyncGearsOfWarQuerySqlServerTest : AsyncGearsOfWarQueryTestBase + public class AsyncGearsOfWarQuerySqlServerTest : AsyncGearsOfWarQueryRelationalTestBase { public AsyncGearsOfWarQuerySqlServerTest(GearsOfWarQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -13,5 +13,7 @@ public AsyncGearsOfWarQuerySqlServerTest(GearsOfWarQuerySqlServerFixture fixture Fixture.TestSqlLoggerFactory.Clear(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + + protected override bool CanExecuteQueryString => true; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerFixture.cs index 1010c529bb2..e2c30b68fdf 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerFixture.cs @@ -8,7 +8,5 @@ namespace Microsoft.EntityFrameworkCore.Query public class ComplexNavigationsQuerySqlServerFixture : ComplexNavigationsQueryRelationalFixtureBase { protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; - - protected override bool CanExecuteQueryString => true; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs index f58d71c28d8..5a435dd6163 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs @@ -9,7 +9,7 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public class ComplexNavigationsQuerySqlServerTest : ComplexNavigationsQueryTestBase + public class ComplexNavigationsQuerySqlServerTest : ComplexNavigationsQueryRelationalTestBase { public ComplexNavigationsQuerySqlServerTest( ComplexNavigationsQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) @@ -19,6 +19,8 @@ public ComplexNavigationsQuerySqlServerTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + protected override bool CanExecuteQueryString => true; + public override async Task Entity_equality_empty(bool async) { await base.Entity_equality_empty(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs index 20970ed435a..74793af9723 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs @@ -1,10 +1,7 @@ // 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.Collections.Generic; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.TestModels.FunkyDataModel; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit.Abstractions; @@ -19,6 +16,11 @@ public FunkyDataQuerySqlServerTest(FunkyDataQuerySqlServerFixture fixture, ITest //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + protected virtual bool CanExecuteQueryString => true; + + protected override QueryAsserter CreateQueryAsserter(FunkyDataQuerySqlServerFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + public override async Task String_contains_on_argument_with_wildcard_constant(bool async) { await base.String_contains_on_argument_with_wildcard_constant(async); @@ -463,18 +465,6 @@ public class FunkyDataQuerySqlServerFixture : FunkyDataQueryFixtureBase public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; - - protected override bool CanExecuteQueryString => true; - - protected override QueryAsserter CreateQueryAsserter( - Dictionary entitySorters, - Dictionary entityAsserters) - => new RelationalQueryAsserter( - CreateContext, - new FunkyDataData(), - entitySorters, - entityAsserters, - CanExecuteQueryString); } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerFixture.cs index b6fe33a99f4..60a91321fb2 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerFixture.cs @@ -15,9 +15,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con base.OnModelCreating(modelBuilder, context); modelBuilder.Entity().Property(g => g.Location).HasColumnType("varchar(100)"); - } - - protected override bool CanExecuteQueryString => true; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index 903836ce176..072985380f6 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -10,11 +10,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class GearsOfWarQuerySqlServerTest : GearsOfWarQueryTestBase + public class GearsOfWarQuerySqlServerTest : GearsOfWarQueryRelationalTestBase { - private static readonly string _eol = Environment.NewLine; - - // ReSharper disable once UnusedParameter.Local #pragma warning disable IDE0060 // Remove unused parameter public GearsOfWarQuerySqlServerTest(GearsOfWarQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) #pragma warning restore IDE0060 // Remove unused parameter @@ -24,6 +21,8 @@ public GearsOfWarQuerySqlServerTest(GearsOfWarQuerySqlServerFixture fixture, ITe //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + protected override bool CanExecuteQueryString => true; + public override async Task Entity_equality_empty(bool async) { await base.Entity_equality_empty(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs index c8651cf551b..c537e465504 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs @@ -6,7 +6,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class ManyToManyQuerySqlServerTest : ManyToManyQueryTestBase + public class ManyToManyQuerySqlServerTest : ManyToManyQueryRelationalTestBase { public ManyToManyQuerySqlServerTest(ManyToManyQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -15,6 +15,8 @@ public ManyToManyQuerySqlServerTest(ManyToManyQuerySqlServerFixture fixture, ITe //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + protected override bool CanExecuteQueryString => true; + public override async Task Can_use_skip_navigation_in_predicate(bool async) { await base.Can_use_skip_navigation_in_predicate(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs index 7792193b3d9..8c523e7f2dd 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindAggregateOperatorsQuerySqlServerTest : NorthwindAggregateOperatorsQueryTestBase> + public class NorthwindAggregateOperatorsQuerySqlServerTest : NorthwindAggregateOperatorsQueryRelationalTestBase> { public NorthwindAggregateOperatorsQuerySqlServerTest( NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) @@ -17,6 +17,8 @@ public NorthwindAggregateOperatorsQuerySqlServerTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + protected override bool CanExecuteQueryString => true; + public override void Select_All() { base.Select_All(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqlServerTest.cs index 172ae6cb4ca..64ec3d69107 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqlServerTest.cs @@ -13,7 +13,7 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindAsyncSimpleQuerySqlServerTest : NorthwindAsyncSimpleQueryTestBase> + public class NorthwindAsyncSimpleQuerySqlServerTest : NorthwindAsyncSimpleQueryRelationalTestBase> { // ReSharper disable once UnusedParameter.Local public NorthwindAsyncSimpleQuerySqlServerTest( @@ -24,6 +24,8 @@ public NorthwindAsyncSimpleQuerySqlServerTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + protected override bool CanExecuteQueryString => true; + [ConditionalFact(Skip = "Issue#16314")] public override Task Throws_on_concurrent_query_list() { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs index a10729c573b..5eea84ad0bf 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs @@ -14,7 +14,7 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindDbFunctionsQuerySqlServerTest : RelationalNorthwindDbFunctionsQueryTestBase> + public class NorthwindDbFunctionsQuerySqlServerTest : NorthwindDbFunctionsQueryRelationalTestBase> { public NorthwindDbFunctionsQuerySqlServerTest( NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs index 17e61ea4a62..b7696591b47 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs @@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindFunctionsQuerySqlServerTest : NorthwindFunctionsQueryTestBase> + public class NorthwindFunctionsQuerySqlServerTest : NorthwindFunctionsQueryRelationalTestBase> { public NorthwindFunctionsQuerySqlServerTest( #pragma warning disable IDE0060 // Remove unused parameter @@ -22,6 +22,8 @@ public NorthwindFunctionsQuerySqlServerTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + protected override bool CanExecuteQueryString => true; + public override async Task String_StartsWith_Literal(bool async) { await base.String_StartsWith_Literal(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs index 8c3fdd88c61..96121413ab9 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs @@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindGroupByQuerySqlServerTest : NorthwindGroupByQueryTestBase> + public class NorthwindGroupByQuerySqlServerTest : NorthwindGroupByQueryRelationalTestBase> { // ReSharper disable once UnusedParameter.Local public NorthwindGroupByQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) @@ -20,6 +20,8 @@ public NorthwindGroupByQuerySqlServerTest(NorthwindQuerySqlServerFixture true; + public override async Task GroupBy_Property_Select_Average(bool async) { await base.GroupBy_Property_Select_Average(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs index 442198c2095..a7ca49a4b7a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindIncludeQuerySqlServerTest : NorthwindIncludeQueryTestBase> + public class NorthwindIncludeQuerySqlServerTest : NorthwindIncludeQueryRelationalTestBase> { // ReSharper disable once UnusedParameter.Local public NorthwindIncludeQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) @@ -17,6 +17,8 @@ public NorthwindIncludeQuerySqlServerTest(NorthwindQuerySqlServerFixture true; + public override async Task Include_list(bool async) { await base.Include_list(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinQuerySqlServerTest.cs index 4dd10e801c0..a45aa1c9857 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinQuerySqlServerTest.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindJoinQuerySqlServerTest : NorthwindJoinQueryTestBase> + public class NorthwindJoinQuerySqlServerTest : NorthwindJoinQueryRelationalTestBase> { public NorthwindJoinQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -16,6 +16,8 @@ public NorthwindJoinQuerySqlServerTest(NorthwindQuerySqlServerFixture true; + public override async Task Join_customers_orders_projection(bool async) { await base.Join_customers_orders_projection(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqlServerTest.cs index ab35e005495..cb0d15755d5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqlServerTest.cs @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindKeylessEntitiesQuerySqlServerTest : NorthwindKeylessEntitiesQueryTestBase> + public class NorthwindKeylessEntitiesQuerySqlServerTest : NorthwindKeylessEntitiesQueryRelationalTestBase> { public NorthwindKeylessEntitiesQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -17,6 +17,8 @@ public NorthwindKeylessEntitiesQuerySqlServerTest(NorthwindQuerySqlServerFixture //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + protected override bool CanExecuteQueryString => true; + [ConditionalTheory] public override async Task KeylessEntity_simple(bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs index e327a278972..312094fdfc8 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs @@ -13,7 +13,7 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindMiscellaneousQuerySqlServerTest : NorthwindMiscellaneousQueryTestBase> + public class NorthwindMiscellaneousQuerySqlServerTest : NorthwindMiscellaneousQueryRelationalTestBase> { public NorthwindMiscellaneousQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -22,6 +22,8 @@ public NorthwindMiscellaneousQuerySqlServerTest(NorthwindQuerySqlServerFixture true; + public override void Shaper_command_caching_when_parameter_names_different() { base.Shaper_command_caching_when_parameter_names_different(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs index 07161c4f887..07508b51312 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindNavigationsQuerySqlServerTest : NorthwindNavigationsQueryTestBase> + public class NorthwindNavigationsQuerySqlServerTest : NorthwindNavigationsQueryRelationalTestBase> { public NorthwindNavigationsQuerySqlServerTest( NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) @@ -16,6 +16,8 @@ public NorthwindNavigationsQuerySqlServerTest( fixture.TestSqlLoggerFactory.Clear(); } + protected override bool CanExecuteQueryString => true; + public override async Task Select_Where_Navigation(bool async) { await base.Select_Where_Navigation(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQuerySqlServerFixture.cs index 4f8cf6f389d..978037227e1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQuerySqlServerFixture.cs @@ -12,8 +12,6 @@ public class NorthwindQuerySqlServerFixture : NorthwindQueryRe { protected override ITestStoreFactory TestStoreFactory => SqlServerNorthwindTestStoreFactory.Instance; - protected override bool CanExecuteQueryString => true; - protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { base.OnModelCreating(modelBuilder, context); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs index cc723da7f1a..d36d68b59af 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindSelectQuerySqlServerTest : NorthwindSelectQueryTestBase> + public class NorthwindSelectQuerySqlServerTest : NorthwindSelectQueryRelationalTestBase> { public NorthwindSelectQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -16,6 +16,8 @@ public NorthwindSelectQuerySqlServerTest(NorthwindQuerySqlServerFixture true; + public override async Task Projection_when_arithmetic_expression_precedence(bool async) { await base.Projection_when_arithmetic_expression_precedence(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSetOperationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSetOperationsQuerySqlServerTest.cs index b5ebe9e7814..0618845f594 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSetOperationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSetOperationsQuerySqlServerTest.cs @@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindSetOperationsQuerySqlServerTest : NorthwindSetOperationsQueryTestBase> + public class NorthwindSetOperationsQuerySqlServerTest : NorthwindSetOperationsQueryRelationalTestBase> { public NorthwindSetOperationsQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -18,6 +18,8 @@ public NorthwindSetOperationsQuerySqlServerTest(NorthwindQuerySqlServerFixture true; + public override async Task Union(bool async) { await base.Union(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs index 760912f2986..1a878e28111 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindWhereQuerySqlServerTest : NorthwindWhereQueryTestBase> + public class NorthwindWhereQuerySqlServerTest : NorthwindWhereQueryRelationalTestBase> { public NorthwindWhereQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -17,6 +17,8 @@ public NorthwindWhereQuerySqlServerTest(NorthwindQuerySqlServerFixture true; + public override async Task Where_simple(bool async) { await base.Where_simple(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs index cbd824e5326..1147aaedcac 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class OwnedQuerySqlServerTest : RelationalOwnedQueryTestBase + public class OwnedQuerySqlServerTest : OwnedQueryRelationalTestBase { public OwnedQuerySqlServerTest(OwnedQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -15,6 +15,8 @@ public OwnedQuerySqlServerTest(OwnedQuerySqlServerFixture fixture, ITestOutputHe Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + protected override bool CanExecuteQueryString => true; + public override async Task Query_with_owned_entity_equality_operator(bool async) { await base.Query_with_owned_entity_equality_operator(async); @@ -776,8 +778,6 @@ private void AssertSql(params string[] expected) public class OwnedQuerySqlServerFixture : RelationalOwnedQueryFixture { protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; - - protected override bool CanExecuteQueryString => true; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerFixture.cs index 0989f326a0d..34ba1f5fba8 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerFixture.cs @@ -27,8 +27,6 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build return optionsBuilder; } - protected override bool CanExecuteQueryString => true; - protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { base.OnModelCreating(modelBuilder, context); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs index 9e927f2c340..15c22136cd5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs @@ -6,7 +6,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class SpatialQuerySqlServerGeographyTest : SpatialQueryTestBase + public class SpatialQuerySqlServerGeographyTest : SpatialQueryRelationalTestBase { public SpatialQuerySqlServerGeographyTest(SpatialQuerySqlServerGeographyFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -15,6 +15,8 @@ public SpatialQuerySqlServerGeographyTest(SpatialQuerySqlServerGeographyFixture //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + protected override bool CanExecuteQueryString => true; + // TODO: Remove after NetTopologySuite/NetTopologySuite#233 protected override bool AssertDistances => false; diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs index 5d331c96a26..0cdbf72e1f2 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs @@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class SpatialQuerySqlServerGeometryTest : SpatialQueryTestBase + public class SpatialQuerySqlServerGeometryTest : SpatialQueryRelationalTestBase { public SpatialQuerySqlServerGeometryTest(SpatialQuerySqlServerGeometryFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -19,6 +19,8 @@ public SpatialQuerySqlServerGeometryTest(SpatialQuerySqlServerGeometryFixture fi //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + protected override bool CanExecuteQueryString => true; + public override async Task SimpleSelect(bool async) { await base.SimpleSelect(async); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/AsyncGearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/AsyncGearsOfWarQuerySqliteTest.cs index 6bc49057c57..1779b17011e 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/AsyncGearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/AsyncGearsOfWarQuerySqliteTest.cs @@ -5,7 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class AsyncGearsOfWarQuerySqliteTest : AsyncGearsOfWarQueryTestBase + public class AsyncGearsOfWarQuerySqliteTest : AsyncGearsOfWarQueryRelationalTestBase { public AsyncGearsOfWarQuerySqliteTest(GearsOfWarQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs index 6c45adcdb65..746e1edbd16 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs @@ -6,7 +6,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class ComplexNavigationsQuerySqliteTest : ComplexNavigationsQueryTestBase + public class ComplexNavigationsQuerySqliteTest : ComplexNavigationsQueryRelationalTestBase { public ComplexNavigationsQuerySqliteTest(ComplexNavigationsQuerySqliteFixture fixture) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/FunkyDataQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/FunkyDataQuerySqliteTest.cs index ad229f0d9ea..f8ea62c5c45 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/FunkyDataQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/FunkyDataQuerySqliteTest.cs @@ -1,9 +1,6 @@ // 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.Collections.Generic; -using Microsoft.EntityFrameworkCore.TestModels.FunkyDataModel; using Microsoft.EntityFrameworkCore.TestUtilities; namespace Microsoft.EntityFrameworkCore.Query @@ -15,21 +12,16 @@ public FunkyDataQuerySqliteTest(FunkyDataQuerySqliteFixture fixture) { } + protected virtual bool CanExecuteQueryString => false; + + protected override QueryAsserter CreateQueryAsserter(FunkyDataQuerySqliteFixture fixture) + => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + public class FunkyDataQuerySqliteFixture : FunkyDataQueryFixtureBase { public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; - - protected override QueryAsserter CreateQueryAsserter( - Dictionary entitySorters, - Dictionary entityAsserters) - => new RelationalQueryAsserter( - CreateContext, - new FunkyDataData(), - entitySorters, - entityAsserters, - CanExecuteQueryString); } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs index c584a7f307b..10117e94377 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class GearsOfWarQuerySqliteTest : GearsOfWarQueryTestBase + public class GearsOfWarQuerySqliteTest : GearsOfWarQueryRelationalTestBase { public GearsOfWarQuerySqliteTest(GearsOfWarQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/IncludeSqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/IncludeSqliteFixture.cs deleted file mode 100644 index 992f67d8f37..00000000000 --- a/test/EFCore.Sqlite.FunctionalTests/Query/IncludeSqliteFixture.cs +++ /dev/null @@ -1,13 +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 IncludeSqliteFixture : NorthwindQuerySqliteFixture - { - public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) - => base.AddOptions(builder); - } -} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyQuerySqliteTest.cs index fd21c827573..e443fe97d59 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyQuerySqliteTest.cs @@ -3,7 +3,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class ManyToManyQuerySqliteTest : ManyToManyQueryTestBase + public class ManyToManyQuerySqliteTest : ManyToManyQueryRelationalTestBase { public ManyToManyQuerySqliteTest(ManyToManyQuerySqliteFixture fixture) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs index 821fa41aa92..c4add4c207f 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindAggregateOperatorsQuerySqliteTest : NorthwindAggregateOperatorsQueryTestBase> + public class NorthwindAggregateOperatorsQuerySqliteTest : NorthwindAggregateOperatorsQueryRelationalTestBase> { public NorthwindAggregateOperatorsQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqliteTest.cs index aec09bad88e..8d682393edb 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqliteTest.cs @@ -10,7 +10,7 @@ #pragma warning disable 1998 namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindAsyncSimpleQuerySqliteTest : NorthwindAsyncSimpleQueryTestBase> + public class NorthwindAsyncSimpleQuerySqliteTest : NorthwindAsyncSimpleQueryRelationalTestBase> { public NorthwindAsyncSimpleQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/CompiledQueryInMemoryTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindCompiledQuerySqliteTest.cs similarity index 100% rename from test/EFCore.Sqlite.FunctionalTests/Query/CompiledQueryInMemoryTest.cs rename to test/EFCore.Sqlite.FunctionalTests/Query/NorthwindCompiledQuerySqliteTest.cs diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs index 30676e4587f..747459a4c39 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs @@ -6,7 +6,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindDbFunctionsQuerySqliteTest : RelationalNorthwindDbFunctionsQueryTestBase> + public class NorthwindDbFunctionsQuerySqliteTest : NorthwindDbFunctionsQueryRelationalTestBase> { public NorthwindDbFunctionsQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs index ad0cb2b423a..c8c5e9f07c8 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindFunctionsQuerySqliteTest : NorthwindFunctionsQueryTestBase> + public class NorthwindFunctionsQuerySqliteTest : NorthwindFunctionsQueryRelationalTestBase> { public NorthwindFunctionsQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindGroupByQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindGroupByQuerySqliteTest.cs index 68e32f087f2..fbe2b67c34d 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindGroupByQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindGroupByQuerySqliteTest.cs @@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindGroupByQuerySqliteTest : NorthwindGroupByQueryTestBase> + public class NorthwindGroupByQuerySqliteTest : NorthwindGroupByQueryRelationalTestBase> { // ReSharper disable once UnusedParameter.Local public NorthwindGroupByQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeQuerySqliteTest.cs index 48ef2a78c2a..363812673bc 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeQuerySqliteTest.cs @@ -2,13 +2,14 @@ // 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 class NorthwindIncludeQuerySqliteTest : NorthwindIncludeQueryTestBase + public class NorthwindIncludeQuerySqliteTest : NorthwindIncludeQueryRelationalTestBase> { - public NorthwindIncludeQuerySqliteTest(IncludeSqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindIncludeQuerySqliteTest(NorthwindQuerySqliteFixture 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 index 5649855ffcd..a2b3a955a03 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindJoinQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindJoinQuerySqliteTest.cs @@ -6,7 +6,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindJoinQuerySqliteTest : NorthwindJoinQueryTestBase> + public class NorthwindJoinQuerySqliteTest : NorthwindJoinQueryRelationalTestBase> { public NorthwindJoinQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqliteTest.cs index 8dda6d97a08..0b2f1636444 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqliteTest.cs @@ -6,7 +6,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindKeylessEntitiesQuerySqliteTest : NorthwindKeylessEntitiesQueryTestBase> + public class NorthwindKeylessEntitiesQuerySqliteTest : NorthwindKeylessEntitiesQueryRelationalTestBase> { public NorthwindKeylessEntitiesQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs index b20dd511cc2..a1361c4e8c8 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs @@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindMiscellaneousQuerySqliteTest : NorthwindMiscellaneousQueryTestBase> + public class NorthwindMiscellaneousQuerySqliteTest : NorthwindMiscellaneousQueryRelationalTestBase> { // ReSharper disable once UnusedParameter.Local public NorthwindMiscellaneousQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindNavigationsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindNavigationsQuerySqliteTest.cs index 93a1bf98ee4..d0f9d9eb088 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindNavigationsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindNavigationsQuerySqliteTest.cs @@ -5,7 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindNavigationsQuerySqliteTest : NorthwindNavigationsQueryTestBase> + public class NorthwindNavigationsQuerySqliteTest : NorthwindNavigationsQueryRelationalTestBase> { public NorthwindNavigationsQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSelectQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSelectQuerySqliteTest.cs index a31c6d39644..8feb9ac400d 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSelectQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSelectQuerySqliteTest.cs @@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindSelectQuerySqliteTest : NorthwindSelectQueryTestBase> + public class NorthwindSelectQuerySqliteTest : NorthwindSelectQueryRelationalTestBase> { public NorthwindSelectQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSetOperationsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSetOperationsQuerySqliteTest.cs index 20def8f5c86..e1a2643a4a1 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSetOperationsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSetOperationsQuerySqliteTest.cs @@ -6,7 +6,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindSetOperationsQuerySqliteTest : NorthwindSetOperationsQueryTestBase> + public class NorthwindSetOperationsQuerySqliteTest : NorthwindSetOperationsQueryRelationalTestBase> { public NorthwindSetOperationsQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs index cf0e3f04557..18775eca3d2 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindWhereQuerySqliteTest : NorthwindWhereQueryTestBase> + public class NorthwindWhereQuerySqliteTest : NorthwindWhereQueryRelationalTestBase> { public NorthwindWhereQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/OwnedQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/OwnedQuerySqliteTest.cs index dc951372f9d..8b175078a0e 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/OwnedQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/OwnedQuerySqliteTest.cs @@ -5,7 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class OwnedQuerySqliteTest : RelationalOwnedQueryTestBase + public class OwnedQuerySqliteTest : OwnedQueryRelationalTestBase { public OwnedQuerySqliteTest(OwnedQuerySqliteFixture fixture) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteTest.cs index bb1503bcbe5..e589b41be11 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteTest.cs @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.Query { [SpatialiteRequired] - public class SpatialQuerySqliteTest : SpatialQueryTestBase + public class SpatialQuerySqliteTest : SpatialQueryRelationalTestBase { public SpatialQuerySqliteTest(SpatialQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture)