Skip to content
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 1 commit into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
}
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;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +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.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace Microsoft.EntityFrameworkCore.Query
Expand Down
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)
{
}
}
}
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)
{
}
}
}
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);
}
}
}
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")]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public override Task Include_reference_collection_order_by_reference_navigation(bool async)
{
return base.Include_reference_collection_order_by_reference_navigation(async);
}
}
}
Loading