-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ComplexNavigations test refactoring #24709
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsCollectionsQueryInMemoryTest.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,16 @@ | ||
// 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 Xunit.Abstractions; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
public class ComplexNavigationsCollectionsQueryInMemoryTest : ComplexNavigationsCollectionsQueryTestBase<ComplexNavigationsQueryInMemoryFixture> | ||
{ | ||
public ComplexNavigationsCollectionsQueryInMemoryTest(ComplexNavigationsQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) | ||
: base(fixture) | ||
{ | ||
//TestLoggerFactory.TestOutputHelper = testOutputHelper; | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...nMemory.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQueryInMemoryTest.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,20 @@ | ||
// 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 Xunit.Abstractions; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
public class ComplexNavigationsCollectionsSharedTypeQueryInMemoryTest : | ||
ComplexNavigationsCollectionsSharedTypeQueryTestBase<ComplexNavigationsSharedTypeQueryInMemoryFixture> | ||
{ | ||
// ReSharper disable once UnusedParameter.Local | ||
public ComplexNavigationsCollectionsSharedTypeQueryInMemoryTest( | ||
ComplexNavigationsSharedTypeQueryInMemoryFixture fixture, | ||
ITestOutputHelper testOutputHelper) | ||
: base(fixture) | ||
{ | ||
//TestLoggerFactory.TestOutputHelper = testOutputHelper; | ||
} | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryTest.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
14 changes: 14 additions & 0 deletions
14
...ational.Specification.Tests/Query/ComplexNavigationsCollectionsQueryRelationalTestBase.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,14 @@ | ||
// 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. | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
public abstract class ComplexNavigationsCollectionsQueryRelationalTestBase<TFixture> : ComplexNavigationsCollectionsQueryTestBase<TFixture> | ||
where TFixture : ComplexNavigationsQueryFixtureBase, new() | ||
{ | ||
protected ComplexNavigationsCollectionsQueryRelationalTestBase(TFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ecification.Tests/Query/ComplexNavigationsCollectionsSharedQueryTypeRelationalTestBase.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,14 @@ | ||
// 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. | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
public abstract class ComplexNavigationsCollectionsSharedQueryTypeRelationalTestBase<TFixture> : ComplexNavigationsCollectionsSharedTypeQueryTestBase<TFixture> | ||
where TFixture : ComplexNavigationsSharedTypeQueryRelationalFixtureBase, new() | ||
{ | ||
protected ComplexNavigationsCollectionsSharedQueryTypeRelationalTestBase(TFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
} | ||
} |
130 changes: 130 additions & 0 deletions
130
...al.Specification.Tests/Query/ComplexNavigationsCollectionsSplitQueryRelationalTestBase.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,130 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Linq.Expressions; | ||
using System.Reflection; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
public abstract class ComplexNavigationsCollectionsSplitQueryRelationalTestBase<TFixture> : ComplexNavigationsCollectionsQueryTestBase<TFixture> | ||
where TFixture : ComplexNavigationsQueryFixtureBase, new() | ||
{ | ||
protected ComplexNavigationsCollectionsSplitQueryRelationalTestBase(TFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
|
||
protected override Expression RewriteServerQueryExpression(Expression serverQueryExpression) | ||
=> new SplitQueryRewritingExpressionVisitor().Visit(serverQueryExpression); | ||
|
||
private class SplitQueryRewritingExpressionVisitor : ExpressionVisitor | ||
{ | ||
private readonly MethodInfo _asSplitQueryMethod | ||
= typeof(RelationalQueryableExtensions).GetMethod(nameof(RelationalQueryableExtensions.AsSplitQuery)); | ||
|
||
protected override Expression VisitExtension(Expression extensionExpression) | ||
{ | ||
if (extensionExpression is QueryRootExpression rootExpression) | ||
{ | ||
var splitMethod = _asSplitQueryMethod.MakeGenericMethod(rootExpression.EntityType.ClrType); | ||
|
||
return Expression.Call(splitMethod, rootExpression); | ||
} | ||
|
||
return base.VisitExtension(extensionExpression); | ||
} | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async) | ||
{ | ||
return base.Complex_query_with_let_collection_projection_FirstOrDefault(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(bool async) | ||
{ | ||
return base.Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Filtered_include_outer_parameter_used_inside_filter(bool async) | ||
{ | ||
return base.Filtered_include_outer_parameter_used_inside_filter(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Include_inside_subquery(bool async) | ||
{ | ||
return base.Include_inside_subquery(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Lift_projection_mapping_when_pushing_down_subquery(bool async) | ||
{ | ||
return base.Lift_projection_mapping_when_pushing_down_subquery(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Null_check_in_anonymous_type_projection_should_not_be_removed(bool async) | ||
{ | ||
return base.Null_check_in_anonymous_type_projection_should_not_be_removed(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Null_check_in_Dto_projection_should_not_be_removed(bool async) | ||
{ | ||
return base.Null_check_in_Dto_projection_should_not_be_removed(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Project_collection_navigation_composed(bool async) | ||
{ | ||
return base.Project_collection_navigation_composed(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Project_collection_navigation_nested_with_take(bool async) | ||
{ | ||
return base.Project_collection_navigation_nested_with_take(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Select_nav_prop_collection_one_to_many_required(bool async) | ||
{ | ||
return base.Select_nav_prop_collection_one_to_many_required(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Select_subquery_single_nested_subquery(bool async) | ||
{ | ||
return base.Select_subquery_single_nested_subquery(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Select_subquery_single_nested_subquery2(bool async) | ||
{ | ||
return base.Select_subquery_single_nested_subquery2(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(bool async) | ||
{ | ||
return base.SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Skip_Take_Select_collection_Skip_Take(bool async) | ||
{ | ||
return base.Skip_Take_Select_collection_Skip_Take(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Take_Select_collection_Take(bool async) | ||
{ | ||
return base.Take_Select_collection_Take(async); | ||
} | ||
} | ||
} |
136 changes: 136 additions & 0 deletions
136
...cation.Tests/Query/ComplexNavigationsCollectionsSplitSharedQueryTypeRelationalTestBase.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,136 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Linq.Expressions; | ||
using System.Reflection; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
public abstract class ComplexNavigationsCollectionsSplitSharedQueryTypeRelationalTestBase<TFixture> : ComplexNavigationsCollectionsSharedTypeQueryTestBase<TFixture> | ||
where TFixture : ComplexNavigationsSharedTypeQueryRelationalFixtureBase, new() | ||
{ | ||
protected ComplexNavigationsCollectionsSplitSharedQueryTypeRelationalTestBase(TFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
|
||
protected override Expression RewriteServerQueryExpression(Expression serverQueryExpression) | ||
=> new SplitQueryRewritingExpressionVisitor().Visit(serverQueryExpression); | ||
|
||
private class SplitQueryRewritingExpressionVisitor : ExpressionVisitor | ||
{ | ||
private readonly MethodInfo _asSplitQueryMethod | ||
= typeof(RelationalQueryableExtensions).GetMethod(nameof(RelationalQueryableExtensions.AsSplitQuery)); | ||
|
||
protected override Expression VisitExtension(Expression extensionExpression) | ||
{ | ||
if (extensionExpression is QueryRootExpression rootExpression) | ||
{ | ||
var splitMethod = _asSplitQueryMethod.MakeGenericMethod(rootExpression.EntityType.ClrType); | ||
|
||
return Expression.Call(splitMethod, rootExpression); | ||
} | ||
|
||
return base.VisitExtension(extensionExpression); | ||
} | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async) | ||
{ | ||
return base.Complex_query_with_let_collection_projection_FirstOrDefault(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(bool async) | ||
{ | ||
return base.Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Filtered_include_outer_parameter_used_inside_filter(bool async) | ||
{ | ||
return base.Filtered_include_outer_parameter_used_inside_filter(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Include_inside_subquery(bool async) | ||
{ | ||
return base.Include_inside_subquery(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Lift_projection_mapping_when_pushing_down_subquery(bool async) | ||
{ | ||
return base.Lift_projection_mapping_when_pushing_down_subquery(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Null_check_in_anonymous_type_projection_should_not_be_removed(bool async) | ||
{ | ||
return base.Null_check_in_anonymous_type_projection_should_not_be_removed(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Null_check_in_Dto_projection_should_not_be_removed(bool async) | ||
{ | ||
return base.Null_check_in_Dto_projection_should_not_be_removed(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Project_collection_navigation_composed(bool async) | ||
{ | ||
return base.Project_collection_navigation_composed(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Project_collection_navigation_nested_with_take(bool async) | ||
{ | ||
return base.Project_collection_navigation_nested_with_take(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Select_nav_prop_collection_one_to_many_required(bool async) | ||
{ | ||
return base.Select_nav_prop_collection_one_to_many_required(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Select_subquery_single_nested_subquery(bool async) | ||
{ | ||
return base.Select_subquery_single_nested_subquery(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Select_subquery_single_nested_subquery2(bool async) | ||
{ | ||
return base.Select_subquery_single_nested_subquery2(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(bool async) | ||
{ | ||
return base.SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Skip_Take_Select_collection_Skip_Take(bool async) | ||
{ | ||
return base.Skip_Take_Select_collection_Skip_Take(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query not fully supported yet.")] | ||
public override Task Take_Select_collection_Take(bool async) | ||
{ | ||
return base.Take_Select_collection_Take(async); | ||
} | ||
|
||
[ConditionalTheory(Skip = "Split query bug")] | ||
public override Task Include_reference_collection_order_by_reference_navigation(bool async) | ||
{ | ||
return base.Include_reference_collection_order_by_reference_navigation(async); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smitpatel FYI