Skip to content

Commit

Permalink
Grinding the gears of war
Browse files Browse the repository at this point in the history
#26088 for Gears query tests.
  • Loading branch information
ajcvickers committed Jan 4, 2022
1 parent 31b3ae4 commit d4966ae
Show file tree
Hide file tree
Showing 9 changed files with 17,782 additions and 1,318 deletions.
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

0 comments on commit d4966ae

Please sign in to comment.