-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix to #21393 - Query: Convert to AssertQuery in tests as much as pos…
…sible added support for query filters to the AssertQuery test infra (using AssertFilteredQuery methods) and converted query filter tests to take advantage of it - when creating new instance of ExpectedData we can now apply necessary filtering direcly on the dataset, rather than modifying the expected query itself, - ExpectedData is now created for every query to make sure changes to properties on dbcontext are taken into account (e.g. TenantId), - ExpectedData are cached to avoid big perf hit. Also incorporated async GoW tests into the regular GoW test suite, Fixes #21393
- Loading branch information
Showing
39 changed files
with
1,061 additions
and
593 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
test/EFCore.InMemory.FunctionalTests/Query/AsyncGearsOfWarQueryInMemoryTest.cs
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
test/EFCore.Relational.Specification.Tests/Query/AsyncGearsOfWarQueryRelationalTestBase.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 0 additions & 48 deletions
48
test/EFCore.Specification.Tests/Query/AsyncGearsOfWarQueryTestBase.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
test/EFCore.Specification.Tests/Query/FilteredQueryTestBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Linq; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore.TestUtilities; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
public abstract class FilteredQueryTestBase<TFixture> : QueryTestBase<TFixture> | ||
where TFixture : class, IQueryFixtureBase, new() | ||
{ | ||
protected FilteredQueryTestBase(TFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
|
||
public Task AssertFilteredQuery<TResult>( | ||
bool async, | ||
Func<ISetSource, IQueryable<TResult>> query, | ||
Func<TResult, object> elementSorter = null, | ||
Action<TResult, TResult> elementAsserter = null, | ||
bool assertOrder = false, | ||
int entryCount = 0, | ||
[CallerMemberName] string testMethodName = null) | ||
where TResult : class | ||
=> AssertFilteredQuery(async, query, query, elementSorter, elementAsserter, assertOrder, entryCount, testMethodName); | ||
|
||
public Task AssertFilteredQuery<TResult>( | ||
bool async, | ||
Func<ISetSource, IQueryable<TResult>> actualQuery, | ||
Func<ISetSource, IQueryable<TResult>> expectedQuery, | ||
Func<TResult, object> elementSorter = null, | ||
Action<TResult, TResult> elementAsserter = null, | ||
bool assertOrder = false, | ||
int entryCount = 0, | ||
[CallerMemberName] string testMethodName = null) | ||
where TResult : class | ||
=> QueryAsserter.AssertQuery( | ||
actualQuery, expectedQuery, elementSorter, elementAsserter, assertOrder, entryCount, async, testMethodName, filteredQuery: true); | ||
|
||
public Task AssertFilteredQueryScalar<TResult>( | ||
bool async, | ||
Func<ISetSource, IQueryable<TResult>> query, | ||
bool assertOrder = false, | ||
[CallerMemberName] string testMethodName = null) | ||
where TResult : struct | ||
=> AssertFilteredQueryScalar(async, query, query, assertOrder, testMethodName); | ||
|
||
public Task AssertFilteredQueryScalar<TResult>( | ||
bool async, | ||
Func<ISetSource, IQueryable<TResult>> actualQuery, | ||
Func<ISetSource, IQueryable<TResult>> expectedQuery, | ||
bool assertOrder = false, | ||
[CallerMemberName] string testMethodName = null) | ||
where TResult : struct | ||
=> QueryAsserter.AssertQueryScalar(actualQuery, expectedQuery, assertOrder, async, testMethodName, filteredQuery: true); | ||
|
||
protected Task AssertFilteredCount<TResult>( | ||
bool async, | ||
Func<ISetSource, IQueryable<TResult>> query) | ||
=> AssertFilteredCount(async, query, query); | ||
|
||
protected Task AssertFilteredCount<TResult>( | ||
bool async, | ||
Func<ISetSource, IQueryable<TResult>> actualQuery, | ||
Func<ISetSource, IQueryable<TResult>> expectedQuery) | ||
=> QueryAsserter.AssertCount(actualQuery, expectedQuery, async, filteredQuery: true); | ||
} | ||
} |
Oops, something went wrong.