forked from dotnet/efcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor method/member translation tests into their own suite (dotnet…
…#35319) Closes dotnet#34872
- Loading branch information
Showing
64 changed files
with
30,840 additions
and
34,956 deletions.
There are no files selected for viewing
2,031 changes: 36 additions & 1,995 deletions
2,031
test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs
Large diffs are not rendered by default.
Oops, something went wrong.
421 changes: 0 additions & 421 deletions
421
test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs
Large diffs are not rendered by default.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
test/EFCore.Cosmos.FunctionalTests/Query/Translations/BasicTypesQueryCosmosFixture.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,38 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query.Translations; | ||
|
||
public class BasicTypesQueryCosmosFixture : BasicTypesQueryFixtureBase | ||
{ | ||
protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; | ||
|
||
public TestSqlLoggerFactory TestSqlLoggerFactory | ||
=> (TestSqlLoggerFactory)ListLoggerFactory; | ||
|
||
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) | ||
=> builder.ConfigureWarnings(o => o.Ignore(CosmosEventId.NoPartitionKeyDefined)); | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) | ||
{ | ||
base.OnModelCreating(modelBuilder, context); | ||
|
||
modelBuilder.Entity<BasicTypesEntity>( | ||
builder => | ||
{ | ||
builder.ToContainer(nameof(BasicTypesEntity)); | ||
builder.HasPartitionKey(b => b.Id); | ||
}); | ||
modelBuilder.Entity<NullableBasicTypesEntity>( | ||
builder => | ||
{ | ||
builder.ToContainer(nameof(NullableBasicTypesEntity)); | ||
builder.HasPartitionKey(n => n.Id); | ||
}); | ||
} | ||
|
||
public Task NoSyncTest(bool async, Func<bool, Task> testCode) | ||
=> CosmosTestHelpers.Instance.NoSyncTest(async, testCode); | ||
} |
281 changes: 281 additions & 0 deletions
281
test/EFCore.Cosmos.FunctionalTests/Query/Translations/EnumTranslationsCosmosTest.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,281 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query.Translations; | ||
|
||
public class EnumTranslationsCosmosTest : EnumTranslationsTestBase<BasicTypesQueryCosmosFixture> | ||
{ | ||
public EnumTranslationsCosmosTest(BasicTypesQueryCosmosFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) | ||
{ | ||
Fixture.TestSqlLoggerFactory.Clear(); | ||
Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); | ||
} | ||
|
||
#region Equality | ||
|
||
public override Task Equality_to_constant(bool async) | ||
=> Fixture.NoSyncTest( | ||
async, async a => | ||
{ | ||
await base.Equality_to_constant(a); | ||
|
||
AssertSql( | ||
""" | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE (c["Enum"] = 0) | ||
"""); | ||
}); | ||
|
||
public override Task Equality_to_parameter(bool async) | ||
=> Fixture.NoSyncTest( | ||
async, async a => | ||
{ | ||
await base.Equality_to_parameter(a); | ||
|
||
AssertSql( | ||
""" | ||
@basicEnum=? | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE (c["Enum"] = @basicEnum) | ||
"""); | ||
}); | ||
|
||
public override Task Equality_nullable_enum_to_constant(bool async) | ||
=> Fixture.NoSyncTest( | ||
async, async a => | ||
{ | ||
await base.Equality_nullable_enum_to_constant(a); | ||
|
||
AssertSql( | ||
""" | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE (c["Enum"] = 0) | ||
"""); | ||
}); | ||
|
||
public override Task Equality_nullable_enum_to_parameter(bool async) | ||
=> Fixture.NoSyncTest( | ||
async, async a => | ||
{ | ||
await base.Equality_nullable_enum_to_parameter(a); | ||
|
||
AssertSql( | ||
""" | ||
@basicEnum=? | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE (c["Enum"] = @basicEnum) | ||
"""); | ||
}); | ||
|
||
public override Task Equality_nullable_enum_to_null_constant(bool async) | ||
=> Fixture.NoSyncTest( | ||
async, async a => | ||
{ | ||
await base.Equality_nullable_enum_to_null_constant(a); | ||
|
||
AssertSql( | ||
""" | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE (c["Enum"] = null) | ||
"""); | ||
}); | ||
|
||
public override Task Equality_nullable_enum_to_null_parameter(bool async) | ||
=> Fixture.NoSyncTest( | ||
async, async a => | ||
{ | ||
await base.Equality_nullable_enum_to_null_parameter(a); | ||
|
||
AssertSql( | ||
""" | ||
@basicEnum=? | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE (c["Enum"] = @basicEnum) | ||
"""); | ||
}); | ||
|
||
public override Task Equality_nullable_enum_to_nullable_parameter(bool async) | ||
=> Fixture.NoSyncTest( | ||
async, async a => | ||
{ | ||
await base.Equality_nullable_enum_to_nullable_parameter(a); | ||
|
||
AssertSql( | ||
""" | ||
@basicEnum=? | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE (c["Enum"] = @basicEnum) | ||
"""); | ||
}); | ||
|
||
#endregion Equality | ||
|
||
public override Task Bitwise_and_enum_constant(bool async) | ||
=> Fixture.NoSyncTest( | ||
async, async a => | ||
{ | ||
await base.Bitwise_and_enum_constant(a); | ||
|
||
AssertSql( | ||
""" | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE ((c["FlagsEnum"] & 1) > 0) | ||
""", | ||
// | ||
""" | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE ((c["FlagsEnum"] & 1) = 1) | ||
"""); | ||
}); | ||
|
||
public override async Task Bitwise_and_integral_constant(bool async) | ||
{ | ||
// Always throws for sync. | ||
if (async) | ||
{ | ||
// Cosmos client evaluation. Issue #17246. | ||
await AssertTranslationFailed(() => base.Bitwise_and_integral_constant(async)); | ||
|
||
AssertSql( | ||
""" | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE ((c["FlagsEnum"] & 8) = 8) | ||
"""); | ||
} | ||
} | ||
|
||
public override Task Bitwise_and_nullable_enum_with_constant(bool async) | ||
=> Fixture.NoSyncTest( | ||
async, async a => | ||
{ | ||
await base.Bitwise_and_nullable_enum_with_constant(a); | ||
|
||
AssertSql( | ||
""" | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE ((c["FlagsEnum"] & 8) > 0) | ||
"""); | ||
}); | ||
|
||
public override Task Where_bitwise_and_nullable_enum_with_null_constant(bool async) | ||
=> Fixture.NoSyncTest( | ||
async, async a => | ||
{ | ||
await base.Where_bitwise_and_nullable_enum_with_null_constant(a); | ||
|
||
AssertSql( | ||
""" | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE ((c["FlagsEnum"] & null) > 0) | ||
"""); | ||
}); | ||
|
||
public override Task Where_bitwise_and_nullable_enum_with_non_nullable_parameter(bool async) | ||
=> Fixture.NoSyncTest( | ||
async, async a => | ||
{ | ||
await base.Where_bitwise_and_nullable_enum_with_non_nullable_parameter(a); | ||
|
||
AssertSql( | ||
""" | ||
@flagsEnum=? | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE ((c["FlagsEnum"] & @flagsEnum) > 0) | ||
"""); | ||
}); | ||
|
||
public override Task Where_bitwise_and_nullable_enum_with_nullable_parameter(bool async) | ||
=> Fixture.NoSyncTest( | ||
async, async a => | ||
{ | ||
await base.Where_bitwise_and_nullable_enum_with_nullable_parameter(a); | ||
|
||
AssertSql( | ||
""" | ||
@flagsEnum=? | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE ((c["FlagsEnum"] & @flagsEnum) > 0) | ||
""", | ||
// | ||
""" | ||
@flagsEnum=? | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE ((c["FlagsEnum"] & @flagsEnum) > 0) | ||
"""); | ||
}); | ||
|
||
public override Task Bitwise_or(bool async) | ||
=> Fixture.NoSyncTest( | ||
async, async a => | ||
{ | ||
await base.Bitwise_or(a); | ||
|
||
AssertSql( | ||
""" | ||
SELECT VALUE c | ||
FROM root c | ||
WHERE ((c["FlagsEnum"] | 8) > 0) | ||
"""); | ||
}); | ||
|
||
public override Task Bitwise_projects_values_in_select(bool async) | ||
=> Fixture.NoSyncTest( | ||
async, async a => | ||
{ | ||
await base.Bitwise_projects_values_in_select(a); | ||
|
||
AssertSql( | ||
""" | ||
SELECT VALUE | ||
{ | ||
"BitwiseTrue" : ((c["FlagsEnum"] & 8) = 8), | ||
"BitwiseFalse" : ((c["FlagsEnum"] & 8) = 4), | ||
"BitwiseValue" : (c["FlagsEnum"] & 8) | ||
} | ||
FROM root c | ||
WHERE ((c["FlagsEnum"] & 8) = 8) | ||
OFFSET 0 LIMIT 1 | ||
"""); | ||
}); | ||
|
||
// #35317 | ||
public override Task HasFlag(bool async) | ||
=> AssertTranslationFailed(() => base.HasFlag(async)); | ||
|
||
// #35317 | ||
public override Task HasFlag_with_non_nullable_parameter(bool async) | ||
=> AssertTranslationFailed(() => base.HasFlag(async)); | ||
|
||
// #35317 | ||
public override Task HasFlag_with_nullable_parameter(bool async) | ||
=> AssertTranslationFailed(() => base.HasFlag(async)); | ||
|
||
[ConditionalFact] | ||
public virtual void Check_all_tests_overridden() | ||
=> TestHelpers.AssertAllMethodsOverridden(GetType()); | ||
|
||
private void AssertSql(params string[] expected) | ||
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected); | ||
} |
Oops, something went wrong.