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

Grinding the gears of war #27055

Merged
merged 2 commits into from
Jan 4, 2022
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
Expand Up @@ -3,6 +3,7 @@

using Microsoft.EntityFrameworkCore.InMemory.Internal;
using Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel;
using Xunit.Sdk;

namespace Microsoft.EntityFrameworkCore.Query;

Expand All @@ -28,39 +29,77 @@ public override async Task
.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(
async))).Message);

[ConditionalTheory(Skip = "issue #19683")]
public override Task Group_by_on_StartsWith_with_null_parameter_as_argument(bool async)
=> base.Group_by_on_StartsWith_with_null_parameter_as_argument(async);
public override async Task Group_by_on_StartsWith_with_null_parameter_as_argument(bool async)
// Grouping by constant. Issue #19683.
=> Assert.Equal(
"1",
(await Assert.ThrowsAsync<EqualException>(
() => base.Group_by_on_StartsWith_with_null_parameter_as_argument(async)))
.Actual);

[ConditionalTheory(Skip = "issue #24325")]
public override Task Projecting_entity_as_well_as_correlated_collection_followed_by_Distinct(bool async)
=> base.Projecting_entity_as_well_as_correlated_collection_followed_by_Distinct(async);
public override async Task Projecting_entity_as_well_as_correlated_collection_followed_by_Distinct(bool async)
// Distinct. Issue #24325.
=> Assert.Equal(
InMemoryStrings.DistinctOnSubqueryNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_entity_as_well_as_correlated_collection_followed_by_Distinct(async))).Message);

[ConditionalTheory(Skip = "issue #24325")]
public override Task Projecting_entity_as_well_as_complex_correlated_collection_followed_by_Distinct(bool async)
=> base.Projecting_entity_as_well_as_complex_correlated_collection_followed_by_Distinct(async);
public override async Task Projecting_entity_as_well_as_complex_correlated_collection_followed_by_Distinct(bool async)
// Distinct. Issue #24325.
=> Assert.Equal(
InMemoryStrings.DistinctOnSubqueryNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_entity_as_well_as_complex_correlated_collection_followed_by_Distinct(async))).Message);

[ConditionalTheory(Skip = "issue #24325")]
public override Task Projecting_entity_as_well_as_correlated_collection_of_scalars_followed_by_Distinct(bool async)
=> base.Projecting_entity_as_well_as_correlated_collection_of_scalars_followed_by_Distinct(async);
public override async Task Projecting_entity_as_well_as_correlated_collection_of_scalars_followed_by_Distinct(bool async)
// Distinct. Issue #24325.
=> Assert.Equal(
InMemoryStrings.DistinctOnSubqueryNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_entity_as_well_as_correlated_collection_of_scalars_followed_by_Distinct(async))).Message);

[ConditionalTheory(Skip = "issue #24325")]
public override Task Correlated_collection_with_distinct_3_levels(bool async)
=> base.Correlated_collection_with_distinct_3_levels(async);
public override async Task Correlated_collection_with_distinct_3_levels(bool async)
// Distinct. Issue #24325.
=> Assert.Equal(
InMemoryStrings.DistinctOnSubqueryNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Correlated_collection_with_distinct_3_levels(async))).Message);

public override async Task Projecting_correlated_collection_followed_by_Distinct(bool async)
{
var message = (await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_correlated_collection_followed_by_Distinct(async))).Message;

Assert.Equal(InMemoryStrings.DistinctOnSubqueryNotSupported, message);
}
// Distinct. Issue #24325.
=> Assert.Equal(
InMemoryStrings.DistinctOnSubqueryNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_correlated_collection_followed_by_Distinct(async))).Message);

public override async Task Projecting_some_properties_as_well_as_correlated_collection_followed_by_Distinct(bool async)
{
var message = (await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_some_properties_as_well_as_correlated_collection_followed_by_Distinct(async))).Message;
// Distinct. Issue #24325.
=> Assert.Equal(
InMemoryStrings.DistinctOnSubqueryNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_some_properties_as_well_as_correlated_collection_followed_by_Distinct(async))).Message);

Assert.Equal(InMemoryStrings.DistinctOnSubqueryNotSupported, message);
}
public override Task Include_after_SelectMany_throws(bool async)
=> Assert.ThrowsAsync<NullReferenceException>(() => base.Include_after_SelectMany_throws(async));

public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(bool async)
=> Assert.Equal(
"4",
(((EqualException)(await Assert.ThrowsAsync<TargetInvocationException>(
() => base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(async))).InnerException!.InnerException)!)
.Actual);

public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(bool async)
=> Assert.Equal(
"6",
(((EqualException)(await Assert.ThrowsAsync<TargetInvocationException>(
() => base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(async)))
.InnerException!.InnerException)!)
.Actual);

public override Task Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(
bool async)
// Null protection. Issue #13721.
=> Assert.ThrowsAsync<InvalidOperationException>(
() => base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(async));
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel;
using Xunit.Sdk;

namespace Microsoft.EntityFrameworkCore.Query;

Expand All @@ -13,28 +14,34 @@ protected GearsOfWarQueryRelationalTestBase(TFixture fixture)
{
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Parameter_used_multiple_times_take_appropriate_inferred_type_mapping(bool async)
{
var place = "Seattle";
return AssertQuery(
async,
ss => ss.Set<City>().Where(e => e.Nation == place || e.Location == place));
}

public override async Task
Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection(
bool async)
{
var message = (await Assert.ThrowsAsync<InvalidOperationException>(
() => base
.Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection(
async))).Message;

Assert.Equal(RelationalStrings.InsufficientInformationToIdentifyElementOfCollectionJoin, message);
}
=> Assert.Equal(
RelationalStrings.InsufficientInformationToIdentifyElementOfCollectionJoin,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base
.Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection(
async))).Message);

public override async Task Correlated_collection_with_distinct_not_projecting_identifier_column_also_projecting_complex_expressions(
bool async)
{
var message = (await Assert.ThrowsAsync<InvalidOperationException>(
=> Assert.Equal(
RelationalStrings.InsufficientInformationToIdentifyElementOfCollectionJoin,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Correlated_collection_with_distinct_not_projecting_identifier_column_also_projecting_complex_expressions(
async)))
.Message;

Assert.Equal(RelationalStrings.InsufficientInformationToIdentifyElementOfCollectionJoin, message);
}
.Message);

public override async Task Client_eval_followed_by_aggregate_operation(bool async)
{
Expand Down Expand Up @@ -117,62 +124,56 @@ await AssertQuery(
}

public override async Task Projecting_correlated_collection_followed_by_Distinct(bool async)
{
var message = (await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_correlated_collection_followed_by_Distinct(async))).Message;

Assert.Equal(RelationalStrings.DistinctOnCollectionNotSupported, message);
}
=> Assert.Equal(RelationalStrings.DistinctOnCollectionNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_correlated_collection_followed_by_Distinct(async))).Message);

public override async Task Projecting_some_properties_as_well_as_correlated_collection_followed_by_Distinct(bool async)
{
var message = (await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_some_properties_as_well_as_correlated_collection_followed_by_Distinct(async))).Message;

Assert.Equal(RelationalStrings.DistinctOnCollectionNotSupported, message);
}
=> Assert.Equal(RelationalStrings.DistinctOnCollectionNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_some_properties_as_well_as_correlated_collection_followed_by_Distinct(async))).Message);

public override async Task Projecting_entity_as_well_as_correlated_collection_followed_by_Distinct(bool async)
{
var message = (await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_entity_as_well_as_correlated_collection_followed_by_Distinct(async))).Message;

Assert.Equal(RelationalStrings.DistinctOnCollectionNotSupported, message);
}
=> Assert.Equal(
RelationalStrings.DistinctOnCollectionNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_entity_as_well_as_correlated_collection_followed_by_Distinct(async))).Message);

public override async Task Projecting_entity_as_well_as_complex_correlated_collection_followed_by_Distinct(bool async)
{
var message = (await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_entity_as_well_as_complex_correlated_collection_followed_by_Distinct(async))).Message;

Assert.Equal(RelationalStrings.DistinctOnCollectionNotSupported, message);
}
=> Assert.Equal(
RelationalStrings.DistinctOnCollectionNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_entity_as_well_as_complex_correlated_collection_followed_by_Distinct(async))).Message);

public override async Task Projecting_entity_as_well_as_correlated_collection_of_scalars_followed_by_Distinct(bool async)
{
var message = (await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_entity_as_well_as_correlated_collection_of_scalars_followed_by_Distinct(async))).Message;

Assert.Equal(RelationalStrings.DistinctOnCollectionNotSupported, message);
Assert.Equal(
RelationalStrings.DistinctOnCollectionNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Projecting_entity_as_well_as_correlated_collection_of_scalars_followed_by_Distinct(async))).Message);
}

public override async Task Correlated_collection_with_distinct_3_levels(bool async)
{
var message = (await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Correlated_collection_with_distinct_3_levels(async))).Message;

Assert.Equal(RelationalStrings.DistinctOnCollectionNotSupported, message);
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Parameter_used_multiple_times_take_appropriate_inferred_type_mapping(bool async)
{
var place = "Seattle";
return AssertQuery(
async,
ss => ss.Set<City>().Where(e => e.Nation == place || e.Location == place));
}
=> Assert.Equal(
RelationalStrings.DistinctOnCollectionNotSupported,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Correlated_collection_with_distinct_3_levels(async))).Message);

public override Task Include_after_SelectMany_throws(bool async)
=> Assert.ThrowsAsync<NullReferenceException>(() => base.Include_after_SelectMany_throws(async));

public override Task String_concat_on_various_types(bool async)
=> Assert.ThrowsAsync<EqualException>(() => base.String_concat_on_various_types(async));

public override Task Where_compare_anonymous_types(bool async)
// Anonymous objects comparison Issue #8421.
=> AssertTranslationFailed(() => base.Where_compare_anonymous_types(async));

public override async Task Correlated_collection_after_distinct_3_levels_without_original_identifiers(bool async)
=> Assert.Equal(
RelationalStrings.InsufficientInformationToIdentifyElementOfCollectionJoin,
(await Assert.ThrowsAsync<InvalidOperationException>(
() => base.Correlated_collection_after_distinct_3_levels_without_original_identifiers(async))).Message);

protected virtual bool CanExecuteQueryString
=> false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ protected TPTGearsOfWarQueryRelationalTestBase(TFixture fixture)
}

public override Task Project_discriminator_columns(bool async)
=> Task.CompletedTask;
=> AssertUnableToTranslateEFProperty(() => base.Project_discriminator_columns(async));
}
Loading