diff --git a/test/EFCore.AspNet.InMemory.FunctionalTests/AppServiceProviderFactoryTest.cs b/test/EFCore.AspNet.InMemory.FunctionalTests/AppServiceProviderFactoryTest.cs index faeff786f93..84b3f4c2c46 100644 --- a/test/EFCore.AspNet.InMemory.FunctionalTests/AppServiceProviderFactoryTest.cs +++ b/test/EFCore.AspNet.InMemory.FunctionalTests/AppServiceProviderFactoryTest.cs @@ -139,7 +139,8 @@ public static TestWebHost BuildWebHost(string[] args) } } -public class TestAppServiceProviderFactory(Assembly startupAssembly, IOperationReporter reporter = null) : AppServiceProviderFactory(startupAssembly, reporter ?? new TestOperationReporter()); +public class TestAppServiceProviderFactory(Assembly startupAssembly, IOperationReporter reporter = null) + : AppServiceProviderFactory(startupAssembly, reporter ?? new TestOperationReporter()); public class TestWebHost(IServiceProvider services) { diff --git a/test/EFCore.AspNet.InMemory.FunctionalTests/AspNetIdentityCustomTypesDefaultInMemoryTest.cs b/test/EFCore.AspNet.InMemory.FunctionalTests/AspNetIdentityCustomTypesDefaultInMemoryTest.cs index d51c1a2a2f7..ab0d2597dfb 100644 --- a/test/EFCore.AspNet.InMemory.FunctionalTests/AspNetIdentityCustomTypesDefaultInMemoryTest.cs +++ b/test/EFCore.AspNet.InMemory.FunctionalTests/AspNetIdentityCustomTypesDefaultInMemoryTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore; -public class AspNetIdentityCustomTypesDefaultInMemoryTest(AspNetIdentityCustomTypesDefaultInMemoryTest.AspNetIdentityCustomTypesDefaultInMemoryFixture fixture) +public class AspNetIdentityCustomTypesDefaultInMemoryTest( + AspNetIdentityCustomTypesDefaultInMemoryTest.AspNetIdentityCustomTypesDefaultInMemoryFixture fixture) : AspNetIdentityCustomTypesDefaultTestBase< AspNetIdentityCustomTypesDefaultInMemoryTest.AspNetIdentityCustomTypesDefaultInMemoryFixture>(fixture) { diff --git a/test/EFCore.AspNet.InMemory.FunctionalTests/AspNetIdentityCustomTypesIntKeyInMemoryTest.cs b/test/EFCore.AspNet.InMemory.FunctionalTests/AspNetIdentityCustomTypesIntKeyInMemoryTest.cs index 02fb9961576..44eb7687cbc 100644 --- a/test/EFCore.AspNet.InMemory.FunctionalTests/AspNetIdentityCustomTypesIntKeyInMemoryTest.cs +++ b/test/EFCore.AspNet.InMemory.FunctionalTests/AspNetIdentityCustomTypesIntKeyInMemoryTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore; -public class AspNetIdentityCustomTypesIntKeyInMemoryTest(AspNetIdentityCustomTypesIntKeyInMemoryTest.AspNetIdentityCustomTypesIntKeyInMemoryFixture fixture) +public class AspNetIdentityCustomTypesIntKeyInMemoryTest( + AspNetIdentityCustomTypesIntKeyInMemoryTest.AspNetIdentityCustomTypesIntKeyInMemoryFixture fixture) : AspNetIdentityCustomTypesIntKeyTestBase< AspNetIdentityCustomTypesIntKeyInMemoryTest.AspNetIdentityCustomTypesIntKeyInMemoryFixture>(fixture) { diff --git a/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesDefaultTestBase.cs b/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesDefaultTestBase.cs index 5aded433e13..b88e33d4923 100644 --- a/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesDefaultTestBase.cs +++ b/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesDefaultTestBase.cs @@ -330,9 +330,10 @@ protected override List ExpectedMappings ]; } -public class CustomTypesIdentityContext(DbContextOptions options) : IdentityDbContext(options) +public class CustomTypesIdentityContext(DbContextOptions options) + : IdentityDbContext(options) { protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -405,9 +406,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) public class CustomUserString : IdentityUser { public CustomUserString() - { - Id = Guid.NewGuid().ToString(); - } + => Id = Guid.NewGuid().ToString(); public string CustomTag { get; set; } @@ -422,9 +421,7 @@ public CustomUserString() public class CustomRoleString : IdentityRole { public CustomRoleString() - { - Id = Guid.NewGuid().ToString(); - } + => Id = Guid.NewGuid().ToString(); public virtual ICollection Users { get; set; } diff --git a/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesIntKeyTestBase.cs b/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesIntKeyTestBase.cs index 5a5a9decec6..408f8fb48c9 100644 --- a/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesIntKeyTestBase.cs +++ b/test/EFCore.AspNet.Specification.Tests/AspNetIdentityCustomTypesIntKeyTestBase.cs @@ -172,8 +172,9 @@ protected override List ExpectedMappings ]; } -public class CustomTypesIdentityContextInt(DbContextOptions options) : IdentityDbContext(options) +public class CustomTypesIdentityContextInt(DbContextOptions options) + : IdentityDbContext(options) { protected override void OnModelCreating(ModelBuilder modelBuilder) { diff --git a/test/EFCore.AspNet.Specification.Tests/ConfigurationDbContextTestBase.cs b/test/EFCore.AspNet.Specification.Tests/ConfigurationDbContextTestBase.cs index 3eca988aebe..84f0ad5164e 100644 --- a/test/EFCore.AspNet.Specification.Tests/ConfigurationDbContextTestBase.cs +++ b/test/EFCore.AspNet.Specification.Tests/ConfigurationDbContextTestBase.cs @@ -200,14 +200,14 @@ private static async Task SaveApiResources(ConfigurationDbContext context) Name = "ApiResource1", DisplayName = "ApiResource 1", Description = "ApiResource 1", - Scopes = [new() { Scope = "S1" }, new() { Scope = "S2" }] + Scopes = [new ApiResourceScope { Scope = "S1" }, new ApiResourceScope { Scope = "S2" }] }, new ApiResource { Name = "ApiResource2", DisplayName = "ApiResource 2", Description = "ApiResource 2", - Scopes = [new() { Scope = "S4" }, new() { Scope = "S5" }] + Scopes = [new ApiResourceScope { Scope = "S4" }, new ApiResourceScope { Scope = "S5" }] }, new ApiResource { diff --git a/test/EFCore.AspNet.Specification.Tests/GrpcTestBase.cs b/test/EFCore.AspNet.Specification.Tests/GrpcTestBase.cs index 77a659dee9b..5f1b444116a 100644 --- a/test/EFCore.AspNet.Specification.Tests/GrpcTestBase.cs +++ b/test/EFCore.AspNet.Specification.Tests/GrpcTestBase.cs @@ -12,9 +12,7 @@ public abstract class GrpcTestBase : IClassFixture where TFixture : GrpcTestBase.GrpcFixtureBase { protected GrpcTestBase(TFixture fixture) - { - Fixture = fixture; - } + => Fixture = fixture; protected TFixture Fixture { get; } diff --git a/test/EFCore.AspNet.SqlServer.FunctionalTests/AspNetIdentityCustomTypesDefaultSqlServerTest.cs b/test/EFCore.AspNet.SqlServer.FunctionalTests/AspNetIdentityCustomTypesDefaultSqlServerTest.cs index c71b019ff68..fbea36dcf4d 100644 --- a/test/EFCore.AspNet.SqlServer.FunctionalTests/AspNetIdentityCustomTypesDefaultSqlServerTest.cs +++ b/test/EFCore.AspNet.SqlServer.FunctionalTests/AspNetIdentityCustomTypesDefaultSqlServerTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore; -public class AspNetIdentityCustomTypesDefaultSqlServerTest(AspNetIdentityCustomTypesDefaultSqlServerTest.AspNetIdentityCustomTypesDefaultSqlServerFixture fixture) +public class AspNetIdentityCustomTypesDefaultSqlServerTest( + AspNetIdentityCustomTypesDefaultSqlServerTest.AspNetIdentityCustomTypesDefaultSqlServerFixture fixture) : AspNetIdentityCustomTypesDefaultTestBase< AspNetIdentityCustomTypesDefaultSqlServerTest.AspNetIdentityCustomTypesDefaultSqlServerFixture>(fixture) { diff --git a/test/EFCore.AspNet.SqlServer.FunctionalTests/AspNetIdentityCustomTypesIntKeySqlServerTest.cs b/test/EFCore.AspNet.SqlServer.FunctionalTests/AspNetIdentityCustomTypesIntKeySqlServerTest.cs index 6da42d6afbc..944edab6e11 100644 --- a/test/EFCore.AspNet.SqlServer.FunctionalTests/AspNetIdentityCustomTypesIntKeySqlServerTest.cs +++ b/test/EFCore.AspNet.SqlServer.FunctionalTests/AspNetIdentityCustomTypesIntKeySqlServerTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore; -public class AspNetIdentityCustomTypesIntKeySqlServerTest(AspNetIdentityCustomTypesIntKeySqlServerTest.AspNetIdentityCustomTypesIntKeySqlServerFixture fixture) +public class AspNetIdentityCustomTypesIntKeySqlServerTest( + AspNetIdentityCustomTypesIntKeySqlServerTest.AspNetIdentityCustomTypesIntKeySqlServerFixture fixture) : AspNetIdentityCustomTypesIntKeyTestBase< AspNetIdentityCustomTypesIntKeySqlServerTest.AspNetIdentityCustomTypesIntKeySqlServerFixture>(fixture) { diff --git a/test/EFCore.AspNet.SqlServer.FunctionalTests/AspNetIdentityIntKeySqlServerTest.cs b/test/EFCore.AspNet.SqlServer.FunctionalTests/AspNetIdentityIntKeySqlServerTest.cs index dd00c47d098..b2058476c4b 100644 --- a/test/EFCore.AspNet.SqlServer.FunctionalTests/AspNetIdentityIntKeySqlServerTest.cs +++ b/test/EFCore.AspNet.SqlServer.FunctionalTests/AspNetIdentityIntKeySqlServerTest.cs @@ -4,7 +4,7 @@ namespace Microsoft.EntityFrameworkCore; public class AspNetIdentityIntKeySqlServerTest(AspNetIdentityIntKeySqlServerTest.AspNetIdentityIntKeySqlServerFixture fixture) - : AspNetIdentityIntKeyTestBase(fixture) + : AspNetIdentityIntKeyTestBase(fixture) { public class AspNetIdentityIntKeySqlServerFixture : AspNetIdentityFixtureBase { diff --git a/test/EFCore.AspNet.SqlServer.FunctionalTests/GrpcSqlServerTest.cs b/test/EFCore.AspNet.SqlServer.FunctionalTests/GrpcSqlServerTest.cs index cfaa1c83bfe..bc385b737a6 100644 --- a/test/EFCore.AspNet.SqlServer.FunctionalTests/GrpcSqlServerTest.cs +++ b/test/EFCore.AspNet.SqlServer.FunctionalTests/GrpcSqlServerTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #if !EXCLUDE_ON_MAC -public class GrpcSqlServerTest(GrpcSqlServerTest.GrpcSqlServerFixture fixture) : GrpcTestBase(fixture) +public class GrpcSqlServerTest(GrpcSqlServerTest.GrpcSqlServerFixture fixture) + : GrpcTestBase(fixture) { public class GrpcSqlServerFixture : GrpcFixtureBase { diff --git a/test/EFCore.AspNet.Sqlite.FunctionalTests/AspNetIdentityCustomTypesDefaultSqliteTest.cs b/test/EFCore.AspNet.Sqlite.FunctionalTests/AspNetIdentityCustomTypesDefaultSqliteTest.cs index 44010191062..227a10d0e1f 100644 --- a/test/EFCore.AspNet.Sqlite.FunctionalTests/AspNetIdentityCustomTypesDefaultSqliteTest.cs +++ b/test/EFCore.AspNet.Sqlite.FunctionalTests/AspNetIdentityCustomTypesDefaultSqliteTest.cs @@ -3,8 +3,10 @@ namespace Microsoft.EntityFrameworkCore; -public class AspNetIdentityCustomTypesDefaultSqliteTest(AspNetIdentityCustomTypesDefaultSqliteTest.AspNetIdentityCustomTypesDefaultSqliteFixture fixture) - : AspNetIdentityCustomTypesDefaultTestBase(fixture) +public class AspNetIdentityCustomTypesDefaultSqliteTest( + AspNetIdentityCustomTypesDefaultSqliteTest.AspNetIdentityCustomTypesDefaultSqliteFixture fixture) + : AspNetIdentityCustomTypesDefaultTestBase( + fixture) { public class AspNetIdentityCustomTypesDefaultSqliteFixture : AspNetIdentityFixtureBase { diff --git a/test/EFCore.AspNet.Sqlite.FunctionalTests/AspNetIdentityCustomTypesIntKeySqliteTest.cs b/test/EFCore.AspNet.Sqlite.FunctionalTests/AspNetIdentityCustomTypesIntKeySqliteTest.cs index b1acef99e66..761322f6930 100644 --- a/test/EFCore.AspNet.Sqlite.FunctionalTests/AspNetIdentityCustomTypesIntKeySqliteTest.cs +++ b/test/EFCore.AspNet.Sqlite.FunctionalTests/AspNetIdentityCustomTypesIntKeySqliteTest.cs @@ -3,8 +3,10 @@ namespace Microsoft.EntityFrameworkCore; -public class AspNetIdentityCustomTypesIntKeySqliteTest(AspNetIdentityCustomTypesIntKeySqliteTest.AspNetIdentityCustomTypesIntKeySqliteFixture fixture) - : AspNetIdentityCustomTypesIntKeyTestBase(fixture) +public class AspNetIdentityCustomTypesIntKeySqliteTest( + AspNetIdentityCustomTypesIntKeySqliteTest.AspNetIdentityCustomTypesIntKeySqliteFixture fixture) + : AspNetIdentityCustomTypesIntKeyTestBase( + fixture) { public class AspNetIdentityCustomTypesIntKeySqliteFixture : AspNetIdentityFixtureBase { diff --git a/test/EFCore.Cosmos.FunctionalTests/ConcurrencyDetectorEnabledCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/ConcurrencyDetectorEnabledCosmosTest.cs index 03c35306ac1..d60d12e7e6f 100644 --- a/test/EFCore.Cosmos.FunctionalTests/ConcurrencyDetectorEnabledCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/ConcurrencyDetectorEnabledCosmosTest.cs @@ -5,8 +5,9 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class ConcurrencyDetectorEnabledCosmosTest(ConcurrencyDetectorEnabledCosmosTest.ConcurrencyDetectorCosmosFixture fixture) : ConcurrencyDetectorEnabledTestBase< - ConcurrencyDetectorEnabledCosmosTest.ConcurrencyDetectorCosmosFixture>(fixture) +public class ConcurrencyDetectorEnabledCosmosTest(ConcurrencyDetectorEnabledCosmosTest.ConcurrencyDetectorCosmosFixture fixture) + : ConcurrencyDetectorEnabledTestBase< + ConcurrencyDetectorEnabledCosmosTest.ConcurrencyDetectorCosmosFixture>(fixture) { [ConditionalTheory(Skip = "Issue #17246")] public override Task Any(bool async) diff --git a/test/EFCore.Cosmos.FunctionalTests/ConnectionSpecificationTest.cs b/test/EFCore.Cosmos.FunctionalTests/ConnectionSpecificationTest.cs index 538a02fd0c1..267ce8f173a 100644 --- a/test/EFCore.Cosmos.FunctionalTests/ConnectionSpecificationTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/ConnectionSpecificationTest.cs @@ -38,7 +38,8 @@ public async Task Throws_for_missing_connection_info() using var context = new NoConnectionContext(); var creator = context.GetService(); - Assert.Equal(CosmosStrings.ConnectionInfoMissing, + Assert.Equal( + CosmosStrings.ConnectionInfoMissing, (await Assert.ThrowsAsync(() => creator.EnsureDeletedAsync())).Message); } @@ -49,7 +50,6 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) .ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning)); } - public class Blog { public int Id { get; set; } diff --git a/test/EFCore.Cosmos.FunctionalTests/CosmosApiConsistencyTest.cs b/test/EFCore.Cosmos.FunctionalTests/CosmosApiConsistencyTest.cs index 09653b48a99..10586e1f24e 100644 --- a/test/EFCore.Cosmos.FunctionalTests/CosmosApiConsistencyTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/CosmosApiConsistencyTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class CosmosApiConsistencyTest(CosmosApiConsistencyTest.CosmosApiConsistencyFixture fixture) : ApiConsistencyTestBase(fixture) +public class CosmosApiConsistencyTest(CosmosApiConsistencyTest.CosmosApiConsistencyFixture fixture) + : ApiConsistencyTestBase(fixture) { protected override void AddServices(ServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkCosmos(); diff --git a/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs index fb72ce681cf..4e3a0c0869c 100644 --- a/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs @@ -11,9 +11,7 @@ public class CustomConvertersCosmosTest : CustomConvertersTestBase Fixture.TestSqlLoggerFactory.Clear(); [ConditionalTheory(Skip = "Issue #17246 No Explicit Convert")] public override Task Can_filter_projection_with_inline_enum_variable(bool async) diff --git a/test/EFCore.Cosmos.FunctionalTests/DefaultKeyValuesTest.cs b/test/EFCore.Cosmos.FunctionalTests/DefaultKeyValuesTest.cs index cafa4b3771b..5b07e8fd4d7 100644 --- a/test/EFCore.Cosmos.FunctionalTests/DefaultKeyValuesTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/DefaultKeyValuesTest.cs @@ -58,7 +58,13 @@ public async Task Composite_key_value_with_single_partition_key_must_have_key_se context.Add(new CompositeKeySinglePartitionKey { Id2 = Guid.NewGuid(), Id3 = true }); await AssertSaves(context); - context.Add(new CompositeKeySinglePartitionKey { Id1 = 1, Id2 = Guid.NewGuid(), Id3 = true }); + context.Add( + new CompositeKeySinglePartitionKey + { + Id1 = 1, + Id2 = Guid.NewGuid(), + Id3 = true + }); await AssertSaves(context); context.Add(new CompositeKeySinglePartitionKey { Id1 = 1, PartitionKey = 1 }); @@ -70,16 +76,41 @@ public async Task Composite_key_value_with_single_partition_key_must_have_key_se context.Add(new CompositeKeySinglePartitionKey { Id3 = true, PartitionKey = 1 }); await AssertSaves(context); - context.Add(new CompositeKeySinglePartitionKey { Id1 = 1, Id2 = Guid.NewGuid(), PartitionKey = 1 }); + context.Add( + new CompositeKeySinglePartitionKey + { + Id1 = 1, + Id2 = Guid.NewGuid(), + PartitionKey = 1 + }); await AssertSaves(context); - context.Add(new CompositeKeySinglePartitionKey { Id1 = 1, Id3 = true, PartitionKey = 1 }); + context.Add( + new CompositeKeySinglePartitionKey + { + Id1 = 1, + Id3 = true, + PartitionKey = 1 + }); await AssertSaves(context); - context.Add(new CompositeKeySinglePartitionKey { Id2 = Guid.NewGuid(), Id3 = true, PartitionKey = 1 }); + context.Add( + new CompositeKeySinglePartitionKey + { + Id2 = Guid.NewGuid(), + Id3 = true, + PartitionKey = 1 + }); await AssertSaves(context); - context.Add(new CompositeKeySinglePartitionKey { Id1 = 1, Id2 = Guid.NewGuid(), Id3 = true, PartitionKey = 1 }); + context.Add( + new CompositeKeySinglePartitionKey + { + Id1 = 1, + Id2 = Guid.NewGuid(), + Id3 = true, + PartitionKey = 1 + }); await AssertSaves(context); } @@ -100,16 +131,35 @@ public async Task Single_key_value_with_composite_partition_key_must_have_key_se context.Add(new SingleKeyCompositePartitionKey { PartitionKey3 = true }); await AssertKeyValueNotSet(context, nameof(SingleKeyCompositePartitionKey), nameof(SingleKeyCompositePartitionKey.Id)); - context.Add(new SingleKeyCompositePartitionKey { PartitionKey1 = 1, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true }); + context.Add( + new SingleKeyCompositePartitionKey + { + PartitionKey1 = 1, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertKeyValueNotSet(context, nameof(SingleKeyCompositePartitionKey), nameof(SingleKeyCompositePartitionKey.Id)); context.Add(new SingleKeyCompositePartitionKey { Id = 1 }); await AssertSaves(context); - context.Add(new SingleKeyCompositePartitionKey { Id = 1, PartitionKey1 = 1, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true }); + context.Add( + new SingleKeyCompositePartitionKey + { + Id = 1, + PartitionKey1 = 1, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); - context.Add(new SingleKeyCompositePartitionKey { Id = 1, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true }); + context.Add( + new SingleKeyCompositePartitionKey + { + Id = 1, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); context.Add(new SingleKeyCompositePartitionKey { Id = 1, PartitionKey2 = Guid.NewGuid() }); @@ -133,19 +183,35 @@ public async Task Composite_key_value_with_composite_partition_key_must_have_key context.Add(new CompositeKeyCompositePartitionKey { PartitionKey3 = true }); await AssertKeyValueNotSet(context, nameof(CompositeKeyCompositePartitionKey), nameof(CompositeKeyCompositePartitionKey.Id3)); - context.Add(new CompositeKeyCompositePartitionKey { PartitionKey1 = 1, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true }); + context.Add( + new CompositeKeyCompositePartitionKey + { + PartitionKey1 = 1, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertKeyValueNotSet(context, nameof(CompositeKeyCompositePartitionKey), nameof(CompositeKeyCompositePartitionKey.Id3)); context.Add(new CompositeKeyCompositePartitionKey { Id1 = 1 }); await AssertSaves(context); - context.Add(new CompositeKeyCompositePartitionKey - { - Id1 = 1, PartitionKey1 = 1, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true - }); + context.Add( + new CompositeKeyCompositePartitionKey + { + Id1 = 1, + PartitionKey1 = 1, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); - context.Add(new CompositeKeyCompositePartitionKey { Id1 = 1, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true }); + context.Add( + new CompositeKeyCompositePartitionKey + { + Id1 = 1, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); context.Add(new CompositeKeyCompositePartitionKey { Id1 = 1, PartitionKey2 = Guid.NewGuid() }); @@ -154,13 +220,23 @@ public async Task Composite_key_value_with_composite_partition_key_must_have_key context.Add(new CompositeKeyCompositePartitionKey { Id2 = Guid.NewGuid() }); await AssertSaves(context); - context.Add(new CompositeKeyCompositePartitionKey - { - Id2 = Guid.NewGuid(), PartitionKey1 = 1, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true - }); + context.Add( + new CompositeKeyCompositePartitionKey + { + Id2 = Guid.NewGuid(), + PartitionKey1 = 1, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); - context.Add(new CompositeKeyCompositePartitionKey { Id2 = Guid.NewGuid(), PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true }); + context.Add( + new CompositeKeyCompositePartitionKey + { + Id2 = Guid.NewGuid(), + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); context.Add(new CompositeKeyCompositePartitionKey { Id2 = Guid.NewGuid(), PartitionKey2 = Guid.NewGuid() }); @@ -169,13 +245,23 @@ public async Task Composite_key_value_with_composite_partition_key_must_have_key context.Add(new CompositeKeyCompositePartitionKey { Id3 = true }); await AssertSaves(context); - context.Add(new CompositeKeyCompositePartitionKey - { - Id3 = true, PartitionKey1 = 1, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true - }); + context.Add( + new CompositeKeyCompositePartitionKey + { + Id3 = true, + PartitionKey1 = 1, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); - context.Add(new CompositeKeyCompositePartitionKey { Id3 = true, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true }); + context.Add( + new CompositeKeyCompositePartitionKey + { + Id3 = true, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); context.Add(new CompositeKeyCompositePartitionKey { Id3 = true, PartitionKey2 = Guid.NewGuid() }); @@ -211,7 +297,13 @@ public async Task Composite_same_key_and_partition_key_must_have_key_set() context.Add(new CompositeSameKeyAndPartitionKey { Key3 = true }); await AssertSaves(context); - context.Add(new CompositeSameKeyAndPartitionKey { Key1 = 1, Key2 = Guid.NewGuid(), Key3 = true }); + context.Add( + new CompositeSameKeyAndPartitionKey + { + Key1 = 1, + Key2 = Guid.NewGuid(), + Key3 = true + }); await AssertSaves(context); } @@ -262,7 +354,13 @@ public async Task Composite_key_value_with_single_partition_key_can_use_generate context.Add(new CompositeGeneratedKeySinglePartitionKey { Id2 = Guid.NewGuid(), Id3 = true }); await AssertSaves(context); - context.Add(new CompositeGeneratedKeySinglePartitionKey { Id1 = 1, Id2 = Guid.NewGuid(), Id3 = true }); + context.Add( + new CompositeGeneratedKeySinglePartitionKey + { + Id1 = 1, + Id2 = Guid.NewGuid(), + Id3 = true + }); await AssertSaves(context); context.Add(new CompositeGeneratedKeySinglePartitionKey { Id1 = 1, PartitionKey = 1 }); @@ -274,16 +372,41 @@ public async Task Composite_key_value_with_single_partition_key_can_use_generate context.Add(new CompositeGeneratedKeySinglePartitionKey { Id3 = true, PartitionKey = 1 }); await AssertSaves(context); - context.Add(new CompositeGeneratedKeySinglePartitionKey { Id1 = 1, Id2 = Guid.NewGuid(), PartitionKey = 1 }); + context.Add( + new CompositeGeneratedKeySinglePartitionKey + { + Id1 = 1, + Id2 = Guid.NewGuid(), + PartitionKey = 1 + }); await AssertSaves(context); - context.Add(new CompositeGeneratedKeySinglePartitionKey { Id1 = 1, Id3 = true, PartitionKey = 1 }); + context.Add( + new CompositeGeneratedKeySinglePartitionKey + { + Id1 = 1, + Id3 = true, + PartitionKey = 1 + }); await AssertSaves(context); - context.Add(new CompositeGeneratedKeySinglePartitionKey { Id2 = Guid.NewGuid(), Id3 = true, PartitionKey = 1 }); + context.Add( + new CompositeGeneratedKeySinglePartitionKey + { + Id2 = Guid.NewGuid(), + Id3 = true, + PartitionKey = 1 + }); await AssertSaves(context); - context.Add(new CompositeGeneratedKeySinglePartitionKey { Id1 = 1, Id2 = Guid.NewGuid(), Id3 = true, PartitionKey = 1 }); + context.Add( + new CompositeGeneratedKeySinglePartitionKey + { + Id1 = 1, + Id2 = Guid.NewGuid(), + Id3 = true, + PartitionKey = 1 + }); await AssertSaves(context); } @@ -304,16 +427,35 @@ public async Task Single_key_value_with_composite_partition_key_can_use_generate context.Add(new SingleGeneratedKeyCompositePartitionKey { PartitionKey3 = true }); await AssertSaves(context); - context.Add(new SingleGeneratedKeyCompositePartitionKey { PartitionKey1 = 1, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true }); + context.Add( + new SingleGeneratedKeyCompositePartitionKey + { + PartitionKey1 = 1, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); context.Add(new SingleGeneratedKeyCompositePartitionKey { Id = Guid.NewGuid() }); await AssertSaves(context); - context.Add(new SingleGeneratedKeyCompositePartitionKey { Id = Guid.NewGuid(), PartitionKey1 = 1, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true }); + context.Add( + new SingleGeneratedKeyCompositePartitionKey + { + Id = Guid.NewGuid(), + PartitionKey1 = 1, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); - context.Add(new SingleGeneratedKeyCompositePartitionKey { Id = Guid.NewGuid(), PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true }); + context.Add( + new SingleGeneratedKeyCompositePartitionKey + { + Id = Guid.NewGuid(), + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); context.Add(new SingleGeneratedKeyCompositePartitionKey { Id = Guid.NewGuid(), PartitionKey2 = Guid.NewGuid() }); @@ -337,19 +479,35 @@ public async Task Composite_key_value_with_composite_partition_key_can_use_gener context.Add(new CompositeGeneratedKeyCompositePartitionKey { PartitionKey3 = true }); await AssertSaves(context); - context.Add(new CompositeGeneratedKeyCompositePartitionKey { PartitionKey1 = 1, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true }); + context.Add( + new CompositeGeneratedKeyCompositePartitionKey + { + PartitionKey1 = 1, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); context.Add(new CompositeGeneratedKeyCompositePartitionKey { Id1 = 1 }); await AssertSaves(context); - context.Add(new CompositeGeneratedKeyCompositePartitionKey - { - Id1 = 1, PartitionKey1 = 1, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true - }); + context.Add( + new CompositeGeneratedKeyCompositePartitionKey + { + Id1 = 1, + PartitionKey1 = 1, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); - context.Add(new CompositeGeneratedKeyCompositePartitionKey { Id1 = 1, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true }); + context.Add( + new CompositeGeneratedKeyCompositePartitionKey + { + Id1 = 1, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); context.Add(new CompositeGeneratedKeyCompositePartitionKey { Id1 = 1, PartitionKey2 = Guid.NewGuid() }); @@ -358,13 +516,23 @@ public async Task Composite_key_value_with_composite_partition_key_can_use_gener context.Add(new CompositeGeneratedKeyCompositePartitionKey { Id2 = Guid.NewGuid() }); await AssertSaves(context); - context.Add(new CompositeGeneratedKeyCompositePartitionKey - { - Id2 = Guid.NewGuid(), PartitionKey1 = 1, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true - }); + context.Add( + new CompositeGeneratedKeyCompositePartitionKey + { + Id2 = Guid.NewGuid(), + PartitionKey1 = 1, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); - context.Add(new CompositeGeneratedKeyCompositePartitionKey { Id2 = Guid.NewGuid(), PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true }); + context.Add( + new CompositeGeneratedKeyCompositePartitionKey + { + Id2 = Guid.NewGuid(), + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); context.Add(new CompositeGeneratedKeyCompositePartitionKey { Id2 = Guid.NewGuid(), PartitionKey2 = Guid.NewGuid() }); @@ -373,13 +541,23 @@ public async Task Composite_key_value_with_composite_partition_key_can_use_gener context.Add(new CompositeGeneratedKeyCompositePartitionKey { Id3 = true }); await AssertSaves(context); - context.Add(new CompositeGeneratedKeyCompositePartitionKey - { - Id3 = true, PartitionKey1 = 1, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true - }); + context.Add( + new CompositeGeneratedKeyCompositePartitionKey + { + Id3 = true, + PartitionKey1 = 1, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); - context.Add(new CompositeGeneratedKeyCompositePartitionKey { Id3 = true, PartitionKey2 = Guid.NewGuid(), PartitionKey3 = true }); + context.Add( + new CompositeGeneratedKeyCompositePartitionKey + { + Id3 = true, + PartitionKey2 = Guid.NewGuid(), + PartitionKey3 = true + }); await AssertSaves(context); context.Add(new CompositeGeneratedKeyCompositePartitionKey { Id3 = true, PartitionKey2 = Guid.NewGuid() }); @@ -415,7 +593,13 @@ public async Task Composite_same_key_and_partition_key_can_use_generated_value() context.Add(new CompositeSameGeneratedKeyAndPartitionKey { Key3 = true }); await AssertSaves(context); - context.Add(new CompositeSameGeneratedKeyAndPartitionKey { Key1 = 1, Key2 = Guid.NewGuid(), Key3 = true }); + context.Add( + new CompositeSameGeneratedKeyAndPartitionKey + { + Key1 = 1, + Key2 = Guid.NewGuid(), + Key3 = true + }); await AssertSaves(context); } @@ -431,7 +615,9 @@ private static async Task AssertSaves(DefaultKeyValuesTestContext context) } private static async Task AssertKeyValueNotSet( - DefaultKeyValuesTestContext context, string entityTypeName, string propertyName) + DefaultKeyValuesTestContext context, + string entityTypeName, + string propertyName) { Assert.Equal( CoreStrings.WarningAsErrorTemplate( @@ -466,95 +652,201 @@ public class DefaultKeyValuesTestContext(DbContextOptions dbContextOptions) : Db { protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.Entity(b => - { - b.ToContainer(b.Metadata.ClrType.Name); - b.HasPartitionKey(e => e.PartitionKey); - b.HasKey(e => new { e.Id, e.PartitionKey }); - }); - - modelBuilder.Entity(b => - { - b.ToContainer(b.Metadata.ClrType.Name); - b.HasPartitionKey(e => e.PartitionKey); - b.HasKey(e => new { e.Id1, e.Id2, e.Id3, e.PartitionKey }); - }); - - modelBuilder.Entity(b => - { - b.ToContainer(b.Metadata.ClrType.Name); - b.HasPartitionKey(e => new { e.PartitionKey1, e.PartitionKey2, e.PartitionKey3 }); - b.HasKey(e => new { e.Id, e.PartitionKey1, e.PartitionKey2, e.PartitionKey3 }); - }); - - modelBuilder.Entity(b => - { - b.ToContainer(b.Metadata.ClrType.Name); - b.HasPartitionKey(e => new { e.PartitionKey1, e.PartitionKey2, e.PartitionKey3 }); - b.HasKey(e => new { e.Id1, e.Id2, e.Id3, e.PartitionKey1, e.PartitionKey2, e.PartitionKey3 }); - }); - - modelBuilder.Entity(b => - { - b.ToContainer(b.Metadata.ClrType.Name); - b.HasPartitionKey(e => e.Id); - b.HasKey(e => e.Id); - }); - - modelBuilder.Entity(b => - { - b.ToContainer(b.Metadata.ClrType.Name); - b.HasPartitionKey(e => new { e.Key1, e.Key2, e.Key3 }); - b.HasKey(e => new { e.Key1, e.Key2, e.Key3 }); - }); - - modelBuilder.Entity(b => - { - b.ToContainer(b.Metadata.ClrType.Name); - b.HasPartitionKey(e => e.PartitionKey); - b.HasKey(e => new { e.Id, e.PartitionKey }); - b.Property(e => e.Id).ValueGeneratedOnAdd(); - }); - - modelBuilder.Entity(b => - { - b.ToContainer(b.Metadata.ClrType.Name); - b.HasPartitionKey(e => e.PartitionKey); - b.HasKey(e => new { e.Id1, e.Id2, e.Id3, e.PartitionKey }); - b.Property(e => e.Id2).ValueGeneratedOnAdd(); - }); - - modelBuilder.Entity(b => - { - b.ToContainer(b.Metadata.ClrType.Name); - b.HasPartitionKey(e => new { e.PartitionKey1, e.PartitionKey2, e.PartitionKey3 }); - b.HasKey(e => new { e.Id, e.PartitionKey1, e.PartitionKey2, e.PartitionKey3 }); - b.Property(e => e.Id).ValueGeneratedOnAdd(); - }); - - modelBuilder.Entity(b => - { - b.ToContainer(b.Metadata.ClrType.Name); - b.HasPartitionKey(e => new { e.PartitionKey1, e.PartitionKey2, e.PartitionKey3 }); - b.HasKey(e => new { e.Id1, e.Id2, e.Id3, e.PartitionKey1, e.PartitionKey2, e.PartitionKey3 }); - b.Property(e => e.Id2).ValueGeneratedOnAdd(); - }); - - modelBuilder.Entity(b => - { - b.ToContainer(b.Metadata.ClrType.Name); - b.HasPartitionKey(e => e.Id); - b.HasKey(e => e.Id); - b.Property(e => e.Id).ValueGeneratedOnAdd(); - }); - - modelBuilder.Entity(b => - { - b.ToContainer(b.Metadata.ClrType.Name); - b.HasPartitionKey(e => new { e.Key1, e.Key2, e.Key3 }); - b.HasKey(e => new { e.Key1, e.Key2, e.Key3 }); - b.Property(e => e.Key2).ValueGeneratedOnAdd(); - }); + modelBuilder.Entity( + b => + { + b.ToContainer(b.Metadata.ClrType.Name); + b.HasPartitionKey(e => e.PartitionKey); + b.HasKey(e => new { e.Id, e.PartitionKey }); + }); + + modelBuilder.Entity( + b => + { + b.ToContainer(b.Metadata.ClrType.Name); + b.HasPartitionKey(e => e.PartitionKey); + b.HasKey( + e => new + { + e.Id1, + e.Id2, + e.Id3, + e.PartitionKey + }); + }); + + modelBuilder.Entity( + b => + { + b.ToContainer(b.Metadata.ClrType.Name); + b.HasPartitionKey( + e => new + { + e.PartitionKey1, + e.PartitionKey2, + e.PartitionKey3 + }); + b.HasKey( + e => new + { + e.Id, + e.PartitionKey1, + e.PartitionKey2, + e.PartitionKey3 + }); + }); + + modelBuilder.Entity( + b => + { + b.ToContainer(b.Metadata.ClrType.Name); + b.HasPartitionKey( + e => new + { + e.PartitionKey1, + e.PartitionKey2, + e.PartitionKey3 + }); + b.HasKey( + e => new + { + e.Id1, + e.Id2, + e.Id3, + e.PartitionKey1, + e.PartitionKey2, + e.PartitionKey3 + }); + }); + + modelBuilder.Entity( + b => + { + b.ToContainer(b.Metadata.ClrType.Name); + b.HasPartitionKey(e => e.Id); + b.HasKey(e => e.Id); + }); + + modelBuilder.Entity( + b => + { + b.ToContainer(b.Metadata.ClrType.Name); + b.HasPartitionKey( + e => new + { + e.Key1, + e.Key2, + e.Key3 + }); + b.HasKey( + e => new + { + e.Key1, + e.Key2, + e.Key3 + }); + }); + + modelBuilder.Entity( + b => + { + b.ToContainer(b.Metadata.ClrType.Name); + b.HasPartitionKey(e => e.PartitionKey); + b.HasKey(e => new { e.Id, e.PartitionKey }); + b.Property(e => e.Id).ValueGeneratedOnAdd(); + }); + + modelBuilder.Entity( + b => + { + b.ToContainer(b.Metadata.ClrType.Name); + b.HasPartitionKey(e => e.PartitionKey); + b.HasKey( + e => new + { + e.Id1, + e.Id2, + e.Id3, + e.PartitionKey + }); + b.Property(e => e.Id2).ValueGeneratedOnAdd(); + }); + + modelBuilder.Entity( + b => + { + b.ToContainer(b.Metadata.ClrType.Name); + b.HasPartitionKey( + e => new + { + e.PartitionKey1, + e.PartitionKey2, + e.PartitionKey3 + }); + b.HasKey( + e => new + { + e.Id, + e.PartitionKey1, + e.PartitionKey2, + e.PartitionKey3 + }); + b.Property(e => e.Id).ValueGeneratedOnAdd(); + }); + + modelBuilder.Entity( + b => + { + b.ToContainer(b.Metadata.ClrType.Name); + b.HasPartitionKey( + e => new + { + e.PartitionKey1, + e.PartitionKey2, + e.PartitionKey3 + }); + b.HasKey( + e => new + { + e.Id1, + e.Id2, + e.Id3, + e.PartitionKey1, + e.PartitionKey2, + e.PartitionKey3 + }); + b.Property(e => e.Id2).ValueGeneratedOnAdd(); + }); + + modelBuilder.Entity( + b => + { + b.ToContainer(b.Metadata.ClrType.Name); + b.HasPartitionKey(e => e.Id); + b.HasKey(e => e.Id); + b.Property(e => e.Id).ValueGeneratedOnAdd(); + }); + + modelBuilder.Entity( + b => + { + b.ToContainer(b.Metadata.ClrType.Name); + b.HasPartitionKey( + e => new + { + e.Key1, + e.Key2, + e.Key3 + }); + b.HasKey( + e => new + { + e.Key1, + e.Key2, + e.Key3 + }); + b.Property(e => e.Key2).ValueGeneratedOnAdd(); + }); } } diff --git a/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs index 19768aa764f..4c08c77bc07 100644 --- a/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs @@ -933,8 +933,7 @@ await Can_add_update_delete_with_collection( await Can_add_update_delete_with_collection>>( new Dictionary> { - { "2" , new Dictionary { { "value", 2 } } }, - { "1" , new Dictionary { { "value", 1 } } } + { "2", new Dictionary { { "value", 2 } } }, { "1", new Dictionary { { "value", 1 } } } }, c => { @@ -1525,8 +1524,21 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.Entity( cb => { - cb.HasPartitionKey(c => new { c.PartitionKey1, c.PartitionKey2, c.PartitionKey3 }); - cb.HasKey(c => new { c.Id, c.PartitionKey1, c.PartitionKey2, c.PartitionKey3 }); + cb.HasPartitionKey( + c => new + { + c.PartitionKey1, + c.PartitionKey2, + c.PartitionKey3 + }); + cb.HasKey( + c => new + { + c.Id, + c.PartitionKey1, + c.PartitionKey2, + c.PartitionKey3 + }); }); } @@ -1613,7 +1625,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.Entity( cb => { - cb.HasPartitionKey(c => new { c.PartitionKey1, c.PartitionKey2 } ); + cb.HasPartitionKey(c => new { c.PartitionKey1, c.PartitionKey2 }); cb.Property(c => c.id).HasConversion(); cb.HasKey(c => new { c.id }); }); @@ -1625,8 +1637,14 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.Entity( cb => { - cb.HasPartitionKey(c => new { c.PartitionKey1, c.PartitionKey2 } ); - cb.HasKey(c => new { c.PartitionKey1, c.PartitionKey2, c.id }); + cb.HasPartitionKey(c => new { c.PartitionKey1, c.PartitionKey2 }); + cb.HasKey( + c => new + { + c.PartitionKey1, + c.PartitionKey2, + c.id + }); }); } diff --git a/test/EFCore.Cosmos.FunctionalTests/FindCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/FindCosmosTest.cs index 20b4510389e..c83b8e9ed43 100644 --- a/test/EFCore.Cosmos.FunctionalTests/FindCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/FindCosmosTest.cs @@ -9,9 +9,7 @@ public abstract class FindCosmosTest : FindTestBase fixture.TestSqlLoggerFactory.Clear(); [ConditionalFact(Skip = "#25886")] public override void Find_base_type_using_derived_set_tracked() { } @@ -72,7 +70,7 @@ public override void Find_shadow_key_from_store() public override void Returns_null_for_shadow_key_not_in_store() => CosmosTestHelpers.Instance.NoSyncTest(() => base.Returns_null_for_shadow_key_not_in_store()); - public override void Find_int_key_tracked() + public override void Find_int_key_tracked() { base.Find_int_key_tracked(); diff --git a/test/EFCore.Cosmos.FunctionalTests/HierarchicalPartitionKeyTest.cs b/test/EFCore.Cosmos.FunctionalTests/HierarchicalPartitionKeyTest.cs index 09e0df1b715..d3e2157c475 100644 --- a/test/EFCore.Cosmos.FunctionalTests/HierarchicalPartitionKeyTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/HierarchicalPartitionKeyTest.cs @@ -275,8 +275,21 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.Entity( cb => { - cb.HasPartitionKey(c => new { c.PartitionKey1, c.PartitionKey2, c.PartitionKey3 }); - cb.HasKey(c => new { c.Id, c.PartitionKey1, c.PartitionKey2, c.PartitionKey3 }); + cb.HasPartitionKey( + c => new + { + c.PartitionKey1, + c.PartitionKey2, + c.PartitionKey3 + }); + cb.HasKey( + c => new + { + c.Id, + c.PartitionKey1, + c.PartitionKey2, + c.PartitionKey3 + }); }); } diff --git a/test/EFCore.Cosmos.FunctionalTests/JsonTypesCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/JsonTypesCosmosTest.cs index 13af27e4217..49754ed19a5 100644 --- a/test/EFCore.Cosmos.FunctionalTests/JsonTypesCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/JsonTypesCosmosTest.cs @@ -45,7 +45,8 @@ public override Task Can_read_write_list_of_array_of_GUID_JSON_values(string exp public override Task Can_read_write_list_of_array_of_list_of_array_of_binary_JSON_values(string expected) // Cosmos provider cannot map collections of elements with converters. See Issue #34026. - => Assert.ThrowsAsync(() => base.Can_read_write_list_of_array_of_list_of_array_of_binary_JSON_values(expected)); + => Assert.ThrowsAsync( + () => base.Can_read_write_list_of_array_of_list_of_array_of_binary_JSON_values(expected)); public override Task Can_read_write_list_of_array_of_nullable_GUID_JSON_values(string expected) // Cosmos provider cannot map collections of elements with converters. See Issue #34026. diff --git a/test/EFCore.Cosmos.FunctionalTests/KeysWithConvertersCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/KeysWithConvertersCosmosTest.cs index 41c88fe1f4b..7426f08e237 100644 --- a/test/EFCore.Cosmos.FunctionalTests/KeysWithConvertersCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/KeysWithConvertersCosmosTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class KeysWithConvertersCosmosTest(KeysWithConvertersCosmosTest.KeysWithConvertersCosmosFixture fixture) : KeysWithConvertersTestBase(fixture) +public class KeysWithConvertersCosmosTest(KeysWithConvertersCosmosTest.KeysWithConvertersCosmosFixture fixture) + : KeysWithConvertersTestBase(fixture) { public class KeysWithConvertersCosmosFixture : KeysWithConvertersFixtureBase { diff --git a/test/EFCore.Cosmos.FunctionalTests/ModelBuilding/CosmosModelBuilderGenericTest.cs b/test/EFCore.Cosmos.FunctionalTests/ModelBuilding/CosmosModelBuilderGenericTest.cs index 94011d3df9e..9f8bb60182c 100644 --- a/test/EFCore.Cosmos.FunctionalTests/ModelBuilding/CosmosModelBuilderGenericTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/ModelBuilding/CosmosModelBuilderGenericTest.cs @@ -10,7 +10,8 @@ namespace Microsoft.EntityFrameworkCore.ModelBuilding; public class CosmosModelBuilderGenericTest : ModelBuilderTest { - public class CosmosGenericNonRelationship(CosmosModelBuilderFixture fixture) : NonRelationshipTestBase(fixture), IClassFixture + public class CosmosGenericNonRelationship(CosmosModelBuilderFixture fixture) + : NonRelationshipTestBase(fixture), IClassFixture { // Cosmos provider cannot map collections of elements with converters. See Issue #34026. public override void Element_types_can_have_custom_type_value_converter_type_set() @@ -177,7 +178,13 @@ public virtual void Three_level_hierarchical_partition_key_is_added_to_the_keys( modelBuilder.Entity() .Ignore(b => b.Details) .Ignore(b => b.Orders) - .HasPartitionKey(b => new { b.Title, b.Name, b.AlternateKey }) + .HasPartitionKey( + b => new + { + b.Title, + b.Name, + b.AlternateKey + }) .Property(b => b.AlternateKey).HasConversion(); var model = modelBuilder.FinalizeModel(); @@ -470,12 +477,7 @@ public virtual void Hierarchical_partition_key_is_added_to_the_alternate_key_if_ entity.GetPartitionKeyProperties().Select(p => p.Name)); Assert.Equal( - new[] - { - nameof(Customer.Title), - nameof(Customer.AlternateKey), - CosmosJsonIdConvention.DefaultIdPropertyName - }, + new[] { nameof(Customer.Title), nameof(Customer.AlternateKey), CosmosJsonIdConvention.DefaultIdPropertyName }, entity.FindPrimaryKey()!.Properties.Select(p => p.Name)); } @@ -506,11 +508,23 @@ public virtual void No_alternate_key_is_created_if_id_is_hierarchical_partition_ { var modelBuilder = CreateModelBuilder(); - modelBuilder.Entity().HasKey(e => new { e.Name, e.AlternateKey, e.Title }); + modelBuilder.Entity().HasKey( + e => new + { + e.Name, + e.AlternateKey, + e.Title + }); modelBuilder.Entity() .Ignore(b => b.Details) .Ignore(b => b.Orders) - .HasPartitionKey(b => new { b.Name, b.AlternateKey, b.Title }) + .HasPartitionKey( + b => new + { + b.Name, + b.AlternateKey, + b.Title + }) .Property(b => b.AlternateKey).HasConversion().ToJsonProperty("id"); var model = modelBuilder.FinalizeModel(); @@ -527,7 +541,8 @@ protected override TestModelBuilder CreateModelBuilder(Action new GenericTestModelBuilder(Fixture, configure); } - public class CosmosGenericComplexType(CosmosModelBuilderFixture fixture) : ComplexTypeTestBase(fixture), IClassFixture + public class CosmosGenericComplexType(CosmosModelBuilderFixture fixture) + : ComplexTypeTestBase(fixture), IClassFixture { public override void Properties_can_have_custom_type_value_converter_type_set() => Properties_can_have_custom_type_value_converter_type_set(); @@ -573,7 +588,8 @@ protected override TestModelBuilder CreateModelBuilder(Action new GenericTestModelBuilder(Fixture, configure); } - public class CosmosGenericInheritance(CosmosModelBuilderFixture fixture) : InheritanceTestBase(fixture), IClassFixture + public class CosmosGenericInheritance(CosmosModelBuilderFixture fixture) + : InheritanceTestBase(fixture), IClassFixture { public override void Base_type_can_be_discovered_after_creating_foreign_keys_on_derived() { @@ -602,7 +618,8 @@ protected override TestModelBuilder CreateModelBuilder(Action new GenericTestModelBuilder(Fixture, configure); } - public class CosmosGenericOneToMany(CosmosModelBuilderFixture fixture) : OneToManyTestBase(fixture), IClassFixture + public class CosmosGenericOneToMany(CosmosModelBuilderFixture fixture) + : OneToManyTestBase(fixture), IClassFixture { public override void Creates_overlapping_foreign_keys_with_different_nullability() => Assert.Equal( @@ -631,13 +648,15 @@ protected override TestModelBuilder CreateModelBuilder(Action new GenericTestModelBuilder(Fixture, configure); } - public class CosmosGenericManyToOne(CosmosModelBuilderFixture fixture) : ManyToOneTestBase(fixture), IClassFixture + public class CosmosGenericManyToOne(CosmosModelBuilderFixture fixture) + : ManyToOneTestBase(fixture), IClassFixture { protected override TestModelBuilder CreateModelBuilder(Action? configure = null) => new GenericTestModelBuilder(Fixture, configure); } - public class CosmosGenericOneToOne(CosmosModelBuilderFixture fixture) : OneToOneTestBase(fixture), IClassFixture + public class CosmosGenericOneToOne(CosmosModelBuilderFixture fixture) + : OneToOneTestBase(fixture), IClassFixture { public override void Navigation_to_shared_type_is_not_discovered_by_convention() { @@ -660,7 +679,8 @@ protected override TestModelBuilder CreateModelBuilder(Action new GenericTestModelBuilder(Fixture, configure); } - public class CosmosGenericManyToMany(CosmosModelBuilderFixture fixture) : ManyToManyTestBase(fixture), IClassFixture + public class CosmosGenericManyToMany(CosmosModelBuilderFixture fixture) + : ManyToManyTestBase(fixture), IClassFixture { [ConditionalFact] public virtual void Can_use_shared_type_as_join_entity_with_partition_keys() @@ -705,7 +725,8 @@ public virtual void Can_use_shared_type_as_join_entity_with_partition_keys() var joinType = model.FindEntityType("JoinType")!; Assert.NotNull(joinType); - Assert.Collection(joinType.GetForeignKeys(), + Assert.Collection( + joinType.GetForeignKeys(), fk => Assert.Equal("Foo", fk["Right"]), fk => Assert.Equal("Bar", fk["Left"])); Assert.Equal(3, joinType.FindPrimaryKey()!.Properties.Count); @@ -759,14 +780,16 @@ public virtual void Can_use_shared_type_as_join_entity_with_hierarchical_partiti .UsingEntity>( "JoinType", e => e.HasOne().WithMany().HasForeignKey("DependentId", "PartitionId1", "PartitionId2", "PartitionId3"), - e => e.HasOne().WithMany().HasForeignKey("PrincipalId", "PartitionId1", "PartitionId2", "PartitionId3"), + e => e.HasOne().WithMany().HasForeignKey( + "PrincipalId", "PartitionId1", "PartitionId2", "PartitionId3"), e => e.HasPartitionKey("PartitionId1", "PartitionId2", "PartitionId3")); var model = modelBuilder.FinalizeModel(); var joinType = model.FindEntityType("JoinType")!; Assert.NotNull(joinType); - Assert.Collection(joinType.GetForeignKeys(), + Assert.Collection( + joinType.GetForeignKeys(), fk => Assert.Equal("Foo", fk["Right"]), fk => Assert.Equal("Bar", fk["Left"])); @@ -944,7 +967,8 @@ protected override TestModelBuilder CreateModelBuilder(Action new GenericTestModelBuilder(Fixture, configure); } - public class CosmosGenericOwnedTypes(CosmosModelBuilderFixture fixture) : OwnedTypesTestBase(fixture), IClassFixture + public class CosmosGenericOwnedTypes(CosmosModelBuilderFixture fixture) + : OwnedTypesTestBase(fixture), IClassFixture { public override void Deriving_from_owned_type_throws() // On Cosmos the base type starts as owned @@ -990,7 +1014,8 @@ public override void Can_configure_owned_type_collection_using_nested_closure() public override void Can_configure_chained_ownerships() => Assert.Equal( - CosmosStrings.IndexesExist("Book.Label#BookLabel.AnotherBookLabel#AnotherBookLabel.SpecialBookLabel#SpecialBookLabel", "BookId"), + CosmosStrings.IndexesExist( + "Book.Label#BookLabel.AnotherBookLabel#AnotherBookLabel.SpecialBookLabel#SpecialBookLabel", "BookId"), Assert.Throws( base.Can_configure_chained_ownerships).Message); @@ -1035,7 +1060,9 @@ protected override TestModelBuilder CreateModelBuilder(Action CosmosTestHelpers.Instance; + public override TestHelpers TestHelpers + => CosmosTestHelpers.Instance; + public override bool ForeignKeysHaveIndexes => false; } diff --git a/test/EFCore.Cosmos.FunctionalTests/OverzealousInitializationCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/OverzealousInitializationCosmosTest.cs index f0b85ef9408..34f5af870aa 100644 --- a/test/EFCore.Cosmos.FunctionalTests/OverzealousInitializationCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/OverzealousInitializationCosmosTest.cs @@ -16,8 +16,9 @@ public override void Fixup_ignores_eagerly_initialized_reference_navs() public class OverzealousInitializationCosmosFixture : OverzealousInitializationFixtureBase { public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) - => base.AddOptions(builder.ConfigureWarnings( - w => w.Ignore(CosmosEventId.NoPartitionKeyDefined))); + => base.AddOptions( + builder.ConfigureWarnings( + w => w.Ignore(CosmosEventId.NoPartitionKeyDefined))); protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/FromSqlQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/FromSqlQueryCosmosTest.cs index dc052ecc5a2..a6b932b8814 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/FromSqlQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/FromSqlQueryCosmosTest.cs @@ -51,7 +51,8 @@ SELECT VALUE s public async Task FromSqlRaw_queryable_incorrect_discriminator_throws() { using var context = CreateContext(); - var query = context.Set().FromSqlRaw(""" + var query = context.Set().FromSqlRaw( + """ SELECT * FROM root c WHERE c["$type"] = "OrderDetail" """); @@ -125,7 +126,8 @@ public Task FromSqlRaw_queryable_composed(bool async) async, async a => { using var context = CreateContext(); - var query = context.Set().FromSqlRaw(""" + var query = context.Set().FromSqlRaw( + """ SELECT * FROM root c WHERE c["$type"] = "Customer" """) .Where(c => c.ContactName.Contains("z")); @@ -193,9 +195,10 @@ public Task FromSqlRaw_queryable_composed_compiled(bool async) { var query = EF.CompileAsyncQuery( (NorthwindContext context) => context.Set() - .FromSqlRaw(""" - SELECT * FROM root c WHERE c["$type"] = "Customer" - """) + .FromSqlRaw( + """ +SELECT * FROM root c WHERE c["$type"] = "Customer" +""") .Where(c => c.ContactName.Contains("z"))); using (var context = CreateContext()) @@ -581,9 +584,10 @@ public virtual Task FromSqlRaw_queryable_simple_as_no_tracking_not_composed(bool async, async a => { using var context = CreateContext(); - var query = context.Set().FromSqlRaw(""" - SELECT * FROM root c WHERE c["$type"] = "Customer" - """) + var query = context.Set().FromSqlRaw( + """ +SELECT * FROM root c WHERE c["$type"] = "Customer" +""") .AsNoTracking(); var actual = a @@ -641,9 +645,10 @@ public virtual Task FromSqlRaw_composed_with_nullable_predicate(bool async) async, async a => { using var context = CreateContext(); - var query = context.Set().FromSqlRaw(""" - SELECT * FROM root c WHERE c["$type"] = "Customer" - """) + var query = context.Set().FromSqlRaw( + """ +SELECT * FROM root c WHERE c["$type"] = "Customer" +""") .Where(c => c.ContactName == c.CompanyName); var actual = a @@ -688,9 +693,10 @@ public virtual Task FromSqlRaw_queryable_simple_projection_not_composed(bool asy async, async a => { using var context = CreateContext(); - var query = context.Set().FromSqlRaw(""" - SELECT * FROM root c WHERE c["$type"] = "Customer" - """) + var query = context.Set().FromSqlRaw( + """ +SELECT * FROM root c WHERE c["$type"] = "Customer" +""") .Select( c => new { c.CustomerID, c.City }) .AsNoTracking(); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosFixture.cs b/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosFixture.cs index dd3ed72fb1c..54c5489ea89 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosFixture.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosFixture.cs @@ -25,8 +25,9 @@ public Task NoSyncTest(bool async, Func testCode) => CosmosTestHelpers.Instance.NoSyncTest(async, testCode); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) - => base.AddOptions(builder.ConfigureWarnings( - w => w.Ignore(CoreEventId.MappedEntityTypeIgnoredWarning, CosmosEventId.NoPartitionKeyDefined))); + => base.AddOptions( + builder.ConfigureWarnings( + w => w.Ignore(CoreEventId.MappedEntityTypeIgnoredWarning, CosmosEventId.NoPartitionKeyDefined))); protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { @@ -36,10 +37,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con modelBuilder.Entity().ToContainer("Plants"); modelBuilder.Entity().Property("Discriminator").ToJsonProperty("_type"); modelBuilder.Entity().ToContainer("Countries"); - modelBuilder.Entity().ToContainer("Drinks");; + modelBuilder.Entity().ToContainer("Drinks"); modelBuilder.Entity().ToContainer("Animals"); modelBuilder.Entity().ToContainer("Animals"); - modelBuilder.Entity().ToContainer("Animals");; - modelBuilder.Entity().ToContainer("Animals");; + modelBuilder.Entity().ToContainer("Animals"); + modelBuilder.Entity().ToContainer("Animals"); } } diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosTest.cs index 1a984168fcd..b6ee8afc69b 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosTest.cs @@ -11,10 +11,7 @@ public class InheritanceQueryCosmosTest : InheritanceQueryTestBase ClearLog(); [ConditionalFact] public virtual void Check_all_tests_overridden() diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/JsonQueryCosmosFixture.cs b/test/EFCore.Cosmos.FunctionalTests/Query/JsonQueryCosmosFixture.cs index 7acf8a09d2b..93c954e816a 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/JsonQueryCosmosFixture.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/JsonQueryCosmosFixture.cs @@ -16,8 +16,9 @@ protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) - => base.AddOptions(builder.ConfigureWarnings( - w => w.Ignore(CosmosEventId.NoPartitionKeyDefined))); + => base.AddOptions( + builder.ConfigureWarnings( + w => w.Ignore(CosmosEventId.NoPartitionKeyDefined))); public Task NoSyncTest(bool async, Func testCode) => CosmosTestHelpers.Instance.NoSyncTest(async, testCode); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/JsonQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/JsonQueryCosmosTest.cs index 610268600f4..d9bc9fb7d8c 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/JsonQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/JsonQueryCosmosTest.cs @@ -27,7 +27,7 @@ public override Task Basic_json_projection_enum_inside_json_entity(bool async) await base.Basic_json_projection_enum_inside_json_entity(a); AssertSql( - """ + """ SELECT c["Id"], c["OwnedReferenceRoot"]["OwnedReferenceBranch"]["Enum"] FROM root c WHERE (c["Discriminator"] = "Basic") @@ -75,7 +75,7 @@ public override Task Basic_json_projection_owned_collection_root(bool async) // TODO: issue #34067 (?) AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -90,7 +90,7 @@ public override Task Basic_json_projection_owned_collection_root_NoTrackingWithI // TODO: issue #34067 (?) AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -104,7 +104,7 @@ public override Task Basic_json_projection_owned_reference_branch(bool async) await base.Basic_json_projection_owned_reference_branch(async); AssertSql( -""" + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -118,7 +118,7 @@ public override Task Basic_json_projection_owned_reference_branch_NoTrackingWith await base.Basic_json_projection_owned_reference_branch_NoTrackingWithIdentityResolution(async); AssertSql( -""" + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -132,7 +132,7 @@ public override Task Basic_json_projection_owned_reference_duplicated(bool async await base.Basic_json_projection_owned_reference_duplicated(async); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -147,7 +147,7 @@ public override Task Basic_json_projection_owned_reference_duplicated2(bool asyn await base.Basic_json_projection_owned_reference_duplicated2(async); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -162,7 +162,7 @@ public override Task Basic_json_projection_owned_reference_duplicated2_NoTrackin await base.Basic_json_projection_owned_reference_duplicated2_NoTrackingWithIdentityResolution(async); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -177,7 +177,7 @@ public override Task Basic_json_projection_owned_reference_duplicated_NoTracking await base.Basic_json_projection_owned_reference_duplicated_NoTrackingWithIdentityResolution(async); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -192,7 +192,7 @@ public override Task Basic_json_projection_owned_reference_leaf(bool async) await base.Basic_json_projection_owned_reference_leaf(async); AssertSql( -""" + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -207,7 +207,7 @@ public override Task Basic_json_projection_owned_reference_root(bool async) // TODO: issue #34067 (?) AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -222,7 +222,7 @@ public override Task Basic_json_projection_owned_reference_root_NoTrackingWithId // TODO: issue #34067 (?) AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -236,7 +236,7 @@ public override Task Basic_json_projection_owner_entity(bool async) await base.Basic_json_projection_owner_entity(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -250,7 +250,7 @@ public override Task Basic_json_projection_owner_entity_duplicated(bool async) await base.Basic_json_projection_owner_entity_duplicated(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -264,7 +264,7 @@ public override Task Basic_json_projection_owner_entity_duplicated_NoTracking(bo await base.Basic_json_projection_owner_entity_duplicated_NoTracking(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "SingleOwned") @@ -278,7 +278,7 @@ public override Task Basic_json_projection_owner_entity_duplicated_NoTrackingWit await base.Basic_json_projection_owner_entity_duplicated_NoTrackingWithIdentityResolution(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "SingleOwned") @@ -292,7 +292,7 @@ public override Task Basic_json_projection_owner_entity_NoTracking(bool async) await base.Basic_json_projection_owner_entity_NoTracking(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -306,7 +306,7 @@ public override Task Basic_json_projection_owner_entity_NoTrackingWithIdentityRe await base.Basic_json_projection_owner_entity_NoTrackingWithIdentityResolution(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -320,7 +320,7 @@ public override Task Basic_json_projection_owner_entity_twice(bool async) await base.Basic_json_projection_owner_entity_twice(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -334,7 +334,7 @@ public override Task Basic_json_projection_owner_entity_twice_NoTracking(bool as await base.Basic_json_projection_owner_entity_twice_NoTracking(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -348,7 +348,7 @@ public override Task Basic_json_projection_owner_entity_twice_NoTrackingWithIden await base.Basic_json_projection_owner_entity_twice_NoTrackingWithIdentityResolution(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -362,7 +362,7 @@ public override Task Basic_json_projection_scalar(bool async) await base.Basic_json_projection_scalar(a); AssertSql( - """ + """ SELECT VALUE c["OwnedReferenceRoot"]["Name"] FROM root c WHERE (c["Discriminator"] = "Basic") @@ -387,7 +387,7 @@ public override Task Custom_naming_projection_owned_collection(bool async) // TODO: issue #34067 (?) AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "CustomNaming") @@ -402,7 +402,7 @@ public override Task Custom_naming_projection_owned_reference(bool async) await base.Custom_naming_projection_owned_reference(async); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "CustomNaming") @@ -416,7 +416,7 @@ public override Task Custom_naming_projection_owned_scalar(bool async) await base.Custom_naming_projection_owned_scalar(a); AssertSql( - """ + """ SELECT VALUE c["OwnedReferenceRoot"]["OwnedReferenceBranch"]["Fraction"] FROM root c WHERE (c["Discriminator"] = "CustomNaming") @@ -430,7 +430,7 @@ public override Task Custom_naming_projection_owner_entity(bool async) await base.Custom_naming_projection_owner_entity(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "CustomNaming") @@ -443,7 +443,8 @@ public override async Task Entity_including_collection_with_json(bool async) () => base.Entity_including_collection_with_json(async))).Message; Assert.Equal( - CosmosStrings.NonEmbeddedIncludeNotSupported("Navigation: EntityBasic.JsonEntityBasics (List) Collection ToDependent JsonEntityBasic"), + CosmosStrings.NonEmbeddedIncludeNotSupported( + "Navigation: EntityBasic.JsonEntityBasics (List) Collection ToDependent JsonEntityBasic"), message); } @@ -483,7 +484,7 @@ public override Task Json_all_types_entity_projection(bool async) await base.Json_all_types_entity_projection(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "AllTypes") @@ -499,7 +500,7 @@ public override Task Json_all_types_projection_from_owned_entity_reference(bool // TODO: issue #34067 (?) AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "AllTypes") @@ -513,7 +514,7 @@ public override Task Json_all_types_projection_individual_properties(bool async) await base.Json_all_types_projection_individual_properties(a); AssertSql( - """ + """ SELECT c["Reference"]["TestDefaultString"], c["Reference"]["TestMaxLengthString"], c["Reference"]["TestBoolean"], c["Reference"]["TestByte"], c["Reference"]["TestCharacter"], c["Reference"]["TestDateTime"], c["Reference"]["TestDateTimeOffset"], c["Reference"]["TestDecimal"], c["Reference"]["TestDouble"], c["Reference"]["TestGuid"], c["Reference"]["TestInt16"], c["Reference"]["TestInt32"], c["Reference"]["TestInt64"], c["Reference"]["TestSignedByte"], c["Reference"]["TestSingle"], c["Reference"]["TestTimeSpan"], c["Reference"]["TestDateOnly"], c["Reference"]["TestTimeOnly"], c["Reference"]["TestUnsignedInt16"], c["Reference"]["TestUnsignedInt32"], c["Reference"]["TestUnsignedInt64"], c["Reference"]["TestEnum"], c["Reference"]["TestEnumWithIntConverter"], c["Reference"]["TestNullableEnum"], c["Reference"]["TestNullableEnumWithIntConverter"], c["Reference"]["TestNullableEnumWithConverterThatHandlesNulls"] FROM root c WHERE (c["Discriminator"] = "AllTypes") @@ -528,7 +529,7 @@ public override Task Json_boolean_predicate(bool async) await base.Json_boolean_predicate(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND c["Reference"]["TestBoolean"]) @@ -542,7 +543,7 @@ public override Task Json_boolean_predicate_negated(bool async) await base.Json_boolean_predicate_negated(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND NOT(c["Reference"]["TestBoolean"])) @@ -556,7 +557,7 @@ public override Task Json_boolean_projection(bool async) await base.Json_boolean_projection(a); AssertSql( - """ + """ SELECT VALUE c["Reference"]["TestBoolean"] FROM root c WHERE (c["Discriminator"] = "AllTypes") @@ -570,7 +571,7 @@ public override Task Json_boolean_projection_negated(bool async) await base.Json_boolean_projection_negated(a); AssertSql( - """ + """ SELECT VALUE NOT(c["Reference"]["TestBoolean"]) FROM root c WHERE (c["Discriminator"] = "AllTypes") @@ -579,7 +580,7 @@ FROM root c public override Task Json_branch_collection_distinct_and_other_collection(bool async) => AssertTranslationFailed( - () => base.Json_branch_collection_distinct_and_other_collection(async)); + () => base.Json_branch_collection_distinct_and_other_collection(async)); [ConditionalTheory(Skip = "issue #34335")] public override Task Json_collection_after_collection_index_in_projection_using_constant_when_owner_is_not_present(bool async) @@ -637,7 +638,7 @@ public override Task Json_collection_Any_with_predicate(bool async) await base.Json_collection_Any_with_predicate(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Basic") AND EXISTS ( @@ -649,11 +650,11 @@ FROM o IN c["OwnedReferenceRoot"]["OwnedCollectionBranch"] public override Task Json_collection_Distinct_Count_with_predicate(bool async) => AssertTranslationFailed( - () => base.Json_collection_Distinct_Count_with_predicate(async)); + () => base.Json_collection_Distinct_Count_with_predicate(async)); public override Task Json_collection_distinct_in_projection(bool async) => AssertTranslationFailed( - () => base.Json_collection_distinct_in_projection(async)); + () => base.Json_collection_distinct_in_projection(async)); [ConditionalTheory(Skip = "issue #34335")] public override Task Json_collection_ElementAtOrDefault_in_projection(bool async) @@ -682,7 +683,7 @@ public override Task Json_collection_ElementAt_and_pushdown(bool async) await base.Json_collection_ElementAt_and_pushdown(a); AssertSql( - """ + """ SELECT VALUE { "Id" : c["Id"], @@ -700,7 +701,7 @@ public override Task Json_collection_ElementAt_in_predicate(bool async) await base.Json_collection_ElementAt_in_predicate(a); AssertSql( - """ + """ SELECT VALUE c["Id"] FROM root c WHERE ((c["Discriminator"] = "Basic") AND (c["OwnedCollectionRoot"][1]["Name"] != "Foo")) @@ -771,7 +772,7 @@ public override Task Json_collection_index_in_predicate_using_constant(bool asyn await base.Json_collection_index_in_predicate_using_constant(a); AssertSql( - """ + """ SELECT VALUE c["Id"] FROM root c WHERE ((c["Discriminator"] = "Basic") AND (c["OwnedCollectionRoot"][0]["Name"] != "Foo")) @@ -785,7 +786,7 @@ public override Task Json_collection_index_in_predicate_using_variable(bool asyn await base.Json_collection_index_in_predicate_using_variable(a); AssertSql( - """ + """ @__prm_0='1' SELECT VALUE c["Id"] @@ -1037,7 +1038,7 @@ public override Task Json_collection_in_projection_with_composition_count(bool a await base.Json_collection_in_projection_with_composition_count(a); AssertSql( - """ + """ SELECT VALUE ARRAY_LENGTH(c["OwnedCollectionRoot"]) FROM root c WHERE (c["Discriminator"] = "Basic") @@ -1060,7 +1061,7 @@ public override Task Json_collection_leaf_filter_in_projection(bool async) await base.Json_collection_leaf_filter_in_projection(a); AssertSql( - """ + """ SELECT VALUE ARRAY( SELECT VALUE o FROM o IN c["OwnedReferenceRoot"]["OwnedReferenceBranch"]["OwnedCollectionLeaf"] @@ -1071,7 +1072,6 @@ ORDER BY c["Id"] """); }); - public override Task Json_collection_of_primitives_contains_in_predicate(bool async) => Fixture.NoSyncTest( async, async a => @@ -1079,7 +1079,7 @@ public override Task Json_collection_of_primitives_contains_in_predicate(bool as await base.Json_collection_of_primitives_contains_in_predicate(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Basic") AND ARRAY_CONTAINS(c["OwnedReferenceRoot"]["Names"], "e1_r1")) @@ -1093,7 +1093,7 @@ public override Task Json_collection_of_primitives_index_used_in_orderby(bool as await base.Json_collection_of_primitives_index_used_in_orderby(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -1108,7 +1108,7 @@ public override Task Json_collection_of_primitives_index_used_in_predicate(bool await base.Json_collection_of_primitives_index_used_in_predicate(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Basic") AND (c["OwnedReferenceRoot"]["Names"][0] = "e1_r1")) @@ -1123,7 +1123,7 @@ public override Task Json_collection_of_primitives_index_used_in_projection(bool await base.Json_collection_of_primitives_index_used_in_projection(a); AssertSql( - """ + """ SELECT VALUE c["OwnedReferenceRoot"]["OwnedReferenceBranch"]["Enums"][0] FROM root c WHERE (c["Discriminator"] = "JsonEntityBasic") @@ -1138,7 +1138,7 @@ public override Task Json_collection_of_primitives_SelectMany(bool async) await base.Json_collection_of_primitives_SelectMany(a); AssertSql( - """ + """ SELECT VALUE n FROM root c JOIN n IN c["OwnedReferenceRoot"]["Names"] @@ -1148,10 +1148,8 @@ JOIN n IN c["OwnedReferenceRoot"]["Names"] public override Task Json_collection_OrderByDescending_Skip_ElementAt(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_collection_OrderByDescending_Skip_ElementAt(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries + - Environment.NewLine + - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_collection_OrderByDescending_Skip_ElementAt(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries + Environment.NewLine + CosmosStrings.LimitOffsetNotSupportedInSubqueries); [ConditionalTheory(Skip = "issue #34349")] public override Task Json_collection_SelectMany(bool async) @@ -1164,22 +1162,23 @@ public override Task Json_collection_SelectMany(bool async) }); [ConditionalTheory(Skip = "issue #34335")] - public override Task Json_collection_Select_entity_collection_ElementAt(bool async) => base.Json_collection_Select_entity_collection_ElementAt(async); + public override Task Json_collection_Select_entity_collection_ElementAt(bool async) + => base.Json_collection_Select_entity_collection_ElementAt(async); public override Task Json_collection_Select_entity_ElementAt(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_collection_Select_entity_ElementAt(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_collection_Select_entity_ElementAt(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); public override Task Json_collection_Select_entity_in_anonymous_object_ElementAt(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_collection_Select_entity_in_anonymous_object_ElementAt(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_collection_Select_entity_in_anonymous_object_ElementAt(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); public override Task Json_collection_Select_entity_with_initializer_ElementAt(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_collection_Select_entity_with_initializer_ElementAt(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_collection_Select_entity_with_initializer_ElementAt(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); public override Task Json_collection_Skip(bool async) => Fixture.NoSyncTest( @@ -1188,7 +1187,7 @@ public override Task Json_collection_Skip(bool async) await base.Json_collection_Skip(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Basic") AND (ARRAY( @@ -1199,18 +1198,18 @@ FROM o IN (SELECT VALUE ARRAY_SLICE(c["OwnedReferenceRoot"]["OwnedCollectionBran public override Task Json_collection_skip_take_in_projection(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_collection_skip_take_in_projection(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_collection_skip_take_in_projection(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); public override Task Json_collection_skip_take_in_projection_project_into_anonymous_type(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_collection_skip_take_in_projection_project_into_anonymous_type(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_collection_skip_take_in_projection_project_into_anonymous_type(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); public override Task Json_collection_skip_take_in_projection_with_json_reference_access_as_final_operation(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_collection_skip_take_in_projection_with_json_reference_access_as_final_operation(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_collection_skip_take_in_projection_with_json_reference_access_as_final_operation(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); public override Task Json_collection_Where_ElementAt(bool async) => Fixture.NoSyncTest( @@ -1220,7 +1219,7 @@ public override Task Json_collection_Where_ElementAt(bool async) await base.Json_collection_Where_ElementAt(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Basic") AND (ARRAY( @@ -1237,7 +1236,7 @@ public override Task Json_collection_within_collection_Count(bool async) await base.Json_collection_within_collection_Count(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Basic") AND EXISTS ( @@ -1263,7 +1262,7 @@ public override Task Json_entity_with_inheritance_basic_projection(bool async) await base.Json_entity_with_inheritance_basic_projection(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE c["$type"] IN ("JsonEntityInheritanceBase", "JsonEntityInheritanceDerived") @@ -1277,7 +1276,7 @@ public override Task Json_entity_with_inheritance_project_derived(bool async) await base.Json_entity_with_inheritance_project_derived(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["$type"] IN ("JsonEntityInheritanceBase", "JsonEntityInheritanceDerived") AND (c["$type"] = "JsonEntityInheritanceDerived")) @@ -1306,23 +1305,24 @@ public override Task Json_entity_with_inheritance_project_navigations_on_derived public override Task Json_leaf_collection_distinct_and_other_collection(bool async) => AssertTranslationFailed( - () => base.Json_leaf_collection_distinct_and_other_collection(async)); + () => base.Json_leaf_collection_distinct_and_other_collection(async)); public override Task Json_multiple_collection_projections(bool async) => AssertTranslationFailed( - () => base.Json_multiple_collection_projections(async)); + () => base.Json_multiple_collection_projections(async)); public override Task Json_nested_collection_anonymous_projection_in_projection(bool async) => AssertTranslationFailed( - () => base.Json_nested_collection_anonymous_projection_in_projection(async)); + () => base.Json_nested_collection_anonymous_projection_in_projection(async)); - public override Task Json_nested_collection_anonymous_projection_of_primitives_in_projection_NoTrackingWithIdentityResolution(bool async) + public override Task Json_nested_collection_anonymous_projection_of_primitives_in_projection_NoTrackingWithIdentityResolution( + bool async) => AssertTranslationFailed( - () => base.Json_nested_collection_anonymous_projection_of_primitives_in_projection_NoTrackingWithIdentityResolution(async)); + () => base.Json_nested_collection_anonymous_projection_of_primitives_in_projection_NoTrackingWithIdentityResolution(async)); public override Task Json_nested_collection_filter_in_projection(bool async) => AssertTranslationFailed( - () => base.Json_nested_collection_filter_in_projection(async)); + () => base.Json_nested_collection_filter_in_projection(async)); [ConditionalTheory(Skip = "issue #34349")] public override Task Json_nested_collection_SelectMany(bool async) @@ -1341,7 +1341,7 @@ public override Task Json_predicate_on_bool_converted_to_int_zero_one(bool async await base.Json_predicate_on_bool_converted_to_int_zero_one(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Converters") AND (c["Reference"]["BoolConvertedToIntZeroOne"] = 1)) @@ -1355,7 +1355,7 @@ public override Task Json_predicate_on_bool_converted_to_int_zero_one_with_expli await base.Json_predicate_on_bool_converted_to_int_zero_one_with_explicit_comparison(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Converters") AND (c["Reference"]["BoolConvertedToIntZeroOne"] = 0)) @@ -1369,7 +1369,7 @@ public override Task Json_predicate_on_bool_converted_to_string_True_False(bool await base.Json_predicate_on_bool_converted_to_string_True_False(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Converters") AND (c["Reference"]["BoolConvertedToStringTrueFalse"] = "True")) @@ -1383,7 +1383,7 @@ public override Task Json_predicate_on_bool_converted_to_string_True_False_with_ await base.Json_predicate_on_bool_converted_to_string_True_False_with_explicit_comparison(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Converters") AND (c["Reference"]["BoolConvertedToStringTrueFalse"] = "True")) @@ -1397,7 +1397,7 @@ public override Task Json_predicate_on_bool_converted_to_string_Y_N(bool async) await base.Json_predicate_on_bool_converted_to_string_Y_N(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Converters") AND (c["Reference"]["BoolConvertedToStringYN"] = "Y")) @@ -1411,7 +1411,7 @@ public override Task Json_predicate_on_bool_converted_to_string_Y_N_with_explici await base.Json_predicate_on_bool_converted_to_string_Y_N_with_explicit_comparison(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Converters") AND (c["Reference"]["BoolConvertedToStringYN"] = "N")) @@ -1426,7 +1426,7 @@ public override Task Json_predicate_on_byte(bool async) await base.Json_predicate_on_byte(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestByte"] != 3)) @@ -1441,7 +1441,7 @@ public override Task Json_predicate_on_byte_array(bool async) await base.Json_predicate_on_byte_array(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestByteArray"] != "AQID")) @@ -1456,7 +1456,7 @@ public override Task Json_predicate_on_character(bool async) await base.Json_predicate_on_character(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestCharacter"] != "z")) @@ -1471,7 +1471,7 @@ public override Task Json_predicate_on_dateonly(bool async) await base.Json_predicate_on_dateonly(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestDateOnly"] != "0003-02-01")) @@ -1486,7 +1486,7 @@ public override Task Json_predicate_on_datetime(bool async) await base.Json_predicate_on_datetime(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestDateTime"] != "2000-01-03T00:00:00")) @@ -1501,7 +1501,7 @@ public override Task Json_predicate_on_datetimeoffset(bool async) await base.Json_predicate_on_datetimeoffset(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestDateTimeOffset"] != "2000-01-04T00:00:00+03:02")) @@ -1516,7 +1516,7 @@ public override Task Json_predicate_on_decimal(bool async) await base.Json_predicate_on_decimal(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestDecimal"] != 1.35)) @@ -1531,7 +1531,7 @@ public override Task Json_predicate_on_default_string(bool async) await base.Json_predicate_on_default_string(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestDefaultString"] != "MyDefaultStringInReference1")) @@ -1546,7 +1546,7 @@ public override Task Json_predicate_on_double(bool async) await base.Json_predicate_on_double(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestDouble"] != 33.25)) @@ -1561,7 +1561,7 @@ public override Task Json_predicate_on_enum(bool async) await base.Json_predicate_on_enum(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestEnum"] != 2)) @@ -1576,7 +1576,7 @@ public override Task Json_predicate_on_enumwithintconverter(bool async) await base.Json_predicate_on_enumwithintconverter(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestEnumWithIntConverter"] != -3)) @@ -1591,7 +1591,7 @@ public override Task Json_predicate_on_guid(bool async) await base.Json_predicate_on_guid(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestGuid"] != "00000000-0000-0000-0000-000000000000")) @@ -1606,7 +1606,7 @@ public override Task Json_predicate_on_int16(bool async) await base.Json_predicate_on_int16(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestInt16"] != 3)) @@ -1621,7 +1621,7 @@ public override Task Json_predicate_on_int32(bool async) await base.Json_predicate_on_int32(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestInt32"] != 33)) @@ -1636,7 +1636,7 @@ public override Task Json_predicate_on_int64(bool async) await base.Json_predicate_on_int64(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestInt64"] != 333)) @@ -1650,7 +1650,7 @@ public override Task Json_predicate_on_int_zero_one_converted_to_bool(bool async await base.Json_predicate_on_int_zero_one_converted_to_bool(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Converters") AND (c["Reference"]["IntZeroOneConvertedToBool"] = true)) @@ -1665,7 +1665,7 @@ public override Task Json_predicate_on_max_length_string(bool async) await base.Json_predicate_on_max_length_string(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestMaxLengthString"] != "Foo")) @@ -1680,7 +1680,7 @@ public override Task Json_predicate_on_nullableenum1(bool async) await base.Json_predicate_on_nullableenum1(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestNullableEnum"] != -1)) @@ -1695,7 +1695,7 @@ public override Task Json_predicate_on_nullableenum2(bool async) await base.Json_predicate_on_nullableenum2(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestNullableEnum"] != null)) @@ -1710,7 +1710,7 @@ public override Task Json_predicate_on_nullableenumwithconverter1(bool async) await base.Json_predicate_on_nullableenumwithconverter1(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestNullableEnumWithIntConverter"] != 2)) @@ -1725,7 +1725,7 @@ public override Task Json_predicate_on_nullableenumwithconverter2(bool async) await base.Json_predicate_on_nullableenumwithconverter2(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestNullableEnumWithIntConverter"] != null)) @@ -1740,7 +1740,7 @@ public override Task Json_predicate_on_nullableenumwithconverterthathandlesnulls await base.Json_predicate_on_nullableenumwithconverterthathandlesnulls1(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestNullableEnumWithConverterThatHandlesNulls"] != "One")) @@ -1764,7 +1764,7 @@ public override Task Json_predicate_on_nullableint321(bool async) await base.Json_predicate_on_nullableint321(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestNullableInt32"] != 100)) @@ -1779,7 +1779,7 @@ public override Task Json_predicate_on_nullableint322(bool async) await base.Json_predicate_on_nullableint322(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestNullableInt32"] != null)) @@ -1794,7 +1794,7 @@ public override Task Json_predicate_on_signedbyte(bool async) await base.Json_predicate_on_signedbyte(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestSignedByte"] != 100)) @@ -1809,7 +1809,7 @@ public override Task Json_predicate_on_single(bool async) await base.Json_predicate_on_single(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestSingle"] != 10.4)) @@ -1824,7 +1824,7 @@ public override Task Json_predicate_on_string_condition(bool async) await base.Json_predicate_on_string_condition(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND ((NOT(c["Reference"]["TestBoolean"]) ? c["Reference"]["TestMaxLengthString"] : c["Reference"]["TestDefaultString"]) = "MyDefaultStringInReference1")) @@ -1838,7 +1838,7 @@ public override Task Json_predicate_on_string_True_False_converted_to_bool(bool await base.Json_predicate_on_string_True_False_converted_to_bool(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Converters") AND (c["Reference"]["StringTrueFalseConvertedToBool"] = false)) @@ -1852,7 +1852,7 @@ public override Task Json_predicate_on_string_Y_N_converted_to_bool(bool async) await base.Json_predicate_on_string_Y_N_converted_to_bool(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Converters") AND (c["Reference"]["StringYNConvertedToBool"] = false)) @@ -1867,7 +1867,7 @@ public override Task Json_predicate_on_timeonly(bool async) await base.Json_predicate_on_timeonly(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestTimeOnly"] != "03:02:00")) @@ -1882,7 +1882,7 @@ public override Task Json_predicate_on_timespan(bool async) await base.Json_predicate_on_timespan(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestTimeSpan"] != "03:02:00")) @@ -1897,7 +1897,7 @@ public override Task Json_predicate_on_unisgnedint16(bool async) await base.Json_predicate_on_unisgnedint16(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestUnsignedInt16"] != 100)) @@ -1912,7 +1912,7 @@ public override Task Json_predicate_on_unsignedint32(bool async) await base.Json_predicate_on_unsignedint32(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestUnsignedInt32"] != 1000)) @@ -1927,7 +1927,7 @@ public override Task Json_predicate_on_unsignedint64(bool async) await base.Json_predicate_on_unsignedint64(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "AllTypes") AND (c["Reference"]["TestUnsignedInt64"] != 10000)) @@ -1936,18 +1936,18 @@ FROM root c public override Task Json_projection_collection_element_and_reference_AsNoTrackingWithIdentityResolution(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_projection_collection_element_and_reference_AsNoTrackingWithIdentityResolution(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_projection_collection_element_and_reference_AsNoTrackingWithIdentityResolution(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); public override Task Json_projection_deduplication_with_collection_indexer_in_original(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_projection_deduplication_with_collection_indexer_in_original(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_projection_deduplication_with_collection_indexer_in_original(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); public override Task Json_projection_deduplication_with_collection_indexer_in_target(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_projection_deduplication_with_collection_indexer_in_target(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_projection_deduplication_with_collection_indexer_in_target(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); public override async Task Json_projection_deduplication_with_collection_in_original_and_collection_indexer_in_target(bool async) { @@ -1965,7 +1965,7 @@ public override Task Json_projection_enum_with_custom_conversion(bool async) await base.Json_projection_enum_with_custom_conversion(a); AssertSql( - """ + """ SELECT c["Id"], c["OwnedReferenceRoot"]["Enum"] FROM root c WHERE (c["Discriminator"] = "CustomNaming") @@ -1974,13 +1974,17 @@ FROM root c public override Task Json_projection_nested_collection_and_element_correct_order_AsNoTrackingWithIdentityResolution(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_projection_nested_collection_and_element_correct_order_AsNoTrackingWithIdentityResolution(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_projection_nested_collection_and_element_correct_order_AsNoTrackingWithIdentityResolution(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); - public override async Task Json_projection_nested_collection_element_using_parameter_and_the_owner_in_correct_order_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_nested_collection_element_using_parameter_and_the_owner_in_correct_order_AsNoTrackingWithIdentityResolution( + bool async) { var message = (await Assert.ThrowsAsync( - () => base.Json_projection_nested_collection_element_using_parameter_and_the_owner_in_correct_order_AsNoTrackingWithIdentityResolution(async))).Message; + () => base + .Json_projection_nested_collection_element_using_parameter_and_the_owner_in_correct_order_AsNoTrackingWithIdentityResolution( + async))).Message; // issue #34348 Assert.Equal(NotImplementedBindPropertyMessage, message); @@ -1993,26 +1997,34 @@ public override Task Json_projection_nothing_interesting_AsNoTrackingWithIdentit await base.Json_projection_nothing_interesting_AsNoTrackingWithIdentityResolution(a); AssertSql( - """ + """ SELECT c["Id"], c["Name"] FROM root c WHERE (c["Discriminator"] = "Basic") """); }); - public override async Task Json_projection_only_second_element_through_collection_element_constant_projected_nested_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_only_second_element_through_collection_element_constant_projected_nested_AsNoTrackingWithIdentityResolution( + bool async) { var message = (await Assert.ThrowsAsync( - () => base.Json_projection_only_second_element_through_collection_element_constant_projected_nested_AsNoTrackingWithIdentityResolution(async))).Message; + () => base + .Json_projection_only_second_element_through_collection_element_constant_projected_nested_AsNoTrackingWithIdentityResolution( + async))).Message; // issue #34348 Assert.Equal(NotImplementedBindPropertyMessage, message); } - public override async Task Json_projection_only_second_element_through_collection_element_parameter_projected_nested_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_only_second_element_through_collection_element_parameter_projected_nested_AsNoTrackingWithIdentityResolution( + bool async) { var message = (await Assert.ThrowsAsync( - () => base.Json_projection_only_second_element_through_collection_element_parameter_projected_nested_AsNoTrackingWithIdentityResolution(async))).Message; + () => base + .Json_projection_only_second_element_through_collection_element_parameter_projected_nested_AsNoTrackingWithIdentityResolution( + async))).Message; // issue #34348 Assert.Equal(NotImplementedBindPropertyMessage, message); @@ -2025,7 +2037,7 @@ public override Task Json_projection_owner_entity_AsNoTrackingWithIdentityResolu await base.Json_projection_owner_entity_AsNoTrackingWithIdentityResolution(a); AssertSql( - """ + """ SELECT c["Id"], c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -2034,42 +2046,57 @@ FROM root c public override Task Json_projection_reference_collection_and_collection_element_nested_AsNoTrackingWithIdentityResolution(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_projection_reference_collection_and_collection_element_nested_AsNoTrackingWithIdentityResolution(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_projection_reference_collection_and_collection_element_nested_AsNoTrackingWithIdentityResolution(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); - public override Task Json_projection_second_element_projected_before_owner_as_well_as_root_AsNoTrackingWithIdentityResolution(bool async) + public override Task Json_projection_second_element_projected_before_owner_as_well_as_root_AsNoTrackingWithIdentityResolution( + bool async) => AssertTranslationFailedWithDetails( - () => base.Json_projection_second_element_projected_before_owner_as_well_as_root_AsNoTrackingWithIdentityResolution(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_projection_second_element_projected_before_owner_as_well_as_root_AsNoTrackingWithIdentityResolution(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); [ConditionalTheory(Skip = "issue #34350")] - public override Task Json_projection_second_element_projected_before_owner_nested_as_well_as_root_AsNoTrackingWithIdentityResolution(bool async) + public override Task Json_projection_second_element_projected_before_owner_nested_as_well_as_root_AsNoTrackingWithIdentityResolution( + bool async) => Fixture.NoSyncTest( async, async a => { - await base.Json_projection_second_element_projected_before_owner_nested_as_well_as_root_AsNoTrackingWithIdentityResolution(a); + await base.Json_projection_second_element_projected_before_owner_nested_as_well_as_root_AsNoTrackingWithIdentityResolution( + a); AssertSql(""); }); - public override async Task Json_projection_second_element_through_collection_element_constant_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_second_element_through_collection_element_constant_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) { var message = (await Assert.ThrowsAsync( - () => base.Json_projection_second_element_through_collection_element_constant_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution(async))).Message; + () => base + .Json_projection_second_element_through_collection_element_constant_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution( + async))).Message; // issue #34348 Assert.Equal(NotImplementedBindPropertyMessage, message); } - public override Task Json_projection_second_element_through_collection_element_constant_projected_after_owner_nested_AsNoTrackingWithIdentityResolution(bool async) + public override Task + Json_projection_second_element_through_collection_element_constant_projected_after_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) => AssertTranslationFailedWithDetails( - () => base.Json_projection_second_element_through_collection_element_constant_projected_after_owner_nested_AsNoTrackingWithIdentityResolution(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base + .Json_projection_second_element_through_collection_element_constant_projected_after_owner_nested_AsNoTrackingWithIdentityResolution( + async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); - public override Task Json_projection_second_element_through_collection_element_parameter_correctly_projected_after_owner_nested_AsNoTrackingWithIdentityResolution(bool async) + public override Task + Json_projection_second_element_through_collection_element_parameter_correctly_projected_after_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) => AssertTranslationFailedWithDetails( - () => base.Json_projection_second_element_through_collection_element_parameter_correctly_projected_after_owner_nested_AsNoTrackingWithIdentityResolution(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base + .Json_projection_second_element_through_collection_element_parameter_correctly_projected_after_owner_nested_AsNoTrackingWithIdentityResolution( + async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); [ConditionalTheory(Skip = "issue #34350")] public override Task Json_projection_with_deduplication(bool async) @@ -2088,7 +2115,7 @@ public override Task Json_projection_with_deduplication_reverse_order(bool async await base.Json_projection_with_deduplication_reverse_order(async); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -2102,7 +2129,7 @@ public override Task Json_property_in_predicate(bool async) await base.Json_property_in_predicate(a); AssertSql( - """ + """ SELECT VALUE c["Id"] FROM root c WHERE ((c["Discriminator"] = "Basic") AND (c["OwnedReferenceRoot"]["OwnedReferenceBranch"]["Fraction"] < 20.5)) @@ -2116,7 +2143,7 @@ public override Task Json_scalar_length(bool async) await base.Json_scalar_length(a); AssertSql( - """ + """ SELECT VALUE c["Name"] FROM root c WHERE ((c["Discriminator"] = "Basic") AND (LENGTH(c["OwnedReferenceRoot"]["Name"]) > 2)) @@ -2130,7 +2157,7 @@ public override Task Json_scalar_optional_null_semantics(bool async) await base.Json_scalar_optional_null_semantics(a); AssertSql( - """ + """ SELECT VALUE c["Name"] FROM root c WHERE ((c["Discriminator"] = "Basic") AND (c["OwnedReferenceRoot"]["Name"] != c["OwnedReferenceRoot"]["OwnedReferenceBranch"]["OwnedReferenceLeaf"]["SomethingSomething"])) @@ -2144,7 +2171,7 @@ public override Task Json_scalar_required_null_semantics(bool async) await base.Json_scalar_required_null_semantics(a); AssertSql( - """ + """ SELECT VALUE c["Name"] FROM root c WHERE ((c["Discriminator"] = "Basic") AND (c["OwnedReferenceRoot"]["Number"] != LENGTH(c["OwnedReferenceRoot"]["Name"]))) @@ -2153,18 +2180,18 @@ FROM root c public override Task Json_subquery_property_pushdown_length(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_subquery_property_pushdown_length(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_subquery_property_pushdown_length(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); public override Task Json_subquery_reference_pushdown_property(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_subquery_reference_pushdown_property(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_subquery_reference_pushdown_property(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); public override Task Json_subquery_reference_pushdown_reference(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_subquery_reference_pushdown_reference(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_subquery_reference_pushdown_reference(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); public override Task Json_subquery_reference_pushdown_reference_anonymous_projection(bool async) => base.Json_subquery_reference_pushdown_reference_anonymous_projection(async); @@ -2174,13 +2201,13 @@ public override Task Json_subquery_reference_pushdown_reference_pushdown_anonymo public override Task Json_subquery_reference_pushdown_reference_pushdown_collection(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_subquery_reference_pushdown_reference_pushdown_collection(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_subquery_reference_pushdown_reference_pushdown_collection(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); public override Task Json_subquery_reference_pushdown_reference_pushdown_reference(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_subquery_reference_pushdown_reference_pushdown_reference(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_subquery_reference_pushdown_reference_pushdown_reference(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); public override async Task Json_with_include_on_entity_collection(bool async) { @@ -2188,19 +2215,20 @@ public override async Task Json_with_include_on_entity_collection(bool async) () => base.Json_with_include_on_entity_collection(async))).Message; Assert.Equal( - CosmosStrings.NonEmbeddedIncludeNotSupported("Navigation: JsonEntityBasic.EntityCollection (List) Collection ToDependent JsonEntityBasicForCollection Inverse: Parent"), + CosmosStrings.NonEmbeddedIncludeNotSupported( + "Navigation: JsonEntityBasic.EntityCollection (List) Collection ToDependent JsonEntityBasicForCollection Inverse: Parent"), message); } public override Task Json_with_include_on_entity_collection_and_reference(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_with_include_on_entity_collection_and_reference(async), - CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntityBasicForReference), nameof(JsonEntityBasic))); + () => base.Json_with_include_on_entity_collection_and_reference(async), + CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntityBasicForReference), nameof(JsonEntityBasic))); public override Task Json_with_include_on_entity_reference(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_with_include_on_entity_reference(async), - CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntityBasicForReference), nameof(JsonEntityBasic))); + () => base.Json_with_include_on_entity_reference(async), + CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntityBasicForReference), nameof(JsonEntityBasic))); public override Task Json_with_include_on_json_entity(bool async) => Fixture.NoSyncTest( @@ -2209,7 +2237,7 @@ public override Task Json_with_include_on_json_entity(bool async) await base.Json_with_include_on_json_entity(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Basic") @@ -2218,54 +2246,54 @@ FROM root c public override Task Json_with_projection_of_json_collection_and_entity_collection(bool async) => AssertTranslationFailed( - () => base.Json_with_projection_of_json_collection_and_entity_collection(async)); + () => base.Json_with_projection_of_json_collection_and_entity_collection(async)); public override Task Json_with_projection_of_json_collection_element_and_entity_collection(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_with_projection_of_json_collection_element_and_entity_collection(async), - CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntityBasicForReference), nameof(JsonEntityBasic))); + () => base.Json_with_projection_of_json_collection_element_and_entity_collection(async), + CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntityBasicForReference), nameof(JsonEntityBasic))); public override Task Json_with_projection_of_json_collection_leaf_and_entity_collection(bool async) => AssertTranslationFailed( - () => base.Json_with_projection_of_json_collection_leaf_and_entity_collection(async)); + () => base.Json_with_projection_of_json_collection_leaf_and_entity_collection(async)); public override Task Json_with_projection_of_json_reference_and_entity_collection(bool async) => AssertTranslationFailed( - () => base.Json_with_projection_of_json_reference_and_entity_collection(async)); + () => base.Json_with_projection_of_json_reference_and_entity_collection(async)); public override Task Json_with_projection_of_json_reference_leaf_and_entity_collection(bool async) => AssertTranslationFailed( - () => base.Json_with_projection_of_json_reference_leaf_and_entity_collection(async)); + () => base.Json_with_projection_of_json_reference_leaf_and_entity_collection(async)); public override Task Json_with_projection_of_mix_of_json_collections_json_references_and_entity_collection(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_with_projection_of_mix_of_json_collections_json_references_and_entity_collection(async), - CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntityBasicForReference), nameof(JsonEntityBasic))); + () => base.Json_with_projection_of_mix_of_json_collections_json_references_and_entity_collection(async), + CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntityBasicForReference), nameof(JsonEntityBasic))); public override Task Json_with_projection_of_multiple_json_references_and_entity_collection(bool async) => AssertTranslationFailedWithDetails( - () => base.Json_with_projection_of_multiple_json_references_and_entity_collection(async), - CosmosStrings.LimitOffsetNotSupportedInSubqueries); + () => base.Json_with_projection_of_multiple_json_references_and_entity_collection(async), + CosmosStrings.LimitOffsetNotSupportedInSubqueries); public override Task Left_join_json_entities(bool async) => AssertTranslationFailedWithDetails( - () => base.Left_join_json_entities(async), - CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntityBasic), nameof(JsonEntitySingleOwned))); + () => base.Left_join_json_entities(async), + CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntityBasic), nameof(JsonEntitySingleOwned))); public override Task Left_join_json_entities_complex_projection(bool async) => AssertTranslationFailedWithDetails( - () => base.Left_join_json_entities_complex_projection(async), - CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntityBasic), nameof(JsonEntitySingleOwned))); + () => base.Left_join_json_entities_complex_projection(async), + CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntityBasic), nameof(JsonEntitySingleOwned))); public override Task Left_join_json_entities_complex_projection_json_being_inner(bool async) => AssertTranslationFailedWithDetails( - () => base.Left_join_json_entities_complex_projection_json_being_inner(async), - CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntitySingleOwned), nameof(JsonEntityBasic))); + () => base.Left_join_json_entities_complex_projection_json_being_inner(async), + CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntitySingleOwned), nameof(JsonEntityBasic))); public override Task Left_join_json_entities_json_being_inner(bool async) => AssertTranslationFailedWithDetails( - () => base.Left_join_json_entities_json_being_inner(async), - CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntitySingleOwned), nameof(JsonEntityBasic))); + () => base.Left_join_json_entities_json_being_inner(async), + CosmosStrings.MultipleRootEntityTypesReferencedInQuery(nameof(JsonEntitySingleOwned), nameof(JsonEntityBasic))); public override Task Project_entity_with_single_owned(bool async) => Fixture.NoSyncTest( @@ -2274,7 +2302,7 @@ public override Task Project_entity_with_single_owned(bool async) await base.Project_entity_with_single_owned(a); AssertSql( - """ + """ SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "SingleOwned") @@ -2283,27 +2311,27 @@ FROM root c public override Task Project_json_entity_FirstOrDefault_subquery(bool async) => AssertTranslationFailed( - () => base.Project_json_entity_FirstOrDefault_subquery(async)); + () => base.Project_json_entity_FirstOrDefault_subquery(async)); public override Task Project_json_entity_FirstOrDefault_subquery_deduplication(bool async) => AssertTranslationFailed( - () => base.Project_json_entity_FirstOrDefault_subquery_deduplication(async)); + () => base.Project_json_entity_FirstOrDefault_subquery_deduplication(async)); public override Task Project_json_entity_FirstOrDefault_subquery_deduplication_and_outer_reference(bool async) => AssertTranslationFailed( - () => base.Project_json_entity_FirstOrDefault_subquery_deduplication_and_outer_reference(async)); + () => base.Project_json_entity_FirstOrDefault_subquery_deduplication_and_outer_reference(async)); public override Task Project_json_entity_FirstOrDefault_subquery_deduplication_outer_reference_and_pruning(bool async) => AssertTranslationFailed( - () => base.Project_json_entity_FirstOrDefault_subquery_deduplication_outer_reference_and_pruning(async)); + () => base.Project_json_entity_FirstOrDefault_subquery_deduplication_outer_reference_and_pruning(async)); public override Task Project_json_entity_FirstOrDefault_subquery_with_binding_on_top(bool async) => AssertTranslationFailed( - () => base.Project_json_entity_FirstOrDefault_subquery_with_binding_on_top(async)); + () => base.Project_json_entity_FirstOrDefault_subquery_with_binding_on_top(async)); public override Task Project_json_entity_FirstOrDefault_subquery_with_entity_comparison_on_top(bool async) => AssertTranslationFailed( - () => base.Project_json_entity_FirstOrDefault_subquery_with_entity_comparison_on_top(async)); + () => base.Project_json_entity_FirstOrDefault_subquery_with_entity_comparison_on_top(async)); public override async Task Project_json_reference_in_tracking_query_fails(bool async) { diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs index 7f285c08223..2d30fc87c90 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs @@ -1447,15 +1447,15 @@ public override Task Contains_with_local_array_closure(bool async) await base.Contains_with_local_array_closure(a); AssertSql( - """ + """ @__ids_0='["ABCDE","ALFKI"]' SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__ids_0, c["id"]) """, - // - """ + // + """ @__ids_0='["ABCDE"]' SELECT VALUE c @@ -1610,8 +1610,8 @@ SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__p_0, c["id"]) """, - // - """ + // + """ @__p_0='["ABCDE","ANATR"]' SELECT VALUE c @@ -1709,8 +1709,8 @@ SELECT 1 FROM p IN (SELECT VALUE @__p_0) WHERE ((p != null) AND (p = c["id"]))) """, - // - """ + // + """ @__p_0='["ABCDE","ANATR"]' SELECT VALUE c @@ -1830,8 +1830,8 @@ SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__ids_0, c["id"]) """, - // - """ + // + """ @__ids_0='["ABCDE"]' SELECT VALUE c @@ -1900,8 +1900,8 @@ SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__AsReadOnly_0, c["id"]) """, - // - """ + // + """ @__AsReadOnly_0='["ABCDE","ANATR"]' SELECT VALUE c @@ -2401,8 +2401,8 @@ SELECT VALUE c FROM root c WHERE ((c["City"] = "México D.F.") AND ARRAY_CONTAINS(@__ids_0, c["id"])) """, - // - """ + // + """ @__ids_0='["ABCDE","ALFKI","ANATR"]' SELECT VALUE c @@ -2471,8 +2471,8 @@ SELECT VALUE c FROM root c WHERE ((c["City"] = "México D.F.") AND NOT(ARRAY_CONTAINS(@__ids_0, c["id"]))) """, - // - """ + // + """ @__ids_0='["ABCDE","ALFKI","ANATR"]' SELECT VALUE c diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindDbFunctionsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindDbFunctionsQueryCosmosTest.cs index 39832d51071..9559f950d0b 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindDbFunctionsQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindDbFunctionsQueryCosmosTest.cs @@ -11,9 +11,7 @@ public NorthwindDbFunctionsQueryCosmosTest( NorthwindQueryCosmosFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) - { - ClearLog(); - } + => ClearLog(); [ConditionalFact] public virtual void Check_all_tests_overridden() diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindKeylessEntitiesQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindKeylessEntitiesQueryCosmosTest.cs index 4b29b445211..e971fd661ec 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindKeylessEntitiesQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindKeylessEntitiesQueryCosmosTest.cs @@ -41,8 +41,8 @@ public override Task KeylessEntity_where_simple(bool async) async, async a => { await base.KeylessEntity_where_simple(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE (c["City"] = "London") @@ -175,8 +175,8 @@ public override Task Auto_initialized_view_set(bool async) async, async a => { await base.Auto_initialized_view_set(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c """); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs index df65347ecfa..932708512c3 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs @@ -672,8 +672,8 @@ public override Task Queryable_nested_simple(bool async) async, async a => { await base.Queryable_nested_simple(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c """); @@ -733,8 +733,8 @@ public override Task Take_simple_parameterized(bool async) async, async a => { await base.Take_simple_parameterized(a); -AssertSql( - """ + AssertSql( + """ @__p_0='10' SELECT VALUE c @@ -749,8 +749,8 @@ public override Task Take_simple_projection(bool async) async, async a => { await base.Take_simple_projection(a); -AssertSql( - """ + AssertSql( + """ @__p_0='10' SELECT VALUE c["City"] @@ -765,8 +765,8 @@ public override Task Take_subquery_projection(bool async) async, async a => { await base.Take_subquery_projection(a); -AssertSql( - """ + AssertSql( + """ @__p_0='2' SELECT VALUE c["City"] @@ -821,8 +821,8 @@ public override async Task Any_predicate(bool async) var exception = await Assert.ThrowsAsync(() => base.Any_predicate(async)); Assert.Equal(HttpStatusCode.BadRequest, exception.StatusCode); -AssertSql( - """ + AssertSql( + """ SELECT VALUE EXISTS ( SELECT 1 FROM root c @@ -1340,8 +1340,8 @@ public override Task OrderBy(bool async) async, async a => { await base.OrderBy(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c ORDER BY c["id"] @@ -1374,8 +1374,8 @@ public override async Task OrderBy_integer(bool async) // Cosmos client evaluation. Issue #17246. await Assert.ThrowsAsync( async () => await base.OrderBy_integer(async)); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c ORDER BY 3 @@ -1408,8 +1408,8 @@ public override Task OrderBy_anon(bool async) async, async a => { await base.OrderBy_anon(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["id"] FROM root c ORDER BY c["id"] @@ -1421,8 +1421,8 @@ public override Task OrderBy_anon2(bool async) async, async a => { await base.OrderBy_anon2(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c ORDER BY c["id"] @@ -1471,8 +1471,8 @@ public override async Task OrderBy_shadow(bool async) // Cosmos client evaluation. Issue #17246. await Assert.ThrowsAsync( async () => await base.OrderBy_shadow(async)); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c ORDER BY c["Title"], c["EmployeeID"] @@ -1743,8 +1743,8 @@ public override async Task Select_null_coalesce_operator(bool async) // Cosmos client evaluation. Issue #17246. await Assert.ThrowsAsync( async () => await base.Select_null_coalesce_operator(async)); -AssertSql( - """ + AssertSql( + """ SELECT VALUE { "CustomerID" : c["id"], @@ -1765,8 +1765,8 @@ public override async Task OrderBy_conditional_operator(bool async) // Cosmos client evaluation. Issue #17246. await Assert.ThrowsAsync( async () => await base.OrderBy_conditional_operator(async)); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c ORDER BY ((c["Region"] = null) ? "ZZ" : c["Region"]), c["id"] @@ -1811,8 +1811,8 @@ public override Task Projection_null_coalesce_operator(bool async) async, async a => { await base.Projection_null_coalesce_operator(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE { "CustomerID" : c["id"], @@ -1828,8 +1828,8 @@ public override Task Filter_coalesce_operator(bool async) async, async a => { await base.Filter_coalesce_operator(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE (((c["ContactName"] != null) ? c["ContactName"] : c["CompanyName"]) = "Liz Nixon") @@ -1906,8 +1906,8 @@ public override async Task Selected_column_can_coalesce(bool async) // Unsupported ORDER BY clause. await Assert.ThrowsAsync( () => base.Selected_column_can_coalesce(async)); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c ORDER BY ((c["Region"] != null) ? c["Region"] : "ZZ") @@ -2073,8 +2073,8 @@ public override async Task Select_bitwise_or(bool async) { // Bitwise operators on booleans. Issue #13168. await Assert.ThrowsAsync(() => base.Select_bitwise_or(async)); -AssertSql( - """ + AssertSql( + """ SELECT VALUE { "CustomerID" : c["id"], @@ -2093,8 +2093,8 @@ public override async Task Select_bitwise_or_multiple(bool async) { // Bitwise operators on booleans. Issue #13168. await Assert.ThrowsAsync(() => base.Select_bitwise_or_multiple(async)); -AssertSql( - """ + AssertSql( + """ SELECT VALUE { "CustomerID" : c["id"], @@ -2113,8 +2113,8 @@ public override async Task Select_bitwise_and(bool async) { // Bitwise operators on booleans. Issue #13168. await Assert.ThrowsAsync(() => base.Select_bitwise_and(async)); -AssertSql( - """ + AssertSql( + """ SELECT VALUE { "CustomerID" : c["id"], @@ -2133,8 +2133,8 @@ public override async Task Select_bitwise_and_or(bool async) { // Bitwise operators on booleans. Issue #13168. await Assert.ThrowsAsync(() => base.Select_bitwise_and_or(async)); -AssertSql( - """ + AssertSql( + """ SELECT VALUE { "CustomerID" : c["id"], @@ -2153,8 +2153,8 @@ public override async Task Where_bitwise_or_with_logical_or(bool async) { // Bitwise operators on booleans. Issue #13168. await Assert.ThrowsAsync(() => base.Where_bitwise_or_with_logical_or(async)); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE (((c["id"] = "ALFKI") | (c["id"] = "ANATR")) OR (c["id"] = "ANTON")) @@ -2167,8 +2167,8 @@ public override Task Where_bitwise_and_with_logical_and(bool async) async, async a => { await base.Where_bitwise_and_with_logical_and(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE (((c["id"] = "ALFKI") & (c["id"] = "ANATR")) AND (c["id"] = "ANTON")) @@ -2182,8 +2182,8 @@ public override async Task Where_bitwise_or_with_logical_and(bool async) { // Bitwise operators on booleans. Issue #13168. await Assert.ThrowsAsync(() => base.Where_bitwise_or_with_logical_and(async)); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE (((c["id"] = "ALFKI") | (c["id"] = "ANATR")) AND (c["Country"] = "Germany")) @@ -2196,8 +2196,8 @@ public override Task Where_bitwise_and_with_logical_or(bool async) async, async a => { await base.Where_bitwise_and_with_logical_or(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE (((c["id"] = "ALFKI") & (c["id"] = "ANATR")) OR (c["id"] = "ANTON")) @@ -2269,8 +2269,8 @@ public override async Task Select_bitwise_or_with_logical_or(bool async) { // Bitwise operators on booleans. Issue #13168. await Assert.ThrowsAsync(() => base.Select_bitwise_or_with_logical_or(async)); -AssertSql( - """ + AssertSql( + """ SELECT VALUE { "CustomerID" : c["id"], @@ -2289,8 +2289,8 @@ public override async Task Select_bitwise_and_with_logical_and(bool async) { // Bitwise operators on booleans. Issue #13168. await Assert.ThrowsAsync(() => base.Select_bitwise_and_with_logical_and(async)); -AssertSql( - """ + AssertSql( + """ SELECT VALUE { "CustomerID" : c["id"], @@ -2641,7 +2641,7 @@ public override async Task DefaultIfEmpty_in_subquery_nested_filter_order_compar await AssertTranslationFailed(() => base.DefaultIfEmpty_in_subquery_nested_filter_order_comparison(async)); AssertSql( -); + ); } public override async Task OrderBy_skip_take(bool async) @@ -2700,7 +2700,7 @@ await AssertTranslationFailedWithDetails( CosmosStrings.LimitOffsetNotSupportedInSubqueries); AssertSql( -); + ); } public override Task OrderBy_skip_take_distinct(bool async) @@ -2811,8 +2811,8 @@ public override Task Anonymous_member_distinct_where(bool async) async, async a => { await base.Anonymous_member_distinct_where(a); -AssertSql( - """ + AssertSql( + """ SELECT DISTINCT VALUE c["id"] FROM root c WHERE (c["id"] = "ALFKI") @@ -2842,8 +2842,8 @@ public override Task Anonymous_complex_distinct_where(bool async) async, async a => { await base.Anonymous_complex_distinct_where(a); -AssertSql( - """ + AssertSql( + """ SELECT DISTINCT VALUE (c["id"] || c["City"]) FROM root c WHERE ((c["id"] || c["City"]) = "ALFKIBerlin") @@ -2865,7 +2865,7 @@ public override async Task Anonymous_complex_distinct_result(bool async) // Cosmos client evaluation. Issue #17246. await AssertTranslationFailed(() => base.Anonymous_complex_distinct_result(async)); AssertSql( -); + ); } public override async Task Anonymous_complex_orderby(bool async) @@ -2889,8 +2889,8 @@ public override async Task Anonymous_subquery_orderby(bool async) { // Cosmos client evaluation. Issue #17246. await AssertTranslationFailed(() => base.Anonymous_subquery_orderby(async)); -AssertSql( -); + AssertSql( + ); } public override Task DTO_member_distinct_where(bool async) @@ -2898,8 +2898,8 @@ public override Task DTO_member_distinct_where(bool async) async, async a => { await base.DTO_member_distinct_where(a); -AssertSql( - """ + AssertSql( + """ SELECT DISTINCT VALUE c["id"] FROM root c WHERE (c["id"] = "ALFKI") @@ -2929,8 +2929,8 @@ public override Task DTO_complex_distinct_where(bool async) async, async a => { await base.DTO_complex_distinct_where(a); -AssertSql( - """ + AssertSql( + """ SELECT DISTINCT VALUE (c["id"] || c["City"]) FROM root c WHERE ((c["id"] || c["City"]) = "ALFKIBerlin") @@ -2963,8 +2963,8 @@ public override async Task DTO_complex_orderby(bool async) // Cosmos client evaluation. Issue #17246. await Assert.ThrowsAsync( async () => await base.DTO_complex_orderby(async)); -AssertSql( - """ + AssertSql( + """ SELECT VALUE (c["id"] || c["City"]) FROM root c ORDER BY (c["id"] || c["City"]) @@ -3190,8 +3190,8 @@ public override async Task Select_distinct_sum(bool async) { // Cosmos client evaluation. Issue #17246. await AssertTranslationFailed(() => base.Select_distinct_sum(async)); -AssertSql( -); + AssertSql( + ); } public override Task Comparing_to_fixed_string_parameter(bool async) @@ -3199,8 +3199,8 @@ public override Task Comparing_to_fixed_string_parameter(bool async) async, async a => { await base.Comparing_to_fixed_string_parameter(a); -AssertSql( - """ + AssertSql( + """ @__prefix_0='A' SELECT VALUE c["id"] @@ -3277,8 +3277,8 @@ public override Task Comparing_collection_navigation_to_null(bool async) async, async a => { await base.Comparing_collection_navigation_to_null(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["id"] FROM root c WHERE (c["id"] = null) @@ -3291,7 +3291,7 @@ public override async Task Comparing_collection_navigation_to_null_complex(bool await AssertTranslationFailed(() => base.Comparing_collection_navigation_to_null_complex(async)); AssertSql( -); + ); } public override Task Compare_collection_navigation_with_itself(bool async) @@ -3299,8 +3299,8 @@ public override Task Compare_collection_navigation_with_itself(bool async) async, async a => { await base.Compare_collection_navigation_with_itself(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["id"] FROM root c WHERE (STARTSWITH(c["id"], "A") AND (c["id"] = c["id"])) @@ -3329,7 +3329,7 @@ public override async Task Compare_two_collection_navigations_with_different_pro await AssertTranslationFailed(() => base.Compare_two_collection_navigations_with_different_property_chains(async)); AssertSql( -); + ); } public override Task OrderBy_ThenBy_same_column_different_direction(bool async) @@ -3337,8 +3337,8 @@ public override Task OrderBy_ThenBy_same_column_different_direction(bool async) async, async a => { await base.OrderBy_ThenBy_same_column_different_direction(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["id"] FROM root c WHERE STARTSWITH(c["id"], "A") @@ -3351,8 +3351,8 @@ public override Task OrderBy_OrderBy_same_column_different_direction(bool async) async, async a => { await base.OrderBy_OrderBy_same_column_different_direction(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["id"] FROM root c WHERE STARTSWITH(c["id"], "A") @@ -3383,8 +3383,8 @@ public override Task OrderBy_Dto_projection_skip_take(bool async) async, async a => { await base.OrderBy_Dto_projection_skip_take(a); -AssertSql( - """ + AssertSql( + """ @__p_0='5' @__p_1='10' @@ -3399,8 +3399,8 @@ public override async Task Join_take_count_works(bool async) { // Cosmos client evaluation. Issue #17246. await AssertTranslationFailed(() => base.Join_take_count_works(async)); -AssertSql( -); + AssertSql( + ); } public override async Task OrderBy_empty_list_contains(bool async) @@ -3410,8 +3410,8 @@ public override async Task OrderBy_empty_list_contains(bool async) { await Assert.ThrowsAsync( async () => await base.OrderBy_empty_list_contains(async)); -AssertSql( - """ + AssertSql( + """ @__list_0='[]' SELECT VALUE c @@ -3615,8 +3615,8 @@ public override async Task OrderByDescending_ThenByDescending(bool async) // Cosmos client evaluation. Issue #17246. await Assert.ThrowsAsync( async () => await base.OrderByDescending_ThenByDescending(async)); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["City"] FROM root c ORDER BY c["id"] DESC, c["Country"] DESC @@ -3630,7 +3630,7 @@ public override async Task OrderBy_Join(bool async) await AssertTranslationFailed(() => base.OrderBy_Join(async)); AssertSql( -); + ); } public override async Task OrderBy_ThenBy(bool async) @@ -3763,8 +3763,8 @@ public override Task Where_Property_when_shadow_unconstrained_generic_method(boo async, async a => { await base.Where_Property_when_shadow_unconstrained_generic_method(a); -AssertSql( - """ + AssertSql( + """ @__value_0='Sales Representative' SELECT VALUE c @@ -4006,8 +4006,8 @@ public override Task Entity_equality_contains_with_list_of_null(bool async) async, async a => { await base.Entity_equality_contains_with_list_of_null(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE c["id"] IN (null, "ALFKI") @@ -4208,8 +4208,8 @@ public override Task AsEnumerable_over_string(bool async) async, async a => { await base.AsEnumerable_over_string(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["City"] FROM root c ORDER BY c["id"] @@ -4289,8 +4289,8 @@ public override async Task Throws_on_concurrent_query_first(bool async) if (async) { await base.Throws_on_concurrent_query_first(async); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c """); @@ -4302,8 +4302,8 @@ public override Task Entity_equality_through_include(bool async) async, async a => { await base.Entity_equality_through_include(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["id"] FROM root c WHERE (c["id"] = null) @@ -4352,8 +4352,8 @@ public override Task OrderBy_Select(bool async) async, async a => { await base.OrderBy_Select(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["ContactName"] FROM root c ORDER BY c["id"] @@ -4397,8 +4397,8 @@ public override Task ToList_over_string(bool async) async, async a => { await base.ToList_over_string(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["City"] FROM root c ORDER BY c["id"] @@ -4431,8 +4431,8 @@ public override Task ToListAsync_with_canceled_token() true, async _ => { await base.ToListAsync_with_canceled_token(); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c """); @@ -4460,8 +4460,8 @@ public override Task Entity_equality_orderby(bool async) async, async a => { await base.Entity_equality_orderby(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c ORDER BY c["id"] @@ -4473,8 +4473,8 @@ public override Task Load_should_track_results(bool async) async, async a => { await base.Load_should_track_results(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c """); @@ -4494,16 +4494,16 @@ public override Task Where_Property_shadow_closure(bool async) async, async a => { await base.Where_Property_shadow_closure(a); -AssertSql( - """ + AssertSql( + """ @__value_0='Sales Representative' SELECT VALUE c FROM root c WHERE (c["Title"] = @__value_0) """, - // - """ + // + """ @__value_0='Steven' SELECT VALUE c @@ -4547,8 +4547,8 @@ public override Task MemberInitExpression_NewExpression_is_funcletized_even_when async, async a => { await base.MemberInitExpression_NewExpression_is_funcletized_even_when_bindings_are_not_evaluatable(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["id"] FROM root c WHERE STARTSWITH(c["id"], "A") @@ -4608,8 +4608,8 @@ public override async Task Throws_on_concurrent_query_list(bool async) if (async) { await base.Throws_on_concurrent_query_list(async); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c """); @@ -4667,8 +4667,8 @@ public override Task OrderByDescending(bool async) async, async a => { await base.OrderByDescending(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["City"] FROM root c ORDER BY c["id"] DESC @@ -4964,8 +4964,8 @@ public override Task Contains_over_concatenated_columns_with_different_sizes(boo async, async a => { await base.Contains_over_concatenated_columns_with_different_sizes(a); -AssertSql( - """ + AssertSql( + """ @__data_0='["ALFKIAlfreds Futterkiste","ANATRAna Trujillo Emparedados y helados"]' SELECT VALUE c @@ -5003,8 +5003,8 @@ public override Task Contains_over_concatenated_column_and_parameter(bool async) async, async a => { await base.Contains_over_concatenated_column_and_parameter(a); -AssertSql( - """ + AssertSql( + """ @__data_1='["ALFKISomeVariable","ANATRSomeVariable","ALFKIX"]' @__someVariable_0='SomeVariable' @@ -5035,8 +5035,8 @@ public override Task Compiler_generated_local_closure_produces_valid_parameter_n async, async a => { await base.Compiler_generated_local_closure_produces_valid_parameter_name(a); -AssertSql( - """ + AssertSql( + """ @__customerId_0='ALFKI' @__details_City_1='Berlin' @@ -5220,13 +5220,13 @@ public virtual async Task ToPageAsync_with_exact_maxItemCount() Assert.Equal("ALFKI", onlyPage.Values[0].CustomerID); Assert.Equal("WOLZA", onlyPage.Values[^1].CustomerID); Assert.Null(onlyPage.ContinuationToken); -AssertSql( - """ + AssertSql( + """ SELECT VALUE COUNT(1) FROM root c """, - // - """ + // + """ SELECT VALUE c FROM root c ORDER BY c["id"] @@ -5244,8 +5244,8 @@ public virtual async Task ToPageAsync_does_not_use_ReadItem() Assert.Equal("ALFKI", onlyPage.Values[0].CustomerID); Assert.Null(onlyPage.ContinuationToken); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE (c["id"] = "ALFKI") diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindQueryCosmosFixture.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindQueryCosmosFixture.cs index 9ea50d1c564..d0d57c6d1d5 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindQueryCosmosFixture.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindQueryCosmosFixture.cs @@ -30,8 +30,9 @@ public void NoSyncTest(Action testCode) => CosmosTestHelpers.Instance.NoSyncTest(testCode); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) - => base.AddOptions(builder.ConfigureWarnings( - w => w.Ignore(CosmosEventId.NoPartitionKeyDefined))); + => base.AddOptions( + builder.ConfigureWarnings( + w => w.Ignore(CosmosEventId.NoPartitionKeyDefined))); protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs index 0a268f9aec9..3890ecec032 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs @@ -141,8 +141,8 @@ public override Task Projection_of_entity_type_into_object_array(bool async) async, async a => { await base.Projection_of_entity_type_into_object_array(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE STARTSWITH(c["id"], "A") @@ -163,8 +163,8 @@ public override Task Projection_of_entity_type_into_object_list(bool async) async, async a => { await base.Projection_of_entity_type_into_object_list(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c ORDER BY c["id"] @@ -230,8 +230,8 @@ public override Task Select_anonymous_one(bool async) async, async a => { await base.Select_anonymous_one(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["City"] FROM root c """); @@ -285,8 +285,8 @@ public override Task Select_anonymous_constant_in_expression(bool async) async, async a => { await base.Select_anonymous_constant_in_expression(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE { "CustomerID" : c["id"], @@ -332,8 +332,8 @@ public override Task Select_constant_int(bool async) async, async a => { await base.Select_constant_int(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE 0 FROM root c """); @@ -357,8 +357,8 @@ public override Task Select_local(bool async) async, async a => { await base.Select_local(a); -AssertSql( - """ + AssertSql( + """ @__x_0='10' SELECT VALUE @__x_0 @@ -387,8 +387,8 @@ public override Task Select_project_filter(bool async) async, async a => { await base.Select_project_filter(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["CompanyName"] FROM root c WHERE (c["City"] = "London") @@ -478,8 +478,8 @@ public override Task New_date_time_in_anonymous_type_works(bool async) async, async a => { await base.New_date_time_in_anonymous_type_works(a); -AssertSql( - """ + AssertSql( + """ SELECT 1 FROM root c WHERE STARTSWITH(c["id"], "A") @@ -952,8 +952,8 @@ public override Task Anonymous_projection_with_repeated_property_being_ordered(b async, async a => { await base.Anonymous_projection_with_repeated_property_being_ordered(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["id"] FROM root c ORDER BY c["id"] @@ -995,8 +995,8 @@ public override Task Client_method_in_projection_requiring_materialization_1(boo async, async a => { await base.Client_method_in_projection_requiring_materialization_1(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE STARTSWITH(c["id"], "A") @@ -1008,8 +1008,8 @@ public override Task Client_method_in_projection_requiring_materialization_2(boo async, async a => { await base.Client_method_in_projection_requiring_materialization_2(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE STARTSWITH(c["id"], "A") @@ -1400,8 +1400,8 @@ public override Task Projection_take_projection_doesnt_project_intermittent_colu async, async a => { await base.Projection_take_projection_doesnt_project_intermittent_column(a); -AssertSql( - """ + AssertSql( + """ @__p_0='10' SELECT VALUE ((c["id"] || " ") || c["City"]) @@ -1694,13 +1694,13 @@ public override Task Select_bool_closure(bool async) async, async a => { await base.Select_bool_closure(a); -AssertSql( - """ + AssertSql( + """ SELECT 1 FROM root c """, - // - """ + // + """ SELECT 1 FROM root c """); @@ -1824,8 +1824,8 @@ public override Task Select_anonymous_empty(bool async) async, async a => { await base.Select_anonymous_empty(a); -AssertSql( - """ + AssertSql( + """ SELECT 1 FROM root c """); @@ -1849,8 +1849,8 @@ public override Task Select_into(bool async) async, async a => { await base.Select_into(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c["id"] FROM root c WHERE (c["id"] = "ALFKI") @@ -1947,8 +1947,8 @@ public override Task Select_over_10_nested_ternary_condition(bool async) async, async a => { await base.Select_over_10_nested_ternary_condition(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE ((c["id"] = "1") ? "01" : ((c["id"] = "2") ? "02" : ((c["id"] = "3") ? "03" : ((c["id"] = "4") ? "04" : ((c["id"] = "5") ? "05" : ((c["id"] = "6") ? "06" : ((c["id"] = "7") ? "07" : ((c["id"] = "8") ? "08" : ((c["id"] = "9") ? "09" : ((c["id"] = "10") ? "10" : ((c["id"] = "11") ? "11" : null))))))))))) FROM root c """); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs index bbf6d938b00..682d5a9eaa2 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.Azure.Cosmos; using Microsoft.EntityFrameworkCore.Cosmos.Internal; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Xunit.Sdk; @@ -1455,8 +1454,8 @@ public override Task Where_is_not_null(bool async) async, async a => { await base.Where_is_not_null(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE (c["City"] != null) @@ -1482,8 +1481,8 @@ public override Task Where_constant_is_not_null(bool async) async, async a => { await base.Where_constant_is_not_null(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c """); @@ -1827,8 +1826,8 @@ public override Task Where_comparison_to_nullable_bool(bool async) async, async a => { await base.Where_comparison_to_nullable_bool(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE (ENDSWITH(c["id"], "KI") = true) @@ -1840,8 +1839,8 @@ public override Task Where_true(bool async) async, async a => { await base.Where_true(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c """); @@ -1953,7 +1952,7 @@ public override async Task Where_concat_string_int_comparison4(bool async) await AssertTranslationFailed(() => base.Where_concat_string_int_comparison4(async)); AssertSql( -); + ); } public override Task Where_string_concat_method_comparison(bool async) @@ -2234,7 +2233,7 @@ public override async Task Where_multiple_contains_in_subquery_with_or(bool asyn await AssertTranslationFailed(() => base.Where_multiple_contains_in_subquery_with_or(async)); AssertSql( -); + ); } public override async Task Where_multiple_contains_in_subquery_with_and(bool async) @@ -2528,7 +2527,7 @@ public override Task Filter_with_EF_Property_using_closure_for_property_name(boo await base.Filter_with_EF_Property_using_closure_for_property_name(a); AssertSql("ReadItem(None, ALFKI)"); - }); + }); public override Task Filter_with_EF_Property_using_function_for_property_name(bool async) => Fixture.NoSyncTest( @@ -2711,7 +2710,7 @@ public override async Task Where_Like_or_comparison(bool async) await AssertTranslationFailed(() => base.Where_Like_or_comparison(async)); AssertSql( -); + ); } public override Task GetType_on_non_hierarchy1(bool async) @@ -2760,8 +2759,8 @@ public override Task GetType_on_non_hierarchy4(bool async) async, async a => { await base.GetType_on_non_hierarchy4(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c """); @@ -2772,8 +2771,8 @@ public override Task Case_block_simplification_works_correctly(bool async) async, async a => { await base.Case_block_simplification_works_correctly(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE (((c["Region"] = null) ? "OR" : c["Region"]) = "OR") @@ -2857,8 +2856,8 @@ public override Task Generic_Ilist_contains_translates_to_server(bool async) async, async a => { await base.Generic_Ilist_contains_translates_to_server(a); -AssertSql( - """ + AssertSql( + """ @__cities_0='["Seattle"]' SELECT VALUE c @@ -2886,8 +2885,8 @@ public override Task Multiple_OrElse_on_same_column_with_null_constant_compariso async, async a => { await base.Multiple_OrElse_on_same_column_with_null_constant_comparison_converted_to_in(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE ((((c["Region"] = "WA") OR (c["Region"] = "OR")) OR (c["Region"] = null)) OR (c["Region"] = "BC")) @@ -2899,8 +2898,8 @@ public override Task Constant_array_Contains_OrElse_comparison_with_constant_get async, async a => { await base.Constant_array_Contains_OrElse_comparison_with_constant_gets_combined_to_one_in(a); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE (c["id"] IN ("ALFKI", "ANATR") OR (c["id"] = "ANTON")) @@ -3123,16 +3122,16 @@ public override Task Where_poco_closure(bool async) async, async a => { await base.Where_poco_closure(a); -AssertSql( - """ + AssertSql( + """ @__entity_equality_customer_0_CustomerID='ALFKI' SELECT VALUE c["id"] FROM root c WHERE (c["id"] = @__entity_equality_customer_0_CustomerID) """, - // - """ + // + """ @__entity_equality_customer_0_CustomerID='ANATR' SELECT VALUE c["id"] @@ -3184,8 +3183,8 @@ public override async Task EF_Constant_does_not_parameterized_as_part_of_bigger_ public override async Task EF_Constant_with_non_evaluatable_argument_throws(bool async) { await base.EF_Constant_with_non_evaluatable_argument_throws(async); -AssertSql( -); + AssertSql( + ); } public override Task EF_Parameter(bool async) diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs index 5a236b80163..bd0ccc93934 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs @@ -68,7 +68,8 @@ public override async Task Navigation_rewrite_on_owned_collection_with_compositi // Always throws for sync. if (async) { - var exception = await Assert.ThrowsAsync(() => base.Navigation_rewrite_on_owned_collection_with_composition(async)); + var exception = + await Assert.ThrowsAsync(() => base.Navigation_rewrite_on_owned_collection_with_composition(async)); Assert.Equal(HttpStatusCode.BadRequest, exception.StatusCode); @@ -269,12 +270,14 @@ await AssertTranslationFailedWithDetails( AssertSql(); } - public override async Task Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference_in_predicate_and_projection( - bool async) + public override async Task + Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference_in_predicate_and_projection( + bool async) { // Address.Planet is a non-owned navigation, cross-document join await AssertTranslationFailedWithDetails( - () => base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference_in_predicate_and_projection(async), + () => base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference_in_predicate_and_projection( + async), CosmosStrings.MultipleRootEntityTypesReferencedInQuery("Planet", "OwnedPerson")); AssertSql(); @@ -1337,8 +1340,9 @@ public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ServiceProvider.GetRequiredService(); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) - => base.AddOptions(builder.ConfigureWarnings( - w => w.Ignore(CosmosEventId.NoPartitionKeyDefined))); + => base.AddOptions( + builder.ConfigureWarnings( + w => w.Ignore(CosmosEventId.NoPartitionKeyDefined))); protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/PrimitiveCollectionsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/PrimitiveCollectionsQueryCosmosTest.cs index 6c9d017e956..587b9d29fe4 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/PrimitiveCollectionsQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/PrimitiveCollectionsQueryCosmosTest.cs @@ -377,10 +377,10 @@ public override Task Inline_collection_Max_with_three_values(bool async) => CosmosTestHelpers.Instance.NoSyncTest( async, async a => { - await base.Inline_collection_Max_with_three_values(a); + await base.Inline_collection_Max_with_three_values(a); - AssertSql( - """ + AssertSql( + """ @__i_0='35' SELECT VALUE c @@ -2092,8 +2092,9 @@ protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) - => base.AddOptions(builder.ConfigureWarnings( - w => w.Ignore(CosmosEventId.NoPartitionKeyDefined))); + => base.AddOptions( + builder.ConfigureWarnings( + w => w.Ignore(CosmosEventId.NoPartitionKeyDefined))); protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTest.cs index 57c42bbe0fd..26c7fc1a9fe 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTest.cs @@ -7,8 +7,9 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class QueryLoggingCosmosTest(QueryLoggingCosmosTest.NorthwindQueryCosmosFixtureInsensitive fixture) : QueryLoggingCosmosTestBase(fixture), - IClassFixture> +public class QueryLoggingCosmosTest(QueryLoggingCosmosTest.NorthwindQueryCosmosFixtureInsensitive fixture) + : QueryLoggingCosmosTestBase(fixture), + IClassFixture> { public class NorthwindQueryCosmosFixtureInsensitive : NorthwindQueryCosmosFixture where TModelCustomizer : ITestModelCustomizer, new() diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTestSensitive.cs b/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTestSensitive.cs index df562c4c1c6..e4ab578e139 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTestSensitive.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTestSensitive.cs @@ -5,5 +5,6 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class QueryLoggingCosmosTestSensitive(NorthwindQueryCosmosFixture fixture) : QueryLoggingCosmosTestBase(fixture), - IClassFixture>; +public class QueryLoggingCosmosTestSensitive(NorthwindQueryCosmosFixture fixture) + : QueryLoggingCosmosTestBase(fixture), + IClassFixture>; diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryDiscriminatorInIdTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryDiscriminatorInIdTest.cs index 6ad245a065f..7b16a7e4de1 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryDiscriminatorInIdTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryDiscriminatorInIdTest.cs @@ -393,8 +393,8 @@ FROM root c public override async Task ReadItem_with_WithPartitionKey_with_only_partition_key() { await base.ReadItem_with_WithPartitionKey_with_only_partition_key(); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE (c["$type"] IN ("OnlySinglePartitionKeyEntity", "DerivedOnlySinglePartitionKeyEntity") AND (c["PartitionKey"] = "PK1a")) @@ -414,7 +414,6 @@ FROM root c """); } - public override async Task Multiple_incompatible_predicate_comparisons_cause_no_ReadItem_with_only_partition_key() { await base.Multiple_incompatible_predicate_comparisons_cause_no_ReadItem_with_only_partition_key(); @@ -458,8 +457,8 @@ FROM root c public override async Task ReadItem_with_non_existent_id() { await base.ReadItem_with_non_existent_id(); -AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c WHERE (c["$type"] IN ("SinglePartitionKeyEntity", "DerivedSinglePartitionKeyEntity") AND (c["Id"] = 999)) @@ -520,7 +519,6 @@ public override async Task ReadItem_for_child_type_with_shared_container() AssertSql("""ReadItem(["PK2"], SharedContainerEntity2Child|5)"""); } - public override async Task Predicate_with_hierarchical_partition_key_leaf() { await base.Predicate_with_hierarchical_partition_key_leaf(); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryFixtureBase.cs b/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryFixtureBase.cs index d5896ffb670..b72b194f4bb 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryFixtureBase.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryFixtureBase.cs @@ -305,7 +305,7 @@ public virtual IQueryable Set() private static List CreateHierarchicalPartitionKeyEntities() => new() { - new() + new HierarchicalPartitionKeyEntity { Id = 1, PartitionKey1 = "PK1", @@ -313,7 +313,7 @@ private static List CreateHierarchicalPartitionK PartitionKey3 = true, Payload = "Payload1" }, - new() + new HierarchicalPartitionKeyEntity { Id = 1, PartitionKey1 = "PK2", @@ -321,7 +321,7 @@ private static List CreateHierarchicalPartitionK PartitionKey3 = false, Payload = "Payload2" }, - new() + new HierarchicalPartitionKeyEntity { Id = 2, PartitionKey1 = "PK1", @@ -329,7 +329,7 @@ private static List CreateHierarchicalPartitionK PartitionKey3 = true, Payload = "Payload3" }, - new() + new HierarchicalPartitionKeyEntity { Id = 2, PartitionKey1 = "PK2", @@ -342,25 +342,25 @@ private static List CreateHierarchicalPartitionK private static List CreateSinglePartitionKeyEntities() => new() { - new() + new SinglePartitionKeyEntity { Id = 1, PartitionKey = "PK1", Payload = "Payload1" }, - new() + new SinglePartitionKeyEntity { Id = 1, PartitionKey = "PK2", Payload = "Payload2" }, - new() + new SinglePartitionKeyEntity { Id = 2, PartitionKey = "PK1", Payload = "Payload3" }, - new() + new SinglePartitionKeyEntity { Id = 2, PartitionKey = "PK2", @@ -371,28 +371,28 @@ private static List CreateSinglePartitionKeyEntities() private static List CreateOnlyHierarchicalPartitionKeyEntities() => new() { - new() + new OnlyHierarchicalPartitionKeyEntity { PartitionKey1 = "PK1a", PartitionKey2 = 1, PartitionKey3 = true, Payload = "Payload1" }, - new() + new OnlyHierarchicalPartitionKeyEntity { PartitionKey1 = "PK2a", PartitionKey2 = 2, PartitionKey3 = false, Payload = "Payload2" }, - new() + new OnlyHierarchicalPartitionKeyEntity { PartitionKey1 = "PK1b", PartitionKey2 = 1, PartitionKey3 = true, Payload = "Payload3" }, - new() + new OnlyHierarchicalPartitionKeyEntity { PartitionKey1 = "PK2b", PartitionKey2 = 2, @@ -404,37 +404,40 @@ private static List CreateOnlyHierarchicalPa private static List CreateOnlySinglePartitionKeyEntities() => new() { - new() { PartitionKey = "PK1a", Payload = "Payload1" }, - new() { PartitionKey = "PK2a", Payload = "Payload2" }, - new() { PartitionKey = "PK1b", Payload = "Payload3" }, - new() { PartitionKey = "PK2b", Payload = "Payload4" } + new OnlySinglePartitionKeyEntity { PartitionKey = "PK1a", Payload = "Payload1" }, + new OnlySinglePartitionKeyEntity { PartitionKey = "PK2a", Payload = "Payload2" }, + new OnlySinglePartitionKeyEntity { PartitionKey = "PK1b", Payload = "Payload3" }, + new OnlySinglePartitionKeyEntity { PartitionKey = "PK2b", Payload = "Payload4" } }; private static List CreateNoPartitionKeyEntities() - => new() { new() { Id = 1, Payload = "Payload1" }, new() { Id = 2, Payload = "Payload2" } }; + => new() + { + new NoPartitionKeyEntity { Id = 1, Payload = "Payload1" }, new NoPartitionKeyEntity { Id = 2, Payload = "Payload2" } + }; private static List CreateSharedContainerEntities1() => new() { - new() + new SharedContainerEntity1 { Id = "1", PartitionKey = "PK1", Payload1 = "Payload1" }, - new() + new SharedContainerEntity1 { Id = "1", PartitionKey = "PK2", Payload1 = "Payload2" }, - new() + new SharedContainerEntity1 { Id = "2", PartitionKey = "PK1", Payload1 = "Payload3" }, - new() + new SharedContainerEntity1 { Id = "2", PartitionKey = "PK2", @@ -445,13 +448,13 @@ private static List CreateSharedContainerEntities1() private static List CreateSharedContainerEntities2() => new() { - new() + new SharedContainerEntity2 { Id = 4, PartitionKey = "PK1", Payload2 = "Payload4" }, - new() + new SharedContainerEntity2 { Id = 4, PartitionKey = "PK2", @@ -462,14 +465,14 @@ private static List CreateSharedContainerEntities2() private static List CreateSharedContainerEntities2Children() => new() { - new() + new SharedContainerEntity2Child { Id = 5, PartitionKey = "PK1", Payload2 = "Payload6", ChildPayload = "Child1" }, - new() + new SharedContainerEntity2Child { Id = 5, PartitionKey = "PK2", diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryInheritanceFixtureBase.cs b/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryInheritanceFixtureBase.cs index ecb401608a1..474d4737e25 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryInheritanceFixtureBase.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryInheritanceFixtureBase.cs @@ -31,7 +31,6 @@ public ReadItemPartitionKeyQueryInheritanceFixtureBase() ((DerivedSinglePartitionKeyEntity?)a)?.DerivedPayload); }); - asserters[typeof(DerivedOnlyHierarchicalPartitionKeyEntity)] = new Action( (e, a) => @@ -112,7 +111,8 @@ public override IQueryable Set() if (typeof(TEntity) == typeof(DerivedOnlyHierarchicalPartitionKeyEntity)) { - return (IQueryable)OnlyHierarchicalPartitionKeyEntities.OfType().AsQueryable(); + return (IQueryable)OnlyHierarchicalPartitionKeyEntities.OfType() + .AsQueryable(); } if (typeof(TEntity) == typeof(DerivedOnlySinglePartitionKeyEntity)) @@ -131,7 +131,7 @@ public override IQueryable Set() private static List CreateDerivedHierarchicalPartitionKeyEntities() => new() { - new() + new DerivedHierarchicalPartitionKeyEntity { Id = 11, PartitionKey1 = "PK1", @@ -140,7 +140,7 @@ private static List CreateDerivedHierarch Payload = "Payload1", DerivedPayload = "DerivedPayload1" }, - new() + new DerivedHierarchicalPartitionKeyEntity { Id = 11, PartitionKey1 = "PK2", @@ -149,7 +149,7 @@ private static List CreateDerivedHierarch Payload = "Payload2", DerivedPayload = "DerivedPayload2" }, - new() + new DerivedHierarchicalPartitionKeyEntity { Id = 22, PartitionKey1 = "PK1", @@ -158,7 +158,7 @@ private static List CreateDerivedHierarch Payload = "Payload3", DerivedPayload = "DerivedPayload3" }, - new() + new DerivedHierarchicalPartitionKeyEntity { Id = 22, PartitionKey1 = "PK2", @@ -172,28 +172,28 @@ private static List CreateDerivedHierarch private static List CreateDerivedSinglePartitionKeyEntities() => new() { - new() + new DerivedSinglePartitionKeyEntity { Id = 11, PartitionKey = "PK1", Payload = "Payload1", DerivedPayload = "DerivedPayload1" }, - new() + new DerivedSinglePartitionKeyEntity { Id = 11, PartitionKey = "PK2", Payload = "Payload2", DerivedPayload = "DerivedPayload2" }, - new() + new DerivedSinglePartitionKeyEntity { Id = 22, PartitionKey = "PK1", Payload = "Payload3", DerivedPayload = "DerivedPayload3" }, - new() + new DerivedSinglePartitionKeyEntity { Id = 22, PartitionKey = "PK2", @@ -205,7 +205,7 @@ private static List CreateDerivedSinglePartitio private static List CreateDerivedOnlyHierarchicalPartitionKeyEntities() => new() { - new() + new DerivedOnlyHierarchicalPartitionKeyEntity { PartitionKey1 = "PK1c", PartitionKey2 = 1, @@ -213,7 +213,7 @@ private static List CreateDerivedOnly Payload = "Payload1", DerivedPayload = "DerivedPayload1" }, - new() + new DerivedOnlyHierarchicalPartitionKeyEntity { PartitionKey1 = "PK2c", PartitionKey2 = 2, @@ -221,7 +221,7 @@ private static List CreateDerivedOnly Payload = "Payload2", DerivedPayload = "DerivedPayload2" }, - new() + new DerivedOnlyHierarchicalPartitionKeyEntity { PartitionKey1 = "PK1d", PartitionKey2 = 1, @@ -229,7 +229,7 @@ private static List CreateDerivedOnly Payload = "Payload3", DerivedPayload = "DerivedPayload3" }, - new() + new DerivedOnlyHierarchicalPartitionKeyEntity { PartitionKey1 = "PK2d", PartitionKey2 = 2, @@ -242,25 +242,25 @@ private static List CreateDerivedOnly private static List CreateDerivedOnlySinglePartitionKeyEntities() => new() { - new() + new DerivedOnlySinglePartitionKeyEntity { PartitionKey = "PK1c", Payload = "Payload1", DerivedPayload = "DerivedPayload1" }, - new() + new DerivedOnlySinglePartitionKeyEntity { PartitionKey = "PK2c", Payload = "Payload2", DerivedPayload = "DerivedPayload2" }, - new() + new DerivedOnlySinglePartitionKeyEntity { PartitionKey = "PK1d", Payload = "Payload3", DerivedPayload = "DerivedPayload3" }, - new() + new DerivedOnlySinglePartitionKeyEntity { PartitionKey = "PK2d", Payload = "Payload4", @@ -271,13 +271,13 @@ private static List CreateDerivedOnlySingle private static List CreateDerivedNoPartitionKeyEntities() => new() { - new() + new DerivedNoPartitionKeyEntity { Id = 11, Payload = "Payload1", DerivedPayload = "DerivedPayload1" }, - new() + new DerivedNoPartitionKeyEntity { Id = 22, Payload = "Payload2", diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryNoDiscriminatorInIdTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryNoDiscriminatorInIdTest.cs index 3257a0cb567..56bf7ee34cd 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryNoDiscriminatorInIdTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryNoDiscriminatorInIdTest.cs @@ -394,7 +394,6 @@ public override async Task ReadItem_for_child_type_with_shared_container() AssertSql("""ReadItem(["PK2"], 5)"""); } - public override async Task Predicate_with_hierarchical_partition_key_leaf() { await base.Predicate_with_hierarchical_partition_key_leaf(); @@ -757,6 +756,7 @@ public override async Task ReadItem_with_single_explicit_discriminator_mapping() AssertSql("""ReadItem(["PK1"], 1)"""); } + public override async Task ReadItem_with_single_explicit_incorrect_discriminator_mapping() { await base.ReadItem_with_single_explicit_incorrect_discriminator_mapping(); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryRootDiscriminatorInIdTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryRootDiscriminatorInIdTest.cs index ef9ddfb5cde..f87617a8687 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryRootDiscriminatorInIdTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryRootDiscriminatorInIdTest.cs @@ -320,7 +320,6 @@ FROM root c """); } - public override async Task Multiple_incompatible_predicate_comparisons_cause_no_ReadItem_with_only_partition_key() { await base.Multiple_incompatible_predicate_comparisons_cause_no_ReadItem_with_only_partition_key(); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryTest.cs index 8abdbf7796f..e0af34c54ac 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class ReadItemPartitionKeyQueryTest : ReadItemPartitionKeyQueryTestBase +public class ReadItemPartitionKeyQueryTest : ReadItemPartitionKeyQueryTestBase< + ReadItemPartitionKeyQueryTest.ReadItemPartitionKeyQueryFixture> { public ReadItemPartitionKeyQueryTest(ReadItemPartitionKeyQueryFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper) @@ -315,7 +316,6 @@ FROM root c """); } - public override async Task Multiple_incompatible_predicate_comparisons_cause_no_ReadItem_with_only_partition_key() { await base.Multiple_incompatible_predicate_comparisons_cause_no_ReadItem_with_only_partition_key(); diff --git a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/CompiledModelCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/CompiledModelCosmosTest.cs index 7b2e808bca4..26eb930ce0c 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Scaffolding/CompiledModelCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Scaffolding/CompiledModelCosmosTest.cs @@ -60,7 +60,7 @@ public virtual Task Basic_cosmos_model() Assert.Equal(ValueGenerated.Never, id.ValueGenerated); Assert.Equal(PropertySaveBehavior.Throw, id.GetAfterSaveBehavior()); Assert.Equal(PropertySaveBehavior.Save, id.GetBeforeSaveBehavior()); - Assert.Equal("Id", CosmosPropertyExtensions.GetJsonPropertyName(id)); + Assert.Equal("Id", id.GetJsonPropertyName()); Assert.Null(id.GetValueGeneratorFactory()); Assert.Null(id.GetValueConverter()); Assert.NotNull(id.GetValueComparer()); @@ -75,7 +75,7 @@ public virtual Task Basic_cosmos_model() Assert.Equal(ValueGenerated.Never, storeId.ValueGenerated); Assert.Equal(PropertySaveBehavior.Throw, storeId.GetAfterSaveBehavior()); Assert.Equal(PropertySaveBehavior.Save, storeId.GetBeforeSaveBehavior()); - Assert.Equal("id", CosmosPropertyExtensions.GetJsonPropertyName(storeId)); + Assert.Equal("id", storeId.GetJsonPropertyName()); Assert.IsType(storeId.GetValueGeneratorFactory()!(storeId, dataEntity)); Assert.Null(storeId.GetValueConverter()); Assert.NotNull(storeId.GetValueComparer()); @@ -90,7 +90,7 @@ public virtual Task Basic_cosmos_model() Assert.Equal(ValueGenerated.Never, partitionId.ValueGenerated); Assert.Equal(PropertySaveBehavior.Throw, partitionId.GetAfterSaveBehavior()); Assert.Equal(PropertySaveBehavior.Save, partitionId.GetBeforeSaveBehavior()); - Assert.Equal("PartitionId", CosmosPropertyExtensions.GetJsonPropertyName(partitionId)); + Assert.Equal("PartitionId", partitionId.GetJsonPropertyName()); Assert.Null(partitionId.GetValueGeneratorFactory()); Assert.Null(partitionId.GetValueConverter()); Assert.Equal("1", partitionId.FindTypeMapping()!.Converter!.ConvertToProvider(1)); @@ -107,7 +107,7 @@ public virtual Task Basic_cosmos_model() Assert.Equal(ValueGenerated.Never, map.ValueGenerated); Assert.Equal(PropertySaveBehavior.Save, map.GetAfterSaveBehavior()); Assert.Equal(PropertySaveBehavior.Save, map.GetBeforeSaveBehavior()); - Assert.Equal("Map", CosmosPropertyExtensions.GetJsonPropertyName(map)); + Assert.Equal("Map", map.GetJsonPropertyName()); Assert.Null(map.GetValueGeneratorFactory()); Assert.Null(map.GetValueConverter()); Assert.NotNull(map.GetValueComparer()); @@ -123,7 +123,7 @@ public virtual Task Basic_cosmos_model() Assert.Equal(ValueGenerated.Never, list.ValueGenerated); Assert.Equal(PropertySaveBehavior.Save, list.GetAfterSaveBehavior()); Assert.Equal(PropertySaveBehavior.Save, list.GetBeforeSaveBehavior()); - Assert.Equal("List", CosmosPropertyExtensions.GetJsonPropertyName(list)); + Assert.Equal("List", list.GetJsonPropertyName()); Assert.Null(list.GetValueGeneratorFactory()); Assert.Null(list.GetValueConverter()); Assert.NotNull(list.GetValueComparer()); @@ -139,7 +139,7 @@ public virtual Task Basic_cosmos_model() Assert.Equal(ValueGenerated.Never, bytes.ValueGenerated); Assert.Equal(PropertySaveBehavior.Save, bytes.GetAfterSaveBehavior()); Assert.Equal(PropertySaveBehavior.Save, bytes.GetBeforeSaveBehavior()); - Assert.Equal("Bytes", CosmosPropertyExtensions.GetJsonPropertyName(bytes)); + Assert.Equal("Bytes", bytes.GetJsonPropertyName()); Assert.Null(bytes.GetValueGeneratorFactory()); Assert.Null(bytes.GetValueConverter()); Assert.NotNull(bytes.GetValueComparer()); @@ -154,7 +154,7 @@ public virtual Task Basic_cosmos_model() Assert.Equal(ValueGenerated.OnAddOrUpdate, eTag.ValueGenerated); Assert.Equal(PropertySaveBehavior.Ignore, eTag.GetAfterSaveBehavior()); Assert.Equal(PropertySaveBehavior.Ignore, eTag.GetBeforeSaveBehavior()); - Assert.Equal("_etag", CosmosPropertyExtensions.GetJsonPropertyName(eTag)); + Assert.Equal("_etag", eTag.GetJsonPropertyName()); Assert.Null(eTag.GetValueGeneratorFactory()); Assert.Null(eTag.GetValueConverter()); Assert.NotNull(eTag.GetValueComparer()); @@ -171,7 +171,7 @@ public virtual Task Basic_cosmos_model() Assert.Equal(ValueGenerated.Never, blob.ValueGenerated); Assert.Equal(PropertySaveBehavior.Save, blob.GetAfterSaveBehavior()); Assert.Equal(PropertySaveBehavior.Save, blob.GetBeforeSaveBehavior()); - Assert.Equal("JsonBlob", CosmosPropertyExtensions.GetJsonPropertyName(blob)); + Assert.Equal("JsonBlob", blob.GetJsonPropertyName()); Assert.Null(blob.GetValueGeneratorFactory()); Assert.Null(blob.GetValueConverter()); Assert.NotNull(blob.GetValueComparer()); @@ -186,7 +186,7 @@ public virtual Task Basic_cosmos_model() Assert.Equal(ValueGenerated.OnAddOrUpdate, jObject.ValueGenerated); Assert.Equal(PropertySaveBehavior.Ignore, jObject.GetAfterSaveBehavior()); Assert.Equal(PropertySaveBehavior.Ignore, jObject.GetBeforeSaveBehavior()); - Assert.Equal("", CosmosPropertyExtensions.GetJsonPropertyName(jObject)); + Assert.Equal("", jObject.GetJsonPropertyName()); Assert.Null(jObject.GetValueGeneratorFactory()); Assert.Null(jObject.GetValueConverter()); Assert.NotNull(jObject.GetValueComparer()); @@ -218,7 +218,6 @@ protected override void BuildBigModel(ModelBuilder modelBuilder, bool jsonColumn b.Ignore(e => e.RefTypeArray); b.Ignore(e => e.RefTypeList); }); - }); modelBuilder.Entity>>( @@ -350,13 +349,13 @@ protected override void BuildComplexTypesModel(ModelBuilder modelBuilder) { b.Ignore(e => e.RefTypeArray); b.Ignore(e => e.RefTypeList); - b.ComplexProperty(c => c.Principal, b => - { - b.Ignore(e => e.RefTypeList); - b.Ignore(e => e.RefTypeArray); - }); + b.ComplexProperty( + c => c.Principal, b => + { + b.Ignore(e => e.RefTypeList); + b.Ignore(e => e.RefTypeArray); + }); }); - }); } @@ -371,8 +370,11 @@ protected override void AssertBigModel(IModel model, bool jsonColumns) protected override int ExpectedComplexTypeProperties => 12; - protected override TestHelpers TestHelpers => CosmosTestHelpers.Instance; - protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; + protected override TestHelpers TestHelpers + => CosmosTestHelpers.Instance; + + protected override ITestStoreFactory TestStoreFactory + => CosmosTestStoreFactory.Instance; protected override BuildSource AddReferences(BuildSource build, [CallerFilePath] string filePath = "") { diff --git a/test/EFCore.Cosmos.FunctionalTests/Storage/CosmosDatabaseCreatorTest.cs b/test/EFCore.Cosmos.FunctionalTests/Storage/CosmosDatabaseCreatorTest.cs index e9f9bb666cb..dc683d4121d 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Storage/CosmosDatabaseCreatorTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Storage/CosmosDatabaseCreatorTest.cs @@ -92,8 +92,9 @@ public async Task EnsureCreated_throws_for_missing_seed() await using var testDatabase = await CosmosTestStore.CreateInitializedAsync("EnsureCreatedSeedTest"); using var context = new BloggingContext(testDatabase, seed: true); - Assert.Equal(CoreStrings.MissingSeeder, - (await Assert.ThrowsAsync(() => context.Database.EnsureCreatedAsync())).Message); + Assert.Equal( + CoreStrings.MissingSeeder, + (await Assert.ThrowsAsync(() => context.Database.EnsureCreatedAsync())).Message); } private class BloggingContext(CosmosTestStore testStore, bool seed = false) : DbContext diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosConditionAttribute.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosConditionAttribute.cs index 44613056a6a..e1448e20ee2 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosConditionAttribute.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosConditionAttribute.cs @@ -29,10 +29,10 @@ public ValueTask IsMetAsync() public string SkipReason => string.Format( - "The test Cosmos account does not meet these conditions: '{0}'", - string.Join( - ", ", Enum.GetValues(typeof(CosmosCondition)) - .Cast() - .Where(Conditions.HasFlag) - .Select(f => Enum.GetName(typeof(CosmosCondition), f)))); + "The test Cosmos account does not meet these conditions: '{0}'", + string.Join( + ", ", Enum.GetValues(typeof(CosmosCondition)) + .Cast() + .Where(Conditions.HasFlag) + .Select(f => Enum.GetName(typeof(CosmosCondition), f)))); } diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosModelAsserter.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosModelAsserter.cs index 5c7830ae316..6624496d805 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosModelAsserter.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosModelAsserter.cs @@ -11,7 +11,7 @@ protected CosmosModelAsserter() { } - public new static CosmosModelAsserter Instance { get; } = new(); + public static new CosmosModelAsserter Instance { get; } = new(); public override void AssertEqual( IEnumerable expectedProperties, diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestHelpers.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestHelpers.cs index 4c5f87d3681..74ddb55fdca 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestHelpers.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestHelpers.cs @@ -2,8 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.EntityFrameworkCore.Cosmos.Diagnostics.Internal; -// ReSharper disable once CheckNamespace using Microsoft.EntityFrameworkCore.Cosmos.Internal; +// ReSharper disable once CheckNamespace namespace Microsoft.EntityFrameworkCore.TestUtilities; @@ -23,14 +23,14 @@ public override IServiceCollection AddProviderServices(IServiceCollection servic public override DbContextOptionsBuilder UseProviderOptions(DbContextOptionsBuilder optionsBuilder) => TestEnvironment.UseTokenCredential - ? optionsBuilder.UseCosmos( - TestEnvironment.DefaultConnection, - TestEnvironment.TokenCredential, - "UnitTests") - : optionsBuilder.UseCosmos( - TestEnvironment.DefaultConnection, - TestEnvironment.AuthToken, - "UnitTests"); + ? optionsBuilder.UseCosmos( + TestEnvironment.DefaultConnection, + TestEnvironment.TokenCredential, + "UnitTests") + : optionsBuilder.UseCosmos( + TestEnvironment.DefaultConnection, + TestEnvironment.AuthToken, + "UnitTests"); private static readonly string SyncMessage = CoreStrings.WarningAsErrorTemplate( diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs index dc940a3ef9b..4b2c755da80 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs @@ -89,8 +89,8 @@ protected override DbContext CreateDefaultContext() public override DbContextOptionsBuilder AddProviderOptions(DbContextOptionsBuilder builder) => TestEnvironment.UseTokenCredential - ? builder.UseCosmos(ConnectionUri, TokenCredential, Name, _configureCosmos) - : builder.UseCosmos(ConnectionUri, AuthToken, Name, _configureCosmos); + ? builder.UseCosmos(ConnectionUri, TokenCredential, Name, _configureCosmos) + : builder.UseCosmos(ConnectionUri, AuthToken, Name, _configureCosmos); public static async ValueTask IsConnectionAvailableAsync() { @@ -253,7 +253,8 @@ public async Task EnsureCreatedAsync(DbContext context, CancellationToken var databaseAccount = await GetDBAccount(cancellationToken).ConfigureAwait(false); var collection = databaseAccount.Value.GetCosmosDBSqlDatabases(); - var sqlDatabaseCreateUpdateOptions = new CosmosDBSqlDatabaseCreateOrUpdateContent(TestEnvironment.AzureLocation, + var sqlDatabaseCreateUpdateOptions = new CosmosDBSqlDatabaseCreateOrUpdateContent( + TestEnvironment.AzureLocation, new CosmosDBSqlDatabaseResourceInfo(Name)); if (await collection.ExistsAsync(Name, cancellationToken)) { @@ -281,7 +282,8 @@ private async Task EnsureDeletedAsync(DbContext context, CancellationToken return false; } - var databaseResponse = (await database.Value!.DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false)).GetRawResponse(); + var databaseResponse = (await database.Value!.DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false)) + .GetRawResponse(); return databaseResponse.Status == (int)HttpStatusCode.OK; } @@ -344,16 +346,14 @@ private async Task CreateContainersAsync(DbContext context) { AnalyticalStorageTtl = container.AnalyticalStoreTimeToLiveInSeconds, DefaultTtl = container.DefaultTimeToLive, - PartitionKey = new CosmosDBContainerPartitionKey - { - Version = 2 - } + PartitionKey = new CosmosDBContainerPartitionKey { Version = 2 } }; if (container.PartitionKeyStoreNames.Count > 1) { resource.PartitionKey.Kind = "MultiHash"; } + foreach (var partitionKey in container.PartitionKeyStoreNames) { resource.PartitionKey.Paths.Add("/" + partitionKey); @@ -407,6 +407,7 @@ await database.Value.GetCosmosDBSqlContainers().CreateOrUpdateAsync( { partitionKeyStoreNames = GetPartitionKeyStoreNames(entityType); } + analyticalTtl ??= entityType.GetAnalyticalStoreTimeToLive(); defaultTtl ??= entityType.GetDefaultTimeToLive(); throughput ??= entityType.GetThroughput(); @@ -422,7 +423,7 @@ await database.Value.GetCosmosDBSqlContainers().CreateOrUpdateAsync( } #pragma warning restore EF9103 - yield return new( + yield return new Cosmos.Storage.Internal.ContainerProperties( containerName, partitionKeyStoreNames, analyticalTtl, @@ -538,7 +539,8 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { if (TestEnvironment.UseTokenCredential) { - optionsBuilder.UseCosmos(_testStore.ConnectionUri, _testStore.TokenCredential, _testStore.Name, _testStore._configureCosmos); + optionsBuilder.UseCosmos( + _testStore.ConnectionUri, _testStore.TokenCredential, _testStore.Name, _testStore._configureCosmos); } else { diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs index 261ba0b4ae0..81865e869dd 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs @@ -28,9 +28,7 @@ public TestSqlLoggerFactory() public TestSqlLoggerFactory(Func shouldLogCategory) : base(c => shouldLogCategory(c) || c == DbLoggerCategory.Database.Command.Name) - { - Logger = new TestSqlLogger(); - } + => Logger = new TestSqlLogger(); public IReadOnlyList SqlStatements => ((TestSqlLogger)Logger).SqlStatements; diff --git a/test/EFCore.Cosmos.FunctionalTests/ValueConvertersEndToEndCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/ValueConvertersEndToEndCosmosTest.cs index c4c50a518d7..98f9f14bc1b 100644 --- a/test/EFCore.Cosmos.FunctionalTests/ValueConvertersEndToEndCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/ValueConvertersEndToEndCosmosTest.cs @@ -3,8 +3,6 @@ namespace Microsoft.EntityFrameworkCore; -#nullable enable - public class ValueConvertersEndToEndCosmosTest(ValueConvertersEndToEndCosmosTest.ValueConvertersEndToEndCosmosFixture fixture) : ValueConvertersEndToEndTestBase(fixture) { diff --git a/test/EFCore.Cosmos.FunctionalTests/VectorSearchCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/VectorSearchCosmosTest.cs index c67ca8c3cba..9fa850f7eb4 100644 --- a/test/EFCore.Cosmos.FunctionalTests/VectorSearchCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/VectorSearchCosmosTest.cs @@ -213,8 +213,7 @@ await Assert.ThrowsAsync( // Assert.Equal(3, booksFromStore.Count); - AssertSql( -); + AssertSql(); } [ConditionalFact] @@ -384,7 +383,7 @@ protected override Task SeedAsync(PoolableDbContext context) NestedOwned = new Owned2 { Prop = "7" }, NestedOwnedCollection = new List { new() { Prop = "71" }, new() { Prop = "72" } } }, - OwnedCollection = new List { new Owned1 { Prop = 71 }, new Owned1 { Prop = 72 } } + OwnedCollection = new List { new() { Prop = 71 }, new() { Prop = 72 } } }; var book2 = new Book @@ -404,7 +403,7 @@ protected override Task SeedAsync(PoolableDbContext context) NestedOwned = new Owned2 { Prop = "7" }, NestedOwnedCollection = new List { new() { Prop = "71" }, new() { Prop = "72" } } }, - OwnedCollection = new List { new Owned1 { Prop = 71 }, new Owned1 { Prop = 72 } } + OwnedCollection = new List { new() { Prop = 71 }, new() { Prop = 72 } } }; var book3 = new Book @@ -424,7 +423,7 @@ protected override Task SeedAsync(PoolableDbContext context) NestedOwned = new Owned2 { Prop = "7" }, NestedOwnedCollection = new List { new() { Prop = "71" }, new() { Prop = "72" } } }, - OwnedCollection = new List { new Owned1 { Prop = 71 }, new Owned1 { Prop = 72 } } + OwnedCollection = new List { new() { Prop = 71 }, new() { Prop = 72 } } }; context.AddRange(book1, book2, book3); diff --git a/test/EFCore.Cosmos.Tests/Extensions/CosmosMetadataExtensionsTest.cs b/test/EFCore.Cosmos.Tests/Extensions/CosmosMetadataExtensionsTest.cs index e9cb25f25f9..7e6d8ba36bf 100644 --- a/test/EFCore.Cosmos.Tests/Extensions/CosmosMetadataExtensionsTest.cs +++ b/test/EFCore.Cosmos.Tests/Extensions/CosmosMetadataExtensionsTest.cs @@ -110,7 +110,7 @@ public void Can_get_and_set_hierarchical_partition_key_name() Assert.Null(((IConventionEntityType)entityType).GetPartitionKeyPropertyNamesConfigurationSource()); } - [ConditionalFact] + [ConditionalFact] public void Can_get_and_set_etag_name() { var modelBuilder = CreateModelBuilder(); diff --git a/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs b/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs index 37526b77314..252061170d1 100644 --- a/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs +++ b/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs @@ -194,10 +194,17 @@ public virtual void Detects_missing_partition_keys_one_last_type() public virtual void Detects_missing_partition_key_properties_composite_less_first() { var modelBuilder = CreateConventionModelBuilder(); - modelBuilder.Entity().ToContainer("Orders").HasPartitionKey(c => new { c.PartitionId, c.Id, c.Name }); + modelBuilder.Entity().ToContainer("Orders").HasPartitionKey( + c => new + { + c.PartitionId, + c.Id, + c.Name + }); modelBuilder.Entity().ToContainer("Orders").HasPartitionKey(c => new { c.PartitionId, c.Id }); - VerifyError(CosmosStrings.NoPartitionKey(nameof(Customer), "PartitionId,Id,Name", nameof(Order), "PartitionId,Id", "Orders"), modelBuilder); + VerifyError( + CosmosStrings.NoPartitionKey(nameof(Customer), "PartitionId,Id,Name", nameof(Order), "PartitionId,Id", "Orders"), modelBuilder); } [ConditionalFact] @@ -223,7 +230,8 @@ public virtual void Detects_missing_partition_key_properties_composite_three() b.ToContainer("Orders").HasPartitionKey(c => new { c.OrderId }); }); - VerifyError(CosmosStrings.NoPartitionKey(nameof(Customer), "PartitionId,Id", nameof(OrderProduct), "OrderId", "Orders"), modelBuilder); + VerifyError( + CosmosStrings.NoPartitionKey(nameof(Customer), "PartitionId,Id", nameof(OrderProduct), "OrderId", "Orders"), modelBuilder); } [ConditionalFact] @@ -365,11 +373,12 @@ public virtual void Detects_owned_type_mapped_to_a_container() var modelBuilder = CreateConventionModelBuilder(); modelBuilder.Entity(); modelBuilder.Entity( - ob => ob.OwnsOne(o => o.OrderDetails, b => - { - b.Property(CosmosJsonIdConvention.DefaultIdPropertyName) - .ToJsonProperty(CosmosJsonIdConvention.IdPropertyJsonName); - })); + ob => ob.OwnsOne( + o => o.OrderDetails, b => + { + b.Property(CosmosJsonIdConvention.DefaultIdPropertyName) + .ToJsonProperty(CosmosJsonIdConvention.IdPropertyJsonName); + })); modelBuilder.Model .GetEntityTypes() @@ -497,7 +506,6 @@ public virtual void Detects_vector_index_on_non_vector_property() } #pragma warning restore EF9103 - [ConditionalFact] public virtual void Detects_vector_property_with_unknown_data_type() { @@ -525,10 +533,11 @@ public virtual void Detects_unmappable_property() var modelBuilder = CreateConventionModelBuilder(); modelBuilder.Entity>>().ToContainer("Orders"); - VerifyError(CoreStrings.PropertyNotAdded( - typeof(RememberMyName>).ShortDisplayName(), - nameof(RememberMyName.ForgetMeNot), - typeof(Memory).ShortDisplayName()), modelBuilder); + VerifyError( + CoreStrings.PropertyNotAdded( + typeof(RememberMyName>).ShortDisplayName(), + nameof(RememberMyName.ForgetMeNot), + typeof(Memory).ShortDisplayName()), modelBuilder); } [ConditionalFact] @@ -537,10 +546,11 @@ public virtual void Detects_unmappable_list_property() var modelBuilder = CreateConventionModelBuilder(); modelBuilder.Entity[]>>().ToContainer("Orders"); - VerifyError(CoreStrings.PropertyNotAdded( - typeof(RememberMyName[]>).ShortDisplayName(), - nameof(RememberMyName.ForgetMeNot), - typeof(Memory[]).ShortDisplayName()), modelBuilder); + VerifyError( + CoreStrings.PropertyNotAdded( + typeof(RememberMyName[]>).ShortDisplayName(), + nameof(RememberMyName.ForgetMeNot), + typeof(Memory[]).ShortDisplayName()), modelBuilder); } private class RememberMyName diff --git a/test/EFCore.Cosmos.Tests/Storage/Internal/CosmosTypeMappingSourceTest.cs b/test/EFCore.Cosmos.Tests/Storage/Internal/CosmosTypeMappingSourceTest.cs index 67e2e2196a0..7b850e7e39a 100644 --- a/test/EFCore.Cosmos.Tests/Storage/Internal/CosmosTypeMappingSourceTest.cs +++ b/test/EFCore.Cosmos.Tests/Storage/Internal/CosmosTypeMappingSourceTest.cs @@ -68,15 +68,19 @@ public void Can_map_DateOnly() [ConditionalFact] public void Can_map_TimeOnly() - => Can_map_scalar_by_clr_type(new TimeOnly(20, 19, 12, 254), JTokenType.String, "\"20:19:12.254\""); + => Can_map_scalar_by_clr_type( + new TimeOnly(20, 19, 12, 254), JTokenType.String, "\"20:19:12.254\""); [ConditionalFact] public void Can_map_DateTime() - => Can_map_scalar_by_clr_type(new DateTime(2003, 12, 25, 20, 19, 12, 254), JTokenType.Date, "\"2003-12-25T20:19:12.254\""); + => Can_map_scalar_by_clr_type( + new DateTime(2003, 12, 25, 20, 19, 12, 254), JTokenType.Date, "\"2003-12-25T20:19:12.254\""); [ConditionalFact] public void Can_map_DateTimeOffset() - => Can_map_scalar_by_clr_type(new DateTimeOffset(2003, 12, 25, 20, 19, 12, 254, new TimeSpan(4, 30, 0)), JTokenType.Date, "\"2003-12-25T20:19:12.254+04:30\"", "DefaultDateTimeOffsetValueComparer"); + => Can_map_scalar_by_clr_type( + new DateTimeOffset(2003, 12, 25, 20, 19, 12, 254, new TimeSpan(4, 30, 0)), JTokenType.Date, "\"2003-12-25T20:19:12.254+04:30\"", + "DefaultDateTimeOffsetValueComparer"); [ConditionalFact] public void Can_map_TimeSpan() @@ -144,15 +148,19 @@ public void Can_map_nullable_DateOnly() [ConditionalFact] public void Can_map_nullable_TimeOnly() - => Can_map_scalar_by_clr_type(new TimeOnly(20, 19, 12, 254), JTokenType.String, "\"20:19:12.254\""); + => Can_map_scalar_by_clr_type( + new TimeOnly(20, 19, 12, 254), JTokenType.String, "\"20:19:12.254\""); [ConditionalFact] public void Can_map_nullable_DateTime() - => Can_map_scalar_by_clr_type(new DateTime(2003, 12, 25, 20, 19, 12, 254), JTokenType.Date, "\"2003-12-25T20:19:12.254\""); + => Can_map_scalar_by_clr_type( + new DateTime(2003, 12, 25, 20, 19, 12, 254), JTokenType.Date, "\"2003-12-25T20:19:12.254\""); [ConditionalFact] public void Can_map_nullable_DateTimeOffset() - => Can_map_scalar_by_clr_type(new DateTimeOffset(2003, 12, 25, 20, 19, 12, 254, new TimeSpan(4, 30, 0)), JTokenType.Date, "\"2003-12-25T20:19:12.254+04:30\"", "DefaultDateTimeOffsetValueComparer"); + => Can_map_scalar_by_clr_type( + new DateTimeOffset(2003, 12, 25, 20, 19, 12, 254, new TimeSpan(4, 30, 0)), JTokenType.Date, "\"2003-12-25T20:19:12.254+04:30\"", + "DefaultDateTimeOffsetValueComparer"); [ConditionalFact] public void Can_map_nullable_TimeSpan() @@ -209,78 +217,88 @@ public void Can_map_byte_array() [ConditionalFact] public void Can_map_sbyte_array() => Can_map_collection_by_clr_type>( - [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer", "ValueComparer", "ValueComparer" ); + [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer", "ValueComparer", + "ValueComparer"); [ConditionalFact] public void Can_map_short_array() => Can_map_collection_by_clr_type>( - [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer", "ValueComparer", "ValueComparer" ); + [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer", "ValueComparer", + "ValueComparer"); [ConditionalFact] public void Can_map_int_array() => Can_map_collection_by_clr_type>( - [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer", "ValueComparer", "ValueComparer" ); + [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer", "ValueComparer", "ValueComparer"); [ConditionalFact] public void Can_map_long_array() => Can_map_collection_by_clr_type>( - [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer", "ValueComparer", "ValueComparer" ); + [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer", "ValueComparer", "ValueComparer"); [ConditionalFact] public void Can_map_ushort_array() => Can_map_collection_by_clr_type>( - [1, 2, 3, 4, 5], "[1,2,3,4,5]", "ListOfValueTypesComparer", "ValueComparer", "ValueComparer" ); + [1, 2, 3, 4, 5], "[1,2,3,4,5]", "ListOfValueTypesComparer", "ValueComparer", + "ValueComparer"); [ConditionalFact] public void Can_map_uint_array() => Can_map_collection_by_clr_type>( - [1, 2, 3, 4, 5], "[1,2,3,4,5]", "ListOfValueTypesComparer", "ValueComparer", "ValueComparer" ); + [1, 2, 3, 4, 5], "[1,2,3,4,5]", "ListOfValueTypesComparer", "ValueComparer", "ValueComparer"); [ConditionalFact] public void Can_map_ulong_array() => Can_map_collection_by_clr_type>( - [1, 2, 3, 4, 5], "[1,2,3,4,5]", "ListOfValueTypesComparer", "ValueComparer", "ValueComparer" ); - + [1, 2, 3, 4, 5], "[1,2,3,4,5]", "ListOfValueTypesComparer", "ValueComparer", "ValueComparer"); [ConditionalFact] public void Can_map_sbyte_list() => Can_map_collection_by_clr_type, sbyte, JsonCollectionOfStructsReaderWriter, sbyte>>( - [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer, sbyte>", "ValueComparer>", "ValueComparer>" ); + [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer, sbyte>", "ValueComparer>", + "ValueComparer>"); [ConditionalFact] public void Can_map_short_list() => Can_map_collection_by_clr_type, short, JsonCollectionOfStructsReaderWriter, short>>( - [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer, short>", "ValueComparer>", "ValueComparer>" ); + [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer, short>", "ValueComparer>", + "ValueComparer>"); [ConditionalFact] public void Can_map_int_list() => Can_map_collection_by_clr_type, int, JsonCollectionOfStructsReaderWriter, int>>( - [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer, int>", "ValueComparer>", "ValueComparer>" ); + [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer, int>", "ValueComparer>", + "ValueComparer>"); [ConditionalFact] public void Can_map_long_list() => Can_map_collection_by_clr_type, long, JsonCollectionOfStructsReaderWriter, long>>( - [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer, long>", "ValueComparer>", "ValueComparer>" ); + [1, -2, 3, -4, 5], "[1,-2,3,-4,5]", "ListOfValueTypesComparer, long>", "ValueComparer>", + "ValueComparer>"); [ConditionalFact] public void Can_map_byte_list() => Can_map_collection_by_clr_type, byte, JsonCollectionOfStructsReaderWriter, byte>>( - [1, 2, 3, 4, 5], "[1,2,3,4,5]", "ListOfValueTypesComparer, byte>", "ValueComparer>", "ValueComparer>" ); + [1, 2, 3, 4, 5], "[1,2,3,4,5]", "ListOfValueTypesComparer, byte>", "ValueComparer>", + "ValueComparer>"); [ConditionalFact] public void Can_map_ushort_list() => Can_map_collection_by_clr_type, ushort, JsonCollectionOfStructsReaderWriter, ushort>>( - [1, 2, 3, 4, 5], "[1,2,3,4,5]", "ListOfValueTypesComparer, ushort>", "ValueComparer>", "ValueComparer>" ); + [1, 2, 3, 4, 5], "[1,2,3,4,5]", "ListOfValueTypesComparer, ushort>", "ValueComparer>", + "ValueComparer>"); [ConditionalFact] public void Can_map_uint_list() => Can_map_collection_by_clr_type, uint, JsonCollectionOfStructsReaderWriter, uint>>( - [1, 2, 3, 4, 5], "[1,2,3,4,5]", "ListOfValueTypesComparer, uint>", "ValueComparer>", "ValueComparer>" ); + [1, 2, 3, 4, 5], "[1,2,3,4,5]", "ListOfValueTypesComparer, uint>", "ValueComparer>", + "ValueComparer>"); [ConditionalFact] public void Can_map_ulong_list() => Can_map_collection_by_clr_type, ulong, JsonCollectionOfStructsReaderWriter, ulong>>( - [1, 2, 3, 4, 5], "[1,2,3,4,5]", "ListOfValueTypesComparer, ulong>", "ValueComparer>", "ValueComparer>" ); + [1, 2, 3, 4, 5], "[1,2,3,4,5]", "ListOfValueTypesComparer, ulong>", "ValueComparer>", + "ValueComparer>"); private void Can_map_collection_by_clr_type( TCollection value, @@ -382,19 +400,19 @@ protected IModel CreateModel() protected CoreTypeMapping GetTypeMapping(Type propertyType, bool? nullable = null) { - var modelBuilder = CreateModelBuilder(); - var entityType = modelBuilder.Entity(); - entityType.Property(e => e.Id); - var property = entityType.Property(propertyType, "MyProp").Metadata; + var modelBuilder = CreateModelBuilder(); + var entityType = modelBuilder.Entity(); + entityType.Property(e => e.Id); + var property = entityType.Property(propertyType, "MyProp").Metadata; - if (nullable.HasValue) - { - property.IsNullable = nullable.Value; - } + if (nullable.HasValue) + { + property.IsNullable = nullable.Value; + } - var model = modelBuilder.Model.FinalizeModel(); + var model = modelBuilder.Model.FinalizeModel(); - return CreateTypeMappingSource(model).FindMapping(model.FindEntityType(typeof(MyType))!.FindProperty(property.Name)!)!; + return CreateTypeMappingSource(model).FindMapping(model.FindEntityType(typeof(MyType))!.FindProperty(property.Name)!)!; } private class MyType diff --git a/test/EFCore.Cosmos.Tests/ValueGeneration/IdValueGeneratorTest.cs b/test/EFCore.Cosmos.Tests/ValueGeneration/IdValueGeneratorTest.cs index 45b4ae8371f..e5683496ee8 100644 --- a/test/EFCore.Cosmos.Tests/ValueGeneration/IdValueGeneratorTest.cs +++ b/test/EFCore.Cosmos.Tests/ValueGeneration/IdValueGeneratorTest.cs @@ -107,9 +107,9 @@ public static readonly ValueConverter Converter public bool Equals(BytesStruct other) => Value == null - && other.Value == null + && other.Value == null || other.Value != null - && Value?.SequenceEqual(other.Value) == true; + && Value?.SequenceEqual(other.Value) == true; public override int GetHashCode() { diff --git a/test/EFCore.CrossStore.FunctionalTests/ConfigurationPatternsTest.cs b/test/EFCore.CrossStore.FunctionalTests/ConfigurationPatternsTest.cs index ae181a16c9f..c2cb66619a2 100644 --- a/test/EFCore.CrossStore.FunctionalTests/ConfigurationPatternsTest.cs +++ b/test/EFCore.CrossStore.FunctionalTests/ConfigurationPatternsTest.cs @@ -251,9 +251,7 @@ public BlogContext() } public BlogContext(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider; - } + => _serviceProvider = serviceProvider; // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Blogs { get; set; } @@ -279,9 +277,7 @@ public ExternalProviderContext() } public ExternalProviderContext(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider; - } + => _serviceProvider = serviceProvider; protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder @@ -290,9 +286,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) } public async Task InitializeAsync() - { - ExistingTestStore = await Fixture.CreateTestStoreAsync(SqlServerTestStoreFactory.Instance, StoreName, SeedAsync); - } + => ExistingTestStore = await Fixture.CreateTestStoreAsync(SqlServerTestStoreFactory.Instance, StoreName, SeedAsync); public Task DisposeAsync() { diff --git a/test/EFCore.CrossStore.FunctionalTests/DiscriminatorTest.cs b/test/EFCore.CrossStore.FunctionalTests/DiscriminatorTest.cs index 1965543d645..db106273704 100644 --- a/test/EFCore.CrossStore.FunctionalTests/DiscriminatorTest.cs +++ b/test/EFCore.CrossStore.FunctionalTests/DiscriminatorTest.cs @@ -87,6 +87,7 @@ private class Context4285 : DbContext public DbSet Products { get; set; } public DbSet SubProducts { get; set; } public DbSet SubProducts2 { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet IntProducts { get; set; } public DbSet SubIntProducts { get; set; } diff --git a/test/EFCore.Design.Tests/Design/DbContextActivatorTest.cs b/test/EFCore.Design.Tests/Design/DbContextActivatorTest.cs index 93a0611f456..b0486d2b961 100644 --- a/test/EFCore.Design.Tests/Design/DbContextActivatorTest.cs +++ b/test/EFCore.Design.Tests/Design/DbContextActivatorTest.cs @@ -37,9 +37,7 @@ public void CreateInstance_throws_if_constructor_throws() private class ThrowingTestContext : DbContext { public ThrowingTestContext() - { - throw new Exception("Bang!"); - } + => throw new Exception("Bang!"); protected override void OnConfiguring(DbContextOptionsBuilder options) => options diff --git a/test/EFCore.Design.Tests/Design/DesignTimeServicesTest.cs b/test/EFCore.Design.Tests/Design/DesignTimeServicesTest.cs index e9561f61d8d..c2c58289d54 100644 --- a/test/EFCore.Design.Tests/Design/DesignTimeServicesTest.cs +++ b/test/EFCore.Design.Tests/Design/DesignTimeServicesTest.cs @@ -192,8 +192,12 @@ public bool IsValidId(string value) public class ExtensionHistoryRepository : IHistoryRepository { - public void Create() => throw new NotImplementedException(); - public Task CreateAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException(); + public void Create() + => throw new NotImplementedException(); + + public Task CreateAsync(CancellationToken cancellationToken = default) + => throw new NotImplementedException(); + public bool Exists() => throw new NotImplementedException(); diff --git a/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs b/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs index 205cb31ec12..d0cc4a4bb74 100644 --- a/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs +++ b/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs @@ -894,9 +894,7 @@ public SimpleTestTypeFactory() } public SimpleTestTypeFactory(string factoryArg) - { - FactoryArg = factoryArg; - } + => FactoryArg = factoryArg; public string FactoryArg { get; } = null!; diff --git a/test/EFCore.Design.Tests/Design/Internal/DbContextOperationsTest.cs b/test/EFCore.Design.Tests/Design/Internal/DbContextOperationsTest.cs index 445f0d323e6..0ab95ab7bfd 100644 --- a/test/EFCore.Design.Tests/Design/Internal/DbContextOperationsTest.cs +++ b/test/EFCore.Design.Tests/Design/Internal/DbContextOperationsTest.cs @@ -24,7 +24,8 @@ public void CreateContext_gets_service_when_context_factory_used() public void CreateContext_throws_if_context_type_not_found() => Assert.Equal( DesignStrings.NoContextWithName(typeof(TestContextFromFactory).FullName), - Assert.Throws(() => CreateOperations(typeof(TestProgramRelationalBad)).CreateContext(typeof(TestContextFromFactory).FullName)).Message); + Assert.Throws( + () => CreateOperations(typeof(TestProgramRelationalBad)).CreateContext(typeof(TestContextFromFactory).FullName)).Message); [ConditionalFact] public void CreateContext_throws_if_ambiguous_context_type_by_case() @@ -200,7 +201,8 @@ public void CreateAllContexts_creates_all_contexts() new TestAppServiceProviderFactory(assembly, reporter, throwOnCreate: true)); var contexts = operations.CreateAllContexts().ToList(); - Assert.Collection(contexts, + Assert.Collection( + contexts, c => Assert.Equal(nameof(BaseContext), Assert.IsType(c).FactoryUsed), c => Assert.Equal(nameof(DerivedContext), Assert.IsType(c).FactoryUsed)); @@ -228,8 +230,10 @@ public void Optimize_throws_when_no_contexts() Assert.Equal( DesignStrings.NoContextsToOptimize, - Assert.Throws(() => - operations.Optimize(null, null, contextTypeName: "*", null, scaffoldModel: true, precompileQueries: false, nativeAot: false)).Message); + Assert.Throws( + () => + operations.Optimize( + null, null, contextTypeName: "*", null, scaffoldModel: true, precompileQueries: false, nativeAot: false)).Message); Assert.DoesNotContain(reporter.Messages, m => m.Level == LogLevel.Critical); Assert.DoesNotContain(reporter.Messages, m => m.Level == LogLevel.Error); @@ -393,9 +397,7 @@ private static TestWebHost CreateWebHost(Func throw new Exception("This isn't the constructor you're looking for."); public TestContext(DbContextOptions options) : base(options) @@ -406,9 +408,7 @@ public TestContext(DbContextOptions options) private class TestContextFromFactory : DbContext { private TestContextFromFactory() - { - throw new Exception("This isn't the constructor you're looking for."); - } + => throw new Exception("This isn't the constructor you're looking for."); public TestContextFromFactory(DbContextOptions options) : base(options) @@ -419,9 +419,7 @@ public TestContextFromFactory(DbContextOptions options) private class Testcontext : DbContext { public Testcontext() - { - throw new Exception("This isn't the constructor you're looking for."); - } + => throw new Exception("This isn't the constructor you're looking for."); public Testcontext(DbContextOptions options) : base(options) diff --git a/test/EFCore.Design.Tests/Design/Internal/LanguageBasedSelectorTests.cs b/test/EFCore.Design.Tests/Design/Internal/LanguageBasedSelectorTests.cs index 86a361c08d1..f478b78f16b 100644 --- a/test/EFCore.Design.Tests/Design/Internal/LanguageBasedSelectorTests.cs +++ b/test/EFCore.Design.Tests/Design/Internal/LanguageBasedSelectorTests.cs @@ -82,7 +82,8 @@ public void Select_uses_last_when_multiple_services() Assert.Same(lastService, result); } - private class TestLanguageBasedSelector(params TestLanguageBasedService[] services) : LanguageBasedSelector(services); + private class TestLanguageBasedSelector(params TestLanguageBasedService[] services) + : LanguageBasedSelector(services); private class TestLanguageBasedService(string language) : ILanguageBasedService { diff --git a/test/EFCore.Design.Tests/Design/OperationExecutorTest.cs b/test/EFCore.Design.Tests/Design/OperationExecutorTest.cs index d661113a7a2..96ac004bddd 100644 --- a/test/EFCore.Design.Tests/Design/OperationExecutorTest.cs +++ b/test/EFCore.Design.Tests/Design/OperationExecutorTest.cs @@ -1180,21 +1180,15 @@ private class MockOperation : OperationExecutor.OperationBase { public MockOperation(IOperationResultHandler resultHandler, Action action) : base(resultHandler) - { - Execute(action); - } + => Execute(action); public MockOperation(IOperationResultHandler resultHandler, Func action) : base(resultHandler) - { - Execute(action); - } + => Execute(action); public MockOperation(IOperationResultHandler resultHandler, Func> action) : base(resultHandler) - { - Execute(action); - } + => Execute(action); } } diff --git a/test/EFCore.Design.Tests/DesignApiConsistencyTest.cs b/test/EFCore.Design.Tests/DesignApiConsistencyTest.cs index 465fded100e..7a54b4ffc81 100644 --- a/test/EFCore.Design.Tests/DesignApiConsistencyTest.cs +++ b/test/EFCore.Design.Tests/DesignApiConsistencyTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; -public class DesignApiConsistencyTest(DesignApiConsistencyTest.DesignApiConsistencyFixture fixture) : ApiConsistencyTestBase(fixture) +public class DesignApiConsistencyTest(DesignApiConsistencyTest.DesignApiConsistencyFixture fixture) + : ApiConsistencyTestBase(fixture) { protected override void AddServices(ServiceCollection serviceCollection) { diff --git a/test/EFCore.Design.Tests/DesignTimeFlagTest.cs b/test/EFCore.Design.Tests/DesignTimeFlagTest.cs index 2e94d7330ea..6edeecd0a94 100644 --- a/test/EFCore.Design.Tests/DesignTimeFlagTest.cs +++ b/test/EFCore.Design.Tests/DesignTimeFlagTest.cs @@ -66,9 +66,7 @@ private class MockOperation : OperationExecutor.OperationBase { public MockOperation(IOperationResultHandler resultHandler, Func action) : base(resultHandler) - { - Execute(action); - } + => Execute(action); } } diff --git a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs index 3539ea13791..ba445da389c 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs @@ -2327,20 +2327,14 @@ public void SqlOperation_required_args() [new Coordinate(1.1, 2.2), new Coordinate(2.2, 2.2), new Coordinate(2.2, 1.1), new Coordinate(7.1, 7.2)]) { SRID = 4326 }; private static readonly LineString _lineString2 = new( - [new Coordinate(7.1, 7.2), new Coordinate(20.2, 20.2), new Coordinate(20.20, 1.1), new Coordinate(70.1, 70.2)]) - { - SRID = 4326 - }; + [new Coordinate(7.1, 7.2), new Coordinate(20.2, 20.2), new Coordinate(20.20, 1.1), new Coordinate(70.1, 70.2)]) { SRID = 4326 }; private static readonly MultiPoint _multiPoint = new( [new Point(1.1, 2.2), new Point(2.2, 2.2), new Point(2.2, 1.1)]) { SRID = 4326 }; private static readonly Polygon _polygon1 = new( new LinearRing( - [new Coordinate(1.1, 2.2), new Coordinate(2.2, 2.2), new Coordinate(2.2, 1.1), new Coordinate(1.1, 2.2)])) - { - SRID = 4326 - }; + [new Coordinate(1.1, 2.2), new Coordinate(2.2, 2.2), new Coordinate(2.2, 1.1), new Coordinate(1.1, 2.2)])) { SRID = 4326 }; private static readonly Polygon _polygon2 = new( new LinearRing( @@ -2358,10 +2352,7 @@ public void SqlOperation_required_args() [_polygon2, _polygon1]) { SRID = 4326 }; private static readonly GeometryCollection _geometryCollection = new( - [_lineString1, _lineString2, _multiPoint, _polygon1, _polygon2, _point1, _multiLineString, _multiPolygon]) - { - SRID = 4326 - }; + [_lineString1, _lineString2, _multiPoint, _polygon1, _polygon2, _point1, _multiLineString, _multiPolygon]) { SRID = 4326 }; [ConditionalFact] public void InsertDataOperation_all_args() diff --git a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.ModelSnapshot.cs b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.ModelSnapshot.cs index 7451f84ea95..a3ac3eff14b 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.ModelSnapshot.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.ModelSnapshot.cs @@ -23,7 +23,6 @@ namespace Microsoft.EntityFrameworkCore.Migrations.Design; public partial class CSharpMigrationsGeneratorTest { - [ConditionalFact] public void Snapshots_compile() { @@ -870,15 +869,18 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPT() Assert.Equal(5, model.GetAnnotations().Count()); Assert.Equal(3, model.GetEntityTypes().Count()); - var abstractBase = model.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+AbstractBase"); + var abstractBase = model.FindEntityType( + "Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+AbstractBase"); Assert.Equal("AbstractBase", abstractBase.GetTableName()); Assert.Equal("TPT", abstractBase.GetMappingStrategy()); - var baseType = model.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+BaseEntity"); + var baseType = model.FindEntityType( + "Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+BaseEntity"); Assert.Equal("BaseEntity", baseType.GetTableName()); Assert.Equal("DefaultSchema", baseType.GetSchema()); - var derived = model.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+DerivedEntity"); + var derived = model.FindEntityType( + "Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+DerivedEntity"); Assert.Equal("DerivedEntity", derived.GetTableName()); Assert.Equal("foo", derived.GetSchema()); }); @@ -1050,16 +1052,19 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPC() Assert.Equal(6, model.GetAnnotations().Count()); Assert.Equal(3, model.GetEntityTypes().Count()); - var abstractBase = model.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+AbstractBase"); + var abstractBase = model.FindEntityType( + "Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+AbstractBase"); Assert.Null(abstractBase.GetTableName()); Assert.Null(abstractBase.GetViewName()); Assert.Equal("TPC", abstractBase.GetMappingStrategy()); - var baseType = model.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+BaseEntity"); + var baseType = model.FindEntityType( + "Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+BaseEntity"); Assert.Equal("BaseEntity", baseType.GetTableName()); Assert.Null(baseType.GetViewName()); - var derived = model.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+DerivedEntity"); + var derived = model.FindEntityType( + "Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+DerivedEntity"); Assert.Equal("DerivedEntity", derived.GetTableName()); Assert.Equal("DerivedView", derived.GetViewName()); }); @@ -1210,7 +1215,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) Assert.Equal(6, model.GetAnnotations().Count()); Assert.Equal(6, model.GetEntityTypes().Count()); - var animalType = model.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+Animal"); + var animalType = + model.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+Animal"); Assert.Null(animalType.GetTableName()); Assert.Null(animalType.GetViewName()); Assert.Equal("TPC", animalType.GetMappingStrategy()); @@ -4427,7 +4433,7 @@ public virtual void Owned_types_mapped_to_json_are_stored_in_snapshot() var ownedProperties1 = ownedType1.GetProperties().ToList(); Assert.Equal("EntityWithOnePropertyId", ownedProperties1[0].Name); Assert.Equal("AlternateId", ownedProperties1[1].Name); - Assert.Equal("NotKey", RelationalPropertyExtensions.GetJsonPropertyName(ownedProperties1[1])); + Assert.Equal("NotKey", ownedProperties1[1].GetJsonPropertyName()); Assert.Equal(nameof(EntityWithOneProperty), ownedType1.GetTableName()); Assert.Equal("EntityWithTwoProperties", ownedType1.GetContainerColumnName()); @@ -5012,13 +5018,11 @@ public virtual void Property_column_name_is_stored_in_snapshot_when_DefaultColum model.GetRelationalModel().Tables, t => { - Assert.Equal("BarBase", t.Name); Assert.Equal(["Id", "Discriminator", "FooExtensionId"], t.Columns.Select(t => t.Name)); }, t => { - Assert.Equal("FooExtension", t.Name); Assert.Equal(["Id"], t.Columns.Select(t => t.Name)); }); @@ -5029,7 +5033,7 @@ public virtual void Generic_entity_type_with_owned_entities() => Test( modelBuilder => modelBuilder.Entity>().OwnsOne(e => e.Child), AddBoilerPlate( - """ + """ modelBuilder .HasDefaultSchema("DefaultSchema") .HasAnnotation("Relational:MaxIdentifierLength", 128); @@ -5075,7 +5079,8 @@ public virtual void Generic_entity_type_with_owned_entities() """), model => { - var parentType = model.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+Parrot"); + var parentType = model.FindEntityType( + "Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+Parrot"); Assert.NotNull(parentType); Assert.NotNull(parentType.FindNavigation("Child")!.TargetEntityType); @@ -5088,7 +5093,7 @@ public virtual void Non_generic_entity_type_with_owned_entities() => Test( modelBuilder => modelBuilder.Entity().OwnsOne(e => e.Child), AddBoilerPlate( - """ + """ modelBuilder .HasDefaultSchema("DefaultSchema") .HasAnnotation("Relational:MaxIdentifierLength", 128); @@ -5134,7 +5139,8 @@ public virtual void Non_generic_entity_type_with_owned_entities() """), model => { - var parentType = model.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+Parrot"); + var parentType = + model.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+Parrot"); Assert.NotNull(parentType); Assert.NotNull(parentType.FindNavigation("Child")!.TargetEntityType); @@ -5207,7 +5213,8 @@ public virtual void Property_column_name_on_specific_table_is_stored_in_snapshot Assert.Collection( o.GetEntityTypes(), t => Assert.Equal("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+BaseEntity", t.Name), - t => Assert.Equal("Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+DerivedEntity", t.Name), + t => Assert.Equal( + "Microsoft.EntityFrameworkCore.Migrations.Design.CSharpMigrationsGeneratorTest+DerivedEntity", t.Name), t => { Assert.Equal( @@ -7821,27 +7828,17 @@ static List getAllProperties(IModel model) .ToList(); var lineString1 = new LineString( - [new Coordinate(1.1, 2.2), new Coordinate(2.2, 2.2), new Coordinate(2.2, 1.1), new Coordinate(7.1, 7.2)]) - { - SRID = 4326 - }; + [new Coordinate(1.1, 2.2), new Coordinate(2.2, 2.2), new Coordinate(2.2, 1.1), new Coordinate(7.1, 7.2)]) { SRID = 4326 }; var lineString2 = new LineString( - [new Coordinate(7.1, 7.2), new Coordinate(20.2, 20.2), new Coordinate(20.20, 1.1), new Coordinate(70.1, 70.2)]) - { - SRID = 4326 - }; + [new Coordinate(7.1, 7.2), new Coordinate(20.2, 20.2), new Coordinate(20.20, 1.1), new Coordinate(70.1, 70.2)]) { SRID = 4326 }; var multiPoint = new MultiPoint( - [new Point(1.1, 2.2), new Point(2.2, 2.2), new Point(2.2, 1.1)]) - { SRID = 4326 }; + [new Point(1.1, 2.2), new Point(2.2, 2.2), new Point(2.2, 1.1)]) { SRID = 4326 }; var polygon1 = new Polygon( new LinearRing( - [new Coordinate(1.1, 2.2), new Coordinate(2.2, 2.2), new Coordinate(2.2, 1.1), new Coordinate(1.1, 2.2)])) - { - SRID = 4326 - }; + [new Coordinate(1.1, 2.2), new Coordinate(2.2, 2.2), new Coordinate(2.2, 1.1), new Coordinate(1.1, 2.2)])) { SRID = 4326 }; var polygon2 = new Polygon( new LinearRing( @@ -7857,10 +7854,7 @@ static List getAllProperties(IModel model) var multiPolygon = new MultiPolygon([polygon2, polygon1]) { SRID = 4326 }; var geometryCollection = new GeometryCollection( - [lineString1, lineString2, multiPoint, polygon1, polygon2, point1, multiLineString, multiPolygon]) - { - SRID = 4326 - }; + [lineString1, lineString2, multiPoint, polygon1, polygon2, point1, multiLineString, multiPolygon]) { SRID = 4326 }; Test( builder => diff --git a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs index c044391de2c..033af3a37ff 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs @@ -369,8 +369,9 @@ private static void MissingAnnotationCheck( } var relationalAnnotations = typeof(RelationalAnnotationNames).GetFields() - .Where(f => f.FieldType == typeof(string) - && f.Name != "Prefix").ToList(); + .Where( + f => f.FieldType == typeof(string) + && f.Name != "Prefix").ToList(); foreach (var field in relationalAnnotations) { @@ -382,7 +383,11 @@ private static void MissingAnnotationCheck( { Assert.True( RelationalAnnotationNames.AllNames.Contains(annotationName), - nameof(RelationalAnnotationNames) + "." + nameof(RelationalAnnotationNames.AllNames) + " doesn't contain " + annotationName); + nameof(RelationalAnnotationNames) + + "." + + nameof(RelationalAnnotationNames.AllNames) + + " doesn't contain " + + annotationName); } } diff --git a/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs b/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs index 866b54c997f..94fa478789e 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs @@ -91,20 +91,20 @@ var migrationAssembly services.GetRequiredService()), idGenerator, new MigrationsCodeGeneratorSelector( - [ - new CSharpMigrationsGenerator( - new MigrationsCodeGeneratorDependencies( - sqlServerTypeMappingSource, - sqlServerAnnotationCodeGenerator), - new CSharpMigrationsGeneratorDependencies( - code, - new CSharpMigrationOperationGenerator( - new CSharpMigrationOperationGeneratorDependencies( - code)), - new CSharpSnapshotGenerator( - new CSharpSnapshotGeneratorDependencies( - code, sqlServerTypeMappingSource, sqlServerAnnotationCodeGenerator)))) - ]), + [ + new CSharpMigrationsGenerator( + new MigrationsCodeGeneratorDependencies( + sqlServerTypeMappingSource, + sqlServerAnnotationCodeGenerator), + new CSharpMigrationsGeneratorDependencies( + code, + new CSharpMigrationOperationGenerator( + new CSharpMigrationOperationGeneratorDependencies( + code)), + new CSharpSnapshotGenerator( + new CSharpSnapshotGeneratorDependencies( + code, sqlServerTypeMappingSource, sqlServerAnnotationCodeGenerator)))) + ]), historyRepository, reporter, new MockProvider(), diff --git a/test/EFCore.Design.Tests/Migrations/Design/SnapshotModelProcessorTest.cs b/test/EFCore.Design.Tests/Migrations/Design/SnapshotModelProcessorTest.cs index 5265acf89f0..6cbc70fc2d8 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/SnapshotModelProcessorTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/SnapshotModelProcessorTest.cs @@ -271,7 +271,7 @@ private static IModel PreprocessModel(ModelSnapshot snapshot) } } else if (property.GetValueGenerationStrategy() is SqlServerValueGenerationStrategy strategy - && strategy != SqlServerValueGenerationStrategy.None) + && strategy != SqlServerValueGenerationStrategy.None) { property.SetValueGenerationStrategy(strategy); } diff --git a/test/EFCore.Design.Tests/Query/CSharpToLinqTranslatorTest.cs b/test/EFCore.Design.Tests/Query/CSharpToLinqTranslatorTest.cs index 3fa2f2c2f6f..8a374a9bf2a 100644 --- a/test/EFCore.Design.Tests/Query/CSharpToLinqTranslatorTest.cs +++ b/test/EFCore.Design.Tests/Query/CSharpToLinqTranslatorTest.cs @@ -12,7 +12,6 @@ namespace Microsoft.EntityFrameworkCore.Query; // ReSharper disable InconsistentNaming // ReSharper disable RedundantCast - #nullable enable public class CSharpToLinqTranslatorTest @@ -104,7 +103,12 @@ public void ElementAccess_over_array() [Fact] public void ElementAccess_over_list() => AssertExpression( - () => new List { 1, 2, 3 }[1], + () => new List + { + 1, + 2, + 3 + }[1], "new List { 1, 2, 3 }[1]"); [Fact] @@ -128,7 +132,7 @@ public void Interpolated_string() [Fact] public void Interpolated_string_formattable() => AssertExpression( - () => FormattableStringMethod(FormattableStringFactory.Create("Foo: {0}, {1}", (object)8, (object) 9)), + () => FormattableStringMethod(FormattableStringFactory.Create("Foo: {0}, {1}", (object)8, (object)9)), """CSharpToLinqTranslatorTest.FormattableStringMethod($"Foo: {8}, {9}")"""); [Fact] @@ -260,7 +264,8 @@ public void Invocation_generic_method_on_generic_type() """CSharpToLinqTranslatorTest.SomeGenericType.SomeGenericFunction(1, "foo")"""); [Theory] - [InlineData(""" + [InlineData( + """ "hello" """, "hello")] [InlineData("1", 1)] diff --git a/test/EFCore.Design.Tests/Query/LinqToCSharpSyntaxTranslatorTest.cs b/test/EFCore.Design.Tests/Query/LinqToCSharpSyntaxTranslatorTest.cs index f40df69279a..7807f4a82bb 100644 --- a/test/EFCore.Design.Tests/Query/LinqToCSharpSyntaxTranslatorTest.cs +++ b/test/EFCore.Design.Tests/Query/LinqToCSharpSyntaxTranslatorTest.cs @@ -56,7 +56,9 @@ public void Enum() [Fact] public void Enum_with_multiple_values() - => AssertExpression(Constant(SomeEnum.One | SomeEnum.Two), "LinqToCSharpSyntaxTranslatorTest.SomeEnum.One | LinqToCSharpSyntaxTranslatorTest.SomeEnum.Two"); + => AssertExpression( + Constant(SomeEnum.One | SomeEnum.Two), + "LinqToCSharpSyntaxTranslatorTest.SomeEnum.One | LinqToCSharpSyntaxTranslatorTest.SomeEnum.Two"); [Fact] public void Enum_with_unknown_value() @@ -145,9 +147,8 @@ public void Private_instance_field_AssignOperators_with_replacements(ExpressionT expressionType, Field(Parameter(typeof(Blog), "blog"), "_privateField"), Constant(3)), - $"""AccessPrivateField(blog) {op} Three""", new Dictionary() { { 3, "Three" } }, new Dictionary() { - { BlogPrivateField, new QualifiedName("AccessPrivateField", "") } - }); + $"""AccessPrivateField(blog) {op} Three""", new Dictionary { { 3, "Three" } }, + new Dictionary { { BlogPrivateField, new QualifiedName("AccessPrivateField", "") } }); [Theory] [InlineData(ExpressionType.Negate, "-(i)")] @@ -297,13 +298,14 @@ public void Internal_instance_field_read() Field( Parameter(typeof(Blog), "blog"), "InternalField"), - "UnsafeAccessor_Microsoft_EntityFrameworkCore_Query_Blog_InternalField_Get(blog)", unsafeAccessorsAsserter: unsafeAccessors => Assert.Equal( - """ + "UnsafeAccessor_Microsoft_EntityFrameworkCore_Query_Blog_InternalField_Get(blog)", unsafeAccessorsAsserter: unsafeAccessors + => Assert.Equal( + """ [UnsafeAccessor(UnsafeAccessorKind.Field, Name = "InternalField")] private static extern int UnsafeAccessor_Microsoft_EntityFrameworkCore_Query_Blog_InternalField_Get(LinqToCSharpSyntaxTranslatorTest.Blog instance); """, - Assert.Single(unsafeAccessors), - ignoreLineEndingDifferences: true)); + Assert.Single(unsafeAccessors), + ignoreLineEndingDifferences: true)); [Fact] public void Not() @@ -1142,7 +1144,8 @@ public void Same_parameter_instance_is_used_twice_in_nested_lambdas() [Fact] public void Block_with_non_standalone_expression_as_statement() - => AssertStatement(Block(Add(Constant(1), Constant(2))), + => AssertStatement( + Block(Add(Constant(1), Constant(2))), """ { _ = (1 + 2); @@ -1413,8 +1416,7 @@ public void Lift_block_in_lambda_body_expression() ReturnsIntWithParamMethod, Block( Call(FooMethod), - Call(BarMethod))), - []), + Call(BarMethod)))), """ int () => { @@ -1427,8 +1429,7 @@ public void Lift_block_in_lambda_body_expression() public void Do_not_lift_block_in_lambda_body() => AssertExpression( Lambda>( - Block(Block(Constant(8))), - []), + Block(Block(Constant(8)))), """ int () => { @@ -2073,7 +2074,8 @@ public static int Baz() public static int MethodWithSixParams(int a, int b, int c, int d, int e, int f) => a + b + c + d + e + f; - public static Expression> LambdaExpressionProperty => f => f > 5; + public static Expression> LambdaExpressionProperty + => f => f > 5; private static readonly FieldInfo BlogPrivateField = typeof(Blog).GetField("_privateField", BindingFlags.NonPublic | BindingFlags.Instance)!; @@ -2126,9 +2128,7 @@ private class BlogWithRequiredProperties public BlogWithRequiredProperties() { } public BlogWithRequiredProperties(string name) - { - Name = name; - } + => Name = name; [SetsRequiredMembers] public BlogWithRequiredProperties(string name, int rating) diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs index fff78ef1e68..6a46be64eb1 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs @@ -11,7 +11,8 @@ namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal { - public class CSharpDbContextGeneratorTest(ModelCodeGeneratorTestFixture fixture, ITestOutputHelper output) : ModelCodeGeneratorTestBase(fixture, output) + public class CSharpDbContextGeneratorTest(ModelCodeGeneratorTestFixture fixture, ITestOutputHelper output) + : ModelCodeGeneratorTestBase(fixture, output) { [ConditionalFact] public Task Empty_model() @@ -1360,7 +1361,8 @@ protected override IServiceCollection AddModelServices(IServiceCollection servic protected override IServiceCollection AddScaffoldingServices(IServiceCollection services) => services.Replace(ServiceDescriptor.Singleton()); - private class TestModelAnnotationProvider(RelationalAnnotationProviderDependencies dependencies) : SqlServerAnnotationProvider(dependencies) + private class TestModelAnnotationProvider(RelationalAnnotationProviderDependencies dependencies) + : SqlServerAnnotationProvider(dependencies) { public override IEnumerable For(IRelationalModel database, bool designTime) { @@ -1376,7 +1378,8 @@ public override IEnumerable For(IRelationalModel database, bool des } } - private class TestModelAnnotationCodeGenerator(AnnotationCodeGeneratorDependencies dependencies) : SqlServerAnnotationCodeGenerator(dependencies) + private class TestModelAnnotationCodeGenerator(AnnotationCodeGeneratorDependencies dependencies) + : SqlServerAnnotationCodeGenerator(dependencies) { private static readonly MethodInfo _testFluentApiCallMethodInfo = typeof(TestModelBuilderExtensions).GetRuntimeMethod( diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpEntityTypeGeneratorTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpEntityTypeGeneratorTest.cs index f684700a894..740f3a35a4e 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpEntityTypeGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpEntityTypeGeneratorTest.cs @@ -9,7 +9,8 @@ namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal; -public class CSharpEntityTypeGeneratorTest(ModelCodeGeneratorTestFixture fixture, ITestOutputHelper output) : ModelCodeGeneratorTestBase(fixture, output) +public class CSharpEntityTypeGeneratorTest(ModelCodeGeneratorTestFixture fixture, ITestOutputHelper output) + : ModelCodeGeneratorTestBase(fixture, output) { [ConditionalFact] public Task KeylessAttribute_is_generated_for_key_less_entity() @@ -2934,7 +2935,8 @@ protected override IServiceCollection AddModelServices(IServiceCollection servic protected override IServiceCollection AddScaffoldingServices(IServiceCollection services) => services.Replace(ServiceDescriptor.Singleton()); - private class TestModelAnnotationProvider(RelationalAnnotationProviderDependencies dependencies) : SqlServerAnnotationProvider(dependencies) + private class TestModelAnnotationProvider(RelationalAnnotationProviderDependencies dependencies) + : SqlServerAnnotationProvider(dependencies) { public override IEnumerable For(ITable table, bool designTime) { @@ -2968,7 +2970,8 @@ public override IEnumerable For(IColumn column, bool designTime) } } - private class TestModelAnnotationCodeGenerator(AnnotationCodeGeneratorDependencies dependencies) : SqlServerAnnotationCodeGenerator(dependencies) + private class TestModelAnnotationCodeGenerator(AnnotationCodeGeneratorDependencies dependencies) + : SqlServerAnnotationCodeGenerator(dependencies) { protected override AttributeCodeFragment GenerateDataAnnotation(IEntityType entityType, IAnnotation annotation) => annotation.Name switch diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs index 77eee706a71..66d5a78c003 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs @@ -3200,12 +3200,27 @@ public void Navigation_name_from_composite_FK() // Issue #32685 { Table = someTable, Name = "FK_SomeTable_DetailItem", - Columns = { someTable.Columns.Single(c => c.Name == "DetailItemName"), someTable.Columns.Single(c => c.Name == "DetailItemCategoryName") }, + Columns = + { + someTable.Columns.Single(c => c.Name == "DetailItemName"), + someTable.Columns.Single(c => c.Name == "DetailItemCategoryName") + }, PrincipalTable = itemTable, - PrincipalColumns = { itemTable.Columns.Single(c => c.Name == "Name"), itemTable.Columns.Single(c => c.Name == "CategoryName") }, + PrincipalColumns = + { + itemTable.Columns.Single(c => c.Name == "Name"), itemTable.Columns.Single(c => c.Name == "CategoryName") + }, }); - var info = new DatabaseModel { Tables = { itemTable, someTable, itemCategoryTable } }; + var info = new DatabaseModel + { + Tables = + { + itemTable, + someTable, + itemCategoryTable + } + }; var model = _factory.Create(info, new ModelReverseEngineerOptions()); diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs index d8f2fdce4b4..235799e1f4d 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs @@ -1,7 +1,6 @@ // 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.Scaffolding.Internal; using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal; // ReSharper disable CheckNamespace diff --git a/test/EFCore.Design.Tests/TestUtilities/DatabaseColumnRef.cs b/test/EFCore.Design.Tests/TestUtilities/DatabaseColumnRef.cs index 7b049a52fa8..a04c85a1d67 100644 --- a/test/EFCore.Design.Tests/TestUtilities/DatabaseColumnRef.cs +++ b/test/EFCore.Design.Tests/TestUtilities/DatabaseColumnRef.cs @@ -8,9 +8,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities; internal class DatabaseColumnRef : DatabaseColumn { public DatabaseColumnRef(string name) - { - Name = name; - } + => Name = name; public override DatabaseTable Table { diff --git a/test/EFCore.Design.Tests/TestUtilities/FakeScaffoldingModelFactory.cs b/test/EFCore.Design.Tests/TestUtilities/FakeScaffoldingModelFactory.cs index c6b252a3525..c25e9f00a0f 100644 --- a/test/EFCore.Design.Tests/TestUtilities/FakeScaffoldingModelFactory.cs +++ b/test/EFCore.Design.Tests/TestUtilities/FakeScaffoldingModelFactory.cs @@ -14,8 +14,8 @@ public class FakeScaffoldingModelFactory( ICSharpUtilities cSharpUtilities, IScaffoldingTypeMapper scaffoldingTypeMapper, IModelRuntimeInitializer modelRuntimeInitializer) : RelationalScaffoldingModelFactory( - reporter, candidateNamingService, pluralizer, cSharpUtilities, scaffoldingTypeMapper, - modelRuntimeInitializer) + reporter, candidateNamingService, pluralizer, cSharpUtilities, scaffoldingTypeMapper, + modelRuntimeInitializer) { public override IModel Create(DatabaseModel databaseModel, ModelReverseEngineerOptions options) { diff --git a/test/EFCore.Design.Tests/TestUtilities/TestDbContextOperations.cs b/test/EFCore.Design.Tests/TestUtilities/TestDbContextOperations.cs index 6c089e0e627..ac5ef9c2971 100644 --- a/test/EFCore.Design.Tests/TestUtilities/TestDbContextOperations.cs +++ b/test/EFCore.Design.Tests/TestUtilities/TestDbContextOperations.cs @@ -15,4 +15,5 @@ public class TestDbContextOperations( string language, bool nullable, string[] args, - AppServiceProviderFactory appServicesFactory) : DbContextOperations(reporter, assembly, startupAssembly, project, projectDir, rootNamespace, language, nullable, args, appServicesFactory); + AppServiceProviderFactory appServicesFactory) : DbContextOperations( + reporter, assembly, startupAssembly, project, projectDir, rootNamespace, language, nullable, args, appServicesFactory); diff --git a/test/EFCore.InMemory.FunctionalTests/CompositeKeyEndToEndTest.cs b/test/EFCore.InMemory.FunctionalTests/CompositeKeyEndToEndTest.cs index 47ab8f7b69b..39467eedecd 100644 --- a/test/EFCore.InMemory.FunctionalTests/CompositeKeyEndToEndTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/CompositeKeyEndToEndTest.cs @@ -175,8 +175,10 @@ private class BronieContext(IServiceProvider serviceProvider) : PoolableDbContex // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Pegasuses { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Unicorns { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet EarthPonies { get; set; } diff --git a/test/EFCore.InMemory.FunctionalTests/ConcurrencyDetectorDisabledInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/ConcurrencyDetectorDisabledInMemoryTest.cs index e67d53173f1..11960e294a7 100644 --- a/test/EFCore.InMemory.FunctionalTests/ConcurrencyDetectorDisabledInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ConcurrencyDetectorDisabledInMemoryTest.cs @@ -3,8 +3,9 @@ namespace Microsoft.EntityFrameworkCore; -public class ConcurrencyDetectorDisabledInMemoryTest(ConcurrencyDetectorDisabledInMemoryTest.ConcurrencyDetectorInMemoryFixture fixture) : ConcurrencyDetectorDisabledTestBase< - ConcurrencyDetectorDisabledInMemoryTest.ConcurrencyDetectorInMemoryFixture>(fixture) +public class ConcurrencyDetectorDisabledInMemoryTest(ConcurrencyDetectorDisabledInMemoryTest.ConcurrencyDetectorInMemoryFixture fixture) + : ConcurrencyDetectorDisabledTestBase< + ConcurrencyDetectorDisabledInMemoryTest.ConcurrencyDetectorInMemoryFixture>(fixture) { public class ConcurrencyDetectorInMemoryFixture : ConcurrencyDetectorFixtureBase { diff --git a/test/EFCore.InMemory.FunctionalTests/ConcurrencyDetectorEnabledInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/ConcurrencyDetectorEnabledInMemoryTest.cs index 31f9913b31c..cfdc7faa051 100644 --- a/test/EFCore.InMemory.FunctionalTests/ConcurrencyDetectorEnabledInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ConcurrencyDetectorEnabledInMemoryTest.cs @@ -3,8 +3,9 @@ namespace Microsoft.EntityFrameworkCore; -public class ConcurrencyDetectorEnabledInMemoryTest(ConcurrencyDetectorEnabledInMemoryTest.ConcurrencyDetectorInMemoryFixture fixture) : ConcurrencyDetectorEnabledTestBase< - ConcurrencyDetectorEnabledInMemoryTest.ConcurrencyDetectorInMemoryFixture>(fixture) +public class ConcurrencyDetectorEnabledInMemoryTest(ConcurrencyDetectorEnabledInMemoryTest.ConcurrencyDetectorInMemoryFixture fixture) + : ConcurrencyDetectorEnabledTestBase< + ConcurrencyDetectorEnabledInMemoryTest.ConcurrencyDetectorInMemoryFixture>(fixture) { public class ConcurrencyDetectorInMemoryFixture : ConcurrencyDetectorFixtureBase { diff --git a/test/EFCore.InMemory.FunctionalTests/ConfigPatternsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/ConfigPatternsInMemoryTest.cs index b5281c52a1a..00ee85ff887 100644 --- a/test/EFCore.InMemory.FunctionalTests/ConfigPatternsInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ConfigPatternsInMemoryTest.cs @@ -145,7 +145,6 @@ public void Can_save_and_query_with_explicit_services_and_explicit_config() private class ExplicitServicesAndConfigBlogContext(DbContextOptions options) : DbContext(options) { - // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Blogs { get; set; } } @@ -304,9 +303,7 @@ private class InjectContextAndConfigurationBlogContext : DbContext { public InjectContextAndConfigurationBlogContext(DbContextOptions options) : base(options) - { - Assert.NotNull(options); - } + => Assert.NotNull(options); // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Blogs { get; set; } @@ -362,9 +359,7 @@ private class InjectConfigurationBlogContext : DbContext { public InjectConfigurationBlogContext(DbContextOptions options) : base(options) - { - Assert.NotNull(options); - } + => Assert.NotNull(options); // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Blogs { get; set; } @@ -451,9 +446,7 @@ private class InjectDifferentConfigurationsBlogContext : DbContext { public InjectDifferentConfigurationsBlogContext(DbContextOptions options) : base(options) - { - Assert.NotNull(options); - } + => Assert.NotNull(options); // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Blogs { get; set; } @@ -463,9 +456,7 @@ private class InjectDifferentConfigurationsAccountContext : DbContext { public InjectDifferentConfigurationsAccountContext(DbContextOptions options) : base(options) - { - Assert.NotNull(options); - } + => Assert.NotNull(options); // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Accounts { get; set; } diff --git a/test/EFCore.InMemory.FunctionalTests/FieldsOnlyLoadInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/FieldsOnlyLoadInMemoryTest.cs index a1454f47b83..77ba4d97a1c 100644 --- a/test/EFCore.InMemory.FunctionalTests/FieldsOnlyLoadInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/FieldsOnlyLoadInMemoryTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore; -public class FieldsOnlyLoadInMemoryTest(FieldsOnlyLoadInMemoryTest.FieldsOnlyLoadInMemoryFixture fixture) : FieldsOnlyLoadTestBase(fixture) +public class FieldsOnlyLoadInMemoryTest(FieldsOnlyLoadInMemoryTest.FieldsOnlyLoadInMemoryFixture fixture) + : FieldsOnlyLoadTestBase(fixture) { public class FieldsOnlyLoadInMemoryFixture : FieldsOnlyLoadFixtureBase { diff --git a/test/EFCore.InMemory.FunctionalTests/InMemoryApiConsistencyTest.cs b/test/EFCore.InMemory.FunctionalTests/InMemoryApiConsistencyTest.cs index 86cca60516d..8eecd9ed50a 100644 --- a/test/EFCore.InMemory.FunctionalTests/InMemoryApiConsistencyTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/InMemoryApiConsistencyTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; -public class InMemoryApiConsistencyTest(InMemoryApiConsistencyTest.InMemoryApiConsistencyFixture fixture) : ApiConsistencyTestBase(fixture) +public class InMemoryApiConsistencyTest(InMemoryApiConsistencyTest.InMemoryApiConsistencyFixture fixture) + : ApiConsistencyTestBase(fixture) { protected override void AddServices(ServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkInMemoryDatabase(); diff --git a/test/EFCore.InMemory.FunctionalTests/IntegerValueGeneratorTest.cs b/test/EFCore.InMemory.FunctionalTests/IntegerValueGeneratorTest.cs index 49a507f51ee..1244fa01e58 100644 --- a/test/EFCore.InMemory.FunctionalTests/IntegerValueGeneratorTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/IntegerValueGeneratorTest.cs @@ -384,6 +384,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet CookedBreads { get; set; } public DbSet Olives { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Macs { get; set; } public DbSet Smokeys { get; set; } diff --git a/test/EFCore.InMemory.FunctionalTests/LazyLoadProxyInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/LazyLoadProxyInMemoryTest.cs index 791c03b2b29..5e46f4e83fe 100644 --- a/test/EFCore.InMemory.FunctionalTests/LazyLoadProxyInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/LazyLoadProxyInMemoryTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; -public class LazyLoadProxyInMemoryTest(LazyLoadProxyInMemoryTest.LoadInMemoryFixture fixture) : LazyLoadProxyTestBase(fixture) +public class LazyLoadProxyInMemoryTest(LazyLoadProxyInMemoryTest.LoadInMemoryFixture fixture) + : LazyLoadProxyTestBase(fixture) { protected override string SerializedBlogs2 => """ diff --git a/test/EFCore.InMemory.FunctionalTests/ManyToManyFieldsLoadInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/ManyToManyFieldsLoadInMemoryTest.cs index 7b64655543e..7aea5113c59 100644 --- a/test/EFCore.InMemory.FunctionalTests/ManyToManyFieldsLoadInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ManyToManyFieldsLoadInMemoryTest.cs @@ -3,8 +3,9 @@ namespace Microsoft.EntityFrameworkCore; -public class ManyToManyFieldsLoadInMemoryTest(ManyToManyFieldsLoadInMemoryTest.ManyToManyFieldsLoadInMemoryFixture fixture) : ManyToManyFieldsLoadTestBase< - ManyToManyFieldsLoadInMemoryTest.ManyToManyFieldsLoadInMemoryFixture>(fixture) +public class ManyToManyFieldsLoadInMemoryTest(ManyToManyFieldsLoadInMemoryTest.ManyToManyFieldsLoadInMemoryFixture fixture) + : ManyToManyFieldsLoadTestBase< + ManyToManyFieldsLoadInMemoryTest.ManyToManyFieldsLoadInMemoryFixture>(fixture) { public class ManyToManyFieldsLoadInMemoryFixture : ManyToManyFieldsLoadFixtureBase { diff --git a/test/EFCore.InMemory.FunctionalTests/ManyToManyLoadInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/ManyToManyLoadInMemoryTest.cs index 4d7acaa69a0..a55e41d1106 100644 --- a/test/EFCore.InMemory.FunctionalTests/ManyToManyLoadInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ManyToManyLoadInMemoryTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore; -public class ManyToManyLoadInMemoryTest(ManyToManyLoadInMemoryTest.ManyToManyLoadInMemoryFixture fixture) : ManyToManyLoadTestBase(fixture) +public class ManyToManyLoadInMemoryTest(ManyToManyLoadInMemoryTest.ManyToManyLoadInMemoryFixture fixture) + : ManyToManyLoadTestBase(fixture) { public class ManyToManyLoadInMemoryFixture : ManyToManyLoadFixtureBase { diff --git a/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderAssemblyScanTest.cs b/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderAssemblyScanTest.cs index 275389c4642..f3809d7f4cb 100644 --- a/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderAssemblyScanTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderAssemblyScanTest.cs @@ -44,7 +44,7 @@ public void Scan_reports_load_errors() }; var assembly = MockAssembly.Create( - types, null, new ReflectionTypeLoadException([types[1], types[2]], [new(), new()])); + types, null, new ReflectionTypeLoadException([types[1], types[2]], [new Exception(), new Exception()])); var loggerFactory = new ListLoggerFactory(); var logger = CreateModelLogger(loggerFactory); diff --git a/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderGenericRelationshipStringTest.cs b/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderGenericRelationshipStringTest.cs index 18dd24f8331..e80a12256de 100644 --- a/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderGenericRelationshipStringTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderGenericRelationshipStringTest.cs @@ -37,7 +37,8 @@ protected override TestModelBuilder CreateModelBuilder(Action new GenericStringTestModelBuilder(Fixture, configure); } - public class GenericStringTestModelBuilder(ModelBuilderFixtureBase fixture, Action? configure) : TestModelBuilder(fixture, configure) + public class GenericStringTestModelBuilder(ModelBuilderFixtureBase fixture, Action? configure) + : TestModelBuilder(fixture, configure) { public override TestEntityTypeBuilder Entity() => new GenericStringTestEntityTypeBuilder(ModelBuilder.Entity()); @@ -75,7 +76,8 @@ public override string GetDisplayName(Type entityType) => entityType.FullName!; } - protected class GenericStringTestEntityTypeBuilder(EntityTypeBuilder entityTypeBuilder) : GenericTestEntityTypeBuilder(entityTypeBuilder) + protected class GenericStringTestEntityTypeBuilder(EntityTypeBuilder entityTypeBuilder) + : GenericTestEntityTypeBuilder(entityTypeBuilder) where TEntity : class { protected override TestEntityTypeBuilder Wrap(EntityTypeBuilder entityTypeBuilder) @@ -187,7 +189,8 @@ public override TestReferenceCollectionBuilder HasPrinc keyExpression.GetMemberAccessList().Select(p => p.GetSimpleMemberName()).ToArray())); } - protected class GenericStringTestReferenceReferenceBuilder(ReferenceReferenceBuilder referenceReferenceBuilder) + protected class GenericStringTestReferenceReferenceBuilder( + ReferenceReferenceBuilder referenceReferenceBuilder) : GenericTestReferenceReferenceBuilder(referenceReferenceBuilder) where TEntity : class where TRelatedEntity : class @@ -229,7 +232,8 @@ protected class GenericStringTestCollectionCollectionBuilder(OwnedNavigationBuilder ownedNavigationBuilder) + protected class GenericStringTestOwnedNavigationBuilder( + OwnedNavigationBuilder ownedNavigationBuilder) : GenericTestOwnedNavigationBuilder(ownedNavigationBuilder) where TEntity : class where TDependentEntity : class diff --git a/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderGenericRelationshipTypeTest.cs b/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderGenericRelationshipTypeTest.cs index fda3367c22e..e42b82f6c3b 100644 --- a/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderGenericRelationshipTypeTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderGenericRelationshipTypeTest.cs @@ -19,7 +19,8 @@ protected override TestModelBuilder CreateModelBuilder(Action new GenericTypeTestModelBuilder(Fixture, configure); } - public class GenericTypeTestModelBuilder(ModelBuilderFixtureBase fixture, Action? configure) : TestModelBuilder(fixture, configure) + public class GenericTypeTestModelBuilder(ModelBuilderFixtureBase fixture, Action? configure) + : TestModelBuilder(fixture, configure) { public override TestEntityTypeBuilder Entity() => new GenericTypeTestEntityTypeBuilder(ModelBuilder.Entity()); @@ -54,7 +55,8 @@ public override TestModelBuilder Ignore() } } - protected class GenericTypeTestEntityTypeBuilder(EntityTypeBuilder entityTypeBuilder) : GenericTestEntityTypeBuilder(entityTypeBuilder) + protected class GenericTypeTestEntityTypeBuilder(EntityTypeBuilder entityTypeBuilder) + : GenericTestEntityTypeBuilder(entityTypeBuilder) where TEntity : class { protected override TestEntityTypeBuilder Wrap(EntityTypeBuilder entityTypeBuilder) @@ -89,7 +91,8 @@ public override TestCollectionNavigationBuilder HasMany => new GenericTypeTestCollectionNavigationBuilder(EntityTypeBuilder.HasMany(navigationExpression)); } - protected class GenericTypeTestPropertyBuilder(PropertyBuilder propertyBuilder) : GenericTestPropertyBuilder(propertyBuilder) + protected class GenericTypeTestPropertyBuilder(PropertyBuilder propertyBuilder) + : GenericTestPropertyBuilder(propertyBuilder) { protected override TestPropertyBuilder Wrap(PropertyBuilder propertyBuilder) => new GenericTypeTestPropertyBuilder(propertyBuilder); @@ -112,7 +115,8 @@ public override TestPropertyBuilder HasConversion Wrap(PropertyBuilder.HasConversion(typeof(TConverter), typeof(TComparer), typeof(TProviderComparer))); } - protected class GenericTypeTestReferenceNavigationBuilder(ReferenceNavigationBuilder referenceNavigationBuilder) : GenericTestReferenceNavigationBuilder( + ReferenceNavigationBuilder referenceNavigationBuilder) : GenericTestReferenceNavigationBuilder(referenceNavigationBuilder) where TEntity : class where TRelatedEntity : class @@ -135,7 +139,8 @@ public override TestCollectionCollectionBuilder WithMan CollectionNavigationBuilder.WithMany(navigationExpression)); } - protected class GenericTypeTestReferenceReferenceBuilder(ReferenceReferenceBuilder referenceReferenceBuilder) + protected class GenericTypeTestReferenceReferenceBuilder( + ReferenceReferenceBuilder referenceReferenceBuilder) : GenericTestReferenceReferenceBuilder(referenceReferenceBuilder) where TEntity : class where TRelatedEntity : class @@ -278,7 +283,8 @@ public override TestEntityTypeBuilder UsingEntity( new GenericTypeTestEntityTypeBuilder(new EntityTypeBuilder(e.Metadata))))); } - protected class GenericTypeTestOwnedNavigationBuilder(OwnedNavigationBuilder ownedNavigationBuilder) + protected class GenericTypeTestOwnedNavigationBuilder( + OwnedNavigationBuilder ownedNavigationBuilder) : GenericTestOwnedNavigationBuilder(ownedNavigationBuilder) where TEntity : class where TRelatedEntity : class diff --git a/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderGenericTest.cs b/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderGenericTest.cs index 9b4b0c97154..0f91ab44316 100644 --- a/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderGenericTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderGenericTest.cs @@ -1,12 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.ComponentModel.DataAnnotations.Schema; +#nullable enable + using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using Microsoft.EntityFrameworkCore.Metadata.Internal; -#nullable enable - // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.ModelBuilding; diff --git a/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderNonGenericStringTest.cs b/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderNonGenericStringTest.cs index 691ddf4645c..c8c4bb58bec 100644 --- a/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderNonGenericStringTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderNonGenericStringTest.cs @@ -33,7 +33,7 @@ protected override TestModelBuilder CreateModelBuilder(Action Assert.Throws( - base.WithMany_pointing_to_keyless_entity_throws); + base.WithMany_pointing_to_keyless_entity_throws); } public class NonGenericStringManyToOneType(InMemoryModelBuilderFixture fixture) : InMemoryManyToOne(fixture) @@ -48,7 +48,8 @@ protected override TestModelBuilder CreateModelBuilder(Action new NonGenericStringTestModelBuilder(Fixture, configure); } - private class NonGenericStringTestModelBuilder(ModelBuilderFixtureBase fixture, Action? configure) : TestModelBuilder(fixture, configure) + private class NonGenericStringTestModelBuilder(ModelBuilderFixtureBase fixture, Action? configure) + : TestModelBuilder(fixture, configure) { public override TestEntityTypeBuilder Entity() => new NonGenericStringTestEntityTypeBuilder(ModelBuilder.Entity(typeof(TEntity))); @@ -86,7 +87,8 @@ public override string GetDisplayName(Type entityType) => entityType.FullName!; } - private class NonGenericStringTestEntityTypeBuilder(EntityTypeBuilder entityTypeBuilder) : NonGenericTestEntityTypeBuilder(entityTypeBuilder) + private class NonGenericStringTestEntityTypeBuilder(EntityTypeBuilder entityTypeBuilder) + : NonGenericTestEntityTypeBuilder(entityTypeBuilder) where TEntity : class { protected override NonGenericTestEntityTypeBuilder Wrap(EntityTypeBuilder entityTypeBuilder) @@ -144,7 +146,8 @@ public override TestCollectionNavigationBuilder HasMany navigationExpression?.GetMemberAccess().GetSimpleMemberName())); } - private class NonGenericStringTestReferenceNavigationBuilder(ReferenceNavigationBuilder referenceNavigationBuilder) + private class NonGenericStringTestReferenceNavigationBuilder( + ReferenceNavigationBuilder referenceNavigationBuilder) : NonGenericTestReferenceNavigationBuilder(referenceNavigationBuilder) where TEntity : class where TRelatedEntity : class @@ -156,7 +159,8 @@ public override TestReferenceReferenceBuilder WithOne( navigationExpression?.GetMemberAccess().GetSimpleMemberName())); } - private class NonGenericStringTestReferenceReferenceBuilder(ReferenceReferenceBuilder referenceReferenceBuilder) + private class NonGenericStringTestReferenceReferenceBuilder( + ReferenceReferenceBuilder referenceReferenceBuilder) : NonGenericTestReferenceReferenceBuilder(referenceReferenceBuilder) where TEntity : class where TRelatedEntity : class diff --git a/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderNonGenericUnqualifiedStringTest.cs b/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderNonGenericUnqualifiedStringTest.cs index dac0a0a56d9..0f5fd8e1237 100644 --- a/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderNonGenericUnqualifiedStringTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderNonGenericUnqualifiedStringTest.cs @@ -13,7 +13,8 @@ protected override TestModelBuilder CreateModelBuilder(Action new NonGenericStringTestModelBuilder(Fixture, configure); } - private class NonGenericStringTestModelBuilder(ModelBuilderFixtureBase fixture, Action? configure) : TestModelBuilder(fixture, configure) + private class NonGenericStringTestModelBuilder(ModelBuilderFixtureBase fixture, Action? configure) + : TestModelBuilder(fixture, configure) { public override TestEntityTypeBuilder Entity() => new NonGenericStringTestEntityTypeBuilder(ModelBuilder.Entity(typeof(TEntity))); @@ -48,7 +49,8 @@ public override TestModelBuilder Ignore() } } - private class NonGenericStringTestEntityTypeBuilder(EntityTypeBuilder entityTypeBuilder) : NonGenericTestEntityTypeBuilder(entityTypeBuilder) + private class NonGenericStringTestEntityTypeBuilder(EntityTypeBuilder entityTypeBuilder) + : NonGenericTestEntityTypeBuilder(entityTypeBuilder) where TEntity : class { protected override NonGenericTestEntityTypeBuilder Wrap(EntityTypeBuilder entityTypeBuilder) @@ -112,7 +114,8 @@ public override TestCollectionNavigationBuilder HasMany } } - private class NonGenericStringTestReferenceNavigationBuilder(ReferenceNavigationBuilder referenceNavigationBuilder) : NonGenericTestReferenceNavigationBuilder< + private class NonGenericStringTestReferenceNavigationBuilder( + ReferenceNavigationBuilder referenceNavigationBuilder) : NonGenericTestReferenceNavigationBuilder< TEntity, TRelatedEntity>(referenceNavigationBuilder) where TEntity : class where TRelatedEntity : class @@ -124,7 +127,8 @@ public override TestReferenceReferenceBuilder WithOne( navigationExpression?.GetMemberAccess().GetSimpleMemberName())); } - private class NonGenericStringTestReferenceReferenceBuilder(ReferenceReferenceBuilder referenceReferenceBuilder) : NonGenericTestReferenceReferenceBuilder< + private class NonGenericStringTestReferenceReferenceBuilder( + ReferenceReferenceBuilder referenceReferenceBuilder) : NonGenericTestReferenceReferenceBuilder< TEntity, TRelatedEntity>(referenceReferenceBuilder) where TEntity : class where TRelatedEntity : class diff --git a/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderTest.cs b/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderTest.cs index b3708b71b12..2050f207959 100644 --- a/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ModelBuilding/InMemoryModelBuilderTest.cs @@ -8,25 +8,34 @@ namespace Microsoft.EntityFrameworkCore.ModelBuilding; public class InMemoryModelBuilderTest : ModelBuilderTest { - public abstract class InMemoryNonRelationship(InMemoryModelBuilderFixture fixture) : NonRelationshipTestBase(fixture), IClassFixture; + public abstract class InMemoryNonRelationship(InMemoryModelBuilderFixture fixture) + : NonRelationshipTestBase(fixture), IClassFixture; - public abstract class InMemoryComplexType(InMemoryModelBuilderFixture fixture) : ComplexTypeTestBase(fixture), IClassFixture; + public abstract class InMemoryComplexType(InMemoryModelBuilderFixture fixture) + : ComplexTypeTestBase(fixture), IClassFixture; - public abstract class InMemoryInheritance(InMemoryModelBuilderFixture fixture) : InheritanceTestBase(fixture), IClassFixture; + public abstract class InMemoryInheritance(InMemoryModelBuilderFixture fixture) + : InheritanceTestBase(fixture), IClassFixture; - public abstract class InMemoryOneToMany(InMemoryModelBuilderFixture fixture) : OneToManyTestBase(fixture), IClassFixture; + public abstract class InMemoryOneToMany(InMemoryModelBuilderFixture fixture) + : OneToManyTestBase(fixture), IClassFixture; - public abstract class InMemoryManyToMany(InMemoryModelBuilderFixture fixture) : ManyToManyTestBase(fixture), IClassFixture; + public abstract class InMemoryManyToMany(InMemoryModelBuilderFixture fixture) + : ManyToManyTestBase(fixture), IClassFixture; - public abstract class InMemoryManyToOne(InMemoryModelBuilderFixture fixture) : ManyToOneTestBase(fixture), IClassFixture; + public abstract class InMemoryManyToOne(InMemoryModelBuilderFixture fixture) + : ManyToOneTestBase(fixture), IClassFixture; - public abstract class InMemoryOneToOne(InMemoryModelBuilderFixture fixture) : OneToOneTestBase(fixture), IClassFixture; + public abstract class InMemoryOneToOne(InMemoryModelBuilderFixture fixture) + : OneToOneTestBase(fixture), IClassFixture; - public abstract class InMemoryOwnedTypes(InMemoryModelBuilderFixture fixture) : OwnedTypesTestBase(fixture), IClassFixture; + public abstract class InMemoryOwnedTypes(InMemoryModelBuilderFixture fixture) + : OwnedTypesTestBase(fixture), IClassFixture; public class InMemoryModelBuilderFixture : ModelBuilderFixtureBase { - public override TestHelpers TestHelpers => InMemoryTestHelpers.Instance; + public override TestHelpers TestHelpers + => InMemoryTestHelpers.Instance; public override bool ForeignKeysHaveIndexes => false; diff --git a/test/EFCore.InMemory.FunctionalTests/MonsterFixupSnapshotInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/MonsterFixupSnapshotInMemoryTest.cs index 9161871b951..32ea6cde199 100644 --- a/test/EFCore.InMemory.FunctionalTests/MonsterFixupSnapshotInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/MonsterFixupSnapshotInMemoryTest.cs @@ -3,8 +3,9 @@ namespace Microsoft.EntityFrameworkCore; -public class MonsterFixupSnapshotInMemoryTest(MonsterFixupSnapshotInMemoryTest.MonsterFixupSnapshotInMemoryFixture fixture) : MonsterFixupTestBase< - MonsterFixupSnapshotInMemoryTest.MonsterFixupSnapshotInMemoryFixture>(fixture) +public class MonsterFixupSnapshotInMemoryTest(MonsterFixupSnapshotInMemoryTest.MonsterFixupSnapshotInMemoryFixture fixture) + : MonsterFixupTestBase< + MonsterFixupSnapshotInMemoryTest.MonsterFixupSnapshotInMemoryFixture>(fixture) { public class MonsterFixupSnapshotInMemoryFixture : MonsterFixupSnapshotFixtureBase { diff --git a/test/EFCore.InMemory.FunctionalTests/MusicStoreInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/MusicStoreInMemoryTest.cs index df23e8fe011..49ffa9d389c 100644 --- a/test/EFCore.InMemory.FunctionalTests/MusicStoreInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/MusicStoreInMemoryTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore; -public class MusicStoreInMemoryTest(MusicStoreInMemoryTest.MusicStoreInMemoryFixture fixture) : MusicStoreTestBase(fixture) +public class MusicStoreInMemoryTest(MusicStoreInMemoryTest.MusicStoreInMemoryFixture fixture) + : MusicStoreTestBase(fixture) { public class MusicStoreInMemoryFixture : MusicStoreFixtureBase { diff --git a/test/EFCore.InMemory.FunctionalTests/NonLoadingNavigationsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/NonLoadingNavigationsInMemoryTest.cs index 9199cc0e5a0..880047d49a1 100644 --- a/test/EFCore.InMemory.FunctionalTests/NonLoadingNavigationsInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/NonLoadingNavigationsInMemoryTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore; -public class NonLoadingNavigationsInMemoryTest(NonLoadingNavigationsInMemoryTest.NonLoadingNavigationsInMemoryFixture fixture) : LoadTestBase(fixture) +public class NonLoadingNavigationsInMemoryTest(NonLoadingNavigationsInMemoryTest.NonLoadingNavigationsInMemoryFixture fixture) + : LoadTestBase(fixture) { protected override bool LazyLoadingEnabled => false; diff --git a/test/EFCore.InMemory.FunctionalTests/NotificationEntitiesInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/NotificationEntitiesInMemoryTest.cs index 8426e1a25a3..27c0f651ec4 100644 --- a/test/EFCore.InMemory.FunctionalTests/NotificationEntitiesInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/NotificationEntitiesInMemoryTest.cs @@ -3,8 +3,9 @@ namespace Microsoft.EntityFrameworkCore; -public class NotificationEntitiesInMemoryTest(NotificationEntitiesInMemoryTest.NotificationEntitiesInMemoryFixture fixture) : NotificationEntitiesTestBase< - NotificationEntitiesInMemoryTest.NotificationEntitiesInMemoryFixture>(fixture) +public class NotificationEntitiesInMemoryTest(NotificationEntitiesInMemoryTest.NotificationEntitiesInMemoryFixture fixture) + : NotificationEntitiesTestBase< + NotificationEntitiesInMemoryTest.NotificationEntitiesInMemoryFixture>(fixture) { public class NotificationEntitiesInMemoryFixture : NotificationEntitiesFixtureBase { diff --git a/test/EFCore.InMemory.FunctionalTests/OptimisticConcurrencyInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/OptimisticConcurrencyInMemoryTest.cs index 61abad52f34..84d753a8f76 100644 --- a/test/EFCore.InMemory.FunctionalTests/OptimisticConcurrencyInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/OptimisticConcurrencyInMemoryTest.cs @@ -3,9 +3,11 @@ namespace Microsoft.EntityFrameworkCore; -public class OptimisticConcurrencyULongInMemoryTest(F1ULongInMemoryFixture fixture) : OptimisticConcurrencyInMemoryTestBase(fixture); +public class OptimisticConcurrencyULongInMemoryTest(F1ULongInMemoryFixture fixture) + : OptimisticConcurrencyInMemoryTestBase(fixture); -public class OptimisticConcurrencyInMemoryTest(F1InMemoryFixture fixture) : OptimisticConcurrencyInMemoryTestBase(fixture); +public class OptimisticConcurrencyInMemoryTest(F1InMemoryFixture fixture) + : OptimisticConcurrencyInMemoryTestBase(fixture); public abstract class OptimisticConcurrencyInMemoryTestBase(TFixture fixture) : OptimisticConcurrencyTestBase(fixture) diff --git a/test/EFCore.InMemory.FunctionalTests/PropertyValuesInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/PropertyValuesInMemoryTest.cs index e53710149e9..95edb17f942 100644 --- a/test/EFCore.InMemory.FunctionalTests/PropertyValuesInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/PropertyValuesInMemoryTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore; -public class PropertyValuesInMemoryTest(PropertyValuesInMemoryTest.PropertyValuesInMemoryFixture fixture) : PropertyValuesTestBase(fixture) +public class PropertyValuesInMemoryTest(PropertyValuesInMemoryTest.PropertyValuesInMemoryFixture fixture) + : PropertyValuesTestBase(fixture) { public override Task Complex_current_values_can_be_accessed_as_a_property_dictionary_using_IProperty() => Assert.ThrowsAsync( // In-memory database cannot query complex types @@ -46,7 +47,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.Ignore(e => e.Culture); b.Ignore(e => e.Milk); }); - } } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/FiltersInheritanceQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/FiltersInheritanceQueryInMemoryTest.cs index 83e7a031463..3427fcc712a 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/FiltersInheritanceQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/FiltersInheritanceQueryInMemoryTest.cs @@ -3,4 +3,5 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class FiltersInheritanceQueryInMemoryTest(FiltersInheritanceQueryInMemoryFixture fixture) : FiltersInheritanceQueryTestBase(fixture); +public class FiltersInheritanceQueryInMemoryTest(FiltersInheritanceQueryInMemoryFixture fixture) + : FiltersInheritanceQueryTestBase(fixture); diff --git a/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs index 4d6b2f4b184..fdd78cef5a4 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.InMemory.Internal; using Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel; -using Xunit.Sdk; namespace Microsoft.EntityFrameworkCore.Query; diff --git a/test/EFCore.InMemory.FunctionalTests/Query/IncludeOneToOneInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/IncludeOneToOneInMemoryTest.cs index 7db214c779f..96a992fe374 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/IncludeOneToOneInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/IncludeOneToOneInMemoryTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class IncludeOneToOneInMemoryTest(IncludeOneToOneInMemoryTest.OneToOneQueryInMemoryFixture fixture) : IncludeOneToOneTestBase(fixture) +public class IncludeOneToOneInMemoryTest(IncludeOneToOneInMemoryTest.OneToOneQueryInMemoryFixture fixture) + : IncludeOneToOneTestBase(fixture) { public class OneToOneQueryInMemoryFixture : OneToOneQueryFixtureBase { diff --git a/test/EFCore.InMemory.FunctionalTests/Query/IncompleteMappingInheritanceQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/IncompleteMappingInheritanceQueryInMemoryTest.cs index 03edfb5389b..5bc8c697d26 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/IncompleteMappingInheritanceQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/IncompleteMappingInheritanceQueryInMemoryTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class IncompleteMappingInheritanceQueryInMemoryTest(IncompleteMappingInheritanceQueryInMemoryFixture fixture) : InheritanceQueryTestBase(fixture) +public class IncompleteMappingInheritanceQueryInMemoryTest(IncompleteMappingInheritanceQueryInMemoryFixture fixture) + : InheritanceQueryTestBase(fixture) { public override async Task Can_query_all_animal_views(bool async) { diff --git a/test/EFCore.InMemory.FunctionalTests/Query/InheritanceRelationshipsQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/InheritanceRelationshipsQueryInMemoryTest.cs index 70682997865..64efa13f59b 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/InheritanceRelationshipsQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/InheritanceRelationshipsQueryInMemoryTest.cs @@ -3,5 +3,6 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class InheritanceRelationshipsQueryInMemoryTest(InheritanceRelationshipsQueryInMemoryFixture fixture) : InheritanceRelationshipsQueryTestBase< - InheritanceRelationshipsQueryInMemoryFixture>(fixture); +public class InheritanceRelationshipsQueryInMemoryTest(InheritanceRelationshipsQueryInMemoryFixture fixture) + : InheritanceRelationshipsQueryTestBase< + InheritanceRelationshipsQueryInMemoryFixture>(fixture); diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAggregateOperatorsQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAggregateOperatorsQueryInMemoryTest.cs index 2b91264909c..4fbd11e77d6 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAggregateOperatorsQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAggregateOperatorsQueryInMemoryTest.cs @@ -6,7 +6,6 @@ namespace Microsoft.EntityFrameworkCore.Query; public class NorthwindAggregateOperatorsQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) : NorthwindAggregateOperatorsQueryTestBase>(fixture) { - // InMemory can throw server side exception public override async Task Average_no_data_subquery(bool async) => Assert.Equal( diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsNoTrackingQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsNoTrackingQueryInMemoryTest.cs index f3eedf76916..9750c5ffbb2 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsNoTrackingQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsNoTrackingQueryInMemoryTest.cs @@ -3,5 +3,6 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class NorthwindAsNoTrackingQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) : NorthwindAsNoTrackingQueryTestBase< - NorthwindQueryInMemoryFixture>(fixture); +public class NorthwindAsNoTrackingQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) + : NorthwindAsNoTrackingQueryTestBase< + NorthwindQueryInMemoryFixture>(fixture); diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsTrackingQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsTrackingQueryInMemoryTest.cs index 0612b33b427..cfe6d2593c5 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsTrackingQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsTrackingQueryInMemoryTest.cs @@ -3,4 +3,5 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class NorthwindAsTrackingQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) : NorthwindAsTrackingQueryTestBase>(fixture); +public class NorthwindAsTrackingQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) + : NorthwindAsTrackingQueryTestBase>(fixture); diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindCompiledQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindCompiledQueryInMemoryTest.cs index 3ddd7408e95..abb05e2df8d 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindCompiledQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindCompiledQueryInMemoryTest.cs @@ -3,4 +3,5 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class NorthwindCompiledQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) : NorthwindCompiledQueryTestBase>(fixture); +public class NorthwindCompiledQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) + : NorthwindCompiledQueryTestBase>(fixture); diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindKeylessEntitiesQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindKeylessEntitiesQueryInMemoryTest.cs index 266a51c0a63..eba6a41d5b7 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindKeylessEntitiesQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindKeylessEntitiesQueryInMemoryTest.cs @@ -6,7 +6,6 @@ namespace Microsoft.EntityFrameworkCore.Query; public class NorthwindKeylessEntitiesQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) : NorthwindKeylessEntitiesQueryTestBase>(fixture) { - // mapping to view not supported on InMemory public override Task KeylessEntity_by_database_view(bool async) => Task.CompletedTask; diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs index d7e36df9e11..4c7da207ccb 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs @@ -50,6 +50,4 @@ public override Task Where_compare_tuple_constructed_multi_value_not_equal(bool public override Task Where_compare_tuple_create_constructed_multi_value_not_equal(bool async) => Task.CompletedTask; - - } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NullKeysInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NullKeysInMemoryTest.cs index 6478fe0a052..a98ca3683c4 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NullKeysInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NullKeysInMemoryTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class NullKeysInMemoryTest(NullKeysInMemoryTest.NullKeysInMemoryFixture fixture) : NullKeysTestBase(fixture) +public class NullKeysInMemoryTest(NullKeysInMemoryTest.NullKeysInMemoryFixture fixture) + : NullKeysTestBase(fixture) { public class NullKeysInMemoryFixture : NullKeysFixtureBase { diff --git a/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs index b03a2f9b49c..d9228539327 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs @@ -583,7 +583,7 @@ private Task Seed5456(MyContext5456 context) new Blog5456 { Id = i + 1, - Posts = [new() { Comments = [new(), new()] }, new()], + Posts = [new Post5456 { Comments = [new Comment5456(), new Comment5456()] }, new Post5456()], Author = new Author5456() }); } @@ -1487,7 +1487,7 @@ public virtual async Task Ordering_of_collection_result_is_correct() private static Task Seed18394(MyContext18394 context) { - var a = new A18394 { PropertyB = new B18394 { PropertyCList = [new() { SomeText = "TestText" }] } }; + var a = new A18394 { PropertyB = new B18394 { PropertyCList = [new C18394 { SomeText = "TestText" }] } }; context.As.Add(a); return context.SaveChangesAsync(); diff --git a/test/EFCore.InMemory.FunctionalTests/Query/WarningsTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/WarningsTest.cs index bc9020d4244..6f337e0891b 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/WarningsTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/WarningsTest.cs @@ -286,9 +286,7 @@ public WarningAsErrorEntity() } private WarningAsErrorEntity(Action lazyLoader) - { - _loader = lazyLoader; - } + => _loader = lazyLoader; public IncludedEntity Nav { diff --git a/test/EFCore.InMemory.FunctionalTests/SaveChangesInterceptionInMemoryTestBase.cs b/test/EFCore.InMemory.FunctionalTests/SaveChangesInterceptionInMemoryTestBase.cs index 8612adaf330..cdb52d890f1 100644 --- a/test/EFCore.InMemory.FunctionalTests/SaveChangesInterceptionInMemoryTestBase.cs +++ b/test/EFCore.InMemory.FunctionalTests/SaveChangesInterceptionInMemoryTestBase.cs @@ -37,7 +37,8 @@ protected override bool ShouldSubscribeToDiagnosticListener } } - public class SaveChangesInterceptionWithDiagnosticsInMemoryTest(SaveChangesInterceptionWithDiagnosticsInMemoryTest.InterceptionInMemoryFixture fixture) + public class SaveChangesInterceptionWithDiagnosticsInMemoryTest( + SaveChangesInterceptionWithDiagnosticsInMemoryTest.InterceptionInMemoryFixture fixture) : SaveChangesInterceptionInMemoryTestBase(fixture), IClassFixture { diff --git a/test/EFCore.InMemory.FunctionalTests/Scaffolding/CompiledModelInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Scaffolding/CompiledModelInMemoryTest.cs index e354ce9e31e..07c5954d2a2 100644 --- a/test/EFCore.InMemory.FunctionalTests/Scaffolding/CompiledModelInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Scaffolding/CompiledModelInMemoryTest.cs @@ -31,11 +31,12 @@ public virtual Task Empty_model() [ConditionalFact] public virtual Task Global_namespace() => Test( - modelBuilder => modelBuilder.Entity("1", e => - { - e.Property("Id"); - e.HasKey("Id"); - }), + modelBuilder => modelBuilder.Entity( + "1", e => + { + e.Property("Id"); + e.HasKey("Id"); + }), model => { Assert.NotNull(model.FindEntityType("1")); @@ -57,7 +58,8 @@ public virtual Task Self_referential_property() } ); - public class SelfReferentialPropertyValueConverter(ConverterMappingHints hints) : ValueConverter(v => null, v => null, hints) + public class SelfReferentialPropertyValueConverter(ConverterMappingHints hints) + : ValueConverter(v => null, v => null, hints) { public SelfReferentialPropertyValueConverter() : this(new ConverterMappingHints()) @@ -91,7 +93,8 @@ public virtual Task Throws_for_constructor_binding() [ConditionalFact] public virtual Task Manual_lazy_loading() => Test( - modelBuilder => { + modelBuilder => + { modelBuilder.Entity(); modelBuilder.Entity( @@ -168,8 +171,7 @@ public virtual Task Lazy_loading_proxies() { var principal = new LazyProxiesEntity2 { - Id = 1, - CollectionNavigation = new List { new LazyProxiesEntity1 { Id = 1 } } + Id = 1, CollectionNavigation = new List { new() { Id = 1 } } }; c.Set().Add(principal); @@ -204,8 +206,7 @@ public virtual Task Lazy_loading_manual() { var principal = new LazyProxiesEntity3 { - Id = 1, - CollectionNavigation = new List { new LazyProxiesEntity4 { Id = 1 } } + Id = 1, CollectionNavigation = new List { new() { Id = 1 } } }; c.Set().Add(principal); @@ -242,9 +243,7 @@ public LazyProxiesEntity3() } protected LazyProxiesEntity3(ILazyLoader lazyLoader) - { - LazyLoader = lazyLoader; - } + => LazyLoader = lazyLoader; private ILazyLoader? LazyLoader { get; set; } @@ -271,9 +270,7 @@ public LazyProxiesEntity4() } protected LazyProxiesEntity4(Action lazyLoader) - { - LazyLoader = lazyLoader; - } + => LazyLoader = lazyLoader; private Action? LazyLoader { get; set; } @@ -320,22 +317,24 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) [ConditionalFact] public virtual Task Throws_for_value_generator() => Test( - modelBuilder => modelBuilder.Entity("MyEntity", e => - { - e.Property("Id").HasValueGenerator((p, e) => null!); - e.HasKey("Id"); - }), + modelBuilder => modelBuilder.Entity( + "MyEntity", e => + { + e.Property("Id").HasValueGenerator((p, e) => null!); + e.HasKey("Id"); + }), expectedExceptionMessage: DesignStrings.CompiledModelValueGenerator( "MyEntity", "Id", nameof(PropertyBuilder.HasValueGeneratorFactory))); [ConditionalFact] public virtual Task Custom_value_converter() => Test( - modelBuilder => modelBuilder.Entity("MyEntity", e => - { - e.Property("Id").HasConversion(i => i, i => i); - e.HasKey("Id"); - }), + modelBuilder => modelBuilder.Entity( + "MyEntity", e => + { + e.Property("Id").HasConversion(i => i, i => i); + e.HasKey("Id"); + }), model => { var entityType = model.GetEntityTypes().Single(); @@ -347,11 +346,12 @@ public virtual Task Custom_value_converter() [ConditionalFact] public virtual Task Custom_value_comparer() => Test( - modelBuilder => modelBuilder.Entity("MyEntity", e => - { - e.Property("Id").HasConversion(typeof(int), new FakeValueComparer()); - e.HasKey("Id"); - }), + modelBuilder => modelBuilder.Entity( + "MyEntity", e => + { + e.Property("Id").HasConversion(typeof(int), new FakeValueComparer()); + e.HasKey("Id"); + }), model => { var entityType = model.GetEntityTypes().Single(); @@ -380,11 +380,12 @@ public override object Snapshot(object? instance) [ConditionalFact] public virtual Task Custom_provider_value_comparer() => Test( - modelBuilder => modelBuilder.Entity("MyEntity", e => - { - e.Property("Id").HasConversion(typeof(int), null, new FakeValueComparer()); - e.HasKey("Id"); - }), + modelBuilder => modelBuilder.Entity( + "MyEntity", e => + { + e.Property("Id").HasConversion(typeof(int), null, new FakeValueComparer()); + e.HasKey("Id"); + }), model => { var entityType = model.GetEntityTypes().Single(); @@ -400,12 +401,13 @@ is Expression> lambda [ConditionalFact] public virtual Task Custom_type_mapping() => Test( - modelBuilder => modelBuilder.Entity("MyEntity", e => - { - e.Property("Id").Metadata.SetTypeMapping( + modelBuilder => modelBuilder.Entity( + "MyEntity", e => + { + e.Property("Id").Metadata.SetTypeMapping( new InMemoryTypeMapping(typeof(int), jsonValueReaderWriter: JsonInt32ReaderWriter.Instance)); - e.HasKey("Id"); - }), + e.HasKey("Id"); + }), model => { var entityType = model.GetEntityTypes().Single(); @@ -418,10 +420,11 @@ public virtual Task Custom_type_mapping() [ConditionalFact] public virtual Task Fully_qualified_model() => Test( - modelBuilder => { + modelBuilder => + { modelBuilder.Entity(); modelBuilder.Entity(); - modelBuilder.Entity( + modelBuilder.Entity( eb => { eb.HasDiscriminator().HasValue("DerivedIdentityUser"); @@ -511,8 +514,11 @@ protected override bool ShouldUseFullName(string shortTypeName) => base.ShouldUseFullName(shortTypeName) || shortTypeName is nameof(System.Index) or nameof(Internal); } - protected override TestHelpers TestHelpers => InMemoryTestHelpers.Instance; - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override TestHelpers TestHelpers + => InMemoryTestHelpers.Instance; + + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; protected override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder) diff --git a/test/EFCore.InMemory.FunctionalTests/ShadowStateUpdateTest.cs b/test/EFCore.InMemory.FunctionalTests/ShadowStateUpdateTest.cs index 9a3f75ba2e5..8dfa647fc22 100644 --- a/test/EFCore.InMemory.FunctionalTests/ShadowStateUpdateTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ShadowStateUpdateTest.cs @@ -80,9 +80,7 @@ public async Task Can_add_update_delete_end_to_end_using_partial_shadow_state() private class Customer { private Customer(object[] values) - { - Id = (int)values[0]; - } + => Id = (int)values[0]; public Customer() { diff --git a/test/EFCore.InMemory.FunctionalTests/StoreGeneratedFixupInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/StoreGeneratedFixupInMemoryTest.cs index 589eeaaf615..24982ced5f5 100644 --- a/test/EFCore.InMemory.FunctionalTests/StoreGeneratedFixupInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/StoreGeneratedFixupInMemoryTest.cs @@ -5,8 +5,9 @@ namespace Microsoft.EntityFrameworkCore; -public class StoreGeneratedFixupInMemoryTest(StoreGeneratedFixupInMemoryTest.StoreGeneratedFixupInMemoryFixture fixture) : StoreGeneratedFixupTestBase< - StoreGeneratedFixupInMemoryTest.StoreGeneratedFixupInMemoryFixture>(fixture) +public class StoreGeneratedFixupInMemoryTest(StoreGeneratedFixupInMemoryTest.StoreGeneratedFixupInMemoryFixture fixture) + : StoreGeneratedFixupTestBase< + StoreGeneratedFixupInMemoryTest.StoreGeneratedFixupInMemoryFixture>(fixture) { public override void Temporary_value_equals_database_generated_value() { diff --git a/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithSensitiveDataLoggingTest.cs b/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithSensitiveDataLoggingTest.cs index 9e6ab16d058..da4f9f3e979 100644 --- a/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithSensitiveDataLoggingTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithSensitiveDataLoggingTest.cs @@ -5,8 +5,9 @@ namespace Microsoft.EntityFrameworkCore; -public class UpdatesInMemoryWithSensitiveDataLoggingTest(UpdatesInMemoryWithSensitiveDataLoggingTest.UpdatesInMemoryWithSensitiveDataLoggingFixture fixture) - : UpdatesInMemoryTestBase(fixture) +public class UpdatesInMemoryWithSensitiveDataLoggingTest( + UpdatesInMemoryWithSensitiveDataLoggingTest.UpdatesInMemoryWithSensitiveDataLoggingFixture fixture) + : UpdatesInMemoryTestBase(fixture) { protected override string UpdateConcurrencyTokenMessage => InMemoryStrings.UpdateConcurrencyTokenExceptionSensitive( diff --git a/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithoutSensitiveDataLoggingTest.cs b/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithoutSensitiveDataLoggingTest.cs index 99ac79afb33..4421cddf0f9 100644 --- a/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithoutSensitiveDataLoggingTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithoutSensitiveDataLoggingTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; -public class UpdatesInMemoryWithoutSensitiveDataLoggingTest(UpdatesInMemoryWithoutSensitiveDataLoggingTest.UpdatesInMemoryWithoutSensitiveDataLoggingFixture fixture) +public class UpdatesInMemoryWithoutSensitiveDataLoggingTest( + UpdatesInMemoryWithoutSensitiveDataLoggingTest.UpdatesInMemoryWithoutSensitiveDataLoggingFixture fixture) : UpdatesInMemoryTestBase(fixture) { protected override string UpdateConcurrencyTokenMessage diff --git a/test/EFCore.InMemory.Tests/Storage/InMemoryDatabaseCreatorTest.cs b/test/EFCore.InMemory.Tests/Storage/InMemoryDatabaseCreatorTest.cs index 44985085f8f..19fe82ac5f7 100644 --- a/test/EFCore.InMemory.Tests/Storage/InMemoryDatabaseCreatorTest.cs +++ b/test/EFCore.InMemory.Tests/Storage/InMemoryDatabaseCreatorTest.cs @@ -55,9 +55,10 @@ private static InMemoryDatabaseCreator CreateDatabaseCreator(IServiceProvider se [ConditionalFact] public void EnsureCreated_throws_for_missing_seed() { - using var context = new FraggleContext( asyncSeed: true); + using var context = new FraggleContext(asyncSeed: true); - Assert.Equal(CoreStrings.MissingSeeder, + Assert.Equal( + CoreStrings.MissingSeeder, Assert.Throws(() => context.Database.EnsureCreated()).Message); } @@ -66,8 +67,9 @@ public async Task EnsureCreatedAsync_throws_for_missing_seed() { using var context = new FraggleContext(seed: true); - Assert.Equal(CoreStrings.MissingSeeder, - (await Assert.ThrowsAsync(() => context.Database.EnsureCreatedAsync())).Message); + Assert.Equal( + CoreStrings.MissingSeeder, + (await Assert.ThrowsAsync(() => context.Database.EnsureCreatedAsync())).Message); } [ConditionalFact] diff --git a/test/EFCore.InMemory.Tests/ValueGeneration/InMemoryIntegerValueGeneratorTest.cs b/test/EFCore.InMemory.Tests/ValueGeneration/InMemoryIntegerValueGeneratorTest.cs index b9cef3f4bea..711dd3eacf2 100644 --- a/test/EFCore.InMemory.Tests/ValueGeneration/InMemoryIntegerValueGeneratorTest.cs +++ b/test/EFCore.InMemory.Tests/ValueGeneration/InMemoryIntegerValueGeneratorTest.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. diff --git a/test/EFCore.InMemory.Tests/ValueGeneration/InMemoryValueGeneratorSelectorTest.cs b/test/EFCore.InMemory.Tests/ValueGeneration/InMemoryValueGeneratorSelectorTest.cs index c0987d6155a..c3345646048 100644 --- a/test/EFCore.InMemory.Tests/ValueGeneration/InMemoryValueGeneratorSelectorTest.cs +++ b/test/EFCore.InMemory.Tests/ValueGeneration/InMemoryValueGeneratorSelectorTest.cs @@ -49,26 +49,46 @@ public void Returns_built_in_generators_for_types_setup_for_value_generation_usi var selector = InMemoryTestHelpers.Instance.CreateContextServices(model).GetRequiredService(); - Assert.IsType(selector.TrySelect(entityType.FindProperty("Custom")!, entityType, out var generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("Id")!, entityType, out generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("Long")!, entityType, out generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("Short")!, entityType, out generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("Byte")!, entityType, out generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("NullableInt")!, entityType, out generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("NullableLong")!, entityType, out generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("NullableShort")!, entityType, out generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("NullableByte")!, entityType, out generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("UInt")!, entityType, out generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("ULong")!, entityType, out generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("UShort")!, entityType, out generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("SByte")!, entityType, out generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("NullableUInt")!, entityType, out generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("NullableULong")!, entityType, out generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("NullableUShort")!, entityType, out generator) ? generator : null); - Assert.IsType>(selector.TrySelect(entityType.FindProperty("NullableSByte")!, entityType, out generator) ? generator : null); - Assert.IsType(selector.TrySelect(entityType.FindProperty("String")!, entityType, out generator) ? generator : null); - Assert.IsType(selector.TrySelect(entityType.FindProperty("Guid")!, entityType, out generator) ? generator : null); - Assert.IsType(selector.TrySelect(entityType.FindProperty("Binary")!, entityType, out generator) ? generator : null); + Assert.IsType( + selector.TrySelect(entityType.FindProperty("Custom")!, entityType, out var generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("Id")!, entityType, out generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("Long")!, entityType, out generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("Short")!, entityType, out generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("Byte")!, entityType, out generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("NullableInt")!, entityType, out generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("NullableLong")!, entityType, out generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("NullableShort")!, entityType, out generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("NullableByte")!, entityType, out generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("UInt")!, entityType, out generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("ULong")!, entityType, out generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("UShort")!, entityType, out generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("SByte")!, entityType, out generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("NullableUInt")!, entityType, out generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("NullableULong")!, entityType, out generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("NullableUShort")!, entityType, out generator) ? generator : null); + Assert.IsType>( + selector.TrySelect(entityType.FindProperty("NullableSByte")!, entityType, out generator) ? generator : null); + Assert.IsType( + selector.TrySelect(entityType.FindProperty("String")!, entityType, out generator) ? generator : null); + Assert.IsType( + selector.TrySelect(entityType.FindProperty("Guid")!, entityType, out generator) ? generator : null); + Assert.IsType( + selector.TrySelect(entityType.FindProperty("Binary")!, entityType, out generator) ? generator : null); } [ConditionalTheory] diff --git a/test/EFCore.OData.FunctionalTests/Query/ComplexNavigationsODataQueryTestFixture.cs b/test/EFCore.OData.FunctionalTests/Query/ComplexNavigationsODataQueryTestFixture.cs index b23140662de..dffd4677e47 100644 --- a/test/EFCore.OData.FunctionalTests/Query/ComplexNavigationsODataQueryTestFixture.cs +++ b/test/EFCore.OData.FunctionalTests/Query/ComplexNavigationsODataQueryTestFixture.cs @@ -16,10 +16,8 @@ protected override string StoreName => "ODataComplexNavigations"; public ComplexNavigationsODataQueryTestFixture() - { - (BaseAddress, ClientFactory, _selfHostServer) + => (BaseAddress, ClientFactory, _selfHostServer) = ODataQueryTestFixtureInitializer.Initialize(StoreName, GetEdmModel()); - } private static IEdmModel GetEdmModel() { diff --git a/test/EFCore.OData.FunctionalTests/Query/ComplexNavigationsODataQueryTests.cs b/test/EFCore.OData.FunctionalTests/Query/ComplexNavigationsODataQueryTests.cs index abb3a3cbd1a..b53523594b7 100644 --- a/test/EFCore.OData.FunctionalTests/Query/ComplexNavigationsODataQueryTests.cs +++ b/test/EFCore.OData.FunctionalTests/Query/ComplexNavigationsODataQueryTests.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class ComplexNavigationsODataQueryTests(ComplexNavigationsODataQueryTestFixture fixture) : ODataQueryTestBase(fixture), IClassFixture +public class ComplexNavigationsODataQueryTests(ComplexNavigationsODataQueryTestFixture fixture) + : ODataQueryTestBase(fixture), IClassFixture { [ConditionalFact] public async Task Query_level_ones() diff --git a/test/EFCore.OData.FunctionalTests/Query/GearsOfWarODataQueryTestFixture.cs b/test/EFCore.OData.FunctionalTests/Query/GearsOfWarODataQueryTestFixture.cs index e62ff277de8..02a2c8cf189 100644 --- a/test/EFCore.OData.FunctionalTests/Query/GearsOfWarODataQueryTestFixture.cs +++ b/test/EFCore.OData.FunctionalTests/Query/GearsOfWarODataQueryTestFixture.cs @@ -16,10 +16,8 @@ protected override string StoreName => "ODataGearsOfWarQueryTest"; public GearsOfWarODataQueryTestFixture() - { - (BaseAddress, ClientFactory, _selfHostServer) + => (BaseAddress, ClientFactory, _selfHostServer) = ODataQueryTestFixtureInitializer.Initialize(StoreName, GetEdmModel()); - } private static IEdmModel GetEdmModel() { diff --git a/test/EFCore.OData.FunctionalTests/Query/GearsOfWarODataQueryTests.cs b/test/EFCore.OData.FunctionalTests/Query/GearsOfWarODataQueryTests.cs index a4388b98d18..cad179ec81d 100644 --- a/test/EFCore.OData.FunctionalTests/Query/GearsOfWarODataQueryTests.cs +++ b/test/EFCore.OData.FunctionalTests/Query/GearsOfWarODataQueryTests.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class GearsOfWarODataQueryTests(GearsOfWarODataQueryTestFixture fixture) : ODataQueryTestBase(fixture), IClassFixture +public class GearsOfWarODataQueryTests(GearsOfWarODataQueryTestFixture fixture) + : ODataQueryTestBase(fixture), IClassFixture { [ConditionalFact] public async Task Basic_query_gears() diff --git a/test/EFCore.OData.FunctionalTests/Query/NorthwindODataQueryTestFixture.cs b/test/EFCore.OData.FunctionalTests/Query/NorthwindODataQueryTestFixture.cs index 4f78ca62ad9..52ccbfffc94 100644 --- a/test/EFCore.OData.FunctionalTests/Query/NorthwindODataQueryTestFixture.cs +++ b/test/EFCore.OData.FunctionalTests/Query/NorthwindODataQueryTestFixture.cs @@ -19,13 +19,11 @@ protected override string StoreName => "ODataNorthwind"; public NorthwindODataQueryTestFixture() - { - (BaseAddress, ClientFactory, _selfHostServer) + => (BaseAddress, ClientFactory, _selfHostServer) = ODataQueryTestFixtureInitializer.Initialize( StoreName, GetEdmModel(), [new OrderDetailsControllerActionConvention()]); - } private static IEdmModel GetEdmModel() { diff --git a/test/EFCore.OData.FunctionalTests/Query/NorthwindODataQueryTests.cs b/test/EFCore.OData.FunctionalTests/Query/NorthwindODataQueryTests.cs index e05ec472681..f656928f57b 100644 --- a/test/EFCore.OData.FunctionalTests/Query/NorthwindODataQueryTests.cs +++ b/test/EFCore.OData.FunctionalTests/Query/NorthwindODataQueryTests.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore.Query; -public class NorthwindODataQueryTests(NorthwindODataQueryTestFixture fixture) : ODataQueryTestBase(fixture), IClassFixture +public class NorthwindODataQueryTests(NorthwindODataQueryTestFixture fixture) + : ODataQueryTestBase(fixture), IClassFixture { [ConditionalFact] public async Task Basic_query_customers() diff --git a/test/EFCore.OData.FunctionalTests/TestControllers.cs b/test/EFCore.OData.FunctionalTests/TestControllers.cs index 62778f563ab..56fb978d66d 100644 --- a/test/EFCore.OData.FunctionalTests/TestControllers.cs +++ b/test/EFCore.OData.FunctionalTests/TestControllers.cs @@ -93,25 +93,19 @@ public class TestOkObjectResult : TestObjectResult { public TestOkObjectResult(object innerResult) : base(innerResult) - { - StatusCode = 200; - } + => StatusCode = 200; } public class TestOkObjectResult : TestObjectResult { public TestOkObjectResult(object innerResult) : base(innerResult) - { - StatusCode = 200; - } + => StatusCode = 200; public TestOkObjectResult(T content, TestODataController controller) : base(content) - { - // Controller is unused. - StatusCode = 200; - } + // Controller is unused. + => StatusCode = 200; } public class TestStatusCodeObjectResult(ObjectResult innerResult) : TestObjectResult(innerResult); diff --git a/test/EFCore.Proxies.Tests/ChangeDetectionProxyTests.cs b/test/EFCore.Proxies.Tests/ChangeDetectionProxyTests.cs index a79d9d7e3f5..29acbdab89d 100644 --- a/test/EFCore.Proxies.Tests/ChangeDetectionProxyTests.cs +++ b/test/EFCore.Proxies.Tests/ChangeDetectionProxyTests.cs @@ -313,8 +313,8 @@ private class ChangeContext( bool useLazyLoading = false, bool checkEquality = true, Action> entityBuilderAction = null) : TestContext( - dbName: "ChangeDetectionContext", useLazyLoading: useLazyLoading, useChangeDetection: true, - checkEquality: checkEquality) + dbName: "ChangeDetectionContext", useLazyLoading: useLazyLoading, useChangeDetection: true, + checkEquality: checkEquality) where TEntity : class { private readonly Action> _entityBuilderAction = entityBuilderAction; diff --git a/test/EFCore.Proxies.Tests/ProxiesApiConsistencyTest.cs b/test/EFCore.Proxies.Tests/ProxiesApiConsistencyTest.cs index 2d264014772..d8fbbdc6469 100644 --- a/test/EFCore.Proxies.Tests/ProxiesApiConsistencyTest.cs +++ b/test/EFCore.Proxies.Tests/ProxiesApiConsistencyTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore; -public class ProxiesApiConsistencyTest(ProxiesApiConsistencyTest.ProxiesApiConsistencyFixture fixture) : ApiConsistencyTestBase(fixture) +public class ProxiesApiConsistencyTest(ProxiesApiConsistencyTest.ProxiesApiConsistencyFixture fixture) + : ApiConsistencyTestBase(fixture) { protected override void AddServices(ServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkProxies(); diff --git a/test/EFCore.Proxies.Tests/ProxyTests.cs b/test/EFCore.Proxies.Tests/ProxyTests.cs index 80c87439beb..bd88895f110 100644 --- a/test/EFCore.Proxies.Tests/ProxyTests.cs +++ b/test/EFCore.Proxies.Tests/ProxyTests.cs @@ -336,10 +336,11 @@ public record IndyCar; private class NeweyContext(string dbName = null, bool useLazyLoading = true, bool useChangeDetection = false) : DbContext { private readonly IServiceProvider _internalServiceProvider - = new ServiceCollection() - .AddEntityFrameworkInMemoryDatabase() - .AddEntityFrameworkProxies() - .BuildServiceProvider(validateScopes: true); + = new ServiceCollection() + .AddEntityFrameworkInMemoryDatabase() + .AddEntityFrameworkProxies() + .BuildServiceProvider(validateScopes: true); + private static readonly InMemoryDatabaseRoot _dbRoot = new(); private readonly bool _useLazyLoadingProxies = useLazyLoading; private readonly bool _useChangeDetectionProxies = useChangeDetection; @@ -351,9 +352,7 @@ public NeweyContext( bool useLazyLoading = true, bool useChangeDetection = false) : this(dbName, useLazyLoading, useChangeDetection) - { - _internalServiceProvider = internalServiceProvider; - } + => _internalServiceProvider = internalServiceProvider; protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { diff --git a/test/EFCore.Relational.Specification.Tests/BulkUpdates/NonSharedModelBulkUpdatesRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/BulkUpdates/NonSharedModelBulkUpdatesRelationalTestBase.cs index c3dc5ad63d8..31dad007759 100644 --- a/test/EFCore.Relational.Specification.Tests/BulkUpdates/NonSharedModelBulkUpdatesRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/BulkUpdates/NonSharedModelBulkUpdatesRelationalTestBase.cs @@ -27,6 +27,7 @@ await AssertTranslationFailedWithDetails( context => context.Set(), rowsAffectedCount: 0), RelationalStrings.ExecuteDeleteOnTableSplitting(nameof(Owner))); } + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Update_main_table_in_entity_with_entity_splitting(bool async) diff --git a/test/EFCore.Relational.Specification.Tests/BulkUpdates/NorthwindBulkUpdatesRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/BulkUpdates/NorthwindBulkUpdatesRelationalFixture.cs index 3ea28305a1f..1878095aa3b 100644 --- a/test/EFCore.Relational.Specification.Tests/BulkUpdates/NorthwindBulkUpdatesRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/BulkUpdates/NorthwindBulkUpdatesRelationalFixture.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.BulkUpdates; #nullable disable -public abstract class NorthwindBulkUpdatesRelationalFixture : NorthwindBulkUpdatesFixture, ITestSqlLoggerFactory +public abstract class NorthwindBulkUpdatesRelationalFixture : NorthwindBulkUpdatesFixture, + ITestSqlLoggerFactory where TModelCustomizer : ITestModelCustomizer, new() { public new RelationalTestStore TestStore diff --git a/test/EFCore.Relational.Specification.Tests/LoggingRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/LoggingRelationalTestBase.cs index 76a247782f8..67b0b5f213d 100644 --- a/test/EFCore.Relational.Specification.Tests/LoggingRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/LoggingRelationalTestBase.cs @@ -64,7 +64,8 @@ public virtual void IndexPropertiesBothMappedAndNotMappedToTable_throws_by_defau () => context.Model).Message); } - protected class IndexPropertiesBothMappedAndNotMappedToTableContext(DbContextOptionsBuilder optionsBuilder) : DbContext(optionsBuilder.Options) + protected class IndexPropertiesBothMappedAndNotMappedToTableContext(DbContextOptionsBuilder optionsBuilder) + : DbContext(optionsBuilder.Options) { protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -89,7 +90,8 @@ public virtual void UnnamedIndexPropertiesMappedToNonOverlappingTables_throws_by () => context.Model).Message); } - protected class UnnamedIndexPropertiesMappedToNonOverlappingTablesContext(DbContextOptionsBuilder optionsBuilder) : DbContext(optionsBuilder.Options) + protected class UnnamedIndexPropertiesMappedToNonOverlappingTablesContext(DbContextOptionsBuilder optionsBuilder) + : DbContext(optionsBuilder.Options) { protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -121,7 +123,8 @@ public virtual void ForeignKeyPropertiesMappedToUnrelatedTables_throws_by_defaul () => context.Model).Message); } - protected class ForeignKeyPropertiesMappedToUnrelatedTablesContext(DbContextOptionsBuilder optionsBuilder) : DbContext(optionsBuilder.Options) + protected class ForeignKeyPropertiesMappedToUnrelatedTablesContext(DbContextOptionsBuilder optionsBuilder) + : DbContext(optionsBuilder.Options) { protected override void OnModelCreating(ModelBuilder modelBuilder) { diff --git a/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsInfrastructureTestBase.cs b/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsInfrastructureTestBase.cs index 0b617c99581..b6125d35fe3 100644 --- a/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsInfrastructureTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsInfrastructureTestBase.cs @@ -153,7 +153,8 @@ public virtual void Can_apply_one_migration() history.GetAppliedMigrations(), x => Assert.Equal("00000000000001_Migration1", x.MigrationId)); - Assert.Equal(LogLevel.Error, + Assert.Equal( + LogLevel.Error, Fixture.TestSqlLoggerFactory.Log.Single(l => l.Id == RelationalEventId.PendingModelChangesWarning).Level); } @@ -202,12 +203,13 @@ public virtual void Can_apply_one_migration_in_parallel() GiveMeSomeTime(db); db.GetService().Create(); - Parallel.For(0, Environment.ProcessorCount, i => - { - using var context = Fixture.CreateContext(); - var migrator = context.GetService(); - migrator.Migrate("Migration1"); - }); + Parallel.For( + 0, Environment.ProcessorCount, i => + { + using var context = Fixture.CreateContext(); + var migrator = context.GetService(); + migrator.Migrate("Migration1"); + }); var history = db.GetService(); Assert.Collection( @@ -223,12 +225,13 @@ public virtual async Task Can_apply_one_migration_in_parallel_async() await GiveMeSomeTimeAsync(db); await db.GetService().CreateAsync(); - await Parallel.ForAsync(0, Environment.ProcessorCount, async (i, _) => - { - using var context = Fixture.CreateContext(); - var migrator = context.GetService(); - await migrator.MigrateAsync("Migration1"); - }); + await Parallel.ForAsync( + 0, Environment.ProcessorCount, async (i, _) => + { + using var context = Fixture.CreateContext(); + var migrator = context.GetService(); + await migrator.MigrateAsync("Migration1"); + }); var history = db.GetService(); Assert.Collection( @@ -244,12 +247,13 @@ public virtual void Can_apply_second_migration_in_parallel() GiveMeSomeTime(db); db.GetService().Migrate("Migration1"); - Parallel.For(0, Environment.ProcessorCount, i => - { - using var context = Fixture.CreateContext(); - var migrator = context.GetService(); - migrator.Migrate("Migration2"); - }); + Parallel.For( + 0, Environment.ProcessorCount, i => + { + using var context = Fixture.CreateContext(); + var migrator = context.GetService(); + migrator.Migrate("Migration2"); + }); var history = db.GetService(); Assert.Collection( @@ -266,12 +270,13 @@ public virtual async Task Can_apply_second_migration_in_parallel_async() await GiveMeSomeTimeAsync(db); await db.GetService().MigrateAsync("Migration1"); - await Parallel.ForAsync(0, Environment.ProcessorCount, async (i, _) => - { - using var context = Fixture.CreateContext(); - var migrator = context.GetService(); - await migrator.MigrateAsync("Migration2"); - }); + await Parallel.ForAsync( + 0, Environment.ProcessorCount, async (i, _) => + { + using var context = Fixture.CreateContext(); + var migrator = context.GetService(); + await migrator.MigrateAsync("Migration2"); + }); var history = db.GetService(); Assert.Collection( @@ -492,25 +497,26 @@ public class MigrationsContext(DbContextOptions options) : PoolableDbContext(opt } protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) - { - modelBuilder.Entity(b => b.ToTable("Table1")); - } + => modelBuilder.Entity(b => b.ToTable("Table1")); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder) - .UseSeeding((context, migrated) => - { - SeedCallCount++; - }) - .UseAsyncSeeding((context, migrated, token) => - { - SeedAsyncCallCount++; - return Task.CompletedTask; - }) - .ConfigureWarnings(e => e - .Log(RelationalEventId.PendingModelChangesWarning) - .Log(RelationalEventId.NonTransactionalMigrationOperationWarning) - ); + .UseSeeding( + (context, migrated) => + { + SeedCallCount++; + }) + .UseAsyncSeeding( + (context, migrated, token) => + { + SeedAsyncCallCount++; + return Task.CompletedTask; + }) + .ConfigureWarnings( + e => e + .Log(RelationalEventId.PendingModelChangesWarning) + .Log(RelationalEventId.NonTransactionalMigrationOperationWarning) + ); protected override bool ShouldLogCategory(string logCategory) => logCategory == DbLoggerCategory.Migrations.Name; @@ -533,7 +539,12 @@ protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder .CreateTable( name: "Table1", - columns: x => new { Id = x.Column(), Foo = x.Column(), Description = x.Column() }) + columns: x => new + { + Id = x.Column(), + Foo = x.Column(), + Description = x.Column() + }) .PrimaryKey( name: "PK_Table1", columns: x => x.Id); @@ -586,7 +597,8 @@ protected override void Up(MigrationBuilder migrationBuilder) { if (ActiveProvider == "Microsoft.EntityFrameworkCore.SqlServer") { - migrationBuilder.Sql(""" + migrationBuilder.Sql( + """ CREATE PROCEDURE [dbo].[GotoReproduction] AS BEGIN @@ -627,13 +639,10 @@ Empty Lines """; protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql($"INSERT INTO Table1 (Id, Bar, Description) VALUES (-1, 3, '{TestValue}')"); - } + => migrationBuilder.Sql($"INSERT INTO Table1 (Id, Bar, Description) VALUES (-1, 3, '{TestValue}')"); protected override void Down(MigrationBuilder migrationBuilder) { - } } @@ -649,13 +658,10 @@ Empty Lines """; protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql($"INSERT INTO Table1 (Id, Bar, Description) VALUES (-2, 4, '{TestValue}')"); - } + => migrationBuilder.Sql($"INSERT INTO Table1 (Id, Bar, Description) VALUES (-2, 4, '{TestValue}')"); protected override void Down(MigrationBuilder migrationBuilder) { - } } @@ -674,13 +680,10 @@ Empty Lines """; protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql($"INSERT INTO Table1 (Id, Bar, Description) VALUES (-3, 5, '{TestValue}')"); - } + => migrationBuilder.Sql($"INSERT INTO Table1 (Id, Bar, Description) VALUES (-3, 5, '{TestValue}')"); protected override void Down(MigrationBuilder migrationBuilder) { - } } } diff --git a/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsSqlGeneratorTestBase.cs b/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsSqlGeneratorTestBase.cs index f03b89e7609..307cf0420d4 100644 --- a/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsSqlGeneratorTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsSqlGeneratorTestBase.cs @@ -181,20 +181,14 @@ public virtual void SqlOperation() [new Coordinate(1.1, 2.2), new Coordinate(2.2, 2.2), new Coordinate(2.2, 1.1), new Coordinate(7.1, 7.2)]) { SRID = 4326 }; private static readonly LineString _lineString2 = new( - [new Coordinate(7.1, 7.2), new Coordinate(20.2, 20.2), new Coordinate(20.20, 1.1), new Coordinate(70.1, 70.2)]) - { - SRID = 4326 - }; + [new Coordinate(7.1, 7.2), new Coordinate(20.2, 20.2), new Coordinate(20.20, 1.1), new Coordinate(70.1, 70.2)]) { SRID = 4326 }; private static readonly MultiPoint _multiPoint = new( [new Point(1.1, 2.2), new Point(2.2, 2.2), new Point(2.2, 1.1)]) { SRID = 4326 }; private static readonly Polygon _polygon1 = new( new LinearRing( - [new Coordinate(1.1, 2.2), new Coordinate(2.2, 2.2), new Coordinate(2.2, 1.1), new Coordinate(1.1, 2.2)])) - { - SRID = 4326 - }; + [new Coordinate(1.1, 2.2), new Coordinate(2.2, 2.2), new Coordinate(2.2, 1.1), new Coordinate(1.1, 2.2)])) { SRID = 4326 }; private static readonly Polygon _polygon2 = new( new LinearRing( @@ -212,10 +206,7 @@ public virtual void SqlOperation() [_polygon2, _polygon1]) { SRID = 4326 }; private static readonly GeometryCollection _geometryCollection = new( - [_lineString1, _lineString2, _multiPoint, _polygon1, _polygon2, _point1, _multiLineString, _multiPolygon]) - { - SRID = 4326 - }; + [_lineString1, _lineString2, _multiPoint, _polygon1, _polygon2, _point1, _multiLineString, _multiPolygon]) { SRID = 4326 }; [ConditionalFact] public virtual void InsertDataOperation_all_args_spatial() diff --git a/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsTestBase.cs b/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsTestBase.cs index 71f0e702ed5..f83e2575b6b 100644 --- a/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Migrations/MigrationsTestBase.cs @@ -2864,7 +2864,7 @@ public virtual Task Add_required_primitive_collection_with_custom_converter_to_e new ValueConverter, string>( convertToProviderExpression: x => x != null && x.Count > 0 ? "some numbers" : "nothing", convertFromProviderExpression: x => x == "nothing" - ? new List { } + ? new List() : new List { 7, @@ -2908,7 +2908,7 @@ public virtual Task Add_required_primitive_collection_with_custom_converter_and_ new ValueConverter, string>( convertToProviderExpression: x => x != null && x.Count > 0 ? "some numbers" : "nothing", convertFromProviderExpression: x => x == "nothing" - ? new List { } + ? new List() : new List { 7, @@ -3145,7 +3145,7 @@ public virtual Task Add_required_primitve_collection_with_custom_converter_to_ex new ValueConverter, string>( convertToProviderExpression: x => x != null && x.Count > 0 ? "some numbers" : "nothing", convertFromProviderExpression: x => x == "nothing" - ? new List { } + ? new List() : new List { 7, @@ -3189,7 +3189,7 @@ public virtual Task Add_required_primitve_collection_with_custom_converter_and_c new ValueConverter, string>( convertToProviderExpression: x => x != null && x.Count > 0 ? "some numbers" : "nothing", convertFromProviderExpression: x => x == "nothing" - ? new List { } + ? new List() : new List { 7, diff --git a/test/EFCore.Relational.Specification.Tests/ModelBuilding/RelationalModelBuilderTest.cs b/test/EFCore.Relational.Specification.Tests/ModelBuilding/RelationalModelBuilderTest.cs index 4a9096d6012..b854cde3b93 100644 --- a/test/EFCore.Relational.Specification.Tests/ModelBuilding/RelationalModelBuilderTest.cs +++ b/test/EFCore.Relational.Specification.Tests/ModelBuilding/RelationalModelBuilderTest.cs @@ -716,32 +716,36 @@ public virtual void Can_use_ForeignKeyAttribute_with_InversePropertyAttribute() var model = modelBuilder.FinalizeModel(); - Assert.Collection(model.GetEntityTypes(), + Assert.Collection( + model.GetEntityTypes(), e => { Assert.Equal("FuelTypeMotorArt", e.ShortName()); Assert.Collection(e.GetProperties(), p => Assert.Equal("FuelTypeId", p.Name), p => Assert.Equal("MotorArtId", p.Name)); - Assert.Collection(e.GetKeys(), k =>Assert.Collection(k.Properties, - p => Assert.Equal("FuelTypeId", p.Name), - p => Assert.Equal("MotorArtId", p.Name))); - Assert.Collection(e.GetForeignKeys(), k => - { - Assert.Equal("FuelType", k.PrincipalEntityType.ShortName()); - Assert.Collection(k.Properties, p => Assert.Equal("FuelTypeId", p.Name)); - Assert.Collection(k.PrincipalKey.Properties, p => Assert.Equal("FuelTypeId", p.Name)); - }, k => - { - Assert.Equal("MotorArt", k.PrincipalEntityType.ShortName()); - Assert.Collection(k.Properties, p => Assert.Equal("MotorArtId", p.Name)); - Assert.Collection(k.PrincipalKey.Properties, p => Assert.Equal("MotorArtId", p.Name)); - }); + Assert.Collection( + e.GetKeys(), k => Assert.Collection( + k.Properties, + p => Assert.Equal("FuelTypeId", p.Name), + p => Assert.Equal("MotorArtId", p.Name))); + Assert.Collection( + e.GetForeignKeys(), k => + { + Assert.Equal("FuelType", k.PrincipalEntityType.ShortName()); + Assert.Collection(k.Properties, p => Assert.Equal("FuelTypeId", p.Name)); + Assert.Collection(k.PrincipalKey.Properties, p => Assert.Equal("FuelTypeId", p.Name)); + }, k => + { + Assert.Equal("MotorArt", k.PrincipalEntityType.ShortName()); + Assert.Collection(k.Properties, p => Assert.Equal("MotorArtId", p.Name)); + Assert.Collection(k.PrincipalKey.Properties, p => Assert.Equal("MotorArtId", p.Name)); + }); Assert.Empty(e.GetNavigations()); Assert.Empty(e.GetSkipNavigations()); }, e => { Assert.Equal("FuelType", e.ShortName()); - Assert.Collection(e.GetKeys(), k =>Assert.Collection(k.Properties, p => Assert.Equal("FuelTypeId", p.Name))); + Assert.Collection(e.GetKeys(), k => Assert.Collection(k.Properties, p => Assert.Equal("FuelTypeId", p.Name))); Assert.Collection(e.GetProperties(), p => Assert.Equal("FuelTypeId", p.Name), p => Assert.Equal("Bezeichnung", p.Name)); Assert.Empty(e.GetForeignKeys()); Assert.Empty(e.GetNavigations()); @@ -750,18 +754,19 @@ public virtual void Can_use_ForeignKeyAttribute_with_InversePropertyAttribute() e => { Assert.Equal("MotorArt", e.ShortName()); - Assert.Collection(e.GetKeys(), k =>Assert.Collection(k.Properties, p => Assert.Equal("MotorArtId", p.Name))); + Assert.Collection(e.GetKeys(), k => Assert.Collection(k.Properties, p => Assert.Equal("MotorArtId", p.Name))); Assert.Collection(e.GetProperties(), p => Assert.Equal("MotorArtId", p.Name)); Assert.Empty(e.GetForeignKeys()); Assert.Empty(e.GetNavigations()); - Assert.Collection(e.GetSkipNavigations(), + Assert.Collection( + e.GetSkipNavigations(), n => Assert.Equal("FuelType", n.Name), n => Assert.Equal("MotorBauArt", n.Name)); }, e => { Assert.Equal("MotorBauart", e.ShortName()); - Assert.Collection(e.GetKeys(), k =>Assert.Collection(k.Properties, p => Assert.Equal("MotorBauartId", p.Name))); + Assert.Collection(e.GetKeys(), k => Assert.Collection(k.Properties, p => Assert.Equal("MotorBauartId", p.Name))); Assert.Collection(e.GetProperties(), p => Assert.Equal("MotorBauartId", p.Name)); Assert.Empty(e.GetForeignKeys()); Assert.Empty(e.GetNavigations()); @@ -770,23 +775,27 @@ public virtual void Can_use_ForeignKeyAttribute_with_InversePropertyAttribute() e => { Assert.Equal("MotorArtXMotorBauart", e.ShortName()); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("MotorArtId", p.Name), p => Assert.Equal("MotorBauArtId", p.Name)); - Assert.Collection(e.GetKeys(), k =>Assert.Collection(k.Properties, - p => Assert.Equal("MotorArtId", p.Name), - p => Assert.Equal("MotorBauArtId", p.Name))); - Assert.Collection(e.GetForeignKeys(), k => - { - Assert.Equal("MotorArt", k.PrincipalEntityType.ShortName()); - Assert.Collection(k.Properties, p => Assert.Equal("MotorArtId", p.Name)); - Assert.Collection(k.PrincipalKey.Properties, p => Assert.Equal("MotorArtId", p.Name)); - }, k => - { - Assert.Equal("MotorBauart", k.PrincipalEntityType.ShortName()); - Assert.Collection(k.Properties, p => Assert.Equal("MotorBauArtId", p.Name)); - Assert.Collection(k.PrincipalKey.Properties, p => Assert.Equal("MotorBauartId", p.Name)); - }); + Assert.Collection( + e.GetKeys(), k => Assert.Collection( + k.Properties, + p => Assert.Equal("MotorArtId", p.Name), + p => Assert.Equal("MotorBauArtId", p.Name))); + Assert.Collection( + e.GetForeignKeys(), k => + { + Assert.Equal("MotorArt", k.PrincipalEntityType.ShortName()); + Assert.Collection(k.Properties, p => Assert.Equal("MotorArtId", p.Name)); + Assert.Collection(k.PrincipalKey.Properties, p => Assert.Equal("MotorArtId", p.Name)); + }, k => + { + Assert.Equal("MotorBauart", k.PrincipalEntityType.ShortName()); + Assert.Collection(k.Properties, p => Assert.Equal("MotorBauArtId", p.Name)); + Assert.Collection(k.PrincipalKey.Properties, p => Assert.Equal("MotorBauartId", p.Name)); + }); Assert.Empty(e.GetNavigations()); Assert.Empty(e.GetSkipNavigations()); }); @@ -833,7 +842,6 @@ protected class MotorBauart [InverseProperty("MotorBauArt")] public virtual ICollection MotorArt { get; set; } = new HashSet(); } - } public abstract class RelationalOwnedTypesTestBase(RelationalModelBuilderFixture fixture) : OwnedTypesTestBase(fixture) @@ -1075,7 +1083,6 @@ public virtual void Can_use_sproc_mapping_with_owned_reference() Assert.Null(bookOwnership2.DeclaringEntityType.GetUpdateStoredProcedure()); Assert.Null(bookOwnership2.DeclaringEntityType.GetDeleteStoredProcedure()); } -#nullable disable protected class JsonEntity { @@ -1205,6 +1212,7 @@ static void AssertOwnership(IEntityType owner) owned.GetProperties().Select(p => p.Name)); } } + public override void Can_configure_owned_type_key() { var modelBuilder = CreateModelBuilder(); @@ -1247,7 +1255,8 @@ public abstract TestCheckConstraintBuilder HasCheckConstraint( public abstract TestColumnBuilder Property(Expression> propertyExpression); } - public class GenericTestTableBuilder(TableBuilder tableBuilder) : TestTableBuilder, IInfrastructure> + public class GenericTestTableBuilder(TableBuilder tableBuilder) + : TestTableBuilder, IInfrastructure> where TEntity : class { private TableBuilder TableBuilder { get; } = tableBuilder; @@ -1332,7 +1341,8 @@ public abstract TestCheckConstraintBuilder HasCheckConstraint( public abstract TestColumnBuilder Property(Expression> propertyExpression); } - public class GenericTestOwnedNavigationTableBuilder(OwnedNavigationTableBuilder tableBuilder) : + public class GenericTestOwnedNavigationTableBuilder( + OwnedNavigationTableBuilder tableBuilder) : TestOwnedNavigationTableBuilder, IInfrastructure> where TOwnerEntity : class @@ -1420,7 +1430,8 @@ public abstract TestSplitTableBuilder HasAnnotation( object? value); } - public class GenericTestSplitTableBuilder(SplitTableBuilder tableBuilder) : TestSplitTableBuilder, IInfrastructure> + public class GenericTestSplitTableBuilder(SplitTableBuilder tableBuilder) + : TestSplitTableBuilder, IInfrastructure> where TEntity : class { private SplitTableBuilder TableBuilder { get; } = tableBuilder; @@ -1453,7 +1464,8 @@ public override TestSplitTableBuilder HasAnnotation(string annotation, => Wrap(TableBuilder.HasAnnotation(annotation, value)); } - public class NonGenericTestSplitTableBuilder(SplitTableBuilder tableBuilder) : TestSplitTableBuilder, IInfrastructure + public class NonGenericTestSplitTableBuilder(SplitTableBuilder tableBuilder) + : TestSplitTableBuilder, IInfrastructure where TEntity : class { private SplitTableBuilder TableBuilder { get; } = tableBuilder; @@ -1505,7 +1517,8 @@ public abstract TestOwnedNavigationSplitTableBuilder(OwnedNavigationSplitTableBuilder tableBuilder) : + public class GenericTestOwnedNavigationSplitTableBuilder( + OwnedNavigationSplitTableBuilder tableBuilder) : TestOwnedNavigationSplitTableBuilder, IInfrastructure> where TOwnerEntity : class @@ -1540,7 +1553,8 @@ public override TestOwnedNavigationSplitTableBuilder Wrap(TableBuilder.HasAnnotation(annotation, value)); } - public class NonGenericTestOwnedNavigationSplitTableBuilder(OwnedNavigationSplitTableBuilder tableBuilder) : + public class NonGenericTestOwnedNavigationSplitTableBuilder( + OwnedNavigationSplitTableBuilder tableBuilder) : TestOwnedNavigationSplitTableBuilder, IInfrastructure where TOwnerEntity : class @@ -1583,7 +1597,8 @@ public abstract TestColumnBuilder HasAnnotation( object? value); } - public class GenericTestColumnBuilder(ColumnBuilder columnBuilder) : TestColumnBuilder, IInfrastructure> + public class GenericTestColumnBuilder(ColumnBuilder columnBuilder) + : TestColumnBuilder, IInfrastructure> { private ColumnBuilder ColumnBuilder { get; } = columnBuilder; @@ -1602,7 +1617,8 @@ public override TestColumnBuilder HasAnnotation( => Wrap(ColumnBuilder.HasAnnotation(annotation, value)); } - public class NonGenericTestColumnBuilder(ColumnBuilder tableBuilder) : TestColumnBuilder, IInfrastructure + public class NonGenericTestColumnBuilder(ColumnBuilder tableBuilder) + : TestColumnBuilder, IInfrastructure { private ColumnBuilder ColumnBuilder { get; } = tableBuilder; @@ -1633,7 +1649,8 @@ public abstract class TestViewBuilder public abstract TestViewColumnBuilder Property(Expression> propertyExpression); } - public class GenericTestViewBuilder(ViewBuilder tableBuilder) : TestViewBuilder, IInfrastructure> + public class GenericTestViewBuilder(ViewBuilder tableBuilder) + : TestViewBuilder, IInfrastructure> where TEntity : class { private ViewBuilder ViewBuilder { get; } = tableBuilder; @@ -1695,7 +1712,8 @@ public abstract TestViewColumnBuilder Property( Expression> propertyExpression); } - public class GenericTestOwnedNavigationViewBuilder(OwnedNavigationViewBuilder tableBuilder) : + public class GenericTestOwnedNavigationViewBuilder( + OwnedNavigationViewBuilder tableBuilder) : TestOwnedNavigationViewBuilder, IInfrastructure> where TOwnerEntity : class @@ -1769,7 +1787,8 @@ public abstract TestSplitViewBuilder HasAnnotation( object? value); } - public class GenericTestSplitViewBuilder(SplitViewBuilder tableBuilder) : TestSplitViewBuilder, IInfrastructure> + public class GenericTestSplitViewBuilder(SplitViewBuilder tableBuilder) + : TestSplitViewBuilder, IInfrastructure> where TEntity : class { private SplitViewBuilder ViewBuilder { get; } = tableBuilder; @@ -1796,7 +1815,8 @@ public override TestSplitViewBuilder HasAnnotation(string annotation, o => Wrap(ViewBuilder.HasAnnotation(annotation, value)); } - public class NonGenericTestSplitViewBuilder(SplitViewBuilder tableBuilder) : TestSplitViewBuilder, IInfrastructure + public class NonGenericTestSplitViewBuilder(SplitViewBuilder tableBuilder) + : TestSplitViewBuilder, IInfrastructure where TEntity : class { private SplitViewBuilder ViewBuilder { get; } = tableBuilder; @@ -1841,7 +1861,8 @@ public abstract TestOwnedNavigationSplitViewBuilder(OwnedNavigationSplitViewBuilder tableBuilder) : + public class GenericTestOwnedNavigationSplitViewBuilder( + OwnedNavigationSplitViewBuilder tableBuilder) : TestOwnedNavigationSplitViewBuilder, IInfrastructure> where TOwnerEntity : class @@ -1874,9 +1895,10 @@ public override TestOwnedNavigationSplitViewBuilder Wrap(ViewBuilder.HasAnnotation(annotation, value)); } - public class NonGenericTestOwnedNavigationSplitViewBuilder(OwnedNavigationSplitViewBuilder tableBuilder) : - TestOwnedNavigationSplitViewBuilder, - IInfrastructure + public class NonGenericTestOwnedNavigationSplitViewBuilder(OwnedNavigationSplitViewBuilder tableBuilder) + : + TestOwnedNavigationSplitViewBuilder, + IInfrastructure where TOwnerEntity : class where TDependentEntity : class { @@ -1915,7 +1937,8 @@ public abstract TestViewColumnBuilder HasAnnotation( object? value); } - public class GenericTestViewColumnBuilder(ViewColumnBuilder columnBuilder) : TestViewColumnBuilder, IInfrastructure> + public class GenericTestViewColumnBuilder(ViewColumnBuilder columnBuilder) + : TestViewColumnBuilder, IInfrastructure> { private ViewColumnBuilder ViewColumnBuilder { get; } = columnBuilder; @@ -2366,7 +2389,8 @@ public class GenericTestOwnedNavigationStoredProcedureBuilder StoredProcedureBuilder { get; } = storedProcedureBuilder; + private OwnedNavigationStoredProcedureBuilder StoredProcedureBuilder { get; } = + storedProcedureBuilder; OwnedNavigationStoredProcedureBuilder IInfrastructure>.Instance @@ -2460,7 +2484,8 @@ public override TestOwnedNavigationStoredProcedureBuilder Wrap(StoredProcedureBuilder.HasAnnotation(annotation, value)); } - public class NonGenericTestOwnedNavigationStoredProcedureBuilder(OwnedNavigationStoredProcedureBuilder storedProcedureBuilder) + public class NonGenericTestOwnedNavigationStoredProcedureBuilder( + OwnedNavigationStoredProcedureBuilder storedProcedureBuilder) : TestOwnedNavigationStoredProcedureBuilder, IInfrastructure where TOwnerEntity : class @@ -2561,7 +2586,8 @@ public override TestOwnedNavigationStoredProcedureBuilder Wrap(StoredProcedureBuilder.HasAnnotation(annotation, value)); } - public class TestStoredProcedureParameterBuilder(StoredProcedureParameterBuilder storedProcedureParameterBuilder) : IInfrastructure + public class TestStoredProcedureParameterBuilder(StoredProcedureParameterBuilder storedProcedureParameterBuilder) + : IInfrastructure { private StoredProcedureParameterBuilder StoredProcedureParameterBuilder { get; } = storedProcedureParameterBuilder; @@ -2586,7 +2612,8 @@ public virtual TestStoredProcedureParameterBuilder HasAnnotation( => Wrap(StoredProcedureParameterBuilder.HasAnnotation(annotation, value)); } - public class TestStoredProcedureResultColumnBuilder(StoredProcedureResultColumnBuilder storedProcedureResultColumnBuilder) : IInfrastructure + public class TestStoredProcedureResultColumnBuilder(StoredProcedureResultColumnBuilder storedProcedureResultColumnBuilder) + : IInfrastructure { private StoredProcedureResultColumnBuilder StoredProcedureResultColumnBuilder { get; } = storedProcedureResultColumnBuilder; diff --git a/test/EFCore.Relational.Specification.Tests/Query/AdHocAdvancedMappingsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/AdHocAdvancedMappingsQueryRelationalTestBase.cs index e33ea578f93..5a5ea258faf 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/AdHocAdvancedMappingsQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/AdHocAdvancedMappingsQueryRelationalTestBase.cs @@ -71,8 +71,7 @@ public virtual async Task Projecting_one_of_two_similar_complex_types_picks_the_ .Select( x => new { - x.B.A.Id, - x.B.Info.Created, + x.B.A.Id, x.B.Info.Created, }).ToList(); Assert.Equal(new DateTime(2000, 1, 1), query[0].Created); @@ -153,14 +152,14 @@ public class Offer : EntityBase public class Variation : EntityBase { - public Payment Payment { get; set; } = new Payment(0, 0); + public Payment Payment { get; set; } = new(0, 0); public NestedEntity Nested { get; set; } } public class NestedEntity : EntityBase { - public Payment Payment { get; set; } = new Payment(0, 0); + public Payment Payment { get; set; } = new(0, 0); } public record Payment(decimal Netto, decimal Brutto); diff --git a/test/EFCore.Relational.Specification.Tests/Query/AdHocJsonQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/AdHocJsonQueryTestBase.cs index 04dd844badd..d7461ae71fe 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/AdHocJsonQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/AdHocJsonQueryTestBase.cs @@ -40,7 +40,10 @@ public virtual async Task Contains_on_nested_collection_with_init_only_navigatio protected virtual async Task Seed32310(DbContext context) { - var user = new Pub32310 { Name = "FBI", Visits = new Visits32310 { LocationTag = "tag", DaysVisited = [new(2023, 1, 1)] } }; + var user = new Pub32310 + { + Name = "FBI", Visits = new Visits32310 { LocationTag = "tag", DaysVisited = [new DateOnly(2023, 1, 1)] } + }; context.Add(user); await context.SaveChangesAsync(); @@ -284,11 +287,7 @@ public virtual async Task Project_json_with_no_properties() protected Task Seed32939(DbContext ctx) { - var entity = new Entity32939 - { - Empty = new JsonEmpty32939(), - FieldOnly = new JsonFieldOnly32939() - }; + var entity = new Entity32939 { Empty = new JsonEmpty32939(), FieldOnly = new JsonFieldOnly32939() }; ctx.Add(entity); return ctx.SaveChangesAsync(); @@ -306,7 +305,6 @@ public class Entity32939 public int Id { get; set; } public JsonEmpty32939 Empty { get; set; } public JsonFieldOnly32939 FieldOnly { get; set; } - } public class JsonEmpty32939 @@ -367,7 +365,7 @@ public class ReviewRound public int RoundNumber { get; set; } #pragma warning disable IDE0044 // Add readonly modifier - private List _subRounds = []; + private readonly List _subRounds = []; #pragma warning restore IDE0044 // Add readonly modifier public IReadOnlyList SubRounds => _subRounds.AsReadOnly(); @@ -393,7 +391,8 @@ public virtual async Task Project_json_array_of_primitives_on_reference(bool asy using (var context = contextFactory.CreateContext()) { - var query = context.Set().OrderBy(x => x.Id).Select(x => new { x.Reference.IntArray, x.Reference.ListOfString }); + var query = context.Set().OrderBy(x => x.Id) + .Select(x => new { x.Reference.IntArray, x.Reference.ListOfString }); var result = async ? await query.ToListAsync() @@ -418,7 +417,8 @@ public virtual async Task Project_json_array_of_primitives_on_collection(bool as using (var context = contextFactory.CreateContext()) { - var query = context.Set().OrderBy(x => x.Id).Select(x => new { x.Collection[0].IntArray, x.Collection[1].ListOfString }); + var query = context.Set().OrderBy(x => x.Id) + .Select(x => new { x.Collection[0].IntArray, x.Collection[1].ListOfString }); var result = async ? await query.ToListAsync() @@ -850,8 +850,7 @@ public virtual async Task Project_shadow_properties_from_json_entity(bool async) protected abstract Task SeedShadowProperties(DbContext ctx); protected virtual void BuildModelShadowProperties(ModelBuilder modelBuilder) - { - modelBuilder.Entity( + => modelBuilder.Entity( b => { b.ToTable("Entities"); @@ -885,7 +884,6 @@ protected virtual void BuildModelShadowProperties(ModelBuilder modelBuilder) b.Property("ShadowNullableByte"); }); }); - } public class MyEntityShadowProperties { diff --git a/test/EFCore.Relational.Specification.Tests/Query/AdHocMiscellaneousQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/AdHocMiscellaneousQueryRelationalTestBase.cs index d27d4c9d37c..6f58c2da809 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/AdHocMiscellaneousQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/AdHocMiscellaneousQueryRelationalTestBase.cs @@ -1,11 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable disable + using System.ComponentModel.DataAnnotations.Schema; using NameSpace1; -#nullable disable - namespace Microsoft.EntityFrameworkCore.Query { public abstract class AdHocMiscellaneousQueryRelationalTestBase : AdHocMiscellaneousQueryTestBase diff --git a/test/EFCore.Relational.Specification.Tests/Query/AdHocNavigationsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/AdHocNavigationsQueryRelationalTestBase.cs index 31fa22cdf6c..d4da75680e7 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/AdHocNavigationsQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/AdHocNavigationsQueryRelationalTestBase.cs @@ -44,7 +44,8 @@ public virtual async Task Select_enumerable_navigation_backed_by_collection(bool } } - private class Context21803(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context21803(DbContextOptions options) : DbContext(options) { public DbSet Entities { get; set; } diff --git a/test/EFCore.Relational.Specification.Tests/Query/AdHocPrecompiledQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/AdHocPrecompiledQueryRelationalTestBase.cs index 2984bc2895a..e9980c5e6f7 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/AdHocPrecompiledQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/AdHocPrecompiledQueryRelationalTestBase.cs @@ -22,8 +22,8 @@ await Test( var blogs = context.JsonEntities.Where(b => b.IntList[b.Id] == 2).ToList(); """, - typeof(JsonContext), - options); + typeof(JsonContext), + options); } [ConditionalFact] @@ -117,7 +117,8 @@ await Test( Assert.Contains("var instance = UnsafeAccessor_Microsoft_EntityFrameworkCore_Query_NonPublicEntity_Ctor();", code); Assert.Contains("UnsafeAccessor_Microsoft_EntityFrameworkCore_Query_NonPublicEntity_Id_Set(instance) =", code); - Assert.Contains("UnsafeAccessor_Microsoft_EntityFrameworkCore_Query_NonPublicEntity_PrivateAutoProperty_Set(instance) =", code); + Assert.Contains( + "UnsafeAccessor_Microsoft_EntityFrameworkCore_Query_NonPublicEntity_PrivateAutoProperty_Set(instance) =", code); Assert.Contains("UnsafeAccessor_Microsoft_EntityFrameworkCore_Query_NonPublicEntity_set_PrivateProperty(instance,", code); Assert.Contains("UnsafeAccessor_Microsoft_EntityFrameworkCore_Query_NonPublicEntity__privateField_Set(instance) =", code); }); @@ -158,6 +159,7 @@ private int? PrivateProperty get => _privatePropertyBackingField; set => _privatePropertyBackingField = value; } + private int? _privatePropertyBackingField; private int? PrivateAutoProperty { get; set; } diff --git a/test/EFCore.Relational.Specification.Tests/Query/AdHocQuerySplittingQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/AdHocQuerySplittingQueryTestBase.cs index db6a201e52f..2b3471ebcb4 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/AdHocQuerySplittingQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/AdHocQuerySplittingQueryTestBase.cs @@ -148,7 +148,7 @@ protected class Context21355(DbContextOptions options) : DbContext(options) public async Task SeedAsync() { - Add(new Parent { Id = "Parent1", Children1 = [new(), new()] }); + Add(new Parent { Id = "Parent1", Children1 = [new Child(), new Child()] }); await SaveChangesAsync(); } @@ -249,8 +249,7 @@ protected virtual Task CreateTestStore25225() .Select( c => new Context25225.CollectionViewModel { - Id = c.Id, - ParentId = c.ParentId, + Id = c.Id, ParentId = c.ParentId, }) .ToArray() }); @@ -330,7 +329,8 @@ public virtual async Task NoTracking_split_query_creates_only_required_instances Assert.Equal(1, Context25400.Test.ConstructorCallCount); } - private class Context25400(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context25400(DbContextOptions options) : DbContext(options) { public DbSet Tests { get; set; } @@ -349,14 +349,10 @@ public class Test public static int ConstructorCallCount; public Test() - { - ++ConstructorCallCount; - } + => ++ConstructorCallCount; public Test(int value) - { - Value = value; - } + => Value = value; public int Id { get; set; } public int Value { get; set; } diff --git a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryRelationalFixtureBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryRelationalFixtureBase.cs index 6a74dee8c8e..298481c9d8d 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryRelationalFixtureBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryRelationalFixtureBase.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public abstract class ComplexNavigationsSharedTypeQueryRelationalFixtureBase : ComplexNavigationsSharedTypeQueryFixtureBase, ITestSqlLoggerFactory +public abstract class ComplexNavigationsSharedTypeQueryRelationalFixtureBase : ComplexNavigationsSharedTypeQueryFixtureBase, + ITestSqlLoggerFactory { public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; diff --git a/test/EFCore.Relational.Specification.Tests/Query/EntitySplittingQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/EntitySplittingQueryTestBase.cs index c600f3deeeb..19bfbbb4a6d 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/EntitySplittingQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/EntitySplittingQueryTestBase.cs @@ -11,9 +11,7 @@ namespace Microsoft.EntityFrameworkCore.Query; public abstract class EntitySplittingQueryTestBase : NonSharedModelTestBase { protected EntitySplittingQueryTestBase() - { - _setSourceCreator = GetSetSourceCreator(); - } + => _setSourceCreator = GetSetSourceCreator(); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -2927,16 +2925,18 @@ protected virtual EntitySplittingContext CreateContext() protected override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder) - .UseSeeding((c, _) => - { - EntitySplittingData.Instance.AddSeedData((EntitySplittingContext)c); - c.SaveChanges(); - }) - .UseAsyncSeeding((c, _, t) => - { - EntitySplittingData.Instance.AddSeedData((EntitySplittingContext)c); - return c.SaveChangesAsync(t); - }); + .UseSeeding( + (c, _) => + { + EntitySplittingData.Instance.AddSeedData((EntitySplittingContext)c); + c.SaveChanges(); + }) + .UseAsyncSeeding( + (c, _, t) => + { + EntitySplittingData.Instance.AddSeedData((EntitySplittingContext)c); + return c.SaveChangesAsync(t); + }); public void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs index 116bc23ab3e..851e0f44191 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs @@ -18,9 +18,7 @@ public abstract class FromSqlQueryTestBase : QueryTestBase protected FromSqlQueryTestBase(TFixture fixture) : base(fixture) - { - Fixture.TestSqlLoggerFactory.Clear(); - } + => Fixture.TestSqlLoggerFactory.Clear(); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -207,7 +205,6 @@ public virtual async Task FromSqlRaw_queryable_simple_different_cased_columns_an : Assert.Throws(() => query.ToList())).Message); } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task FromSqlRaw_queryable_composed(bool async) diff --git a/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationshipsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationshipsQueryRelationalTestBase.cs index e9a1787947d..ae4d9996606 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationshipsQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationshipsQueryRelationalTestBase.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public abstract class InheritanceRelationshipsQueryRelationalTestBase(TFixture fixture) : InheritanceRelationshipsQueryTestBase(fixture) +public abstract class InheritanceRelationshipsQueryRelationalTestBase(TFixture fixture) + : InheritanceRelationshipsQueryTestBase(fixture) where TFixture : InheritanceRelationshipsQueryRelationalFixture, new() { [ConditionalTheory] diff --git a/test/EFCore.Relational.Specification.Tests/Query/JsonQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/JsonQueryRelationalTestBase.cs index b698d82eb3d..c24220e6add 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/JsonQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/JsonQueryRelationalTestBase.cs @@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore.TestModels.JsonQuery; namespace Microsoft.EntityFrameworkCore.Query; + public abstract class JsonQueryRelationalTestBase(TFixture fixture) : JsonQueryTestBase(fixture) where TFixture : JsonQueryRelationalFixture, new() { @@ -122,28 +123,31 @@ public virtual Task FromSql_on_entity_with_json_inheritance_project_reference_on [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task Json_projection_using_queryable_methods_on_top_of_JSON_collection_AsNoTrackingWithIdentityResolution(bool async) + public virtual async Task Json_projection_using_queryable_methods_on_top_of_JSON_collection_AsNoTrackingWithIdentityResolution( + bool async) { - var message = (await Assert.ThrowsAsync(() => - AssertQuery( - async, - ss => ss.Set().Select( - x => new - { - x.Id, - Skip = x.OwnedCollectionRoot.Skip(1).ToList(), - Take = x.OwnedCollectionRoot.Take(2).ToList(), - }).AsNoTrackingWithIdentityResolution(), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - AssertEqual(e.Id, a.Id); - AssertCollection(e.Skip, a.Skip); - AssertCollection(e.Take, a.Take); - }))).Message; + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( + async, + ss => ss.Set().Select( + x => new + { + x.Id, + Skip = x.OwnedCollectionRoot.Skip(1).ToList(), + Take = x.OwnedCollectionRoot.Take(2).ToList(), + }).AsNoTrackingWithIdentityResolution(), + elementSorter: e => e.Id, + elementAsserter: (e, a) => + { + AssertEqual(e.Id, a.Id); + AssertCollection(e.Skip, a.Skip); + AssertCollection(e.Take, a.Take); + }))).Message; Assert.Equal( - RelationalStrings.JsonProjectingQueryableOperationNoTrackingWithIdentityResolution(nameof(QueryTrackingBehavior.NoTrackingWithIdentityResolution)), + RelationalStrings.JsonProjectingQueryableOperationNoTrackingWithIdentityResolution( + nameof(QueryTrackingBehavior.NoTrackingWithIdentityResolution)), message); } @@ -151,40 +155,42 @@ public virtual async Task Json_projection_using_queryable_methods_on_top_of_JSON [MemberData(nameof(IsAsyncData))] public virtual async Task Json_nested_collection_anonymous_projection_in_projection_NoTrackingWithIdentityResolution(bool async) { - var message = (await Assert.ThrowsAsync(() => - AssertQuery( - async, - ss => ss.Set() - .OrderBy(x => x.Id) - .Select( - x => x.OwnedCollectionRoot - .Select( - xx => xx.OwnedCollectionBranch.Select( - xxx => new - { - xxx.Date, - xxx.Enum, - xxx.Enums, - xxx.Fraction, - xxx.OwnedReferenceLeaf, - xxx.OwnedCollectionLeaf - }).ToList())) - .AsNoTrackingWithIdentityResolution(), - assertOrder: true, - elementAsserter: (e, a) => AssertCollection( - e, a, ordered: true, elementAsserter: (ee, aa) => AssertCollection( - ee, aa, ordered: true, elementAsserter: (eee, aaa) => - { - AssertEqual(eee.Date, aaa.Date); - AssertEqual(eee.Enum, aaa.Enum); - AssertCollection(eee.Enums, aaa.Enums, ordered: true); - AssertEqual(eee.Fraction, aaa.Fraction); - AssertEqual(eee.OwnedReferenceLeaf, aaa.OwnedReferenceLeaf); - AssertCollection(eee.OwnedCollectionLeaf, aaa.OwnedCollectionLeaf, ordered: true); - }))))).Message; + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( + async, + ss => ss.Set() + .OrderBy(x => x.Id) + .Select( + x => x.OwnedCollectionRoot + .Select( + xx => xx.OwnedCollectionBranch.Select( + xxx => new + { + xxx.Date, + xxx.Enum, + xxx.Enums, + xxx.Fraction, + xxx.OwnedReferenceLeaf, + xxx.OwnedCollectionLeaf + }).ToList())) + .AsNoTrackingWithIdentityResolution(), + assertOrder: true, + elementAsserter: (e, a) => AssertCollection( + e, a, ordered: true, elementAsserter: (ee, aa) => AssertCollection( + ee, aa, ordered: true, elementAsserter: (eee, aaa) => + { + AssertEqual(eee.Date, aaa.Date); + AssertEqual(eee.Enum, aaa.Enum); + AssertCollection(eee.Enums, aaa.Enums, ordered: true); + AssertEqual(eee.Fraction, aaa.Fraction); + AssertEqual(eee.OwnedReferenceLeaf, aaa.OwnedReferenceLeaf); + AssertCollection(eee.OwnedCollectionLeaf, aaa.OwnedCollectionLeaf, ordered: true); + }))))).Message; Assert.Equal( - RelationalStrings.JsonProjectingQueryableOperationNoTrackingWithIdentityResolution(nameof(QueryTrackingBehavior.NoTrackingWithIdentityResolution)), + RelationalStrings.JsonProjectingQueryableOperationNoTrackingWithIdentityResolution( + nameof(QueryTrackingBehavior.NoTrackingWithIdentityResolution)), message); } @@ -193,23 +199,24 @@ public virtual async Task Json_nested_collection_anonymous_projection_in_project public virtual async Task Json_projection_nested_collection_and_element_using_parameter_AsNoTrackingWithIdentityResolution(bool async) { var prm = 0; - var message = (await Assert.ThrowsAsync(() => - AssertQuery( - async, - ss => ss.Set().Select( - x => new + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( + async, + ss => ss.Set().Select( + x => new + { + x.Id, + Original = x.OwnedReferenceRoot.OwnedCollectionBranch[prm].OwnedCollectionLeaf, + Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[prm].OwnedCollectionLeaf[1], + }).AsNoTrackingWithIdentityResolution(), + elementSorter: e => e.Id, + elementAsserter: (e, a) => { - x.Id, - Original = x.OwnedReferenceRoot.OwnedCollectionBranch[prm].OwnedCollectionLeaf, - Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[prm].OwnedCollectionLeaf[1], - }).AsNoTrackingWithIdentityResolution(), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - AssertEqual(e.Id, a.Id); - AssertEqual(e.Duplicate, a.Duplicate); - AssertCollection(e.Original, a.Original, ordered: true); - }))).Message; + AssertEqual(e.Id, a.Id); + AssertEqual(e.Duplicate, a.Duplicate); + AssertCollection(e.Original, a.Original, ordered: true); + }))).Message; Assert.Equal( RelationalStrings.JsonProjectingCollectionElementAccessedUsingParmeterNoTrackingWithIdentityResolution( @@ -224,23 +231,24 @@ public virtual async Task Json_projection_nested_collection_and_element_using_pa { var prm1 = 0; var prm2 = 0; - var message = (await Assert.ThrowsAsync(() => - AssertQuery( - async, - ss => ss.Set().Select( - x => new + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( + async, + ss => ss.Set().Select( + x => new + { + x.Id, + Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[prm1].OwnedCollectionLeaf[1], + Original = x.OwnedReferenceRoot.OwnedCollectionBranch[prm2].OwnedCollectionLeaf, + }).AsNoTrackingWithIdentityResolution(), + elementSorter: e => e.Id, + elementAsserter: (e, a) => { - x.Id, - Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[prm1].OwnedCollectionLeaf[1], - Original = x.OwnedReferenceRoot.OwnedCollectionBranch[prm2].OwnedCollectionLeaf, - }).AsNoTrackingWithIdentityResolution(), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - AssertEqual(e.Id, a.Id); - AssertEqual(e.Duplicate, a.Duplicate); - AssertCollection(e.Original, a.Original, ordered: true); - }))).Message; + AssertEqual(e.Id, a.Id); + AssertEqual(e.Duplicate, a.Duplicate); + AssertCollection(e.Original, a.Original, ordered: true); + }))).Message; Assert.Equal( RelationalStrings.JsonProjectingCollectionElementAccessedUsingParmeterNoTrackingWithIdentityResolution( @@ -251,28 +259,31 @@ public virtual async Task Json_projection_nested_collection_and_element_using_pa [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task Json_projection_second_element_through_collection_element_parameter_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution(bool async) + public virtual async Task + Json_projection_second_element_through_collection_element_parameter_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) { var prm1 = 0; var prm2 = 1; - var message = (await Assert.ThrowsAsync(() => - AssertQuery( - async, - ss => ss.Set().Select( - x => new + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( + async, + ss => ss.Set().Select( + x => new + { + x.Id, + Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[prm1].OwnedCollectionLeaf[1], + Original = x.OwnedReferenceRoot.OwnedCollectionBranch[prm2].OwnedCollectionLeaf, + }).AsNoTrackingWithIdentityResolution(), + elementSorter: e => e.Id, + elementAsserter: (e, a) => { - x.Id, - Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[prm1].OwnedCollectionLeaf[1], - Original = x.OwnedReferenceRoot.OwnedCollectionBranch[prm2].OwnedCollectionLeaf, - }).AsNoTrackingWithIdentityResolution(), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - AssertEqual(e.Id, a.Id); - AssertCollection(e.Original, a.Original, ordered: true); - AssertEqual(e.Duplicate, a.Duplicate); - }))).Message; + AssertEqual(e.Id, a.Id); + AssertCollection(e.Original, a.Original, ordered: true); + AssertEqual(e.Duplicate, a.Duplicate); + }))).Message; Assert.Equal( RelationalStrings.JsonProjectingCollectionElementAccessedUsingParmeterNoTrackingWithIdentityResolution( @@ -283,27 +294,30 @@ public virtual async Task Json_projection_second_element_through_collection_elem [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task Json_projection_second_element_through_collection_element_parameter_projected_before_owner_nested_AsNoTrackingWithIdentityResolution(bool async) + public virtual async Task + Json_projection_second_element_through_collection_element_parameter_projected_before_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) { var prm = 0; - var message = (await Assert.ThrowsAsync(() => - AssertQuery( - async, - ss => ss.Set().Select( - x => new + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( + async, + ss => ss.Set().Select( + x => new + { + x.Id, + Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[prm].OwnedCollectionLeaf[1], + Original = x.OwnedReferenceRoot.OwnedCollectionBranch[prm].OwnedCollectionLeaf, + }).AsNoTrackingWithIdentityResolution(), + elementSorter: e => e.Id, + elementAsserter: (e, a) => { - x.Id, - Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[prm].OwnedCollectionLeaf[1], - Original = x.OwnedReferenceRoot.OwnedCollectionBranch[prm].OwnedCollectionLeaf, - }).AsNoTrackingWithIdentityResolution(), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - AssertEqual(e.Id, a.Id); - AssertCollection(e.Original, a.Original, ordered: true); - AssertEqual(e.Duplicate, a.Duplicate); - }))).Message; + AssertEqual(e.Id, a.Id); + AssertCollection(e.Original, a.Original, ordered: true); + AssertEqual(e.Duplicate, a.Duplicate); + }))).Message; Assert.Equal( RelationalStrings.JsonProjectingCollectionElementAccessedUsingParmeterNoTrackingWithIdentityResolution( @@ -314,28 +328,31 @@ public virtual async Task Json_projection_second_element_through_collection_elem [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task Json_projection_second_element_through_collection_element_parameter_projected_before_owner_nested_AsNoTrackingWithIdentityResolution2(bool async) + public virtual async Task + Json_projection_second_element_through_collection_element_parameter_projected_before_owner_nested_AsNoTrackingWithIdentityResolution2( + bool async) { var prm1 = 0; var prm2 = 0; - var message = (await Assert.ThrowsAsync(() => - AssertQuery( - async, - ss => ss.Set().Select( - x => new + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( + async, + ss => ss.Set().Select( + x => new + { + x.Id, + Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[prm1].OwnedCollectionLeaf[1], + Original = x.OwnedReferenceRoot.OwnedCollectionBranch[prm2].OwnedCollectionLeaf, + }).AsNoTrackingWithIdentityResolution(), + elementSorter: e => e.Id, + elementAsserter: (e, a) => { - x.Id, - Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[prm1].OwnedCollectionLeaf[1], - Original = x.OwnedReferenceRoot.OwnedCollectionBranch[prm2].OwnedCollectionLeaf, - }).AsNoTrackingWithIdentityResolution(), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - AssertEqual(e.Id, a.Id); - AssertEqual(e.Original, a.Original); - AssertEqual(e.Duplicate, a.Duplicate); - }))).Message; + AssertEqual(e.Id, a.Id); + AssertEqual(e.Original, a.Original); + AssertEqual(e.Duplicate, a.Duplicate); + }))).Message; Assert.Equal( RelationalStrings.JsonProjectingCollectionElementAccessedUsingParmeterNoTrackingWithIdentityResolution( @@ -346,27 +363,30 @@ public virtual async Task Json_projection_second_element_through_collection_elem [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task Json_projection_second_element_through_collection_element_parameter_projected_after_owner_nested_AsNoTrackingWithIdentityResolution(bool async) + public virtual async Task + Json_projection_second_element_through_collection_element_parameter_projected_after_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) { var prm = 0; - var message = (await Assert.ThrowsAsync(() => - AssertQuery( - async, - ss => ss.Set().Select( - x => new + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( + async, + ss => ss.Set().Select( + x => new + { + x.Id, + Original = x.OwnedReferenceRoot.OwnedCollectionBranch[prm].OwnedCollectionLeaf, + Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[prm].OwnedCollectionLeaf[1], + }).AsNoTrackingWithIdentityResolution(), + elementSorter: e => e.Id, + elementAsserter: (e, a) => { - x.Id, - Original = x.OwnedReferenceRoot.OwnedCollectionBranch[prm].OwnedCollectionLeaf, - Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[prm].OwnedCollectionLeaf[1], - }).AsNoTrackingWithIdentityResolution(), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - AssertEqual(e.Id, a.Id); - AssertCollection(e.Original, a.Original, ordered: true); - AssertEqual(e.Duplicate, a.Duplicate); - }))).Message; + AssertEqual(e.Id, a.Id); + AssertCollection(e.Original, a.Original, ordered: true); + AssertEqual(e.Duplicate, a.Duplicate); + }))).Message; Assert.Equal( RelationalStrings.JsonProjectingCollectionElementAccessedUsingParmeterNoTrackingWithIdentityResolution( @@ -377,25 +397,28 @@ public virtual async Task Json_projection_second_element_through_collection_elem [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task Json_projection_second_element_through_collection_element_constant_projected_before_owner_nested_AsNoTrackingWithIdentityResolution(bool async) + public virtual async Task + Json_projection_second_element_through_collection_element_constant_projected_before_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) { - var message = (await Assert.ThrowsAsync(() => - AssertQuery( - async, - ss => ss.Set().Select( - x => new - { - x.Id, - Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[0].OwnedCollectionLeaf[1], - Original = x.OwnedReferenceRoot.OwnedCollectionBranch[0].OwnedCollectionLeaf, - }).AsNoTrackingWithIdentityResolution(), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - AssertEqual(e.Id, a.Id); - AssertEqual(e.Original, a.Original); - AssertEqual(e.Duplicate, a.Duplicate); - }))).Message; + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( + async, + ss => ss.Set().Select( + x => new + { + x.Id, + Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[0].OwnedCollectionLeaf[1], + Original = x.OwnedReferenceRoot.OwnedCollectionBranch[0].OwnedCollectionLeaf, + }).AsNoTrackingWithIdentityResolution(), + elementSorter: e => e.Id, + elementAsserter: (e, a) => + { + AssertEqual(e.Id, a.Id); + AssertEqual(e.Original, a.Original); + AssertEqual(e.Duplicate, a.Duplicate); + }))).Message; Assert.Equal( RelationalStrings.JsonProjectingEntitiesIncorrectOrderNoTrackingWithIdentityResolution( @@ -408,27 +431,29 @@ public virtual async Task Json_projection_second_element_through_collection_elem [MemberData(nameof(IsAsyncData))] public virtual async Task Json_branch_collection_distinct_and_other_collection_AsNoTrackingWithIdentityResolution(bool async) { - var message = (await Assert.ThrowsAsync(() => - AssertQuery( - async, - ss => ss.Set() - .OrderBy(x => x.Id) - .Select( - x => new - { - First = x.EntityCollection.ToList(), - Second = x.OwnedReferenceRoot.OwnedCollectionBranch.Distinct().ToList() - }) - .AsNoTrackingWithIdentityResolution(), - assertOrder: true, - elementAsserter: (e, a) => - { - AssertCollection(e.First, a.First, ordered: true); - AssertCollection(e.Second, a.Second, elementSorter: ee => ee.Fraction); - }))).Message; + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( + async, + ss => ss.Set() + .OrderBy(x => x.Id) + .Select( + x => new + { + First = x.EntityCollection.ToList(), + Second = x.OwnedReferenceRoot.OwnedCollectionBranch.Distinct().ToList() + }) + .AsNoTrackingWithIdentityResolution(), + assertOrder: true, + elementAsserter: (e, a) => + { + AssertCollection(e.First, a.First, ordered: true); + AssertCollection(e.Second, a.Second, elementSorter: ee => ee.Fraction); + }))).Message; Assert.Equal( - RelationalStrings.JsonProjectingQueryableOperationNoTrackingWithIdentityResolution(nameof(QueryTrackingBehavior.NoTrackingWithIdentityResolution)), + RelationalStrings.JsonProjectingQueryableOperationNoTrackingWithIdentityResolution( + nameof(QueryTrackingBehavior.NoTrackingWithIdentityResolution)), message); } @@ -436,8 +461,9 @@ public virtual async Task Json_branch_collection_distinct_and_other_collection_A [MemberData(nameof(IsAsyncData))] public virtual async Task Json_collection_SelectMany_AsNoTrackingWithIdentityResolution(bool async) { - var message = (await Assert.ThrowsAsync(() => - AssertQuery( + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( async, ss => ss.Set() .SelectMany(x => x.OwnedCollectionRoot) @@ -445,7 +471,8 @@ public virtual async Task Json_collection_SelectMany_AsNoTrackingWithIdentityRes elementSorter: e => (e.Number, e.Name)))).Message; Assert.Equal( - RelationalStrings.JsonProjectingQueryableOperationNoTrackingWithIdentityResolution(nameof(QueryTrackingBehavior.NoTrackingWithIdentityResolution)), + RelationalStrings.JsonProjectingQueryableOperationNoTrackingWithIdentityResolution( + nameof(QueryTrackingBehavior.NoTrackingWithIdentityResolution)), message); } @@ -454,25 +481,26 @@ public virtual async Task Json_collection_SelectMany_AsNoTrackingWithIdentityRes public virtual async Task Json_projection_deduplication_with_collection_indexer_in_target_AsNoTrackingWithIdentityResolution(bool async) { var prm = 1; - var message = (await Assert.ThrowsAsync(() => - AssertQuery( - async, - ss => ss.Set().Select( - x => new + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( + async, + ss => ss.Set().Select( + x => new + { + x.Id, + Duplicate1 = x.OwnedReferenceRoot.OwnedCollectionBranch[1], + Original = x.OwnedReferenceRoot, + Duplicate2 = x.OwnedReferenceRoot.OwnedReferenceBranch.OwnedCollectionLeaf[prm] + }).AsNoTrackingWithIdentityResolution(), + elementSorter: e => e.Id, + elementAsserter: (e, a) => { - x.Id, - Duplicate1 = x.OwnedReferenceRoot.OwnedCollectionBranch[1], - Original = x.OwnedReferenceRoot, - Duplicate2 = x.OwnedReferenceRoot.OwnedReferenceBranch.OwnedCollectionLeaf[prm] - }).AsNoTrackingWithIdentityResolution(), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - AssertEqual(e.Id, a.Id); - AssertEqual(e.Original, a.Original); - AssertEqual(e.Duplicate1, a.Duplicate1); - AssertEqual(e.Duplicate2, a.Duplicate2); - }))).Message; + AssertEqual(e.Id, a.Id); + AssertEqual(e.Original, a.Original); + AssertEqual(e.Duplicate1, a.Duplicate1); + AssertEqual(e.Duplicate2, a.Duplicate2); + }))).Message; Assert.Equal( RelationalStrings.JsonProjectingEntitiesIncorrectOrderNoTrackingWithIdentityResolution( @@ -485,23 +513,24 @@ public virtual async Task Json_projection_deduplication_with_collection_indexer_ [MemberData(nameof(IsAsyncData))] public virtual async Task Json_projection_nested_collection_and_element_wrong_order_AsNoTrackingWithIdentityResolution(bool async) { - var message = (await Assert.ThrowsAsync(() => - AssertQuery( - async, - ss => ss.Set().Select( - x => new + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( + async, + ss => ss.Set().Select( + x => new + { + x.Id, + Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[0].OwnedCollectionLeaf[1], + Original = x.OwnedReferenceRoot.OwnedCollectionBranch[0].OwnedCollectionLeaf, + }).AsNoTrackingWithIdentityResolution(), + elementSorter: e => e.Id, + elementAsserter: (e, a) => { - x.Id, - Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[0].OwnedCollectionLeaf[1], - Original = x.OwnedReferenceRoot.OwnedCollectionBranch[0].OwnedCollectionLeaf, - }).AsNoTrackingWithIdentityResolution(), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - AssertEqual(e.Id, a.Id); - AssertEqual(e.Duplicate, a.Duplicate); - AssertCollection(e.Original, a.Original, ordered: true); - }))).Message; + AssertEqual(e.Id, a.Id); + AssertEqual(e.Duplicate, a.Duplicate); + AssertCollection(e.Original, a.Original, ordered: true); + }))).Message; Assert.Equal( RelationalStrings.JsonProjectingEntitiesIncorrectOrderNoTrackingWithIdentityResolution( @@ -512,25 +541,27 @@ public virtual async Task Json_projection_nested_collection_and_element_wrong_or [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task Json_projection_second_element_projected_before_entire_collection_AsNoTrackingWithIdentityResolution(bool async) + public virtual async Task Json_projection_second_element_projected_before_entire_collection_AsNoTrackingWithIdentityResolution( + bool async) { - var message = (await Assert.ThrowsAsync(() => - AssertQuery( - async, - ss => ss.Set().Select( - x => new + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( + async, + ss => ss.Set().Select( + x => new + { + x.Id, + Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[1], + Original = x.OwnedReferenceRoot.OwnedCollectionBranch, + }).AsNoTrackingWithIdentityResolution(), + elementSorter: e => e.Id, + elementAsserter: (e, a) => { - x.Id, - Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[1], - Original = x.OwnedReferenceRoot.OwnedCollectionBranch, - }).AsNoTrackingWithIdentityResolution(), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - AssertEqual(e.Id, a.Id); - AssertEqual(e.Original, a.Original); - AssertEqual(e.Duplicate, a.Duplicate); - }))).Message; + AssertEqual(e.Id, a.Id); + AssertEqual(e.Original, a.Original); + AssertEqual(e.Duplicate, a.Duplicate); + }))).Message; Assert.Equal( RelationalStrings.JsonProjectingEntitiesIncorrectOrderNoTrackingWithIdentityResolution( @@ -543,23 +574,24 @@ public virtual async Task Json_projection_second_element_projected_before_entire [MemberData(nameof(IsAsyncData))] public virtual async Task Json_projection_second_element_projected_before_owner_AsNoTrackingWithIdentityResolution(bool async) { - var message = (await Assert.ThrowsAsync(() => - AssertQuery( - async, - ss => ss.Set().Select( - x => new + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( + async, + ss => ss.Set().Select( + x => new + { + x.Id, + Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[1], + Original = x.OwnedReferenceRoot, + }).AsNoTrackingWithIdentityResolution(), + elementSorter: e => e.Id, + elementAsserter: (e, a) => { - x.Id, - Duplicate = x.OwnedReferenceRoot.OwnedCollectionBranch[1], - Original = x.OwnedReferenceRoot, - }).AsNoTrackingWithIdentityResolution(), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - AssertEqual(e.Id, a.Id); - AssertEqual(e.Original, a.Original); - AssertEqual(e.Duplicate, a.Duplicate); - }))).Message; + AssertEqual(e.Id, a.Id); + AssertEqual(e.Original, a.Original); + AssertEqual(e.Duplicate, a.Duplicate); + }))).Message; Assert.Equal( RelationalStrings.JsonProjectingEntitiesIncorrectOrderNoTrackingWithIdentityResolution( @@ -572,24 +604,25 @@ public virtual async Task Json_projection_second_element_projected_before_owner_ [MemberData(nameof(IsAsyncData))] public virtual async Task Json_projection_second_element_projected_before_owner_nested_AsNoTrackingWithIdentityResolution(bool async) { - var message = (await Assert.ThrowsAsync(() => - AssertQuery( - async, - ss => ss.Set().Select( - x => new + var message = (await Assert.ThrowsAsync( + () => + AssertQuery( + async, + ss => ss.Set().Select( + x => new + { + x.Id, + Duplicate = x.OwnedReferenceRoot.OwnedReferenceBranch.OwnedCollectionLeaf[1], + Original = x.OwnedReferenceRoot.OwnedReferenceBranch.OwnedCollectionLeaf, + Parent = x.OwnedReferenceRoot.OwnedReferenceBranch, + }).AsNoTrackingWithIdentityResolution(), + elementSorter: e => e.Id, + elementAsserter: (e, a) => { - x.Id, - Duplicate = x.OwnedReferenceRoot.OwnedReferenceBranch.OwnedCollectionLeaf[1], - Original = x.OwnedReferenceRoot.OwnedReferenceBranch.OwnedCollectionLeaf, - Parent = x.OwnedReferenceRoot.OwnedReferenceBranch, - }).AsNoTrackingWithIdentityResolution(), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - AssertEqual(e.Id, a.Id); - AssertEqual(e.Original, a.Original); - AssertEqual(e.Duplicate, a.Duplicate); - }))).Message; + AssertEqual(e.Id, a.Id); + AssertEqual(e.Original, a.Original); + AssertEqual(e.Duplicate, a.Duplicate); + }))).Message; Assert.Equal( RelationalStrings.JsonProjectingEntitiesIncorrectOrderNoTrackingWithIdentityResolution( diff --git a/test/EFCore.Relational.Specification.Tests/Query/NonSharedPrimitiveCollectionsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NonSharedPrimitiveCollectionsQueryRelationalTestBase.cs index cafccdba0d1..e08f86ad249 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NonSharedPrimitiveCollectionsQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NonSharedPrimitiveCollectionsQueryRelationalTestBase.cs @@ -95,7 +95,8 @@ public virtual async Task Parameter_collection_Count_with_column_predicate_with_ await using var context = contextFactory.CreateContext(); var ids = new[] { 2, 999 }; - var result = await context.Set().Where(c => EF.Parameter(ids).Count(i => i > c.Id) == 1).Select(x => x.Id).ToListAsync(); + var result = await context.Set().Where(c => EF.Parameter(ids).Count(i => i > c.Id) == 1).Select(x => x.Id) + .ToListAsync(); Assert.Equivalent(new[] { 100 }, result); } diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs index b0fdd042b38..1d702595038 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs @@ -1,8 +1,6 @@ // 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.Northwind; - namespace Microsoft.EntityFrameworkCore.Query; #nullable disable diff --git a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryFixtureBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryFixtureBase.cs index 8cc44b96471..81779164442 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryFixtureBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryFixtureBase.cs @@ -123,32 +123,35 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con modelBuilder.HasDbFunction( typeof(NullSemanticsQueryFixtureBase).GetMethod(nameof(Cases)), - b => b.HasTranslation(args => new CaseExpression([ - new CaseWhenClause(args[0], args[1]), - new CaseWhenClause(args[2], args[3]), - new CaseWhenClause(args[4], args[5]), - ])) + b => b.HasTranslation( + args => new CaseExpression( + [ + new CaseWhenClause(args[0], args[1]), + new CaseWhenClause(args[2], args[3]), + new CaseWhenClause(args[4], args[5]), + ])) ); modelBuilder.HasDbFunction( typeof(NullSemanticsQueryFixtureBase).GetMethod(nameof(BoolSwitch)), - b => b.HasTranslation(args => new CaseExpression( - operand: args[0], - [ - new CaseWhenClause(new SqlConstantExpression(true, typeMapping: BoolTypeMapping.Default), args[1]), - new CaseWhenClause(new SqlConstantExpression(false, typeMapping: BoolTypeMapping.Default), args[2]), - ])) + b => b.HasTranslation( + args => new CaseExpression( + operand: args[0], + [ + new CaseWhenClause(new SqlConstantExpression(true, typeMapping: BoolTypeMapping.Default), args[1]), + new CaseWhenClause(new SqlConstantExpression(false, typeMapping: BoolTypeMapping.Default), args[2]), + ])) ); } - public static int? Cases(bool c1, int v1, bool c2, int v2, bool c3, int v3) => - c1 ? v1 : - c2 ? v2 : - c3 ? v3 : - null; + public static int? Cases(bool c1, int v1, bool c2, int v2, bool c3, int v3) + => c1 ? v1 : + c2 ? v2 : + c3 ? v3 : + null; - public static int BoolSwitch(bool x, int whenTrue, int whenFalse) => - x switch + public static int BoolSwitch(bool x, int whenTrue, int whenFalse) + => x switch { true => whenTrue, false => whenFalse, diff --git a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs index d0b6f8dec32..4ac99509883 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs @@ -24,7 +24,7 @@ public abstract class NullSemanticsQueryTestBase(TFixture fixture) : Q [MemberData(nameof(IsAsyncData))] public virtual async Task Rewrite_compare_int_with_int(bool async) { - var bools = new bool[] { false, true }; + var bools = new[] { false, true }; foreach (var neq in bools) { @@ -37,12 +37,38 @@ public virtual async Task Rewrite_compare_int_with_int(bool async) var queryBuilder = (ISetSource ss) => { var data = nullableA - ? ss.Set().Select(e => new { e.Id, A = e.NullableIntA, e.IntB, e.NullableIntB }) - : ss.Set().Select(e => new { e.Id, A = (int?)e.IntA, e.IntB, e.NullableIntB }); + ? ss.Set().Select( + e => new + { + e.Id, + A = e.NullableIntA, + e.IntB, + e.NullableIntB + }) + : ss.Set().Select( + e => new + { + e.Id, + A = (int?)e.IntA, + e.IntB, + e.NullableIntB + }); var query = nullableB - ? data.Select(e => new { e.Id, e.A, B = e.NullableIntB }) - : data.Select(e => new { e.Id, e.A, B = (int?)e.IntB }); + ? data.Select( + e => new + { + e.Id, + e.A, + B = e.NullableIntB + }) + : data.Select( + e => new + { + e.Id, + e.A, + B = (int?)e.IntB + }); var result = neq ? query.Select(e => new { e.Id, X = e.A != e.B }) @@ -65,7 +91,7 @@ public virtual async Task Rewrite_compare_int_with_int(bool async) [MemberData(nameof(IsAsyncData))] public virtual async Task Rewrite_compare_bool_with_bool(bool async) { - var bools = new bool[] { false, true }; + var bools = new[] { false, true }; foreach (var neq in bools) { @@ -82,15 +108,57 @@ public virtual async Task Rewrite_compare_bool_with_bool(bool async) var queryBuilder = (ISetSource ss) => { var data = nullableA - ? ss.Set().Select(e => new { e.Id, A = e.NullableBoolA, e.BoolB, e.NullableBoolB }) - : ss.Set().Select(e => new { e.Id, A = (bool?)e.BoolA, e.BoolB, e.NullableBoolB }); + ? ss.Set().Select( + e => new + { + e.Id, + A = e.NullableBoolA, + e.BoolB, + e.NullableBoolB + }) + : ss.Set().Select( + e => new + { + e.Id, + A = (bool?)e.BoolA, + e.BoolB, + e.NullableBoolB + }); var query = nullableB - ? data.Select(e => new { e.Id, e.A, B = e.NullableBoolB }) - : data.Select(e => new { e.Id, e.A, B = (bool?)e.BoolB }); - - query = negateA ? query.Select(e => new { e.Id, A = !e.A, e.B }) : query; - query = negateB ? query.Select(e => new { e.Id, e.A, B = !e.B }) : query; + ? data.Select( + e => new + { + e.Id, + e.A, + B = e.NullableBoolB + }) + : data.Select( + e => new + { + e.Id, + e.A, + B = (bool?)e.BoolB + }); + + query = negateA + ? query.Select( + e => new + { + e.Id, + A = !e.A, + e.B + }) + : query; + query = negateB + ? query.Select( + e => new + { + e.Id, + e.A, + B = !e.B + }) + : query; var result = neq ? query.Select(e => new { e.Id, X = e.A != e.B }) @@ -495,7 +563,7 @@ public virtual Task Join_uses_csharp_semantics_for_anon_objects(bool async) async, ss => from e1 in ss.Set() join e2 in ss.Set() on - new { NullInt = e1.NullableIntA } equals new { NullInt = e2.NullableIntB } + new { NullInt = e1.NullableIntA } equals new { NullInt = e2.NullableIntB } select new { Id1 = e1.Id, @@ -615,14 +683,17 @@ public virtual Task Where_coalesce(bool async) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_coalesce_shortcircuit(bool async) - => AssertQueryScalar(async, ss => ss.Set().Where(e => (bool?)(e.BoolA | e.BoolB) ?? e.NullableBoolA ?? true) - .Select(e => e.Id)); + => AssertQueryScalar( + async, ss => ss.Set().Where(e => (bool?)(e.BoolA | e.BoolB) ?? e.NullableBoolA ?? true) + .Select(e => e.Id)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_coalesce_shortcircuit_many(bool async) - => AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA ?? (bool?)(e.BoolA | e.BoolB) ?? e.NullableBoolB ?? e.BoolB) - .Select(e => e.Id)); + => AssertQueryScalar( + async, ss => ss.Set() + .Where(e => e.NullableBoolA ?? (bool?)(e.BoolA | e.BoolB) ?? e.NullableBoolB ?? e.BoolB) + .Select(e => e.Id)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -1061,7 +1132,8 @@ public virtual Task Where_IndexOf_empty(bool async) => AssertQueryScalar( async, ss => ss.Set().Where(e => e.NullableStringA.IndexOf("") == e.NullableIntA).Select(e => e.Id), - ss => ss.Set().Where(e => 0 == e.NullableIntA || (e.NullableStringA == null && e.NullableIntA == null)).Select(e => e.Id)); + ss => ss.Set().Where(e => 0 == e.NullableIntA || (e.NullableStringA == null && e.NullableIntA == null)) + .Select(e => e.Id)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -1543,11 +1615,13 @@ public virtual async Task Null_semantics_contains_non_nullable_item_with_values( await AssertQueryScalar(async, ss => ss.Set().Where(e => !ids2.Contains(e.IntA)).Select(e => e.Id)); var ids3 = new List(); - await AssertQueryScalar(async, ss => ss.Set().Where(e => ids3.Contains(e.IntA)).Select(e => e.Id), assertEmpty: true); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => ids3.Contains(e.IntA)).Select(e => e.Id), assertEmpty: true); await AssertQueryScalar(async, ss => ss.Set().Where(e => !ids3.Contains(e.IntA)).Select(e => e.Id)); var ids4 = new List { null }; - await AssertQueryScalar(async, ss => ss.Set().Where(e => ids4.Contains(e.IntA)).Select(e => e.Id), assertEmpty: true); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => ids4.Contains(e.IntA)).Select(e => e.Id), assertEmpty: true); await AssertQueryScalar(async, ss => ss.Set().Where(e => !ids4.Contains(e.IntA)).Select(e => e.Id)); } @@ -1844,11 +1918,13 @@ public virtual Task CaseWhen_equal_to_second_filter(bool async) => AssertQuery( async, ss => ss.Set() - .Where(x => NullSemanticsQueryFixtureBase.Cases( - x.StringA == "Foo", 3, - x.StringB == "Foo", 2, - x.StringC == "Foo", 3 - ) == 2) + .Where( + x => NullSemanticsQueryFixtureBase.Cases( + x.StringA == "Foo", 3, + x.StringB == "Foo", 2, + x.StringC == "Foo", 3 + ) + == 2) ); [ConditionalTheory] @@ -1857,11 +1933,13 @@ public virtual Task CaseWhen_equal_to_first_or_third_filter(bool async) => AssertQuery( async, ss => ss.Set() - .Where(x => NullSemanticsQueryFixtureBase.Cases( - x.StringA == "Foo", 3, - x.StringB == "Foo", 2, - x.StringC == "Foo", 3 - ) == 3) + .Where( + x => NullSemanticsQueryFixtureBase.Cases( + x.StringA == "Foo", 3, + x.StringB == "Foo", 2, + x.StringC == "Foo", 3 + ) + == 3) ); [ConditionalTheory] @@ -1871,11 +1949,13 @@ public virtual Task CaseWhen_equal_to_second_select(bool async) async, ss => ss.Set() .OrderBy(x => x.Id) - .Select(x => NullSemanticsQueryFixtureBase.Cases( - x.StringA == "Foo", 3, - x.StringB == "Foo", 2, - x.StringC == "Foo", 3 - ) == 2), + .Select( + x => NullSemanticsQueryFixtureBase.Cases( + x.StringA == "Foo", 3, + x.StringB == "Foo", 2, + x.StringC == "Foo", 3 + ) + == 2), assertOrder: true ); @@ -1886,11 +1966,13 @@ public virtual Task CaseWhen_equal_to_first_or_third_select(bool async) async, ss => ss.Set() .OrderBy(x => x.Id) - .Select(x => NullSemanticsQueryFixtureBase.Cases( - x.StringA == "Foo", 3, - x.StringB == "Foo", 2, - x.StringC == "Foo", 3 - ) == 3), + .Select( + x => NullSemanticsQueryFixtureBase.Cases( + x.StringA == "Foo", 3, + x.StringB == "Foo", 2, + x.StringC == "Foo", 3 + ) + == 3), assertOrder: true ); @@ -1901,9 +1983,10 @@ public virtual Task CaseOpWhen_projection(bool async) async, ss => ss.Set() .OrderBy(x => x.Id) - .Select(x => NullSemanticsQueryFixtureBase.BoolSwitch( - x.StringA == "Foo", 3, 2 - )), + .Select( + x => NullSemanticsQueryFixtureBase.BoolSwitch( + x.StringA == "Foo", 3, 2 + )), assertOrder: true ); @@ -1913,9 +1996,11 @@ public virtual Task CaseOpWhen_predicate(bool async) => AssertQuery( async, ss => ss.Set() - .Where(x => NullSemanticsQueryFixtureBase.BoolSwitch( - x.StringA == "Foo", 3, 2 - ) == 2), + .Where( + x => NullSemanticsQueryFixtureBase.BoolSwitch( + x.StringA == "Foo", 3, 2 + ) + == 2), assertOrder: true ); diff --git a/test/EFCore.Relational.Specification.Tests/Query/OperatorsProceduralQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/OperatorsProceduralQueryTestBase.cs index f9529d0c361..f44b4ec2392 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/OperatorsProceduralQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/OperatorsProceduralQueryTestBase.cs @@ -1280,7 +1280,7 @@ private class RootEntityExpressionInfo(Expression expression) { public Expression Expression { get; } = expression; - public bool Used { get; set; } = false; + public bool Used { get; set; } } private class ActualSetSource(DbContext context) : ISetSource diff --git a/test/EFCore.Relational.Specification.Tests/Query/OptionalDependentQueryFixtureBase.cs b/test/EFCore.Relational.Specification.Tests/Query/OptionalDependentQueryFixtureBase.cs index c4366a6ce5e..2185c3ce8f4 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/OptionalDependentQueryFixtureBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/OptionalDependentQueryFixtureBase.cs @@ -93,7 +93,6 @@ public static void AssertOptionalDependentJsonSomeRequired( Assert.Equal(expected.OpProp2, actual.OpProp2); Assert.Equal(expected.ReqProp, actual.ReqProp); - if (expected.OpNav1 is not null || actual.OpNav1 is not null) { AssertOptionalDependentNestedJsonAllOptional(expected.OpNav1, actual.OpNav1); diff --git a/test/EFCore.Relational.Specification.Tests/Query/OwnedEntityQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/OwnedEntityQueryRelationalTestBase.cs index 12f1b63c13d..bfee9bfd966 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/OwnedEntityQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/OwnedEntityQueryRelationalTestBase.cs @@ -28,7 +28,8 @@ public virtual async Task An_optional_dependent_without_any_columns_and_nested_d message); } - private class Context23198(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context23198(DbContextOptions options) : DbContext(options) { protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.Entity().OwnsOne( @@ -81,7 +82,8 @@ public virtual async Task Multiple_owned_reference_mapped_to_own_table_containin Assert.Equal(2, root3.ModdleA.Leaves.Count); } - private class Context24777(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context24777(DbContextOptions options) : DbContext(options) { public DbSet Roots { get; set; } @@ -155,7 +157,7 @@ public class ModdleA { public int Id { get; init; } public int RootId { get; init; } - public List Leaves { get; init; } + public List Leaves { get; } } public class MiddleB @@ -422,7 +424,8 @@ public virtual async Task Owned_entity_with_all_null_properties_property_access_ }); } - private class Context28247(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context28247(DbContextOptions options) : DbContext(options) { public DbSet RotRutCases { get; set; } @@ -505,7 +508,8 @@ join magus in context.Magi.Where(x => x.Name.Contains("Bayaz")) on monarch.Ruler Assert.Equal("The Divider", result[0].magus.ToolUsed.Name); } - private class Context30358(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context30358(DbContextOptions options) : DbContext(options) { public DbSet Monarchs { get; set; } public DbSet Magi { get; set; } @@ -518,15 +522,13 @@ public Task SeedAsync() Add( new Monarch { - Name = "His August Majesty Guslav the Fifth", - RulerOf = "The Union", + Name = "His August Majesty Guslav the Fifth", RulerOf = "The Union", }); Add( new Monarch { - Name = "Emperor Uthman-ul-Dosht", - RulerOf = "The Gurkish Empire", + Name = "Emperor Uthman-ul-Dosht", RulerOf = "The Gurkish Empire", }); Add( @@ -581,7 +583,8 @@ public async Task Can_have_required_owned_type_on_derived_type() context.Set().ToList(); } - private class Context31107(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context31107(DbContextOptions options) : DbContext(options) { protected override void OnModelCreating(ModelBuilder modelBuilder) { diff --git a/test/EFCore.Relational.Specification.Tests/Query/OwnedQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/OwnedQueryRelationalTestBase.cs index b6ed890e077..ecbe47b3c9f 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/OwnedQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/OwnedQueryRelationalTestBase.cs @@ -1,8 +1,6 @@ // 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.Diagnostics.Internal; - namespace Microsoft.EntityFrameworkCore.Query; #nullable disable diff --git a/test/EFCore.Relational.Specification.Tests/Query/PrecompiledQueryRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/Query/PrecompiledQueryRelationalFixture.cs index 74c4c745a9f..a557ec7a11d 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/PrecompiledQueryRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/PrecompiledQueryRelationalFixture.cs @@ -7,6 +7,7 @@ using Post = Microsoft.EntityFrameworkCore.Query.PrecompiledQueryRelationalTestBase.Post; using JsonRoot = Microsoft.EntityFrameworkCore.Query.PrecompiledQueryRelationalTestBase.JsonRoot; using JsonBranch = Microsoft.EntityFrameworkCore.Query.PrecompiledQueryRelationalTestBase.JsonBranch; + namespace Microsoft.EntityFrameworkCore.Query; public abstract class PrecompiledQueryRelationalFixture @@ -30,24 +31,65 @@ protected override IServiceCollection AddServices(IServiceCollection serviceColl protected override async Task SeedAsync(PrecompiledQueryRelationalTestBase.PrecompiledQueryContext context) { - var blog1 = new Blog { Id = 8, Name = "Blog1", Json = [] }; + var blog1 = new Blog + { + Id = 8, + Name = "Blog1", + Json = [] + }; var blog2 = new Blog { Id = 9, Name = "Blog2", Json = [ - new JsonRoot { Number = 1, Text = "One", Inner = new JsonBranch { Date = new DateTime(2001, 1, 1) } }, - new JsonRoot { Number = 2, Text = "Two", Inner = new JsonBranch { Date = new DateTime(2002, 2, 2) } }, - ]}; + new JsonRoot + { + Number = 1, + Text = "One", + Inner = new JsonBranch { Date = new DateTime(2001, 1, 1) } + }, + new JsonRoot + { + Number = 2, + Text = "Two", + Inner = new JsonBranch { Date = new DateTime(2002, 2, 2) } + }, + ] + }; context.Blogs.AddRange(blog1, blog2); - var post11 = new Post { Id = 11, Title = "Post11", Blog = blog1 }; - var post12 = new Post { Id = 12, Title = "Post12", Blog = blog1 }; - var post21 = new Post { Id = 21, Title = "Post21", Blog = blog2 }; - var post22 = new Post { Id = 22, Title = "Post22", Blog = blog2 }; - var post23 = new Post { Id = 23, Title = "Post23", Blog = blog2 }; + var post11 = new Post + { + Id = 11, + Title = "Post11", + Blog = blog1 + }; + var post12 = new Post + { + Id = 12, + Title = "Post12", + Blog = blog1 + }; + var post21 = new Post + { + Id = 21, + Title = "Post21", + Blog = blog2 + }; + var post22 = new Post + { + Id = 22, + Title = "Post22", + Blog = blog2 + }; + var post23 = new Post + { + Id = 23, + Title = "Post23", + Blog = blog2 + }; context.Posts.AddRange(post11, post12, post21, post22, post23); await context.SaveChangesAsync(); diff --git a/test/EFCore.Relational.Specification.Tests/Query/PrecompiledQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/PrecompiledQueryRelationalTestBase.cs index 6a7642767f6..5658c6863a9 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/PrecompiledQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/PrecompiledQueryRelationalTestBase.cs @@ -12,7 +12,6 @@ namespace Microsoft.EntityFrameworkCore.Query; // ReSharper disable InconsistentNaming - /// /// General tests for precompiled queries. /// See also for tests specifically related to SQL pregeneration. @@ -32,7 +31,8 @@ public PrecompiledQueryRelationalTestBase(PrecompiledQueryRelationalFixture fixt [ConditionalFact] public virtual Task BinaryExpression() - => Test(""" + => Test( + """ var id = 3; var blogs = await context.Blogs.Where(b => b.Id > id).ToListAsync(); @@ -60,14 +60,16 @@ public virtual Task BinaryExpression() [ConditionalFact] public virtual Task Conditional_no_evaluatable() - => Test(""" + => Test( + """ var id = 3; var blogs = await context.Blogs.Select(b => b.Id == 2 ? "yes" : "no").ToListAsync(); """); [ConditionalFact] public virtual Task Conditional_contains_captured_variable() - => Test(""" + => Test( + """ var yes = "yes"; var blogs = await context.Blogs.Select(b => b.Id == 2 ? yes : "no").ToListAsync(); """); @@ -87,14 +89,14 @@ public virtual Task Invoke_no_evaluatability_is_not_supported() """, errorAsserter: errors => Assert.IsType(errors.Single().Exception)); - [ConditionalFact] - public virtual Task ListInit_no_evaluatability() - => Test("_ = await context.Blogs.Select(b => new List { b.Id, b.Id + 1 }).ToListAsync();"); + [ConditionalFact] + public virtual Task ListInit_no_evaluatability() + => Test("_ = await context.Blogs.Select(b => new List { b.Id, b.Id + 1 }).ToListAsync();"); - [ConditionalFact] - public virtual Task ListInit_with_evaluatable_with_captured_variable() - => Test( - """ + [ConditionalFact] + public virtual Task ListInit_with_evaluatable_with_captured_variable() + => Test( + """ var i = 1; _ = await context.Blogs.Select(b => new List { b.Id, i }).ToListAsync(); """); @@ -102,25 +104,27 @@ public virtual Task ListInit_with_evaluatable_with_captured_variable() [ConditionalFact] public virtual Task ListInit_with_evaluatable_without_captured_variable() => Test( - """ + """ var i = 1; _ = await context.Blogs.Select(b => new List { b.Id, 8 }).ToListAsync(); """); [ConditionalFact] public virtual Task ListInit_fully_evaluatable() - => Test(""" + => Test( + """ var blog = await context.Blogs.Where(b => new List { 7, 8 }.Contains(b.Id)).SingleAsync(); Assert.Equal("Blog1", blog.Name); """); - [ConditionalFact] - public virtual Task MethodCallExpression_no_evaluatability() - => Test("_ = await context.Blogs.Where(b => b.Name.StartsWith(b.Name)).ToListAsync();"); + [ConditionalFact] + public virtual Task MethodCallExpression_no_evaluatability() + => Test("_ = await context.Blogs.Where(b => b.Name.StartsWith(b.Name)).ToListAsync();"); [ConditionalFact] public virtual Task MethodCallExpression_with_evaluatable_with_captured_variable() - => Test(""" + => Test( + """ var pattern = "foo"; _ = await context.Blogs.Where(b => b.Name.StartsWith(pattern)).ToListAsync(); """); @@ -201,7 +205,8 @@ public virtual Task Unary() [ConditionalFact] public virtual Task Terminating_AsEnumerable() - => Test(""" + => Test( + """ var blogs = context.Blogs.AsEnumerable().ToList(); Assert.Collection( blogs.OrderBy(b => b.Id), @@ -211,7 +216,8 @@ public virtual Task Terminating_AsEnumerable() [ConditionalFact] public virtual Task Terminating_AsAsyncEnumerable_on_DbSet() - => Test(""" + => Test( + """ var sum = 0; await foreach (var blog in context.Blogs.AsAsyncEnumerable()) { @@ -222,7 +228,8 @@ public virtual Task Terminating_AsAsyncEnumerable_on_DbSet() [ConditionalFact] public virtual Task Terminating_AsAsyncEnumerable_on_IQueryable() - => Test(""" + => Test( + """ var sum = 0; await foreach (var blog in context.Blogs.Where(b => b.Id > 8).AsAsyncEnumerable()) { @@ -1083,7 +1090,8 @@ public virtual Task Project_anonymous_object() [ConditionalFact] public virtual Task Two_captured_variables_in_same_lambda() - => Test(""" + => Test( + """ var yes = "yes"; var no = "no"; var blogs = await context.Blogs.Select(b => b.Id == 3 ? yes : no).ToListAsync(); @@ -1091,7 +1099,8 @@ public virtual Task Two_captured_variables_in_same_lambda() [ConditionalFact] public virtual Task Two_captured_variables_in_different_lambdas() - => Test(""" + => Test( + """ var starts = "blog"; var ends = "2"; var blog = await context.Blogs.Where(b => b.Name.StartsWith(starts)).Where(b => b.Name.EndsWith(ends)).SingleAsync(); @@ -1100,14 +1109,16 @@ public virtual Task Two_captured_variables_in_different_lambdas() [ConditionalFact] public virtual Task Same_captured_variable_twice_in_same_lambda() - => Test(""" + => Test( + """ var foo = "X"; var blogs = await context.Blogs.Where(b => b.Name.StartsWith(foo) && b.Name.EndsWith(foo)).ToListAsync(); """); [ConditionalFact] public virtual Task Same_captured_variable_twice_in_different_lambdas() - => Test(""" + => Test( + """ var foo = "X"; var blogs = await context.Blogs.Where(b => b.Name.StartsWith(foo)).Where(b => b.Name.EndsWith(foo)).ToListAsync(); """); @@ -1126,7 +1137,8 @@ public virtual Task Final_GroupBy() [ConditionalFact] public virtual Task Multiple_queries_with_captured_variables() - => Test(""" + => Test( + """ var id1 = 8; var id2 = 9; var blogs = await context.Blogs.Where(b => b.Id == id1 || b.Id == id2).ToListAsync(); @@ -1140,11 +1152,13 @@ public virtual Task Multiple_queries_with_captured_variables() [ConditionalFact] public virtual Task Unsafe_accessor_gets_generated_once_for_multiple_queries() - => Test(""" + => Test( + """ var blogs1 = await context.Blogs.ToListAsync(); var blogs2 = await context.Blogs.ToListAsync(); """, - interceptorCodeAsserter: code => Assert.Equal(2, code.Split("private static extern ref int UnsafeAccessor_Microsoft_EntityFrameworkCore_Query_Blog_Id_Set").Length)); + interceptorCodeAsserter: code => Assert.Equal( + 2, code.Split("private static extern ref int UnsafeAccessor_Microsoft_EntityFrameworkCore_Query_Blog_Id_Set").Length)); public class PrecompiledQueryContext(DbContextOptions options) : DbContext(options) { @@ -1181,7 +1195,8 @@ protected virtual Task Test( """ await using var context = new PrecompiledQueryContext(dbContextOptions); -""" + sourceCode, +""" + + sourceCode, Fixture.ServiceProvider.GetRequiredService(), typeof(PrecompiledQueryContext), interceptorCodeAsserter, @@ -1225,6 +1240,7 @@ public Blog(int id, string name) [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } + public string? Name { get; set; } public List Posts { get; set; } = new(); public List Json { get; set; } = new(); diff --git a/test/EFCore.Relational.Specification.Tests/Query/PrecompiledSqlPregenerationQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/PrecompiledSqlPregenerationQueryRelationalTestBase.cs index 77ffb7c372e..c8aa95c7438 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/PrecompiledSqlPregenerationQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/PrecompiledSqlPregenerationQueryRelationalTestBase.cs @@ -15,7 +15,9 @@ namespace Microsoft.EntityFrameworkCore.Query; /// public class PrecompiledSqlPregenerationQueryRelationalTestBase { - public PrecompiledSqlPregenerationQueryRelationalTestBase(PrecompiledSqlPregenerationQueryRelationalFixture fixture, ITestOutputHelper testOutputHelper) + public PrecompiledSqlPregenerationQueryRelationalTestBase( + PrecompiledSqlPregenerationQueryRelationalFixture fixture, + ITestOutputHelper testOutputHelper) { Fixture = fixture; TestOutputHelper = testOutputHelper; @@ -301,6 +303,7 @@ public Blog(int id, string name) [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } + public string? Name { get; set; } public List Posts { get; set; } = new(); diff --git a/test/EFCore.Relational.Specification.Tests/Query/SqlExecutorTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/SqlExecutorTestBase.cs index 89b17be23d5..863c60d3147 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/SqlExecutorTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/SqlExecutorTestBase.cs @@ -324,9 +324,7 @@ protected NorthwindContext CreateContext() public class SqlExecutorModelCustomizer : NoopModelCustomizer { public override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) - { - configurationBuilder.DefaultTypeMapping().HasConversion(); - } + => configurationBuilder.DefaultTypeMapping().HasConversion(); private sealed class CityToStringConverter() : ValueConverter(value => value.Name, value => new City { Name = value }); } diff --git a/test/EFCore.Relational.Specification.Tests/Query/SqlQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/SqlQueryTestBase.cs index 9af9bb1a2df..ef897e5014e 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/SqlQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/SqlQueryTestBase.cs @@ -19,9 +19,7 @@ public abstract class SqlQueryTestBase : QueryTestBase protected SqlQueryTestBase(TFixture fixture) : base(fixture) - { - Fixture.TestSqlLoggerFactory.Clear(); - } + => Fixture.TestSqlLoggerFactory.Clear(); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -818,7 +816,8 @@ public virtual Task SqlQueryRaw_composed_with_predicate(bool async) _ => Fixture.CreateContext().Database.SqlQueryRaw( NormalizeDelimitersInRawString("SELECT * FROM [Customers]")) .Where(c => c.ContactName.Substring(0, 1) == c.CompanyName.Substring(0, 1)), - ss => ss.Set().Where(c => c.ContactName.Substring(0, 1) == c.CompanyName.Substring(0, 1)).Select(e => UnmappedCustomer.FromCustomer(e)), + ss => ss.Set().Where(c => c.ContactName.Substring(0, 1) == c.CompanyName.Substring(0, 1)) + .Select(e => UnmappedCustomer.FromCustomer(e)), elementSorter: e => e.CustomerID, elementAsserter: AssertUnmappedCustomers); diff --git a/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs index e7a8bd7b4a1..5b9204a952f 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs @@ -388,7 +388,7 @@ protected override async Task SeedAsync(DbContext context) { Name = "Order11", OrderDate = new DateTime(2000, 1, 20), - Items = [new() { Quantity = 5, Product = product1 }, new() { Quantity = 15, Product = product3 }] + Items = [new LineItem { Quantity = 5, Product = product1 }, new LineItem { Quantity = 15, Product = product3 }] }; var order12 = new Order @@ -397,9 +397,9 @@ protected override async Task SeedAsync(DbContext context) OrderDate = new DateTime(2000, 2, 21), Items = [ - new() { Quantity = 1, Product = product1 }, - new() { Quantity = 6, Product = product2 }, - new() { Quantity = 200, Product = product3 } + new LineItem { Quantity = 1, Product = product1 }, + new LineItem { Quantity = 6, Product = product2 }, + new LineItem { Quantity = 200, Product = product3 } ] }; @@ -407,7 +407,7 @@ protected override async Task SeedAsync(DbContext context) { Name = "Order13", OrderDate = new DateTime(2001, 3, 20), - Items = [new() { Quantity = 50, Product = product4 }] + Items = [new LineItem { Quantity = 50, Product = product4 }] }; var order21 = new Order @@ -416,9 +416,9 @@ protected override async Task SeedAsync(DbContext context) OrderDate = new DateTime(2000, 4, 21), Items = [ - new() { Quantity = 1, Product = product1 }, - new() { Quantity = 34, Product = product4 }, - new() { Quantity = 100, Product = product5 } + new LineItem { Quantity = 1, Product = product1 }, + new LineItem { Quantity = 34, Product = product4 }, + new LineItem { Quantity = 100, Product = product5 } ] }; @@ -426,14 +426,14 @@ protected override async Task SeedAsync(DbContext context) { Name = "Order22", OrderDate = new DateTime(2000, 5, 20), - Items = [new() { Quantity = 34, Product = product3 }, new() { Quantity = 100, Product = product4 }] + Items = [new LineItem { Quantity = 34, Product = product3 }, new LineItem { Quantity = 100, Product = product4 }] }; var order31 = new Order { Name = "Order31", OrderDate = new DateTime(2001, 6, 21), - Items = [new() { Quantity = 5, Product = product5 }] + Items = [new LineItem { Quantity = 5, Product = product5 }] }; var address11 = new Address @@ -1153,8 +1153,7 @@ public virtual void Scalar_Function_Anonymous_Type_Select_Nested_Instance() where c.Id == customerId select new { - c.LastName, - OrderCount = context.StarValueInstance(starCount, context.CustomerOrderCountInstance(customerId)) + c.LastName, OrderCount = context.StarValueInstance(starCount, context.CustomerOrderCountInstance(customerId)) }).Single(); Assert.Equal("Three", cust.LastName); @@ -1588,8 +1587,7 @@ public virtual void QF_Select_Direct_In_Anonymous() () => (from c in context.Customers select new { - c.Id, - Prods = context.GetTopTwoSellingProducts().ToList(), + c.Id, Prods = context.GetTopTwoSellingProducts().ToList(), }).ToList()).Message; Assert.Equal(RelationalStrings.InsufficientInformationToIdentifyElementOfCollectionJoin, message); @@ -1604,8 +1602,7 @@ public virtual void QF_Select_Direct_In_Anonymous_distinct() var query = (from c in context.Customers select new { - c.Id, - Prods = context.GetTopTwoSellingProducts().Distinct().ToList(), + c.Id, Prods = context.GetTopTwoSellingProducts().Distinct().ToList(), }).ToList(); } } @@ -1732,8 +1729,7 @@ public virtual void QF_Select_NonCorrelated_Subquery_In_Anonymous() () => (from c in context.Customers select new { - c.Id, - Prods = context.GetTopTwoSellingProducts().Select(p => p.ProductId).ToList(), + c.Id, Prods = context.GetTopTwoSellingProducts().Select(p => p.ProductId).ToList(), }).ToList()).Message; Assert.Equal(RelationalStrings.InsufficientInformationToIdentifyElementOfCollectionJoin, message); diff --git a/test/EFCore.Relational.Specification.Tests/RelationalComplianceTestBase.cs b/test/EFCore.Relational.Specification.Tests/RelationalComplianceTestBase.cs index cedb1c82835..641018ea791 100644 --- a/test/EFCore.Relational.Specification.Tests/RelationalComplianceTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/RelationalComplianceTestBase.cs @@ -25,6 +25,7 @@ public virtual void All_query_test_fixtures_must_implement_ITestSqlLoggerFactory Assert.False( queryFixturesWithoutTestSqlLogger.Count > 0, - "\r\n-- Missing ITestSqlLoggerFactory implementation for relational QueryFixtures --\r\n" + string.Join(Environment.NewLine, queryFixturesWithoutTestSqlLogger)); + "\r\n-- Missing ITestSqlLoggerFactory implementation for relational QueryFixtures --\r\n" + + string.Join(Environment.NewLine, queryFixturesWithoutTestSqlLogger)); } } diff --git a/test/EFCore.Relational.Specification.Tests/Scaffolding/CompiledModelRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Scaffolding/CompiledModelRelationalTestBase.cs index 68bc3153e19..789bf20c5e1 100644 --- a/test/EFCore.Relational.Specification.Tests/Scaffolding/CompiledModelRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Scaffolding/CompiledModelRelationalTestBase.cs @@ -432,26 +432,26 @@ protected override void BuildComplexTypesModel(ModelBuilder modelBuilder) [ConditionalFact] public override Task ComplexTypes() - => Test( - BuildComplexTypesModel, - AssertComplexTypes, - c => - { - // Sprocs not supported with complex types - //c.Set>>().Add( - // new PrincipalDerived> - // { - // Id = 1, - // AlternateId = new Guid(), - // Dependent = new DependentBase(1), - // Owned = new OwnedType(c) { Principal = new PrincipalBase() } - // }); - - //c.SaveChanges(); - - return Task.CompletedTask; - }, - options: new CompiledModelCodeGenerationOptions { UseNullableReferenceTypes = true, ForNativeAot = true }); + => Test( + BuildComplexTypesModel, + AssertComplexTypes, + c => + { + // Sprocs not supported with complex types + //c.Set>>().Add( + // new PrincipalDerived> + // { + // Id = 1, + // AlternateId = new Guid(), + // Dependent = new DependentBase(1), + // Owned = new OwnedType(c) { Principal = new PrincipalBase() } + // }); + + //c.SaveChanges(); + + return Task.CompletedTask; + }, + options: new CompiledModelCodeGenerationOptions { UseNullableReferenceTypes = true, ForNativeAot = true }); protected override void AssertComplexTypes(IModel model) { @@ -1290,7 +1290,8 @@ public virtual Task Dynamic_schema() }, additionalSourceFiles: [ - new("DbContextModelCustomizer.cs", + new ScaffoldedFile( + "DbContextModelCustomizer.cs", """ using Microsoft.EntityFrameworkCore.Metadata; diff --git a/test/EFCore.Relational.Specification.Tests/TestModels/EntitySplitting/EntitySplittingData.cs b/test/EFCore.Relational.Specification.Tests/TestModels/EntitySplitting/EntitySplittingData.cs index 24d0458b431..8028248a056 100644 --- a/test/EFCore.Relational.Specification.Tests/TestModels/EntitySplitting/EntitySplittingData.cs +++ b/test/EFCore.Relational.Specification.Tests/TestModels/EntitySplitting/EntitySplittingData.cs @@ -68,7 +68,7 @@ public IQueryable Set() private static EntityOne[] CreateEntityOnes() => [ - new() + new EntityOne { Id = 1, IntValue1 = 11, @@ -80,7 +80,7 @@ private static EntityOne[] CreateEntityOnes() StringValue3 = "V13", StringValue4 = "V14" }, - new() + new EntityOne { Id = 2, IntValue1 = 21, @@ -92,7 +92,7 @@ private static EntityOne[] CreateEntityOnes() StringValue3 = "V23", StringValue4 = "V24" }, - new() + new EntityOne { Id = 3, IntValue1 = 31, @@ -104,7 +104,7 @@ private static EntityOne[] CreateEntityOnes() StringValue3 = "V33", StringValue4 = "V34" }, - new() + new EntityOne { Id = 4, IntValue1 = 41, @@ -116,7 +116,7 @@ private static EntityOne[] CreateEntityOnes() StringValue3 = "V43", StringValue4 = "V44" }, - new() + new EntityOne { Id = 5, IntValue1 = 51, @@ -133,27 +133,27 @@ private static EntityOne[] CreateEntityOnes() private static EntityTwo[] CreateEntityTwos() => [ - new() { Id = 1, Name = "Two1" }, - new() { Id = 2, Name = "Two2" }, - new() { Id = 3, Name = "Two3" }, - new() { Id = 4, Name = "Two4" }, - new() { Id = 5, Name = "Two5" } + new EntityTwo { Id = 1, Name = "Two1" }, + new EntityTwo { Id = 2, Name = "Two2" }, + new EntityTwo { Id = 3, Name = "Two3" }, + new EntityTwo { Id = 4, Name = "Two4" }, + new EntityTwo { Id = 5, Name = "Two5" } ]; private static EntityThree[] CreateEntityThrees() => [ - new() { Id = 1, Name = "Three1" }, - new() { Id = 2, Name = "Three2" }, - new() { Id = 3, Name = "Three3" }, - new() { Id = 4, Name = "Three4" }, - new() { Id = 5, Name = "Three5" } + new EntityThree { Id = 1, Name = "Three1" }, + new EntityThree { Id = 2, Name = "Three2" }, + new EntityThree { Id = 3, Name = "Three3" }, + new EntityThree { Id = 4, Name = "Three4" }, + new EntityThree { Id = 5, Name = "Three5" } ]; private static BaseEntity[] CreateHierarchyEntities() => [ - new() { Id = 1, BaseValue = 1 }, + new BaseEntity { Id = 1, BaseValue = 1 }, new MiddleEntity { Id = 2, diff --git a/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityBase.cs b/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityBase.cs index 7355e11a290..74f0240cf6f 100644 --- a/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityBase.cs +++ b/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityBase.cs @@ -3,8 +3,6 @@ namespace Microsoft.EntityFrameworkCore.TestModels.Operators; -#nullable disable - public abstract class OperatorEntityBase { public int Id { get; set; } diff --git a/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityBool.cs b/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityBool.cs index a3b95c6fea6..09fb32b1ddf 100644 --- a/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityBool.cs +++ b/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityBool.cs @@ -3,8 +3,6 @@ namespace Microsoft.EntityFrameworkCore.TestModels.Operators; -#nullable disable - public class OperatorEntityBool : OperatorEntityBase { public bool Value { get; set; } diff --git a/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityInt.cs b/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityInt.cs index 1be70a9c8af..f55285e8835 100644 --- a/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityInt.cs +++ b/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityInt.cs @@ -3,8 +3,6 @@ namespace Microsoft.EntityFrameworkCore.TestModels.Operators; -#nullable disable - public class OperatorEntityInt : OperatorEntityBase { public int Value { get; set; } diff --git a/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityLong.cs b/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityLong.cs index eb7ab473efc..f8cc75b9a6a 100644 --- a/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityLong.cs +++ b/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityLong.cs @@ -3,8 +3,6 @@ namespace Microsoft.EntityFrameworkCore.TestModels.Operators; -#nullable disable - public class OperatorEntityLong : OperatorEntityBase { public long Value { get; set; } diff --git a/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityNullableBool.cs b/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityNullableBool.cs index f9e861b0694..34de2843f8a 100644 --- a/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityNullableBool.cs +++ b/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityNullableBool.cs @@ -3,8 +3,6 @@ namespace Microsoft.EntityFrameworkCore.TestModels.Operators; -#nullable disable - public class OperatorEntityNullableBool : OperatorEntityBase { public bool? Value { get; set; } diff --git a/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityNullableInt.cs b/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityNullableInt.cs index 0f873721670..2496af6310c 100644 --- a/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityNullableInt.cs +++ b/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorEntityNullableInt.cs @@ -3,8 +3,6 @@ namespace Microsoft.EntityFrameworkCore.TestModels.Operators; -#nullable disable - public class OperatorEntityNullableInt : OperatorEntityBase { public int? Value { get; set; } diff --git a/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorsData.cs b/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorsData.cs index 5a898e2442d..d74349f97b2 100644 --- a/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorsData.cs +++ b/test/EFCore.Relational.Specification.Tests/TestModels/Operators/OperatorsData.cs @@ -56,7 +56,7 @@ public class OperatorsData : ISetSource () => new DateTimeOffset(new DateTime(2000, 1, 1, 9, 0, 0), new TimeSpan(13, 0, 0)) ]; - private readonly List>> _nullableDateTimeOffsetValues = + private readonly List>> _nullableDateTimeOffsetValues = [ () => null, () => new DateTimeOffset(new DateTime(2000, 1, 1, 10, 0, 0), new TimeSpan(-8, 0, 0)), @@ -168,6 +168,7 @@ public IReadOnlyList CreateDateTimeOffsets() .Select((x, i) => new OperatorEntityDateTimeOffset { Id = i + 1, Value = _dateTimeOffsetValues[i].Compile()() }).ToList(); public IReadOnlyList CreateNullableDateTimeOffsets() - => _nullableDateTimeOffsetValues.Select((x, i) => new OperatorEntityNullableDateTimeOffset { Id = i + 1, Value = _nullableDateTimeOffsetValues[i].Compile()() }) + => _nullableDateTimeOffsetValues.Select( + (x, i) => new OperatorEntityNullableDateTimeOffset { Id = i + 1, Value = _nullableDateTimeOffsetValues[i].Compile()() }) .ToList(); } diff --git a/test/EFCore.Relational.Specification.Tests/TestModels/OptionalDependent/OptionalDependentData.cs b/test/EFCore.Relational.Specification.Tests/TestModels/OptionalDependent/OptionalDependentData.cs index b3c20d391fb..dbb0f3fc553 100644 --- a/test/EFCore.Relational.Specification.Tests/TestModels/OptionalDependent/OptionalDependentData.cs +++ b/test/EFCore.Relational.Specification.Tests/TestModels/OptionalDependent/OptionalDependentData.cs @@ -21,7 +21,13 @@ public static IReadOnlyList CreateEntitiesAl OpProp1 = "1", OpProp2 = 1, OpNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "11", OpNested2 = 11 }, - OpNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(2001, 1, 1), OpNested1 = "1001", OpNested2 = 1001 } + OpNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(2001, 1, 1), + OpNested1 = "1001", + OpNested2 = 1001 + } } }; @@ -34,7 +40,13 @@ public static IReadOnlyList CreateEntitiesAl OpProp1 = "2", OpProp2 = 2, OpNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = null, OpNested2 = 21 }, - OpNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(2002, 1, 1), OpNested1 = "2001", OpNested2 = 2001 } + OpNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(2002, 1, 1), + OpNested1 = "2001", + OpNested2 = 2001 + } } }; @@ -47,7 +59,13 @@ public static IReadOnlyList CreateEntitiesAl OpProp1 = "3", OpProp2 = 3, OpNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = null, OpNested2 = null }, - OpNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(2003, 1, 1), OpNested1 = "3001", OpNested2 = 3001 } + OpNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(2003, 1, 1), + OpNested1 = "3001", + OpNested2 = 3001 + } } }; @@ -60,7 +78,13 @@ public static IReadOnlyList CreateEntitiesAl OpProp1 = "4", OpProp2 = 4, OpNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = null, OpNested2 = 41 }, - OpNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(2004, 1, 1), OpNested1 = null, OpNested2 = 4001 } + OpNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(2004, 1, 1), + OpNested1 = null, + OpNested2 = 4001 + } } }; @@ -73,7 +97,13 @@ public static IReadOnlyList CreateEntitiesAl OpProp1 = "5", OpProp2 = 5, OpNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = null, OpNested2 = 51 }, - OpNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(2005, 1, 1), OpNested1 = null, OpNested2 = null } + OpNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(2005, 1, 1), + OpNested1 = null, + OpNested2 = null + } } }; @@ -86,7 +116,13 @@ public static IReadOnlyList CreateEntitiesAl OpProp1 = "6", OpProp2 = 6, OpNav1 = null, - OpNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(2005, 1, 1), OpNested1 = null, OpNested2 = 6001 } + OpNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(2005, 1, 1), + OpNested1 = null, + OpNested2 = 6001 + } } }; @@ -162,7 +198,21 @@ public static IReadOnlyList CreateEntitiesAl Json = null }; - return new List { e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12 }; + return new List + { + e1, + e2, + e3, + e4, + e5, + e6, + e7, + e8, + e9, + e10, + e11, + e12 + }; } public static IReadOnlyList CreateEntitiesSomeRequired() @@ -176,12 +226,22 @@ public static IReadOnlyList CreateEntitiesS ReqProp = 1.5, OpProp1 = "1", OpProp2 = 1, - ReqNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "11", OpNested2 = 11 }, - ReqNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(4001, 1, 1), OpNested1 = "12", OpNested2 = 12 }, - + ReqNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(4001, 1, 1), + OpNested1 = "12", + OpNested2 = 12 + }, OpNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "13", OpNested2 = 13 }, - OpNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = false, ReqNested2 = new DateTime(5001, 1, 1), OpNested1 = "14", OpNested2 = 14 } + OpNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = false, + ReqNested2 = new DateTime(5001, 1, 1), + OpNested1 = "14", + OpNested2 = 14 + } } }; @@ -194,12 +254,22 @@ public static IReadOnlyList CreateEntitiesS ReqProp = 2.5, OpProp1 = "2", OpProp2 = 2, - ReqNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = null, OpNested2 = 21 }, - ReqNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(4002, 1, 1), OpNested1 = "22", OpNested2 = 22 }, - + ReqNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(4002, 1, 1), + OpNested1 = "22", + OpNested2 = 22 + }, OpNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "23", OpNested2 = 23 }, - OpNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = false, ReqNested2 = new DateTime(5002, 1, 1), OpNested1 = "24", OpNested2 = 24 } + OpNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = false, + ReqNested2 = new DateTime(5002, 1, 1), + OpNested1 = "24", + OpNested2 = 24 + } } }; @@ -212,12 +282,22 @@ public static IReadOnlyList CreateEntitiesS ReqProp = 3.5, OpProp1 = "3", OpProp2 = 3, - ReqNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = null, OpNested2 = null }, - ReqNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(4003, 1, 1), OpNested1 = "32", OpNested2 = 32 }, - + ReqNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(4003, 1, 1), + OpNested1 = "32", + OpNested2 = 32 + }, OpNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "33", OpNested2 = 33 }, - OpNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = false, ReqNested2 = new DateTime(5003, 1, 1), OpNested1 = "34", OpNested2 = 34 } + OpNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = false, + ReqNested2 = new DateTime(5003, 1, 1), + OpNested1 = "34", + OpNested2 = 34 + } } }; @@ -230,12 +310,22 @@ public static IReadOnlyList CreateEntitiesS ReqProp = 4.5, OpProp1 = "4", OpProp2 = 4, - ReqNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "41", OpNested2 = 41 }, - ReqNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(4004, 1, 1), OpNested1 = null, OpNested2 = null }, - + ReqNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(4004, 1, 1), + OpNested1 = null, + OpNested2 = null + }, OpNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "43", OpNested2 = 43 }, - OpNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = false, ReqNested2 = new DateTime(5004, 1, 1), OpNested1 = "44", OpNested2 = 44 } + OpNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = false, + ReqNested2 = new DateTime(5004, 1, 1), + OpNested1 = "44", + OpNested2 = 44 + } } }; @@ -248,12 +338,22 @@ public static IReadOnlyList CreateEntitiesS ReqProp = 5.5, OpProp1 = "5", OpProp2 = 5, - ReqNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "51", OpNested2 = 51 }, - ReqNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(4005, 1, 1), OpNested1 = "52", OpNested2 = 52 }, - + ReqNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(4005, 1, 1), + OpNested1 = "52", + OpNested2 = 52 + }, OpNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = null, OpNested2 = null }, - OpNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = false, ReqNested2 = new DateTime(5005, 1, 1), OpNested1 = "54", OpNested2 = 54 } + OpNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = false, + ReqNested2 = new DateTime(5005, 1, 1), + OpNested1 = "54", + OpNested2 = 54 + } } }; @@ -266,12 +366,22 @@ public static IReadOnlyList CreateEntitiesS ReqProp = 6.5, OpProp1 = "6", OpProp2 = 6, - ReqNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "61", OpNested2 = 61 }, - ReqNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(4006, 1, 1), OpNested1 = "62", OpNested2 = 62 }, - + ReqNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(4006, 1, 1), + OpNested1 = "62", + OpNested2 = 62 + }, OpNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "63", OpNested2 = 63 }, - OpNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = false, ReqNested2 = new DateTime(5006, 1, 1), OpNested1 = null, OpNested2 = null } + OpNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = false, + ReqNested2 = new DateTime(5006, 1, 1), + OpNested1 = null, + OpNested2 = null + } } }; @@ -284,12 +394,22 @@ public static IReadOnlyList CreateEntitiesS ReqProp = 7.5, OpProp1 = "7", OpProp2 = 7, - ReqNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "71", OpNested2 = 71 }, - ReqNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(4007, 1, 1), OpNested1 = "72", OpNested2 = 72 }, - + ReqNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(4007, 1, 1), + OpNested1 = "72", + OpNested2 = 72 + }, OpNav1 = null, - OpNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = false, ReqNested2 = new DateTime(5007, 1, 1), OpNested1 = "74", OpNested2 = 74 } + OpNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = false, + ReqNested2 = new DateTime(5007, 1, 1), + OpNested1 = "74", + OpNested2 = 74 + } } }; @@ -302,10 +422,14 @@ public static IReadOnlyList CreateEntitiesS ReqProp = 8.5, OpProp1 = "8", OpProp2 = 8, - ReqNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "81", OpNested2 = 81 }, - ReqNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(4008, 1, 1), OpNested1 = "82", OpNested2 = 82 }, - + ReqNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(4008, 1, 1), + OpNested1 = "82", + OpNested2 = 82 + }, OpNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "83", OpNested2 = 83 }, OpNav2 = null } @@ -320,10 +444,14 @@ public static IReadOnlyList CreateEntitiesS ReqProp = 9.5, OpProp1 = "9", OpProp2 = 9, - ReqNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "91", OpNested2 = 91 }, - ReqNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(4009, 1, 1), OpNested1 = "92", OpNested2 = 92 }, - + ReqNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(4009, 1, 1), + OpNested1 = "92", + OpNested2 = 92 + }, OpNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = null, OpNested2 = null }, OpNav2 = null } @@ -338,10 +466,14 @@ public static IReadOnlyList CreateEntitiesS ReqProp = 10.5, OpProp1 = "10", OpProp2 = 10, - ReqNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "101", OpNested2 = 101 }, - ReqNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(4010, 1, 1), OpNested1 = "102", OpNested2 = 102 }, - + ReqNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(4010, 1, 1), + OpNested1 = "102", + OpNested2 = 102 + }, OpNav1 = null, OpNav2 = null } @@ -356,10 +488,14 @@ public static IReadOnlyList CreateEntitiesS ReqProp = 11.5, OpProp1 = null, OpProp2 = null, - ReqNav1 = new OptionalDependentNestedJsonAllOptional { OpNested1 = "111", OpNested2 = 111 }, - ReqNav2 = new OptionalDependentNestedJsonSomeRequired { ReqNested1 = true, ReqNested2 = new DateTime(4011, 1, 1), OpNested1 = "112", OpNested2 = 112 }, - + ReqNav2 = new OptionalDependentNestedJsonSomeRequired + { + ReqNested1 = true, + ReqNested2 = new DateTime(4011, 1, 1), + OpNested1 = "112", + OpNested2 = 112 + }, OpNav1 = null, OpNav2 = null } @@ -372,7 +508,21 @@ public static IReadOnlyList CreateEntitiesS Json = null }; - return new List { e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12 }; + return new List + { + e1, + e2, + e3, + e4, + e5, + e6, + e7, + e8, + e9, + e10, + e11, + e12 + }; } public IQueryable Set() diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/PrecompiledQueryTestHelpers.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/PrecompiledQueryTestHelpers.cs index 2e8c217efe7..fdb1044e622 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/PrecompiledQueryTestHelpers.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/PrecompiledQueryTestHelpers.cs @@ -82,9 +82,9 @@ public async Task FullSourceTest( // This turns on the interceptors feature for the designated namespace(s). var parseOptions = new CSharpParseOptions().WithFeatures( - [ - new KeyValuePair("InterceptorsPreviewNamespaces", "Microsoft.EntityFrameworkCore.GeneratedInterceptors") - ]); + [ + new KeyValuePair("InterceptorsPreviewNamespaces", "Microsoft.EntityFrameworkCore.GeneratedInterceptors") + ]); var syntaxTree = CSharpSyntaxTree.ParseText(source, parseOptions, path: "Test.cs"); @@ -113,7 +113,8 @@ public async Task FullSourceTest( // Perform precompilation var precompilationErrors = new List(); generatedFiles = precompiledQueryCodeGenerator.GeneratePrecompiledQueries( - compilation, syntaxGenerator, dbContext, memberAccessReplacements: new Dictionary(), precompilationErrors, new HashSet(), additionalAssembly: assembly); + compilation, syntaxGenerator, dbContext, memberAccessReplacements: new Dictionary(), + precompilationErrors, new HashSet(), additionalAssembly: assembly); if (errorAsserter is null) { @@ -277,7 +278,8 @@ public class NonCompilingQueryCompiler( ICurrentDbContext currentContext, IEvaluatableExpressionFilter evaluatableExpressionFilter, IModel model) - : QueryCompiler(queryContextFactory, compiledQueryCache, compiledQueryCacheKeyGenerator, database, logger, + : QueryCompiler( + queryContextFactory, compiledQueryCache, compiledQueryCacheKeyGenerator, database, logger, currentContext, evaluatableExpressionFilter, model) { public const string ErrorMessage = diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalModelAsserter.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalModelAsserter.cs index d096745b403..92f20aac4f6 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalModelAsserter.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalModelAsserter.cs @@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities; public class RelationalModelAsserter : ModelAsserter { - public new static RelationalModelAsserter Instance { get; } = new(); + public static new RelationalModelAsserter Instance { get; } = new(); public override void AssertEqual( IReadOnlyModel expected, @@ -38,7 +38,8 @@ public override void AssertEqual( Assert.Equal(expected.GetCollation(), actual.GetCollation()); } }, - () => Assert.Equal(expected.GetDbFunctions().Select(x => x), + () => Assert.Equal( + expected.GetDbFunctions().Select(x => x), actual.GetDbFunctions(), (expected, actual) => AssertEqual( @@ -47,7 +48,8 @@ public override void AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.GetSequences().Select(x => x), + () => Assert.Equal( + expected.GetSequences().Select(x => x), actual.GetSequences(), (expected, actual) => AssertEqual( @@ -95,7 +97,8 @@ public virtual bool AssertEqual( () => Assert.Equal(expected.MethodInfo, actual.MethodInfo), () => Assert.Equal(expected.Translation, actual.Translation), () => Assert.Equal(expected.TypeMapping?.StoreType, actual.TypeMapping?.StoreType), - () => Assert.Equal(expected.Parameters.Select(x => x), + () => Assert.Equal( + expected.Parameters.Select(x => x), actual.Parameters, (expected, actual) => AssertEqual( @@ -108,8 +111,9 @@ public virtual bool AssertEqual( { if (isFinalized) { - Assert.Equal(((IRuntimeDbFunction)expected).StoreFunction.SchemaQualifiedName, - ((IRuntimeDbFunction)actual).StoreFunction.SchemaQualifiedName); + Assert.Equal( + ((IRuntimeDbFunction)expected).StoreFunction.SchemaQualifiedName, + ((IRuntimeDbFunction)actual).StoreFunction.SchemaQualifiedName); } }, () => Assert.Equal(expectedAnnotations, actualAnnotations, TestAnnotationComparer.Instance)); @@ -143,8 +147,9 @@ public virtual bool AssertEqual( { if (isFinalized) { - Assert.Equal(((IRuntimeDbFunctionParameter)expected).StoreFunctionParameter.Name, - ((IRuntimeDbFunctionParameter)actual).StoreFunctionParameter.Name); + Assert.Equal( + ((IRuntimeDbFunctionParameter)expected).StoreFunctionParameter.Name, + ((IRuntimeDbFunctionParameter)actual).StoreFunctionParameter.Name); } }, () => Assert.Equal(expectedAnnotations, actualAnnotations, TestAnnotationComparer.Instance)); @@ -240,7 +245,8 @@ public override bool AssertEqual( actual.GetDeleteStoredProcedure(), compareBackreferences: false, compareMemberAnnotations), - () => Assert.Equal(expected.GetMappingFragments().Select(x => x), + () => Assert.Equal( + expected.GetMappingFragments().Select(x => x), actual.GetMappingFragments(), (expected, actual) => AssertEqual( @@ -253,7 +259,8 @@ public override bool AssertEqual( { if (designTime) { - Assert.Equal(expected.GetCheckConstraints().Select(x => x), + Assert.Equal( + expected.GetCheckConstraints().Select(x => x), actual.GetCheckConstraints(), (expected, actual) => AssertEqual( @@ -268,46 +275,54 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetDefaultMappings().Select(x => x), + Assert.Equal( + expectedStructuralType.GetDefaultMappings().Select(x => x), actualStructuralType.GetDefaultMappings(), (expected, actual) => - { - Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); return true; - }); + { + Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); + return true; + }); } }, () => { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetTableMappings().Select(x => x), + Assert.Equal( + expectedStructuralType.GetTableMappings().Select(x => x), actualStructuralType.GetTableMappings(), (expected, actual) => - { - Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); return true; - }); + { + Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); + return true; + }); } }, () => { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetViewMappings().Select(x => x), + Assert.Equal( + expectedStructuralType.GetViewMappings().Select(x => x), actualStructuralType.GetViewMappings(), (expected, actual) => - { - Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); return true; - }); + { + Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); + return true; + }); } }, () => { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetSqlQueryMappings().Select(x => x), + Assert.Equal( + expectedStructuralType.GetSqlQueryMappings().Select(x => x), actualStructuralType.GetSqlQueryMappings(), (expected, actual) => { - Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); return true; + Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); + return true; }); } }, @@ -315,10 +330,12 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetFunctionMappings().Select(x => x), + Assert.Equal( + expectedStructuralType.GetFunctionMappings().Select(x => x), actualStructuralType.GetFunctionMappings(), (expected, actual) => { - Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); return true; + Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); + return true; }); } }, @@ -326,10 +343,12 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetInsertStoredProcedureMappings().Select(x => x), + Assert.Equal( + expectedStructuralType.GetInsertStoredProcedureMappings().Select(x => x), actualStructuralType.GetInsertStoredProcedureMappings(), (expected, actual) => { - Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); return true; + Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); + return true; }); } }, @@ -337,11 +356,13 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetUpdateStoredProcedureMappings().Select(x => x), + Assert.Equal( + expectedStructuralType.GetUpdateStoredProcedureMappings().Select(x => x), actualStructuralType.GetUpdateStoredProcedureMappings(), (expected, actual) => { - Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); return true; + Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); + return true; }); } }, @@ -349,11 +370,13 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetDeleteStoredProcedureMappings().Select(x => x), + Assert.Equal( + expectedStructuralType.GetDeleteStoredProcedureMappings().Select(x => x), actualStructuralType.GetDeleteStoredProcedureMappings(), (expected, actual) => { - Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); return true; + Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); + return true; }); } }); @@ -412,7 +435,8 @@ public virtual bool AssertEqual( Assert.Equal(expected.EntityType, actual.EntityType, EntityTypeFullNameComparer.Instance); } }, - () => Assert.Equal(expected.Parameters.Select(x => x), actual.Parameters, + () => Assert.Equal( + expected.Parameters.Select(x => x), actual.Parameters, (expected, actual) => AssertEqual( expected, @@ -421,7 +445,8 @@ public virtual bool AssertEqual( compareAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareBackreferences: false, compareAnnotations)), - () => Assert.Equal(expected.ResultColumns.Select(x => x), actual.ResultColumns, + () => Assert.Equal( + expected.ResultColumns.Select(x => x), actual.ResultColumns, (expected, actual) => AssertEqual( expected, @@ -430,7 +455,8 @@ public virtual bool AssertEqual( compareAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareBackreferences: false, compareAnnotations)), - () => Assert.Equal(((IRuntimeStoredProcedure)expected).StoreStoredProcedure.SchemaQualifiedName, + () => Assert.Equal( + ((IRuntimeStoredProcedure)expected).StoreStoredProcedure.SchemaQualifiedName, ((IRuntimeStoredProcedure)actual).StoreStoredProcedure.SchemaQualifiedName), () => Assert.Equal(expectedAnnotations, actualAnnotations, TestAnnotationComparer.Instance)); @@ -458,7 +484,8 @@ public virtual bool AssertEqual( Assert.Equal(expected.StoredProcedure.Name, actual.StoredProcedure.Name); } }, - () => Assert.Equal(((IRuntimeStoredProcedureParameter)expected).StoreParameter.Name, + () => Assert.Equal( + ((IRuntimeStoredProcedureParameter)expected).StoreParameter.Name, ((IRuntimeStoredProcedureParameter)actual).StoreParameter.Name), () => Assert.Equal(expectedAnnotations, actualAnnotations, TestAnnotationComparer.Instance)); @@ -484,11 +511,11 @@ public virtual bool AssertEqual( Assert.Equal(expected.StoredProcedure.Name, actual.StoredProcedure.Name); } }, - () => Assert.Equal(((IRuntimeStoredProcedureResultColumn)expected).StoreResultColumn.Name, + () => Assert.Equal( + ((IRuntimeStoredProcedureResultColumn)expected).StoreResultColumn.Name, ((IRuntimeStoredProcedureResultColumn)actual).StoreResultColumn.Name), () => Assert.Equal(expectedAnnotations, actualAnnotations, TestAnnotationComparer.Instance)); - return true; } @@ -565,7 +592,8 @@ public override bool AssertEqual( actualStructuralType.GetDeleteStoredProcedure(), compareBackreferences: false, compareMemberAnnotations), - () => Assert.Equal(expectedStructuralType.GetMappingFragments().Select(x => x), + () => Assert.Equal( + expectedStructuralType.GetMappingFragments().Select(x => x), actualStructuralType.GetMappingFragments(), (expected, actual) => AssertEqual( @@ -578,7 +606,8 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetDefaultMappings().Select(x => x), + Assert.Equal( + expectedStructuralType.GetDefaultMappings().Select(x => x), actualStructuralType.GetDefaultMappings(), (expected, actual) => { @@ -591,7 +620,8 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetTableMappings().Select(x => x), + Assert.Equal( + expectedStructuralType.GetTableMappings().Select(x => x), actualStructuralType.GetTableMappings().Select(x => x), (expected, actual) => { @@ -604,11 +634,13 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetViewMappings().Select(x => x), + Assert.Equal( + expectedStructuralType.GetViewMappings().Select(x => x), actualStructuralType.GetViewMappings(), (expected, actual) => { - Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); return true; + Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); + return true; }); } }, @@ -616,11 +648,13 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetSqlQueryMappings().Select(x => x), + Assert.Equal( + expectedStructuralType.GetSqlQueryMappings().Select(x => x), actualStructuralType.GetSqlQueryMappings(), (expected, actual) => { - Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); return true; + Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); + return true; }); } }, @@ -628,11 +662,13 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetFunctionMappings().Select(x => x), + Assert.Equal( + expectedStructuralType.GetFunctionMappings().Select(x => x), actualStructuralType.GetFunctionMappings(), (expected, actual) => { - Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); return true; + Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); + return true; }); } }, @@ -640,10 +676,13 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetInsertStoredProcedureMappings().Select(x => x), actualStructuralType.GetInsertStoredProcedureMappings(), + Assert.Equal( + expectedStructuralType.GetInsertStoredProcedureMappings().Select(x => x), + actualStructuralType.GetInsertStoredProcedureMappings(), (expected, actual) => { - Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); return true; + Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); + return true; }); } }, @@ -651,11 +690,13 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetUpdateStoredProcedureMappings().Select(x => x), + Assert.Equal( + expectedStructuralType.GetUpdateStoredProcedureMappings().Select(x => x), actualStructuralType.GetUpdateStoredProcedureMappings(), (expected, actual) => { - Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); return true; + Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); + return true; }); } }, @@ -663,11 +704,13 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedStructuralType.GetDeleteStoredProcedureMappings().Select(x => x), + Assert.Equal( + expectedStructuralType.GetDeleteStoredProcedureMappings().Select(x => x), actualStructuralType.GetDeleteStoredProcedureMappings(), (expected, actual) => { - Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); return true; + Assert.Equal(expected.Table.SchemaQualifiedName, actual.Table.SchemaQualifiedName); + return true; }); } }); @@ -735,7 +778,8 @@ public override bool AssertEqual( Assert.Equal(expected.GetCollation(), actual.GetCollation()); } }, - () => Assert.Equal(expected.GetOverrides().Select(x => x), actual.GetOverrides().Select(x => x), + () => Assert.Equal( + expected.GetOverrides().Select(x => x), actual.GetOverrides().Select(x => x), (expected, actual) => AssertEqual( expected, @@ -746,7 +790,8 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedProperty.GetDefaultColumnMappings().Select(x => x), actualProperty.GetDefaultColumnMappings(), + Assert.Equal( + expectedProperty.GetDefaultColumnMappings().Select(x => x), actualProperty.GetDefaultColumnMappings(), (expected, actual) => { Assert.Equal(expected.Column.Table.SchemaQualifiedName, actual.Column.Table.SchemaQualifiedName); @@ -758,7 +803,8 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedProperty.GetTableColumnMappings().Select(x => x), actualProperty.GetTableColumnMappings(), + Assert.Equal( + expectedProperty.GetTableColumnMappings().Select(x => x), actualProperty.GetTableColumnMappings(), (expected, actual) => { Assert.Equal(expected.Column.Table.SchemaQualifiedName, actual.Column.Table.SchemaQualifiedName); @@ -770,7 +816,8 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedProperty.GetViewColumnMappings().Select(x => x), actualProperty.GetViewColumnMappings(), + Assert.Equal( + expectedProperty.GetViewColumnMappings().Select(x => x), actualProperty.GetViewColumnMappings(), (expected, actual) => { Assert.Equal(expected.Column.Table.SchemaQualifiedName, actual.Column.Table.SchemaQualifiedName); @@ -782,7 +829,9 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedProperty.GetSqlQueryColumnMappings().Select(x => x), actualProperty.GetSqlQueryColumnMappings(), (expected, actual) => + Assert.Equal( + expectedProperty.GetSqlQueryColumnMappings().Select(x => x), actualProperty.GetSqlQueryColumnMappings(), + (expected, actual) => { Assert.Equal(expected.Column.Table.SchemaQualifiedName, actual.Column.Table.SchemaQualifiedName); return true; @@ -793,7 +842,9 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedProperty.GetFunctionColumnMappings().Select(x => x), actualProperty.GetFunctionColumnMappings(), (expected, actual) => + Assert.Equal( + expectedProperty.GetFunctionColumnMappings().Select(x => x), actualProperty.GetFunctionColumnMappings(), + (expected, actual) => { Assert.Equal(expected.Column.Table.SchemaQualifiedName, actual.Column.Table.SchemaQualifiedName); return true; @@ -804,7 +855,9 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedProperty.GetInsertStoredProcedureParameterMappings().Select(x => x), actualProperty.GetInsertStoredProcedureParameterMappings(), (expected, actual) => + Assert.Equal( + expectedProperty.GetInsertStoredProcedureParameterMappings().Select(x => x), + actualProperty.GetInsertStoredProcedureParameterMappings(), (expected, actual) => { Assert.Equal(expected.Column.Table.SchemaQualifiedName, actual.Column.Table.SchemaQualifiedName); return true; @@ -815,7 +868,9 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedProperty.GetInsertStoredProcedureResultColumnMappings().Select(x => x), actualProperty.GetInsertStoredProcedureResultColumnMappings(), (expected, actual) => + Assert.Equal( + expectedProperty.GetInsertStoredProcedureResultColumnMappings().Select(x => x), + actualProperty.GetInsertStoredProcedureResultColumnMappings(), (expected, actual) => { Assert.Equal(expected.Column.Table.SchemaQualifiedName, actual.Column.Table.SchemaQualifiedName); return true; @@ -826,7 +881,9 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedProperty.GetUpdateStoredProcedureParameterMappings().Select(x => x), actualProperty.GetUpdateStoredProcedureParameterMappings(), (expected, actual) => + Assert.Equal( + expectedProperty.GetUpdateStoredProcedureParameterMappings().Select(x => x), + actualProperty.GetUpdateStoredProcedureParameterMappings(), (expected, actual) => { Assert.Equal(expected.Column.Table.SchemaQualifiedName, actual.Column.Table.SchemaQualifiedName); return true; @@ -837,7 +894,9 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedProperty.GetUpdateStoredProcedureResultColumnMappings().Select(x => x), actualProperty.GetUpdateStoredProcedureResultColumnMappings(), (expected, actual) => + Assert.Equal( + expectedProperty.GetUpdateStoredProcedureResultColumnMappings().Select(x => x), + actualProperty.GetUpdateStoredProcedureResultColumnMappings(), (expected, actual) => { Assert.Equal(expected.Column.Table.SchemaQualifiedName, actual.Column.Table.SchemaQualifiedName); return true; @@ -848,7 +907,9 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedProperty.GetDeleteStoredProcedureParameterMappings().Select(x => x), actualProperty.GetDeleteStoredProcedureParameterMappings(), (expected, actual) => + Assert.Equal( + expectedProperty.GetDeleteStoredProcedureParameterMappings().Select(x => x), + actualProperty.GetDeleteStoredProcedureParameterMappings(), (expected, actual) => { Assert.Equal(expected.Column.Table.SchemaQualifiedName, actual.Column.Table.SchemaQualifiedName); return true; @@ -907,7 +968,8 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedForeignKey.GetMappedConstraints().Select(x => x), + Assert.Equal( + expectedForeignKey.GetMappedConstraints().Select(x => x), actualForeignKey.GetMappedConstraints(), (expected, actual) => { @@ -951,7 +1013,8 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedIndex.GetMappedTableIndexes().Select(x => x), + Assert.Equal( + expectedIndex.GetMappedTableIndexes().Select(x => x), actualIndex.GetMappedTableIndexes(), (expected, actual) => { @@ -994,7 +1057,8 @@ public override bool AssertEqual( { if (isFinalized) { - Assert.Equal(expectedKey.GetMappedConstraints().Select(x => x), + Assert.Equal( + expectedKey.GetMappedConstraints().Select(x => x), actualKey.GetMappedConstraints(), (expected, actual) => { @@ -1042,7 +1106,8 @@ public virtual void AssertEqual( Assert.Equal(expected.Collation, actual.Collation); } }, - () => Assert.Equal(expectedModel.DefaultTables.Values.Select(x => x), actualModel.DefaultTables.Values, + () => Assert.Equal( + expectedModel.DefaultTables.Values.Select(x => x), actualModel.DefaultTables.Values, (expected, actual) => AssertEqual( expected, @@ -1050,7 +1115,8 @@ public virtual void AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.Tables.Select(x => x), actual.Tables, + () => Assert.Equal( + expected.Tables.Select(x => x), actual.Tables, (expected, actual) => AssertEqual( expected, @@ -1058,7 +1124,8 @@ public virtual void AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.Views.Select(x => x), actual.Views, + () => Assert.Equal( + expected.Views.Select(x => x), actual.Views, (expected, actual) => AssertEqual( expected, @@ -1066,7 +1133,8 @@ public virtual void AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.Queries.Select(x => x), actual.Queries, + () => Assert.Equal( + expected.Queries.Select(x => x), actual.Queries, (expected, actual) => AssertEqual( expected, @@ -1074,7 +1142,8 @@ public virtual void AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.Functions.Select(x => x), actual.Functions, + () => Assert.Equal( + expected.Functions.Select(x => x), actual.Functions, (expected, actual) => AssertEqual( expected, @@ -1082,7 +1151,8 @@ public virtual void AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.StoredProcedures.Select(x => x), actual.StoredProcedures, + () => Assert.Equal( + expected.StoredProcedures.Select(x => x), actual.StoredProcedures, (expected, actual) => AssertEqual( expected, @@ -1090,7 +1160,8 @@ public virtual void AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.Sequences.Select(x => x), actual.Sequences, + () => Assert.Equal( + expected.Sequences.Select(x => x), actual.Sequences, (expected, actual) => AssertEqual( expected, @@ -1141,7 +1212,8 @@ public virtual bool AssertEqual( Assert.Multiple( () => AssertEqualBase(expected, actual, expectedAnnotations, actualAnnotations, compareMemberAnnotations), () => Assert.Same(actual, ((RelationalModel)actual.Model).DefaultTables[actual.Name]), - () => Assert.Equal(expected.Columns, actual.Columns, + () => Assert.Equal( + expected.Columns, actual.Columns, (expected, actual) => AssertEqual( expected, @@ -1149,7 +1221,8 @@ public virtual bool AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.EntityTypeMappings.Select(x => x), actual.EntityTypeMappings, + () => Assert.Equal( + expected.EntityTypeMappings.Select(x => x), actual.EntityTypeMappings, (expected, actual) => AssertEqual( expected, @@ -1157,7 +1230,8 @@ public virtual bool AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.ComplexTypeMappings.Select(x => x), actual.ComplexTypeMappings, + () => Assert.Equal( + expected.ComplexTypeMappings.Select(x => x), actual.ComplexTypeMappings, (expected, actual) => AssertEqual( expected, @@ -1179,7 +1253,8 @@ public virtual bool AssertEqual( Assert.Multiple( () => AssertEqualBase(expected, actual, expectedAnnotations, actualAnnotations, compareMemberAnnotations), () => Assert.Same(actual, actual.Model.FindTable(actual.Name, actual.Schema)), - () => Assert.Equal(expected.Columns.Select(x => x), actual.Columns, + () => Assert.Equal( + expected.Columns.Select(x => x), actual.Columns, (expected, actual) => AssertEqual( expected, @@ -1187,42 +1262,48 @@ public virtual bool AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.Indexes.Select(x => x), actual.Indexes, + () => Assert.Equal( + expected.Indexes.Select(x => x), actual.Indexes, (expected, actual) => AssertEqual( expected, actual, compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty())), - () => Assert.Equal(expected.ForeignKeyConstraints.Select(x => x), actual.ForeignKeyConstraints, + () => Assert.Equal( + expected.ForeignKeyConstraints.Select(x => x), actual.ForeignKeyConstraints, (expected, actual) => AssertEqual( expected, actual, compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty())), - () => Assert.Equal(expected.ReferencingForeignKeyConstraints.Select(x => x), actual.ReferencingForeignKeyConstraints, + () => Assert.Equal( + expected.ReferencingForeignKeyConstraints.Select(x => x), actual.ReferencingForeignKeyConstraints, (expected, actual) => AssertEqual( expected, actual, compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty())), - () => Assert.Equal(expected.UniqueConstraints.Select(x => x), actual.UniqueConstraints, + () => Assert.Equal( + expected.UniqueConstraints.Select(x => x), actual.UniqueConstraints, (expected, actual) => AssertEqual( expected, actual, compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty())), - () => Assert.Equal(expected.Triggers.Select(x => x), actual.Triggers, + () => Assert.Equal( + expected.Triggers.Select(x => x), actual.Triggers, (expected, actual) => AssertEqual( expected, actual, compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty())), - () => Assert.Equal(expected.EntityTypeMappings.Select(x => x), actual.EntityTypeMappings, + () => Assert.Equal( + expected.EntityTypeMappings.Select(x => x), actual.EntityTypeMappings, (expected, actual) => AssertEqual( expected, @@ -1230,7 +1311,8 @@ public virtual bool AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.ComplexTypeMappings.Select(x => x), actual.ComplexTypeMappings, + () => Assert.Equal( + expected.ComplexTypeMappings.Select(x => x), actual.ComplexTypeMappings, (expected, actual) => AssertEqual( expected, @@ -1252,7 +1334,8 @@ public virtual bool AssertEqual( Assert.Multiple( () => AssertEqualBase(expected, actual, expectedAnnotations, actualAnnotations, compareMemberAnnotations), () => Assert.Same(actual, actual.Model.FindView(actual.Name, actual.Schema)), - () => Assert.Equal(expected.Columns.Select(x => x), actual.Columns, + () => Assert.Equal( + expected.Columns.Select(x => x), actual.Columns, (expected, actual) => AssertEqual( expected, @@ -1260,7 +1343,8 @@ public virtual bool AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.EntityTypeMappings.Select(x => x), actual.EntityTypeMappings, + () => Assert.Equal( + expected.EntityTypeMappings.Select(x => x), actual.EntityTypeMappings, (expected, actual) => AssertEqual( expected, @@ -1268,7 +1352,8 @@ public virtual bool AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.ComplexTypeMappings.Select(x => x), actual.ComplexTypeMappings, + () => Assert.Equal( + expected.ComplexTypeMappings.Select(x => x), actual.ComplexTypeMappings, (expected, actual) => AssertEqual( expected, @@ -1291,7 +1376,8 @@ public virtual bool AssertEqual( () => AssertEqualBase(expected, actual, expectedAnnotations, actualAnnotations, compareMemberAnnotations), () => Assert.Equal(expected.Sql, actual.Sql), () => Assert.Same(actual, actual.Model.FindQuery(actual.Name)), - () => Assert.Equal(expected.Columns.Select(x => x), actual.Columns, + () => Assert.Equal( + expected.Columns.Select(x => x), actual.Columns, (expected, actual) => AssertEqual( expected, @@ -1299,7 +1385,8 @@ public virtual bool AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.EntityTypeMappings.Select(x => x), actual.EntityTypeMappings, + () => Assert.Equal( + expected.EntityTypeMappings.Select(x => x), actual.EntityTypeMappings, (expected, actual) => AssertEqual( expected, @@ -1307,7 +1394,8 @@ public virtual bool AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.ComplexTypeMappings.Select(x => x), actual.ComplexTypeMappings, + () => Assert.Equal( + expected.ComplexTypeMappings.Select(x => x), actual.ComplexTypeMappings, (expected, actual) => AssertEqual( expected, @@ -1335,7 +1423,8 @@ public virtual bool AssertEqual( () => Assert.Equal( actual.DbFunctions.Select(p => p.ModelName), expected.DbFunctions.Select(p => p.ModelName)), - () => Assert.Equal(expected.Parameters.Select(x => x), actual.Parameters, + () => Assert.Equal( + expected.Parameters.Select(x => x), actual.Parameters, (expected, actual) => AssertEqual( expected, @@ -1343,7 +1432,8 @@ public virtual bool AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.Columns.Select(x => x), actual.Columns, + () => Assert.Equal( + expected.Columns.Select(x => x), actual.Columns, (expected, actual) => AssertEqual( expected, @@ -1351,7 +1441,8 @@ public virtual bool AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.EntityTypeMappings.Select(x => x), actual.EntityTypeMappings, + () => Assert.Equal( + expected.EntityTypeMappings.Select(x => x), actual.EntityTypeMappings, (expected, actual) => AssertEqual( expected, @@ -1359,7 +1450,8 @@ public virtual bool AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.ComplexTypeMappings.Select(x => x), actual.ComplexTypeMappings, + () => Assert.Equal( + expected.ComplexTypeMappings.Select(x => x), actual.ComplexTypeMappings, (expected, actual) => AssertEqual( expected, @@ -1394,7 +1486,8 @@ public virtual bool AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty()); Assert.Same(actual, actual.ReturnValue.StoredProcedure); - Assert.Equal(expected.ReturnValue.PropertyMappings.Select(x => x), actual.ReturnValue.PropertyMappings, + Assert.Equal( + expected.ReturnValue.PropertyMappings.Select(x => x), actual.ReturnValue.PropertyMappings, (expected, actual) => AssertEqual( expected, @@ -1407,7 +1500,8 @@ public virtual bool AssertEqual( Assert.Null(actual.ReturnValue); } }, - () => Assert.Equal(expected.Parameters.Select(x => x), actual.Parameters, + () => Assert.Equal( + expected.Parameters.Select(x => x), actual.Parameters, (expected, actual) => AssertEqual( expected, @@ -1415,7 +1509,8 @@ public virtual bool AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.ResultColumns.Select(x => x), actual.ResultColumns, + () => Assert.Equal( + expected.ResultColumns.Select(x => x), actual.ResultColumns, (expected, actual) => AssertEqual( expected, @@ -1423,7 +1518,8 @@ public virtual bool AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.EntityTypeMappings.Select(x => x), actual.EntityTypeMappings, + () => Assert.Equal( + expected.EntityTypeMappings.Select(x => x), actual.EntityTypeMappings, (expected, actual) => AssertEqual( expected, @@ -1431,7 +1527,8 @@ public virtual bool AssertEqual( compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations)), - () => Assert.Equal(expected.ComplexTypeMappings.Select(x => x), actual.ComplexTypeMappings, + () => Assert.Equal( + expected.ComplexTypeMappings.Select(x => x), actual.ComplexTypeMappings, (expected, actual) => AssertEqual( expected, @@ -1469,7 +1566,8 @@ public virtual bool AssertEqual( { Assert.Multiple( () => AssertEqualBase(expected, actual, expectedAnnotations, actualAnnotations), - () => Assert.Equal(expected.ColumnMappings.Select(x => x), actual.ColumnMappings, + () => Assert.Equal( + expected.ColumnMappings.Select(x => x), actual.ColumnMappings, (expected, actual) => AssertEqual( expected, @@ -1492,7 +1590,8 @@ public virtual bool AssertEqual( () => AssertEqual(expected.DeleteStoredProcedureMapping, actual.DeleteStoredProcedureMapping, compareMemberAnnotations), () => AssertEqual(expected.InsertStoredProcedureMapping, actual.InsertStoredProcedureMapping, compareMemberAnnotations), () => AssertEqual(expected.UpdateStoredProcedureMapping, actual.UpdateStoredProcedureMapping, compareMemberAnnotations), - () => Assert.Equal(expected.ColumnMappings.Select(x => x), actual.ColumnMappings, + () => Assert.Equal( + expected.ColumnMappings.Select(x => x), actual.ColumnMappings, (expected, actual) => AssertEqual( expected, @@ -1512,7 +1611,8 @@ public virtual bool AssertEqual( { Assert.Multiple( () => AssertEqualBase(expected, actual, expectedAnnotations, actualAnnotations), - () => Assert.Equal(expected.ColumnMappings.Select(x => x), actual.ColumnMappings, + () => Assert.Equal( + expected.ColumnMappings.Select(x => x), actual.ColumnMappings, (expected, actual) => AssertEqual( expected, @@ -1533,7 +1633,8 @@ public virtual bool AssertEqual( Assert.Multiple( () => AssertEqualBase(expected, actual, expectedAnnotations, actualAnnotations), () => Assert.Equal(expected.IsDefaultSqlQueryMapping, actual.IsDefaultSqlQueryMapping), - () => Assert.Equal(expected.ColumnMappings.Select(x => x), actual.ColumnMappings, + () => Assert.Equal( + expected.ColumnMappings.Select(x => x), actual.ColumnMappings, (expected, actual) => AssertEqual( expected, @@ -1554,7 +1655,8 @@ public virtual bool AssertEqual( Assert.Multiple( () => AssertEqualBase(expected, actual, expectedAnnotations, actualAnnotations), () => Assert.Equal(expected.IsDefaultFunctionMapping, actual.IsDefaultFunctionMapping), - () => Assert.Equal(expected.ColumnMappings.Select(x => x), actual.ColumnMappings, + () => Assert.Equal( + expected.ColumnMappings.Select(x => x), actual.ColumnMappings, (expected, actual) => AssertEqual( expected, @@ -1595,14 +1697,16 @@ public virtual bool AssertEqual( () => AssertEqualBase(expected, actual, expectedAnnotations, actualAnnotations), () => Assert.Equal(expected.StoredProcedure.GetSchemaQualifiedName(), actual.StoredProcedure.GetSchemaQualifiedName()), () => Assert.Contains(expected.TableMapping?.Table.SchemaQualifiedName, actual.TableMapping?.Table.SchemaQualifiedName), - () => Assert.Equal(expected.ResultColumnMappings.Select(x => x), actual.ResultColumnMappings, + () => Assert.Equal( + expected.ResultColumnMappings.Select(x => x), actual.ResultColumnMappings, (expected, actual) => AssertEqual( expected, actual, compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty())), - () => Assert.Equal(expected.ParameterMappings.Select(x => x), actual.ParameterMappings, + () => Assert.Equal( + expected.ParameterMappings.Select(x => x), actual.ParameterMappings, (expected, actual) => AssertEqual( expected, @@ -1640,7 +1744,8 @@ public virtual bool AssertEqual( Assert.Multiple( () => AssertEqualBase(expected, actual, expectedAnnotations, actualAnnotations), () => Assert.Same(actual, actual.Table.FindColumn(actual.Name)), - () => Assert.Equal(expected.PropertyMappings.Select(x => x), actual.PropertyMappings, + () => Assert.Equal( + expected.PropertyMappings.Select(x => x), actual.PropertyMappings, (expected, actual) => AssertEqual( expected, @@ -1661,7 +1766,8 @@ public virtual bool AssertEqual( Assert.Multiple( () => AssertEqualBase(expected, actual, expectedAnnotations, actualAnnotations), () => Assert.Same(actual, actual.Table.FindColumn(actual.Name)), - () => Assert.Equal(expected.PropertyMappings.Select(x => x), actual.PropertyMappings, + () => Assert.Equal( + expected.PropertyMappings.Select(x => x), actual.PropertyMappings, (expected, actual) => AssertEqual( expected, @@ -1682,7 +1788,8 @@ public virtual bool AssertEqual( Assert.Multiple( () => AssertEqualBase(expected, actual, expectedAnnotations, actualAnnotations), () => Assert.Same(actual, actual.View.FindColumn(actual.Name)), - () => Assert.Equal(expected.PropertyMappings.Select(x => x), actual.PropertyMappings, + () => Assert.Equal( + expected.PropertyMappings.Select(x => x), actual.PropertyMappings, (expected, actual) => AssertEqual( expected, @@ -1703,7 +1810,8 @@ public virtual bool AssertEqual( Assert.Multiple( () => AssertEqualBase(expected, actual, expectedAnnotations, actualAnnotations), () => Assert.Same(actual, actual.SqlQuery.FindColumn(actual.Name)), - () => Assert.Equal(expected.PropertyMappings.Select(x => x), actual.PropertyMappings, + () => Assert.Equal( + expected.PropertyMappings.Select(x => x), actual.PropertyMappings, (expected, actual) => AssertEqual( expected, @@ -1724,7 +1832,8 @@ public virtual bool AssertEqual( Assert.Multiple( () => AssertEqualBase(expected, actual, expectedAnnotations, actualAnnotations), () => Assert.Same(actual, actual.Function.FindColumn(actual.Name)), - () => Assert.Equal(expected.PropertyMappings.Select(x => x), actual.PropertyMappings, + () => Assert.Equal( + expected.PropertyMappings.Select(x => x), actual.PropertyMappings, (expected, actual) => AssertEqual( expected, @@ -1746,7 +1855,8 @@ public virtual bool AssertEqual( () => Assert.Equal(expected.Name, actual.Name), () => Assert.Equal(expected.StoreType, actual.StoreType), () => Assert.Contains(actual, actual.Function.Parameters), - () => Assert.Equal(expected.DbFunctionParameters.Select(x => x), actual.DbFunctionParameters, + () => Assert.Equal( + expected.DbFunctionParameters.Select(x => x), actual.DbFunctionParameters, (expected, actual) => { Assert.Equal(expected.Name, actual.Name); @@ -1768,7 +1878,8 @@ public virtual bool AssertEqual( () => AssertEqualBase(expected, actual, expectedAnnotations, actualAnnotations), () => Assert.Equal(expected.Position, actual.Position), () => Assert.Same(actual, actual.StoredProcedure.FindResultColumn(actual.Name)), - () => Assert.Equal(expected.PropertyMappings.Select(x => x), actual.PropertyMappings, + () => Assert.Equal( + expected.PropertyMappings.Select(x => x), actual.PropertyMappings, (expected, actual) => AssertEqual( expected, @@ -1791,7 +1902,8 @@ public virtual bool AssertEqual( () => Assert.Equal(expected.Position, actual.Position), () => Assert.Equal(expected.Direction, actual.Direction), () => Assert.Same(actual, actual.StoredProcedure.FindParameter(actual.Name)), - () => Assert.Equal(expected.PropertyMappings.Select(x => x), actual.PropertyMappings, + () => Assert.Equal( + expected.PropertyMappings.Select(x => x), actual.PropertyMappings, (expected, actual) => AssertEqual( expected, @@ -1842,6 +1954,7 @@ public virtual bool AssertEqual( return true; } + public virtual bool AssertEqual( IViewColumnMapping expected, IViewColumnMapping actual, diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalQueryAsserter.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalQueryAsserter.cs index 36c247629b3..95f022b888f 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalQueryAsserter.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalQueryAsserter.cs @@ -9,7 +9,8 @@ public class RelationalQueryAsserter( IQueryFixtureBase queryFixture, Func rewriteExpectedQueryExpression, Func rewriteServerQueryExpression, - bool ignoreEntryCount = false) : QueryAsserter(queryFixture, rewriteExpectedQueryExpression, rewriteServerQueryExpression, ignoreEntryCount) + bool ignoreEntryCount = false) : QueryAsserter( + queryFixture, rewriteExpectedQueryExpression, rewriteServerQueryExpression, ignoreEntryCount) { private static int ExecuteReader(DbCommand command) { @@ -79,7 +80,8 @@ public override async Task AssertQuery( var outputSql = true; try { - await base.AssertQuery(actualQuery, expectedQuery, elementSorter, elementAsserter, assertOrder, assertEmpty, async, testMethodName, filteredQuery); + await base.AssertQuery( + actualQuery, expectedQuery, elementSorter, elementAsserter, assertOrder, assertEmpty, async, testMethodName, filteredQuery); outputSql = false; } finally @@ -104,7 +106,8 @@ public override async Task AssertQueryScalar( var outputSql = true; try { - await base.AssertQueryScalar(actualQuery, expectedQuery, asserter, assertOrder, assertEmpty, async, testMethodName, filteredQuery); + await base.AssertQueryScalar( + actualQuery, expectedQuery, asserter, assertOrder, assertEmpty, async, testMethodName, filteredQuery); outputSql = false; } finally @@ -129,7 +132,8 @@ public override async Task AssertQueryScalar( var outputSql = true; try { - await base.AssertQueryScalar(actualQuery, expectedQuery, asserter, assertOrder, assertEmpty, async, testMethodName, filteredQuery); + await base.AssertQueryScalar( + actualQuery, expectedQuery, asserter, assertOrder, assertEmpty, async, testMethodName, filteredQuery); outputSql = false; } finally @@ -165,7 +169,8 @@ public override Task AssertAll( Expression> expectedPredicate, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertAll(actualQuery, expectedQuery, actualPredicate, expectedPredicate, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertAll(actualQuery, expectedQuery, actualPredicate, expectedPredicate, async, filteredQuery)); public override Task AssertAny( Func> actualQuery, @@ -181,7 +186,8 @@ public override Task AssertAny( Expression> expectedPredicate, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertAny(actualQuery, expectedQuery, actualPredicate, expectedPredicate, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertAny(actualQuery, expectedQuery, actualPredicate, expectedPredicate, async, filteredQuery)); public override Task AssertAverage( Func> actualQuery, @@ -271,7 +277,8 @@ public override Task AssertAverage( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertAverage( Func> actualQuery, @@ -281,7 +288,8 @@ public override Task AssertAverage( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertAverage( Func> actualQuery, @@ -291,7 +299,8 @@ public override Task AssertAverage( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertAverage( Func> actualQuery, @@ -301,7 +310,8 @@ public override Task AssertAverage( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertAverage( Func> actualQuery, @@ -311,7 +321,8 @@ public override Task AssertAverage( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertAverage( Func> actualQuery, @@ -321,7 +332,8 @@ public override Task AssertAverage( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertAverage( Func> actualQuery, @@ -331,7 +343,8 @@ public override Task AssertAverage( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertAverage( Func> actualQuery, @@ -341,7 +354,8 @@ public override Task AssertAverage( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertAverage( Func> actualQuery, @@ -351,7 +365,8 @@ public override Task AssertAverage( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertAverage( Func> actualQuery, @@ -361,7 +376,8 @@ public override Task AssertAverage( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertCount( Func> actualQuery, @@ -377,7 +393,8 @@ public override Task AssertCount( Expression> expectedPredicate, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertCount(actualQuery, expectedQuery, actualPredicate, expectedPredicate, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertCount(actualQuery, expectedQuery, actualPredicate, expectedPredicate, async, filteredQuery)); public override Task AssertElementAt( Func> actualQuery, @@ -387,7 +404,8 @@ public override Task AssertElementAt( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertElementAt(actualQuery, expectedQuery, actualIndex, expectedIndex, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertElementAt(actualQuery, expectedQuery, actualIndex, expectedIndex, asserter, async, filteredQuery)); public override Task AssertElementAtOrDefault( Func> actualQuery, @@ -398,7 +416,8 @@ public override Task AssertElementAtOrDefault( bool async = false, bool filteredQuery = false) where TResult : default - => RunAndOutputSqlOnFailure(() => base.AssertElementAtOrDefault(actualQuery, expectedQuery, actualIndex, expectedIndex, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertElementAtOrDefault(actualQuery, expectedQuery, actualIndex, expectedIndex, asserter, async, filteredQuery)); public override Task AssertFirst( Func> actualQuery, @@ -416,7 +435,8 @@ public override Task AssertFirst( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertFirst(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertFirst(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async, filteredQuery)); public override Task AssertFirstOrDefault( Func> actualQuery, @@ -436,7 +456,9 @@ public override Task AssertFirstOrDefault( bool async = false, bool filteredQuery = false) where TResult : default - => RunAndOutputSqlOnFailure(() => base.AssertFirstOrDefault(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertFirstOrDefault( + actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async, filteredQuery)); public override Task AssertLast( Func> actualQuery, @@ -454,7 +476,8 @@ public override Task AssertLast( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertLast(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertLast(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async, filteredQuery)); public override Task AssertLastOrDefault( Func> actualQuery, @@ -474,7 +497,8 @@ public override Task AssertLastOrDefault( bool async = false, bool filteredQuery = false) where TResult : default - => RunAndOutputSqlOnFailure(() => base.AssertLastOrDefault(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertLastOrDefault(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async, filteredQuery)); public override Task AssertLongCount( Func> actualQuery, @@ -490,7 +514,8 @@ public override Task AssertLongCount( Expression> expectedPredicate, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertLongCount(actualQuery, expectedQuery, actualPredicate, expectedPredicate, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertLongCount(actualQuery, expectedQuery, actualPredicate, expectedPredicate, async, filteredQuery)); public override Task AssertMax( Func> actualQuery, @@ -501,7 +526,8 @@ public override Task AssertMax( bool async = false, bool filteredQuery = false) where TSelector : default - => RunAndOutputSqlOnFailure(() => base.AssertMax(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertMax(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertMax( Func> actualQuery, @@ -521,7 +547,8 @@ public override Task AssertMin( bool async = false, bool filteredQuery = false) where TSelector : default - => RunAndOutputSqlOnFailure(() => base.AssertMin(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertMin(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertMin( Func> actualQuery, @@ -548,7 +575,8 @@ public override Task AssertSingle( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertSingle(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertSingle(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async, filteredQuery)); public override Task AssertSingleOrDefault( Func> actualQuery, @@ -568,7 +596,9 @@ public override Task AssertSingleOrDefault( bool async = false, bool filteredQuery = false) where TResult : default - => RunAndOutputSqlOnFailure(() => base.AssertSingleOrDefault(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertSingleOrDefault( + actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async, filteredQuery)); public override Task AssertSum( Func> actualQuery, @@ -658,7 +688,8 @@ public override Task AssertSum( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertSum( Func> actualQuery, @@ -668,7 +699,8 @@ public override Task AssertSum( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertSum( Func> actualQuery, @@ -678,7 +710,8 @@ public override Task AssertSum( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertSum( Func> actualQuery, @@ -688,7 +721,8 @@ public override Task AssertSum( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertSum( Func> actualQuery, @@ -698,7 +732,8 @@ public override Task AssertSum( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertSum( Func> actualQuery, @@ -708,7 +743,8 @@ public override Task AssertSum( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertSum( Func> actualQuery, @@ -718,7 +754,8 @@ public override Task AssertSum( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertSum( Func> actualQuery, @@ -728,7 +765,8 @@ public override Task AssertSum( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertSum( Func> actualQuery, @@ -738,7 +776,8 @@ public override Task AssertSum( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); public override Task AssertSum( Func> actualQuery, @@ -748,5 +787,6 @@ public override Task AssertSum( Action? asserter = null, bool async = false, bool filteredQuery = false) - => RunAndOutputSqlOnFailure(() => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); + => RunAndOutputSqlOnFailure( + () => base.AssertSum(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async, filteredQuery)); } diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalTestHelpers.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalTestHelpers.cs index 5b53c7eb7e4..58759a8ffaa 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalTestHelpers.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalTestHelpers.cs @@ -5,5 +5,6 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities; public abstract class RelationalTestHelpers : TestHelpers { - public override ModelAsserter ModelAsserter => RelationalModelAsserter.Instance; + public override ModelAsserter ModelAsserter + => RelationalModelAsserter.Instance; } diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs index c07a15a4603..43ffe427271 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs @@ -28,9 +28,7 @@ public TestSqlLoggerFactory() public TestSqlLoggerFactory(Func shouldLogCategory) : base(c => shouldLogCategory(c) || c == DbLoggerCategory.Database.Command.Name) - { - Logger = new TestSqlLogger(shouldLogCategory(DbLoggerCategory.Database.Command.Name)); - } + => Logger = new TestSqlLogger(shouldLogCategory(DbLoggerCategory.Database.Command.Name)); public IReadOnlyList SqlStatements => ((TestSqlLogger)Logger).SqlStatements; diff --git a/test/EFCore.Relational.Specification.Tests/TwoDatabasesTestBase.cs b/test/EFCore.Relational.Specification.Tests/TwoDatabasesTestBase.cs index 286da3eced4..11b88c9e37c 100644 --- a/test/EFCore.Relational.Specification.Tests/TwoDatabasesTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/TwoDatabasesTestBase.cs @@ -98,7 +98,8 @@ public virtual void Can_set_connection_string_in_interceptor(bool withConnection Assert.Equal(new[] { "Modified One", "Modified Two" }, context1.Foos.Select(e => e.Bar).ToList()); } - protected class ConnectionStringConnectionInterceptor(string goodConnectionString, string dummyConnectionString) : DbConnectionInterceptor + protected class ConnectionStringConnectionInterceptor(string goodConnectionString, string dummyConnectionString) + : DbConnectionInterceptor { private readonly string _goodConnectionString = goodConnectionString; private readonly string _dummyConnectionString = dummyConnectionString; diff --git a/test/EFCore.Relational.Specification.Tests/Update/JsonUpdateTestBase.cs b/test/EFCore.Relational.Specification.Tests/Update/JsonUpdateTestBase.cs index 8ca39553716..90f5e03f5d4 100644 --- a/test/EFCore.Relational.Specification.Tests/Update/JsonUpdateTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Update/JsonUpdateTestBase.cs @@ -41,7 +41,7 @@ public virtual Task Add_entity_with_json() Fraction = 42.42m, OwnedCollectionLeaf = [ - new() { SomethingSomething = "ss1" }, new() { SomethingSomething = "ss2" } + new JsonOwnedLeaf { SomethingSomething = "ss1" }, new JsonOwnedLeaf { SomethingSomething = "ss2" } ], OwnedReferenceLeaf = new JsonOwnedLeaf { SomethingSomething = "ss3" } } @@ -102,7 +102,7 @@ public virtual Task Add_entity_with_json_null_navigations() Fraction = 42.42m, OwnedCollectionLeaf = [ - new() { SomethingSomething = "ss1" }, new() { SomethingSomething = "ss2" } + new JsonOwnedLeaf { SomethingSomething = "ss1" }, new JsonOwnedLeaf { SomethingSomething = "ss2" } ], OwnedReferenceLeaf = null, } @@ -169,7 +169,7 @@ public virtual Task Add_json_reference_root() Fraction = 42.42m, OwnedCollectionLeaf = [ - new() { SomethingSomething = "ss1" }, new() { SomethingSomething = "ss2" } + new JsonOwnedLeaf { SomethingSomething = "ss1" }, new JsonOwnedLeaf { SomethingSomething = "ss2" } ], OwnedReferenceLeaf = new JsonOwnedLeaf { SomethingSomething = "ss3" } } @@ -249,7 +249,7 @@ public virtual Task Add_element_to_json_collection_root() Fraction = 42.42m, OwnedCollectionLeaf = [ - new() { SomethingSomething = "ss1" }, new() { SomethingSomething = "ss2" } + new JsonOwnedLeaf { SomethingSomething = "ss1" }, new JsonOwnedLeaf { SomethingSomething = "ss2" } ], OwnedReferenceLeaf = new JsonOwnedLeaf { SomethingSomething = "ss3" } } @@ -340,7 +340,7 @@ public virtual Task Add_element_to_json_collection_branch() Fraction = 42.42m, OwnedCollectionLeaf = [ - new() { SomethingSomething = "ss1" }, new() { SomethingSomething = "ss2" } + new JsonOwnedLeaf { SomethingSomething = "ss1" }, new JsonOwnedLeaf { SomethingSomething = "ss2" } ], OwnedReferenceLeaf = new JsonOwnedLeaf { SomethingSomething = "ss3" } }; @@ -566,7 +566,7 @@ public virtual Task Add_element_to_json_collection_on_derived() Fraction = 42.42m, OwnedCollectionLeaf = [ - new() { SomethingSomething = "ss1" }, new() { SomethingSomething = "ss2" } + new JsonOwnedLeaf { SomethingSomething = "ss1" }, new JsonOwnedLeaf { SomethingSomething = "ss2" } ], OwnedReferenceLeaf = new JsonOwnedLeaf { SomethingSomething = "ss3" } }; @@ -1484,7 +1484,7 @@ public virtual Task Edit_a_scalar_property_and_collection_navigation_on_the_same var query = await context.JsonEntitiesBasic.ToListAsync(); var entity = query.Single(); entity.OwnedReferenceRoot.OwnedReferenceBranch.Fraction = 523.532M; - entity.OwnedReferenceRoot.OwnedReferenceBranch.OwnedCollectionLeaf = [new() { SomethingSomething = "edit" }]; + entity.OwnedReferenceRoot.OwnedReferenceBranch.OwnedCollectionLeaf = [new JsonOwnedLeaf { SomethingSomething = "edit" }]; ClearLog(); await context.SaveChangesAsync(); @@ -1898,8 +1898,8 @@ public virtual Task Edit_single_property_collection_of_guid() { var query = await context.JsonEntitiesAllTypes.ToListAsync(); var entity = query.Single(x => x.Id == 1); - entity.Reference.TestGuidCollection = [new("12345678-1234-4321-5555-987654321000")]; - entity.Collection[0].TestGuidCollection = [new("12345678-1234-4321-5555-987654321000")]; + entity.Reference.TestGuidCollection = [new Guid("12345678-1234-4321-5555-987654321000")]; + entity.Collection[0].TestGuidCollection = [new Guid("12345678-1234-4321-5555-987654321000")]; ClearLog(); await context.SaveChangesAsync(); @@ -1907,8 +1907,8 @@ public virtual Task Edit_single_property_collection_of_guid() async context => { var result = await context.Set().SingleAsync(x => x.Id == 1); - Assert.Equal([new("12345678-1234-4321-5555-987654321000")], result.Reference.TestGuidCollection); - Assert.Equal([new("12345678-1234-4321-5555-987654321000")], result.Collection[0].TestGuidCollection); + Assert.Equal([new Guid("12345678-1234-4321-5555-987654321000")], result.Reference.TestGuidCollection); + Assert.Equal([new Guid("12345678-1234-4321-5555-987654321000")], result.Collection[0].TestGuidCollection); Assert.False(result.Reference.NewCollectionSet); Assert.False(result.Collection[0].NewCollectionSet); @@ -2638,7 +2638,7 @@ public virtual Task Edit_single_property_relational_collection_of_guid() { var query = await context.JsonEntitiesAllTypes.ToListAsync(); var entity = query.Single(x => x.Id == 1); - entity.TestGuidCollection = new ReadOnlyCollection([new("12345678-1234-4321-5555-987654321000")]); + entity.TestGuidCollection = new ReadOnlyCollection([new Guid("12345678-1234-4321-5555-987654321000")]); ClearLog(); await context.SaveChangesAsync(); @@ -2646,7 +2646,7 @@ public virtual Task Edit_single_property_relational_collection_of_guid() async context => { var result = await context.Set().SingleAsync(x => x.Id == 1); - Assert.Equal(new ReadOnlyCollection([new("12345678-1234-4321-5555-987654321000")]), result.TestGuidCollection); + Assert.Equal(new ReadOnlyCollection([new Guid("12345678-1234-4321-5555-987654321000")]), result.TestGuidCollection); Assert.False(result.NewCollectionSet); }); @@ -2704,7 +2704,7 @@ public virtual Task Edit_single_property_relational_collection_of_int64() { var query = await context.JsonEntitiesAllTypes.ToListAsync(); var entity = query.Single(x => x.Id == 1); - entity.TestInt64Collection = new([]); + entity.TestInt64Collection = new ReadOnlyCollection([]); ClearLog(); await context.SaveChangesAsync(); @@ -3112,7 +3112,7 @@ public virtual Task Edit_single_property_collection_of_collection_of_char() var query = await context.JsonEntitiesAllTypes.ToListAsync(); var entity = query.Single(x => x.Id == 1); entity.Reference.TestCharacterCollectionCollection[0] = - ['E', 'F', 'C', 'ö', 'r', 'E', '\"', '\\']; + ['E', 'F', 'C', 'ö', 'r', 'E', '\"', '\\']; entity.Collection[0].TestCharacterCollectionCollection[2] = ['D', 'E', 'F', '\0']; ClearLog(); @@ -3121,7 +3121,9 @@ public virtual Task Edit_single_property_collection_of_collection_of_char() async context => { var result = await context.Set().SingleAsync(x => x.Id == 1); - Assert.Equal([['E', 'F', 'C', 'ö', 'r', 'E', '\"', '\\'], null, ['D', 'E', 'F']], result.Reference.TestCharacterCollectionCollection); + Assert.Equal( + [['E', 'F', 'C', 'ö', 'r', 'E', '\"', '\\'], null, ['D', 'E', 'F']], + result.Reference.TestCharacterCollectionCollection); Assert.Equal([['A', 'B', 'C'], null, ['D', 'E', 'F', '\0']], result.Collection[0].TestCharacterCollectionCollection); }); @@ -3166,8 +3168,12 @@ public virtual Task Edit_single_property_collection_of_collection_of_int16() async context => { var result = await context.Set().SingleAsync(x => x.Id == 1); - Assert.Equal([[short.MinValue, 0, short.MaxValue], null, [short.MinValue, 0, short.MaxValue, 3234]], result.Reference.TestInt16CollectionCollection); - Assert.Equal([[short.MinValue, 0, short.MaxValue], null, [short.MinValue, 0, short.MaxValue], null], result.Collection[0].TestInt16CollectionCollection); + Assert.Equal( + [[short.MinValue, 0, short.MaxValue], null, [short.MinValue, 0, short.MaxValue, 3234]], + result.Reference.TestInt16CollectionCollection); + Assert.Equal( + [[short.MinValue, 0, short.MaxValue], null, [short.MinValue, 0, short.MaxValue], null], + result.Collection[0].TestInt16CollectionCollection); }); [ConditionalFact] @@ -3258,8 +3264,12 @@ public virtual Task Edit_single_property_collection_of_collection_of_nullable_in async context => { var result = await context.Set().SingleAsync(x => x.Id == 1); - Assert.Equal([[77], [int.MinValue, null, int.MaxValue, null], null, [int.MinValue, 0, int.MaxValue], null], result.Reference.TestNullableInt32CollectionCollection); - Assert.Equal([null, [int.MinValue, null, int.MaxValue, null], null, [int.MinValue, 0, int.MaxValue], [null, 77]], result.Collection[0].TestNullableInt32CollectionCollection); + Assert.Equal( + [[77], [int.MinValue, null, int.MaxValue, null], null, [int.MinValue, 0, int.MaxValue], null], + result.Reference.TestNullableInt32CollectionCollection); + Assert.Equal( + [null, [int.MinValue, null, int.MaxValue, null], null, [int.MinValue, 0, int.MaxValue], [null, 77]], + result.Collection[0].TestNullableInt32CollectionCollection); }); [ConditionalFact] @@ -3348,7 +3358,7 @@ public virtual Task Add_and_update_top_level_optional_owned_collection_to_JSON(b OwnedCollectionRoot = value.HasValue ? value.Value - ? [new()] + ? [new JsonOwnedRoot()] : [] : null }; @@ -3382,6 +3392,7 @@ public virtual Task Add_and_update_top_level_optional_owned_collection_to_JSON(b // Because just setting the navigation to an empty collection currently doesn't mark it as modified. context.Entry(newEntity).State = EntityState.Modified; } + await context.SaveChangesAsync(); var saved = context.Database.SqlQueryRaw("select OwnedCollectionRoot from JsonEntitiesBasic where Id = 2").ToList(); @@ -3421,12 +3432,12 @@ public virtual Task Add_and_update_nested_optional_owned_collection_to_JSON(bool { Id = 2, Name = "NewEntity", - OwnedReferenceRoot = new JsonOwnedRoot() + OwnedReferenceRoot = new JsonOwnedRoot { OwnedCollectionBranch = value.HasValue ? value.Value - ? [new()] + ? [new JsonOwnedBranch()] : [] : null } @@ -3461,6 +3472,7 @@ public virtual Task Add_and_update_nested_optional_owned_collection_to_JSON(bool // Because just setting the navigation to an empty collection currently doesn't mark it as modified. context.Entry(newEntity).Reference(e => e.OwnedReferenceRoot).TargetEntry!.State = EntityState.Modified; } + await context.SaveChangesAsync(); }, async context => @@ -3484,7 +3496,6 @@ public virtual Task Add_and_update_nested_optional_owned_collection_to_JSON(bool } }); - [ConditionalTheory] [InlineData(false)] [InlineData(true)] @@ -3506,10 +3517,10 @@ public virtual Task Add_and_update_nested_optional_primitive_collection(bool? va TestDateTimeOffsetCollection = [], TestDoubleCollection = [], TestDecimalCollection = [], - TestGuidCollection = new([]), + TestGuidCollection = new ReadOnlyCollection([]), TestInt16Collection = [], TestInt32Collection = [], - TestInt64Collection = new([]), + TestInt64Collection = new ReadOnlyCollection([]), TestSignedByteCollection = [], TestSingleCollection = [], TestTimeSpanCollection = [], @@ -3535,10 +3546,10 @@ public virtual Task Add_and_update_nested_optional_primitive_collection(bool? va TestNullableEnumWithIntConverterCollectionCollection = [], Collection = [ - new() + new JsonOwnedAllTypes { TestDefaultStringCollection = [], - TestMaxLengthStringCollection = new([]), + TestMaxLengthStringCollection = new ReadOnlyCollection([]), TestBooleanCollection = [], TestDateTimeCollection = [], TestDateTimeOffsetCollection = [], diff --git a/test/EFCore.Relational.Tests/DbSetAsTableNameTest.cs b/test/EFCore.Relational.Tests/DbSetAsTableNameTest.cs index d94e00a99d7..ba4df9e5e61 100644 --- a/test/EFCore.Relational.Tests/DbSetAsTableNameTest.cs +++ b/test/EFCore.Relational.Tests/DbSetAsTableNameTest.cs @@ -142,8 +142,20 @@ protected abstract class SetsContext : DbContext public DbSet WheatThins { get; set; } public DbSet Food { get; set; } public DbSet Beverage { get; set; } - public DbSet ReallyLongNames12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890A { get; set; } - public DbSet ReallyLongNames12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890B { get; set; } + + public DbSet + ReallyLongNames12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890A + { + get; + set; + } + + public DbSet + ReallyLongNames12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890B + { + get; + set; + } public DbSet Bovrils => Set("Bovril"); diff --git a/test/EFCore.Relational.Tests/Extensions/RelationalDatabaseFacadeExtensionsTest.cs b/test/EFCore.Relational.Tests/Extensions/RelationalDatabaseFacadeExtensionsTest.cs index 92e7f123544..3e56284521a 100644 --- a/test/EFCore.Relational.Tests/Extensions/RelationalDatabaseFacadeExtensionsTest.cs +++ b/test/EFCore.Relational.Tests/Extensions/RelationalDatabaseFacadeExtensionsTest.cs @@ -355,6 +355,7 @@ public string GetBeginIfExistsScript(string migrationId) public string GetEndIfScript() => throw new NotImplementedException(); + public void Create() => throw new NotImplementedException(); @@ -389,7 +390,8 @@ public async Task GetPendingMigrations_works(bool async) .AddSingleton(repository) .AddSingleton(migrationsAssembly)); - Assert.Equal(["00000000000003_Three"], + Assert.Equal( + ["00000000000003_Three"], async ? await context.Database.GetPendingMigrationsAsync() : context.Database.GetPendingMigrations()); diff --git a/test/EFCore.Relational.Tests/Infrastructure/RelationalEventIdTest.cs b/test/EFCore.Relational.Tests/Infrastructure/RelationalEventIdTest.cs index 6cf00809dc8..018a4e11014 100644 --- a/test/EFCore.Relational.Tests/Infrastructure/RelationalEventIdTest.cs +++ b/test/EFCore.Relational.Tests/Infrastructure/RelationalEventIdTest.cs @@ -6,7 +6,6 @@ using System.Transactions; using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; using Microsoft.EntityFrameworkCore.TestUtilities.FakeProvider; using Index = Microsoft.EntityFrameworkCore.Metadata.Internal.Index; @@ -166,7 +165,8 @@ public string FindMigrationId(string nameOrId) => throw new NotImplementedException(); } - private class FakeMigrationCommand() : MigrationCommand(new FakeRelationalCommand(), null, new FakeRelationalCommandDiagnosticsLogger()); + private class FakeMigrationCommand() + : MigrationCommand(new FakeRelationalCommand(), null, new FakeRelationalCommandDiagnosticsLogger()); private class FakeRelationalCommand : IRelationalCommand { @@ -186,7 +186,9 @@ public Task ExecuteNonQueryAsync(RelationalCommandParameterObject parameter public RelationalDataReader ExecuteReader(RelationalCommandParameterObject parameterObject) => throw new NotImplementedException(); - public Task ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) + public Task ExecuteReaderAsync( + RelationalCommandParameterObject parameterObject, + CancellationToken cancellationToken) => throw new NotImplementedException(); public object ExecuteScalar(RelationalCommandParameterObject parameterObject) diff --git a/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs b/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs index 5be11a5de3f..fa7f1afb8fb 100644 --- a/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs +++ b/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs @@ -2510,10 +2510,11 @@ public virtual void Detects_owned_view_sharing_on_abstract_class_with_TPT() modelBuilder.Entity() .UseTptMappingStrategy() - .OwnsOne(b => b.Details, ob => - { - ob.ToTable((string)null); - }); + .OwnsOne( + b => b.Details, ob => + { + ob.ToTable((string)null); + }); modelBuilder.Entity() .ToView("Animal"); @@ -3809,8 +3810,9 @@ public void Detects_trigger_on_TPH_non_root() modelBuilder.Entity(); modelBuilder.Entity().ToTable(tb => tb.HasTrigger("SomeTrigger")); - VerifyWarning(RelationalResources.LogTriggerOnNonRootTphEntity(new TestLogger()) - .GenerateMessage("Cat", "Animal"), modelBuilder); + VerifyWarning( + RelationalResources.LogTriggerOnNonRootTphEntity(new TestLogger()) + .GenerateMessage("Cat", "Animal"), modelBuilder); } private class TpcBase diff --git a/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs b/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs index dfd8f64e2fa..24bc5288dd4 100644 --- a/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs +++ b/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs @@ -35,7 +35,8 @@ public void Both_design_and_runtime_RelationalModels_are_built_for_external_mode var designTimeModel = context.GetService().Model; var runtimeModel = context.Model; - Assert.NotSame(designTimeModel.FindRuntimeAnnotationValue(RelationalAnnotationNames.RelationalModelFactory), + Assert.NotSame( + designTimeModel.FindRuntimeAnnotationValue(RelationalAnnotationNames.RelationalModelFactory), runtimeModel.FindRuntimeAnnotationValue(RelationalAnnotationNames.RelationalModelFactory)); var designTimeRelationalModel = designTimeModel.GetRelationalModel(); @@ -1341,7 +1342,8 @@ private static void AssertSprocs(IRelationalModel model, Mapping mapping, bool m Assert.DoesNotContain(abstractCustomerType.GetInsertStoredProcedureMappings(), m => m.IncludesDerivedTypes != false); Assert.Equal( "SpecialCustomer_Insert", - specialCustomerType.GetInsertStoredProcedureMappings().Single(m => m.IncludesDerivedTypes == true).StoreStoredProcedure.Name); + specialCustomerType.GetInsertStoredProcedureMappings().Single(m => m.IncludesDerivedTypes == true).StoreStoredProcedure + .Name); Assert.Null(baseInsertSproc.Schema); Assert.Equal( new[] @@ -1379,7 +1381,8 @@ private static void AssertSprocs(IRelationalModel model, Mapping mapping, bool m Assert.DoesNotContain(abstractCustomerType.GetUpdateStoredProcedureMappings(), m => m.IncludesDerivedTypes != false); Assert.Equal( "SpecialCustomer_Update", - specialCustomerType.GetUpdateStoredProcedureMappings().Single(m => m.IncludesDerivedTypes == true).StoreStoredProcedure.Name); + specialCustomerType.GetUpdateStoredProcedureMappings().Single(m => m.IncludesDerivedTypes == true).StoreStoredProcedure + .Name); Assert.Null(baseUpdateSproc.Schema); Assert.Equal( @@ -1418,7 +1421,8 @@ private static void AssertSprocs(IRelationalModel model, Mapping mapping, bool m Assert.DoesNotContain(abstractCustomerType.GetDeleteStoredProcedureMappings(), m => m.IncludesDerivedTypes != false); Assert.Equal( "SpecialCustomer_Delete", - specialCustomerType.GetDeleteStoredProcedureMappings().Single(m => m.IncludesDerivedTypes == true).StoreStoredProcedure.Name); + specialCustomerType.GetDeleteStoredProcedureMappings().Single(m => m.IncludesDerivedTypes == true).StoreStoredProcedure + .Name); Assert.Null(baseDeleteSproc.Schema); Assert.Equal( @@ -3224,6 +3228,7 @@ private class SpecialCustomer : AbstractCustomer private class CustomerDetails { public string Address { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public DateTime BirthDay { get; set; } } diff --git a/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs b/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs index c9e9a08882e..91747976f02 100644 --- a/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs +++ b/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs @@ -11142,9 +11142,7 @@ public Order() } public Order(int secretId) - { - _secretId = secretId; - } + => _secretId = secretId; public int Id { get; set; } @@ -11834,9 +11832,7 @@ public Blog() } private Blog(Action lazyLoader) - { - _loader = lazyLoader; - } + => _loader = lazyLoader; public int BlogId { get; set; } public string Url { get; set; } @@ -11858,9 +11854,7 @@ public Post() } private Post(ILazyLoader loader) - { - _loader = loader; - } + => _loader = loader; public int PostId { get; set; } public string Title { get; set; } diff --git a/test/EFCore.Relational.Tests/Migrations/MigrationCommandExecutorTest.cs b/test/EFCore.Relational.Tests/Migrations/MigrationCommandExecutorTest.cs index f428f1e65c9..f1ca15a4b7b 100644 --- a/test/EFCore.Relational.Tests/Migrations/MigrationCommandExecutorTest.cs +++ b/test/EFCore.Relational.Tests/Migrations/MigrationCommandExecutorTest.cs @@ -1,7 +1,6 @@ // 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.Migrations.Internal; using Microsoft.EntityFrameworkCore.Storage.Internal; using Microsoft.EntityFrameworkCore.TestUtilities.FakeProvider; @@ -122,15 +121,17 @@ public async Task Executes_transaction_suppressed_migration_commands_in_user_tra { Assert.Equal( RelationalStrings.TransactionSuppressedMigrationInUserTransaction, - (await Assert.ThrowsAsync(async () - => await migrationCommandExecutor.ExecuteNonQueryAsync(commandList, fakeConnection))).Message); + (await Assert.ThrowsAsync( + async () + => await migrationCommandExecutor.ExecuteNonQueryAsync(commandList, fakeConnection))).Message); } else { Assert.Equal( RelationalStrings.TransactionSuppressedMigrationInUserTransaction, - Assert.Throws(() - => migrationCommandExecutor.ExecuteNonQuery(commandList, fakeConnection)).Message); + Assert.Throws( + () + => migrationCommandExecutor.ExecuteNonQuery(commandList, fakeConnection)).Message); } tx.Rollback(); @@ -355,13 +356,15 @@ public async Task Disposes_transaction_on_exception(bool async) if (async) { - await Assert.ThrowsAsync(async () - => await migrationCommandExecutor.ExecuteNonQueryAsync(commandList, fakeConnection)); + await Assert.ThrowsAsync( + async () + => await migrationCommandExecutor.ExecuteNonQueryAsync(commandList, fakeConnection)); } else { - Assert.Throws(() - => migrationCommandExecutor.ExecuteNonQuery(commandList, fakeConnection)); + Assert.Throws( + () + => migrationCommandExecutor.ExecuteNonQuery(commandList, fakeConnection)); } Assert.Equal(1, fakeDbConnection.OpenCount); diff --git a/test/EFCore.Relational.Tests/RelationalApiConsistencyTest.cs b/test/EFCore.Relational.Tests/RelationalApiConsistencyTest.cs index 15b0f1a4087..3916535c30d 100644 --- a/test/EFCore.Relational.Tests/RelationalApiConsistencyTest.cs +++ b/test/EFCore.Relational.Tests/RelationalApiConsistencyTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore; -public class RelationalApiConsistencyTest(RelationalApiConsistencyTest.RelationalApiConsistencyFixture fixture) : ApiConsistencyTestBase(fixture) +public class RelationalApiConsistencyTest(RelationalApiConsistencyTest.RelationalApiConsistencyFixture fixture) + : ApiConsistencyTestBase(fixture) { protected override void AddServices(ServiceCollection serviceCollection) => new EntityFrameworkRelationalServicesBuilder(serviceCollection).TryAddCoreServices(); @@ -556,10 +557,11 @@ public class RelationalApiConsistencyFixture : ApiConsistencyFixtureBase nameof(IRelationalConnectionDiagnosticsLogger.ConnectionDisposedAsync)), // internal methods made public for AOT - typeof(ShaperProcessingExpressionVisitor).GetMethod(nameof(ShaperProcessingExpressionVisitor.PopulateSplitIncludeCollectionAsync)), + typeof(ShaperProcessingExpressionVisitor).GetMethod( + nameof(ShaperProcessingExpressionVisitor.PopulateSplitIncludeCollectionAsync)), typeof(ShaperProcessingExpressionVisitor).GetMethod(nameof(ShaperProcessingExpressionVisitor.PopulateSplitCollectionAsync)), typeof(ShaperProcessingExpressionVisitor).GetMethod(nameof(ShaperProcessingExpressionVisitor.TaskAwaiter)), - typeof(RelationalShapedQueryCompilingExpressionVisitor).GetMethod(nameof(RelationalShapedQueryCompilingExpressionVisitor.NonQueryResultAsync)), + typeof(RelationalShapedQueryCompilingExpressionVisitor).GetMethod(nameof(NonQueryResultAsync)), ]; public override HashSet MetadataMethodExceptions { get; } = @@ -576,9 +578,21 @@ public class RelationalApiConsistencyFixture : ApiConsistencyFixtureBase typeof(RelationalMaterializerLiftableConstantContext).GetMethod("set_RelationalDependencies"), typeof(RelationalMaterializerLiftableConstantContext).GetMethod("get_CommandBuilderDependencies"), typeof(RelationalMaterializerLiftableConstantContext).GetMethod("set_CommandBuilderDependencies"), - typeof(RelationalMaterializerLiftableConstantContext).GetMethod("Deconstruct", [typeof(ShapedQueryCompilingExpressionVisitorDependencies).MakeByRefType()]), - typeof(RelationalMaterializerLiftableConstantContext).GetMethod("Deconstruct", [typeof(ShapedQueryCompilingExpressionVisitorDependencies).MakeByRefType(), typeof(RelationalShapedQueryCompilingExpressionVisitorDependencies).MakeByRefType()]), - typeof(RelationalMaterializerLiftableConstantContext).GetMethod("Deconstruct", [typeof(ShapedQueryCompilingExpressionVisitorDependencies).MakeByRefType(), typeof(RelationalShapedQueryCompilingExpressionVisitorDependencies).MakeByRefType(), typeof(RelationalCommandBuilderDependencies).MakeByRefType()]), + typeof(RelationalMaterializerLiftableConstantContext).GetMethod( + "Deconstruct", [typeof(ShapedQueryCompilingExpressionVisitorDependencies).MakeByRefType()]), + typeof(RelationalMaterializerLiftableConstantContext).GetMethod( + "Deconstruct", + [ + typeof(ShapedQueryCompilingExpressionVisitorDependencies).MakeByRefType(), + typeof(RelationalShapedQueryCompilingExpressionVisitorDependencies).MakeByRefType() + ]), + typeof(RelationalMaterializerLiftableConstantContext).GetMethod( + "Deconstruct", + [ + typeof(ShapedQueryCompilingExpressionVisitorDependencies).MakeByRefType(), + typeof(RelationalShapedQueryCompilingExpressionVisitorDependencies).MakeByRefType(), + typeof(RelationalCommandBuilderDependencies).MakeByRefType() + ]), #pragma warning restore EF9100 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. ]; diff --git a/test/EFCore.Relational.Tests/RelationalConnectionTest.cs b/test/EFCore.Relational.Tests/RelationalConnectionTest.cs index e06bf17947a..2d26f147675 100644 --- a/test/EFCore.Relational.Tests/RelationalConnectionTest.cs +++ b/test/EFCore.Relational.Tests/RelationalConnectionTest.cs @@ -901,12 +901,10 @@ public void Can_create_new_connection_with_CommandTimeout_set_to_zero() [ConditionalFact] public void Throws_if_create_new_connection_with_CommandTimeout_negative() - { - Assert.Throws( + => Assert.Throws( () => new FakeRelationalOptionsExtension() .WithConnectionString("Database=FrodoLives") .WithCommandTimeout(-1)); - } [ConditionalFact] public void Can_set_CommandTimeout() diff --git a/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs b/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs index eec5503a85c..a751990e9fc 100644 --- a/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs +++ b/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs @@ -492,9 +492,9 @@ public async Task Throws_when_parameters_are_configured_and_parameter_values_is_ var relationalCommand = CreateRelationalCommand( parameters: new[] { - new TypeMappedRelationalParameter("FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false), + new TypeMappedRelationalParameter("FirstInvariant", "FirstParameter", new IntTypeMapping("int"), false), new TypeMappedRelationalParameter( - "SecondInvariant", "SecondParameter", new LongTypeMapping("long", DbType.Int64), true), + "SecondInvariant", "SecondParameter", new LongTypeMapping("long"), true), new TypeMappedRelationalParameter("ThirdInvariant", "ThirdParameter", RelationalTypeMapping.NullMapping, null) }); @@ -529,9 +529,9 @@ public async Task Throws_when_parameters_are_configured_and_value_is_missing( var relationalCommand = CreateRelationalCommand( parameters: new[] { - new TypeMappedRelationalParameter("FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false), + new TypeMappedRelationalParameter("FirstInvariant", "FirstParameter", new IntTypeMapping("int"), false), new TypeMappedRelationalParameter( - "SecondInvariant", "SecondParameter", new LongTypeMapping("long", DbType.Int64), true), + "SecondInvariant", "SecondParameter", new LongTypeMapping("long"), true), new TypeMappedRelationalParameter("ThirdInvariant", "ThirdParameter", RelationalTypeMapping.NullMapping, null) }); @@ -568,9 +568,9 @@ public async Task Configures_DbCommand_with_type_mapped_parameters( var relationalCommand = CreateRelationalCommand( parameters: new[] { - new TypeMappedRelationalParameter("FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false), + new TypeMappedRelationalParameter("FirstInvariant", "FirstParameter", new IntTypeMapping("int"), false), new TypeMappedRelationalParameter( - "SecondInvariant", "SecondParameter", new LongTypeMapping("long", DbType.Int64), true), + "SecondInvariant", "SecondParameter", new LongTypeMapping("long"), true), new TypeMappedRelationalParameter("ThirdInvariant", "ThirdParameter", RelationalTypeMapping.NullMapping, null) }); @@ -636,9 +636,9 @@ public async Task Configures_DbCommand_with_composite_parameters( new[] { new TypeMappedRelationalParameter( - "FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false), + "FirstInvariant", "FirstParameter", new IntTypeMapping("int"), false), new TypeMappedRelationalParameter( - "SecondInvariant", "SecondParameter", new LongTypeMapping("long", DbType.Int64), true), + "SecondInvariant", "SecondParameter", new LongTypeMapping("long"), true), new TypeMappedRelationalParameter("ThirdInvariant", "ThirdParameter", RelationalTypeMapping.NullMapping, null) }) }); @@ -700,9 +700,9 @@ public async Task Throws_when_composite_parameters_are_configured_and_value_is_m new[] { new TypeMappedRelationalParameter( - "FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false), + "FirstInvariant", "FirstParameter", new IntTypeMapping("int"), false), new TypeMappedRelationalParameter( - "SecondInvariant", "SecondParameter", new LongTypeMapping("long", DbType.Int64), true), + "SecondInvariant", "SecondParameter", new LongTypeMapping("long"), true), new TypeMappedRelationalParameter("ThirdInvariant", "ThirdParameter", RelationalTypeMapping.NullMapping, null) }) }); @@ -745,7 +745,7 @@ public async Task Throws_when_composite_parameters_are_configured_and_value_is_n new[] { new TypeMappedRelationalParameter( - "FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false) + "FirstInvariant", "FirstParameter", new IntTypeMapping("int"), false) }) }); @@ -996,7 +996,7 @@ public async Task Logs_commands_without_parameter_values( parameters: new[] { new TypeMappedRelationalParameter( - "FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false) + "FirstInvariant", "FirstParameter", new IntTypeMapping("int"), false) }); var parameterValues = new Dictionary { { "FirstInvariant", 17 } }; @@ -1054,7 +1054,7 @@ public async Task Logs_commands_parameter_values( parameters: new[] { new TypeMappedRelationalParameter( - "FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false) + "FirstInvariant", "FirstParameter", new IntTypeMapping("int"), false) }); var parameterValues = new Dictionary { { "FirstInvariant", 17 } }; @@ -1113,7 +1113,7 @@ public async Task Reports_command_diagnostic( parameters: new[] { new TypeMappedRelationalParameter( - "FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false) + "FirstInvariant", "FirstParameter", new IntTypeMapping("int"), false) }); var parameterValues = new Dictionary { { "FirstInvariant", 17 } }; @@ -1186,7 +1186,7 @@ public async Task Reports_command_diagnostic_on_exception( parameters: new[] { new TypeMappedRelationalParameter( - "FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false) + "FirstInvariant", "FirstParameter", new IntTypeMapping("int"), false) }); var parameterValues = new Dictionary { { "FirstInvariant", 17 } }; @@ -1265,7 +1265,7 @@ public async Task Reports_command_diagnostic_on_cancellation( parameters: new[] { new TypeMappedRelationalParameter( - "FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false) + "FirstInvariant", "FirstParameter", new IntTypeMapping("int"), false) }); var parameterValues = new Dictionary { { "FirstInvariant", 17 } }; diff --git a/test/EFCore.Relational.Tests/Storage/RelationalParameterBuilderTest.cs b/test/EFCore.Relational.Tests/Storage/RelationalParameterBuilderTest.cs index 47bdee99c40..8be3b7ba3a9 100644 --- a/test/EFCore.Relational.Tests/Storage/RelationalParameterBuilderTest.cs +++ b/test/EFCore.Relational.Tests/Storage/RelationalParameterBuilderTest.cs @@ -96,7 +96,7 @@ public void Can_add_composite_parameter() new TypeMappedRelationalParameter( "FirstInvariant", "FirstName", - new IntTypeMapping("int", DbType.Int32), + new IntTypeMapping("int"), nullable: false), new TypeMappedRelationalParameter( "SecondInvariant", diff --git a/test/EFCore.Relational.Tests/Storage/RelationalTypeMappingTest.cs b/test/EFCore.Relational.Tests/Storage/RelationalTypeMappingTest.cs index 2f24c151101..450d5eb092b 100644 --- a/test/EFCore.Relational.Tests/Storage/RelationalTypeMappingTest.cs +++ b/test/EFCore.Relational.Tests/Storage/RelationalTypeMappingTest.cs @@ -296,7 +296,7 @@ public void Can_create_simple_nullable_parameter() public void Can_create_simple_parameter_with_DbType() { using var command = CreateTestCommand(); - var parameter = new IntTypeMapping("int", DbType.Int32) + var parameter = new IntTypeMapping("int") .CreateParameter(command, "Name", 17, nullable: false); Assert.Equal(ParameterDirection.Input, parameter.Direction); @@ -310,7 +310,7 @@ public void Can_create_simple_parameter_with_DbType() public void Can_create_simple_nullable_parameter_with_DbType() { using var command = CreateTestCommand(); - var parameter = new IntTypeMapping("int", DbType.Int32) + var parameter = new IntTypeMapping("int") .CreateParameter(command, "Name", 17, nullable: true); Assert.Equal(ParameterDirection.Input, parameter.Direction); @@ -374,7 +374,7 @@ public virtual void ByteArray_literal_generated_correctly() [ConditionalFact] public virtual void Byte_literal_generated_correctly() { - var typeMapping = new ByteTypeMapping("byte", DbType.Byte); + var typeMapping = new ByteTypeMapping("byte"); Test_GenerateSqlLiteral_helper(typeMapping, byte.MinValue, "0"); Test_GenerateSqlLiteral_helper(typeMapping, byte.MaxValue, "255"); @@ -421,7 +421,7 @@ public virtual void TimeOnly_literal_generated_correctly() [ConditionalFact] public virtual void Decimal_literal_generated_correctly() { - var typeMapping = new DecimalTypeMapping("decimal", DbType.Decimal); + var typeMapping = new DecimalTypeMapping("decimal"); Test_GenerateSqlLiteral_helper(typeMapping, decimal.MinValue, "-79228162514264337593543950335.0"); Test_GenerateSqlLiteral_helper(typeMapping, decimal.MaxValue, "79228162514264337593543950335.0"); @@ -430,7 +430,7 @@ public virtual void Decimal_literal_generated_correctly() [ConditionalFact] public virtual void Double_literal_generated_correctly() { - var typeMapping = new DoubleTypeMapping("double", DbType.Double); + var typeMapping = new DoubleTypeMapping("double"); Test_GenerateSqlLiteral_helper(typeMapping, double.NaN, "NaN"); Test_GenerateSqlLiteral_helper(typeMapping, double.PositiveInfinity, "Infinity"); @@ -442,7 +442,7 @@ public virtual void Double_literal_generated_correctly() [ConditionalFact] public virtual void Float_literal_generated_correctly() { - var typeMapping = new FloatTypeMapping("float", DbType.Single); + var typeMapping = new FloatTypeMapping("float"); Test_GenerateSqlLiteral_helper(typeMapping, float.NaN, "NaN"); Test_GenerateSqlLiteral_helper(typeMapping, float.PositiveInfinity, "Infinity"); @@ -461,7 +461,7 @@ public virtual void Guid_literal_generated_correctly() [ConditionalFact] public virtual void NullableInt_literal_generated_correctly() { - var typeMapping = new IntTypeMapping("int?", DbType.Int32); + var typeMapping = new IntTypeMapping("int?"); Test_GenerateSqlLiteral_helper(typeMapping, default(int?), "NULL"); Test_GenerateSqlLiteral_helper(typeMapping, (int?)123, "123"); @@ -470,7 +470,7 @@ public virtual void NullableInt_literal_generated_correctly() [ConditionalFact] public virtual void Int_literal_generated_correctly() { - var typeMapping = new IntTypeMapping("int", DbType.Int32); + var typeMapping = new IntTypeMapping("int"); Test_GenerateSqlLiteral_helper(typeMapping, int.MinValue, "-2147483648"); Test_GenerateSqlLiteral_helper(typeMapping, int.MaxValue, "2147483647"); @@ -479,7 +479,7 @@ public virtual void Int_literal_generated_correctly() [ConditionalFact] public virtual void Long_literal_generated_correctly() { - var typeMapping = new LongTypeMapping("long", DbType.Int64); + var typeMapping = new LongTypeMapping("long"); Test_GenerateSqlLiteral_helper(typeMapping, long.MinValue, "-9223372036854775808"); Test_GenerateSqlLiteral_helper(typeMapping, long.MaxValue, "9223372036854775807"); @@ -488,7 +488,7 @@ public virtual void Long_literal_generated_correctly() [ConditionalFact] public virtual void SByte_literal_generated_correctly() { - var typeMapping = new SByteTypeMapping("sbyte", DbType.SByte); + var typeMapping = new SByteTypeMapping("sbyte"); Test_GenerateSqlLiteral_helper(typeMapping, sbyte.MinValue, "-128"); Test_GenerateSqlLiteral_helper(typeMapping, sbyte.MaxValue, "127"); @@ -497,7 +497,7 @@ public virtual void SByte_literal_generated_correctly() [ConditionalFact] public virtual void Short_literal_generated_correctly() { - var typeMapping = new ShortTypeMapping("short", DbType.Int16); + var typeMapping = new ShortTypeMapping("short"); Test_GenerateSqlLiteral_helper(typeMapping, short.MinValue, "-32768"); Test_GenerateSqlLiteral_helper(typeMapping, short.MaxValue, "32767"); @@ -514,7 +514,7 @@ public virtual void Timespan_literal_generated_correctly() [ConditionalFact] public virtual void UInt_literal_generated_correctly() { - var typeMapping = new UIntTypeMapping("uint", DbType.UInt32); + var typeMapping = new UIntTypeMapping("uint"); Test_GenerateSqlLiteral_helper(typeMapping, uint.MinValue, "0"); Test_GenerateSqlLiteral_helper(typeMapping, uint.MaxValue, "4294967295"); @@ -523,7 +523,7 @@ public virtual void UInt_literal_generated_correctly() [ConditionalFact] public virtual void ULong_literal_generated_correctly() { - var typeMapping = new ULongTypeMapping("ulong", DbType.UInt64); + var typeMapping = new ULongTypeMapping("ulong"); Test_GenerateSqlLiteral_helper(typeMapping, ulong.MinValue, "0"); Test_GenerateSqlLiteral_helper(typeMapping, ulong.MaxValue, "18446744073709551615"); @@ -532,7 +532,7 @@ public virtual void ULong_literal_generated_correctly() [ConditionalFact] public virtual void UShort_literal_generated_correctly() { - var typeMapping = new UShortTypeMapping("ushort", DbType.UInt16); + var typeMapping = new UShortTypeMapping("ushort"); Test_GenerateSqlLiteral_helper(typeMapping, ushort.MinValue, "0"); Test_GenerateSqlLiteral_helper(typeMapping, ushort.MaxValue, "65535"); @@ -541,7 +541,7 @@ public virtual void UShort_literal_generated_correctly() [ConditionalFact] public virtual void Double_value_comparer_handles_NaN() { - var typeMapping = new DoubleTypeMapping("double precision", DbType.Double); + var typeMapping = new DoubleTypeMapping("double precision"); Assert.True(typeMapping.Comparer.Equals(3.0, 3.0)); Assert.True(typeMapping.Comparer.Equals(double.NaN, double.NaN)); @@ -551,7 +551,7 @@ public virtual void Double_value_comparer_handles_NaN() [ConditionalFact] public virtual void Float_value_comparer_handles_NaN() { - var typeMapping = new FloatTypeMapping("float", DbType.Single); + var typeMapping = new FloatTypeMapping("float"); Assert.True(typeMapping.Comparer.Equals(3.0f, 3.0f)); Assert.True(typeMapping.Comparer.Equals(float.NaN, float.NaN)); @@ -561,7 +561,7 @@ public virtual void Float_value_comparer_handles_NaN() [ConditionalFact] public virtual void DateTimeOffset_value_comparer_behaves_correctly() { - var typeMapping = new DateTimeOffsetTypeMapping("datetimeoffset", DbType.DateTimeOffset); + var typeMapping = new DateTimeOffsetTypeMapping("datetimeoffset"); var same1 = new DateTimeOffset(2000, 1, 1, 12, 0, 0, TimeSpan.FromHours(0)); var same2 = new DateTimeOffset(2000, 1, 1, 12, 0, 0, TimeSpan.FromHours(0)); diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeCommandExecutor.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeCommandExecutor.cs index 7a22cbea17c..f7ed5444156 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeCommandExecutor.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeCommandExecutor.cs @@ -14,17 +14,22 @@ public class FakeCommandExecutor( Func> executeReaderAsync = null) { private readonly Func _executeNonQuery = executeNonQuery - ?? (c => -1); + ?? (c => -1); + private readonly Func _executeScalar = executeScalar - ?? (c => null); + ?? (c => null); + private readonly Func _executeReader = executeReader - ?? ((c, b) => new FakeDbDataReader()); + ?? ((c, b) => new FakeDbDataReader()); + private readonly Func> _executeNonQueryAsync = executeNonQueryAsync - ?? ((c, ct) => Task.FromResult(-1)); + ?? ((c, ct) => Task.FromResult(-1)); + private readonly Func> _executeScalarAsync = executeScalarAsync - ?? ((c, ct) => Task.FromResult(null)); + ?? ((c, ct) => Task.FromResult(null)); + private readonly Func> _executeReaderAsync = executeReaderAsync - ?? ((c, ct, b) => Task.FromResult(new FakeDbDataReader())); + ?? ((c, ct, b) => Task.FromResult(new FakeDbDataReader())); public virtual int ExecuteNonQuery(FakeDbCommand command) => _executeNonQuery(command); diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalConnection.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalConnection.cs index 482a090304a..98caf4177df 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalConnection.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalConnection.cs @@ -8,33 +8,33 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities.FakeProvider; public class FakeRelationalConnection(IDbContextOptions options = null) : RelationalConnection( - new RelationalConnectionDependencies( - options ?? CreateOptions(), - new DiagnosticsLogger( - new LoggerFactory(), - new LoggingOptions(), - new DiagnosticListener("FakeDiagnosticListener"), - new TestRelationalLoggingDefinitions(), - new NullDbContextLogger()), - new RelationalConnectionDiagnosticsLogger( - new LoggerFactory(), - new LoggingOptions(), - new DiagnosticListener("FakeDiagnosticListener"), - new TestRelationalLoggingDefinitions(), - new NullDbContextLogger(), - CreateOptions()), - new NamedConnectionStringResolver(options ?? CreateOptions()), - new RelationalTransactionFactory( - new RelationalTransactionFactoryDependencies( - new RelationalSqlGenerationHelper( - new RelationalSqlGenerationHelperDependencies()))), - new CurrentDbContext(new FakeDbContext()), - new RelationalCommandBuilderFactory( - new RelationalCommandBuilderDependencies( - new TestRelationalTypeMappingSource( - TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create()), - new ExceptionDetector())))) + new RelationalConnectionDependencies( + options ?? CreateOptions(), + new DiagnosticsLogger( + new LoggerFactory(), + new LoggingOptions(), + new DiagnosticListener("FakeDiagnosticListener"), + new TestRelationalLoggingDefinitions(), + new NullDbContextLogger()), + new RelationalConnectionDiagnosticsLogger( + new LoggerFactory(), + new LoggingOptions(), + new DiagnosticListener("FakeDiagnosticListener"), + new TestRelationalLoggingDefinitions(), + new NullDbContextLogger(), + CreateOptions()), + new NamedConnectionStringResolver(options ?? CreateOptions()), + new RelationalTransactionFactory( + new RelationalTransactionFactoryDependencies( + new RelationalSqlGenerationHelper( + new RelationalSqlGenerationHelperDependencies()))), + new CurrentDbContext(new FakeDbContext()), + new RelationalCommandBuilderFactory( + new RelationalCommandBuilderDependencies( + new TestRelationalTypeMappingSource( + TestServiceFactory.Instance.Create(), + TestServiceFactory.Instance.Create()), + new ExceptionDetector())))) { private DbConnection _connection; diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeRelationalTestHelpers.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeRelationalTestHelpers.cs index 8f1b2ec34a2..56314269ea4 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeRelationalTestHelpers.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeRelationalTestHelpers.cs @@ -25,5 +25,6 @@ public override DbContextOptionsBuilder UseProviderOptions(DbContextOptionsBuild public override LoggingDefinitions LoggingDefinitions { get; } = new TestRelationalLoggingDefinitions(); - public override ModelAsserter ModelAsserter => RelationalModelAsserter.Instance; + public override ModelAsserter ModelAsserter + => RelationalModelAsserter.Instance; } diff --git a/test/EFCore.Relational.Tests/TestUtilities/TestRelationalConventionSetBuilder.cs b/test/EFCore.Relational.Tests/TestUtilities/TestRelationalConventionSetBuilder.cs index de75c775256..11916686c0a 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/TestRelationalConventionSetBuilder.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/TestRelationalConventionSetBuilder.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities; public class TestRelationalConventionSetBuilder( ProviderConventionSetBuilderDependencies dependencies, - RelationalConventionSetBuilderDependencies relationalDependencies) : RelationalConventionSetBuilder(dependencies, relationalDependencies) + RelationalConventionSetBuilderDependencies relationalDependencies) + : RelationalConventionSetBuilder(dependencies, relationalDependencies) { public static ConventionSet Build() => ConventionSet.CreateConventionSet(FakeRelationalTestHelpers.Instance.CreateContext()); diff --git a/test/EFCore.Relational.Tests/TestUtilities/TestRelationalTypeMappingSource.cs b/test/EFCore.Relational.Tests/TestUtilities/TestRelationalTypeMappingSource.cs index 3db839763b7..b200bc67402 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/TestRelationalTypeMappingSource.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/TestRelationalTypeMappingSource.cs @@ -124,14 +124,14 @@ private class TestStringTypeMapping( bool unicode = false, int? size = null, bool fixedLength = false) : StringTypeMapping( - new RelationalTypeMappingParameters( - new CoreTypeMappingParameters(typeof(string)), - storeType, - StoreTypePostfix.None, - dbType, - unicode, - size, - fixedLength)) + new RelationalTypeMappingParameters( + new CoreTypeMappingParameters(typeof(string)), + storeType, + StoreTypePostfix.None, + dbType, + unicode, + size, + fixedLength)) { protected override string ProcessStoreType( RelationalTypeMappingParameters parameters, diff --git a/test/EFCore.Specification.Tests/ApiConsistencyTestBase.cs b/test/EFCore.Specification.Tests/ApiConsistencyTestBase.cs index c9e63d3b76e..531aaeccc5f 100644 --- a/test/EFCore.Specification.Tests/ApiConsistencyTestBase.cs +++ b/test/EFCore.Specification.Tests/ApiConsistencyTestBase.cs @@ -580,14 +580,14 @@ private string ValidateConventionBuilderMethods(IReadOnlyList method var expectedName = methodName.StartsWith("HasNo", StringComparison.Ordinal) ? "CanRemove" + methodName[5..] : "CanSet" - + (methodName.StartsWith("Has", StringComparison.Ordinal) - || methodName.StartsWith("Use", StringComparison.Ordinal) - ? methodName[3..] - : methodName.StartsWith("To", StringComparison.Ordinal) - ? methodName[2..] - : methodName.StartsWith("With", StringComparison.Ordinal) - ? methodName[4..] - : methodName); + + (methodName.StartsWith("Has", StringComparison.Ordinal) + || methodName.StartsWith("Use", StringComparison.Ordinal) + ? methodName[3..] + : methodName.StartsWith("To", StringComparison.Ordinal) + ? methodName[2..] + : methodName.StartsWith("With", StringComparison.Ordinal) + ? methodName[4..] + : methodName); if (!methodLookup.TryGetValue(expectedName, out var canSetMethod)) { @@ -1245,9 +1245,7 @@ public int GetHashCode(Type obj) public abstract class ApiConsistencyFixtureBase { protected ApiConsistencyFixtureBase() - { - Initialize(); - } + => Initialize(); public virtual HashSet FluentApiTypes { get; } = []; @@ -1284,25 +1282,26 @@ protected ApiConsistencyFixtureBase() public virtual Dictionary> UnmatchedMirrorMethods { get; } = new(); public virtual Dictionary MetadataMethodNameTransformers { get; } = new(); public virtual HashSet MetadataMethodExceptions { get; } = []; + public virtual HashSet VirtualMethodExceptions { get; } = - [ + [ // un-sealed record #pragma warning disable EF9100 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. typeof(MaterializerLiftableConstantContext).GetMethod("get_Dependencies"), typeof(MaterializerLiftableConstantContext).GetMethod("set_Dependencies"), typeof(MaterializerLiftableConstantContext).GetMethod("Deconstruct"), #pragma warning restore EF9100 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. - ]; + ]; public virtual HashSet ComputedDependencyProperties { get; } = - [ - typeof(ProviderConventionSetBuilderDependencies).GetProperty( - nameof(ProviderConventionSetBuilderDependencies.ContextType)), - typeof(QueryCompilationContextDependencies).GetProperty(nameof(QueryCompilationContextDependencies.ContextType)), - typeof(QueryCompilationContextDependencies).GetProperty( - nameof(QueryCompilationContextDependencies.QueryTrackingBehavior)), - typeof(QueryContextDependencies).GetProperty(nameof(QueryContextDependencies.StateManager)) - ]; + [ + typeof(ProviderConventionSetBuilderDependencies).GetProperty( + nameof(ProviderConventionSetBuilderDependencies.ContextType)), + typeof(QueryCompilationContextDependencies).GetProperty(nameof(QueryCompilationContextDependencies.ContextType)), + typeof(QueryCompilationContextDependencies).GetProperty( + nameof(QueryCompilationContextDependencies.QueryTrackingBehavior)), + typeof(QueryContextDependencies).GetProperty(nameof(QueryContextDependencies.StateManager)) + ]; public Dictionary MetadataTypes { get; } = new() @@ -1440,7 +1439,8 @@ protected static MethodInfo GetMethod( string name, int genericParameterCount, Func parameterGenerator) - => type.GetGenericMethod(name, + => type.GetGenericMethod( + name, genericParameterCount, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly, parameterGenerator); diff --git a/test/EFCore.Specification.Tests/BadDataJsonDeserializationTestBase.cs b/test/EFCore.Specification.Tests/BadDataJsonDeserializationTestBase.cs index bda389f7d88..5389827a391 100644 --- a/test/EFCore.Specification.Tests/BadDataJsonDeserializationTestBase.cs +++ b/test/EFCore.Specification.Tests/BadDataJsonDeserializationTestBase.cs @@ -165,9 +165,9 @@ protected virtual void Throws_for_bad_JSON_value( } protected class SingleTypeDbContext( - Action buildOptions, - Action buildModel, - Action? configureConventions = null) + Action buildOptions, + Action buildModel, + Action? configureConventions = null) : DbContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) diff --git a/test/EFCore.Specification.Tests/BuiltInDataTypesTestBase.cs b/test/EFCore.Specification.Tests/BuiltInDataTypesTestBase.cs index 9387b221d41..ada9f374292 100644 --- a/test/EFCore.Specification.Tests/BuiltInDataTypesTestBase.cs +++ b/test/EFCore.Specification.Tests/BuiltInDataTypesTestBase.cs @@ -2341,39 +2341,41 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb.HasData( new sbyte[] { -10, -7, -4, -3, -2, -1, 0, 1, 2, 3, 8, 15 } - .Select((x, i) => - new BuiltInDataTypes - { - Id = 17 + i, - PartitionId = 2, - TestInt16 = x, - TestInt32 = x, - TestInt64 = x, - TestDouble = x * 0.25, - TestDecimal = x * 0.2M, - TestDateTime = DateTime.Parse("01/01/2000 12:34:56"), - TestDateTimeOffset = new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)), - TestTimeSpan = new TimeSpan(0, 10, 9, 8, 7), - TestDateOnly = new DateOnly(2020, 3, 1), - TestTimeOnly = new TimeOnly(12, 30, 45, 123), - TestSingle = x * 0.25F, - TestBoolean = x > 0, - TestByte = (byte)(10 + x), - TestUnsignedInt16 = (byte)(10 + x), - TestUnsignedInt32 = (byte)(10 + x), - TestUnsignedInt64 = (byte)(10 + x), - TestCharacter = 'a', - TestSignedByte = x, - Enum64 = Enum64.SomeValue, - Enum32 = Enum32.SomeValue, - Enum16 = Enum16.SomeValue, - Enum8 = Enum8.SomeValue, - EnumU64 = EnumU64.SomeValue, - EnumU32 = EnumU32.SomeValue, - EnumU16 = EnumU16.SomeValue, - EnumS8 = EnumS8.SomeValue - } - ) + .Select( + (x, i) => + new BuiltInDataTypes + { + Id = 17 + i, + PartitionId = 2, + TestInt16 = x, + TestInt32 = x, + TestInt64 = x, + TestDouble = x * 0.25, + TestDecimal = x * 0.2M, + TestDateTime = DateTime.Parse("01/01/2000 12:34:56"), + TestDateTimeOffset = + new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)), + TestTimeSpan = new TimeSpan(0, 10, 9, 8, 7), + TestDateOnly = new DateOnly(2020, 3, 1), + TestTimeOnly = new TimeOnly(12, 30, 45, 123), + TestSingle = x * 0.25F, + TestBoolean = x > 0, + TestByte = (byte)(10 + x), + TestUnsignedInt16 = (byte)(10 + x), + TestUnsignedInt32 = (byte)(10 + x), + TestUnsignedInt64 = (byte)(10 + x), + TestCharacter = 'a', + TestSignedByte = x, + Enum64 = Enum64.SomeValue, + Enum32 = Enum32.SomeValue, + Enum16 = Enum16.SomeValue, + Enum8 = Enum8.SomeValue, + EnumU64 = EnumU64.SomeValue, + EnumU32 = EnumU32.SomeValue, + EnumU16 = EnumU16.SomeValue, + EnumS8 = EnumS8.SomeValue + } + ) ); eb.Property(e => e.Id).ValueGeneratedNever(); @@ -2416,38 +2418,39 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb.HasData( new sbyte?[] { null, -10, -7, -4, -3, -2, -1, 0, 1, 2, 3, 8, 15 } - .Select((x, i) => - new BuiltInNullableDataTypes - { - Id = 17 + i, - PartitionId = 2, - TestNullableInt16 = x, - TestNullableInt32 = x, - TestNullableInt64 = x, - TestNullableDouble = x * 0.25, - TestNullableDecimal = x * 0.2M, - TestNullableDateTimeOffset = new DateTimeOffset(new DateTime(), TimeSpan.FromHours(-8.0)), - TestNullableTimeSpan = new TimeSpan(0, 10, 9, 8, 7), - TestNullableDateOnly = new DateOnly(2020, 3, 1), - TestNullableTimeOnly = new TimeOnly(12, 30, 45, 123), - TestNullableSingle = x * 0.25F, - TestNullableBoolean = x == null ? null : x > 0, - TestNullableByte = (byte?)(10 + x), - TestNullableUnsignedInt16 = (byte?)(10 + x), - TestNullableUnsignedInt32 = (byte?)(10 + x), - TestNullableUnsignedInt64 = (byte?)(10 + x), - TestNullableCharacter = 'a', - TestNullableSignedByte = x, - Enum64 = Enum64.SomeValue, - Enum32 = Enum32.SomeValue, - Enum16 = Enum16.SomeValue, - Enum8 = Enum8.SomeValue, - EnumU64 = EnumU64.SomeValue, - EnumU32 = EnumU32.SomeValue, - EnumU16 = EnumU16.SomeValue, - EnumS8 = EnumS8.SomeValue - } - ) + .Select( + (x, i) => + new BuiltInNullableDataTypes + { + Id = 17 + i, + PartitionId = 2, + TestNullableInt16 = x, + TestNullableInt32 = x, + TestNullableInt64 = x, + TestNullableDouble = x * 0.25, + TestNullableDecimal = x * 0.2M, + TestNullableDateTimeOffset = new DateTimeOffset(new DateTime(), TimeSpan.FromHours(-8.0)), + TestNullableTimeSpan = new TimeSpan(0, 10, 9, 8, 7), + TestNullableDateOnly = new DateOnly(2020, 3, 1), + TestNullableTimeOnly = new TimeOnly(12, 30, 45, 123), + TestNullableSingle = x * 0.25F, + TestNullableBoolean = x == null ? null : x > 0, + TestNullableByte = (byte?)(10 + x), + TestNullableUnsignedInt16 = (byte?)(10 + x), + TestNullableUnsignedInt32 = (byte?)(10 + x), + TestNullableUnsignedInt64 = (byte?)(10 + x), + TestNullableCharacter = 'a', + TestNullableSignedByte = x, + Enum64 = Enum64.SomeValue, + Enum32 = Enum32.SomeValue, + Enum16 = Enum16.SomeValue, + Enum8 = Enum8.SomeValue, + EnumU64 = EnumU64.SomeValue, + EnumU32 = EnumU32.SomeValue, + EnumU16 = EnumU16.SomeValue, + EnumS8 = EnumS8.SomeValue + } + ) ); eb.Property(e => e.Id).ValueGeneratedNever(); diff --git a/test/EFCore.Specification.Tests/BulkUpdates/ComplexTypeBulkUpdatesTestBase.cs b/test/EFCore.Specification.Tests/BulkUpdates/ComplexTypeBulkUpdatesTestBase.cs index 9c5224e2fa6..763af7947b9 100644 --- a/test/EFCore.Specification.Tests/BulkUpdates/ComplexTypeBulkUpdatesTestBase.cs +++ b/test/EFCore.Specification.Tests/BulkUpdates/ComplexTypeBulkUpdatesTestBase.cs @@ -106,11 +106,7 @@ public virtual Task Update_complex_type_to_parameter(bool async) AddressLine1 = "New AddressLine1", AddressLine2 = "New AddressLine2", ZipCode = 99999, - Country = new() - { - Code = "FR", - FullName = "France" - }, + Country = new Country { Code = "FR", FullName = "France" }, Tags = new List { "new_tag1", "new_tag2" } }; @@ -126,11 +122,7 @@ public virtual Task Update_complex_type_to_parameter(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Update_nested_complex_type_to_parameter(bool async) { - var newCountry = new Country - { - Code = "FR", - FullName = "France" - }; + var newCountry = new Country { Code = "FR", FullName = "France" }; return AssertUpdate( async, @@ -157,18 +149,15 @@ public virtual Task Update_complex_type_to_inline_without_lambda(bool async) async, ss => ss.Set(), c => c, - s => s.SetProperty(x => x.ShippingAddress, new Address - { - AddressLine1 = "New AddressLine1", - AddressLine2 = "New AddressLine2", - ZipCode = 99999, - Country = new() + s => s.SetProperty( + x => x.ShippingAddress, new Address { - Code = "FR", - FullName = "France" - }, - Tags = new List { "new_tag1", "new_tag2" } - }), + AddressLine1 = "New AddressLine1", + AddressLine2 = "New AddressLine2", + ZipCode = 99999, + Country = new Country { Code = "FR", FullName = "France" }, + Tags = new List { "new_tag1", "new_tag2" } + }), rowsAffectedCount: 3); [ConditionalTheory] @@ -178,18 +167,15 @@ public virtual Task Update_complex_type_to_inline_with_lambda(bool async) async, ss => ss.Set(), c => c, - s => s.SetProperty(x => x.ShippingAddress, x => new Address - { - AddressLine1 = "New AddressLine1", - AddressLine2 = "New AddressLine2", - ZipCode = 99999, - Country = new() + s => s.SetProperty( + x => x.ShippingAddress, x => new Address { - Code = "FR", - FullName = "France" - }, - Tags = new List { "new_tag1", "new_tag2" } - }), + AddressLine1 = "New AddressLine1", + AddressLine2 = "New AddressLine2", + ZipCode = 99999, + Country = new Country { Code = "FR", FullName = "France" }, + Tags = new List { "new_tag1", "new_tag2" } + }), rowsAffectedCount: 3); [ConditionalTheory] diff --git a/test/EFCore.Specification.Tests/BulkUpdates/InheritanceBulkUpdatesTestBase.cs b/test/EFCore.Specification.Tests/BulkUpdates/InheritanceBulkUpdatesTestBase.cs index 195b23bd23e..d020ebb7c58 100644 --- a/test/EFCore.Specification.Tests/BulkUpdates/InheritanceBulkUpdatesTestBase.cs +++ b/test/EFCore.Specification.Tests/BulkUpdates/InheritanceBulkUpdatesTestBase.cs @@ -185,4 +185,5 @@ public virtual Task Update_with_interface_in_EF_Property_in_property_expression( e => e, // ReSharper disable once RedundantCast s => s.SetProperty(c => EF.Property((ISugary)c, nameof(ISugary.SugarGrams)), 0), - rowsAffectedCount: 1);} + rowsAffectedCount: 1); +} diff --git a/test/EFCore.Specification.Tests/BulkUpdates/NonSharedModelBulkUpdatesTestBase.cs b/test/EFCore.Specification.Tests/BulkUpdates/NonSharedModelBulkUpdatesTestBase.cs index c5cca8e6334..21099591a5f 100644 --- a/test/EFCore.Specification.Tests/BulkUpdates/NonSharedModelBulkUpdatesTestBase.cs +++ b/test/EFCore.Specification.Tests/BulkUpdates/NonSharedModelBulkUpdatesTestBase.cs @@ -296,8 +296,6 @@ public class Post public virtual Blog Blog { get; set; } } -#nullable disable - #region HelperMethods public Task AssertDelete( diff --git a/test/EFCore.Specification.Tests/ComplexTypesTrackingTestBase.cs b/test/EFCore.Specification.Tests/ComplexTypesTrackingTestBase.cs index 0e855cc7871..c7c372ee85d 100644 --- a/test/EFCore.Specification.Tests/ComplexTypesTrackingTestBase.cs +++ b/test/EFCore.Specification.Tests/ComplexTypesTrackingTestBase.cs @@ -997,8 +997,9 @@ protected void AssertPropertiesModified(EntityEntry entry, bool expected) protected static EntityEntry TrackFromQuery(DbContext context, TEntity pub) where TEntity : class - => new(context.GetService().StartTrackingFromQuery( - context.Model.FindEntityType(typeof(TEntity))!, pub, Snapshot.Empty)); + => new( + context.GetService().StartTrackingFromQuery( + context.Model.FindEntityType(typeof(TEntity))!, pub, Snapshot.Empty)); protected virtual Task ExecuteWithStrategyInTransactionAsync( Func testOperation, diff --git a/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs b/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs index d06679043d2..5dffaf88d9a 100644 --- a/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs +++ b/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs @@ -179,7 +179,6 @@ public virtual async Task Can_query_and_update_with_conversion_for_custom_type() protected class User(Email email) { - // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Local public Guid Id { get; private set; } = Guid.NewGuid(); @@ -192,9 +191,7 @@ protected class Email private readonly string _value; private Email(string value) - { - _value = value; - } + => _value = value; public override bool Equals(object obj) => _value == ((Email)obj)?._value; @@ -344,9 +341,7 @@ public class Order public struct OrderId { private OrderId(string stringValue) - { - StringValue = stringValue; - } + => StringValue = stringValue; public string StringValue { get; } diff --git a/test/EFCore.Specification.Tests/F1FixtureBase.cs b/test/EFCore.Specification.Tests/F1FixtureBase.cs index b785fcfc11e..cf5f697c7ed 100644 --- a/test/EFCore.Specification.Tests/F1FixtureBase.cs +++ b/test/EFCore.Specification.Tests/F1FixtureBase.cs @@ -17,26 +17,28 @@ protected override bool UsePooling public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder) .UseModel(CreateModelExternal()) - .UseSeeding((c, _) => - { - if (!ShouldSeed((F1Context)c)) + .UseSeeding( + (c, _) => { - return; - } - - F1Context.AddSeedData((F1Context)c); - c.SaveChanges(); - }) - .UseAsyncSeeding(async (c, _, t) => - { - if (!await ShouldSeedAsync((F1Context)c)) + if (!ShouldSeed((F1Context)c)) + { + return; + } + + F1Context.AddSeedData((F1Context)c); + c.SaveChanges(); + }) + .UseAsyncSeeding( + async (c, _, t) => { - return; - } + if (!await ShouldSeedAsync((F1Context)c)) + { + return; + } - F1Context.AddSeedData((F1Context)c); - await c.SaveChangesAsync(t); - }) + F1Context.AddSeedData((F1Context)c); + await c.SaveChangesAsync(t); + }) .ConfigureWarnings( w => w.Ignore(CoreEventId.SaveChangesStarting, CoreEventId.SaveChangesCompleted)); diff --git a/test/EFCore.Specification.Tests/FindTestBase.cs b/test/EFCore.Specification.Tests/FindTestBase.cs index 3618da38e09..d12e516facd 100644 --- a/test/EFCore.Specification.Tests/FindTestBase.cs +++ b/test/EFCore.Specification.Tests/FindTestBase.cs @@ -1,11 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable disable + using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -#nullable disable - // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore { @@ -817,13 +817,13 @@ protected override Task SeedAsync(PoolableDbContext context) { Id = 77, Foo = "Smokey", - OwnedReference = new() + OwnedReference = new Owned1 { Prop = 7, - NestedOwned = new() { Prop = "7" }, - NestedOwnedCollection = new() { new() { Prop = "71" }, new() { Prop = "72" } } + NestedOwned = new Owned2 { Prop = "7" }, + NestedOwnedCollection = new List { new() { Prop = "71" }, new() { Prop = "72" } } }, - OwnedCollection = new() { new() { Prop = 71 }, new() { Prop = 72 } } + OwnedCollection = new List { new Owned1 { Prop = 71 }, new Owned1 { Prop = 72 } } }, new NullableIntKey { Id = 77, Foo = "Smokey" }, new StringKey { Id = "Cat", Foo = "Alice" }, diff --git a/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBase.cs b/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBase.cs index ec390202571..83ed6b1d7f0 100644 --- a/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBase.cs +++ b/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBase.cs @@ -898,15 +898,23 @@ protected virtual IQueryable ModifyQueryRoot(IQueryable query) protected virtual OwnerRoot CreateOwnerRoot() => new() { - OptionalSingle = new() { Name = "OS", Single = new() { Name = "OS2" } }, - RequiredSingle = new() { Name = "RS", Single = new() { Name = "RS2 " } }, + OptionalSingle = new OwnedOptionalSingle1 { Name = "OS", Single = new OwnedOptionalSingle2 { Name = "OS2" } }, + RequiredSingle = new OwnedRequiredSingle1 { Name = "RS", Single = new OwnedRequiredSingle2 { Name = "RS2 " } }, OptionalChildren = { - new() { Name = "OC1" }, new() { Name = "OC2", Children = { new() { Name = "OCC1" }, new() { Name = "OCC2" } } } + new OwnedOptional1 { Name = "OC1" }, + new OwnedOptional1 + { + Name = "OC2", Children = { new OwnedOptional2 { Name = "OCC1" }, new OwnedOptional2 { Name = "OCC2" } } + } }, RequiredChildren = { - new() { Name = "RC1", Children = { new() { Name = "RCC1" }, new() { Name = "RCC2" } } }, new() { Name = "RC2" } + new OwnedRequired1 + { + Name = "RC1", Children = { new OwnedRequired2 { Name = "RCC1" }, new OwnedRequired2 { Name = "RCC2" } } + }, + new OwnedRequired1 { Name = "RC2" } } }; diff --git a/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBaseMiscellaneous.cs b/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBaseMiscellaneous.cs index 33c7d260379..f5118d9c36f 100644 --- a/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBaseMiscellaneous.cs +++ b/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBaseMiscellaneous.cs @@ -134,7 +134,7 @@ public virtual Task Can_insert_when_nullable_bool_PK_in_composite_key_has_sentin protected async Task Can_insert_when_PK_property_in_composite_key_has_sentinel_value(bool async, T initialValue) where T : new() { - var inserted = new CompositeKeyWith() + var inserted = new CompositeKeyWith { SourceId = Guid.NewGuid(), TargetId = Guid.NewGuid(), @@ -184,7 +184,7 @@ public virtual Task Throws_for_single_property_nullable_bool_key_with_default_va protected async Task Throws_for_single_property_key_with_default_value_generation(bool async, T initialValue) where T : new() { - var inserted = new BoolOnlyKey() { PrimaryGroup = initialValue }; + var inserted = new BoolOnlyKey { PrimaryGroup = initialValue }; await ExecuteWithStrategyInTransactionAsync( async context => @@ -410,7 +410,7 @@ public virtual async Task Clearing_shadow_key_owned_collection_throws(bool async } owner.OwnedCollection = addNew - ? [new(), new()] + ? [new Owned(), new Owned()] : new List(); Assert.Equal( @@ -636,11 +636,11 @@ public virtual async Task Clearing_CLR_key_owned_collection(bool async, bool use } owner.OwnedCollection = addNew - ? [new() { Bar = "OfGold" }, new() { Bar = "OfSoap" }] + ? [new OwnedWithKey { Bar = "OfGold" }, new OwnedWithKey { Bar = "OfSoap" }] : new List(); owner.OwnedCollectionPrivateKey = addNew - ? [new() { Bar = "OfChocolate" }, new() { Bar = "OfLead" }] + ? [new OwnedWithPrivateKey { Bar = "OfChocolate" }, new OwnedWithPrivateKey { Bar = "OfLead" }] : new List(); if (async) @@ -1766,8 +1766,8 @@ public virtual Task Save_changed_owned_one_to_one() context.Entry(root.RequiredSingle).State = EntityState.Deleted; } - root.OptionalSingle = new() { Name = "OS`", Single = new() { Name = "OS2`" } }; - root.RequiredSingle = new() { Name = "RS`", Single = new() { Name = "RS2`" } }; + root.OptionalSingle = new OwnedOptionalSingle1 { Name = "OS`", Single = new OwnedOptionalSingle2 { Name = "OS2`" } }; + root.RequiredSingle = new OwnedRequiredSingle1 { Name = "RS`", Single = new OwnedRequiredSingle2 { Name = "RS2`" } }; Assert.True(context.ChangeTracker.HasChanges()); @@ -1812,10 +1812,18 @@ public virtual Task Save_changed_owned_one_to_many() root.OptionalChildren.Remove(optionalChildren); root.RequiredChildren.Remove(requiredChildren); - root.OptionalChildren.First().Children.Add(new() { Name = "OCC3" }); - root.OptionalChildren.Add(new() { Name = "OC3", Children = { new() { Name = "OCC4" }, new() { Name = "OCC5" } } }); - root.RequiredChildren.First().Children.Add(new() { Name = "RCC3" }); - root.RequiredChildren.Add(new() { Name = "RC3", Children = { new() { Name = "RCC4" }, new() { Name = "RCC5" } } }); + root.OptionalChildren.First().Children.Add(new OwnedOptional2 { Name = "OCC3" }); + root.OptionalChildren.Add( + new OwnedOptional1 + { + Name = "OC3", Children = { new OwnedOptional2 { Name = "OCC4" }, new OwnedOptional2 { Name = "OCC5" } } + }); + root.RequiredChildren.First().Children.Add(new OwnedRequired2 { Name = "RCC3" }); + root.RequiredChildren.Add( + new OwnedRequired1 + { + Name = "RC3", Children = { new OwnedRequired2 { Name = "RCC4" }, new OwnedRequired2 { Name = "RCC5" } } + }); Assert.True(context.ChangeTracker.HasChanges()); @@ -2292,7 +2300,7 @@ public virtual Task Mark_explicitly_set_stable_dependent_appropriately(bool asyn ? await context.FindAsync(parentId) : context.Find(parentId); - var child = new StableChild32084() + var child = new StableChild32084 { Id = childId, ParentId = parent!.Id, }; diff --git a/test/EFCore.Specification.Tests/JsonTypesTestBase.cs b/test/EFCore.Specification.Tests/JsonTypesTestBase.cs index 3316bab9453..c0096a11891 100644 --- a/test/EFCore.Specification.Tests/JsonTypesTestBase.cs +++ b/test/EFCore.Specification.Tests/JsonTypesTestBase.cs @@ -1321,7 +1321,7 @@ public class NullablePointType } [ConditionalFact] - public async virtual Task Can_read_write_point_with_Z() + public virtual async Task Can_read_write_point_with_Z() { var factory = NtsGeometryServices.Instance.CreateGeometryFactory(srid: 4326); @@ -1703,7 +1703,7 @@ public virtual Task Can_read_write_custom_converted_type_JSON_values(string valu b => b.Entity().HasNoKey().Property(e => e.Address), b => b.Properties().HaveConversion(), nameof(IpAddressType.Address), - new(IPAddress.Parse(value)), + new IpAddress(IPAddress.Parse(value)), json); protected class IpAddressConverter() : ValueConverter( @@ -1767,7 +1767,8 @@ protected class Int16CollectionType public virtual Task Can_read_write_collection_of_int_JSON_values() => Can_read_and_write_JSON_value>( nameof(Int32CollectionType.Int32), - new ReadOnlyCollection([ + new ReadOnlyCollection( + [ int.MinValue, 0, int.MaxValue @@ -1924,7 +1925,7 @@ public virtual Task Can_read_write_collection_of_DateOnly_JSON_values() nameof(DateOnlyCollectionType.DateOnly), [ DateOnly.MinValue, - new(2023, 5, 29), + new DateOnly(2023, 5, 29), DateOnly.MaxValue ], """{"Prop":["0001-01-01","2023-05-29","9999-12-31"]}""", @@ -1941,7 +1942,7 @@ public virtual Task Can_read_write_collection_of_TimeOnly_JSON_values() nameof(TimeOnlyCollectionType.TimeOnly), [ TimeOnly.MinValue, - new(11, 5, 2, 3, 4), + new TimeOnly(11, 5, 2, 3, 4), TimeOnly.MaxValue ], """{"Prop":["00:00:00.0000000","11:05:02.0030040","23:59:59.9999999"]}""", @@ -1960,7 +1961,7 @@ public virtual Task Can_read_write_collection_of_DateTime_JSON_values(string exp nameof(DateTimeCollectionType.DateTime), [ DateTime.MinValue, - new(2023, 5, 29, 10, 52, 47), + new DateTime(2023, 5, 29, 10, 52, 47), DateTime.MaxValue ], expected, @@ -1972,15 +1973,16 @@ protected class DateTimeCollectionType } [ConditionalTheory] - [InlineData("""{"Prop":["0001-01-01T00:00:00+00:00","2023-05-29T10:52:47-02:00","2023-05-29T10:52:47+00:00","2023-05-29T10:52:47+02:00","9999-12-31T23:59:59.9999999+00:00"]}""")] + [InlineData( + """{"Prop":["0001-01-01T00:00:00+00:00","2023-05-29T10:52:47-02:00","2023-05-29T10:52:47+00:00","2023-05-29T10:52:47+02:00","9999-12-31T23:59:59.9999999+00:00"]}""")] public virtual Task Can_read_write_collection_of_DateTimeOffset_JSON_values(string expected) => Can_read_and_write_JSON_value>( nameof(DateTimeOffsetCollectionType.DateTimeOffset), [ DateTimeOffset.MinValue, - new(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(-2, 0, 0)), - new(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(0, 0, 0)), - new(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(2, 0, 0)), + new DateTimeOffset(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(-2, 0, 0)), + new DateTimeOffset(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(0, 0, 0)), + new DateTimeOffset(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(2, 0, 0)), DateTimeOffset.MaxValue ], expected, @@ -1997,7 +1999,7 @@ public virtual Task Can_read_write_collection_of_TimeSpan_JSON_values() nameof(TimeSpanCollectionType.TimeSpan), [ TimeSpan.MinValue, - new(1, 2, 3, 4, 5), + new TimeSpan(1, 2, 3, 4, 5), TimeSpan.MaxValue ], """{"Prop":["-10675199:2:48:05.4775808","1:2:03:04.005","10675199:2:48:05.4775807"]}""", @@ -2039,13 +2041,14 @@ protected class CharacterCollectionType } [ConditionalTheory] - [InlineData("""{"Prop":["00000000-0000-0000-0000-000000000000","8c44242f-8e3f-4a20-8be8-98c7c1aadebd","ffffffff-ffff-ffff-ffff-ffffffffffff"]}""")] + [InlineData( + """{"Prop":["00000000-0000-0000-0000-000000000000","8c44242f-8e3f-4a20-8be8-98c7c1aadebd","ffffffff-ffff-ffff-ffff-ffffffffffff"]}""")] public virtual Task Can_read_write_collection_of_GUID_JSON_values(string expected) => Can_read_and_write_JSON_value>( nameof(GuidCollectionType.Guid), [ - new(), - new("8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD"), + new Guid(), + new Guid("8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD"), Guid.Parse("FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF") ], expected, @@ -2097,8 +2100,8 @@ public virtual Task Can_read_write_collection_of_URI_JSON_values() => Can_read_and_write_JSON_value>( nameof(UriCollectionType.Uri), [ - new("https://user:password@www.contoso.com:80/Home/Index.htm?q1=v1&q2=v2#FragmentName"), - new("file:///C:/test/path/file.txt") + new Uri("https://user:password@www.contoso.com:80/Home/Index.htm?q1=v1&q2=v2#FragmentName"), + new Uri("file:///C:/test/path/file.txt") ], """{"Prop":["https://user:password@www.contoso.com:80/Home/Index.htm?q1=v1\u0026q2=v2#FragmentName","file:///C:/test/path/file.txt"]}""", mappedCollection: true); @@ -2112,7 +2115,8 @@ protected class UriCollectionType public virtual Task Can_read_write_collection_of_IP_address_JSON_values() => Can_read_and_write_JSON_value>( nameof(IpAddressCollectionType.IpAddress), - new ReadOnlyCollection([ + new ReadOnlyCollection( + [ IPAddress.Parse("127.0.0.1"), IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255"), @@ -2506,7 +2510,7 @@ public virtual Task Can_read_write_collection_of_nullable_DateOnly_JSON_values() nameof(NullableDateOnlyCollectionType.DateOnly), [ DateOnly.MinValue, - new(2023, 5, 29), + new DateOnly(2023, 5, 29), DateOnly.MaxValue, null ], @@ -2525,7 +2529,7 @@ public virtual Task Can_read_write_collection_of_nullable_TimeOnly_JSON_values() [ null, TimeOnly.MinValue, - new(11, 5, 2, 3, 4), + new TimeOnly(11, 5, 2, 3, 4), TimeOnly.MaxValue ], """{"Prop":[null,"00:00:00.0000000","11:05:02.0030040","23:59:59.9999999"]}""", @@ -2544,7 +2548,7 @@ public virtual Task Can_read_write_collection_of_nullable_DateTime_JSON_values(s [ DateTime.MinValue, null, - new(2023, 5, 29, 10, 52, 47), + new DateTime(2023, 5, 29, 10, 52, 47), DateTime.MaxValue ], expected, @@ -2556,16 +2560,17 @@ protected class NullableDateTimeCollectionType } [ConditionalTheory] - [InlineData("""{"Prop":["0001-01-01T00:00:00+00:00","2023-05-29T10:52:47-02:00","2023-05-29T10:52:47+00:00",null,"2023-05-29T10:52:47+02:00","9999-12-31T23:59:59.9999999+00:00"]}""")] + [InlineData( + """{"Prop":["0001-01-01T00:00:00+00:00","2023-05-29T10:52:47-02:00","2023-05-29T10:52:47+00:00",null,"2023-05-29T10:52:47+02:00","9999-12-31T23:59:59.9999999+00:00"]}""")] public virtual Task Can_read_write_collection_of_nullable_DateTimeOffset_JSON_values(string expected) => Can_read_and_write_JSON_value>( nameof(NullableDateTimeOffsetCollectionType.DateTimeOffset), [ DateTimeOffset.MinValue, - new(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(-2, 0, 0)), - new(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(0, 0, 0)), + new DateTimeOffset(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(-2, 0, 0)), + new DateTimeOffset(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(0, 0, 0)), null, - new(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(2, 0, 0)), + new DateTimeOffset(new DateTime(2023, 5, 29, 10, 52, 47), new TimeSpan(2, 0, 0)), DateTimeOffset.MaxValue ], expected, @@ -2582,7 +2587,7 @@ public virtual Task Can_read_write_collection_of_nullable_TimeSpan_JSON_values() nameof(NullableTimeSpanCollectionType.TimeSpan), [ TimeSpan.MinValue, - new(1, 2, 3, 4, 5), + new TimeSpan(1, 2, 3, 4, 5), TimeSpan.MaxValue, null ], @@ -2631,14 +2636,15 @@ protected class NullableCharacterCollectionType } [ConditionalTheory] - [InlineData("""{"Prop":["00000000-0000-0000-0000-000000000000",null,"8c44242f-8e3f-4a20-8be8-98c7c1aadebd","ffffffff-ffff-ffff-ffff-ffffffffffff"]}""")] + [InlineData( + """{"Prop":["00000000-0000-0000-0000-000000000000",null,"8c44242f-8e3f-4a20-8be8-98c7c1aadebd","ffffffff-ffff-ffff-ffff-ffffffffffff"]}""")] public virtual Task Can_read_write_collection_of_nullable_GUID_JSON_values(string expected) => Can_read_and_write_JSON_value>( nameof(NullableGuidCollectionType.Guid), [ - new(), + new Guid(), null, - new("8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD"), + new Guid("8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD"), Guid.Parse("FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF") ], expected, @@ -2692,9 +2698,9 @@ public virtual Task Can_read_write_collection_of_nullable_URI_JSON_values() => Can_read_and_write_JSON_value>( nameof(NullableUriCollectionType.Uri), [ - new("https://user:password@www.contoso.com:80/Home/Index.htm?q1=v1&q2=v2#FragmentName"), + new Uri("https://user:password@www.contoso.com:80/Home/Index.htm?q1=v1&q2=v2#FragmentName"), null, - new("file:///C:/test/path/file.txt") + new Uri("file:///C:/test/path/file.txt") ], """{"Prop":["https://user:password@www.contoso.com:80/Home/Index.htm?q1=v1\u0026q2=v2#FragmentName",null,"file:///C:/test/path/file.txt"]}""", mappedCollection: true); @@ -3344,9 +3350,9 @@ public virtual Task Can_read_write_collection_of_int_with_converter_JSON_values( }), nameof(DddIdCollectionType.DddId), [ - new() { Id = int.MinValue }, - new() { Id = 0 }, - new() { Id = int.MaxValue } + new DddId { Id = int.MinValue }, + new DddId { Id = 0 }, + new DddId { Id = int.MaxValue } ], """{"Prop":[-2147483648,0,2147483647]}""", facets: new Dictionary { { CoreAnnotationNames.ValueConverter, typeof(DddIdConverter) } }); @@ -3363,10 +3369,10 @@ public virtual Task Can_read_write_collection_of_nullable_int_with_converter_JSO nameof(NullableDddIdCollectionType.DddId), [ null, - new() { Id = int.MinValue }, + new DddId { Id = int.MinValue }, null, - new() { Id = 0 }, - new() { Id = int.MaxValue } + new DddId { Id = 0 }, + new DddId { Id = int.MaxValue } ], """{"Prop":[null,-2147483648,null,0,2147483647]}""", facets: new Dictionary { { CoreAnnotationNames.ValueConverter, typeof(DddIdConverter) } }); @@ -3410,8 +3416,8 @@ public virtual Task Can_read_write_collection_of_Guid_converted_to_bytes_JSON_va b => b.ElementType().HasConversion(), nameof(GuidCollectionType.Guid), [ - new(), - new("8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD"), + new Guid(), + new Guid("8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD"), Guid.Parse("FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF") ], expected, @@ -3547,7 +3553,8 @@ protected class BinaryArrayListType } [ConditionalTheory] - [InlineData("""{"Prop":[["00000000-0000-0000-0000-000000000000","8c44242f-8e3f-4a20-8be8-98c7c1aadebd"],[],["ffffffff-ffff-ffff-ffff-ffffffffffff"]]}""")] + [InlineData( + """{"Prop":[["00000000-0000-0000-0000-000000000000","8c44242f-8e3f-4a20-8be8-98c7c1aadebd"],[],["ffffffff-ffff-ffff-ffff-ffffffffffff"]]}""")] public virtual Task Can_read_write_list_of_array_of_GUID_JSON_values(string expected) => Can_read_and_write_JSON_value>( nameof(GuidArrayListType.Prop), @@ -3566,13 +3573,17 @@ protected class GuidArrayListType } [ConditionalTheory] - [InlineData("""{"Prop":[["00000000-0000-0000-0000-000000000000",null,"8c44242f-8e3f-4a20-8be8-98c7c1aadebd"],[],["ffffffff-ffff-ffff-ffff-ffffffffffff"]]}""")] + [InlineData( + """{"Prop":[["00000000-0000-0000-0000-000000000000",null,"8c44242f-8e3f-4a20-8be8-98c7c1aadebd"],[],["ffffffff-ffff-ffff-ffff-ffffffffffff"]]}""")] public virtual Task Can_read_write_list_of_array_of_nullable_GUID_JSON_values(string expected) => Can_read_and_write_JSON_value>( nameof(NullableGuidArrayListType.Prop), new List { - new Guid?[] { new Guid("00000000-0000-0000-0000-000000000000"), null, new Guid("8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD") }, + new Guid?[] + { + new Guid("00000000-0000-0000-0000-000000000000"), null, new Guid("8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD") + }, Array.Empty(), new Guid?[] { new Guid("FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF") } }, @@ -3590,7 +3601,12 @@ public virtual Task Can_read_write_array_of_list_of_int_JSON_values() nameof(Int32ListArrayType.Prop), new List[] { - new() { int.MinValue, 0, int.MaxValue }, + new() + { + int.MinValue, + 0, + int.MaxValue + }, new(), new() { 77 } }, @@ -3608,7 +3624,12 @@ public virtual Task Can_read_write_array_of_list_of_string_JSON_values() nameof(StringListArrayType.Prop), new List[] { - new() { "X", "Y", "" }, + new() + { + "X", + "Y", + "" + }, new(), new() { "77" } }, @@ -3644,7 +3665,12 @@ public virtual Task Can_read_write_array_of_list_of_ulong_JSON_values() nameof(ULongListArrayType.Prop), new List[] { - new() { ulong.MinValue, 1UL, ulong.MaxValue }, + new() + { + ulong.MinValue, + 1UL, + ulong.MaxValue + }, new(), new() { 77UL } }, @@ -3663,7 +3689,12 @@ public virtual Task Can_read_write_array_of_list_of_binary_JSON_values(string ex nameof(BinaryListArrayType.Prop), new List[] { - new() { new byte[] { 0, 1, 2 }, new byte[] { 1 }, new byte[] { 77 } }, + new() + { + new byte[] { 0, 1, 2 }, + new byte[] { 1 }, + new byte[] { 77 } + }, new(), new() { new byte[] { 78 } } }, @@ -3676,7 +3707,8 @@ protected class BinaryListArrayType } [ConditionalTheory] - [InlineData("""{"Prop":[["00000000-0000-0000-0000-000000000000","8c44242f-8e3f-4a20-8be8-98c7c1aadebd"],[],["ffffffff-ffff-ffff-ffff-ffffffffffff"]]}""")] + [InlineData( + """{"Prop":[["00000000-0000-0000-0000-000000000000","8c44242f-8e3f-4a20-8be8-98c7c1aadebd"],[],["ffffffff-ffff-ffff-ffff-ffffffffffff"]]}""")] public virtual Task Can_read_write_array_of_list_of_GUID_JSON_values(string expected) => Can_read_and_write_JSON_value[]>( nameof(GuidListArrayType.Prop), @@ -3700,9 +3732,23 @@ public virtual Task Can_read_write_list_of_list_of_list_of_int_JSON_values() nameof(Int32ListListListType.Prop), new List>> { - new() { new () { int.MinValue, 0, int.MaxValue }, new() { 77 } }, + new() + { + new List + { + int.MinValue, + 0, + int.MaxValue + }, + new List { 77 } + }, new(), - new() { new () { 1, 2 }, new(), new() { 78, 79 } } + new() + { + new List { 1, 2 }, + new List(), + new List { 78, 79 } + } }, """{"Prop":[[[-2147483648,0,2147483647],[77]],[],[[1,2],[],[78,79]]]}""", mappedCollection: true); @@ -3735,9 +3781,18 @@ public virtual Task Can_read_write_list_of_array_of_list_of_string_JSON_values() nameof(StringListArrayListType.Prop), new List[]> { - new List[] { new () { "int.MinValue", "", "int.MaxValue" }, new() { "77" } }, + new List[] + { + new() + { + "int.MinValue", + "", + "int.MaxValue" + }, + new() { "77" } + }, Array.Empty>(), - new List[] { new () { "1", "2" }, new(), new() { "78", "79" } } + new List[] { new() { "1", "2" }, new(), new() { "78", "79" } } }, """{"Prop":[[["int.MinValue","","int.MaxValue"],["77"]],[],[["1","2"],[],["78","79"]]]}""", mappedCollection: true); @@ -3755,7 +3810,12 @@ public virtual Task Can_read_write_array_of_list_of_array_of_string_JSON_values( { new() { new[] { "int.MinValue", "", "int.MaxValue" }, new[] { "77" } }, new(), - new() { new[] { "1", "2" }, Array.Empty(), new[] { "78", "79" } } + new() + { + new[] { "1", "2" }, + Array.Empty(), + new[] { "78", "79" } + } }, """{"Prop":[[["int.MinValue","","int.MaxValue"],["77"]],[],[["1","2"],[],["78","79"]]]}""", mappedCollection: true); @@ -3789,7 +3849,10 @@ public virtual Task Can_read_write_list_of_array_of_list_of_IPAddress_JSON_value nameof(IpAddressListArrayListType.Prop), new List[]> { - new List[] { new() { IPAddress.Parse("127.0.0.1"), IPAddress.Parse("2a00:23c7:c60f:4f01:ba43:6d5a:e648:7577") } }, + new List[] + { + new() { IPAddress.Parse("127.0.0.1"), IPAddress.Parse("2a00:23c7:c60f:4f01:ba43:6d5a:e648:7577") } + }, Array.Empty>(), new List[] { new() { new IPAddress(0) } } }, @@ -3826,9 +3889,12 @@ public virtual Task Can_read_write_list_of_array_of_list_of_array_of_binary_JSON nameof(BinaryListArrayArrayListType.Prop), new List[]> { - new List[] { new() { new byte[][] { new byte[] { 0, 1, 2 }, [1], [77] } }, new(), new() { new byte[][] { }, Array.Empty() } }, + new List[] + { + new() { new[] { new byte[] { 0, 1, 2 }, [1], [77] } }, new(), new() { new byte[][] { }, Array.Empty() } + }, Array.Empty>(), - new List[] { new() { new byte[][] { } }, new() { new byte[][] { new byte[] { 0, 1, 2 }, [1], [77] } } }, + new List[] { new() { new byte[][] { } }, new() { new[] { new byte[] { 0, 1, 2 }, [1], [77] } } }, }, expected, mappedCollection: true); @@ -4223,7 +4289,8 @@ public override void ToJsonTyped(Utf8JsonWriter writer, Geometry value) private readonly Expression> _instanceLambda = () => Instance; /// - public override Expression ConstructorExpression => _instanceLambda.Body; + public override Expression ConstructorExpression + => _instanceLambda.Body; } private readonly NullabilityInfoContext _nullabilityInfoContext = new(); diff --git a/test/EFCore.Specification.Tests/KeysWithConvertersTestBase.cs b/test/EFCore.Specification.Tests/KeysWithConvertersTestBase.cs index ad6ea7bb260..90a6b92c44b 100644 --- a/test/EFCore.Specification.Tests/KeysWithConvertersTestBase.cs +++ b/test/EFCore.Specification.Tests/KeysWithConvertersTestBase.cs @@ -451,7 +451,8 @@ await principalQuery.SingleAsync(e => e.Id.Equals(new IntStructKey { Id = 14 })) dependents = [ await context.Set().FirstOrDefaultAsync(e => e.Id.Equals(new IntStructKey { Id = 111 })), - await context.Set().FirstOrDefaultAsync(e => e.Id.Equals(new IntStructKey { Id = oneTwelve })), + await context.Set() + .FirstOrDefaultAsync(e => e.Id.Equals(new IntStructKey { Id = oneTwelve })), await context.Set().FirstOrDefaultAsync(e => e.Id.Equals(oneThirteen)), await context.Set().FirstOrDefaultAsync(e => e.Id.Equals(new IntStructKey { Id = 114 })), await context.Set() @@ -463,7 +464,8 @@ await context.Set().FirstOrDefaultAsync(e => e.Id Assert.Same(dependents[1], await context.Set().FindAsync(new IntStructKey { Id = oneTwelve })); Assert.Same(dependents[2], await context.Set().FindAsync(oneThirteen)); Assert.Same(dependents[3], await context.FindAsync(typeof(IntStructKeyRequiredDependent), new IntStructKey { Id = 114 })); - Assert.Same(dependents[4], await context.FindAsync(typeof(IntStructKeyRequiredDependent), new IntStructKey { Id = oneFifteeen })); + Assert.Same( + dependents[4], await context.FindAsync(typeof(IntStructKeyRequiredDependent), new IntStructKey { Id = oneFifteeen })); Assert.Same(dependents[5], await context.FindAsync(typeof(IntStructKeyRequiredDependent), oneSixteen)); } @@ -574,13 +576,15 @@ await context.Set().FirstOrDefaultAsync ]; Assert.Same( - dependents[0], await context.Set().FindAsync(new ComparableIntStructKey { Id = 111 })); + dependents[0], + await context.Set().FindAsync(new ComparableIntStructKey { Id = 111 })); Assert.Same( dependents[1], await context.Set().FindAsync(new ComparableIntStructKey { Id = oneTwelve })); Assert.Same(dependents[2], await context.Set().FindAsync(oneThirteen)); Assert.Same( - dependents[3], await context.FindAsync(typeof(ComparableIntStructKeyRequiredDependent), new ComparableIntStructKey { Id = 114 })); + dependents[3], + await context.FindAsync(typeof(ComparableIntStructKeyRequiredDependent), new ComparableIntStructKey { Id = 114 })); Assert.Same( dependents[4], await context.FindAsync(typeof(ComparableIntStructKeyRequiredDependent), new ComparableIntStructKey { Id = oneFifteeen })); @@ -695,7 +699,8 @@ await context.Set().FirstOrDefau Assert.Same( dependents[0], - await context.Set().FindAsync(new GenericComparableIntStructKey { Id = 111 })); + await context.Set() + .FindAsync(new GenericComparableIntStructKey { Id = 111 })); Assert.Same( dependents[1], await context.Set() @@ -703,7 +708,8 @@ await context.Set() Assert.Same(dependents[2], await context.Set().FindAsync(oneThirteen)); Assert.Same( dependents[3], - await context.FindAsync(typeof(GenericComparableIntStructKeyRequiredDependent), new GenericComparableIntStructKey { Id = 114 })); + await context.FindAsync( + typeof(GenericComparableIntStructKeyRequiredDependent), new GenericComparableIntStructKey { Id = 114 })); Assert.Same( dependents[4], await context.FindAsync( @@ -924,7 +930,8 @@ await context.Set().SingleAsync(e => e.Id = ]; Assert.Same(dependents[0], await context.Set().FindAsync(new EnumerableClassKey(101))); - Assert.Same(dependents[1], await context.Set().FindAsync(new EnumerableClassKey(oneOhTwo))); + Assert.Same( + dependents[1], await context.Set().FindAsync(new EnumerableClassKey(oneOhTwo))); Assert.Same(dependents[2], await context.Set().FindAsync(oneOhThree)); Assert.Same(dependents[3], await context.FindAsync(new EnumerableClassKey(104))); Assert.Same(dependents[4], await context.FindAsync(new EnumerableClassKey(oneOhFive))); @@ -1764,11 +1771,13 @@ await context.Set().FirstOrDefaultAsync(e => e. Assert.Same( dependents[0], await context.Set().FindAsync(new BytesStructKey { Id = [111] })); - Assert.Same(dependents[1], await context.Set().FindAsync(new BytesStructKey { Id = oneTwelve })); + Assert.Same( + dependents[1], await context.Set().FindAsync(new BytesStructKey { Id = oneTwelve })); Assert.Same(dependents[2], await context.Set().FindAsync(oneThirteen)); Assert.Same( dependents[3], await context.FindAsync(typeof(BytesStructKeyRequiredDependent), new BytesStructKey { Id = [114] })); - Assert.Same(dependents[4], await context.FindAsync(typeof(BytesStructKeyRequiredDependent), new BytesStructKey { Id = oneFifteeen })); + Assert.Same( + dependents[4], await context.FindAsync(typeof(BytesStructKeyRequiredDependent), new BytesStructKey { Id = oneFifteeen })); Assert.Same(dependents[5], await context.FindAsync(typeof(BytesStructKeyRequiredDependent), oneSixteen)); } @@ -1892,7 +1901,8 @@ await context.FindAsync( typeof(ComparableBytesStructKeyRequiredDependent), new ComparableBytesStructKey { Id = [114] })); Assert.Same( dependents[4], - await context.FindAsync(typeof(ComparableBytesStructKeyRequiredDependent), new ComparableBytesStructKey { Id = oneFifteeen })); + await context.FindAsync( + typeof(ComparableBytesStructKeyRequiredDependent), new ComparableBytesStructKey { Id = oneFifteeen })); Assert.Same(dependents[5], await context.FindAsync(typeof(ComparableBytesStructKeyRequiredDependent), oneSixteen)); } @@ -2250,7 +2260,8 @@ public virtual async Task Can_query_and_update_owned_entity_with_binary_struct_k using (var context = CreateContext()) { - var owner = await context.Set().SingleAsync(o => o.Id.Equals(new BytesStructKey(new byte[] { 1, 5, 7, 1 }))); + var owner = await context.Set() + .SingleAsync(o => o.Id.Equals(new BytesStructKey(new byte[] { 1, 5, 7, 1 }))); Assert.Equal(77, owner.Owned.Position); owner.Owned = new OwnedBytesStructKey(88); @@ -2491,7 +2502,8 @@ public virtual async Task Can_query_and_update_owned_entity_with_generic_compara using (var context = CreateContext()) { - var owner = await context.Set().SingleAsync(o => o.Id.Equals(new GenericComparableIntClassKey(1))); + var owner = await context.Set() + .SingleAsync(o => o.Id.Equals(new GenericComparableIntClassKey(1))); Assert.Equal(77, owner.Owned.Position); owner.Owned = new OwnedGenericComparableIntClassKey(88); @@ -2779,12 +2791,15 @@ await context.Set().SingleAsync(e ]; Assert.Same( - dependents[0], await context.Set().FindAsync(new ComparableIntStructKey(101))); + dependents[0], + await context.Set().FindAsync(new ComparableIntStructKey(101))); Assert.Same( - dependents[1], await context.Set().FindAsync(new ComparableIntStructKey(oneOhTwo))); + dependents[1], + await context.Set().FindAsync(new ComparableIntStructKey(oneOhTwo))); Assert.Same(dependents[2], await context.Set().FindAsync(oneOhThree)); Assert.Same( - dependents[3], await context.FindAsync(typeof(ComparableIntStructKeyOptionalDependentShadow), new ComparableIntStructKey(104))); + dependents[3], + await context.FindAsync(typeof(ComparableIntStructKeyOptionalDependentShadow), new ComparableIntStructKey(104))); Assert.Same( dependents[4], await context.FindAsync(typeof(ComparableIntStructKeyOptionalDependentShadow), new ComparableIntStructKey(oneOhFive))); @@ -2963,14 +2978,17 @@ await context.Set().Single Assert.Same( dependents[0], - await context.Set().FindAsync(new GenericComparableIntStructKey(101))); + await context.Set() + .FindAsync(new GenericComparableIntStructKey(101))); Assert.Same( dependents[1], - await context.Set().FindAsync(new GenericComparableIntStructKey(oneOhTwo))); + await context.Set() + .FindAsync(new GenericComparableIntStructKey(oneOhTwo))); Assert.Same(dependents[2], await context.Set().FindAsync(oneOhThree)); Assert.Same( dependents[3], - await context.FindAsync(typeof(GenericComparableIntStructKeyOptionalDependentShadow), new GenericComparableIntStructKey(104))); + await context.FindAsync( + typeof(GenericComparableIntStructKeyOptionalDependentShadow), new GenericComparableIntStructKey(104))); Assert.Same( dependents[4], await context.FindAsync( @@ -3120,18 +3138,21 @@ await principalQuery.SingleAsync(e => e.Id.Equals(new IntStructKey { Id = 14 })) dependents = [ - await context.Set().FirstOrDefaultAsync(e => e.Id.Equals(new IntStructKey { Id = 111 })), + await context.Set() + .FirstOrDefaultAsync(e => e.Id.Equals(new IntStructKey { Id = 111 })), await context.Set() .FirstOrDefaultAsync(e => e.Id.Equals(new IntStructKey { Id = oneTwelve })), await context.Set().FirstOrDefaultAsync(e => e.Id.Equals(oneThirteen)), - await context.Set().FirstOrDefaultAsync(e => e.Id.Equals(new IntStructKey { Id = 114 })), + await context.Set() + .FirstOrDefaultAsync(e => e.Id.Equals(new IntStructKey { Id = 114 })), await context.Set() .FirstOrDefaultAsync(e => e.Id.Equals(new IntStructKey { Id = oneFifteeen })), await context.Set().FirstOrDefaultAsync(e => e.Id.Equals(oneSixteen)) ]; Assert.Same(dependents[0], await context.Set().FindAsync(new IntStructKey { Id = 111 })); - Assert.Same(dependents[1], await context.Set().FindAsync(new IntStructKey { Id = oneTwelve })); + Assert.Same( + dependents[1], await context.Set().FindAsync(new IntStructKey { Id = oneTwelve })); Assert.Same(dependents[2], await context.Set().FindAsync(oneThirteen)); Assert.Same(dependents[3], await context.FindAsync(typeof(IntStructKeyRequiredDependentShadow), new IntStructKey { Id = 114 })); Assert.Same( @@ -3294,14 +3315,16 @@ await context.Set().FirstOrDefaul await context.Set().FindAsync(new ComparableIntStructKey { Id = 111 })); Assert.Same( dependents[1], - await context.Set().FindAsync(new ComparableIntStructKey { Id = oneTwelve })); + await context.Set() + .FindAsync(new ComparableIntStructKey { Id = oneTwelve })); Assert.Same(dependents[2], await context.Set().FindAsync(oneThirteen)); Assert.Same( dependents[3], await context.FindAsync(typeof(ComparableIntStructKeyRequiredDependentShadow), new ComparableIntStructKey { Id = 114 })); Assert.Same( dependents[4], - await context.FindAsync(typeof(ComparableIntStructKeyRequiredDependentShadow), new ComparableIntStructKey { Id = oneFifteeen })); + await context.FindAsync( + typeof(ComparableIntStructKeyRequiredDependentShadow), new ComparableIntStructKey { Id = oneFifteeen })); Assert.Same(dependents[5], await context.FindAsync(typeof(ComparableIntStructKeyRequiredDependentShadow), oneSixteen)); } @@ -3466,7 +3489,8 @@ await context.Set() .FirstOrDefaultAsync(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 111 })), await context.Set() .FirstOrDefaultAsync(e => e.Id.Equals(new GenericComparableIntStructKey { Id = oneTwelve })), - await context.Set().FirstOrDefaultAsync(e => e.Id.Equals(oneThirteen)), + await context.Set() + .FirstOrDefaultAsync(e => e.Id.Equals(oneThirteen)), await context.Set() .FirstOrDefaultAsync(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 114 })), await context.Set() @@ -3800,7 +3824,8 @@ await context.Set().SingleAsync(e => e.I ]; Assert.Same(dependents[0], await context.Set().FindAsync(new BareIntClassKey(101))); - Assert.Same(dependents[1], await context.Set().FindAsync(new BareIntClassKey(oneOhTwo))); + Assert.Same( + dependents[1], await context.Set().FindAsync(new BareIntClassKey(oneOhTwo))); Assert.Same(dependents[2], await context.Set().FindAsync(oneOhThree)); Assert.Same(dependents[3], await context.FindAsync(new BareIntClassKey(104))); Assert.Same(dependents[4], await context.FindAsync(new BareIntClassKey(oneOhFive))); @@ -3963,9 +3988,11 @@ await context.Set().SingleAsync(e Assert.Same( dependents[0], await context.Set().FindAsync(new ComparableIntClassKey(101))); Assert.Same( - dependents[1], await context.Set().FindAsync(new ComparableIntClassKey(oneOhTwo))); + dependents[1], + await context.Set().FindAsync(new ComparableIntClassKey(oneOhTwo))); Assert.Same(dependents[2], await context.Set().FindAsync(oneOhThree)); - Assert.Same(dependents[3], await context.FindAsync(new ComparableIntClassKey(104))); + Assert.Same( + dependents[3], await context.FindAsync(new ComparableIntClassKey(104))); Assert.Same( dependents[4], await context.FindAsync(new ComparableIntClassKey(oneOhFive))); Assert.Same(dependents[5], await context.FindAsync(oneOhSix)); @@ -4131,7 +4158,8 @@ await context.Set().SingleAsync(e => e.Id Assert.Same( dependents[3], await context.FindAsync(typeof(BytesStructKeyOptionalDependentShadow), new BytesStructKey { Id = [104] })); - Assert.Same(dependents[4], await context.FindAsync(typeof(BytesStructKeyOptionalDependentShadow), new BytesStructKey(oneOhFive))); + Assert.Same( + dependents[4], await context.FindAsync(typeof(BytesStructKeyOptionalDependentShadow), new BytesStructKey(oneOhFive))); Assert.Same(dependents[5], await context.FindAsync(typeof(BytesStructKeyOptionalDependentShadow), oneOhSix)); } @@ -4216,10 +4244,7 @@ public virtual async Task Can_insert_and_read_back_with_structural_struct_binary { Id = new StructuralComparableBytesStructKey([105]), Principal = principals0[2] }, - new StructuralComparableBytesStructKeyOptionalDependentShadow - { - Id = new StructuralComparableBytesStructKey([106]) - }); + new StructuralComparableBytesStructKeyOptionalDependentShadow { Id = new StructuralComparableBytesStructKey([106]) }); Assert.Equal(10, await context.SaveChangesAsync()); } @@ -4322,7 +4347,8 @@ await context.Set() dependents[1], await context.Set() .FindAsync(new StructuralComparableBytesStructKey(oneOhTwo))); - Assert.Same(dependents[2], await context.Set().FindAsync(oneOhThree)); + Assert.Same( + dependents[2], await context.Set().FindAsync(oneOhThree)); Assert.Same( dependents[3], await context.FindAsync( @@ -4333,7 +4359,8 @@ await context.FindAsync( await context.FindAsync( typeof(StructuralComparableBytesStructKeyOptionalDependentShadow), new StructuralComparableBytesStructKey(oneOhFive))); - Assert.Same(dependents[5], await context.FindAsync(typeof(StructuralComparableBytesStructKeyOptionalDependentShadow), oneOhSix)); + Assert.Same( + dependents[5], await context.FindAsync(typeof(StructuralComparableBytesStructKeyOptionalDependentShadow), oneOhSix)); } void Validate( @@ -4606,10 +4633,7 @@ public virtual async Task Can_insert_and_read_back_with_generic_comparable_struc { Id = new GenericComparableBytesStructKey([105]), Principal = principals0[2] }, - new GenericComparableBytesStructKeyOptionalDependentShadow - { - Id = new GenericComparableBytesStructKey([106]) - }); + new GenericComparableBytesStructKeyOptionalDependentShadow { Id = new GenericComparableBytesStructKey([106]) }); Assert.Equal(10, await context.SaveChangesAsync()); } @@ -4890,7 +4914,8 @@ await context.Set().FirstOrDefaultAsync(e dependents[3], await context.FindAsync(typeof(BytesStructKeyRequiredDependentShadow), new BytesStructKey { Id = [114] })); Assert.Same( - dependents[4], await context.FindAsync(typeof(BytesStructKeyRequiredDependentShadow), new BytesStructKey { Id = oneFifteeen })); + dependents[4], + await context.FindAsync(typeof(BytesStructKeyRequiredDependentShadow), new BytesStructKey { Id = oneFifteeen })); Assert.Same(dependents[5], await context.FindAsync(typeof(BytesStructKeyRequiredDependentShadow), oneSixteen)); } @@ -5075,7 +5100,8 @@ await context.Set() .FindAsync(new ComparableBytesStructKey { Id = [111] })); Assert.Same( dependents[1], - await context.Set().FindAsync(new ComparableBytesStructKey { Id = oneTwelve })); + await context.Set() + .FindAsync(new ComparableBytesStructKey { Id = oneTwelve })); Assert.Same(dependents[2], await context.Set().FindAsync(oneThirteen)); Assert.Same( dependents[3], @@ -5260,12 +5286,14 @@ await context.Set() .FirstOrDefaultAsync(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 111 } })), await context.Set() .FirstOrDefaultAsync(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = oneTwelve })), - await context.Set().FirstOrDefaultAsync(e => e.Id.Equals(oneThirteen)), + await context.Set() + .FirstOrDefaultAsync(e => e.Id.Equals(oneThirteen)), await context.Set() .FirstOrDefaultAsync(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 114 } })), await context.Set() .FirstOrDefaultAsync(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = oneFifteeen })), - await context.Set().FirstOrDefaultAsync(e => e.Id.Equals(oneSixteen)) + await context.Set() + .FirstOrDefaultAsync(e => e.Id.Equals(oneSixteen)) ]; Assert.Same( @@ -5276,7 +5304,8 @@ await context.Set() dependents[1], await context.Set() .FindAsync(new StructuralComparableBytesStructKey { Id = oneTwelve })); - Assert.Same(dependents[2], await context.Set().FindAsync(oneThirteen)); + Assert.Same( + dependents[2], await context.Set().FindAsync(oneThirteen)); Assert.Same( dependents[3], await context.FindAsync( @@ -5287,7 +5316,8 @@ await context.FindAsync( await context.FindAsync( typeof(StructuralComparableBytesStructKeyRequiredDependentShadow), new StructuralComparableBytesStructKey { Id = oneFifteeen })); - Assert.Same(dependents[5], await context.FindAsync(typeof(StructuralComparableBytesStructKeyRequiredDependentShadow), oneSixteen)); + Assert.Same( + dependents[5], await context.FindAsync(typeof(StructuralComparableBytesStructKeyRequiredDependentShadow), oneSixteen)); } void Validate( @@ -5462,12 +5492,14 @@ await context.Set() .FirstOrDefaultAsync(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 111 } })), await context.Set() .FirstOrDefaultAsync(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = oneTwelve })), - await context.Set().FirstOrDefaultAsync(e => e.Id.Equals(oneThirteen)), + await context.Set() + .FirstOrDefaultAsync(e => e.Id.Equals(oneThirteen)), await context.Set() .FirstOrDefaultAsync(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 114 } })), await context.Set() .FirstOrDefaultAsync(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = oneFifteeen })), - await context.Set().FirstOrDefaultAsync(e => e.Id.Equals(oneSixteen)) + await context.Set() + .FirstOrDefaultAsync(e => e.Id.Equals(oneSixteen)) ]; Assert.Same( diff --git a/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs b/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs index 978261d356c..2012b95f63d 100644 --- a/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs +++ b/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs @@ -4533,9 +4533,7 @@ protected Applicant() } public Applicant(FullName name) - { - Name = name ?? throw new ArgumentNullException(nameof(name)); - } + => Name = name ?? throw new ArgumentNullException(nameof(name)); } public class FirstName @@ -4547,9 +4545,7 @@ protected FirstName() } private FirstName(string value) - { - _value = value; - } + => _value = value; public static FirstName Create(string firstName) => new(firstName); @@ -4564,9 +4560,7 @@ protected LastName() } private LastName(string value) - { - _value = value; - } + => _value = value; public static LastName Create(string lastName) => new(lastName); @@ -4583,9 +4577,7 @@ protected Pyrson() } public Pyrson(FullName name) - { - Name = name ?? throw new ArgumentNullException(nameof(name)); - } + => Name = name ?? throw new ArgumentNullException(nameof(name)); public virtual Culture Culture { get; set; } public virtual Milk Milk { get; set; } = null!; diff --git a/test/EFCore.Specification.Tests/LoadTestBase.cs b/test/EFCore.Specification.Tests/LoadTestBase.cs index 709858621b2..c9c97a3a2a8 100644 --- a/test/EFCore.Specification.Tests/LoadTestBase.cs +++ b/test/EFCore.Specification.Tests/LoadTestBase.cs @@ -5353,9 +5353,7 @@ public Parent Parent protected abstract class RootClass { protected RootClass(Action lazyLoader) - { - LazyLoader = lazyLoader; - } + => LazyLoader = lazyLoader; protected RootClass() { @@ -5422,9 +5420,7 @@ public OptionalChildView() } public OptionalChildView(Action lazyLoader) - { - _loader = lazyLoader; - } + => _loader = lazyLoader; public int? RootId { get; set; } @@ -5445,9 +5441,7 @@ public RequiredChildView() } public RequiredChildView(Action lazyLoader) - { - _loader = lazyLoader; - } + => _loader = lazyLoader; public int RootId { get; set; } @@ -5469,9 +5463,7 @@ public ParentFullLoaderByConstructor() } private ParentFullLoaderByConstructor(ILazyLoader loader) - { - _loader = loader; - } + => _loader = loader; [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } @@ -5521,9 +5513,7 @@ public ChildFullLoaderByConstructor() } public ChildFullLoaderByConstructor(ILazyLoader loader) - { - _loader = loader; - } + => _loader = loader; [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } @@ -5558,9 +5548,7 @@ public SingleFullLoaderByConstructor() } public SingleFullLoaderByConstructor(ILazyLoader loader) - { - _loader = loader; - } + => _loader = loader; [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } @@ -5596,9 +5584,7 @@ public ParentDelegateLoaderByConstructor() } private ParentDelegateLoaderByConstructor(Action lazyLoader) - { - _loader = lazyLoader; - } + => _loader = lazyLoader; [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } @@ -5627,9 +5613,7 @@ public ChildDelegateLoaderByConstructor() } private ChildDelegateLoaderByConstructor(Action lazyLoader) - { - _loader = lazyLoader; - } + => _loader = lazyLoader; [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } @@ -5665,9 +5649,7 @@ public SingleDelegateLoaderByConstructor() } private SingleDelegateLoaderByConstructor(Action lazyLoader) - { - _loader = lazyLoader; - } + => _loader = lazyLoader; [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } diff --git a/test/EFCore.Specification.Tests/ManyToManyTrackingTestBase.cs b/test/EFCore.Specification.Tests/ManyToManyTrackingTestBase.cs index 6a0e444e4d1..4c008887538 100644 --- a/test/EFCore.Specification.Tests/ManyToManyTrackingTestBase.cs +++ b/test/EFCore.Specification.Tests/ManyToManyTrackingTestBase.cs @@ -594,8 +594,10 @@ public virtual Task Can_update_many_to_many_composite_shared_with_navs() return ExecuteWithStrategyInTransactionAsync( async context => { - var leftEntities = await context.Set().Include(e => e.RootSkipShared).OrderBy(e => e.Key2).ToListAsync(); - var rightEntities = await context.Set().Include(e => e.CompositeKeySkipShared).OrderBy(e => e.Name).ToListAsync(); + var leftEntities = await context.Set().Include(e => e.RootSkipShared).OrderBy(e => e.Key2) + .ToListAsync(); + var rightEntities = await context.Set().Include(e => e.CompositeKeySkipShared).OrderBy(e => e.Name) + .ToListAsync(); var roots = new[] { @@ -687,8 +689,10 @@ public virtual Task Can_update_many_to_many_composite_shared_with_navs() ValidateFixup(context, leftEntities, rightEntities, 24, 24, 47 - 4); }, async context => { - var leftEntities = await context.Set().Include(e => e.RootSkipShared).OrderBy(e => e.Key2).ToListAsync(); - var rightEntities = await context.Set().Include(e => e.CompositeKeySkipShared).OrderBy(e => e.Name).ToListAsync(); + var leftEntities = await context.Set().Include(e => e.RootSkipShared).OrderBy(e => e.Key2) + .ToListAsync(); + var rightEntities = await context.Set().Include(e => e.CompositeKeySkipShared).OrderBy(e => e.Name) + .ToListAsync(); ValidateFixup(context, leftEntities, rightEntities, 24, 24, 47 - 4); }); @@ -1018,7 +1022,8 @@ public virtual Task Can_update_many_to_many_composite_additional_pk_with_navs() async context => { var leftEntities = await context.Set().Include(e => e.ThreeSkipFull).OrderBy(e => e.Key2).ToListAsync(); - var rightEntities = await context.Set().Include(e => e.CompositeKeySkipFull).OrderBy(e => e.Name).ToListAsync(); + var rightEntities = + await context.Set().Include(e => e.CompositeKeySkipFull).OrderBy(e => e.Name).ToListAsync(); var threes = new[] { @@ -1116,7 +1121,8 @@ public virtual Task Can_update_many_to_many_composite_additional_pk_with_navs() }, async context => { var leftEntities = await context.Set().Include(e => e.ThreeSkipFull).OrderBy(e => e.Key2).ToListAsync(); - var rightEntities = await context.Set().Include(e => e.CompositeKeySkipFull).OrderBy(e => e.Name).ToListAsync(); + var rightEntities = + await context.Set().Include(e => e.CompositeKeySkipFull).OrderBy(e => e.Name).ToListAsync(); ValidateFixup(context, leftEntities, rightEntities, 24, 24, 53 - 4); }); @@ -2551,8 +2557,10 @@ public virtual Task Can_update_many_to_many_shared_with_payload() return ExecuteWithStrategyInTransactionAsync( async context => { - var leftEntities = await context.Set().Include(e => e.ThreeSkipPayloadFullShared).OrderBy(e => e.Name).ToListAsync(); - var rightEntities = await context.Set().Include(e => e.OneSkipPayloadFullShared).OrderBy(e => e.Name).ToListAsync(); + var leftEntities = await context.Set().Include(e => e.ThreeSkipPayloadFullShared).OrderBy(e => e.Name) + .ToListAsync(); + var rightEntities = await context.Set().Include(e => e.OneSkipPayloadFullShared).OrderBy(e => e.Name) + .ToListAsync(); leftEntities[0].ThreeSkipPayloadFullShared.Add( context.EntityThrees.CreateInstance( @@ -2643,8 +2651,10 @@ public virtual Task Can_update_many_to_many_shared_with_payload() ValidateFixup(context, leftEntities, rightEntities, 24, 24, 48 - 4, postSave: true); }, async context => { - var leftEntities = await context.Set().Include(e => e.ThreeSkipPayloadFullShared).OrderBy(e => e.Name).ToListAsync(); - var rightEntities = await context.Set().Include(e => e.OneSkipPayloadFullShared).OrderBy(e => e.Name).ToListAsync(); + var leftEntities = await context.Set().Include(e => e.ThreeSkipPayloadFullShared).OrderBy(e => e.Name) + .ToListAsync(); + var rightEntities = await context.Set().Include(e => e.OneSkipPayloadFullShared).OrderBy(e => e.Name) + .ToListAsync(); ValidateFixup(context, leftEntities, rightEntities, 24, 24, 48 - 4, postSave: true); }); diff --git a/test/EFCore.Specification.Tests/ModelBuilding/GiantModel.cs b/test/EFCore.Specification.Tests/ModelBuilding/GiantModel.cs index 32db7483401..2784a30ee9f 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/GiantModel.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/GiantModel.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // + namespace Microsoft.EntityFrameworkCore.ModelBuilding; public static class GiantModel diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ComplexType.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ComplexType.cs index caa9480ca54..ac2c52eb438 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ComplexType.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ComplexType.cs @@ -2077,8 +2077,8 @@ public virtual void Can_set_sentinel_for_primitive_collections() Assert.Null(complexType.FindProperty("Up")!.Sentinel); Assert.Equal(new ObservableCollection(), complexType.FindProperty("Down")!.Sentinel); Assert.Equal(Array.Empty(), complexType.FindProperty("Charm")!.Sentinel); - Assert.Equal(new List { }, complexType.FindProperty("Strange")!.Sentinel); - Assert.Equal(new int[] { 77 }, complexType.FindProperty("Top")!.Sentinel); + Assert.Equal(new List(), complexType.FindProperty("Strange")!.Sentinel); + Assert.Equal(new[] { 77 }, complexType.FindProperty("Top")!.Sentinel); Assert.Equal(new List { "" }, complexType.FindProperty("Bottom")!.Sentinel); } @@ -2168,22 +2168,23 @@ public virtual void PrimitiveCollectionBuilder_methods_can_be_chained() .Entity() .ComplexProperty(e => e.CollectionQuarks) .PrimitiveCollection(e => e.Up) - .ElementType(t => t - .HasAnnotation("B", "C") - .HasConversion(typeof(long)) - .HasConversion(new CastingConverter()) - .HasConversion(typeof(long), typeof(CustomValueComparer)) - .HasConversion(typeof(long), new CustomValueComparer()) - .HasConversion(new CastingConverter()) - .HasConversion(new CastingConverter(), new CustomValueComparer()) - .HasConversion() - .HasConversion(new CustomValueComparer()) - .HasConversion>() - .HasMaxLength(2) - .HasPrecision(1) - .HasPrecision(1, 2) - .IsRequired() - .IsUnicode()) + .ElementType( + t => t + .HasAnnotation("B", "C") + .HasConversion(typeof(long)) + .HasConversion(new CastingConverter()) + .HasConversion(typeof(long), typeof(CustomValueComparer)) + .HasConversion(typeof(long), new CustomValueComparer()) + .HasConversion(new CastingConverter()) + .HasConversion(new CastingConverter(), new CustomValueComparer()) + .HasConversion() + .HasConversion(new CustomValueComparer()) + .HasConversion>() + .HasMaxLength(2) + .HasPrecision(1) + .HasPrecision(1, 2) + .IsRequired() + .IsUnicode()) .IsRequired() .HasAnnotation("A", "V") .IsConcurrencyToken() diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.Generic.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.Generic.cs index bd656f5d05e..abacffdbb5c 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.Generic.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.Generic.cs @@ -2,11 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // ReSharper disable InconsistentNaming + namespace Microsoft.EntityFrameworkCore.ModelBuilding; public abstract partial class ModelBuilderTest { - public class GenericTestModelBuilder(ModelBuilderFixtureBase fixture, Action? configure) : TestModelBuilder(fixture, configure) + public class GenericTestModelBuilder(ModelBuilderFixtureBase fixture, Action? configure) + : TestModelBuilder(fixture, configure) { public override TestEntityTypeBuilder Entity() => new GenericTestEntityTypeBuilder(ModelBuilder.Entity()); @@ -41,7 +43,8 @@ public override TestModelBuilder Ignore() } } - protected class GenericTestEntityTypeBuilder(EntityTypeBuilder entityTypeBuilder) : TestEntityTypeBuilder, IInfrastructure> + protected class GenericTestEntityTypeBuilder(EntityTypeBuilder entityTypeBuilder) + : TestEntityTypeBuilder, IInfrastructure> where TEntity : class { protected EntityTypeBuilder EntityTypeBuilder { get; } = entityTypeBuilder; @@ -454,7 +457,8 @@ public ComplexPropertyBuilder Instance => PropertyBuilder; } - protected class GenericTestDiscriminatorBuilder(DiscriminatorBuilder discriminatorBuilder) : TestDiscriminatorBuilder + protected class GenericTestDiscriminatorBuilder(DiscriminatorBuilder discriminatorBuilder) + : TestDiscriminatorBuilder { protected DiscriminatorBuilder DiscriminatorBuilder { get; } = discriminatorBuilder; @@ -477,8 +481,9 @@ public override TestDiscriminatorBuilder HasValue(string entityT => Wrap(DiscriminatorBuilder.HasValue(entityTypeName, value)); } - protected class GenericTestOwnedEntityTypeBuilder(OwnedEntityTypeBuilder ownedEntityTypeBuilder) : TestOwnedEntityTypeBuilder, - IInfrastructure> + protected class GenericTestOwnedEntityTypeBuilder(OwnedEntityTypeBuilder ownedEntityTypeBuilder) + : TestOwnedEntityTypeBuilder, + IInfrastructure> where TEntity : class { protected OwnedEntityTypeBuilder OwnedEntityTypeBuilder { get; } = ownedEntityTypeBuilder; @@ -487,7 +492,8 @@ public OwnedEntityTypeBuilder Instance => OwnedEntityTypeBuilder; } - protected class GenericTestPropertyBuilder(PropertyBuilder propertyBuilder) : TestPropertyBuilder, IInfrastructure> + protected class GenericTestPropertyBuilder(PropertyBuilder propertyBuilder) + : TestPropertyBuilder, IInfrastructure> { protected PropertyBuilder PropertyBuilder { get; } = propertyBuilder; @@ -850,7 +856,8 @@ ComplexTypePropertyBuilder IInfrastructure PropertyBuilder; } - protected class GenericTestComplexTypePrimitiveCollectionBuilder(ComplexTypePrimitiveCollectionBuilder primitiveCollectionBuilder) : + protected class GenericTestComplexTypePrimitiveCollectionBuilder( + ComplexTypePrimitiveCollectionBuilder primitiveCollectionBuilder) : TestComplexTypePrimitiveCollectionBuilder, IInfrastructure> { @@ -921,7 +928,8 @@ ComplexTypePrimitiveCollectionBuilder IInfrastructure PrimitiveCollectionBuilder; } - protected class GenericTestKeyBuilder(KeyBuilder keyBuilder) : TestKeyBuilder, IInfrastructure> + protected class GenericTestKeyBuilder(KeyBuilder keyBuilder) + : TestKeyBuilder, IInfrastructure> { private KeyBuilder KeyBuilder { get; } = keyBuilder; @@ -935,7 +943,8 @@ KeyBuilder IInfrastructure>.Instance => KeyBuilder; } - protected class GenericTestIndexBuilder(IndexBuilder indexBuilder) : TestIndexBuilder, IInfrastructure> + protected class GenericTestIndexBuilder(IndexBuilder indexBuilder) + : TestIndexBuilder, IInfrastructure> { private IndexBuilder IndexBuilder { get; } = indexBuilder; @@ -955,7 +964,8 @@ IndexBuilder IInfrastructure>.Instance => IndexBuilder; } - protected class GenericTestNavigationBuilder(NavigationBuilder navigationBuilder) : TestNavigationBuilder + protected class GenericTestNavigationBuilder(NavigationBuilder navigationBuilder) + : TestNavigationBuilder where TSource : class where TTarget : class { @@ -981,7 +991,9 @@ public override TestNavigationBuilder IsRequired(bool required = true) } protected class - GenericTestReferenceNavigationBuilder(ReferenceNavigationBuilder referenceNavigationBuilder) : TestReferenceNavigationBuilder + GenericTestReferenceNavigationBuilder( + ReferenceNavigationBuilder referenceNavigationBuilder) + : TestReferenceNavigationBuilder where TEntity : class where TRelatedEntity : class { @@ -1006,7 +1018,8 @@ public override TestReferenceReferenceBuilder WithOne( ReferenceNavigationBuilder.WithOne(navigationExpression)); } - protected class GenericTestCollectionNavigationBuilder(CollectionNavigationBuilder collectionNavigationBuilder) : + protected class GenericTestCollectionNavigationBuilder( + CollectionNavigationBuilder collectionNavigationBuilder) : TestCollectionNavigationBuilder where TEntity : class where TRelatedEntity : class @@ -1033,7 +1046,8 @@ public override TestCollectionCollectionBuilder WithMan CollectionNavigationBuilder.WithMany(navigationExpression)); } - protected class GenericTestReferenceCollectionBuilder(ReferenceCollectionBuilder referenceCollectionBuilder) + protected class GenericTestReferenceCollectionBuilder( + ReferenceCollectionBuilder referenceCollectionBuilder) : TestReferenceCollectionBuilder where TEntity : class where TRelatedEntity : class @@ -1071,7 +1085,8 @@ public override TestReferenceCollectionBuilder OnDelete => Wrap(ReferenceCollectionBuilder.OnDelete(deleteBehavior)); } - protected class GenericTestReferenceReferenceBuilder(ReferenceReferenceBuilder referenceReferenceBuilder) : + protected class GenericTestReferenceReferenceBuilder( + ReferenceReferenceBuilder referenceReferenceBuilder) : TestReferenceReferenceBuilder where TEntity : class where TRelatedEntity : class @@ -1336,7 +1351,8 @@ OwnershipBuilder IInfrastructure OwnershipBuilder; } - protected class GenericTestOwnedNavigationBuilder(OwnedNavigationBuilder ownedNavigationBuilder) + protected class GenericTestOwnedNavigationBuilder( + OwnedNavigationBuilder ownedNavigationBuilder) : TestOwnedNavigationBuilder, IInfrastructure> where TEntity : class @@ -1413,7 +1429,9 @@ public override TestIndexBuilder HasIndex(string[] propertyNam public override TestIndexBuilder HasIndex(Expression> indexExpression) => new GenericTestIndexBuilder(OwnedNavigationBuilder.HasIndex(indexExpression)); - public override TestIndexBuilder HasIndex(Expression> indexExpression, string name) + public override TestIndexBuilder HasIndex( + Expression> indexExpression, + string name) => new GenericTestIndexBuilder(OwnedNavigationBuilder.HasIndex(indexExpression, name)); public override TestOwnershipBuilder WithOwner(string? ownerReference) diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.Inheritance.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.Inheritance.cs index 1534c3600e4..6cc741e6d46 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.Inheritance.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.Inheritance.cs @@ -148,7 +148,8 @@ public virtual void Can_set_and_remove_base_type() Fixture.TestHelpers.ModelAsserter.AssertEqual( initialProperties.Where(p => p.Name != "Discriminator"), actualProperties.Where(p => p.Name != "Discriminator")); - Assert.Equal(initialKeys, pickle.GetKeys(), + Assert.Equal( + initialKeys, pickle.GetKeys(), (expected, actual) => { Fixture.TestHelpers.ModelAsserter.AssertEqual( @@ -179,7 +180,8 @@ public virtual void Can_set_and_remove_base_type() Fixture.TestHelpers.ModelAsserter.AssertEqual( initialProperties.Where(p => p.Name != "Discriminator"), actualProperties.Where(p => p.Name != "Discriminator")); - Assert.Equal(initialKeys, ingredient.GetKeys(), + Assert.Equal( + initialKeys, ingredient.GetKeys(), (expected, actual) => { Fixture.TestHelpers.ModelAsserter.AssertEqual( diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ManyToMany.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ManyToMany.cs index 0264ca3532c..1681985a01f 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ManyToMany.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ManyToMany.cs @@ -728,7 +728,8 @@ public virtual void ForeignKeyAttribute_does_not_force_convention_join_table_inc Assert.Equal(3, model.GetEntityTypes().Count()); - Assert.Collection(model.GetEntityTypes(), + Assert.Collection( + model.GetEntityTypes(), e => { Assert.Equal("MotorArtMatching", e.ShortName()); @@ -748,7 +749,8 @@ public virtual void ForeignKeyAttribute_does_not_force_convention_join_table_inc e => { Assert.Equal("MotorArtXMotorBauartMatching", e.ShortName()); - Assert.Collection(e.GetForeignKeys(), + Assert.Collection( + e.GetForeignKeys(), k => { Assert.Equal("MotorArtMatching", k.PrincipalEntityType.ShortName()); @@ -800,7 +802,8 @@ public virtual void ForeignKeyAttribute_does_not_force_convention_join_table_inc Assert.Equal(3, model.GetEntityTypes().Count()); - Assert.Collection(model.GetEntityTypes(), + Assert.Collection( + model.GetEntityTypes(), e => { Assert.Equal("MotorArtMismatching", e.ShortName()); @@ -820,7 +823,8 @@ public virtual void ForeignKeyAttribute_does_not_force_convention_join_table_inc e => { Assert.Equal("MotorArtXMotorBauartMismatching", e.ShortName()); - Assert.Collection(e.GetForeignKeys(), + Assert.Collection( + e.GetForeignKeys(), k => { Assert.Equal("MotorArtMismatching", k.PrincipalEntityType.ShortName()); diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ManyToOne.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ManyToOne.cs index 0746bb93847..2f33dcf9f0c 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ManyToOne.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ManyToOne.cs @@ -1902,7 +1902,6 @@ public virtual void Creates_relationship_on_existing_FK_is_using_different_princ Assert.Empty(dependentType.GetIndexes()); } - Assert.Equal( CoreStrings.AmbiguousOneToOneRelationship( existingFk.DeclaringEntityType.DisplayName() + "." + existingFk.DependentToPrincipal.Name, diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonGeneric.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonGeneric.cs index 44a00f536f6..ccd94bd3435 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonGeneric.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonGeneric.cs @@ -1,13 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Reflection; - namespace Microsoft.EntityFrameworkCore.ModelBuilding; public abstract partial class ModelBuilderTest { - public class NonGenericTestModelBuilder(ModelBuilderFixtureBase fixture, Action? configure) : TestModelBuilder(fixture, configure) + public class NonGenericTestModelBuilder(ModelBuilderFixtureBase fixture, Action? configure) + : TestModelBuilder(fixture, configure) { public override TestEntityTypeBuilder Entity() => new NonGenericTestEntityTypeBuilder(ModelBuilder.Entity(typeof(TEntity))); @@ -42,7 +41,8 @@ public override TestModelBuilder Ignore() } } - protected class NonGenericTestEntityTypeBuilder(EntityTypeBuilder entityTypeBuilder) : TestEntityTypeBuilder, IInfrastructure + protected class NonGenericTestEntityTypeBuilder(EntityTypeBuilder entityTypeBuilder) + : TestEntityTypeBuilder, IInfrastructure where TEntity : class { protected EntityTypeBuilder EntityTypeBuilder { get; } = entityTypeBuilder; @@ -525,7 +525,8 @@ public ComplexPropertyBuilder Instance => PropertyBuilder; } - protected class NonGenericTestDiscriminatorBuilder(DiscriminatorBuilder discriminatorBuilder) : TestDiscriminatorBuilder + protected class NonGenericTestDiscriminatorBuilder(DiscriminatorBuilder discriminatorBuilder) + : TestDiscriminatorBuilder { protected DiscriminatorBuilder DiscriminatorBuilder { get; } = discriminatorBuilder; @@ -548,8 +549,9 @@ public override TestDiscriminatorBuilder HasValue(string entityT => Wrap(DiscriminatorBuilder.HasValue(entityTypeName, value)); } - protected class NonGenericTestOwnedEntityTypeBuilder(OwnedEntityTypeBuilder ownedEntityTypeBuilder) : TestOwnedEntityTypeBuilder, - IInfrastructure + protected class NonGenericTestOwnedEntityTypeBuilder(OwnedEntityTypeBuilder ownedEntityTypeBuilder) + : TestOwnedEntityTypeBuilder, + IInfrastructure where TEntity : class { protected OwnedEntityTypeBuilder OwnedEntityTypeBuilder { get; } = ownedEntityTypeBuilder; @@ -558,7 +560,8 @@ public OwnedEntityTypeBuilder Instance => OwnedEntityTypeBuilder; } - protected class NonGenericTestPropertyBuilder(PropertyBuilder propertyBuilder) : TestPropertyBuilder, IInfrastructure + protected class NonGenericTestPropertyBuilder(PropertyBuilder propertyBuilder) + : TestPropertyBuilder, IInfrastructure { private PropertyBuilder PropertyBuilder { get; } = propertyBuilder; @@ -703,8 +706,9 @@ PropertyBuilder IInfrastructure.Instance => PropertyBuilder; } - protected class NonGenericTestPrimitiveCollectionBuilder(PrimitiveCollectionBuilder primitiveCollectionBuilder) : TestPrimitiveCollectionBuilder, - IInfrastructure + protected class NonGenericTestPrimitiveCollectionBuilder(PrimitiveCollectionBuilder primitiveCollectionBuilder) + : TestPrimitiveCollectionBuilder, + IInfrastructure { private PrimitiveCollectionBuilder PrimitiveCollectionBuilder { get; } = primitiveCollectionBuilder; @@ -915,7 +919,8 @@ ComplexTypePropertyBuilder IInfrastructure.Instance => PropertyBuilder; } - protected class NonGenericTestComplexTypePrimitiveCollectionBuilder(ComplexTypePrimitiveCollectionBuilder primitiveCollectionBuilder) : + protected class NonGenericTestComplexTypePrimitiveCollectionBuilder( + ComplexTypePrimitiveCollectionBuilder primitiveCollectionBuilder) : TestComplexTypePrimitiveCollectionBuilder, IInfrastructure { @@ -1023,7 +1028,8 @@ KeyBuilder IInfrastructure.Instance => KeyBuilder; } - protected class NonGenericTestIndexBuilder(IndexBuilder indexBuilder) : TestIndexBuilder, IInfrastructure + protected class NonGenericTestIndexBuilder(IndexBuilder indexBuilder) + : TestIndexBuilder, IInfrastructure { private IndexBuilder IndexBuilder { get; } = indexBuilder; @@ -1044,7 +1050,8 @@ IndexBuilder IInfrastructure.Instance } protected class - NonGenericTestReferenceNavigationBuilder(ReferenceNavigationBuilder referenceNavigationBuilder) : TestReferenceNavigationBuilder + NonGenericTestReferenceNavigationBuilder(ReferenceNavigationBuilder referenceNavigationBuilder) + : TestReferenceNavigationBuilder where TEntity : class where TRelatedEntity : class { @@ -1071,7 +1078,8 @@ public override TestReferenceReferenceBuilder WithOne( navigationExpression?.GetMemberAccess().GetSimpleMemberName())); } - protected class NonGenericTestCollectionNavigationBuilder(CollectionNavigationBuilder collectionNavigationBuilder) + protected class NonGenericTestCollectionNavigationBuilder( + CollectionNavigationBuilder collectionNavigationBuilder) : TestCollectionNavigationBuilder where TEntity : class where TRelatedEntity : class @@ -1143,7 +1151,8 @@ public override TestReferenceCollectionBuilder OnDelete } protected class - NonGenericTestReferenceReferenceBuilder(ReferenceReferenceBuilder referenceReferenceBuilder) : TestReferenceReferenceBuilder + NonGenericTestReferenceReferenceBuilder(ReferenceReferenceBuilder referenceReferenceBuilder) + : TestReferenceReferenceBuilder where TEntity : class where TRelatedEntity : class { @@ -1187,7 +1196,8 @@ public override TestReferenceReferenceBuilder OnDelete( => Wrap(ReferenceReferenceBuilder.OnDelete(deleteBehavior)); } - protected class NonGenericTestCollectionCollectionBuilder(CollectionCollectionBuilder collectionCollectionBuilder) : + protected class NonGenericTestCollectionCollectionBuilder( + CollectionCollectionBuilder collectionCollectionBuilder) : TestCollectionCollectionBuilder where TLeftEntity : class where TRightEntity : class @@ -1490,7 +1500,9 @@ public override TestIndexBuilder HasIndex(Expression p.GetSimpleMemberName()).ToArray())); - public override TestIndexBuilder HasIndex(Expression> indexExpression, string name) + public override TestIndexBuilder HasIndex( + Expression> indexExpression, + string name) => new NonGenericTestIndexBuilder( OwnedNavigationBuilder.HasIndex( indexExpression.GetMemberAccessList().Select(p => p.GetSimpleMemberName()).ToArray(), name)); diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonRelationship.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonRelationship.cs index c46e75bc8c3..32cc4eb4675 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonRelationship.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonRelationship.cs @@ -468,7 +468,8 @@ public void ProcessModelInitialized( => modelBuilder.HasAnnotation("foo", "bar"); } - protected class TestDbSetFindingConvention(ProviderConventionSetBuilderDependencies dependencies) : DbSetFindingConvention(dependencies) + protected class TestDbSetFindingConvention(ProviderConventionSetBuilderDependencies dependencies) + : DbSetFindingConvention(dependencies) { public override void ProcessModelInitialized( IConventionModelBuilder modelBuilder, @@ -1397,7 +1398,7 @@ public virtual void Can_set_sentinel_for_properties() { b.Property(e => e.Up).HasSentinel(1); b.Property(e => e.Down).HasSentinel("100"); - b.Property("Charm").HasSentinel((sbyte)-1); + b.Property("Charm").HasSentinel(-1); b.Property("Strange").HasSentinel(""); b.Property("Top").HasSentinel(77); b.Property("Bottom").HasSentinel(null); @@ -1425,7 +1426,8 @@ public virtual void Setting_sentinel_throws_for_null_on_nonnullable() { b.Property("Top").Metadata.Sentinel = 77D; b.Property("Charm").Metadata.Sentinel = EnumerablePartitionerOptions.NoBuffering; - Assert.Equal(CoreStrings.IncompatibleSentinelValue("null", nameof(Quarks), nameof(Quarks.Up), "int"), + Assert.Equal( + CoreStrings.IncompatibleSentinelValue("null", nameof(Quarks), nameof(Quarks.Up), "int"), Assert.Throws(() => b.Property(e => e.Up).Metadata.Sentinel = null).Message); }); } @@ -1438,8 +1440,10 @@ public virtual void Setting_sentinel_throws_for_noncompatible() modelBuilder.Entity( b => { - Assert.Equal(CoreStrings.IncompatibleSentinelValue("System.Byte[]", nameof(Quarks), nameof(Quarks.Up), "int"), - Assert.Throws(() => b.Property(e => e.Up).Metadata.Sentinel = Array.Empty()).Message); + Assert.Equal( + CoreStrings.IncompatibleSentinelValue("System.Byte[]", nameof(Quarks), nameof(Quarks.Up), "int"), + Assert.Throws(() => b.Property(e => e.Up).Metadata.Sentinel = Array.Empty()) + .Message); }); } @@ -2753,7 +2757,7 @@ public virtual void Can_set_sentinel_for_primitive_collections() b.PrimitiveCollection(e => e.Up).HasSentinel(null); b.PrimitiveCollection(e => e.Down).HasSentinel(new ObservableCollection()); b.PrimitiveCollection("Charm").HasSentinel([]); - b.PrimitiveCollection>("Strange").HasSentinel(new List { }); + b.PrimitiveCollection>("Strange").HasSentinel(new List()); b.PrimitiveCollection("Top").HasSentinel([77]); b.PrimitiveCollection>("Bottom").HasSentinel(new List { "" }); }); @@ -2765,8 +2769,8 @@ public virtual void Can_set_sentinel_for_primitive_collections() Assert.Null(entityType.FindProperty("Up")!.Sentinel); Assert.Equal(new ObservableCollection(), entityType.FindProperty("Down")!.Sentinel); Assert.Equal(Array.Empty(), entityType.FindProperty("Charm")!.Sentinel); - Assert.Equal(new List { }, entityType.FindProperty("Strange")!.Sentinel); - Assert.Equal(new int[] { 77 }, entityType.FindProperty("Top")!.Sentinel); + Assert.Equal(new List(), entityType.FindProperty("Strange")!.Sentinel); + Assert.Equal(new[] { 77 }, entityType.FindProperty("Top")!.Sentinel); Assert.Equal(new List { "" }, entityType.FindProperty("Bottom")!.Sentinel); } @@ -2913,22 +2917,23 @@ public virtual void PrimitiveCollectionBuilder_methods_can_be_chained() => CreateModelBuilder() .Entity() .PrimitiveCollection(e => e.Up) - .ElementType(t => t - .HasAnnotation("B", "C") - .HasConversion(typeof(long)) - .HasConversion(new CastingConverter()) - .HasConversion(typeof(long), typeof(CustomValueComparer)) - .HasConversion(typeof(long), new CustomValueComparer()) - .HasConversion(new CastingConverter()) - .HasConversion(new CastingConverter(), new CustomValueComparer()) - .HasConversion() - .HasConversion(new CustomValueComparer()) - .HasConversion>() - .HasMaxLength(2) - .HasPrecision(1) - .HasPrecision(1, 2) - .IsRequired() - .IsUnicode()) + .ElementType( + t => t + .HasAnnotation("B", "C") + .HasConversion(typeof(long)) + .HasConversion(new CastingConverter()) + .HasConversion(typeof(long), typeof(CustomValueComparer)) + .HasConversion(typeof(long), new CustomValueComparer()) + .HasConversion(new CastingConverter()) + .HasConversion(new CastingConverter(), new CustomValueComparer()) + .HasConversion() + .HasConversion(new CustomValueComparer()) + .HasConversion>() + .HasMaxLength(2) + .HasPrecision(1) + .HasPrecision(1, 2) + .IsRequired() + .IsUnicode()) .IsRequired() .IsRequired(false) .HasAnnotation("A", "V") @@ -3107,7 +3112,8 @@ public virtual void Element_types_can_be_made_required() b.PrimitiveCollection(e => e.Down).ElementType().IsRequired(false); b.PrimitiveCollection>("Charm").ElementType().IsRequired(); b.PrimitiveCollection>("Strange").ElementType().IsRequired(); - b.PrimitiveCollection>("Stranger").ElementType().IsRequired(); // Still optional since no NRT metadata available + b.PrimitiveCollection>("Stranger").ElementType() + .IsRequired(); // Still optional since no NRT metadata available }); var entityType = modelBuilder.FinalizeModel().FindEntityType(typeof(CollectionQuarks))!; @@ -3282,11 +3288,13 @@ public virtual void Conversion_on_base_property_prevents_primitive_collection() { var modelBuilder = CreateModelBuilder(); modelBuilder.Entity(); - modelBuilder.Entity(b => - { - b.Property(c => c.Down).HasConversion(gs => string.Join(',', gs!), - s => new ObservableCollection(s.Split(',', StringSplitOptions.RemoveEmptyEntries))); - }); + modelBuilder.Entity( + b => + { + b.Property(c => c.Down).HasConversion( + gs => string.Join(',', gs!), + s => new ObservableCollection(s.Split(',', StringSplitOptions.RemoveEmptyEntries))); + }); var model = modelBuilder.FinalizeModel(); @@ -3299,13 +3307,16 @@ public virtual void Conversion_on_base_property_prevents_primitive_collection() public virtual void Conversion_on_base_property_prevents_primitive_collection_when_base_first() { var modelBuilder = CreateModelBuilder(); - modelBuilder.Entity(b => - { - b.Property(c => c.Down).HasConversion(gs => string.Join(',', gs!), - s => new ObservableCollection(s.Split(',', StringSplitOptions.RemoveEmptyEntries))); - }); + modelBuilder.Entity( + b => + { + b.Property(c => c.Down).HasConversion( + gs => string.Join(',', gs!), + s => new ObservableCollection(s.Split(',', StringSplitOptions.RemoveEmptyEntries))); + }); - var property = (IProperty)modelBuilder.Model.FindEntityType(typeof(CollectionQuarks))!.FindProperty(nameof(CollectionQuarks.Down))!; + var property = + (IProperty)modelBuilder.Model.FindEntityType(typeof(CollectionQuarks))!.FindProperty(nameof(CollectionQuarks.Down))!; Assert.False(property.IsPrimitiveCollection); modelBuilder.Entity(); diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.OneToMany.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.OneToMany.cs index e570cb25769..a72255fd709 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.OneToMany.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.OneToMany.cs @@ -2546,12 +2546,13 @@ public virtual void Non_nullable_FK_can_be_made_optional_separately() public virtual void Nullable_FK_overrides_NRT_navigation() { var modelBuilder = CreateModelBuilder(); - modelBuilder.Entity(eb => - { - eb.Property(d => d.PrincipalEntityId); - eb.Ignore(d => d.Nav); - eb.HasOne(d => d.Nav).WithMany(p => p.InverseNav); - }); + modelBuilder.Entity( + eb => + { + eb.Property(d => d.PrincipalEntityId); + eb.Ignore(d => d.Nav); + eb.HasOne(d => d.Nav).WithMany(p => p.InverseNav); + }); var model = modelBuilder.FinalizeModel(); diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.OwnedTypes.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.OwnedTypes.cs index deef5a8683b..811c6fae39e 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.OwnedTypes.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.OwnedTypes.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // ReSharper disable InconsistentNaming + namespace Microsoft.EntityFrameworkCore.ModelBuilding; #nullable disable @@ -1628,9 +1629,7 @@ protected class DepartmentId public DepartmentId() { } public DepartmentId(int value) - { - Value = value; - } + => Value = value; public int Value { get; } } @@ -1646,15 +1645,16 @@ public virtual void Can_configure_property_and_owned_entity_of_same_type() { var modelBuilder = CreateModelBuilder(); - modelBuilder.Entity(b => - { - b.Property(d => d.Id) - .HasConversion( - id => id.Value, - value => new DepartmentId(value)); + modelBuilder.Entity( + b => + { + b.Property(d => d.Id) + .HasConversion( + id => id.Value, + value => new DepartmentId(value)); - b.OwnsMany(d => d.DepartmentIds); - }); + b.OwnsMany(d => d.DepartmentIds); + }); modelBuilder.Entity() .OwnsMany(o => o.DepartmentIds); @@ -1683,15 +1683,16 @@ public virtual void Can_configure_owned_entity_and_property_of_same_type() modelBuilder.Entity() .OwnsMany(o => o.DepartmentIds); - modelBuilder.Entity(b => - { - b.Property(d => d.Id) - .HasConversion( - id => id.Value, - value => new DepartmentId(value)); + modelBuilder.Entity( + b => + { + b.Property(d => d.Id) + .HasConversion( + id => id.Value, + value => new DepartmentId(value)); - b.OwnsMany(d => d.DepartmentIds); - }); + b.OwnsMany(d => d.DepartmentIds); + }); var model = modelBuilder.FinalizeModel(); @@ -2033,22 +2034,23 @@ public virtual void PrimitiveCollectionBuilder_methods_can_be_chained() .Entity() .OwnsOne(e => e.CollectionQuarks) .PrimitiveCollection(e => e.Up) - .ElementType(t => t - .HasAnnotation("B", "C") - .HasConversion(typeof(long)) - .HasConversion(new CastingConverter()) - .HasConversion(typeof(long), typeof(CustomValueComparer)) - .HasConversion(typeof(long), new CustomValueComparer()) - .HasConversion(new CastingConverter()) - .HasConversion(new CastingConverter(), new CustomValueComparer()) - .HasConversion() - .HasConversion(new CustomValueComparer()) - .HasConversion>() - .HasMaxLength(2) - .HasPrecision(1) - .HasPrecision(1, 2) - .IsRequired() - .IsUnicode()) + .ElementType( + t => t + .HasAnnotation("B", "C") + .HasConversion(typeof(long)) + .HasConversion(new CastingConverter()) + .HasConversion(typeof(long), typeof(CustomValueComparer)) + .HasConversion(typeof(long), new CustomValueComparer()) + .HasConversion(new CastingConverter()) + .HasConversion(new CastingConverter(), new CustomValueComparer()) + .HasConversion() + .HasConversion(new CustomValueComparer()) + .HasConversion>() + .HasMaxLength(2) + .HasPrecision(1) + .HasPrecision(1, 2) + .IsRequired() + .IsUnicode()) .IsRequired() .HasAnnotation("A", "V") .IsConcurrencyToken() @@ -2071,22 +2073,23 @@ public virtual void PrimitiveCollectionBuilder_methods_can_be_chained_on_collect .Entity() .OwnsMany(e => e.Orders) .PrimitiveCollection>("List") - .ElementType(t => t - .HasAnnotation("B", "C") - .HasConversion(typeof(long)) - .HasConversion(new CastingConverter()) - .HasConversion(typeof(long), typeof(CustomValueComparer)) - .HasConversion(typeof(long), new CustomValueComparer()) - .HasConversion(new CastingConverter()) - .HasConversion(new CastingConverter(), new CustomValueComparer()) - .HasConversion() - .HasConversion(new CustomValueComparer()) - .HasConversion>() - .HasMaxLength(2) - .HasPrecision(1) - .HasPrecision(1, 2) - .IsRequired() - .IsUnicode()) + .ElementType( + t => t + .HasAnnotation("B", "C") + .HasConversion(typeof(long)) + .HasConversion(new CastingConverter()) + .HasConversion(typeof(long), typeof(CustomValueComparer)) + .HasConversion(typeof(long), new CustomValueComparer()) + .HasConversion(new CastingConverter()) + .HasConversion(new CastingConverter(), new CustomValueComparer()) + .HasConversion() + .HasConversion(new CustomValueComparer()) + .HasConversion>() + .HasMaxLength(2) + .HasPrecision(1) + .HasPrecision(1, 2) + .IsRequired() + .IsUnicode()) .IsRequired() .HasAnnotation("A", "V") .IsConcurrencyToken() @@ -2117,6 +2120,7 @@ private class CustomValueGeneratorFactory : ValueGeneratorFactory public override ValueGenerator Create(IProperty property, ITypeBase entityType) => new CustomValueGenerator(); } + private class CustomValueComparer() : ValueComparer(false); } } diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.cs index c7b1d0f0d2f..75d69f0d5fd 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.cs @@ -44,8 +44,12 @@ protected TestModelBuilder HobNobBuilder() public abstract class ModelBuilderFixtureBase { public abstract TestHelpers TestHelpers { get; } - public virtual DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => builder; - public virtual IServiceCollection AddServices(IServiceCollection services) => services; + + public virtual DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) + => builder; + + public virtual IServiceCollection AddServices(IServiceCollection services) + => services; public virtual bool ForeignKeysHaveIndexes => true; @@ -934,7 +938,10 @@ public abstract TestOwnedNavigationBuilder Ignore( public abstract TestIndexBuilder HasIndex(string[] propertyNames, string name); public abstract TestIndexBuilder HasIndex(Expression> indexExpression); - public abstract TestIndexBuilder HasIndex(Expression> indexExpression, string name); + + public abstract TestIndexBuilder HasIndex( + Expression> indexExpression, + string name); public abstract TestOwnershipBuilder WithOwner(string? ownerReference); diff --git a/test/EFCore.Specification.Tests/NonSharedModelTestBase.cs b/test/EFCore.Specification.Tests/NonSharedModelTestBase.cs index 7f8f924020e..3d49751a8a8 100644 --- a/test/EFCore.Specification.Tests/NonSharedModelTestBase.cs +++ b/test/EFCore.Specification.Tests/NonSharedModelTestBase.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // ReSharper disable VirtualMemberCallInConstructor + namespace Microsoft.EntityFrameworkCore; public abstract class NonSharedModelTestBase : IAsyncLifetime diff --git a/test/EFCore.Specification.Tests/OverzealousInitializationTestBase.cs b/test/EFCore.Specification.Tests/OverzealousInitializationTestBase.cs index 0d3d0d435c3..fa0a9fc57c6 100644 --- a/test/EFCore.Specification.Tests/OverzealousInitializationTestBase.cs +++ b/test/EFCore.Specification.Tests/OverzealousInitializationTestBase.cs @@ -33,7 +33,7 @@ public virtual void Fixup_ignores_eagerly_initialized_reference_navs() private static readonly Artist[] _artists = [ - new() { Id = 1, Name = "Freddie" }, new() { Id = 2, Name = "Kendrick" }, new() { Id = 3, Name = "Jarvis" } + new Artist { Id = 1, Name = "Freddie" }, new Artist { Id = 2, Name = "Kendrick" }, new Artist { Id = 3, Name = "Jarvis" } ]; protected class Album diff --git a/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs b/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs index 25cfa814fd3..2709a3d6932 100644 --- a/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs +++ b/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs @@ -2749,29 +2749,31 @@ protected override Task SeedAsync(PoolableDbContext context) Assert.True((bool)joinEntry.Entity["InitializedCalled"]); } - context.Add(new Supplier33307 - { - Name = "Foo", - Address = new() + context.Add( + new Supplier33307 { - Street = "One", - Altitude = Math.PI, - Number = 42, - }, - Foo = "F" - }); + Name = "Foo", + Address = new Address33307 + { + Street = "One", + Altitude = Math.PI, + Number = 42, + }, + Foo = "F" + }); - context.Add(new Customer33307 - { - Name = "Bar", - Address = new() + context.Add( + new Customer33307 { - Street = "Two", - Altitude = Math.E, - Number = 42, - }, - Bar = 11 - }); + Name = "Bar", + Address = new Address33307 + { + Street = "Two", + Altitude = Math.E, + Number = 42, + }, + Bar = 11 + }); return context.SaveChangesAsync(); } diff --git a/test/EFCore.Specification.Tests/Query/AdHocAdvancedMappingsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/AdHocAdvancedMappingsQueryTestBase.cs index dcba2641818..c14b2cdecc0 100644 --- a/test/EFCore.Specification.Tests/Query/AdHocAdvancedMappingsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/AdHocAdvancedMappingsQueryTestBase.cs @@ -24,7 +24,8 @@ public virtual async Task Setting_IsUnicode_generates_unicode_literal_in_SQL() var query = context.Set().Where(xx => xx.Nombre.Contains("lla")).ToList(); } - private class Context9582(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context9582(DbContextOptions options) : DbContext(options) { protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -82,7 +83,8 @@ public virtual async Task Projecting_correlated_collection_along_with_non_mapped } } - private class Context11835(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context11835(DbContextOptions options) : DbContext(options) { public DbSet Blogs { get; set; } public DbSet Posts { get; set; } @@ -144,7 +146,8 @@ from c in grouping.DefaultIfEmpty() Assert.Equal(2, result.Count); } - private class Context15684(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context15684(DbContextOptions options) : DbContext(options) { public DbSet Categories { get; set; } public DbSet Products { get; set; } @@ -238,9 +241,12 @@ public virtual async Task Expression_tree_constructed_via_interface_works() } } - private class Context17276(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context17276(DbContextOptions options) : DbContext(options) { + // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet RemovableEntities { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Parents { get; set; } public static List List(IQueryable query) @@ -311,7 +317,8 @@ public virtual async Task Double_convert_interface_created_expression_tree() Assert.Equal(1, query); } - private class Context17794(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context17794(DbContextOptions options) : DbContext(options) { public DbSet Offers { get; set; } public DbSet OfferActions { get; set; } @@ -407,7 +414,8 @@ public virtual async Task Casts_are_removed_from_expression_tree_when_redundant( } } - private class Context18087(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context18087(DbContextOptions options) : DbContext(options) { public DbSet MockEntities { get; set; } @@ -453,7 +461,8 @@ public virtual async Task Can_query_hierarchy_with_non_nullable_property_on_deri Assert.Equal(3, query.Count); } - private class Context18346(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context18346(DbContextOptions options) : DbContext(options) { public DbSet Businesses { get; set; } @@ -575,7 +584,8 @@ public virtual async Task Query_generates_correct_timespan_parameter_definition( _ = context.Entities.Where(x => x.TimeSpan == parameter).Select(e => e.TimeSpan).FirstOrDefault(); } - private class Context26742(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context26742(DbContextOptions options) : DbContext(options) { public DbSet Entities { get; set; } diff --git a/test/EFCore.Specification.Tests/Query/AdHocComplexTypeQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/AdHocComplexTypeQueryTestBase.cs index 6712d2f03fe..9dd81de6853 100644 --- a/test/EFCore.Specification.Tests/Query/AdHocComplexTypeQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/AdHocComplexTypeQueryTestBase.cs @@ -4,7 +4,6 @@ namespace Microsoft.EntityFrameworkCore.Query; // ReSharper disable ClassNeverInstantiated.Local - public abstract class AdHocComplexTypeQueryTestBase : NonSharedModelTestBase { #region 33449 @@ -18,11 +17,11 @@ public virtual async Task Complex_type_equals_parameter_with_nested_types_with_p context.AddRange( new Context33449.EntityType { - ComplexContainer = new() + ComplexContainer = new Context33449.ComplexContainer { Id = 1, - Containee1 = new() { Id = 2 }, - Containee2 = new() { Id = 3 } + Containee1 = new Context33449.ComplexContainee1 { Id = 2 }, + Containee2 = new Context33449.ComplexContainee2 { Id = 3 } } }); return context.SaveChangesAsync(); @@ -33,8 +32,8 @@ public virtual async Task Complex_type_equals_parameter_with_nested_types_with_p var container = new Context33449.ComplexContainer { Id = 1, - Containee1 = new() { Id = 2 }, - Containee2 = new() { Id = 3 } + Containee1 = new Context33449.ComplexContainee1 { Id = 2 }, + Containee2 = new Context33449.ComplexContainee2 { Id = 3 } }; _ = await context.Set().Where(b => b.ComplexContainer == container).SingleAsync(); @@ -43,11 +42,12 @@ public virtual async Task Complex_type_equals_parameter_with_nested_types_with_p private class Context33449(DbContextOptions options) : DbContext(options) { protected override void OnModelCreating(ModelBuilder modelBuilder) - => modelBuilder.Entity().ComplexProperty(b => b.ComplexContainer, x => - { - x.ComplexProperty(c => c.Containee1); - x.ComplexProperty(c => c.Containee2); - }); + => modelBuilder.Entity().ComplexProperty( + b => b.ComplexContainer, x => + { + x.ComplexProperty(c => c.Containee1); + x.ComplexProperty(c => c.Containee2); + }); public class EntityType { diff --git a/test/EFCore.Specification.Tests/Query/AdHocManyToManyQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/AdHocManyToManyQueryTestBase.cs index 7221edef55c..5db2b2bc962 100644 --- a/test/EFCore.Specification.Tests/Query/AdHocManyToManyQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/AdHocManyToManyQueryTestBase.cs @@ -27,7 +27,8 @@ from organisation in context.Organisations.Where(o => o.OrganisationUsers.Any()) Assert.Equal(2, users.Count); } - private class MyContext7973(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class MyContext7973(DbContextOptions options) : DbContext(options) { public DbSet Users { get; set; } public DbSet Organisations { get; set; } diff --git a/test/EFCore.Specification.Tests/Query/AdHocMiscellaneousQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/AdHocMiscellaneousQueryTestBase.cs index e217ab475cc..fc013607902 100644 --- a/test/EFCore.Specification.Tests/Query/AdHocMiscellaneousQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/AdHocMiscellaneousQueryTestBase.cs @@ -41,7 +41,8 @@ public virtual async Task First_FirstOrDefault_ix_async() } } - private class Context603(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context603(DbContextOptions options) : DbContext(options) { public DbSet Products { get; set; } @@ -87,7 +88,8 @@ from custPC in custPCTmp.DefaultIfEmpty() Assert.True(results[3].CustomerName != results[4].CustomerName); } - private class Context6901(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context6901(DbContextOptions options) : DbContext(options) { protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -218,7 +220,8 @@ public virtual async Task Shadow_property_with_inheritance() } } - private class Context6986(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context6986(DbContextOptions options) : DbContext(options) { public DbSet Contacts { get; set; } public DbSet EmployerContacts { get; set; } @@ -238,18 +241,15 @@ public async Task SeedAsync() Contacts.AddRange( new ServiceOperatorContact { - UserName = "service.operator@esoterix.co.uk", - ServiceOperator = ServiceOperators.OrderBy(o => o.Id).First() + UserName = "service.operator@esoterix.co.uk", ServiceOperator = ServiceOperators.OrderBy(o => o.Id).First() }, new EmployerContact { - UserName = "uwe@esoterix.co.uk", - Employer = Employers.OrderBy(e => e.Id).First(e => e.Name == "UWE") + UserName = "uwe@esoterix.co.uk", Employer = Employers.OrderBy(e => e.Id).First(e => e.Name == "UWE") }, new EmployerContact { - UserName = "hp@esoterix.co.uk", - Employer = Employers.OrderBy(e => e.Id).First(e => e.Name == "Hewlett Packard") + UserName = "hp@esoterix.co.uk", Employer = Employers.OrderBy(e => e.Id).First(e => e.Name == "Hewlett Packard") }, new Contact { UserName = "noroles@esoterix.co.uk" }); @@ -308,7 +308,8 @@ public virtual async Task Inlined_dbcontext_is_not_leaking() } } - private class Context7222(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context7222(DbContextOptions options) : DbContext(options) { public DbSet Blogs { get; set; } @@ -348,7 +349,8 @@ public virtual async Task Discriminator_type_is_handled_correctly() } } - private class Context7359(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context7359(DbContextOptions options) : DbContext(options) { public DbSet Products { get; set; } @@ -393,7 +395,8 @@ public virtual async Task New_instances_in_projection_are_not_shared_across_resu Assert.Equal(new[] { "First", "Second", "Third" }, list.Select(dto => dto.Title)); } - private class Context7983(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context7983(DbContextOptions options) : DbContext(options) { public DbSet Blogs { get; set; } public DbSet Posts { get; set; } @@ -483,7 +486,8 @@ public virtual async Task Enum_has_flag_does_not_apply_explicit_cast_for_non_con } } - private class Context8538(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context8538(DbContextOptions options) : DbContext(options) { public DbSet Entities { get; set; } @@ -671,7 +675,8 @@ public virtual async Task Explicitly_compiled_query_does_not_add_cache_entry() } } - private class Context8909(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context8909(DbContextOptions options) : DbContext(options) { public DbSet Entities { get; set; } @@ -711,7 +716,8 @@ public virtual async Task Conditional_expression_with_conditions_does_not_collap Assert.Single(query.Where(t => t.Processing == false)); } - private class Context9468(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context9468(DbContextOptions options) : DbContext(options) { public DbSet Carts { get; set; } @@ -755,7 +761,8 @@ public virtual async Task QueryBuffer_requirement_is_computed_when_querying_base Assert.Equal(typeof(Context11104.Derived1), derived1.GetType()); } - private class Context11104(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context11104(DbContextOptions options) : DbContext(options) { public DbSet Bases { get; set; } @@ -814,7 +821,8 @@ public virtual async Task Average_with_cast() Assert.Equal(prices.Average(e => e.NullableDecimalColumn), context.Prices.Average(e => e.NullableDecimalColumn)); } - private class Context11885(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context11885(DbContextOptions options) : DbContext(options) { public DbSet Prices { get; set; } @@ -912,7 +920,8 @@ public virtual async Task Parameterless_ctor_on_inner_DTO_gets_called_for_every_ Assert.False(ReferenceEquals(results[2].Inner, results[3].Inner)); } - private class Context12274(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context12274(DbContextOptions options) : DbContext(options) { public DbSet Entities { get; set; } @@ -977,7 +986,8 @@ public virtual async Task Union_and_insert_works_correctly_together() } } - private class Context12549(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context12549(DbContextOptions options) : DbContext(options) { public DbSet Tables1 { get; set; } public DbSet Tables2 { get; set; } @@ -1014,7 +1024,8 @@ public virtual async Task Repeated_parameters_in_generated_query_sql() Assert.Single(equalQuery); } - private class Context15215(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context15215(DbContextOptions options) : DbContext(options) { public DbSet Autos { get; set; } public DbSet EqualAutos { get; set; } @@ -1169,7 +1180,8 @@ public virtual async Task Operators_combine_nullability_of_entity_shapers() } } - private class Context19253(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context19253(DbContextOptions options) : DbContext(options) { public DbSet As { get; set; } public DbSet Bs { get; set; } @@ -1306,7 +1318,8 @@ public virtual async Task Null_check_removal_in_ternary_maintain_appropriate_cas : query.ToList(); } - private class Context21770(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context21770(DbContextOptions options) : DbContext(options) { public DbSet IceCreams { get; set; } public DbSet Foods { get; set; } @@ -1369,7 +1382,7 @@ public class Food #region 22841 [ConditionalFact] - public async virtual Task SaveChangesAsync_accepts_changes_with_ConfigureAwait_true() + public virtual async Task SaveChangesAsync_accepts_changes_with_ConfigureAwait_true() { var contextFactory = await InitializeAsync(); @@ -1404,7 +1417,8 @@ public async virtual Task SaveChangesAsync_accepts_changes_with_ConfigureAwait_t Assert.True(isMySyncContext); } - private class Context22841(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context22841(DbContextOptions options) : DbContext(options) { protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder @@ -1452,7 +1466,8 @@ public virtual async Task Bool_discriminator_column_works(bool async) Assert.Equal(2, authors.Count); } - private class Context24657(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context24657(DbContextOptions options) : DbContext(options) { public DbSet Authors { get; set; } @@ -1486,17 +1501,13 @@ public abstract class Blog public class DevBlog : Blog { public DevBlog() - { - IsPhotoBlog = false; - } + => IsPhotoBlog = false; } public class PhotoBlog : Blog { public PhotoBlog() - { - IsPhotoBlog = true; - } + => IsPhotoBlog = true; public int NumberOfPhotos { get; set; } } @@ -1581,7 +1592,8 @@ public virtual async Task Unwrap_convert_node_over_projection_when_translating_c : query.ToList(); } - private class Context26593(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context26593(DbContextOptions options) : DbContext(options) { public DbSet Users { get; set; } public DbSet Groups { get; set; } @@ -1640,8 +1652,7 @@ public virtual async Task GroupBy_aggregate_on_right_side_of_join(bool async) o => o.OrderId, (o, g) => new { - Key = o, - IsPending = g.Max(y => y.ShippingDate == null && y.CancellationDate == null ? o : (o - 10000000)) + Key = o, IsPending = g.Max(y => y.ShippingDate == null && y.CancellationDate == null ? o : (o - 10000000)) }) .OrderBy(e => e.Key); @@ -1654,7 +1665,8 @@ public virtual async Task GroupBy_aggregate_on_right_side_of_join(bool async) : query.ToList(); } - private class Context26587(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context26587(DbContextOptions options) : DbContext(options) { public DbSet OrderItems { get; set; } @@ -1695,7 +1707,8 @@ public virtual async Task Enum_with_value_converter_matching_take_value(bool asy : query.ToList(); } - private class Context26472(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context26472(DbContextOptions options) : DbContext(options) { public virtual DbSet Orders { get; set; } public virtual DbSet OrderItems { get; set; } @@ -1801,7 +1814,8 @@ public virtual async Task Aggregate_over_subquery_in_group_by_projection(bool as }); } - private class Context27083(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context27083(DbContextOptions options) : DbContext(options) { public DbSet TimeSheets { get; set; } public DbSet Customers { get; set; } @@ -1900,8 +1914,7 @@ group t.Id by t.Value into tg select new { - A = tg.Key, - B = context.Tables.Where(t => t.Value == tg.Max() * 6).Max(t => (int?)t.Id), + A = tg.Key, B = context.Tables.Where(t => t.Value == tg.Max() * 6).Max(t => (int?)t.Id), }; var orders = async @@ -1935,7 +1948,8 @@ select tg.Sum() + tg2.Sum() : query.ToList(); } - private class Context27094(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context27094(DbContextOptions options) : DbContext(options) { public DbSet Tables { get; set; } @@ -1999,16 +2013,15 @@ public virtual async Task SelectMany_where_Select(bool async) Assert.Single(result); } - private class Context26744(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context26744(DbContextOptions options) : DbContext(options) { public DbSet Parents { get; set; } public Task SeedAsync() { - Add( - new Parent { Children = [new() { SomeInteger = 1, SomeOtherNullableDateTime = new DateTime(2000, 11, 18) }] }); - - Add(new Parent { Children = [new() { SomeInteger = 1, }] }); + Add(new Parent { Children = [new Child { SomeInteger = 1, SomeOtherNullableDateTime = new DateTime(2000, 11, 18) }] }); + Add(new Parent { Children = [new Child { SomeInteger = 1, }] }); return SaveChangesAsync(); } @@ -2052,7 +2065,8 @@ from c in grouping.DefaultIfEmpty() Assert.Empty(result); } - private class Context27343(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context27343(DbContextOptions options) : DbContext(options) { public DbSet Parents { get; set; } @@ -2109,7 +2123,8 @@ orderby dcv.ParcelNumber : jsonLookup.ToList(); } - private class Context28039(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context28039(DbContextOptions options) : DbContext(options) { public DbSet IndexDatas { get; set; } public DbSet TableDatas { get; set; } @@ -2155,20 +2170,19 @@ public virtual async Task Filter_on_nested_DTO_with_interface_gets_simplified_co var query = await context.Customers .Select( - m => new Context31961.CustomerDto() + m => new Context31961.CustomerDto { Id = m.Id, CompanyId = m.CompanyId, Company = m.Company != null - ? new Context31961.CompanyDto() + ? new Context31961.CompanyDto { Id = m.Company.Id, CompanyName = m.Company.CompanyName, CountryId = m.Company.CountryId, - Country = new Context31961.CountryDto() + Country = new Context31961.CountryDto { - Id = m.Company.Country.Id, - CountryName = m.Company.Country.CountryName, + Id = m.Company.Country.Id, CountryName = m.Company.Country.CountryName, }, } : null, @@ -2177,7 +2191,8 @@ public virtual async Task Filter_on_nested_DTO_with_interface_gets_simplified_co .ToListAsync(); } - private class Context31961(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context31961(DbContextOptions options) : DbContext(options) { public DbSet Customers { get; set; } diff --git a/test/EFCore.Specification.Tests/Query/AdHocNavigationsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/AdHocNavigationsQueryTestBase.cs index 3ab439edd39..e078a525e00 100644 --- a/test/EFCore.Specification.Tests/Query/AdHocNavigationsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/AdHocNavigationsQueryTestBase.cs @@ -79,7 +79,8 @@ public virtual async Task ThenInclude_with_interface_navigations() } } - private class Context3409(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context3409(DbContextOptions options) : DbContext(options) { public DbSet Parents { get; set; } public DbSet Children { get; set; } @@ -201,8 +202,7 @@ protected class Context3758(DbContextOptions options) : DbContext(options) public DbSet Orders { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity( + => modelBuilder.Entity( b => { b.HasMany(e => e.Orders1).WithOne().HasForeignKey("CustomerId1"); @@ -210,7 +210,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) b.HasMany(e => e.Orders3).WithOne().HasForeignKey("CustomerId3"); b.HasMany(e => e.Orders4).WithOne().HasForeignKey("CustomerId4"); }); - } public Task SeedAsync() { @@ -313,7 +312,8 @@ public virtual async Task Reference_include_on_derived_type_with_sibling_works() } } - private class Context7312(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context7312(DbContextOptions options) : DbContext(options) { public DbSet Proposals { get; set; } public DbSet ProposalCustoms { get; set; } @@ -387,7 +387,8 @@ public virtual async Task Include_collection_optional_reference_collection() } } - private class Context9038(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context9038(DbContextOptions options) : DbContext(options) { public DbSet People { get; set; } @@ -493,7 +494,8 @@ public virtual async Task Include_with_order_by_on_interface_key() } } - private class Context10635(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context10635(DbContextOptions options) : DbContext(options) { public DbSet Parents { get; set; } public DbSet Children { get; set; } @@ -570,7 +572,8 @@ public virtual async Task Collection_without_setter_materialized_correctly() }).ToList()); } - private class Context11923(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context11923(DbContextOptions options) : DbContext(options) { public DbSet Blogs { get; set; } public DbSet Posts { get; set; } @@ -760,7 +763,8 @@ public virtual async Task Let_multiple_references_with_reference_to_outer() } } - private class Context12456(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context12456(DbContextOptions options) : DbContext(options) { public DbSet Activities { get; set; } public DbSet CompetitionSeasons { get; set; } @@ -841,7 +845,8 @@ public virtual async Task Include_collection_with_OfType_base() } } - private class Context12582(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context12582(DbContextOptions options) : DbContext(options) { public DbSet Employees { get; set; } public DbSet Devices { get; set; } @@ -903,7 +908,8 @@ public virtual async Task Correlated_collection_correctly_associates_entities_wi Assert.Single(result[0].Comments); } - private class Context12748(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context12748(DbContextOptions options) : DbContext(options) { public DbSet Blogs { get; set; } public DbSet Comments { get; set; } @@ -1010,7 +1016,8 @@ public virtual async Task SelectMany_and_collection_in_projection_in_FirstOrDefa }).SingleOrDefault(); } - private class Context20813(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context20813(DbContextOptions options) : DbContext(options) { public DbSet Orders { get; set; } @@ -1088,7 +1095,8 @@ public virtual async Task Using_explicit_interface_implementation_as_navigation_ var result = context.Books.Where(b => b.Id == 1).Select(projection).SingleOrDefault(); } - private class Context21768(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context21768(DbContextOptions options) : DbContext(options) { public DbSet Books { get; set; } public DbSet BookCovers { get; set; } @@ -1274,10 +1282,7 @@ public Task SeedAsync() { Add(new PrincipalOneToOne { Dependent = new DependentOneToOne() }); Add( - new PrincipalOneToMany - { - Dependents = [new(), new()] - }); + new PrincipalOneToMany { Dependents = [new DependentOneToMany(), new DependentOneToMany()] }); return SaveChangesAsync(); } @@ -1431,12 +1436,12 @@ public virtual async Task Walking_back_include_tree_is_not_allowed_4() } } - private class Context23674(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context23674(DbContextOptions options) : DbContext(options) { protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.Entity(); - public class Principal { public int Id { get; set; } @@ -1516,7 +1521,8 @@ public virtual async Task Projection_with_multiple_includes_and_subquery_with_se .FirstOrDefaultAsync(x => x.Id == id); } - private class Context23676(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context23676(DbContextOptions options) : DbContext(options) { public DbSet Persons { get; set; } diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsCollectionsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsCollectionsQueryTestBase.cs index e1ce7bcb771..7c18447c42f 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsCollectionsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsCollectionsQueryTestBase.cs @@ -2533,17 +2533,18 @@ public virtual Task Final_GroupBy_property_entity_Include_reference_multiple(boo public virtual Task Project_collection_and_nested_conditional(bool async) => AssertQuery( async, - ss => ss.Set().OrderBy(x => x.Id).Select(x => new - { - Collection = x.OneToMany_Optional1.OrderBy(xx => xx.Id).Select(xx => xx.Name).ToList(), - Condition = x.Id == 1 - ? "01" - : x.Id == 2 - ? "02" - : x.Id == 3 - ? "03" - : null - }).Where(x => x.Condition == "02"), + ss => ss.Set().OrderBy(x => x.Id).Select( + x => new + { + Collection = x.OneToMany_Optional1.OrderBy(xx => xx.Id).Select(xx => xx.Name).ToList(), + Condition = x.Id == 1 + ? "01" + : x.Id == 2 + ? "02" + : x.Id == 3 + ? "03" + : null + }).Where(x => x.Condition == "02"), assertOrder: true, elementAsserter: (e, a) => { diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs index 4c79717d07b..a9eb2f70f43 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.CodeDom.Compiler; using Microsoft.EntityFrameworkCore.TestModels.ComplexNavigationsModel; #pragma warning disable RCS1155 // Use StringComparison when comparing strings. @@ -1727,18 +1726,18 @@ public virtual Task Required_navigation_on_a_subquery_with_First_in_predicate(bo .Where( l1 => EF.Property( ss.Set().OrderBy(l2i => l2i.Id).First().OneToOne_Required_FK_Inverse2, "Name") - == "L1 10" || - EF.Property( + == "L1 10" + || EF.Property( ss.Set().OrderBy(l2i => l2i.Id).First().OneToOne_Required_FK_Inverse2, "Name") == "L1 01")); - //=> AssertQuery( - // async, - // ss => ss.Set() - // .Where(l2o => l2o.Id == 7) - // .Where( - // l1 => EF.Property( - // ss.Set().OrderBy(l2i => l2i.Id).First().OneToOne_Required_FK_Inverse2, "Name") - // == "L1 10")); + //=> AssertQuery( + // async, + // ss => ss.Set() + // .Where(l2o => l2o.Id == 7) + // .Where( + // l1 => EF.Property( + // ss.Set().OrderBy(l2i => l2i.Id).First().OneToOne_Required_FK_Inverse2, "Name") + // == "L1 10")); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -2204,8 +2203,9 @@ public virtual Task Where_on_multilevel_reference_in_subquery_with_outer_project => AssertQuery( async, ss => ss.Set() - .Where(l3 => l3.OneToMany_Required_Inverse3.OneToOne_Required_FK_Inverse2.Name == "L1 10" - || l3.OneToMany_Required_Inverse3.OneToOne_Required_FK_Inverse2.Name == "L1 01") + .Where( + l3 => l3.OneToMany_Required_Inverse3.OneToOne_Required_FK_Inverse2.Name == "L1 10" + || l3.OneToMany_Required_Inverse3.OneToOne_Required_FK_Inverse2.Name == "L1 01") .OrderBy(l3 => l3.Level2_Required_Id) .Skip(0) .Take(10) @@ -2237,8 +2237,7 @@ join l2 in ss.Set() } equals new { - A = EF.Property(l2, "Level1_Optional_Id"), - B = EF.Property(l2, "OneToMany_Optional_Self_Inverse2Id") + A = EF.Property(l2, "Level1_Optional_Id"), B = EF.Property(l2, "OneToMany_Optional_Self_Inverse2Id") } select l1); @@ -3296,8 +3295,7 @@ public virtual Task Member_over_null_check_ternary_and_nested_dto_type(bool asyn ? null : new Level2Dto { - Id = l1.OneToOne_Optional_FK1.Id, - Name = l1.OneToOne_Optional_FK1.Name, + Id = l1.OneToOne_Optional_FK1.Id, Name = l1.OneToOne_Optional_FK1.Name, } }) .OrderBy(e => e.Level2.Name) @@ -3435,8 +3433,7 @@ public virtual Task Composite_key_join_on_groupby_aggregate_projecting_only_grou o => new { o.Id, Condition = true }, i => new { - Id = i.Key, - Condition = i.Sum > 10, + Id = i.Key, Condition = i.Sum > 10, }, (o, i) => i.Key)); @@ -3451,8 +3448,7 @@ public virtual Task Composite_key_join_on_groupby_aggregate_projecting_only_grou o => new { o.Id, Condition = false }, i => new { - Id = i.Key, - Condition = i.Sum <= 10, + Id = i.Key, Condition = i.Sum <= 10, }, (o, i) => i.Key)); @@ -3757,8 +3753,7 @@ public virtual Task Project_shadow_properties8(bool async) ss => from x in ss.Set() select new { - x.Id, - InheritanceLeaf2Id = EF.Property(x, "InheritanceLeaf2Id"), + x.Id, InheritanceLeaf2Id = EF.Property(x, "InheritanceLeaf2Id"), }, elementSorter: e => e.Id); @@ -3965,9 +3960,10 @@ from l3 in grouping2.Where(x => x.Id != prm) public virtual Task Multiple_optional_navs_should_not_deadlock(bool async) => AssertCount( async, - ss => ss.Set().Where(x => x.OneToMany_Optional_Inverse2 != null - && x.OneToMany_Optional_Inverse2.Name.Contains("L1 01") - || x.OneToOne_Optional_FK_Inverse2 != null + ss => ss.Set().Where( + x => x.OneToMany_Optional_Inverse2 != null + && x.OneToMany_Optional_Inverse2.Name.Contains("L1 01") + || x.OneToOne_Optional_FK_Inverse2 != null && x.OneToOne_Optional_FK_Inverse2.Name.Contains("L1 01"))); [ConditionalTheory] @@ -4015,18 +4011,21 @@ public virtual Task Null_check_removal_applied_recursively_complex(bool async) public virtual Task Correlated_projection_with_first(bool async) => AssertQuery( async, - ss => ss.Set().Select(x => new - { - x.Id, - Results = x.OneToMany_Optional1.OrderBy(xx => xx.Id).First().OneToMany_Optional2.Select(xx => xx.OneToOne_Required_FK3.Id) - }), - ss => ss.Set().Select(x => new - { - x.Id, - Results = x.OneToMany_Optional1.OrderBy(xx => xx.Id).Any() - ? x.OneToMany_Optional1.OrderBy(xx => xx.Id).First().OneToMany_Optional2.Select(xx => xx.OneToOne_Required_FK3.Id) - : new List() - }), + ss => ss.Set().Select( + x => new + { + x.Id, + Results = x.OneToMany_Optional1.OrderBy(xx => xx.Id).First().OneToMany_Optional2 + .Select(xx => xx.OneToOne_Required_FK3.Id) + }), + ss => ss.Set().Select( + x => new + { + x.Id, + Results = x.OneToMany_Optional1.OrderBy(xx => xx.Id).Any() + ? x.OneToMany_Optional1.OrderBy(xx => xx.Id).First().OneToMany_Optional2.Select(xx => xx.OneToOne_Required_FK3.Id) + : new List() + }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -4039,23 +4038,26 @@ public virtual Task Correlated_projection_with_first(bool async) public virtual Task Max_in_multi_level_nested_subquery(bool async) => AssertQuery( async, - ss => ss.Set().OrderBy(l1 => l1.Id).Take(2).Select(x => new - { - x.Id, - LevelTwos = x.OneToMany_Optional1.AsQueryable().Select(xx => new + ss => ss.Set().OrderBy(l1 => l1.Id).Take(2).Select( + x => new { - xx.Id, - LevelThree = new - { - xx.OneToOne_Required_FK2.Id, - LevelFour = new + x.Id, + LevelTwos = x.OneToMany_Optional1.AsQueryable().Select( + xx => new { - xx.OneToOne_Required_FK2.OneToOne_Required_FK3.Id, - Result = (xx.OneToOne_Required_FK2.OneToMany_Optional3.Max(xxx => (int?)xxx.Id) ?? 0) > 1 - } - } - }).ToList() - }), + xx.Id, + LevelThree = new + { + xx.OneToOne_Required_FK2.Id, + LevelFour = new + { + xx.OneToOne_Required_FK2.OneToOne_Required_FK3.Id, + Result = (xx.OneToOne_Required_FK2.OneToMany_Optional3.Max(xxx => (int?)xxx.Id) ?? 0) + > 1 + } + } + }).ToList() + }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -4078,20 +4080,17 @@ public virtual Task Max_in_multi_level_nested_subquery(bool async) public virtual Task Multiple_select_many_in_projection(bool async) => AssertQuery( async, - ss => ss.Set().Select(x => new - { - x.Id, - Collection = x.OneToMany_Optional1 - .SelectMany(xx => xx.OneToMany_Optional2) - .OrderBy(xx => xx.Id).Take(12) - .Select(xx => new - { - xx.Id, - RefId = xx.OneToOne_Optional_FK3.Id - }).ToList(), - Count = x.OneToMany_Optional1 - .SelectMany(xx => xx.OneToMany_Optional2).Count(xx => xx.Name != "") - }), + ss => ss.Set().Select( + x => new + { + x.Id, + Collection = x.OneToMany_Optional1 + .SelectMany(xx => xx.OneToMany_Optional2) + .OrderBy(xx => xx.Id).Take(12) + .Select(xx => new { xx.Id, RefId = xx.OneToOne_Optional_FK3.Id }).ToList(), + Count = x.OneToMany_Optional1 + .SelectMany(xx => xx.OneToMany_Optional2).Count(xx => xx.Name != "") + }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -4113,18 +4112,15 @@ public virtual Task Multiple_select_many_in_projection(bool async) public virtual Task Single_select_many_in_projection_with_take(bool async) => AssertQuery( async, - ss => ss.Set().Select(x => new - { - x.Id, - Collection = x.OneToMany_Optional1 - .SelectMany(xx => xx.OneToMany_Optional2) - .OrderBy(xx => xx.Id).Take(12) - .Select(xx => new - { - xx.Id, - RefId = xx.OneToOne_Optional_FK3.Id - }).ToList(), - }), + ss => ss.Set().Select( + x => new + { + x.Id, + Collection = x.OneToMany_Optional1 + .SelectMany(xx => xx.OneToMany_Optional2) + .OrderBy(xx => xx.Id).Take(12) + .Select(xx => new { xx.Id, RefId = xx.OneToOne_Optional_FK3.Id }).ToList(), + }), elementSorter: e => e.Id, elementAsserter: (e, a) => { diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryTestBase.cs index f8431bf9861..1c7c4db433d 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryTestBase.cs @@ -70,7 +70,8 @@ public override Task Project_shadow_properties9(bool async) public override async Task Null_check_removal_applied_recursively_complex(bool async) { - var message = (await Assert.ThrowsAsync(() => base.Null_check_removal_applied_recursively_complex(async))).Message; + var message = + (await Assert.ThrowsAsync(() => base.Null_check_removal_applied_recursively_complex(async))).Message; Assert.Equal(CoreStrings.IncludeOnNonEntity("x => x.OneToMany_Required_Inverse3"), message); } diff --git a/test/EFCore.Specification.Tests/Query/ComplexTypeQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexTypeQueryTestBase.cs index c052448915d..51a6f55d5bd 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexTypeQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexTypeQueryTestBase.cs @@ -10,9 +10,7 @@ public abstract class ComplexTypeQueryTestBase : QueryTestBase fixture.ListLoggerFactory.Clear(); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -322,12 +320,11 @@ public virtual Task Filter_on_property_inside_nested_struct_complex_type_after_s [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Filter_on_required_property_inside_required_struct_complex_type_on_optional_navigation(bool async) - { - return AssertQuery( + => AssertQuery( async, ss => ss.Set().Where(cg => cg.OptionalCustomer!.ShippingAddress.ZipCode != 07728), - ss => ss.Set().Where(cg => cg.OptionalCustomer == null || cg.OptionalCustomer.ShippingAddress.ZipCode != 07728)); - } + ss => ss.Set() + .Where(cg => cg.OptionalCustomer == null || cg.OptionalCustomer.ShippingAddress.ZipCode != 07728)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -679,10 +676,11 @@ public virtual Task Union_of_same_entity_with_nested_complex_type_projected_twic from c2 in ss.Set() orderby c1.Id, c2.Id select new { c1, c2 }) - .Union(from c1 in ss.Set() - from c2 in ss.Set() - orderby c1.Id, c2.Id - select new { c1, c2 }) + .Union( + from c1 in ss.Set() + from c2 in ss.Set() + orderby c1.Id, c2.Id + select new { c1, c2 }) .OrderBy(x => x.c1.Id).ThenBy(x => x.c2.Id) .Take(50) .Select(x => new { x.c1, x.c2 }), @@ -702,10 +700,11 @@ public virtual Task Union_of_same_entity_with_nested_complex_type_projected_twic from c2 in ss.Set() orderby c1.Id, c2.Id select new { c1, c2 }) - .Union(from c1 in ss.Set() - from c2 in ss.Set() - orderby c1.Id, c2.Id - select new { c1, c2 }) + .Union( + from c1 in ss.Set() + from c2 in ss.Set() + orderby c1.Id, c2.Id + select new { c1, c2 }) .OrderBy(x => x.c1.Id).ThenBy(x => x.c2.Id) .Take(50) .Select(x => new { x.c1, x.c2 }) @@ -729,10 +728,11 @@ public virtual Task Union_of_same_nested_complex_type_projected_twice_with_pushd from c2 in ss.Set() orderby c1.Id, c2.Id select new { BA1 = c1.BillingAddress, BA2 = c2.BillingAddress }) - .Union(from c1 in ss.Set() - from c2 in ss.Set() - orderby c1.Id, c2.Id - select new { BA1 = c1.BillingAddress, BA2 = c2.BillingAddress }) + .Union( + from c1 in ss.Set() + from c2 in ss.Set() + orderby c1.Id, c2.Id + select new { BA1 = c1.BillingAddress, BA2 = c2.BillingAddress }) .OrderBy(x => x.BA1.ZipCode).ThenBy(x => x.BA2.ZipCode) .Take(50) .Select(x => new { x.BA1, x.BA2 }), @@ -752,10 +752,11 @@ public virtual Task Union_of_same_nested_complex_type_projected_twice_with_doubl from c2 in ss.Set() orderby c1.Id, c2.Id select new { BA1 = c1.BillingAddress, BA2 = c2.BillingAddress }) - .Union(from c1 in ss.Set() - from c2 in ss.Set() - orderby c1.Id, c2.Id - select new { BA1 = c1.BillingAddress, BA2 = c2.BillingAddress }) + .Union( + from c1 in ss.Set() + from c2 in ss.Set() + orderby c1.Id, c2.Id + select new { BA1 = c1.BillingAddress, BA2 = c2.BillingAddress }) .OrderBy(x => x.BA1.ZipCode).ThenBy(x => x.BA2.ZipCode) .Take(50) .Select(x => new { x.BA1, x.BA2 }) @@ -775,14 +776,15 @@ from c2 in ss.Set() public virtual Task Same_entity_with_complex_type_projected_twice_with_pushdown_as_part_of_another_projection(bool async) => AssertQuery( async, - ss => ss.Set().Select(x => new - { - x.Id, - Complex = (from c1 in ss.Set() - from c2 in ss.Set() - orderby c1.Id, c2.Id descending - select new { One = c1, Two = c2 }).FirstOrDefault() - }), + ss => ss.Set().Select( + x => new + { + x.Id, + Complex = (from c1 in ss.Set() + from c2 in ss.Set() + orderby c1.Id, c2.Id descending + select new { One = c1, Two = c2 }).FirstOrDefault() + }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -796,14 +798,15 @@ from c2 in ss.Set() public virtual Task Same_complex_type_projected_twice_with_pushdown_as_part_of_another_projection(bool async) => AssertQuery( async, - ss => ss.Set().Select(x => new - { - x.Id, - Complex = (from c1 in ss.Set() - from c2 in ss.Set() - orderby c1.Id, c2.Id descending - select new { One = c1.BillingAddress, Two = c2.BillingAddress }).FirstOrDefault() - }), + ss => ss.Set().Select( + x => new + { + x.Id, + Complex = (from c1 in ss.Set() + from c2 in ss.Set() + orderby c1.Id, c2.Id descending + select new { One = c1.BillingAddress, Two = c2.BillingAddress }).FirstOrDefault() + }), elementSorter: e => e.Id, elementAsserter: (e, a) => { diff --git a/test/EFCore.Specification.Tests/Query/FilteredQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/FilteredQueryTestBase.cs index f8c14e5afaf..f3549470a7d 100644 --- a/test/EFCore.Specification.Tests/Query/FilteredQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/FilteredQueryTestBase.cs @@ -54,7 +54,8 @@ public Task AssertFilteredQueryScalar( bool assertEmpty = false, [CallerMemberName] string testMethodName = null) where TResult : struct - => QueryAsserter.AssertQueryScalar(actualQuery, expectedQuery, asserter, assertOrder, assertEmpty, async, testMethodName, filteredQuery: true); + => QueryAsserter.AssertQueryScalar( + actualQuery, expectedQuery, asserter, assertOrder, assertEmpty, async, testMethodName, filteredQuery: true); protected Task AssertFilteredCount( bool async, diff --git a/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs index bab811541e9..bb78977da6e 100644 --- a/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs @@ -539,7 +539,6 @@ public virtual Task String_FirstOrDefault_and_LastOrDefault(bool async) AssertEqual(e.last, a.last); }); - [ConditionalTheory] // #32432 [MemberData(nameof(IsAsyncData))] public virtual Task String_Contains_and_StartsWith_with_same_parameter(bool async) diff --git a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs index fb245ad579c..ec8180be84c 100644 --- a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs @@ -683,8 +683,7 @@ public virtual Task Select_enum_has_flag(bool async) .Select( b => new { - hasFlagTrue = b.Rank.HasFlag(MilitaryRank.Corporal), - hasFlagFalse = b.Rank.HasFlag(MilitaryRank.Sergeant) + hasFlagTrue = b.Rank.HasFlag(MilitaryRank.Corporal), hasFlagFalse = b.Rank.HasFlag(MilitaryRank.Sergeant) })); [ConditionalTheory] @@ -1136,11 +1135,11 @@ public virtual Task Where_compare_anonymous_types(bool async) ss => from g in ss.Set() from o in ss.Set().OfType() where new - { - Name = g.LeaderNickname, - Squad = g.LeaderSquadId, - Five = 5 - } + { + Name = g.LeaderNickname, + Squad = g.LeaderSquadId, + Five = 5 + } == new { Name = o.Nickname, @@ -2846,7 +2845,7 @@ public virtual Task Comparing_two_collection_navigations_composite_key(bool asyn async, ss => from g1 in ss.Set() from g2 in ss.Set() - // ReSharper disable once PossibleUnintendedReferenceComparison + // ReSharper disable once PossibleUnintendedReferenceComparison where g1.Weapons == g2.Weapons orderby g1.Nickname select new { Nickname1 = g1.Nickname, Nickname2 = g2.Nickname }, @@ -5597,22 +5596,22 @@ public virtual Task Navigation_based_on_complex_expression3(bool async) public virtual async Task Navigation_based_on_complex_expression4(bool async) // Nav expansion. Issue #17782. => await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => from lc1 in ss.Set().Select(f => (f is LocustHorde) ? ((LocustHorde)f).Commander : null) - from lc2 in ss.Set().OfType() - select (lc1 ?? lc2).DefeatedBy)); + () => AssertQuery( + async, + ss => from lc1 in ss.Set().Select(f => (f is LocustHorde) ? ((LocustHorde)f).Commander : null) + from lc2 in ss.Set().OfType() + select (lc1 ?? lc2).DefeatedBy)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Navigation_based_on_complex_expression5(bool async) // Nav expansion. Issue #17782. => await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => from lc1 in ss.Set().OfType().Select(lh => lh.Commander) - join lc2 in ss.Set().OfType() on true equals true - select (lc1 ?? lc2).DefeatedBy)); + () => AssertQuery( + async, + ss => from lc1 in ss.Set().OfType().Select(lh => lh.Commander) + join lc2 in ss.Set().OfType() on true equals true + select (lc1 ?? lc2).DefeatedBy)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -6828,11 +6827,13 @@ public virtual Task FirstOrDefault_over_int_compared_to_zero(bool async) => AssertQuery( async, ss => ss.Set().Where(s => s.Name == "Delta") - .Where(s => s.Members - .Where(m => m.HasSoulPatch) - .OrderBy(m => m.FullName) - .Select(m => m.SquadId) - .FirstOrDefault() != 0) + .Where( + s => s.Members + .Where(m => m.HasSoulPatch) + .OrderBy(m => m.FullName) + .Select(m => m.SquadId) + .FirstOrDefault() + != 0) .Select(s => s.Name), elementSorter: e => e); @@ -8258,10 +8259,12 @@ public virtual Task Where_subquery_equality_to_null_with_composite_key(bool asyn public virtual Task Where_subquery_equality_to_null_with_composite_key_should_match_nulls(bool async) => AssertQuery( async, - ss => ss.Set().Where(s => s.Members - .Where(m => m.FullName == "Anthony Carmine") - .OrderBy(e => e.Nickname) - .FirstOrDefault() == null)); + ss => ss.Set().Where( + s => s.Members + .Where(m => m.FullName == "Anthony Carmine") + .OrderBy(e => e.Nickname) + .FirstOrDefault() + == null)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -8276,7 +8279,8 @@ public virtual Task Where_subquery_equality_to_null_without_composite_key(bool a public virtual Task Where_subquery_equality_to_null_without_composite_key_should_match_null(bool async) => AssertQuery( async, - ss => ss.Set().Where(s => s.Weapons.Where(w => w.Name == "Hammer of Dawn").OrderBy(e => e.Name).FirstOrDefault() == null)); + ss => ss.Set().Where( + s => s.Weapons.Where(w => w.Name == "Hammer of Dawn").OrderBy(e => e.Name).FirstOrDefault() == null)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -8477,12 +8481,12 @@ public virtual Task Find_underlying_property_after_GroupJoin_DefaultIfEmpty(bool async, ss => from g in ss.Set() join lc in ss.Set().OfType() - on g.Nickname equals lc.DefeatedByNickname into grouping + on g.Nickname equals lc.DefeatedByNickname into grouping from lc in grouping.DefaultIfEmpty() select new GearLocustLeaderDto { FullName = g.FullName, ThreatLevel = lc.ThreatLevel }, ss => from g in ss.Set() join lc in ss.Set().OfType() - on g.Nickname equals lc.DefeatedByNickname into grouping + on g.Nickname equals lc.DefeatedByNickname into grouping from lc in grouping.DefaultIfEmpty() select new GearLocustLeaderDto { FullName = g.FullName, ThreatLevel = lc != null ? lc.ThreatLevel : null }, elementSorter: e => (e.FullName, e.ThreatLevel), @@ -8548,7 +8552,12 @@ await AssertQuery( ss => from g in ss.Set().Include(x => x.Weapons) join o in ss.Set() on g.LeaderNickname equals o.Nickname into grouping from o in grouping.DefaultIfEmpty() - select new { One = 1, Result = o ?? (g ?? o), IsMarcus = g.Nickname == "Marcus" }, + select new + { + One = 1, + Result = o ?? (g ?? o), + IsMarcus = g.Nickname == "Marcus" + }, elementSorter: e => e.Result.Nickname, elementAsserter: (e, a) => { @@ -8568,7 +8577,12 @@ await AssertQuery( ss => from g in ss.Set() join o in ss.Set().Include(x => x.Weapons) on g.LeaderNickname equals o.Nickname into grouping from o in grouping.DefaultIfEmpty() - select new { One = 1, Two = o, Result = o ?? (g ?? o) }, + select new + { + One = 1, + Two = o, + Result = o ?? (g ?? o) + }, elementSorter: e => e.Result.Nickname, elementAsserter: (e, a) => { @@ -8627,7 +8641,6 @@ await AssertQuery( ss => ss.Set().Where(x => keys.Contains(ammoTypes.Contains(x.AmmunitionType) ? key : key))); } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] // Issue #33330 public virtual Task Non_string_concat_uses_appropriate_type_mapping(bool async) diff --git a/test/EFCore.Specification.Tests/Query/JsonQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/JsonQueryTestBase.cs index 2aebccf72a6..b7cfe2ae3ce 100644 --- a/test/EFCore.Specification.Tests/Query/JsonQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/JsonQueryTestBase.cs @@ -302,8 +302,7 @@ public virtual Task Basic_json_projection_enum_inside_json_entity(bool async) ss => ss.Set().Select( x => new { - x.Id, - x.OwnedReferenceRoot.OwnedReferenceBranch.Enum, + x.Id, x.OwnedReferenceRoot.OwnedReferenceBranch.Enum, }), elementSorter: e => e.Id, elementAsserter: (e, a) => @@ -320,8 +319,7 @@ public virtual Task Json_projection_enum_with_custom_conversion(bool async) ss => ss.Set().Select( x => new { - x.Id, - x.OwnedReferenceRoot.Enum, + x.Id, x.OwnedReferenceRoot.Enum, }), elementSorter: e => e.Id, elementAsserter: (e, a) => @@ -1109,7 +1107,8 @@ public virtual Task Json_collection_index_in_predicate_nested_mix(bool async) return AssertQuery( async, ss => ss.Set().Where( - x => x.OwnedCollectionRoot[1].OwnedCollectionBranch[prm].OwnedCollectionLeaf[x.Id - 1].SomethingSomething == "e1_c2_c1_c1")); + x => x.OwnedCollectionRoot[1].OwnedCollectionBranch[prm].OwnedCollectionLeaf[x.Id - 1].SomethingSomething + == "e1_c2_c1_c1")); } [ConditionalTheory] @@ -1443,8 +1442,7 @@ public virtual Task Json_branch_collection_distinct_and_other_collection(bool as .Select( x => new { - First = x.OwnedReferenceRoot.OwnedCollectionBranch.Distinct().ToList(), - Second = x.EntityCollection.ToList() + First = x.OwnedReferenceRoot.OwnedCollectionBranch.Distinct().ToList(), Second = x.EntityCollection.ToList() }) .AsNoTracking(), assertOrder: true, @@ -1825,8 +1823,7 @@ public virtual Task Json_collection_index_in_projection_when_owner_is_present_mi ss => ss.Set().Select( x => new { - x, - CollectionElement = x.OwnedCollectionRoot[1].OwnedCollectionBranch[prm], + x, CollectionElement = x.OwnedCollectionRoot[1].OwnedCollectionBranch[prm], }).AsNoTracking(), elementSorter: e => e.x.Id, elementAsserter: (e, a) => @@ -1847,8 +1844,7 @@ public virtual Task Json_collection_index_in_projection_when_owner_is_not_presen ss => ss.Set().Select( x => new { - x.Id, - CollectionElement = x.OwnedCollectionRoot[1].OwnedCollectionBranch[prm], + x.Id, CollectionElement = x.OwnedCollectionRoot[1].OwnedCollectionBranch[prm], }).AsNoTracking(), elementSorter: e => e.Id, elementAsserter: (e, a) => @@ -2586,8 +2582,7 @@ public virtual Task Json_predicate_on_string_Y_N_converted_to_bool(bool async) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Json_projection_collection_element_and_reference_AsNoTrackingWithIdentityResolution(bool async) - { - return AssertQuery( + => AssertQuery( async, ss => ss.Set().Select( x => new @@ -2603,42 +2598,29 @@ public virtual Task Json_projection_collection_element_and_reference_AsNoTrackin AssertEqual(e.CollectionElement, a.CollectionElement); AssertEqual(e.Reference, a.Reference); }); - } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Json_projection_nothing_interesting_AsNoTrackingWithIdentityResolution(bool async) - { - return AssertQuery( + => AssertQuery( async, ss => ss.Set().Select( - x => new - { - x.Id, - x.Name - }).AsNoTrackingWithIdentityResolution(), + x => new { x.Id, x.Name }).AsNoTrackingWithIdentityResolution(), elementSorter: e => e.Id); - } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Json_projection_owner_entity_AsNoTrackingWithIdentityResolution(bool async) - { - return AssertQuery( + => AssertQuery( async, ss => ss.Set().Select( - x => new - { - x.Id, - x - }).AsNoTrackingWithIdentityResolution(), + x => new { x.Id, x }).AsNoTrackingWithIdentityResolution(), elementSorter: e => e.Id, elementAsserter: (e, a) => { AssertEqual(e.Id, a.Id); AssertEqual(e.x, a.x); }); - } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -2672,7 +2654,9 @@ public virtual Task Json_nested_collection_anonymous_projection_of_primitives_in [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Json_projection_second_element_through_collection_element_constant_projected_after_owner_nested_AsNoTrackingWithIdentityResolution(bool async) + public virtual Task + Json_projection_second_element_through_collection_element_constant_projected_after_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) => AssertQuery( async, ss => ss.Set().Select( @@ -2714,7 +2698,9 @@ public virtual Task Json_projection_reference_collection_and_collection_element_ [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Json_projection_second_element_through_collection_element_parameter_correctly_projected_after_owner_nested_AsNoTrackingWithIdentityResolution(bool async) + public virtual Task + Json_projection_second_element_through_collection_element_parameter_correctly_projected_after_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) { var prm = 1; @@ -2738,14 +2724,15 @@ public virtual Task Json_projection_second_element_through_collection_element_pa [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Json_projection_only_second_element_through_collection_element_constant_projected_nested_AsNoTrackingWithIdentityResolution(bool async) + public virtual Task + Json_projection_only_second_element_through_collection_element_constant_projected_nested_AsNoTrackingWithIdentityResolution( + bool async) => AssertQuery( async, ss => ss.Set().Select( x => new { - x.Id, - Element = x.OwnedReferenceRoot.OwnedCollectionBranch[0].OwnedCollectionLeaf[1], + x.Id, Element = x.OwnedReferenceRoot.OwnedCollectionBranch[0].OwnedCollectionLeaf[1], }).AsNoTrackingWithIdentityResolution(), elementSorter: e => e.Id, elementAsserter: (e, a) => @@ -2756,7 +2743,9 @@ public virtual Task Json_projection_only_second_element_through_collection_eleme [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Json_projection_only_second_element_through_collection_element_parameter_projected_nested_AsNoTrackingWithIdentityResolution(bool async) + public virtual Task + Json_projection_only_second_element_through_collection_element_parameter_projected_nested_AsNoTrackingWithIdentityResolution( + bool async) { var prm1 = 0; var prm2 = 1; @@ -2766,8 +2755,7 @@ public virtual Task Json_projection_only_second_element_through_collection_eleme ss => ss.Set().Select( x => new { - x.Id, - Element = x.OwnedReferenceRoot.OwnedCollectionBranch[prm1].OwnedCollectionLeaf[prm2], + x.Id, Element = x.OwnedReferenceRoot.OwnedCollectionBranch[prm1].OwnedCollectionLeaf[prm2], }).AsNoTrackingWithIdentityResolution(), elementSorter: e => e.Id, elementAsserter: (e, a) => @@ -2779,9 +2767,10 @@ public virtual Task Json_projection_only_second_element_through_collection_eleme [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Json_projection_second_element_through_collection_element_constant_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution(bool async) - { - return AssertQuery( + public virtual Task + Json_projection_second_element_through_collection_element_constant_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) + => AssertQuery( async, ss => ss.Set().Select( x => new @@ -2797,13 +2786,11 @@ public virtual Task Json_projection_second_element_through_collection_element_co AssertEqual(e.Duplicate, a.Duplicate); AssertCollection(e.Original, a.Original, ordered: true); }); - } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Json_projection_nested_collection_and_element_correct_order_AsNoTrackingWithIdentityResolution(bool async) - { - return AssertQuery( + => AssertQuery( async, ss => ss.Set().Select( x => new @@ -2819,11 +2806,12 @@ public virtual Task Json_projection_nested_collection_and_element_correct_order_ AssertCollection(e.Original, a.Original, ordered: true); AssertEqual(e.Duplicate, a.Duplicate); }); - } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Json_projection_nested_collection_element_using_parameter_and_the_owner_in_correct_order_AsNoTrackingWithIdentityResolution(bool async) + public virtual Task + Json_projection_nested_collection_element_using_parameter_and_the_owner_in_correct_order_AsNoTrackingWithIdentityResolution( + bool async) { var prm = 0; return AssertQuery( @@ -2847,8 +2835,7 @@ public virtual Task Json_projection_nested_collection_element_using_parameter_an [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Json_projection_second_element_projected_before_owner_as_well_as_root_AsNoTrackingWithIdentityResolution(bool async) - { - return AssertQuery( + => AssertQuery( async, ss => ss.Set().Select( x => new @@ -2865,11 +2852,11 @@ public virtual Task Json_projection_second_element_projected_before_owner_as_wel AssertEqual(e.Original, a.Original); AssertEqual(e.Duplicate, a.Duplicate); }); - } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Json_projection_second_element_projected_before_owner_nested_as_well_as_root_AsNoTrackingWithIdentityResolution(bool async) + public virtual Task Json_projection_second_element_projected_before_owner_nested_as_well_as_root_AsNoTrackingWithIdentityResolution( + bool async) => AssertQuery( async, ss => ss.Set().Select( diff --git a/test/EFCore.Specification.Tests/Query/NonSharedPrimitiveCollectionsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NonSharedPrimitiveCollectionsQueryTestBase.cs index 168c491f486..a49d0f9dc8d 100644 --- a/test/EFCore.Specification.Tests/Query/NonSharedPrimitiveCollectionsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NonSharedPrimitiveCollectionsQueryTestBase.cs @@ -223,8 +223,18 @@ public virtual async Task Project_collection_from_entity_type_with_owned() seed: context => { context.AddRange( - new TestEntityWithOwned { Id = 1, Ints = [1, 2], Owned = new Owned { Foo = 0 } }, - new TestEntityWithOwned { Id = 2, Ints = [3, 4], Owned = new Owned { Foo = 1 } }); + new TestEntityWithOwned + { + Id = 1, + Ints = [1, 2], + Owned = new Owned { Foo = 0 } + }, + new TestEntityWithOwned + { + Id = 2, + Ints = [3, 4], + Owned = new Owned { Foo = 1 } + }); return context.SaveChangesAsync(); }); diff --git a/test/EFCore.Specification.Tests/Query/NorthwindCompiledQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindCompiledQueryTestBase.cs index 17450108311..f83e32ebcf6 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindCompiledQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindCompiledQueryTestBase.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.EntityFrameworkCore.TestModels.Northwind; -using Xunit.Sdk; // ReSharper disable AccessToModifiedClosure // ReSharper disable InconsistentNaming diff --git a/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs index e34aaf66c39..81015e204f9 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs @@ -88,25 +88,29 @@ public virtual Task String_StartsWith_with_StringComparison_OrdinalIgnoreCase(bo [MemberData(nameof(IsAsyncData))] public virtual async Task String_StartsWith_with_StringComparison_unsupported(bool async) { - await AssertTranslationFailed(() => - AssertQuery( - async, - ss => ss.Set().Where(c => c.CompanyName.StartsWith("Qu", StringComparison.CurrentCulture)))); - - await AssertTranslationFailed(() => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.CurrentCultureIgnoreCase)))); - - await AssertTranslationFailed(() => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("Qu", StringComparison.InvariantCulture)))); - - await AssertTranslationFailed(() => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("Qu", StringComparison.InvariantCultureIgnoreCase)))); + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.CompanyName.StartsWith("Qu", StringComparison.CurrentCulture)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.CurrentCultureIgnoreCase)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.ContactName.Contains("Qu", StringComparison.InvariantCulture)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.ContactName.Contains("Qu", StringComparison.InvariantCultureIgnoreCase)))); } #endregion String.StartsWith @@ -171,25 +175,29 @@ public virtual Task String_EndsWith_with_StringComparison_OrdinalIgnoreCase(bool [MemberData(nameof(IsAsyncData))] public virtual async Task String_EndsWith_with_StringComparison_unsupported(bool async) { - await AssertTranslationFailed(() => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.EndsWith("Qu", StringComparison.CurrentCulture)))); - - await AssertTranslationFailed(() => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.CurrentCultureIgnoreCase)))); - - await AssertTranslationFailed(() => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("Qu", StringComparison.InvariantCulture)))); - - await AssertTranslationFailed(() => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("Qu", StringComparison.InvariantCultureIgnoreCase)))); + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.ContactName.EndsWith("Qu", StringComparison.CurrentCulture)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.CurrentCultureIgnoreCase)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.ContactName.Contains("Qu", StringComparison.InvariantCulture)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.ContactName.Contains("Qu", StringComparison.InvariantCultureIgnoreCase)))); } #endregion String.EndsWith @@ -258,25 +266,29 @@ public virtual Task String_Contains_with_StringComparison_OrdinalIgnoreCase(bool [MemberData(nameof(IsAsyncData))] public virtual async Task String_Contains_with_StringComparison_unsupported(bool async) { - await AssertTranslationFailed(() => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.CurrentCulture)))); - - await AssertTranslationFailed(() => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.CurrentCultureIgnoreCase)))); - - await AssertTranslationFailed(() => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.InvariantCulture)))); - - await AssertTranslationFailed(() => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.InvariantCultureIgnoreCase)))); + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.CurrentCulture)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.CurrentCultureIgnoreCase)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.InvariantCulture)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.InvariantCultureIgnoreCase)))); } #endregion String.Contains diff --git a/test/EFCore.Specification.Tests/Query/NorthwindGroupByQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindGroupByQueryTestBase.cs index 0e97440fa69..d123b7027b4 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindGroupByQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindGroupByQueryTestBase.cs @@ -2543,8 +2543,7 @@ public virtual Task GroupBy_group_Distinct_Select_Distinct_aggregate(bool async) g => new { - g.Key, - Max = g.Distinct().Select(e => e.OrderDate).Distinct().Max(), + g.Key, Max = g.Distinct().Select(e => e.OrderDate).Distinct().Max(), }), elementSorter: e => e.Key); @@ -2559,8 +2558,7 @@ public virtual Task GroupBy_group_Where_Select_Distinct_aggregate(bool async) g => new { - g.Key, - Max = g.Where(e => e.OrderDate.HasValue).Select(e => e.OrderDate).Distinct().Max(), + g.Key, Max = g.Where(e => e.OrderDate.HasValue).Select(e => e.OrderDate).Distinct().Max(), }), elementSorter: e => e.Key); diff --git a/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs index 75196ee04e4..248bd260ce1 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs @@ -718,8 +718,7 @@ public virtual Task Ternary_should_not_evaluate_both_sides_with_parameter(bool a o => new { // ReSharper disable SimplifyConditionalTernaryExpression - Data1 = param != null ? o.OrderDate == param.Value : true, - Data2 = param == null ? true : o.OrderDate == param.Value + Data1 = param != null ? o.OrderDate == param.Value : true, Data2 = param == null ? true : o.OrderDate == param.Value // ReSharper restore SimplifyConditionalTernaryExpression })); } @@ -2520,7 +2519,8 @@ public virtual Task Where_Order_First(bool async) => AssertQuery( async, ss => ss.Set().Where(c => c.Orders.Order().First().OrderID == 10248).Select(c => c.CustomerID), - ss => ss.Set().AsEnumerable().Where(c => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault()?.OrderID == 10248).Select(c => c.CustomerID).AsQueryable()); + ss => ss.Set().AsEnumerable().Where(c => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault()?.OrderID == 10248) + .Select(c => c.CustomerID).AsQueryable()); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -3307,15 +3307,12 @@ public virtual Task Where_bitwise_binary_or(bool async) async, ss => ss.Set().Where(o => (o.OrderID | 10248) == 10248)); - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_bitwise_binary_xor(bool async) - { - return AssertQuery( + => AssertQuery( async, ss => ss.Set().Where(o => (o.OrderID ^ 1) == 10249)); - } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] diff --git a/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs index 688f697b7ba..f7c619d7c6d 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs @@ -771,7 +771,7 @@ public virtual Task Select_conditional_drops_false(bool async) ? o.OrderID : false ? 0 - : -o.OrderID ); + : -o.OrderID); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -783,7 +783,7 @@ public virtual Task Select_conditional_terminates_at_true(bool async) ? o.OrderID : true ? 0 - : -o.OrderID ); + : -o.OrderID); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -1548,7 +1548,8 @@ public virtual Task Select_with_complex_expression_that_can_be_funcletized(bool => AssertQueryScalar( async, ss => ss.Set().Where(c => c.CustomerID == "ALFKI").Select(c => (int?)c.Region.IndexOf("")), - ss => ss.Set().Where(c => c.CustomerID == "ALFKI").Select(c => c.Region == null ? default(int?) : c.Region.IndexOf("")), + ss => ss.Set().Where(c => c.CustomerID == "ALFKI") + .Select(c => c.Region == null ? default(int?) : c.Region.IndexOf("")), assertOrder: true); [ConditionalTheory] @@ -2483,16 +2484,18 @@ public virtual Task Set_operation_in_pending_collection(bool async) async, ss => ss.Set() .OrderBy(x => x.CustomerID) - .Select(x => new - { - OrderIds = (from o1 in ss.Set() - where o1.CustomerID == x.CustomerID - select o1.OrderID) - .Union(from o2 in ss.Set() - where o2.CustomerID == x.CustomerID - select o2.OrderID) - .ToList() - }).Take(5), + .Select( + x => new + { + OrderIds = (from o1 in ss.Set() + where o1.CustomerID == x.CustomerID + select o1.OrderID) + .Union( + from o2 in ss.Set() + where o2.CustomerID == x.CustomerID + select o2.OrderID) + .ToList() + }).Take(5), assertOrder: true, elementAsserter: (e, a) => AssertCollection(e.OrderIds, a.OrderIds, elementSorter: ee => ee)); } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs index f63d63faea2..c1de5a6b834 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs @@ -10,7 +10,6 @@ namespace Microsoft.EntityFrameworkCore.Query; // ReSharper disable ConvertToConstant.Local // ReSharper disable RedundantBoolCompare // ReSharper disable InconsistentNaming - public abstract class NorthwindWhereQueryTestBase(TFixture fixture) : QueryTestBase(fixture) where TFixture : NorthwindQueryFixtureBase, new() { @@ -1463,11 +1462,9 @@ public virtual Task Where_ternary_boolean_condition_with_false_as_result_false(b [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_ternary_boolean_condition_negated(bool async) - { - return AssertQuery( + => AssertQuery( async, ss => ss.Set().Where(p => !(p.UnitsInStock >= 20 ? false : true))); - } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -1556,7 +1553,7 @@ public virtual Task Where_compare_null(bool async) public virtual Task Where_compare_null_with_cast_to_object(bool async) => AssertQuery( async, - ss => ss.Set().Where(c => (object)c.Region == null)); + ss => ss.Set().Where(c => c.Region == null)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -1653,7 +1650,6 @@ public virtual Task Where_subquery_FirstOrDefault_compared_to_entity(bool async) async, ss => ss.Set().Where( c => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault() == new Order { OrderID = 10276 }), - ss => ss.Set().Where( c => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault().OrderID == 10276)); diff --git a/test/EFCore.Specification.Tests/Query/OwnedEntityQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/OwnedEntityQueryTestBase.cs index 57b319b2181..25b210961c9 100644 --- a/test/EFCore.Specification.Tests/Query/OwnedEntityQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/OwnedEntityQueryTestBase.cs @@ -42,7 +42,8 @@ public virtual async Task Include_collection_for_entity_with_owned_type_works() } } - private class Context9202(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context9202(DbContextOptions options) : DbContext(options) { public DbSet Movies { get; set; } public DbSet Actors { get; set; } @@ -113,7 +114,8 @@ public virtual async Task Multilevel_owned_entities_determine_correct_nullabilit await context.SaveChangesAsync(); } - private class Context13079(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context13079(DbContextOptions options) : DbContext(options) { public virtual DbSet BaseEntities { get; set; } @@ -182,7 +184,8 @@ public virtual async Task Correlated_subquery_with_owned_navigation_being_compar } } - private class Context13157(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context13157(DbContextOptions options) : DbContext(options) { public virtual DbSet Partners { get; set; } @@ -297,13 +300,19 @@ public Task SeedAsync() { SecondValueObjects = [ - new() + new SecondValueObject { FourthValueObject = - new FourthValueObject { FifthValueObjects = [new() { AnyValue = 10 }] }, + new FourthValueObject { FifthValueObjects = [new FifthValueObject { AnyValue = 10 }] }, ThirdValueObjects = [ - new() { FourthValueObject = new FourthValueObject { FifthValueObjects = [new() { AnyValue = 20 }] } } + new ThirdValueObject + { + FourthValueObject = new FourthValueObject + { + FifthValueObjects = [new FifthValueObject { AnyValue = 20 }] + } + } ] } ] @@ -363,8 +372,7 @@ public virtual async Task Projecting_correlated_collection_property_for_owned_en var query = context.Warehouses.Select( x => new Context18582.WarehouseModel { - WarehouseCode = x.WarehouseCode, - DestinationCountryCodes = x.DestinationCountries.Select(c => c.CountryCode).ToArray() + WarehouseCode = x.WarehouseCode, DestinationCountryCodes = x.DestinationCountries.Select(c => c.CountryCode).ToArray() }).AsNoTracking(); var result = async @@ -376,7 +384,8 @@ public virtual async Task Projecting_correlated_collection_property_for_owned_en Assert.True(new[] { "US", "CA" }.SequenceEqual(warehouseModel.DestinationCountryCodes)); } - private class Context18582(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context18582(DbContextOptions options) : DbContext(options) { public DbSet Warehouses { get; set; } @@ -441,7 +450,8 @@ public virtual async Task Accessing_scalar_property_in_derived_type_projection_d Assert.Equal("A", Assert.Single(result).OtherEntityData); } - private class Context19138(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context19138(DbContextOptions options) : DbContext(options) { public DbSet BaseEntities { get; set; } public DbSet OtherEntities { get; set; } @@ -523,7 +533,8 @@ public virtual async Task Multiple_single_result_in_projection_containing_owned_ x.Type, }; - private class Context20277(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context20277(DbContextOptions options) : DbContext(options) { public DbSet Entities => Set(); @@ -595,7 +606,8 @@ public virtual async Task Can_auto_include_navigation_from_model() } } - private class Context21540(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context21540(DbContextOptions options) : DbContext(options) { public DbSet Parents { get; set; } @@ -624,7 +636,7 @@ public Task SeedAsync() OwnedReference = new Owned(), Collection = [ - new(), new() + new Collection(), new Collection() ] } }; @@ -693,7 +705,8 @@ public virtual async Task Nested_owned_required_dependents_are_materialized() Assert.Equal(12345, result.Contact.Address.Zip); } - private class Context21807(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context21807(DbContextOptions options) : DbContext(options) { protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.Entity( @@ -751,13 +764,13 @@ public virtual async Task OwnsMany_correlated_projection(bool async) var results = await context.Contacts.Select( contact => new Context22089.ContactDto { - Id = contact.Id, - Names = contact.Names.Select(name => new Context22089.NameDto()).ToArray() + Id = contact.Id, Names = contact.Names.Select(name => new Context22089.NameDto()).ToArray() }) .ToListAsync(); } - private class Context22089(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context22089(DbContextOptions options) : DbContext(options) { public DbSet Contacts { get; set; } @@ -816,7 +829,8 @@ public virtual async Task Projecting_owned_collection_and_aggregate(bool async) : query.ToList(); } - private class Context24133(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context24133(DbContextOptions options) : DbContext(options) { protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.Entity( diff --git a/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs index bf8d2404c7e..51f16b590f5 100644 --- a/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs @@ -12,9 +12,7 @@ public abstract class OwnedQueryTestBase : QueryTestBase { protected OwnedQueryTestBase(TFixture fixture) : base(fixture) - { - fixture.ListLoggerFactory.Clear(); - } + => fixture.ListLoggerFactory.Clear(); [ConditionalTheory] // Issue #26257 [MemberData(nameof(IsAsyncData))] @@ -25,8 +23,7 @@ public virtual async Task Can_query_owner_with_different_owned_types_having_same await context.AddAsync( new HeliumBalloon { - Id = Guid.NewGuid().ToString(), - Gas = new Helium(), + Id = Guid.NewGuid().ToString(), Gas = new Helium(), }); await context.AddAsync(new HydrogenBalloon { Id = Guid.NewGuid().ToString(), Gas = new Hydrogen() }); @@ -989,7 +986,9 @@ public virtual Task FirstOrDefault_over_owned_collection(bool async) => AssertQuery( async, ss => ss.Set().Where(p => ((DateTime)p.Orders.FirstOrDefault(o => o.Id > -20)["OrderDate"]).Year == 2018), - ss => ss.Set().Where(p => p.Orders.FirstOrDefault(o => o.Id > -20) != null && ((DateTime)p.Orders.FirstOrDefault(o => o.Id > -20)["OrderDate"]).Year == 2018)); + ss => ss.Set().Where( + p => p.Orders.FirstOrDefault(o => o.Id > -20) != null + && ((DateTime)p.Orders.FirstOrDefault(o => o.Id > -20)["OrderDate"]).Year == 2018)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -1742,13 +1741,13 @@ private static IReadOnlyList CreateStars() Name = "Sol", Composition = [ - new() + new Element { Id = "H", Name = "Hydrogen", StarId = 1 }, - new() + new Element { Id = "He", Name = "Helium", @@ -1868,7 +1867,7 @@ private static IReadOnlyList CreateOwnedPeople() Id = -10, Client = ownedPerson1, ["OrderDate"] = Convert.ToDateTime("2018-07-11 10:01:41"), - Details = [new() { Detail = "Discounted Order" }, new() { Detail = "Full Price Order" }] + Details = [new OrderDetail { Detail = "Discounted Order" }, new OrderDetail { Detail = "Full Price Order" }] }; var order2 = new Order @@ -1885,7 +1884,7 @@ private static IReadOnlyList CreateOwnedPeople() Id = -20, Client = ownedPerson2, ["OrderDate"] = Convert.ToDateTime("2015-05-25 20:35:48"), - Details = [new() { Detail = "Internal Order" }] + Details = [new OrderDetail { Detail = "Internal Order" }] }; ownedPerson2.Orders = new List { order3 }; @@ -1894,7 +1893,7 @@ private static IReadOnlyList CreateOwnedPeople() Id = -30, Client = ownedPerson3, ["OrderDate"] = Convert.ToDateTime("2014-11-10 04:32:42"), - Details = [new() { Detail = "Bulk Order" }] + Details = [new OrderDetail { Detail = "Bulk Order" }] }; ownedPerson3.Orders = new List { order4 }; diff --git a/test/EFCore.Specification.Tests/Query/PrimitiveCollectionsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/PrimitiveCollectionsQueryTestBase.cs index 94de007cf69..7de363ee184 100644 --- a/test/EFCore.Specification.Tests/Query/PrimitiveCollectionsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/PrimitiveCollectionsQueryTestBase.cs @@ -130,7 +130,14 @@ public virtual async Task Inline_collection_List_Contains_with_mixed_value_types await AssertQuery( async, - ss => ss.Set().Where(c => new List { 999, i, c.Id, c.Id + c.Int }.Contains(c.Int))); + ss => ss.Set().Where( + c => new List + { + 999, + i, + c.Id, + c.Id + c.Int + }.Contains(c.Int))); } [ConditionalTheory] @@ -159,7 +166,7 @@ public virtual async Task Inline_collection_Min_with_two_values(bool async) public virtual async Task Inline_collection_List_Min_with_two_values(bool async) => await AssertQuery( async, - ss => ss.Set().Where(c => new List() { 30, c.Int }.Min() == 30)); + ss => ss.Set().Where(c => new List { 30, c.Int }.Min() == 30)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -173,7 +180,7 @@ public virtual async Task Inline_collection_Max_with_two_values(bool async) public virtual async Task Inline_collection_List_Max_with_two_values(bool async) => await AssertQuery( async, - ss => ss.Set().Where(c => new List() { 30, c.Int }.Max() == 30)); + ss => ss.Set().Where(c => new List { 30, c.Int }.Max() == 30)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -194,7 +201,14 @@ public virtual async Task Inline_collection_List_Min_with_three_values(bool asyn await AssertQuery( async, - ss => ss.Set().Where(c => new List() { 30, c.Int, i }.Min() == 25)); + ss => ss.Set().Where( + c => new List + { + 30, + c.Int, + i + }.Min() + == 25)); } [ConditionalTheory] @@ -216,7 +230,14 @@ public virtual async Task Inline_collection_List_Max_with_three_values(bool asyn await AssertQuery( async, - ss => ss.Set().Where(c => new List { 30, c.Int, i }.Max() == 35)); + ss => ss.Set().Where( + c => new List + { + 30, + c.Int, + i + }.Max() + == 35)); } [ConditionalTheory] @@ -290,22 +311,18 @@ public virtual Task Inline_collection_with_single_parameter_element_Count(bool a [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Inline_collection_Contains_with_EF_Parameter(bool async) - { - return AssertQuery( + => AssertQuery( async, ss => ss.Set().Where(c => EF.Parameter(new[] { 2, 999, 1000 }).Contains(c.Id)), ss => ss.Set().Where(c => new[] { 2, 999, 1000 }.Contains(c.Id))); - } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Inline_collection_Count_with_column_predicate_with_EF_Parameter(bool async) - { - return AssertQuery( + => AssertQuery( async, ss => ss.Set().Where(c => EF.Parameter(new[] { 2, 999, 1000 }).Count(i => i > c.Id) == 2), ss => ss.Set().Where(c => new[] { 2, 999, 1000 }.Count(i => i > c.Id) == 2)); - } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -336,7 +353,7 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public virtual async Task Parameter_collection_HashSet_of_ints_Contains_int(bool async) { - var ints = new HashSet() { 10, 999 }; + var ints = new HashSet { 10, 999 }; await AssertQuery( async, @@ -680,8 +697,24 @@ public virtual Task Inline_collection_value_index_Column(bool async) public virtual Task Inline_collection_List_value_index_Column(bool async) => AssertQuery( async, - ss => ss.Set().Where(c => new List() { 1, c.Int, 3 }[c.Int] == 1), - ss => ss.Set().Where(c => (c.Int <= 2 ? new List() { 1, c.Int, 3 }[c.Int] : -1) == 1)); + ss => ss.Set().Where( + c => new List + { + 1, + c.Int, + 3 + }[c.Int] + == 1), + ss => ss.Set().Where( + c => (c.Int <= 2 + ? new List + { + 1, + c.Int, + 3 + }[c.Int] + : -1) + == 1)); // The JsonScalarExpression (ints[c.Int]) should get inferred from the column on the other side (c.Int), and that should propagate to // ints @@ -1175,8 +1208,7 @@ public virtual Task Project_empty_collection_of_nullables_and_collection_only_co ss => ss.Set().OrderBy(x => x.Id).Select( x => new { - Empty = x.NullableInts.Where(x => false).ToList(), - OnlyNull = x.NullableInts.Where(x => x == null).ToList(), + Empty = x.NullableInts.Where(x => false).ToList(), OnlyNull = x.NullableInts.Where(x => x == null).ToList(), }), assertOrder: true, elementAsserter: (e, a) => @@ -1246,7 +1278,8 @@ public virtual Task Project_inline_collection_with_Union(bool async) x => new { x.Id, - Values = new[] { x.String }.Union(ss.Set().OrderBy(xx => xx.Id).Select(xx => xx.String)).ToList() + Values = new[] { x.String } + .Union(ss.Set().OrderBy(xx => xx.Id).Select(xx => xx.String)).ToList() }) .OrderBy(x => x.Id), elementAsserter: (e, a) => @@ -1266,7 +1299,8 @@ public virtual Task Project_inline_collection_with_Concat(bool async) x => new { x.Id, - Values = new[] { x.String }.Concat(ss.Set().OrderBy(xx => xx.Id).Select(xx => xx.String)).ToList() + Values = new[] { x.String } + .Concat(ss.Set().OrderBy(xx => xx.Id).Select(xx => xx.String)).ToList() }) .OrderBy(x => x.Id), elementAsserter: (e, a) => @@ -1395,9 +1429,7 @@ public class PrimitiveCollectionsData : ISetSource public IReadOnlyList PrimitiveArrayEntities { get; } public PrimitiveCollectionsData(PrimitiveCollectionsContext? context = null) - { - PrimitiveArrayEntities = CreatePrimitiveArrayEntities(); - } + => PrimitiveArrayEntities = CreatePrimitiveArrayEntities(); public IQueryable Set() where TEntity : class @@ -1427,7 +1459,7 @@ private static IReadOnlyList CreatePrimitiveArrayEnt Strings = ["1", "10"], DateTimes = [ - new(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), new(2020, 1, 10, 12, 30, 0, DateTimeKind.Utc) + new DateTime(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), new DateTime(2020, 1, 10, 12, 30, 0, DateTimeKind.Utc) ], Bools = [true, false], Enums = [MyEnum.Value1, MyEnum.Value2], @@ -1448,9 +1480,9 @@ private static IReadOnlyList CreatePrimitiveArrayEnt Strings = ["1", "11", "111"], DateTimes = [ - new(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), - new(2020, 1, 11, 12, 30, 0, DateTimeKind.Utc), - new(2020, 1, 31, 12, 30, 0, DateTimeKind.Utc) + new DateTime(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), + new DateTime(2020, 1, 11, 12, 30, 0, DateTimeKind.Utc), + new DateTime(2020, 1, 31, 12, 30, 0, DateTimeKind.Utc) ], Bools = [false], Enums = [MyEnum.Value2, MyEnum.Value3], @@ -1471,11 +1503,11 @@ private static IReadOnlyList CreatePrimitiveArrayEnt Strings = ["1", "10", "10", "1", "1"], DateTimes = [ - new(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), - new(2020, 1, 10, 12, 30, 0, DateTimeKind.Utc), - new(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), - new(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), - new(2020, 1, 10, 12, 30, 0, DateTimeKind.Utc) + new DateTime(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), + new DateTime(2020, 1, 10, 12, 30, 0, DateTimeKind.Utc), + new DateTime(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), + new DateTime(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), + new DateTime(2020, 1, 10, 12, 30, 0, DateTimeKind.Utc) ], Bools = [true, false], Enums = [MyEnum.Value1, MyEnum.Value2], @@ -1496,14 +1528,14 @@ private static IReadOnlyList CreatePrimitiveArrayEnt Strings = ["1", "11", "111", "11"], DateTimes = [ - new(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), - new(2020, 1, 11, 12, 30, 0, DateTimeKind.Utc), - new(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), - new(2020, 1, 11, 12, 30, 0, DateTimeKind.Utc), - new(2020, 1, 31, 12, 30, 0, DateTimeKind.Utc), - new(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), - new(2020, 1, 31, 12, 30, 0, DateTimeKind.Utc), - new(2020, 1, 31, 12, 30, 0, DateTimeKind.Utc) + new DateTime(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), + new DateTime(2020, 1, 11, 12, 30, 0, DateTimeKind.Utc), + new DateTime(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), + new DateTime(2020, 1, 11, 12, 30, 0, DateTimeKind.Utc), + new DateTime(2020, 1, 31, 12, 30, 0, DateTimeKind.Utc), + new DateTime(2020, 1, 1, 12, 30, 0, DateTimeKind.Utc), + new DateTime(2020, 1, 31, 12, 30, 0, DateTimeKind.Utc), + new DateTime(2020, 1, 31, 12, 30, 0, DateTimeKind.Utc) ], Bools = [false], Enums = [MyEnum.Value2, MyEnum.Value3], diff --git a/test/EFCore.Specification.Tests/Query/QueryTestBase.cs b/test/EFCore.Specification.Tests/Query/QueryTestBase.cs index 6515b7c61bb..0072b3bac73 100644 --- a/test/EFCore.Specification.Tests/Query/QueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/QueryTestBase.cs @@ -77,7 +77,8 @@ public Task AssertQueryScalar( bool assertEmpty = false, [CallerMemberName] string testMethodName = "") where TResult : struct - => TestOutputWrapper(() => QueryAsserter.AssertQueryScalar(actualQuery, expectedQuery, asserter, assertOrder, assertEmpty, async, testMethodName)); + => TestOutputWrapper( + () => QueryAsserter.AssertQueryScalar(actualQuery, expectedQuery, asserter, assertOrder, assertEmpty, async, testMethodName)); public Task AssertQueryScalar( bool async, @@ -98,7 +99,8 @@ public Task AssertQueryScalar( bool assertEmpty = false, [CallerMemberName] string testMethodName = "") where TResult : struct - => TestOutputWrapper(() => QueryAsserter.AssertQueryScalar(actualQuery, expectedQuery, asserter, assertOrder, assertEmpty, async, testMethodName)); + => TestOutputWrapper( + () => QueryAsserter.AssertQueryScalar(actualQuery, expectedQuery, asserter, assertOrder, assertEmpty, async, testMethodName)); protected Task AssertSingleResult( bool async, @@ -216,7 +218,8 @@ protected Task AssertFirst( Expression> actualPredicate, Expression> expectedPredicate, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertFirst(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertFirst(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async)); protected Task AssertFirstOrDefault( bool async, @@ -246,7 +249,8 @@ protected Task AssertFirstOrDefault( Expression> actualPredicate, Expression> expectedPredicate, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertFirstOrDefault(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertFirstOrDefault(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async)); protected Task AssertSingle( bool async, @@ -275,7 +279,8 @@ protected Task AssertSingle( Expression> actualPredicate, Expression> expectedPredicate, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertSingle(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertSingle(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async)); protected Task AssertSingleOrDefault( bool async, @@ -304,7 +309,8 @@ protected Task AssertSingleOrDefault( Expression> actualPredicate, Expression> expectedPredicate, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertSingleOrDefault(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertSingleOrDefault(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async)); protected Task AssertLast( bool async, @@ -333,7 +339,8 @@ protected Task AssertLast( Expression> actualPredicate, Expression> expectedPredicate, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertLast(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertLast(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async)); protected Task AssertLastOrDefault( bool async, @@ -362,7 +369,8 @@ protected Task AssertLastOrDefault( Expression> actualPredicate, Expression> expectedPredicate, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertLastOrDefault(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertLastOrDefault(actualQuery, expectedQuery, actualPredicate, expectedPredicate, asserter, async)); protected Task AssertCount( bool async, @@ -906,7 +914,8 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); protected Task AssertAverage( bool async, @@ -922,7 +931,8 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); protected Task AssertAverage( bool async, @@ -938,7 +948,8 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); protected Task AssertAverage( bool async, @@ -954,7 +965,8 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); protected Task AssertAverage( bool async, @@ -970,7 +982,8 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); protected Task AssertAverage( bool async, @@ -986,7 +999,8 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); protected Task AssertAverage( bool async, @@ -1002,7 +1016,8 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); protected Task AssertAverage( bool async, @@ -1018,7 +1033,8 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); protected Task AssertAverage( bool async, @@ -1034,7 +1050,8 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); protected Task AssertAverage( bool async, @@ -1050,7 +1067,8 @@ protected Task AssertAverage( Expression> actualSelector, Expression> expectedSelector, Action? asserter = null) - => TestOutputWrapper(() => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); + => TestOutputWrapper( + () => QueryAsserter.AssertAverage(actualQuery, expectedQuery, actualSelector, expectedSelector, asserter, async)); #endregion diff --git a/test/EFCore.Specification.Tests/Query/SpatialQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/SpatialQueryTestBase.cs index bfbc4e04319..b97821604b2 100644 --- a/test/EFCore.Specification.Tests/Query/SpatialQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/SpatialQueryTestBase.cs @@ -282,7 +282,8 @@ public virtual Task LineString_Count(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task CoveredBy(bool async) { - var polygon = Fixture.GeometryFactory.CreatePolygon([new(-1, -1), new(2, -1), new(2, 2), new(-1, 2), new(-1, -1)]); + var polygon = Fixture.GeometryFactory.CreatePolygon( + [new Coordinate(-1, -1), new Coordinate(2, -1), new Coordinate(2, 2), new Coordinate(-1, 2), new Coordinate(-1, -1)]); return AssertQuery( async, @@ -309,7 +310,7 @@ public virtual Task Covers(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Crosses(bool async) { - var lineString = Fixture.GeometryFactory.CreateLineString([new(0.5, -0.5), new(0.5, 0.5)]); + var lineString = Fixture.GeometryFactory.CreateLineString([new Coordinate(0.5, -0.5), new Coordinate(0.5, 0.5)]); return AssertQuery( async, @@ -323,7 +324,8 @@ public virtual Task Crosses(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Difference(bool async) { - var polygon = Fixture.GeometryFactory.CreatePolygon([new(0, 0), new(1, 0), new(1, 1), new(0, 0)]); + var polygon = Fixture.GeometryFactory.CreatePolygon( + [new Coordinate(0, 0), new Coordinate(1, 0), new Coordinate(1, 1), new Coordinate(0, 0)]); return AssertQuery( async, @@ -725,7 +727,8 @@ public virtual Task InteriorPoint(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Intersection(bool async) { - var polygon = Fixture.GeometryFactory.CreatePolygon([new(0, 0), new(1, 0), new(1, 1), new(0, 0)]); + var polygon = Fixture.GeometryFactory.CreatePolygon( + [new Coordinate(0, 0), new Coordinate(1, 0), new Coordinate(1, 1), new Coordinate(0, 0)]); return AssertQuery( async, @@ -744,7 +747,7 @@ public virtual Task Intersection(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Intersects(bool async) { - var lineString = Fixture.GeometryFactory.CreateLineString([new(0.5, -0.5), new(0.5, 0.5)]); + var lineString = Fixture.GeometryFactory.CreateLineString([new Coordinate(0.5, -0.5), new Coordinate(0.5, 0.5)]); return AssertQuery( async, @@ -943,7 +946,8 @@ public virtual Task OgcGeometryType(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Overlaps(bool async) { - var polygon = Fixture.GeometryFactory.CreatePolygon([new(0, 0), new(1, 0), new(1, 1), new(0, 0)]); + var polygon = Fixture.GeometryFactory.CreatePolygon( + [new Coordinate(0, 0), new Coordinate(1, 0), new Coordinate(1, 1), new Coordinate(0, 0)]); return AssertQuery( async, @@ -984,7 +988,8 @@ public virtual Task PointOnSurface(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Relate(bool async) { - var polygon = Fixture.GeometryFactory.CreatePolygon([new(0, 0), new(1, 0), new(1, 1), new(0, 0)]); + var polygon = Fixture.GeometryFactory.CreatePolygon( + [new Coordinate(0, 0), new Coordinate(1, 0), new Coordinate(1, 1), new Coordinate(0, 0)]); return AssertQuery( async, @@ -1034,7 +1039,8 @@ public virtual Task StartPoint(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task SymmetricDifference(bool async) { - var polygon = Fixture.GeometryFactory.CreatePolygon([new(0, 0), new(1, 0), new(1, 1), new(0, 0)]); + var polygon = Fixture.GeometryFactory.CreatePolygon( + [new Coordinate(0, 0), new Coordinate(1, 0), new Coordinate(1, 1), new Coordinate(0, 0)]); return AssertQuery( async, @@ -1081,7 +1087,8 @@ public virtual Task ToText(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Touches(bool async) { - var polygon = Fixture.GeometryFactory.CreatePolygon([new(0, 1), new(1, 0), new(1, 1), new(0, 1)]); + var polygon = Fixture.GeometryFactory.CreatePolygon( + [new Coordinate(0, 1), new Coordinate(1, 0), new Coordinate(1, 1), new Coordinate(0, 1)]); return AssertQuery( async, @@ -1095,7 +1102,8 @@ public virtual Task Touches(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Union(bool async) { - var polygon = Fixture.GeometryFactory.CreatePolygon([new(0, 0), new(1, 0), new(1, 1), new(0, 0)]); + var polygon = Fixture.GeometryFactory.CreatePolygon( + [new Coordinate(0, 0), new Coordinate(1, 0), new Coordinate(1, 1), new Coordinate(0, 0)]); return AssertQuery( async, @@ -1139,7 +1147,8 @@ public virtual Task Union_void(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Within(bool async) { - var polygon = Fixture.GeometryFactory.CreatePolygon([new(-1, -1), new(2, -1), new(2, 2), new(-1, 2), new(-1, -1)]); + var polygon = Fixture.GeometryFactory.CreatePolygon( + [new Coordinate(-1, -1), new Coordinate(2, -1), new Coordinate(2, 2), new Coordinate(-1, 2), new Coordinate(-1, -1)]); return AssertQuery( async, @@ -1234,7 +1243,7 @@ public virtual Task IsEmpty_not_equal_to_null(bool async) [MemberData(nameof(IsAsyncData))] public virtual async Task Intersects_equal_to_null(bool async) { - var lineString = Fixture.GeometryFactory.CreateLineString([new(0.5, -0.5), new(0.5, 0.5)]); + var lineString = Fixture.GeometryFactory.CreateLineString([new Coordinate(0.5, -0.5), new Coordinate(0.5, 0.5)]); await AssertQueryScalar( async, @@ -1255,7 +1264,7 @@ await AssertQueryScalar( [MemberData(nameof(IsAsyncData))] public virtual async Task Intersects_not_equal_to_null(bool async) { - var lineString = Fixture.GeometryFactory.CreateLineString([new(0.5, -0.5), new(0.5, 0.5)]); + var lineString = Fixture.GeometryFactory.CreateLineString([new Coordinate(0.5, -0.5), new Coordinate(0.5, 0.5)]); await AssertQueryScalar( async, diff --git a/test/EFCore.Specification.Tests/Scaffolding/CompiledModelTestBase.cs b/test/EFCore.Specification.Tests/Scaffolding/CompiledModelTestBase.cs index 2560e1d2738..29a7f138fb7 100644 --- a/test/EFCore.Specification.Tests/Scaffolding/CompiledModelTestBase.cs +++ b/test/EFCore.Specification.Tests/Scaffolding/CompiledModelTestBase.cs @@ -46,7 +46,8 @@ public virtual Task SimpleModel() options: new CompiledModelCodeGenerationOptions { UseNullableReferenceTypes = true, ForNativeAot = true }, additionalSourceFiles: [ - new("DbContextModelStub.cs", + new ScaffoldedFile( + "DbContextModelStub.cs", """ using Microsoft.EntityFrameworkCore.Metadata; using static TestNamespace.DbContextModel.Dummy; @@ -313,7 +314,8 @@ protected virtual void AssertBigModel(IModel model, bool jsonColumns) var principalAlternateKey = principalBase.GetKeys().Single(k => k.Properties.Count == 1 && principalId == k.Properties.Single()); Assert.False(principalAlternateKey.IsPrimaryKey()); - var principalKey = principalBase.GetKeys().Single(k => k.Properties.Count == 2 && k.Properties.SequenceEqual([principalId, principalAlternateId])); + var principalKey = principalBase.GetKeys() + .Single(k => k.Properties.Count == 2 && k.Properties.SequenceEqual([principalId, principalAlternateId])); Assert.True(principalKey.IsPrimaryKey()); Assert.Equal([principalAlternateKey, principalKey], principalId.GetContainingKeys()); @@ -566,6 +568,7 @@ protected virtual async Task UseBigModel(DbContext context) await context.SaveChangesAsync(); } + [ConditionalFact] public virtual Task ComplexTypes() => Test( @@ -614,11 +617,12 @@ protected virtual void BuildComplexTypesModel(ModelBuilder modelBuilder) .HasPrecision(3, 2) .HasAnnotation("foo", "bar"); eb.Ignore(e => e.Context); - eb.ComplexProperty(o => o.Principal, cb => - { - cb.IsRequired(); - cb.Property("FlagsEnum2"); - }); + eb.ComplexProperty( + o => o.Principal, cb => + { + cb.IsRequired(); + cb.Property("FlagsEnum2"); + }); }); }); @@ -801,10 +805,11 @@ public override Guid FromJsonTyped(ref Utf8JsonReaderManager manager, object? ex public override void ToJsonTyped(Utf8JsonWriter writer, Guid value) => writer.WriteStringValue(value); - private readonly Expression> _ctorLambda = () => new(); + private readonly Expression> _ctorLambda = () => new MyJsonGuidReaderWriter(); /// - public override Expression ConstructorExpression => _ctorLambda.Body; + public override Expression ConstructorExpression + => _ctorLambda.Body; } public class ManyTypes @@ -1156,9 +1161,7 @@ public OwnedType() } public OwnedType(DbContext context) - { - Context = context; - } + => Context = context; public DbContext? Context { @@ -1429,8 +1432,7 @@ private IModel CompileModel( { var build = new BuildSource { - Sources = scaffoldedFiles.ToDictionary(f => f.Path, f => f.Code), - NullableReferenceTypes = options.UseNullableReferenceTypes + Sources = scaffoldedFiles.ToDictionary(f => f.Path, f => f.Code), NullableReferenceTypes = options.UseNullableReferenceTypes }; AddReferences(build); diff --git a/test/EFCore.Specification.Tests/ServiceProviderFixtureBase.cs b/test/EFCore.Specification.Tests/ServiceProviderFixtureBase.cs index 1dc3a839f92..fad50c8c89c 100644 --- a/test/EFCore.Specification.Tests/ServiceProviderFixtureBase.cs +++ b/test/EFCore.Specification.Tests/ServiceProviderFixtureBase.cs @@ -16,10 +16,8 @@ public ListLoggerFactory ListLoggerFactory => _listLoggerFactory ??= (ListLoggerFactory)ServiceProvider.GetRequiredService(); protected ServiceProviderFixtureBase() - { - ServiceProvider = AddServices(TestStoreFactory.AddProviderServices(new ServiceCollection())) + => ServiceProvider = AddServices(TestStoreFactory.AddProviderServices(new ServiceCollection())) .BuildServiceProvider(validateScopes: true); - } public DbContextOptions CreateOptions(TestStore testStore) => AddOptions(testStore.AddProviderOptions(new DbContextOptionsBuilder())) diff --git a/test/EFCore.Specification.Tests/SharedStoreFixtureBase.cs b/test/EFCore.Specification.Tests/SharedStoreFixtureBase.cs index 1ffad9e7362..226300402d7 100644 --- a/test/EFCore.Specification.Tests/SharedStoreFixtureBase.cs +++ b/test/EFCore.Specification.Tests/SharedStoreFixtureBase.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // ReSharper disable VirtualMemberCallInConstructor + namespace Microsoft.EntityFrameworkCore; public abstract class SharedStoreFixtureBase : FixtureBase, IAsyncLifetime diff --git a/test/EFCore.Specification.Tests/SpatialTestBase.cs b/test/EFCore.Specification.Tests/SpatialTestBase.cs index 7adbd529002..c49dd8c3e2b 100644 --- a/test/EFCore.Specification.Tests/SpatialTestBase.cs +++ b/test/EFCore.Specification.Tests/SpatialTestBase.cs @@ -45,7 +45,7 @@ Point CreatePoint(double y = 2.2) Polygon CreatePolygon(double y = 2.2) => new( - new LinearRing([new(1.1, 2.2), new(2.2, y), new(2.2, 1.1), new(1.1, 2.2)])); + new LinearRing([new Coordinate(1.1, 2.2), new Coordinate(2.2, y), new Coordinate(2.2, 1.1), new Coordinate(1.1, 2.2)])); var id1 = Guid.NewGuid(); var id2 = Guid.NewGuid(); diff --git a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityDbContext``.cs b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityDbContext``.cs index c28553085b1..ef3b9628646 100644 --- a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityDbContext``.cs +++ b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityDbContext``.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.TestModels.AspNetIdentity; public abstract class IdentityDbContext : IdentityUserContext + TUserClaim, TUserLogin, TUserToken> where TUser : IdentityUser where TRole : IdentityRole where TKey : IEquatable diff --git a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityRole.cs b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityRole.cs index c43a32153e8..9756760e111 100644 --- a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityRole.cs +++ b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityRole.cs @@ -14,9 +14,7 @@ public IdentityRole() public IdentityRole(string roleName) : this() - { - Name = roleName; - } + => Name = roleName; public virtual TKey Id { get; set; } @@ -33,13 +31,9 @@ public override string ToString() public class IdentityRole : IdentityRole { public IdentityRole() - { - Id = Guid.NewGuid().ToString(); - } + => Id = Guid.NewGuid().ToString(); public IdentityRole(string roleName) : this() - { - Name = roleName; - } + => Name = roleName; } diff --git a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUser.cs b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUser.cs index f8b9367c08c..ab72e5e3945 100644 --- a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUser.cs +++ b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUser.cs @@ -13,7 +13,5 @@ public IdentityUser() public IdentityUser(string userName) : this() - { - UserName = userName; - } + => UserName = userName; } diff --git a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUserContext.cs b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUserContext.cs index 678a7baae84..652146b6cbd 100644 --- a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUserContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUserContext.cs @@ -27,8 +27,8 @@ protected IdentityUserContext() public virtual DbSet UserTokens { get; set; } private class PersonalDataConverter(IPersonalDataProtector protector) : ValueConverter( - s => protector.Protect(s), - s => protector.Unprotect(s)); + s => protector.Protect(s), + s => protector.Unprotect(s)); private class PersonalDataProtector : IPersonalDataProtector { diff --git a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUser`.cs b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUser`.cs index 359a8096737..7cd4adbcbc1 100644 --- a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUser`.cs +++ b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUser`.cs @@ -14,9 +14,7 @@ public IdentityUser() public IdentityUser(string userName) : this() - { - UserName = userName; - } + => UserName = userName; [PersonalData] public virtual TKey Id { get; set; } diff --git a/test/EFCore.Specification.Tests/TestModels/ChangedChangingMonsterContext.cs b/test/EFCore.Specification.Tests/TestModels/ChangedChangingMonsterContext.cs index c905c6ee252..2d40a347054 100644 --- a/test/EFCore.Specification.Tests/TestModels/ChangedChangingMonsterContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/ChangedChangingMonsterContext.cs @@ -60,9 +60,7 @@ public class BackOrderLine : OrderLine, IBackOrderLine private DateTime _eta; public BackOrderLine() - { - ETA = DateTime.Now; - } + => ETA = DateTime.Now; public DateTime ETA { @@ -215,9 +213,7 @@ public class ComputerDetail : NotificationEntity, IComputerDetail private IComputer _computer; public ComputerDetail() - { - Dimensions = new Dimensions(); - } + => Dimensions = new Dimensions(); public int ComputerDetailId { @@ -560,9 +556,7 @@ public class License : NotificationEntity, ILicense private IDriver _driver; public License() - { - LicenseClass = "C"; - } + => LicenseClass = "C"; public string Name { @@ -684,9 +678,7 @@ public class OrderLine : NotificationEntity, IOrderLine private IProduct _product; public OrderLine() - { - Quantity = 1; - } + => Quantity = 1; public int OrderId { @@ -738,9 +730,7 @@ public class AnOrder : NotificationEntity, IAnOrder private ILogin _login; public AnOrder() - { - Concurrency = new ConcurrencyInfo(); - } + => Concurrency = new ConcurrencyInfo(); public void InitializeCollections() { @@ -1628,9 +1618,7 @@ public class Phone : NotificationEntity, IPhone private string _phoneNumber; public Phone() - { - Extension = "None"; - } + => Extension = "None"; public string PhoneNumber { diff --git a/test/EFCore.Specification.Tests/TestModels/ChangedOnlyMonsterContext.cs b/test/EFCore.Specification.Tests/TestModels/ChangedOnlyMonsterContext.cs index 87862a680ce..4f120f292a6 100644 --- a/test/EFCore.Specification.Tests/TestModels/ChangedOnlyMonsterContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/ChangedOnlyMonsterContext.cs @@ -55,9 +55,7 @@ public class BackOrderLine : OrderLine, IBackOrderLine private DateTime _eta; public BackOrderLine() - { - ETA = DateTime.Now; - } + => ETA = DateTime.Now; public DateTime ETA { @@ -210,9 +208,7 @@ public class ComputerDetail : NotificationEntity, IComputerDetail private IComputer _computer; public ComputerDetail() - { - Dimensions = new Dimensions(); - } + => Dimensions = new Dimensions(); public int ComputerDetailId { @@ -555,9 +551,7 @@ public class License : NotificationEntity, ILicense private IDriver _driver; public License() - { - LicenseClass = "C"; - } + => LicenseClass = "C"; public string Name { @@ -679,9 +673,7 @@ public class OrderLine : NotificationEntity, IOrderLine private IProduct _product; public OrderLine() - { - Quantity = 1; - } + => Quantity = 1; public int OrderId { @@ -733,9 +725,7 @@ public class AnOrder : NotificationEntity, IAnOrder private ILogin _login; public AnOrder() - { - Concurrency = new ConcurrencyInfo(); - } + => Concurrency = new ConcurrencyInfo(); public void InitializeCollections() { @@ -1623,9 +1613,7 @@ public class Phone : NotificationEntity, IPhone private string _phoneNumber; public Phone() - { - Extension = "None"; - } + => Extension = "None"; public string PhoneNumber { diff --git a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Team.cs b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Team.cs index ba8b9009cf5..46da17ff84c 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Team.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Team.cs @@ -24,7 +24,8 @@ public class TeamProxy( int fastestLaps, int? gearboxId) : Team( loader, id, name, constructor, tire, principal, constructorsChampionships, driversChampionships, races, victories, poles, - fastestLaps, gearboxId), IF1Proxy + fastestLaps, gearboxId), + IF1Proxy { public bool CreatedCalled { get; set; } public bool InitializingCalled { get; set; } diff --git a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/TestDriver.cs b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/TestDriver.cs index 370e27453b6..d64f3c28ed3 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/TestDriver.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/TestDriver.cs @@ -40,7 +40,5 @@ private TestDriver( int fastestLaps, int teamId) : base(loader, id, name, carNumber, championships, races, wins, podiums, poles, fastestLaps, teamId) - { - Assert.IsType(this); - } + => Assert.IsType(this); } diff --git a/test/EFCore.Specification.Tests/TestModels/FunkyDataModel/FunkyDataData.cs b/test/EFCore.Specification.Tests/TestModels/FunkyDataModel/FunkyDataData.cs index 93a79228b89..302c6122f3f 100644 --- a/test/EFCore.Specification.Tests/TestModels/FunkyDataModel/FunkyDataData.cs +++ b/test/EFCore.Specification.Tests/TestModels/FunkyDataModel/FunkyDataData.cs @@ -12,9 +12,7 @@ public class FunkyDataData : ISetSource public IReadOnlyList FunkyCustomers { get; } private FunkyDataData() - { - FunkyCustomers = CreateFunkyCustomers(); - } + => FunkyCustomers = CreateFunkyCustomers(); public virtual IQueryable Set() where TEntity : class diff --git a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Gear.cs b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Gear.cs index c7c780c6d14..16be3003b19 100644 --- a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Gear.cs +++ b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Gear.cs @@ -10,9 +10,7 @@ namespace Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel; public class Gear { public Gear() - { - Weapons = new List(); - } + => Weapons = new List(); // composite key public string Nickname { get; set; } diff --git a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs index 4e6b377e38a..4abffab963a 100644 --- a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs +++ b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs @@ -608,7 +608,8 @@ public static void WireUp( ((LocustHorde)factions[1]).Commander = ((LocustCommander)locustLeaders[5]); ((LocustHorde)factions[2]).Commander = ((LocustCommander)locustLeaders[6]); - locustHighCommands[0].Commanders = [ + locustHighCommands[0].Commanders = + [ (LocustCommander)locustLeaders[3], (LocustCommander)locustLeaders[5], (LocustCommander)locustLeaders[6], diff --git a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Officer.cs b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Officer.cs index 18a678ec6bc..57a83322825 100644 --- a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Officer.cs +++ b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Officer.cs @@ -6,9 +6,7 @@ namespace Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel; public class Officer : Gear { public Officer() - { - Reports = new List(); - } + => Reports = new List(); // 1 - many self reference public virtual ICollection Reports { get; set; } diff --git a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Squad.cs b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Squad.cs index e00a81bf681..aae303e17c9 100644 --- a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Squad.cs +++ b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Squad.cs @@ -8,9 +8,7 @@ namespace Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel; public class Squad { public Squad() - { - Members = new List(); - } + => Members = new List(); // non-auto generated key public int Id { get; set; } diff --git a/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/InheritanceRelationshipsData.cs b/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/InheritanceRelationshipsData.cs index 09b76e9e5dc..846c3072231 100644 --- a/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/InheritanceRelationshipsData.cs +++ b/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/InheritanceRelationshipsData.cs @@ -136,7 +136,7 @@ public static IReadOnlyList CreateBaseEntitie Name = "Base1", OwnedReferenceOnBase = new OwnedEntity { Name = "OROB1" }, OwnedCollectionOnBase = - [new() { Id = 1, Name = "OCOB11" }, new() { Id = 2, Name = "OCOB12" }], + [new OwnedEntity { Id = 1, Name = "OCOB11" }, new OwnedEntity { Id = 2, Name = "OCOB12" }], BaseCollectionOnBase = [], CollectionOnBase = [], }, @@ -145,7 +145,7 @@ public static IReadOnlyList CreateBaseEntitie Id = 2, Name = "Base2", OwnedReferenceOnBase = new OwnedEntity { Name = "OROB2" }, - OwnedCollectionOnBase = [new() { Id = 3, Name = "OCOB21" }], + OwnedCollectionOnBase = [new OwnedEntity { Id = 3, Name = "OCOB21" }], BaseCollectionOnBase = [], CollectionOnBase = [], }, @@ -163,10 +163,10 @@ public static IReadOnlyList CreateBaseEntitie Name = "Derived1(4)", OwnedReferenceOnBase = new OwnedEntity { Name = "OROB4" }, OwnedCollectionOnBase = - [new() { Id = 4, Name = "OCOB41" }, new() { Id = 5, Name = "OCOB42" }], + [new OwnedEntity { Id = 4, Name = "OCOB41" }, new OwnedEntity { Id = 5, Name = "OCOB42" }], OwnedReferenceOnDerived = new OwnedEntity { Name = "OROD4" }, OwnedCollectionOnDerived = - [new() { Id = 1, Name = "OCOD41" }, new() { Id = 2, Name = "OCOD42" }], + [new OwnedEntity { Id = 1, Name = "OCOD41" }, new OwnedEntity { Id = 2, Name = "OCOD42" }], BaseCollectionOnBase = [], BaseCollectionOnDerived = [], CollectionOnBase = [], @@ -178,9 +178,9 @@ public static IReadOnlyList CreateBaseEntitie Id = 5, Name = "Derived2(5)", OwnedReferenceOnBase = new OwnedEntity { Name = "OROB5" }, - OwnedCollectionOnBase = [new() { Id = 6, Name = "OCOB51" }], + OwnedCollectionOnBase = [new OwnedEntity { Id = 6, Name = "OCOB51" }], OwnedReferenceOnDerived = new OwnedEntity { Name = "OROD5" }, - OwnedCollectionOnDerived = [new() { Id = 3, Name = "OCOD51" }], + OwnedCollectionOnDerived = [new OwnedEntity { Id = 3, Name = "OCOD51" }], BaseCollectionOnBase = [], BaseCollectionOnDerived = [], CollectionOnBase = [], diff --git a/test/EFCore.Specification.Tests/TestModels/JsonQuery/JsonEntityAllTypes.cs b/test/EFCore.Specification.Tests/TestModels/JsonQuery/JsonEntityAllTypes.cs index 157cd0ee3cd..1bc8effc7b3 100644 --- a/test/EFCore.Specification.Tests/TestModels/JsonQuery/JsonEntityAllTypes.cs +++ b/test/EFCore.Specification.Tests/TestModels/JsonQuery/JsonEntityAllTypes.cs @@ -15,11 +15,11 @@ public class JsonEntityAllTypes private Collection _testNullableEnumCollectionX = []; private Collection _testNullableEnumWithIntConverterCollectionX = [JsonEnum.Three]; - public List> TestInt64CollectionCollection { get; set; } = []; - public IReadOnlyList TestDoubleCollectionCollection { get; set; } = new List(); - public List[] TestSingleCollectionCollection { get; set; } = [[1.1f, 1.2f]]; - public bool[][] TestBooleanCollectionCollection { get; set; } = []; - public ObservableCollection> TestCharacterCollectionCollection { get; set; } = []; + public List> TestInt64CollectionCollection { get; set; } = []; + public IReadOnlyList TestDoubleCollectionCollection { get; set; } = new List(); + public List[] TestSingleCollectionCollection { get; set; } = [[1.1f, 1.2f]]; + public bool[][] TestBooleanCollectionCollection { get; set; } = []; + public ObservableCollection> TestCharacterCollectionCollection { get; set; } = []; public int Id { get; set; } public JsonOwnedAllTypes Reference { get; init; } @@ -40,9 +40,9 @@ public class JsonEntityAllTypes public decimal[] TestDecimalCollection { get; set; } public List TestDateTimeCollection { get; set; } public IList TestDateTimeOffsetCollection { get; set; } - public TimeSpan[] TestTimeSpanCollection { get; set; } = [new(1, 1, 1)]; + public TimeSpan[] TestTimeSpanCollection { get; set; } = [new TimeSpan(1, 1, 1)]; - public ReadOnlyCollection TestInt64Collection { get; set; } = new ReadOnlyCollection([]); + public ReadOnlyCollection TestInt64Collection { get; set; } = new([]); public IList TestDoubleCollection { get; set; } = new List(); public IReadOnlyList TestSingleCollection { get; set; } = [1.1f, 1.2f]; public IList TestBooleanCollection { get; set; } = new List { true }; diff --git a/test/EFCore.Specification.Tests/TestModels/JsonQuery/JsonOwnedAllTypes.cs b/test/EFCore.Specification.Tests/TestModels/JsonQuery/JsonOwnedAllTypes.cs index 1e53672004f..d455de89c9a 100644 --- a/test/EFCore.Specification.Tests/TestModels/JsonQuery/JsonOwnedAllTypes.cs +++ b/test/EFCore.Specification.Tests/TestModels/JsonQuery/JsonOwnedAllTypes.cs @@ -48,11 +48,11 @@ public class JsonOwnedAllTypes public JsonEnum? TestNullableEnumWithIntConverter { get; set; } public JsonEnum? TestNullableEnumWithConverterThatHandlesNulls { get; set; } - public List> TestInt64CollectionCollection { get; set; } = []; - public List TestDoubleCollectionCollection { get; set; } = new(); - public List TestSingleCollectionCollection { get; set; } = new([([1.1f, 1.2f])]); - public bool[][] TestBooleanCollectionCollection { get; set; } = []; - public ObservableCollection> TestCharacterCollectionCollection { get; set; } = []; + public List> TestInt64CollectionCollection { get; set; } = []; + public List TestDoubleCollectionCollection { get; set; } = new(); + public List TestSingleCollectionCollection { get; set; } = new([( [1.1f, 1.2f])]); + public bool[][] TestBooleanCollectionCollection { get; set; } = []; + public ObservableCollection> TestCharacterCollectionCollection { get; set; } = []; public string[] TestDefaultStringCollection { get; set; } public ReadOnlyCollection TestMaxLengthStringCollection { get; set; } @@ -83,7 +83,7 @@ public IList TestDoubleCollection public decimal[] TestDecimalCollection { get; set; } public List TestDateTimeCollection { get; set; } public IList TestDateTimeOffsetCollection { get; set; } - public TimeSpan[] TestTimeSpanCollection { get; set; } = [new(1, 1, 1)]; + public TimeSpan[] TestTimeSpanCollection { get; set; } = [new TimeSpan(1, 1, 1)]; public DateOnly[] TestDateOnlyCollection { get; set; } public TimeOnly[] TestTimeOnlyCollection { get; set; } diff --git a/test/EFCore.Specification.Tests/TestModels/JsonQuery/JsonQueryData.cs b/test/EFCore.Specification.Tests/TestModels/JsonQuery/JsonQueryData.cs index 239ecda402e..71d19bc0b18 100644 --- a/test/EFCore.Specification.Tests/TestModels/JsonQuery/JsonQueryData.cs +++ b/test/EFCore.Specification.Tests/TestModels/JsonQuery/JsonQueryData.cs @@ -480,9 +480,9 @@ public static IReadOnlyList CreateJsonEntitiesSingleOwned Name = "JsonEntitySingleOwned1", OwnedCollection = [ - new() { SomethingSomething = "owned_1_1" }, - new() { SomethingSomething = "owned_1_2" }, - new() { SomethingSomething = "owned_1_3" } + new JsonOwnedLeaf { SomethingSomething = "owned_1_1" }, + new JsonOwnedLeaf { SomethingSomething = "owned_1_2" }, + new JsonOwnedLeaf { SomethingSomething = "owned_1_3" } ] }; @@ -499,7 +499,7 @@ public static IReadOnlyList CreateJsonEntitiesSingleOwned Name = "JsonEntitySingleOwned3", OwnedCollection = [ - new() { SomethingSomething = "owned_3_1" }, new() { SomethingSomething = "owned_3_2" } + new JsonOwnedLeaf { SomethingSomething = "owned_3_1" }, new JsonOwnedLeaf { SomethingSomething = "owned_3_2" } ] }; @@ -755,7 +755,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() TestDateTimeOffsetCollection = new[] { new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)) }, TestDoubleCollection = new[] { -1.23456789, 1.23456789, 0.0 }, TestDecimalCollection = [-1234567890.01M], - TestGuidCollection = [new("12345678-1234-4321-7777-987654321000")], + TestGuidCollection = [new Guid("12345678-1234-4321-7777-987654321000")], TestInt16Collection = new[] { short.MinValue, (short)0, short.MaxValue }, TestInt32Collection = [int.MinValue, 0, int.MaxValue], TestInt64Collection = @@ -764,7 +764,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() 0, long.MaxValue ], - TestSignedByteCollection = [sbyte.MinValue, (sbyte)0, sbyte.MaxValue], + TestSignedByteCollection = [sbyte.MinValue, 0, sbyte.MaxValue], TestSingleCollection = [ -1.234F, @@ -780,7 +780,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() 0, ushort.MaxValue }, - TestUnsignedInt32Collection = [uint.MinValue, (uint)0, uint.MaxValue], + TestUnsignedInt32Collection = [uint.MinValue, 0, uint.MaxValue], TestUnsignedInt64Collection = [ ulong.MinValue, @@ -814,7 +814,8 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() ], TestNullableEnumWithConverterThatHandlesNullsCollection = [JsonEnum.One, null, (JsonEnum)(-7)], TestDefaultStringCollectionCollection = [["S11", "S12", "S13"], null, ["S21", null, "S23"]], - TestMaxLengthStringCollectionCollection = [new ReadOnlyCollection(["S11", "S12", "S13"]), null, new ReadOnlyCollection(["S21", null, "S23"])], + TestMaxLengthStringCollectionCollection = + [new ReadOnlyCollection(["S11", "S12", "S13"]), null, new ReadOnlyCollection(["S21", null, "S23"])], TestBooleanCollectionCollection = [[true], null, [true, false]], TestCharacterCollectionCollection = [['A', 'B', 'C'], null, ['D', 'E', 'F']], TestDoubleCollectionCollection = [[-1.23456789, -1.23456789], null, [1.23456789]], @@ -823,8 +824,16 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() TestInt64CollectionCollection = [[long.MinValue, 0, long.MaxValue], null, [long.MinValue, 0, long.MaxValue]], TestSingleCollectionCollection = [[-1.234F, 0.0F, -1.234F], null, [-1.234F, 0.0F, -1.234F]], TestNullableInt32CollectionCollection = [null, [int.MinValue, null, int.MaxValue, null], null, [int.MinValue, 0, int.MaxValue]], - TestNullableEnumCollectionCollection = [[null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], null], - TestNullableEnumWithIntConverterCollectionCollection = [[null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], null], + TestNullableEnumCollectionCollection = + [ + [null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], + null + ], + TestNullableEnumWithIntConverterCollectionCollection = + [ + [null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], + null + ], }; var r2 = new JsonOwnedAllTypes @@ -875,7 +884,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() TestDateTimeOffsetCollection = new[] { new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)) }, TestDoubleCollection = new[] { -1.23456789, 1.23456789, 0.0 }, TestDecimalCollection = [-1234567890.01M], - TestGuidCollection = [new("12345678-1234-4321-7777-987654321000")], + TestGuidCollection = [new Guid("12345678-1234-4321-7777-987654321000")], TestInt16Collection = new[] { short.MinValue, (short)0, short.MaxValue }, TestInt32Collection = [int.MinValue, 0, int.MaxValue], TestInt64Collection = @@ -884,7 +893,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() 0, long.MaxValue ], - TestSignedByteCollection = [sbyte.MinValue, (sbyte)0, sbyte.MaxValue], + TestSignedByteCollection = [sbyte.MinValue, 0, sbyte.MaxValue], TestSingleCollection = [ -1.234F, @@ -895,7 +904,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() TestDateOnlyCollection = [new DateOnly(2234, 1, 23), new DateOnly(5321, 1, 21)], TestTimeOnlyCollection = [new TimeOnly(21, 42, 23), new TimeOnly(17, 17, 27)], TestUnsignedInt16Collection = new[] { ushort.MinValue, (ushort)0, ushort.MaxValue }, - TestUnsignedInt32Collection = [uint.MinValue, (uint)0, uint.MaxValue], + TestUnsignedInt32Collection = [uint.MinValue, 0, uint.MaxValue], TestUnsignedInt64Collection = [ ulong.MinValue, @@ -929,7 +938,8 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() ], TestNullableEnumWithConverterThatHandlesNullsCollection = [JsonEnum.One, null, (JsonEnum)(-7)], TestDefaultStringCollectionCollection = [["S11", "S12", "S13"], null, ["S21", null, "S23"]], - TestMaxLengthStringCollectionCollection = [new ReadOnlyCollection(["S11", "S12", "S13"]), null, new ReadOnlyCollection(["S21", null, "S23"])], + TestMaxLengthStringCollectionCollection = + [new ReadOnlyCollection(["S11", "S12", "S13"]), null, new ReadOnlyCollection(["S21", null, "S23"])], TestBooleanCollectionCollection = [[true], null, [true, false]], TestCharacterCollectionCollection = [['A', 'B', 'C'], null, ['D', 'E', 'F']], TestDoubleCollectionCollection = [[-1.23456789, -1.23456789], null, [1.23456789]], @@ -938,8 +948,16 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() TestInt64CollectionCollection = [[long.MinValue, 0, long.MaxValue], null, [long.MinValue, 0, long.MaxValue]], TestSingleCollectionCollection = [[-1.234F, 0.0F, -1.234F], null, [-1.234F, 0.0F, -1.234F]], TestNullableInt32CollectionCollection = [null, [int.MinValue, null, int.MaxValue, null], null, [int.MinValue, 0, int.MaxValue]], - TestNullableEnumCollectionCollection = [[null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], null], - TestNullableEnumWithIntConverterCollectionCollection = [[null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], null], + TestNullableEnumCollectionCollection = + [ + [null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], + null + ], + TestNullableEnumWithIntConverterCollectionCollection = + [ + [null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], + null + ], }; var c1 = new JsonOwnedAllTypes @@ -990,7 +1008,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() TestDateTimeOffsetCollection = new[] { new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)) }, TestDoubleCollection = new[] { -1.23456789, 1.23456789, 0.0 }, TestDecimalCollection = [-1234567890.01M], - TestGuidCollection = [new("12345678-1234-4321-7777-987654321000")], + TestGuidCollection = [new Guid("12345678-1234-4321-7777-987654321000")], TestInt16Collection = new[] { short.MinValue, (short)0, short.MaxValue }, TestInt32Collection = [int.MinValue, 0, int.MaxValue], TestInt64Collection = @@ -999,7 +1017,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() 0, long.MaxValue ], - TestSignedByteCollection = [sbyte.MinValue, (sbyte)0, sbyte.MaxValue], + TestSignedByteCollection = [sbyte.MinValue, 0, sbyte.MaxValue], TestSingleCollection = [ -1.234F, @@ -1010,7 +1028,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() TestDateOnlyCollection = [new DateOnly(3234, 1, 23), new DateOnly(4331, 1, 21)], TestTimeOnlyCollection = [new TimeOnly(13, 42, 23), new TimeOnly(7, 17, 25)], TestUnsignedInt16Collection = new[] { ushort.MinValue, (ushort)0, ushort.MaxValue }, - TestUnsignedInt32Collection = [uint.MinValue, (uint)0, uint.MaxValue], + TestUnsignedInt32Collection = [uint.MinValue, 0, uint.MaxValue], TestUnsignedInt64Collection = [ ulong.MinValue, @@ -1044,7 +1062,8 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() }, TestNullableEnumWithConverterThatHandlesNullsCollection = [JsonEnum.One, null, (JsonEnum)(-7)], TestDefaultStringCollectionCollection = [["S11", "S12", "S13"], null, ["S21", null, "S23"]], - TestMaxLengthStringCollectionCollection = [new ReadOnlyCollection(["S11", "S12", "S13"]), null, new ReadOnlyCollection(["S21", null, "S23"])], + TestMaxLengthStringCollectionCollection = + [new ReadOnlyCollection(["S11", "S12", "S13"]), null, new ReadOnlyCollection(["S21", null, "S23"])], TestBooleanCollectionCollection = [[true], null, [true, false]], TestCharacterCollectionCollection = [['A', 'B', 'C'], null, ['D', 'E', 'F']], TestDoubleCollectionCollection = [[-1.23456789, -1.23456789], null, [1.23456789]], @@ -1053,8 +1072,16 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() TestInt64CollectionCollection = [[long.MinValue, 0, long.MaxValue], null, [long.MinValue, 0, long.MaxValue]], TestSingleCollectionCollection = [[-1.234F, 0.0F, -1.234F], null, [-1.234F, 0.0F, -1.234F]], TestNullableInt32CollectionCollection = [null, [int.MinValue, null, int.MaxValue, null], null, [int.MinValue, 0, int.MaxValue]], - TestNullableEnumCollectionCollection = [[null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], null], - TestNullableEnumWithIntConverterCollectionCollection = [[null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], null], + TestNullableEnumCollectionCollection = + [ + [null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], + null + ], + TestNullableEnumWithIntConverterCollectionCollection = + [ + [null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], + null + ], }; var c2 = new JsonOwnedAllTypes @@ -1105,7 +1132,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() TestDateTimeOffsetCollection = new[] { new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)) }, TestDoubleCollection = new[] { -1.23456789, 1.23456789, 0.0 }, TestDecimalCollection = [-1234567890.01M], - TestGuidCollection = [new("12345678-1234-4321-7777-987654321000")], + TestGuidCollection = [new Guid("12345678-1234-4321-7777-987654321000")], TestInt16Collection = new[] { short.MinValue, (short)0, short.MaxValue }, TestInt32Collection = [int.MinValue, 0, int.MaxValue], TestInt64Collection = @@ -1114,7 +1141,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() 0, long.MaxValue ], - TestSignedByteCollection = [sbyte.MinValue, (sbyte)0, sbyte.MaxValue], + TestSignedByteCollection = [sbyte.MinValue, 0, sbyte.MaxValue], TestSingleCollection = [ -1.234F, @@ -1125,7 +1152,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() TestDateOnlyCollection = [new DateOnly(1638, 1, 23), new DateOnly(4321, 1, 21)], TestTimeOnlyCollection = [new TimeOnly(8, 22, 23), new TimeOnly(7, 27, 37)], TestUnsignedInt16Collection = new[] { ushort.MinValue, (ushort)0, ushort.MaxValue }, - TestUnsignedInt32Collection = [uint.MinValue, (uint)0, uint.MaxValue], + TestUnsignedInt32Collection = [uint.MinValue, 0, uint.MaxValue], TestUnsignedInt64Collection = [ ulong.MinValue, @@ -1159,7 +1186,8 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() }, TestNullableEnumWithConverterThatHandlesNullsCollection = [JsonEnum.One, null, (JsonEnum)(-7)], TestDefaultStringCollectionCollection = [["S11", "S12", "S13"], null, ["S21", null, "S23"]], - TestMaxLengthStringCollectionCollection = [new ReadOnlyCollection(["S11", "S12", "S13"]), null, new ReadOnlyCollection(["S21", null, "S23"])], + TestMaxLengthStringCollectionCollection = + [new ReadOnlyCollection(["S11", "S12", "S13"]), null, new ReadOnlyCollection(["S21", null, "S23"])], TestBooleanCollectionCollection = [[true], null, [true, false]], TestCharacterCollectionCollection = [['A', 'B', 'C'], null, ['D', 'E', 'F']], TestDoubleCollectionCollection = [[-1.23456789, -1.23456789], null, [1.23456789]], @@ -1168,8 +1196,16 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() TestInt64CollectionCollection = [[long.MinValue, 0, long.MaxValue], null, [long.MinValue, 0, long.MaxValue]], TestSingleCollectionCollection = [[-1.234F, 0.0F, -1.234F], null, [-1.234F, 0.0F, -1.234F]], TestNullableInt32CollectionCollection = [null, [int.MinValue, null, int.MaxValue, null], null, [int.MinValue, 0, int.MaxValue]], - TestNullableEnumCollectionCollection = [[null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], null], - TestNullableEnumWithIntConverterCollectionCollection = [[null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], null], + TestNullableEnumCollectionCollection = + [ + [null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], + null + ], + TestNullableEnumWithIntConverterCollectionCollection = + [ + [null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], + null + ], }; return new List @@ -1200,7 +1236,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() new[] { new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)) }, TestDoubleCollection = new[] { -1.23456789, 1.23456789, 0.0 }, TestDecimalCollection = [-1234567890.01M], - TestGuidCollection = new ReadOnlyCollection([new("12345678-1234-4321-7777-987654321000")]), + TestGuidCollection = new ReadOnlyCollection([new Guid("12345678-1234-4321-7777-987654321000")]), TestInt16Collection = new[] { short.MinValue, (short)0, short.MaxValue }, TestInt32Collection = [int.MinValue, 0, int.MaxValue], TestInt64Collection = new ReadOnlyCollection( @@ -1209,7 +1245,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() 0, long.MaxValue ]), - TestSignedByteCollection = [sbyte.MinValue, (sbyte)0, sbyte.MaxValue], + TestSignedByteCollection = [sbyte.MinValue, 0, sbyte.MaxValue], TestSingleCollection = [ -1.234F, @@ -1223,7 +1259,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() 0, ushort.MaxValue }, - TestUnsignedInt32Collection = [uint.MinValue, (uint)0, uint.MaxValue], + TestUnsignedInt32Collection = [uint.MinValue, 0, uint.MaxValue], TestUnsignedInt64Collection = [ ulong.MinValue, @@ -1259,15 +1295,31 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() TestDefaultStringCollectionCollection = [["S11", "S12", "S13"], null, ["S21", null, "S23"]], TestMaxLengthStringCollectionCollection = [["S11", "S12", "S13"], null, ["S21", null, "S23"]], TestBooleanCollectionCollection = [[true], null, [true, false]], - TestCharacterCollectionCollection = [new ReadOnlyCollection(['A', 'B', 'C']), null, new ReadOnlyCollection(['D', 'E', 'F'])], + TestCharacterCollectionCollection = + [new ReadOnlyCollection(['A', 'B', 'C']), null, new ReadOnlyCollection(['D', 'E', 'F'])], TestDoubleCollectionCollection = [[-1.23456789, -1.23456789], null, [1.23456789]], TestInt16CollectionCollection = [[short.MinValue, 0, short.MaxValue], null, [short.MinValue, 0, short.MaxValue]], TestInt32CollectionCollection = [[int.MinValue, 0, int.MaxValue], null, [int.MinValue, 0, int.MaxValue]], TestInt64CollectionCollection = [[long.MinValue, 0, long.MaxValue], null, [long.MinValue, 0, long.MaxValue]], TestSingleCollectionCollection = [[-1.234F, 0.0F, -1.234F], null, [-1.234F, 0.0F, -1.234F]], - TestNullableInt32CollectionCollection = [null, [int.MinValue, null, int.MaxValue, null], null, [int.MinValue, 0, int.MaxValue]], - TestNullableEnumCollectionCollection = [[null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], null], - TestNullableEnumWithIntConverterCollectionCollection = [[null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], null], + TestNullableInt32CollectionCollection = + [null, [int.MinValue, null, int.MaxValue, null], null, [int.MinValue, 0, int.MaxValue]], + TestNullableEnumCollectionCollection = + [ + [ + null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, + [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)] + ], + null + ], + TestNullableEnumWithIntConverterCollectionCollection = + [ + [ + null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, + [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)] + ], + null + ], }, new() { @@ -1295,7 +1347,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() new[] { new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)) }, TestDoubleCollection = new[] { -1.23456789, 1.23456789, 0.0 }, TestDecimalCollection = [-1234567890.01M], - TestGuidCollection = new ReadOnlyCollection([new("12345678-1234-4321-7777-987654321000")]), + TestGuidCollection = new ReadOnlyCollection([new Guid("12345678-1234-4321-7777-987654321000")]), TestInt16Collection = new[] { short.MinValue, (short)0, short.MaxValue }, TestInt32Collection = [int.MinValue, 0, int.MaxValue], TestInt64Collection = new ReadOnlyCollection( @@ -1304,7 +1356,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() 0, long.MaxValue ]), - TestSignedByteCollection = [sbyte.MinValue, (sbyte)0, sbyte.MaxValue], + TestSignedByteCollection = [sbyte.MinValue, 0, sbyte.MaxValue], TestSingleCollection = [ -1.234F, @@ -1318,7 +1370,7 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() 0, ushort.MaxValue }, - TestUnsignedInt32Collection = [uint.MinValue, (uint)0, uint.MaxValue], + TestUnsignedInt32Collection = [uint.MinValue, 0, uint.MaxValue], TestUnsignedInt64Collection = [ ulong.MinValue, @@ -1354,15 +1406,31 @@ public static IReadOnlyList CreateJsonEntitiesAllTypes() TestDefaultStringCollectionCollection = [["S11B", "S12B", "S13B"], null, ["S21B", null, "S23B"]], TestMaxLengthStringCollectionCollection = [["S11B", "S12B", "S13B"], null, ["S21B", null, "S23B"]], TestBooleanCollectionCollection = [[true], null, [true, false]], - TestCharacterCollectionCollection = [new ReadOnlyCollection(['A', 'B', 'C']), null, new ReadOnlyCollection(['D', 'E', 'F'])], + TestCharacterCollectionCollection = + [new ReadOnlyCollection(['A', 'B', 'C']), null, new ReadOnlyCollection(['D', 'E', 'F'])], TestDoubleCollectionCollection = [[-1.23456789, -1.23456789], null, [1.23456789]], TestInt16CollectionCollection = [[short.MinValue, 0, short.MaxValue], null, [short.MinValue, 0, short.MaxValue]], TestInt32CollectionCollection = [[int.MinValue, 0, int.MaxValue], null, [int.MinValue, 0, int.MaxValue]], TestInt64CollectionCollection = [[long.MinValue, 0, long.MaxValue], null, [long.MinValue, 0, long.MaxValue]], TestSingleCollectionCollection = [[-1.234F, 0.0F, -1.234F], null, [-1.234F, 0.0F, -1.234F]], - TestNullableInt32CollectionCollection = [null, [int.MinValue, null, int.MaxValue, null], null, [int.MinValue, 0, int.MaxValue]], - TestNullableEnumCollectionCollection = [[null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], null], - TestNullableEnumWithIntConverterCollectionCollection = [[null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)]], null], + TestNullableInt32CollectionCollection = + [null, [int.MinValue, null, int.MaxValue, null], null, [int.MinValue, 0, int.MaxValue]], + TestNullableEnumCollectionCollection = + [ + [ + null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, + [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)] + ], + null + ], + TestNullableEnumWithIntConverterCollectionCollection = + [ + [ + null, [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)], null, + [JsonEnum.One, null, JsonEnum.Three, (JsonEnum)(-7)] + ], + null + ], } }; } diff --git a/test/EFCore.Specification.Tests/TestModels/MonsterContext`.cs b/test/EFCore.Specification.Tests/TestModels/MonsterContext`.cs index de7eab59d7f..a3b6ca82d09 100644 --- a/test/EFCore.Specification.Tests/TestModels/MonsterContext`.cs +++ b/test/EFCore.Specification.Tests/TestModels/MonsterContext`.cs @@ -12,7 +12,8 @@ public class MonsterContext< TSmartCard, TRsaToken, TPasswordReset, TPageView, TLastLogin, TMessage, TAnOrder, TOrderNote, TOrderQualityCheck, TOrderLine, TProduct, TProductDetail, TProductReview, TProductPhoto, TProductWebFeature, TSupplier, TSupplierLogo, TSupplierInfo, TCustomerInfo, TComputer, TComputerDetail, TDriver, TLicense, TConcurrencyInfo, TAuditInfo, - TContactDetails, TDimensions, TPhone, TBackOrderLine, TDiscontinuedProduct, TProductPageView>(DbContextOptions options) : MonsterContext(options) + TContactDetails, TDimensions, TPhone, TBackOrderLine, TDiscontinuedProduct, TProductPageView>(DbContextOptions options) + : MonsterContext(options) where TCustomer : class, ICustomer, new() where TBarcode : class, IBarcode, new() where TIncorrectScan : class, IIncorrectScan, new() @@ -798,10 +799,7 @@ public override Task SeedUsingFKs() new TSupplier { Name = "Ants By Boris" }).Entity; var supplierLogo1 = Add( - new TSupplierLogo - { - SupplierId = Entry(supplier1).Property(e => e.SupplierId).CurrentValue, Logo = [201, 202] - }) + new TSupplierLogo { SupplierId = Entry(supplier1).Property(e => e.SupplierId).CurrentValue, Logo = [201, 202] }) .Entity; var supplierInfo1 = Add( @@ -1416,8 +1414,7 @@ public override Task SeedUsingNavigations(bool dependentNavs, bool principalNavs var supplierLogo1 = Add( new TSupplierLogo { - SupplierId = !principalNavs ? Entry(supplier1).Property(e => e.SupplierId).CurrentValue : 0, - Logo = [201, 202] + SupplierId = !principalNavs ? Entry(supplier1).Property(e => e.SupplierId).CurrentValue : 0, Logo = [201, 202] }).Entity; if (principalNavs) { diff --git a/test/EFCore.Specification.Tests/TestModels/Northwind/Customer.cs b/test/EFCore.Specification.Tests/TestModels/Northwind/Customer.cs index 6ab99aef8ed..ccabdd5406e 100644 --- a/test/EFCore.Specification.Tests/TestModels/Northwind/Customer.cs +++ b/test/EFCore.Specification.Tests/TestModels/Northwind/Customer.cs @@ -19,9 +19,7 @@ public Customer() // Custom ctor binding public Customer(DbContext context, ILazyLoader lazyLoader, string customerID) - { - CustomerID = customerID; - } + => CustomerID = customerID; [MaxLength(5)] [Required] diff --git a/test/EFCore.Specification.Tests/TestModels/Northwind/OrderQuery.cs b/test/EFCore.Specification.Tests/TestModels/Northwind/OrderQuery.cs index a3ea211e310..2bbd5fdfbab 100644 --- a/test/EFCore.Specification.Tests/TestModels/Northwind/OrderQuery.cs +++ b/test/EFCore.Specification.Tests/TestModels/Northwind/OrderQuery.cs @@ -12,9 +12,7 @@ public OrderQuery() } public OrderQuery(string customerID) - { - CustomerID = customerID; - } + => CustomerID = customerID; public string CustomerID { get; set; } diff --git a/test/EFCore.Specification.Tests/TestModels/Northwind/Product.cs b/test/EFCore.Specification.Tests/TestModels/Northwind/Product.cs index 3926568be96..ddde126b672 100644 --- a/test/EFCore.Specification.Tests/TestModels/Northwind/Product.cs +++ b/test/EFCore.Specification.Tests/TestModels/Northwind/Product.cs @@ -12,9 +12,7 @@ public class Product private int? _productId; public Product() - { - OrderDetails = []; - } + => OrderDetails = []; public int ProductID { diff --git a/test/EFCore.Specification.Tests/TestModels/SpatialModel/SpatialData.cs b/test/EFCore.Specification.Tests/TestModels/SpatialModel/SpatialData.cs index 79c37161a84..0492bb4077e 100644 --- a/test/EFCore.Specification.Tests/TestModels/SpatialModel/SpatialData.cs +++ b/test/EFCore.Specification.Tests/TestModels/SpatialModel/SpatialData.cs @@ -100,11 +100,7 @@ public static IReadOnlyList CreateGeoPointEntities() public static IReadOnlyList CreateLineStringEntities(GeometryFactory factory) => new[] { - new LineStringEntity - { - Id = 1, - LineString = factory.CreateLineString([new(0, 0), new(1, 0)]) - }, + new LineStringEntity { Id = 1, LineString = factory.CreateLineString([new Coordinate(0, 0), new Coordinate(1, 0)]) }, new LineStringEntity { Id = 2, LineString = null } }; @@ -128,8 +124,8 @@ public static IReadOnlyList CreateMultiLineStringEntities Id = 1, MultiLineString = factory.CreateMultiLineString( [ - factory.CreateLineString([new(0, 0), new(0, 1)]), - factory.CreateLineString([new(1, 0), new(1, 1)]) + factory.CreateLineString([new Coordinate(0, 0), new Coordinate(0, 1)]), + factory.CreateLineString([new Coordinate(1, 0), new Coordinate(1, 1)]) ]) }, new MultiLineStringEntity { Id = 2, MultiLineString = null } diff --git a/test/EFCore.Specification.Tests/TestUtilities/DataGenerator`.cs b/test/EFCore.Specification.Tests/TestUtilities/DataGenerator`.cs index 21b225c9c20..61d5ef762e0 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/DataGenerator`.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/DataGenerator`.cs @@ -7,8 +7,9 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities; public class DataGenerator : IEnumerable { - public IEnumerator GetEnumerator() => - DataGenerator.GetCombinations(typeof(T)).AsEnumerable().GetEnumerator(); + public IEnumerator GetEnumerator() + => DataGenerator.GetCombinations(typeof(T)).AsEnumerable().GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); } diff --git a/test/EFCore.Specification.Tests/TestUtilities/DataGenerator``.cs b/test/EFCore.Specification.Tests/TestUtilities/DataGenerator``.cs index 00f5917b903..48dc2f14c44 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/DataGenerator``.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/DataGenerator``.cs @@ -7,8 +7,9 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities; public class DataGenerator : IEnumerable { - public IEnumerator GetEnumerator() => - DataGenerator.GetCombinations(typeof(T1), typeof(T2)).AsEnumerable().GetEnumerator(); + public IEnumerator GetEnumerator() + => DataGenerator.GetCombinations(typeof(T1), typeof(T2)).AsEnumerable().GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); } diff --git a/test/EFCore.Specification.Tests/TestUtilities/ExpectedQueryRewritingVisitor.cs b/test/EFCore.Specification.Tests/TestUtilities/ExpectedQueryRewritingVisitor.cs index 678072fdc69..4bbaef6b333 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/ExpectedQueryRewritingVisitor.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/ExpectedQueryRewritingVisitor.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities; -public class ExpectedQueryRewritingVisitor(Dictionary<(Type, string), Func>? shadowPropertyMappings = null) : ExpressionVisitor +public class ExpectedQueryRewritingVisitor(Dictionary<(Type, string), Func>? shadowPropertyMappings = null) + : ExpressionVisitor { private static readonly MethodInfo _maybeDefaultIfEmpty = typeof(TestExtensions).GetMethod(nameof(TestExtensions.MaybeDefaultIfEmpty))!; @@ -17,7 +18,8 @@ private static readonly MethodInfo _getShadowPropertyValueMethodInfo private static readonly MethodInfo _maybeScalarNullableMethod; private static readonly MethodInfo _maybeScalarNonNullableMethod; - private readonly Dictionary<(Type, string), Func> _shadowPropertyMappings = shadowPropertyMappings ?? new Dictionary<(Type, string), Func>(); + private readonly Dictionary<(Type, string), Func> _shadowPropertyMappings = + shadowPropertyMappings ?? new Dictionary<(Type, string), Func>(); private bool _negated; diff --git a/test/EFCore.Specification.Tests/TestUtilities/ListLoggerFactory.cs b/test/EFCore.Specification.Tests/TestUtilities/ListLoggerFactory.cs index e1ed535fa12..f4acf95c785 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/ListLoggerFactory.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/ListLoggerFactory.cs @@ -18,7 +18,7 @@ public ListLoggerFactory() public List<(LogLevel Level, EventId Id, string? Message, object? State, Exception? Exception)> Log => Logger.LoggedEvents; - protected ListLogger Logger { get; set; } = new ListLogger(); + protected ListLogger Logger { get; set; } = new(); public virtual void Clear() => Logger.Clear(); @@ -149,7 +149,8 @@ public bool IsEnabled(LogLevel logLevel) public IDisposable? BeginScope(object state) => null; - public IDisposable? BeginScope(TState state) where TState : notnull + public IDisposable? BeginScope(TState state) + where TState : notnull => null; public void SuspendTestOutput(bool writeAllPreviousMessages = true) diff --git a/test/EFCore.Specification.Tests/TestUtilities/MetadataExtensions.cs b/test/EFCore.Specification.Tests/TestUtilities/MetadataExtensions.cs index b9b0bb96db8..2c0b76ad569 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/MetadataExtensions.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/MetadataExtensions.cs @@ -1,8 +1,6 @@ // 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.Metadata.Internal; - namespace Microsoft.EntityFrameworkCore.TestUtilities; public static class MetadataExtensions diff --git a/test/EFCore.Specification.Tests/TestUtilities/ModelAsserter.cs b/test/EFCore.Specification.Tests/TestUtilities/ModelAsserter.cs index dd6699e7a09..b9f4f93cc71 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/ModelAsserter.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/ModelAsserter.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using Microsoft.EntityFrameworkCore.Metadata.Internal; +using Index = Microsoft.EntityFrameworkCore.Metadata.Internal.Index; namespace Microsoft.EntityFrameworkCore.TestUtilities; @@ -54,7 +55,8 @@ public virtual void AssertEqual( Assert.Equal(expected.GetPropertyAccessMode(), actual.GetPropertyAccessMode()); } }, - () => AssertEqual(expected.GetEntityTypes(), actual.GetEntityTypes(), + () => AssertEqual( + expected.GetEntityTypes(), actual.GetEntityTypes(), assertOrder: true, compareAnnotations: compareMemberAnnotations), () => Assert.Equal(expectedAnnotations, actualAnnotations, TestAnnotationComparer.Instance)); } @@ -75,7 +77,8 @@ public virtual void AssertEqual( expectedEntityTypes = expectedEntityTypes.Select(x => x); } - Assert.Equal(expectedEntityTypes, actualEntityTypes, + Assert.Equal( + expectedEntityTypes, actualEntityTypes, (expected, actual) => AssertEqual( expected, @@ -86,9 +89,13 @@ public virtual void AssertEqual( compareMemberAnnotations: compareAnnotations)); } - public virtual bool AssertEqual(IReadOnlyEntityType? expected, IReadOnlyEntityType? actual, - IEnumerable expectedAnnotations, IEnumerable actualAnnotations, - bool compareBackreferences = false, bool compareMemberAnnotations = false) + public virtual bool AssertEqual( + IReadOnlyEntityType? expected, + IReadOnlyEntityType? actual, + IEnumerable expectedAnnotations, + IEnumerable actualAnnotations, + bool compareBackreferences = false, + bool compareMemberAnnotations = false) { if (expected == null) { @@ -135,19 +142,26 @@ public virtual bool AssertEqual(IReadOnlyEntityType? expected, IReadOnlyEntityTy () => Assert.Equal(expected.GetDiscriminatorPropertyName(), actual.GetDiscriminatorPropertyName()), () => Assert.Equal(expected.GetDiscriminatorValue(), actual.GetDiscriminatorValue()), () => Assert.Equal(expected.GetIsDiscriminatorMappingComplete(), actual.GetIsDiscriminatorMappingComplete()), - () => AssertEqual(expected.GetProperties(), actual.GetProperties(), + () => AssertEqual( + expected.GetProperties(), actual.GetProperties(), assertOrder: true, compareAnnotations: compareMemberAnnotations), - () => AssertEqual(expected.GetServiceProperties(), actual.GetServiceProperties(), + () => AssertEqual( + expected.GetServiceProperties(), actual.GetServiceProperties(), assertOrder: true, compareAnnotations: compareMemberAnnotations), - () => AssertEqual(expected.GetSkipNavigations(), actual.GetSkipNavigations(), + () => AssertEqual( + expected.GetSkipNavigations(), actual.GetSkipNavigations(), assertOrder: true, compareAnnotations: compareMemberAnnotations), - () => AssertEqual(expected.GetForeignKeys(), actual.GetForeignKeys(), + () => AssertEqual( + expected.GetForeignKeys(), actual.GetForeignKeys(), assertOrder: true, compareAnnotations: compareMemberAnnotations), - () => AssertEqual(expected.GetKeys(), actual.GetKeys(), + () => AssertEqual( + expected.GetKeys(), actual.GetKeys(), assertOrder: true, compareAnnotations: compareMemberAnnotations), - () => AssertEqual(expected.GetIndexes(), actual.GetIndexes(), + () => AssertEqual( + expected.GetIndexes(), actual.GetIndexes(), assertOrder: true, compareAnnotations: compareMemberAnnotations), - () => AssertEqual(expected.GetComplexProperties(), actual.GetComplexProperties(), + () => AssertEqual( + expected.GetComplexProperties(), actual.GetComplexProperties(), assertOrder: true, compareAnnotations: compareMemberAnnotations), () => { @@ -168,8 +182,11 @@ public virtual bool AssertEqual(IReadOnlyEntityType? expected, IReadOnlyEntityTy return true; } - public virtual bool AssertEqual(IReadOnlyComplexType expected, IReadOnlyComplexType actual, - IEnumerable expectedAnnotations, IEnumerable actualAnnotations, + public virtual bool AssertEqual( + IReadOnlyComplexType expected, + IReadOnlyComplexType actual, + IEnumerable expectedAnnotations, + IEnumerable actualAnnotations, bool compareBackreferences = false, bool compareMemberAnnotations = false) { @@ -189,9 +206,11 @@ public virtual bool AssertEqual(IReadOnlyComplexType expected, IReadOnlyComplexT } }, () => Assert.Equal(expected.GetChangeTrackingStrategy(), actual.GetChangeTrackingStrategy()), - () => AssertEqual(expected.GetProperties(), actual.GetProperties(), + () => AssertEqual( + expected.GetProperties(), actual.GetProperties(), assertOrder: true, compareAnnotations: compareMemberAnnotations), - () => AssertEqual(expected.GetComplexProperties(), actual.GetComplexProperties(), + () => AssertEqual( + expected.GetComplexProperties(), actual.GetComplexProperties(), assertOrder: true, compareAnnotations: compareMemberAnnotations), () => { @@ -221,7 +240,8 @@ public virtual void AssertEqual( expectedProperties = expectedProperties.Select(x => x); } - Assert.Equal(expectedProperties, actualProperties, + Assert.Equal( + expectedProperties, actualProperties, (expected, actual) => AssertEqual( expected, @@ -232,8 +252,11 @@ public virtual void AssertEqual( compareMemberAnnotations: compareAnnotations)); } - public virtual bool AssertEqual(IReadOnlyComplexProperty? expected, IReadOnlyComplexProperty? actual, - IEnumerable expectedAnnotations, IEnumerable actualAnnotations, + public virtual bool AssertEqual( + IReadOnlyComplexProperty? expected, + IReadOnlyComplexProperty? actual, + IEnumerable expectedAnnotations, + IEnumerable actualAnnotations, bool compareBackreferences = false, bool compareMemberAnnotations = false) { @@ -258,7 +281,8 @@ public virtual bool AssertEqual(IReadOnlyComplexProperty? expected, IReadOnlyCom () => Assert.Equal(expected.IsNullable, actual.IsNullable), () => Assert.Equal(expected.Sentinel, actual.Sentinel), () => Assert.Equal(expected.GetPropertyAccessMode(), actual.GetPropertyAccessMode()), - () => AssertEqual(expected.ComplexType, actual.ComplexType, + () => AssertEqual( + expected.ComplexType, actual.ComplexType, compareMemberAnnotations ? expected.GetAnnotations() : Enumerable.Empty(), compareMemberAnnotations ? actual.GetAnnotations() : Enumerable.Empty(), compareBackreferences: false, @@ -291,7 +315,8 @@ public virtual void AssertEqual( expectedProperties = expectedProperties.Select(x => x); } - Assert.Equal(expectedProperties, actualProperties, + Assert.Equal( + expectedProperties, actualProperties, (expected, actual) => AssertEqual( expected, @@ -422,7 +447,8 @@ public virtual void AssertEqual( expectedProperties = expectedProperties.Select(x => x); } - Assert.Equal(expectedProperties, actualProperties, + Assert.Equal( + expectedProperties, actualProperties, (expected, actual) => AssertEqual( expected, @@ -432,8 +458,11 @@ public virtual void AssertEqual( compareBackreferences: false)); } - public virtual bool AssertEqual(IReadOnlyServiceProperty? expected, IReadOnlyServiceProperty? actual, - IEnumerable expectedAnnotations, IEnumerable actualAnnotations, + public virtual bool AssertEqual( + IReadOnlyServiceProperty? expected, + IReadOnlyServiceProperty? actual, + IEnumerable expectedAnnotations, + IEnumerable actualAnnotations, bool compareBackreferences = false) { if (expected == null) @@ -484,7 +513,8 @@ public virtual void AssertEqual( expectedNavigations = expectedNavigations.Select(x => x); } - Assert.Equal(expectedNavigations, actualNavigations, + Assert.Equal( + expectedNavigations, actualNavigations, (expected, actual) => AssertEqual( expected, @@ -494,8 +524,11 @@ public virtual void AssertEqual( compareBackreferences: false)); } - public virtual bool AssertEqual(IReadOnlyNavigation? expected, IReadOnlyNavigation? actual, - IEnumerable expectedAnnotations, IEnumerable actualAnnotations, + public virtual bool AssertEqual( + IReadOnlyNavigation? expected, + IReadOnlyNavigation? actual, + IEnumerable expectedAnnotations, + IEnumerable actualAnnotations, bool compareBackreferences = false) { if (expected == null) @@ -563,7 +596,8 @@ public virtual void AssertEqual( expectedNavigations = expectedNavigations.Select(x => x); } - Assert.Equal(expectedNavigations, actualNavigations, + Assert.Equal( + expectedNavigations, actualNavigations, (expected, actual) => AssertEqual( expected, @@ -573,8 +607,11 @@ public virtual void AssertEqual( compareBackreferences: false)); } - public virtual bool AssertEqual(IReadOnlySkipNavigation expected, IReadOnlySkipNavigation actual, - IEnumerable expectedAnnotations, IEnumerable actualAnnotations, + public virtual bool AssertEqual( + IReadOnlySkipNavigation expected, + IReadOnlySkipNavigation actual, + IEnumerable expectedAnnotations, + IEnumerable actualAnnotations, bool compareBackreferences = false) { if (expected == null) @@ -642,7 +679,8 @@ public virtual void AssertEqual( expectedKeys = expectedKeys.Select(x => x); } - Assert.Equal(expectedKeys, actualKeys, + Assert.Equal( + expectedKeys, actualKeys, (expected, actual) => AssertEqual( expected, @@ -696,7 +734,8 @@ public virtual bool AssertEqual( { if (compareBackreferences) { - Assert.Equal(expected.GetReferencingForeignKeys().ToList(), actual.GetReferencingForeignKeys(), ForeignKeyComparer.Instance); + Assert.Equal( + expected.GetReferencingForeignKeys().ToList(), actual.GetReferencingForeignKeys(), ForeignKeyComparer.Instance); } }, () => Assert.Equal(expectedAnnotations, actualAnnotations, TestAnnotationComparer.Instance)); @@ -720,7 +759,8 @@ public virtual void AssertEqual( expectedForeignKey = expectedForeignKey.Select(x => x); } - Assert.Equal(expectedForeignKey, actualForeignKey, + Assert.Equal( + expectedForeignKey, actualForeignKey, (expected, actual) => AssertEqual( expected, @@ -768,7 +808,8 @@ public virtual bool AssertEqual( () => Assert.Equal(expected.IsRequiredDependent, actual.IsRequiredDependent), () => Assert.Equal(expected.IsUnique, actual.IsUnique), () => Assert.Equal(expected.DeleteBehavior, actual.DeleteBehavior), - () => AssertEqual(expected.DependentToPrincipal, actual.DependentToPrincipal, + () => AssertEqual( + expected.DependentToPrincipal, actual.DependentToPrincipal, compareMemberAnnotations ? expected.DependentToPrincipal?.GetAnnotations() ?? Enumerable.Empty() : Enumerable.Empty(), @@ -776,7 +817,8 @@ public virtual bool AssertEqual( ? actual.DependentToPrincipal?.GetAnnotations() ?? Enumerable.Empty() : Enumerable.Empty(), compareBackreferences: true), - () => AssertEqual(expected.PrincipalToDependent, actual.PrincipalToDependent, + () => AssertEqual( + expected.PrincipalToDependent, actual.PrincipalToDependent, compareMemberAnnotations ? expected.PrincipalToDependent?.GetAnnotations() ?? Enumerable.Empty() : Enumerable.Empty(), @@ -812,7 +854,8 @@ public virtual void AssertEqual( expectedIndex = expectedIndex.Select(x => x); } - Assert.Equal(expectedIndex, actualIndex, + Assert.Equal( + expectedIndex, actualIndex, (expected, actual) => AssertEqual( expected, @@ -842,7 +885,7 @@ public virtual bool AssertEqual( expectedAnnotations = expectedAnnotations.Where(a => !CoreAnnotationNames.AllNames.Contains(a.Name)); actualAnnotations = actualAnnotations.Where(a => !CoreAnnotationNames.AllNames.Contains(a.Name)); - var designTime = expected is Metadata.Internal.Index && actual is Metadata.Internal.Index; + var designTime = expected is Index && actual is Index; Assert.Multiple( () => @@ -922,12 +965,13 @@ public virtual IReadOnlyModel Clone(IReadOnlyModel model) { var targetEntityType = clonedEntityType.Value; var otherEntityType = targetEntityType.Model.FindEntityType(skipNavigation.TargetEntityType.Name)!; - Copy(skipNavigation, clonedEntityType.Value.AddSkipNavigation( - skipNavigation.Name, - skipNavigation.GetIdentifyingMemberInfo(), - otherEntityType, - skipNavigation.IsCollection, - skipNavigation.IsOnDependent)); + Copy( + skipNavigation, clonedEntityType.Value.AddSkipNavigation( + skipNavigation.Name, + skipNavigation.GetIdentifyingMemberInfo(), + otherEntityType, + skipNavigation.IsCollection, + skipNavigation.IsOnDependent)); } } @@ -965,24 +1009,27 @@ protected virtual void Copy(IReadOnlyEntityType sourceEntityType, IMutableEntity foreach (var property in sourceEntityType.GetDeclaredComplexProperties()) { - Copy(property, targetEntityType.AddComplexProperty( - property.Name, - property.ClrType, - property.ComplexType.ClrType, - property.ComplexType.Name, - collection: property.IsCollection)); + Copy( + property, targetEntityType.AddComplexProperty( + property.Name, + property.ClrType, + property.ComplexType.ClrType, + property.ComplexType.Name, + collection: property.IsCollection)); } foreach (var property in sourceEntityType.GetDeclaredServiceProperties()) { - Copy(property, targetEntityType.AddServiceProperty( - property.GetIdentifyingMemberInfo()!, property.ClrType)); + Copy( + property, targetEntityType.AddServiceProperty( + property.GetIdentifyingMemberInfo()!, property.ClrType)); } foreach (var key in sourceEntityType.GetDeclaredKeys()) { - Copy(key, targetEntityType.AddKey( - key.Properties.Select(p => targetEntityType.FindProperty(p.Name)!).ToList())); + Copy( + key, targetEntityType.AddKey( + key.Properties.Select(p => targetEntityType.FindProperty(p.Name)!).ToList())); } foreach (var index in sourceEntityType.GetDeclaredIndexes()) @@ -1003,6 +1050,7 @@ protected virtual void Copy(IReadOnlyProperty sourceProperty, IMutableProperty t { targetProperty.FieldInfo = fieldInfo; } + targetProperty.IsNullable = sourceProperty.IsNullable; targetProperty.IsConcurrencyToken = sourceProperty.IsConcurrencyToken; targetProperty.Sentinel = sourceProperty.Sentinel; @@ -1025,6 +1073,7 @@ protected virtual void Copy(IReadOnlyServiceProperty sourceProperty, IMutableSer { targetProperty.FieldInfo = fieldInfo; } + targetProperty.SetPropertyAccessMode(sourceProperty.GetPropertyAccessMode()); targetProperty.AddAnnotations(sourceProperty.GetAnnotations().Where(a => !CoreAnnotationNames.AllNames.Contains(a.Name))); } @@ -1035,6 +1084,7 @@ protected virtual void Copy(IReadOnlyComplexProperty sourceProperty, IMutableCom { targetProperty.FieldInfo = fieldInfo; } + targetProperty.IsNullable = sourceProperty.IsNullable; targetProperty.SetPropertyAccessMode(sourceProperty.GetPropertyAccessMode()); targetProperty.AddAnnotations(sourceProperty.GetAnnotations().Where(a => !CoreAnnotationNames.AllNames.Contains(a.Name))); @@ -1053,12 +1103,13 @@ protected virtual void Copy(IReadOnlyComplexType sourceComplexType, IMutableComp foreach (var property in sourceComplexType.GetDeclaredComplexProperties()) { - Copy(property, targetComplexType.AddComplexProperty( - property.Name, - property.ClrType, - property.ComplexType.ClrType, - property.ComplexType.Name, - collection: property.IsCollection)); + Copy( + property, targetComplexType.AddComplexProperty( + property.Name, + property.ClrType, + property.ComplexType.ClrType, + property.ComplexType.Name, + collection: property.IsCollection)); } targetComplexType.AddAnnotations(sourceComplexType.GetAnnotations().Where(a => !CoreAnnotationNames.AllNames.Contains(a.Name))); @@ -1104,8 +1155,9 @@ protected virtual void Copy(IReadOnlyForeignKey sourceForeignKey, IMutableForeig Copy(sourceForeignKey.PrincipalToDependent, clonedNavigation!); } - targetForeignKey.AddAnnotations(sourceForeignKey.GetAnnotations() - .Where(a => !CoreAnnotationNames.AllNames.Contains(a.Name))); + targetForeignKey.AddAnnotations( + sourceForeignKey.GetAnnotations() + .Where(a => !CoreAnnotationNames.AllNames.Contains(a.Name))); } protected virtual void Copy(IReadOnlyNavigation sourceNavigation, IMutableNavigation targetNavigation) @@ -1118,8 +1170,9 @@ protected virtual void Copy(IReadOnlyNavigation sourceNavigation, IMutableNaviga targetNavigation.SetPropertyAccessMode(sourceNavigation.GetPropertyAccessMode()); targetNavigation.SetIsEagerLoaded(sourceNavigation.IsEagerLoaded); targetNavigation.SetLazyLoadingEnabled(sourceNavigation.LazyLoadingEnabled); - targetNavigation.AddAnnotations(sourceNavigation.GetAnnotations() - .Where(a => !CoreAnnotationNames.AllNames.Contains(a.Name))); + targetNavigation.AddAnnotations( + sourceNavigation.GetAnnotations() + .Where(a => !CoreAnnotationNames.AllNames.Contains(a.Name))); } protected virtual void Copy(IReadOnlySkipNavigation sourceNavigation, IMutableSkipNavigation targetNavigation) diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestAnnotationComparer.cs b/test/EFCore.Specification.Tests/TestUtilities/TestAnnotationComparer.cs index 12fc99b8c49..55985e8067b 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestAnnotationComparer.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestAnnotationComparer.cs @@ -31,9 +31,10 @@ public bool Equals(IAnnotation? x, IAnnotation? y) return y == null; } - return y != null && (x.Name == y.Name - && (x.Name == CoreAnnotationNames.ValueGeneratorFactory - || CompareAnnotations())); + return y != null + && (x.Name == y.Name + && (x.Name == CoreAnnotationNames.ValueGeneratorFactory + || CompareAnnotations())); bool CompareAnnotations() { @@ -46,7 +47,7 @@ bool CompareAnnotations() return false; } - for (int i = 0; i < xList.Count; i++) + for (var i = 0; i < xList.Count; i++) { if (!Equals(xList[i], yList[i])) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestHelpers.cs b/test/EFCore.Specification.Tests/TestUtilities/TestHelpers.cs index d00ba6ec514..bfad3f6333a 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestHelpers.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestHelpers.cs @@ -5,7 +5,6 @@ using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; using Microsoft.EntityFrameworkCore.Design.Internal; using Microsoft.EntityFrameworkCore.Internal; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -432,7 +431,8 @@ public override IModel FinalizeModel() public IModel FinalizeModel(bool designTime = false, bool skipValidation = false) { - var designTimeModel = _modelRuntimeInitializer.Initialize((IModel)Model, designTime: true, skipValidation ? null : _validationLogger); + var designTimeModel = _modelRuntimeInitializer.Initialize( + (IModel)Model, designTime: true, skipValidation ? null : _validationLogger); var runtimeModel = (IModel)designTimeModel.FindRuntimeAnnotationValue(CoreAnnotationNames.ReadOnlyModel)!; return designTime ? designTimeModel : runtimeModel; } diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestLogger.cs b/test/EFCore.Specification.Tests/TestUtilities/TestLogger.cs index 9af4c2282a6..48fb28042ae 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestLogger.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestLogger.cs @@ -23,7 +23,8 @@ public ILogger Logger public bool IsEnabled(LogLevel logLevel) => EnabledFor == logLevel; - public IDisposable? BeginScope(TState state) where TState : notnull + public IDisposable? BeginScope(TState state) + where TState : notnull => null; public void Log( diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestLoggerFactory.cs b/test/EFCore.Specification.Tests/TestUtilities/TestLoggerFactory.cs index c0f51d02a81..d8ae3c7b541 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestLoggerFactory.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestLoggerFactory.cs @@ -5,7 +5,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities; public class TestLoggerFactory(LoggingDefinitions definitions) : ILoggerFactory { - public TestLogger Logger { get; } = new TestLogger(definitions); + public TestLogger Logger { get; } = new(definitions); public LogLevel? LoggedAt => Logger.LoggedAt; diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs b/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs index 6884b6ac5d3..bf2c333fd80 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs @@ -116,9 +116,7 @@ public static IDisposable CreateTransactionScope(bool useTransaction = true) private class DistributedTransactionListener : IDisposable { public DistributedTransactionListener() - { - TransactionManager.DistributedTransactionStarted += DistributedTransactionStarted; - } + => TransactionManager.DistributedTransactionStarted += DistributedTransactionStarted; private void DistributedTransactionStarted(object? sender, TransactionEventArgs e) => Assert.Fail("Distributed transaction started"); diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestValueConverterComparer.cs b/test/EFCore.Specification.Tests/TestUtilities/TestValueConverterComparer.cs index 6a3f95a7cdc..2d9d43bbcba 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestValueConverterComparer.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestValueConverterComparer.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // ReSharper disable PossibleNullReferenceException + namespace Microsoft.EntityFrameworkCore.TestUtilities; public class TestValueConverterComparer : IEqualityComparer @@ -18,7 +19,7 @@ public bool Equals(ValueConverter? x, ValueConverter? y) : y == null ? false : ExpressionEqualityComparer.Instance.Equals(x.ConvertFromProviderExpression, y.ConvertFromProviderExpression) - && ExpressionEqualityComparer.Instance.Equals(x.ConvertToProviderExpression, y.ConvertToProviderExpression); + && ExpressionEqualityComparer.Instance.Equals(x.ConvertToProviderExpression, y.ConvertToProviderExpression); public int GetHashCode(ValueConverter obj) => ExpressionEqualityComparer.Instance.GetHashCode(obj.ConvertFromProviderExpression) diff --git a/test/EFCore.Specification.Tests/TestUtilities/Xunit/SkipOnCiConditionAttribute.cs b/test/EFCore.Specification.Tests/TestUtilities/Xunit/SkipOnCiConditionAttribute.cs index 66f7f760ed3..3a018bd3fa8 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/Xunit/SkipOnCiConditionAttribute.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/Xunit/SkipOnCiConditionAttribute.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities.Xunit; public sealed class SkipOnCiConditionAttribute : Attribute, ITestCondition { public ValueTask IsMetAsync() - => new(Environment.GetEnvironmentVariable("PIPELINE_WORKSPACE") == null + => new( + Environment.GetEnvironmentVariable("PIPELINE_WORKSPACE") == null && Environment.GetEnvironmentVariable("GITHUB_RUN_ID") == null); public string SkipReason { get; set; } = "Tests not reliable on C.I."; diff --git a/test/EFCore.Specification.Tests/Update/UpdatesTestBase.cs b/test/EFCore.Specification.Tests/Update/UpdatesTestBase.cs index bf3395d59b2..6108506e568 100644 --- a/test/EFCore.Specification.Tests/Update/UpdatesTestBase.cs +++ b/test/EFCore.Specification.Tests/Update/UpdatesTestBase.cs @@ -863,7 +863,6 @@ protected class Muffin : Baked { public required string MuffinName { get; set; } public Top Top { get; set; } = null!; - } protected class Tin diff --git a/test/EFCore.Specification.Tests/WithConstructorsTestBase.cs b/test/EFCore.Specification.Tests/WithConstructorsTestBase.cs index 822e188a925..018a307eef4 100644 --- a/test/EFCore.Specification.Tests/WithConstructorsTestBase.cs +++ b/test/EFCore.Specification.Tests/WithConstructorsTestBase.cs @@ -797,9 +797,7 @@ public Post( string content, Blog blog = null) : this(0, title, content) - { - Blog = blog; - } + => Blog = blog; public string Title { get; } public string Content { get; set; } @@ -890,9 +888,7 @@ public HasEntityType() } private HasEntityType(IEntityType entityType) - { - _entityType = entityType; - } + => _entityType = entityType; public int Id { get; set; } @@ -921,9 +917,7 @@ public HasEntityTypePc() } private HasEntityTypePc(IEntityType entityType) - { - _entityType = entityType; - } + => _entityType = entityType; public int Id { get; set; } @@ -956,9 +950,7 @@ public HasStateManager() } private HasStateManager(IStateManager stateManager) - { - _stateManager = stateManager; - } + => _stateManager = stateManager; public int Id { get; set; } @@ -988,9 +980,7 @@ public HasStateManagerPc() } private HasStateManagerPc(IStateManager stateManager) - { - _stateManager = stateManager; - } + => _stateManager = stateManager; public int Id { get; set; } @@ -1024,9 +1014,7 @@ public LazyBlog() } private LazyBlog(ILazyLoader loader) - { - _loader = loader; - } + => _loader = loader; public int Id { get; set; } @@ -1049,9 +1037,7 @@ public LazyPost() } private LazyPost(ILazyLoader loader) - { - _loader = loader; - } + => _loader = loader; public int Id { get; set; } @@ -1231,9 +1217,7 @@ public LazyPcBlog() } private LazyPcBlog(ILazyLoader loader) - { - _loader = loader; - } + => _loader = loader; private ILazyLoader Loader { @@ -1270,9 +1254,7 @@ public LazyPcPost() } private LazyPcPost(ILazyLoader loader) - { - _loader = loader; - } + => _loader = loader; private ILazyLoader Loader { @@ -1309,9 +1291,7 @@ public LazyPcsBlog() } private LazyPcsBlog(Action lazyLoader) - { - _loader = lazyLoader; - } + => _loader = lazyLoader; private Action LazyLoader { @@ -1348,9 +1328,7 @@ public LazyPcsPost() } private LazyPcsPost(Action lazyLoader) - { - _loader = lazyLoader; - } + => _loader = lazyLoader; private Action LazyLoader { @@ -1390,9 +1368,7 @@ public LazyPocoBlog() } private LazyPocoBlog(Action lazyLoader) - { - _loader = lazyLoader; - } + => _loader = lazyLoader; public int Id { get; set; } @@ -1415,9 +1391,7 @@ public LazyPocoPost() } private LazyPocoPost(Action lazyLoader) - { - _loader = lazyLoader; - } + => _loader = lazyLoader; public int Id { get; set; } @@ -1440,9 +1414,7 @@ public LazyAsyncPocoBlog() } private LazyAsyncPocoBlog(Func lazyLoader) - { - _loader = lazyLoader; - } + => _loader = lazyLoader; public int Id { get; set; } @@ -1471,9 +1443,7 @@ public LazyAsyncPocoPost() } private LazyAsyncPocoPost(Func lazyLoader) - { - _loader = lazyLoader; - } + => _loader = lazyLoader; public int Id { get; set; } @@ -1499,9 +1469,7 @@ public LazyAsyncBlog() } private LazyAsyncBlog(ILazyLoader loader) - { - _loader = loader; - } + => _loader = loader; public int Id { get; set; } @@ -1530,9 +1498,7 @@ public LazyAsyncPost() } private LazyAsyncPost(ILazyLoader loader) - { - _loader = loader; - } + => _loader = loader; public int Id { get; set; } diff --git a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesSqlServerTest.cs index 1c719aa04e4..2f6c2b967ee 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesSqlServerTest.cs @@ -5,7 +5,9 @@ namespace Microsoft.EntityFrameworkCore.BulkUpdates; #nullable disable -public class ComplexTypeBulkUpdatesSqlServerTest(ComplexTypeBulkUpdatesSqlServerTest.ComplexTypeBulkUpdatesSqlServerFixture fixture, ITestOutputHelper testOutputHelper) : ComplexTypeBulkUpdatesRelationalTestBase< +public class ComplexTypeBulkUpdatesSqlServerTest( + ComplexTypeBulkUpdatesSqlServerTest.ComplexTypeBulkUpdatesSqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : ComplexTypeBulkUpdatesRelationalTestBase< ComplexTypeBulkUpdatesSqlServerTest.ComplexTypeBulkUpdatesSqlServerFixture>(fixture, testOutputHelper) { public override async Task Delete_entity_type_with_complex_type(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqlServerTest.cs index 27dd7719563..fd52c737309 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqlServerTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore.BulkUpdates; public class NorthwindBulkUpdatesSqlServerTest( NorthwindBulkUpdatesSqlServerFixture fixture, - ITestOutputHelper testOutputHelper) : NorthwindBulkUpdatesRelationalTestBase>(fixture, testOutputHelper) + ITestOutputHelper testOutputHelper) + : NorthwindBulkUpdatesRelationalTestBase>(fixture, testOutputHelper) { [ConditionalFact] public virtual void Check_all_tests_overridden() @@ -1035,7 +1036,7 @@ public override async Task Update_Where_set_property_plus_parameter(bool async) await base.Update_Where_set_property_plus_parameter(async); AssertExecuteUpdateSql( -""" + """ @__value_0='Abc' (Size = 4000) UPDATE [c] diff --git a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSqlServerTest.cs index e047c9b138d..42168ca6a4f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSqlServerTest.cs @@ -9,9 +9,7 @@ public class TPTInheritanceBulkUpdatesSqlServerTest : TPTInheritanceBulkUpdatesT { public TPTInheritanceBulkUpdatesSqlServerTest(TPTInheritanceBulkUpdatesSqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper) - { - ClearLog(); - } + => ClearLog(); [ConditionalFact] public virtual void Check_all_tests_overridden() diff --git a/test/EFCore.SqlServer.FunctionalTests/ComplexTypesTrackingSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ComplexTypesTrackingSqlServerTest.cs index fe8535e292f..87f88713b7c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ComplexTypesTrackingSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ComplexTypesTrackingSqlServerTest.cs @@ -6,8 +6,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable public class ComplexTypesTrackingSqlServerTest( - ComplexTypesTrackingSqlServerTest.SqlServerFixture fixture, - ITestOutputHelper testOutputHelper) + ComplexTypesTrackingSqlServerTest.SqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : ComplexTypesTrackingSqlServerTestBase(fixture, testOutputHelper) { public class SqlServerFixture : SqlServerFixtureBase @@ -18,8 +18,8 @@ protected override string StoreName } public class ComplexTypesTrackingProxiesSqlServerTest( - ComplexTypesTrackingProxiesSqlServerTest.SqlServerFixture fixture, - ITestOutputHelper testOutputHelper) + ComplexTypesTrackingProxiesSqlServerTest.SqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : ComplexTypesTrackingSqlServerTestBase(fixture, testOutputHelper) { // Fields can't be proxied diff --git a/test/EFCore.SqlServer.FunctionalTests/CompositeKeyEndToEndSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/CompositeKeyEndToEndSqlServerTest.cs index 3cdebfb1688..7ce2175182b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/CompositeKeyEndToEndSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/CompositeKeyEndToEndSqlServerTest.cs @@ -5,8 +5,9 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class CompositeKeyEndToEndSqlServerTest(CompositeKeyEndToEndSqlServerTest.CompositeKeyEndToEndSqlServerFixture fixture) : CompositeKeyEndToEndTestBase< - CompositeKeyEndToEndSqlServerTest.CompositeKeyEndToEndSqlServerFixture>(fixture) +public class CompositeKeyEndToEndSqlServerTest(CompositeKeyEndToEndSqlServerTest.CompositeKeyEndToEndSqlServerFixture fixture) + : CompositeKeyEndToEndTestBase< + CompositeKeyEndToEndSqlServerTest.CompositeKeyEndToEndSqlServerFixture>(fixture) { public class CompositeKeyEndToEndSqlServerFixture : CompositeKeyEndToEndFixtureBase { diff --git a/test/EFCore.SqlServer.FunctionalTests/ConcurrencyDetectorDisabledSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ConcurrencyDetectorDisabledSqlServerTest.cs index 5d973555b5f..d373d8ac63c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ConcurrencyDetectorDisabledSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ConcurrencyDetectorDisabledSqlServerTest.cs @@ -10,9 +10,7 @@ public class ConcurrencyDetectorDisabledSqlServerTest : ConcurrencyDetectorDisab { public ConcurrencyDetectorDisabledSqlServerTest(ConcurrencyDetectorSqlServerFixture fixture) : base(fixture) - { - Fixture.TestSqlLoggerFactory.Clear(); - } + => Fixture.TestSqlLoggerFactory.Clear(); protected override async Task ConcurrencyDetectorTest(Func> test) { diff --git a/test/EFCore.SqlServer.FunctionalTests/ConcurrencyDetectorEnabledSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ConcurrencyDetectorEnabledSqlServerTest.cs index 93d5cfe64d1..f1b771d3171 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ConcurrencyDetectorEnabledSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ConcurrencyDetectorEnabledSqlServerTest.cs @@ -10,9 +10,7 @@ public class ConcurrencyDetectorEnabledSqlServerTest : ConcurrencyDetectorEnable { public ConcurrencyDetectorEnabledSqlServerTest(ConcurrencyDetectorSqlServerFixture fixture) : base(fixture) - { - Fixture.TestSqlLoggerFactory.Clear(); - } + => Fixture.TestSqlLoggerFactory.Clear(); protected override async Task ConcurrencyDetectorTest(Func> test) { diff --git a/test/EFCore.SqlServer.FunctionalTests/ConferencePlannerSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ConferencePlannerSqlServerTest.cs index d3aed4b2065..86e5d615196 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ConferencePlannerSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ConferencePlannerSqlServerTest.cs @@ -5,8 +5,9 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class ConferencePlannerSqlServerTest(ConferencePlannerSqlServerTest.ConferencePlannerSqlServerFixture fixture) : ConferencePlannerTestBase(fixture) +public class ConferencePlannerSqlServerTest(ConferencePlannerSqlServerTest.ConferencePlannerSqlServerFixture fixture) + : ConferencePlannerTestBase(fixture) { protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs index d5148ae98d2..b4867588d2e 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs @@ -73,7 +73,8 @@ protected override bool ShouldSubscribeToDiagnosticListener } } - public class ConnectionInterceptionWithConnectionStringSqlServerTest(ConnectionInterceptionWithConnectionStringSqlServerTest.InterceptionSqlServerFixture fixture) + public class ConnectionInterceptionWithConnectionStringSqlServerTest( + ConnectionInterceptionWithConnectionStringSqlServerTest.InterceptionSqlServerFixture fixture) : ConnectionInterceptionSqlServerTestBase(fixture), IClassFixture { @@ -87,8 +88,9 @@ protected override DbContextOptionsBuilder ConfigureProvider(DbContextOptionsBui => optionsBuilder.UseSqlServer("Database=Dummy"); } - public class ConnectionInterceptionWithDiagnosticsSqlServerTest(ConnectionInterceptionWithDiagnosticsSqlServerTest.InterceptionSqlServerFixture fixture) - : ConnectionInterceptionSqlServerTestBase(fixture), + public class ConnectionInterceptionWithDiagnosticsSqlServerTest( + ConnectionInterceptionWithDiagnosticsSqlServerTest.InterceptionSqlServerFixture fixture) + : ConnectionInterceptionSqlServerTestBase(fixture), IClassFixture { public class InterceptionSqlServerFixture : InterceptionSqlServerFixtureBase diff --git a/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs index 5b947a6643a..6817b48124a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs @@ -12,9 +12,7 @@ public class CustomConvertersSqlServerTest : CustomConvertersTestBase Fixture.TestSqlLoggerFactory.Clear(); [ConditionalFact] public virtual void Columns_have_expected_data_types() @@ -282,7 +280,7 @@ FROM [Blog] AS [b] """); } - public async override Task Where_bool_gets_converted_to_equality_when_value_conversion_is_used_using_EFProperty() + public override async Task Where_bool_gets_converted_to_equality_when_value_conversion_is_used_using_EFProperty() { await base.Where_bool_gets_converted_to_equality_when_value_conversion_is_used_using_EFProperty(); @@ -294,7 +292,7 @@ FROM [Blog] AS [b] """); } - public async override Task Where_bool_gets_converted_to_equality_when_value_conversion_is_used_using_indexer() + public override async Task Where_bool_gets_converted_to_equality_when_value_conversion_is_used_using_indexer() { await base.Where_bool_gets_converted_to_equality_when_value_conversion_is_used_using_indexer(); @@ -310,7 +308,7 @@ public override Task Object_to_string_conversion() // Return values are not string => Task.CompletedTask; - public async override Task Id_object_as_entity_key() + public override async Task Id_object_as_entity_key() { await base.Id_object_as_entity_key(); diff --git a/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs b/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs index 778813b94b9..49f7a25e89d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs @@ -19,9 +19,9 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable - #pragma warning disable CS9113 // Parameter is unread. -public class DbContextPoolingTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : IClassFixture> +public class DbContextPoolingTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : IClassFixture> #pragma warning restore CS9113 // Parameter is unread. { private static DbContextOptionsBuilder ConfigureOptions(DbContextOptionsBuilder optionsBuilder) @@ -531,15 +531,11 @@ private class WithParameterlessConstructorContext : DbContext public string ConstructorUsed { get; } public WithParameterlessConstructorContext() - { - ConstructorUsed = "Parameterless"; - } + => ConstructorUsed = "Parameterless"; public WithParameterlessConstructorContext(DbContextOptions options) : base(options) - { - ConstructorUsed = "Options"; - } + => ConstructorUsed = "Options"; } [ConditionalTheory] @@ -2010,7 +2006,7 @@ public void Double_dispose_concurrency_test(bool useInterface) }); } - [ConditionalTheory (Skip = "Issue #32700")] + [ConditionalTheory(Skip = "Issue #32700")] [InlineData(false, false)] [InlineData(true, false)] [InlineData(false, true)] diff --git a/test/EFCore.SqlServer.FunctionalTests/DesignTimeSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/DesignTimeSqlServerTest.cs index 12258ce23dd..8a9fabe566f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/DesignTimeSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/DesignTimeSqlServerTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class DesignTimeSqlServerTest(DesignTimeSqlServerTest.DesignTimeSqlServerFixture fixture) : DesignTimeTestBase(fixture) +public class DesignTimeSqlServerTest(DesignTimeSqlServerTest.DesignTimeSqlServerFixture fixture) + : DesignTimeTestBase(fixture) { protected override Assembly ProviderAssembly => typeof(SqlServerDesignTimeServices).Assembly; diff --git a/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs index 4cdfbd4027e..9ae682e4129 100644 --- a/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs @@ -261,8 +261,7 @@ public SqlServerBytesTypeMappingSource( TypeMappingSourceDependencies dependencies, RelationalTypeMappingSourceDependencies relationalDependencies) : base(dependencies, relationalDependencies) - { - _storeTypeMappings + => _storeTypeMappings = new Dictionary(StringComparer.OrdinalIgnoreCase) { { "binary varying", _variableLengthBinary }, @@ -271,7 +270,6 @@ public SqlServerBytesTypeMappingSource( { "rowversion", _rowversion }, { "varbinary", _variableLengthBinary } }; - } protected override RelationalTypeMapping FindMapping(in RelationalTypeMappingInfo mappingInfo) => FindRawMapping(mappingInfo)?.WithTypeMappingInfo(mappingInfo); diff --git a/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs index 3edade4ed1b..ff89f494fbd 100644 --- a/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs @@ -261,8 +261,7 @@ public SqlServerStringsTypeMappingSource( TypeMappingSourceDependencies dependencies, RelationalTypeMappingSourceDependencies relationalDependencies) : base(dependencies, relationalDependencies) - { - _storeTypeMappings + => _storeTypeMappings = new Dictionary(StringComparer.OrdinalIgnoreCase) { { "char varying", _variableLengthAnsiString }, @@ -278,7 +277,6 @@ public SqlServerStringsTypeMappingSource( { "text", _variableLengthAnsiString }, { "varchar", _variableLengthAnsiString } }; - } protected override RelationalTypeMapping FindMapping(in RelationalTypeMappingInfo mappingInfo) => FindRawMapping(mappingInfo)?.WithTypeMappingInfo(mappingInfo); diff --git a/test/EFCore.SqlServer.FunctionalTests/FieldMappingSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/FieldMappingSqlServerTest.cs index aeeae47abeb..22a61c84ec4 100644 --- a/test/EFCore.SqlServer.FunctionalTests/FieldMappingSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/FieldMappingSqlServerTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class FieldMappingSqlServerTest(FieldMappingSqlServerTest.FieldMappingSqlServerFixture fixture) : FieldMappingTestBase(fixture) +public class FieldMappingSqlServerTest(FieldMappingSqlServerTest.FieldMappingSqlServerFixture fixture) + : FieldMappingTestBase(fixture) { protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.SqlServer.FunctionalTests/FieldsOnlyLoadSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/FieldsOnlyLoadSqlServerTest.cs index 3255d8db36c..eb4ba3c7968 100644 --- a/test/EFCore.SqlServer.FunctionalTests/FieldsOnlyLoadSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/FieldsOnlyLoadSqlServerTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class FieldsOnlyLoadSqlServerTest(FieldsOnlyLoadSqlServerTest.FieldsOnlyLoadSqlServerFixture fixture) : FieldsOnlyLoadTestBase(fixture) +public class FieldsOnlyLoadSqlServerTest(FieldsOnlyLoadSqlServerTest.FieldsOnlyLoadSqlServerFixture fixture) + : FieldsOnlyLoadTestBase(fixture) { public class FieldsOnlyLoadSqlServerFixture : FieldsOnlyLoadFixtureBase { diff --git a/test/EFCore.SqlServer.FunctionalTests/FindSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/FindSqlServerTest.cs index 5540e94ad32..a5b6b87f5b7 100644 --- a/test/EFCore.SqlServer.FunctionalTests/FindSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/FindSqlServerTest.cs @@ -9,9 +9,7 @@ public abstract class FindSqlServerTest : FindTestBase fixture.TestSqlLoggerFactory.Clear(); public class FindSqlServerTestSet(FindSqlServerFixture fixture) : FindSqlServerTest(fixture) { diff --git a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerClientCascadeTest.cs b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerClientCascadeTest.cs index e9fc8fe77e1..d7396dd6b44 100644 --- a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerClientCascadeTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerClientCascadeTest.cs @@ -5,8 +5,9 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class GraphUpdatesSqlServerClientCascadeTest(GraphUpdatesSqlServerClientCascadeTest.SqlServerFixture fixture) : GraphUpdatesSqlServerTestBase< - GraphUpdatesSqlServerClientCascadeTest.SqlServerFixture>(fixture) +public class GraphUpdatesSqlServerClientCascadeTest(GraphUpdatesSqlServerClientCascadeTest.SqlServerFixture fixture) + : GraphUpdatesSqlServerTestBase< + GraphUpdatesSqlServerClientCascadeTest.SqlServerFixture>(fixture) { protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerClientNoActionTest.cs b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerClientNoActionTest.cs index d8e440c4b88..1631dc1f65a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerClientNoActionTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerClientNoActionTest.cs @@ -5,8 +5,9 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class GraphUpdatesSqlServerClientNoActionTest(GraphUpdatesSqlServerClientNoActionTest.SqlServerFixture fixture) : GraphUpdatesSqlServerTestBase< - GraphUpdatesSqlServerClientNoActionTest.SqlServerFixture>(fixture) +public class GraphUpdatesSqlServerClientNoActionTest(GraphUpdatesSqlServerClientNoActionTest.SqlServerFixture fixture) + : GraphUpdatesSqlServerTestBase< + GraphUpdatesSqlServerClientNoActionTest.SqlServerFixture>(fixture) { protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerHiLoTest.cs b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerHiLoTest.cs index f178d2729fe..bde99583153 100644 --- a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerHiLoTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerHiLoTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class GraphUpdatesSqlServerHiLoTest(GraphUpdatesSqlServerHiLoTest.SqlServerFixture fixture) : GraphUpdatesSqlServerTestBase(fixture) +public class GraphUpdatesSqlServerHiLoTest(GraphUpdatesSqlServerHiLoTest.SqlServerFixture fixture) + : GraphUpdatesSqlServerTestBase(fixture) { protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerIdentityTest.cs b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerIdentityTest.cs index e4704b253ed..5cda53cab07 100644 --- a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerIdentityTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerIdentityTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class GraphUpdatesSqlServerIdentityTest(GraphUpdatesSqlServerIdentityTest.SqlServerFixture fixture) : GraphUpdatesSqlServerTestBase(fixture) +public class GraphUpdatesSqlServerIdentityTest(GraphUpdatesSqlServerIdentityTest.SqlServerFixture fixture) + : GraphUpdatesSqlServerTestBase(fixture) { protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerSequenceTest.cs b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerSequenceTest.cs index 2e56efd8491..2693329222b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerSequenceTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerSequenceTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class GraphUpdatesSqlServerSequenceTest(GraphUpdatesSqlServerSequenceTest.SqlServerFixture fixture) : GraphUpdatesSqlServerTestBase(fixture) +public class GraphUpdatesSqlServerSequenceTest(GraphUpdatesSqlServerSequenceTest.SqlServerFixture fixture) + : GraphUpdatesSqlServerTestBase(fixture) { protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerTestBase.cs b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerTestBase.cs index 482f2b45c1a..8d612278e72 100644 --- a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerTestBase.cs +++ b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerTestBase.cs @@ -19,11 +19,7 @@ public virtual void Key_and_index_properties_use_appropriate_comparer() UniqueIndex = "UniqueIndex" }; - var child = new StringKeyAndIndexChild - { - Id = "Child", - ParentId = "parent" - }; + var child = new StringKeyAndIndexChild { Id = "Child", ParentId = "parent" }; using var context = CreateContext(); context.AttachRange(parent, child); @@ -61,7 +57,6 @@ public virtual void Key_and_index_properties_use_appropriate_comparer() Assert.False(childEntry.Property(e => e.Id).IsModified); Assert.False(childEntry.Property(e => e.ParentId).IsModified); } - } protected class StringKeyAndIndexParent : NotifyingEntity @@ -122,7 +117,6 @@ public string ParentId set => SetWithNotify(value, ref _parentId); } - public int Foo { get => _foo; diff --git a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerTptIdentityTest.cs b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerTptIdentityTest.cs index 167e5035017..35e7cb1e538 100644 --- a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerTptIdentityTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerTptIdentityTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class GraphUpdatesSqlServerTptIdentityTest(GraphUpdatesSqlServerTptIdentityTest.SqlServerFixture fixture) : GraphUpdatesSqlServerTestBase(fixture) +public class GraphUpdatesSqlServerTptIdentityTest(GraphUpdatesSqlServerTptIdentityTest.SqlServerFixture fixture) + : GraphUpdatesSqlServerTestBase(fixture) { protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.SqlServer.FunctionalTests/JsonTypesCustomMappingSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/JsonTypesCustomMappingSqlServerTest.cs index c1acbfa7271..700bccd5963 100644 --- a/test/EFCore.SqlServer.FunctionalTests/JsonTypesCustomMappingSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/JsonTypesCustomMappingSqlServerTest.cs @@ -11,8 +11,8 @@ protected override IServiceCollection AddServices(IServiceCollection serviceColl => serviceCollection.AddSingleton(); private class TestSqlServerTypeMappingSource( - TypeMappingSourceDependencies dependencies, - RelationalTypeMappingSourceDependencies relationalDependencies) + TypeMappingSourceDependencies dependencies, + RelationalTypeMappingSourceDependencies relationalDependencies) : SqlServerTypeMappingSource(dependencies, relationalDependencies) { protected override RelationalTypeMapping? FindMapping(in RelationalTypeMappingInfo mappingInfo) diff --git a/test/EFCore.SqlServer.FunctionalTests/JsonTypesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/JsonTypesSqlServerTest.cs index 8c8fb545851..c8e6e9904d5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/JsonTypesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/JsonTypesSqlServerTest.cs @@ -3,6 +3,4 @@ namespace Microsoft.EntityFrameworkCore; -#nullable disable - public class JsonTypesSqlServerTest : JsonTypesSqlServerTestBase; diff --git a/test/EFCore.SqlServer.FunctionalTests/KeysWithConvertersSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/KeysWithConvertersSqlServerTest.cs index 8d1d05fed20..150de2e2455 100644 --- a/test/EFCore.SqlServer.FunctionalTests/KeysWithConvertersSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/KeysWithConvertersSqlServerTest.cs @@ -5,8 +5,9 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class KeysWithConvertersSqlServerTest(KeysWithConvertersSqlServerTest.KeysWithConvertersSqlServerFixture fixture) : KeysWithConvertersTestBase< - KeysWithConvertersSqlServerTest.KeysWithConvertersSqlServerFixture>(fixture) +public class KeysWithConvertersSqlServerTest(KeysWithConvertersSqlServerTest.KeysWithConvertersSqlServerFixture fixture) + : KeysWithConvertersTestBase< + KeysWithConvertersSqlServerTest.KeysWithConvertersSqlServerFixture>(fixture) { public class KeysWithConvertersSqlServerFixture : KeysWithConvertersFixtureBase { diff --git a/test/EFCore.SqlServer.FunctionalTests/LazyLoadProxySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/LazyLoadProxySqlServerTest.cs index 0b277099f14..596125f4ee1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/LazyLoadProxySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/LazyLoadProxySqlServerTest.cs @@ -9,9 +9,7 @@ public class LazyLoadProxySqlServerTest : LazyLoadProxyTestBase fixture.TestSqlLoggerFactory.Clear(); public override void Lazy_load_collection(EntityState state, bool useAttach, bool useDetach) { diff --git a/test/EFCore.SqlServer.FunctionalTests/LoadSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/LoadSqlServerTest.cs index 2f294a0876d..a59ee7f2f0a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/LoadSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/LoadSqlServerTest.cs @@ -9,9 +9,7 @@ public class LoadSqlServerTest : LoadTestBase fixture.TestSqlLoggerFactory.Clear(); public override async Task Lazy_load_collection(EntityState state, QueryTrackingBehavior queryTrackingBehavior, bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/LoggingSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/LoggingSqlServerTest.cs index 64c82f18cdb..188824e6da2 100644 --- a/test/EFCore.SqlServer.FunctionalTests/LoggingSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/LoggingSqlServerTest.cs @@ -27,7 +27,8 @@ public virtual void StoredProcedureConcurrencyTokenNotMapped_throws_by_default() () => context.Model).Message); } - protected class StoredProcedureConcurrencyTokenNotMappedContext(DbContextOptionsBuilder optionsBuilder) : DbContext(optionsBuilder.Options) + protected class StoredProcedureConcurrencyTokenNotMappedContext(DbContextOptionsBuilder optionsBuilder) + : DbContext(optionsBuilder.Options) { protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.Entity( diff --git a/test/EFCore.SqlServer.FunctionalTests/ManyToManyFieldsLoadSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ManyToManyFieldsLoadSqlServerTest.cs index d3b7c3231c8..603be183660 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ManyToManyFieldsLoadSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ManyToManyFieldsLoadSqlServerTest.cs @@ -7,8 +7,9 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class ManyToManyFieldsLoadSqlServerTest(ManyToManyFieldsLoadSqlServerTest.ManyToManyFieldsLoadSqlServerFixture fixture) : ManyToManyFieldsLoadTestBase< - ManyToManyFieldsLoadSqlServerTest.ManyToManyFieldsLoadSqlServerFixture>(fixture) +public class ManyToManyFieldsLoadSqlServerTest(ManyToManyFieldsLoadSqlServerTest.ManyToManyFieldsLoadSqlServerFixture fixture) + : ManyToManyFieldsLoadTestBase< + ManyToManyFieldsLoadSqlServerTest.ManyToManyFieldsLoadSqlServerFixture>(fixture) { public override async Task Load_collection(EntityState state, QueryTrackingBehavior queryTrackingBehavior, bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/ManyToManyLoadSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ManyToManyLoadSqlServerTest.cs index 7b9bb63a67a..2c840d57f36 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ManyToManyLoadSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ManyToManyLoadSqlServerTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class ManyToManyLoadSqlServerTest(ManyToManyLoadSqlServerTest.ManyToManyLoadSqlServerFixture fixture) : ManyToManyLoadTestBase(fixture) +public class ManyToManyLoadSqlServerTest(ManyToManyLoadSqlServerTest.ManyToManyLoadSqlServerFixture fixture) + : ManyToManyLoadTestBase(fixture) { public override async Task Load_collection(EntityState state, QueryTrackingBehavior queryTrackingBehavior, bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/ManyToManyTrackingGeneratedKeysSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ManyToManyTrackingGeneratedKeysSqlServerTest.cs index ec846eb50b8..b54c5563c4b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ManyToManyTrackingGeneratedKeysSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ManyToManyTrackingGeneratedKeysSqlServerTest.cs @@ -7,8 +7,10 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class ManyToManyTrackingGeneratedKeysSqlServerTest(ManyToManyTrackingGeneratedKeysSqlServerTest.ManyToManyTrackingGeneratedKeysSqlServerFixture fixture) - : ManyToManyTrackingSqlServerTestBase(fixture) +public class ManyToManyTrackingGeneratedKeysSqlServerTest( + ManyToManyTrackingGeneratedKeysSqlServerTest.ManyToManyTrackingGeneratedKeysSqlServerFixture fixture) + : ManyToManyTrackingSqlServerTestBase( + fixture) { public class ManyToManyTrackingGeneratedKeysSqlServerFixture : ManyToManyTrackingSqlServerFixtureBase { diff --git a/test/EFCore.SqlServer.FunctionalTests/Migrations/MigrationsInfrastructureSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Migrations/MigrationsInfrastructureSqlServerTest.cs index 0e7dc25e32a..8aeb88a4e31 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Migrations/MigrationsInfrastructureSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Migrations/MigrationsInfrastructureSqlServerTest.cs @@ -1,19 +1,20 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable disable + using Identity30.Data; using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore.Diagnostics.Internal; using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal; using Microsoft.EntityFrameworkCore.TestModels.AspNetIdentity; -#nullable disable - // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Migrations { [SqlServerCondition(SqlServerCondition.IsNotSqlAzure | SqlServerCondition.IsNotCI)] - public class MigrationsInfrastructureSqlServerTest(MigrationsInfrastructureSqlServerTest.MigrationsInfrastructureSqlServerFixture fixture) + public class MigrationsInfrastructureSqlServerTest( + MigrationsInfrastructureSqlServerTest.MigrationsInfrastructureSqlServerFixture fixture) : MigrationsInfrastructureTestBase(fixture) { public override void Can_apply_all_migrations() // Issue #32826 @@ -28,8 +29,9 @@ public override void Can_apply_range_of_migrations() var sql = @"CREATE DATABASE TransactionSuppressed; "; - Assert.Equal(RelationalResources.LogNonTransactionalMigrationOperationWarning(new TestLogger()) - .GenerateMessage(sql, "Migration3"), + Assert.Equal( + RelationalResources.LogNonTransactionalMigrationOperationWarning(new TestLogger()) + .GenerateMessage(sql, "Migration3"), Fixture.TestSqlLoggerFactory.Log.Single(l => l.Id == RelationalEventId.NonTransactionalMigrationOperationWarning).Message); } @@ -965,8 +967,8 @@ public async Task Empty_Migration_Creates_Database() { using var context = new BloggingContext( Fixture.TestStore.AddProviderOptions( - new DbContextOptionsBuilder().EnableServiceProviderCaching(false)) - .ConfigureWarnings(e => e.Log(RelationalEventId.PendingModelChangesWarning)).Options); + new DbContextOptionsBuilder().EnableServiceProviderCaching(false)) + .ConfigureWarnings(e => e.Log(RelationalEventId.PendingModelChangesWarning)).Options); context.Database.EnsureDeleted(); GiveMeSomeTime(context); @@ -1197,7 +1199,8 @@ private class BloggingMigration1 : Migration protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.Sql("--Before", suppressTransaction: true); - migrationBuilder.Sql(""" + migrationBuilder.Sql( + """ IF OBJECT_ID(N'Blogs', N'U') IS NULL BEGIN CREATE TABLE [Blogs] ( @@ -1221,9 +1224,7 @@ protected override void Down(MigrationBuilder migrationBuilder) private class BloggingMigration2 : Migration { protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql("--After"); - } + => migrationBuilder.Sql("--After"); protected override void Down(MigrationBuilder migrationBuilder) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Migrations/MigrationsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Migrations/MigrationsSqlServerTest.cs index ce8f413ffe9..65a90ea1f54 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Migrations/MigrationsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Migrations/MigrationsSqlServerTest.cs @@ -2865,12 +2865,13 @@ await Test( public virtual async Task Add_alternate_key_with_fill_factor() { await Test( - builder => { + builder => + { builder.Entity("People").Property("SomeField").IsRequired().HasMaxLength(450); builder.Entity("People").Property("SomeOtherField").IsRequired().HasMaxLength(450); - }, + }, builder => { }, - builder => builder.Entity("People").HasAlternateKey(["SomeField", "SomeOtherField"]).HasFillFactor(80), + builder => builder.Entity("People").HasAlternateKey("SomeField", "SomeOtherField").HasFillFactor(80), model => { var table = Assert.Single(model.Tables); @@ -7047,8 +7048,8 @@ await Test( """ ALTER TABLE [Customer] SET (SYSTEM_VERSIONING = OFF) """, - // - """ + // + """ DECLARE @var0 sysname; SELECT @var0 = [d].[name] FROM [sys].[default_constraints] [d] @@ -7059,8 +7060,8 @@ FROM [sys].[default_constraints] [d] ALTER TABLE [Customer] ALTER COLUMN [IsVip] bit NOT NULL; ALTER TABLE [Customer] ADD DEFAULT CAST(0 AS bit) FOR [IsVip]; """, - // - """ + // + """ DECLARE @var1 sysname; SELECT @var1 = [d].[name] FROM [sys].[default_constraints] [d] @@ -7071,8 +7072,8 @@ FROM [sys].[default_constraints] [d] ALTER TABLE [HistoryTable] ALTER COLUMN [IsVip] bit NOT NULL; ALTER TABLE [HistoryTable] ADD DEFAULT CAST(0 AS bit) FOR [IsVip]; """, - // - """ + // + """ DECLARE @historyTableSchema sysname = SCHEMA_NAME() EXEC(N'ALTER TABLE [Customer] SET (SYSTEM_VERSIONING = ON (HISTORY_TABLE = [' + @historyTableSchema + '].[HistoryTable]))') """); @@ -7185,16 +7186,16 @@ await Test( """ ALTER TABLE [Customer] SET (SYSTEM_VERSIONING = OFF) """, - // - """ + // + """ ALTER TABLE [Customer] ADD [IdPlusFive] AS Id + 5 PERSISTED; """, - // - """ + // + """ ALTER TABLE [HistoryTable] ADD [IdPlusFive] int NULL; """, - // - """ + // + """ DECLARE @historyTableSchema sysname = SCHEMA_NAME() EXEC(N'ALTER TABLE [Customer] SET (SYSTEM_VERSIONING = ON (HISTORY_TABLE = [' + @historyTableSchema + '].[HistoryTable]))') """); @@ -7249,16 +7250,16 @@ await Test( """ ALTER TABLE [Customer] SET (SYSTEM_VERSIONING = OFF) """, - // - """ + // + """ ALTER TABLE [Customer] ADD [Five] AS 5 PERSISTED; """, - // - """ + // + """ ALTER TABLE [HistoryTable] ADD [Five] int NOT NULL DEFAULT 0; """, - // - """ + // + """ DECLARE @historyTableSchema sysname = SCHEMA_NAME() EXEC(N'ALTER TABLE [Customer] SET (SYSTEM_VERSIONING = ON (HISTORY_TABLE = [' + @historyTableSchema + '].[HistoryTable]))') """); @@ -7312,8 +7313,8 @@ await Test( """ ALTER TABLE [Customer] SET (SYSTEM_VERSIONING = OFF) """, - // - """ + // + """ DECLARE @var0 sysname; SELECT @var0 = [d].[name] FROM [sys].[default_constraints] [d] @@ -7322,8 +7323,8 @@ FROM [sys].[default_constraints] [d] IF @var0 IS NOT NULL EXEC(N'ALTER TABLE [Customer] DROP CONSTRAINT [' + @var0 + '];'); ALTER TABLE [Customer] DROP COLUMN [IdPlusFive]; """, - // - """ + // + """ DECLARE @var1 sysname; SELECT @var1 = [d].[name] FROM [sys].[default_constraints] [d] @@ -7332,8 +7333,8 @@ FROM [sys].[default_constraints] [d] IF @var1 IS NOT NULL EXEC(N'ALTER TABLE [HistoryTable] DROP CONSTRAINT [' + @var1 + '];'); ALTER TABLE [HistoryTable] DROP COLUMN [IdPlusFive]; """, - // - """ + // + """ DECLARE @historyTableSchema sysname = SCHEMA_NAME() EXEC(N'ALTER TABLE [Customer] SET (SYSTEM_VERSIONING = ON (HISTORY_TABLE = [' + @historyTableSchema + '].[HistoryTable]))') """); @@ -7342,51 +7343,52 @@ FROM [sys].[default_constraints] [d] [ConditionalFact] public virtual async Task Alter_computed_column_sql_on_temporal_table() { - var message = (await Assert.ThrowsAsync(() => Test( - builder => builder.Entity( - "Customer", e => - { - e.Property("Id").ValueGeneratedOnAdd(); - e.Property("Start").ValueGeneratedOnAddOrUpdate(); - e.Property("End").ValueGeneratedOnAddOrUpdate(); - e.HasKey("Id"); - - e.ToTable( - tb => tb.IsTemporal( - ttb => - { - ttb.UseHistoryTable("HistoryTable"); - ttb.HasPeriodStart("Start"); - ttb.HasPeriodEnd("End"); - })); - }), - builder => builder.Entity( - "Customer", e => - { - e.Property("IdPlusFive").HasComputedColumnSql("Id + 5 PERSISTED"); - }), - builder => builder.Entity( - "Customer", e => - { - e.Property("IdPlusFive").HasComputedColumnSql("Id + 10 PERSISTED"); - }), - model => - { - var table = Assert.Single(model.Tables); - Assert.Equal("Customer", table.Name); - Assert.NotNull(table[SqlServerAnnotationNames.IsTemporal]); - Assert.Equal("HistoryTable", table[SqlServerAnnotationNames.TemporalHistoryTableName]); - Assert.Equal("Start", table[SqlServerAnnotationNames.TemporalPeriodStartPropertyName]); - Assert.Equal("End", table[SqlServerAnnotationNames.TemporalPeriodEndPropertyName]); + var message = (await Assert.ThrowsAsync( + () => Test( + builder => builder.Entity( + "Customer", e => + { + e.Property("Id").ValueGeneratedOnAdd(); + e.Property("Start").ValueGeneratedOnAddOrUpdate(); + e.Property("End").ValueGeneratedOnAddOrUpdate(); + e.HasKey("Id"); - Assert.Collection( - table.Columns, - c => Assert.Equal("Id", c.Name), - c => Assert.Equal("IdPlusFive", c.Name)); - Assert.Same( - table.Columns.Single(c => c.Name == "Id"), - Assert.Single(table.PrimaryKey!.Columns)); - }))).Message; + e.ToTable( + tb => tb.IsTemporal( + ttb => + { + ttb.UseHistoryTable("HistoryTable"); + ttb.HasPeriodStart("Start"); + ttb.HasPeriodEnd("End"); + })); + }), + builder => builder.Entity( + "Customer", e => + { + e.Property("IdPlusFive").HasComputedColumnSql("Id + 5 PERSISTED"); + }), + builder => builder.Entity( + "Customer", e => + { + e.Property("IdPlusFive").HasComputedColumnSql("Id + 10 PERSISTED"); + }), + model => + { + var table = Assert.Single(model.Tables); + Assert.Equal("Customer", table.Name); + Assert.NotNull(table[SqlServerAnnotationNames.IsTemporal]); + Assert.Equal("HistoryTable", table[SqlServerAnnotationNames.TemporalHistoryTableName]); + Assert.Equal("Start", table[SqlServerAnnotationNames.TemporalPeriodStartPropertyName]); + Assert.Equal("End", table[SqlServerAnnotationNames.TemporalPeriodEndPropertyName]); + + Assert.Collection( + table.Columns, + c => Assert.Equal("Id", c.Name), + c => Assert.Equal("IdPlusFive", c.Name)); + Assert.Same( + table.Columns.Single(c => c.Name == "Id"), + Assert.Single(table.PrimaryKey!.Columns)); + }))).Message; Assert.Equal( SqlServerStrings.TemporalMigrationModifyingComputedColumnNotSupported("IdPlusFive", "Customer"), @@ -7502,8 +7504,8 @@ await Test( """ ALTER TABLE [Customer] SET (SYSTEM_VERSIONING = OFF) """, - // - """ + // + """ DECLARE @var0 sysname; SELECT @var0 = [d].[name] FROM [sys].[default_constraints] [d] @@ -7512,8 +7514,8 @@ FROM [sys].[default_constraints] [d] IF @var0 IS NOT NULL EXEC(N'ALTER TABLE [Customer] DROP CONSTRAINT [' + @var0 + '];'); ALTER TABLE [Customer] DROP COLUMN [Number]; """, - // - """ + // + """ DECLARE @var1 sysname; SELECT @var1 = [d].[name] FROM [sys].[default_constraints] [d] @@ -7522,8 +7524,8 @@ FROM [sys].[default_constraints] [d] IF @var1 IS NOT NULL EXEC(N'ALTER TABLE [HistoryTable] DROP CONSTRAINT [' + @var1 + '];'); ALTER TABLE [HistoryTable] DROP COLUMN [Number]; """, - // - """ + // + """ DECLARE @historyTableSchema sysname = SCHEMA_NAME() EXEC(N'ALTER TABLE [Customer] SET (SYSTEM_VERSIONING = ON (HISTORY_TABLE = [' + @historyTableSchema + '].[HistoryTable]))') """); @@ -7635,21 +7637,21 @@ await Test( """ ALTER TABLE [Customer] SET (SYSTEM_VERSIONING = OFF) """, - // - """ + // + """ IF EXISTS (SELECT 1 FROM [sys].[tables] [t] INNER JOIN [sys].[partitions] [p] ON [t].[object_id] = [p].[object_id] WHERE [t].[name] = 'HistoryTable' AND data_compression <> 0) EXEC(N'ALTER TABLE [HistoryTable] REBUILD PARTITION = ALL WITH (DATA_COMPRESSION = NONE);'); """, - // - """ + // + """ ALTER TABLE [Customer] ADD [MyColumn] int SPARSE NULL; """, - // - """ + // + """ ALTER TABLE [HistoryTable] ADD [MyColumn] int SPARSE NULL; """, - // - """ + // + """ DECLARE @historyTableSchema sysname = SCHEMA_NAME() EXEC(N'ALTER TABLE [Customer] SET (SYSTEM_VERSIONING = ON (HISTORY_TABLE = [' + @historyTableSchema + '].[HistoryTable]))') """); @@ -7667,7 +7669,8 @@ await Test( e.Property("Start").ValueGeneratedOnAddOrUpdate(); e.Property("End").ValueGeneratedOnAddOrUpdate(); e.HasKey("Id"); - e.ToTable("Customers", "mySchema", + e.ToTable( + "Customers", "mySchema", tb => tb.IsTemporal( ttb => { @@ -7706,21 +7709,21 @@ await Test( """ ALTER TABLE [mySchema].[Customers] SET (SYSTEM_VERSIONING = OFF) """, - // - """ + // + """ IF EXISTS (SELECT 1 FROM [sys].[tables] [t] INNER JOIN [sys].[partitions] [p] ON [t].[object_id] = [p].[object_id] WHERE [t].[name] = 'HistoryTable' AND [t].[schema_id] = schema_id('myHistorySchema') AND data_compression <> 0) EXEC(N'ALTER TABLE [myHistorySchema].[HistoryTable] REBUILD PARTITION = ALL WITH (DATA_COMPRESSION = NONE);'); """, - // - """ + // + """ ALTER TABLE [mySchema].[Customers] ADD [MyColumn] int SPARSE NULL; """, - // - """ + // + """ ALTER TABLE [myHistorySchema].[HistoryTable] ADD [MyColumn] int SPARSE NULL; """, - // - """ + // + """ ALTER TABLE [mySchema].[Customers] SET (SYSTEM_VERSIONING = ON (HISTORY_TABLE = [myHistorySchema].[HistoryTable])) """); } @@ -7783,13 +7786,13 @@ await Test( """ ALTER TABLE [Customer] SET (SYSTEM_VERSIONING = OFF) """, - // - """ + // + """ IF EXISTS (SELECT 1 FROM [sys].[tables] [t] INNER JOIN [sys].[partitions] [p] ON [t].[object_id] = [p].[object_id] WHERE [t].[name] = 'HistoryTable' AND data_compression <> 0) EXEC(N'ALTER TABLE [HistoryTable] REBUILD PARTITION = ALL WITH (DATA_COMPRESSION = NONE);'); """, - // - """ + // + """ DECLARE @var0 sysname; SELECT @var0 = [d].[name] FROM [sys].[default_constraints] [d] @@ -7798,8 +7801,8 @@ FROM [sys].[default_constraints] [d] IF @var0 IS NOT NULL EXEC(N'ALTER TABLE [Customer] DROP CONSTRAINT [' + @var0 + '];'); ALTER TABLE [Customer] ALTER COLUMN [MyColumn] int SPARSE NULL; """, - // - """ + // + """ DECLARE @var1 sysname; SELECT @var1 = [d].[name] FROM [sys].[default_constraints] [d] @@ -7808,8 +7811,8 @@ FROM [sys].[default_constraints] [d] IF @var1 IS NOT NULL EXEC(N'ALTER TABLE [HistoryTable] DROP CONSTRAINT [' + @var1 + '];'); ALTER TABLE [HistoryTable] ALTER COLUMN [MyColumn] int SPARSE NULL; """, - // - """ + // + """ DECLARE @historyTableSchema sysname = SCHEMA_NAME() EXEC(N'ALTER TABLE [Customer] SET (SYSTEM_VERSIONING = ON (HISTORY_TABLE = [' + @historyTableSchema + '].[HistoryTable]))') """); @@ -7939,24 +7942,24 @@ await Test( """ ALTER TABLE [Customers] ADD [End] datetime2 NOT NULL DEFAULT '9999-12-31T23:59:59.9999999'; """, - // - """ + // + """ ALTER TABLE [Customers] ADD [Start] datetime2 NOT NULL DEFAULT '0001-01-01T00:00:00.0000000'; """, - // - """ + // + """ ALTER TABLE [Customers] ADD PERIOD FOR SYSTEM_TIME ([Start], [End]) """, - // - """ + // + """ ALTER TABLE [Customers] ALTER COLUMN [Start] ADD HIDDEN """, - // - """ + // + """ ALTER TABLE [Customers] ALTER COLUMN [End] ADD HIDDEN """, - // - """ + // + """ DECLARE @historyTableSchema sysname = SCHEMA_NAME() EXEC(N'ALTER TABLE [Customers] SET (SYSTEM_VERSIONING = ON (HISTORY_TABLE = [' + @historyTableSchema + '].[HistoryTable]))') """); @@ -9658,8 +9661,8 @@ await Test( """ EXEC sp_rename N'[Customers].[PeriodStart]', N'ValidFrom', 'COLUMN'; """, - // - """ + // + """ EXEC sp_rename N'[Customers].[PeriodEnd]', N'ValidTo', 'COLUMN'; """); } @@ -9717,28 +9720,28 @@ await Test( """ ALTER TABLE [Customers] ADD [End] datetime2 NOT NULL DEFAULT '9999-12-31T23:59:59.9999999'; """, - // - """ + // + """ ALTER TABLE [Customers] ADD [Number] int NOT NULL DEFAULT 0; """, - // - """ + // + """ ALTER TABLE [Customers] ADD [Start] datetime2 NOT NULL DEFAULT '0001-01-01T00:00:00.0000000'; """, - // - """ + // + """ ALTER TABLE [Customers] ADD PERIOD FOR SYSTEM_TIME ([Start], [End]) """, - // - """ + // + """ ALTER TABLE [Customers] ALTER COLUMN [Start] ADD HIDDEN """, - // - """ + // + """ ALTER TABLE [Customers] ALTER COLUMN [End] ADD HIDDEN """, - // - """ + // + """ DECLARE @historyTableSchema sysname = SCHEMA_NAME() EXEC(N'ALTER TABLE [Customers] SET (SYSTEM_VERSIONING = ON (HISTORY_TABLE = [' + @historyTableSchema + '].[HistoryTable]))') """); @@ -9802,28 +9805,28 @@ FROM [sys].[default_constraints] [d] IF @var0 IS NOT NULL EXEC(N'ALTER TABLE [Customers] DROP CONSTRAINT [' + @var0 + '];'); ALTER TABLE [Customers] DROP COLUMN [Number]; """, - // - """ + // + """ ALTER TABLE [Customers] ADD [End] datetime2 NOT NULL DEFAULT '9999-12-31T23:59:59.9999999'; """, - // - """ + // + """ ALTER TABLE [Customers] ADD [Start] datetime2 NOT NULL DEFAULT '0001-01-01T00:00:00.0000000'; """, - // - """ + // + """ ALTER TABLE [Customers] ADD PERIOD FOR SYSTEM_TIME ([Start], [End]) """, - // - """ + // + """ ALTER TABLE [Customers] ALTER COLUMN [Start] ADD HIDDEN """, - // - """ + // + """ ALTER TABLE [Customers] ALTER COLUMN [End] ADD HIDDEN """, - // - """ + // + """ DECLARE @historyTableSchema sysname = SCHEMA_NAME() EXEC(N'ALTER TABLE [Customers] SET (SYSTEM_VERSIONING = ON (HISTORY_TABLE = [' + @historyTableSchema + '].[HistoryTable]))') """); @@ -9883,28 +9886,28 @@ await Test( """ EXEC sp_rename N'[Customers].[Number]', N'NewNumber', 'COLUMN'; """, - // - """ + // + """ ALTER TABLE [Customers] ADD [End] datetime2 NOT NULL DEFAULT '9999-12-31T23:59:59.9999999'; """, - // - """ + // + """ ALTER TABLE [Customers] ADD [Start] datetime2 NOT NULL DEFAULT '0001-01-01T00:00:00.0000000'; """, - // - """ + // + """ ALTER TABLE [Customers] ADD PERIOD FOR SYSTEM_TIME ([Start], [End]) """, - // - """ + // + """ ALTER TABLE [Customers] ALTER COLUMN [Start] ADD HIDDEN """, - // - """ + // + """ ALTER TABLE [Customers] ALTER COLUMN [End] ADD HIDDEN """, - // - """ + // + """ DECLARE @historyTableSchema sysname = SCHEMA_NAME() EXEC(N'ALTER TABLE [Customers] SET (SYSTEM_VERSIONING = ON (HISTORY_TABLE = [' + @historyTableSchema + '].[HistoryTable]))') """); @@ -9924,13 +9927,12 @@ await Test( e.Property("Name"); e.ToTable( "Customers", tb => tb.IsTemporal( - ttb => - { - ttb.UseHistoryTable("HistoryTable"); - ttb.HasPeriodStart("Start"); - ttb.HasPeriodEnd("End"); - })); - + ttb => + { + ttb.UseHistoryTable("HistoryTable"); + ttb.HasPeriodStart("Start"); + ttb.HasPeriodEnd("End"); + })); }), builder => builder.Entity( "Customer", e => @@ -9960,12 +9962,12 @@ await Test( """ ALTER TABLE [Customers] SET (SYSTEM_VERSIONING = OFF) """, - // - """ + // + """ ALTER TABLE [Customers] DROP PERIOD FOR SYSTEM_TIME """, - // - """ + // + """ DECLARE @var0 sysname; SELECT @var0 = [d].[name] FROM [sys].[default_constraints] [d] @@ -9974,8 +9976,8 @@ FROM [sys].[default_constraints] [d] IF @var0 IS NOT NULL EXEC(N'ALTER TABLE [Customers] DROP CONSTRAINT [' + @var0 + '];'); ALTER TABLE [Customers] DROP COLUMN [End]; """, - // - """ + // + """ DECLARE @var1 sysname; SELECT @var1 = [d].[name] FROM [sys].[default_constraints] [d] @@ -9984,12 +9986,12 @@ FROM [sys].[default_constraints] [d] IF @var1 IS NOT NULL EXEC(N'ALTER TABLE [Customers] DROP CONSTRAINT [' + @var1 + '];'); ALTER TABLE [Customers] DROP COLUMN [Start]; """, - // - """ + // + """ DROP TABLE [HistoryTable]; """, - // - """ + // + """ ALTER TABLE [Customers] ADD [Number] int NOT NULL DEFAULT 0; """); } @@ -10042,12 +10044,12 @@ await Test( """ ALTER TABLE [Customers] SET (SYSTEM_VERSIONING = OFF) """, - // - """ + // + """ ALTER TABLE [Customers] DROP PERIOD FOR SYSTEM_TIME """, - // - """ + // + """ DECLARE @var0 sysname; SELECT @var0 = [d].[name] FROM [sys].[default_constraints] [d] @@ -10056,8 +10058,8 @@ FROM [sys].[default_constraints] [d] IF @var0 IS NOT NULL EXEC(N'ALTER TABLE [Customers] DROP CONSTRAINT [' + @var0 + '];'); ALTER TABLE [Customers] DROP COLUMN [End]; """, - // - """ + // + """ DECLARE @var1 sysname; SELECT @var1 = [d].[name] FROM [sys].[default_constraints] [d] @@ -10066,8 +10068,8 @@ FROM [sys].[default_constraints] [d] IF @var1 IS NOT NULL EXEC(N'ALTER TABLE [Customers] DROP CONSTRAINT [' + @var1 + '];'); ALTER TABLE [Customers] DROP COLUMN [Number]; """, - // - """ + // + """ DECLARE @var2 sysname; SELECT @var2 = [d].[name] FROM [sys].[default_constraints] [d] @@ -10076,8 +10078,8 @@ FROM [sys].[default_constraints] [d] IF @var2 IS NOT NULL EXEC(N'ALTER TABLE [HistoryTable] DROP CONSTRAINT [' + @var2 + '];'); ALTER TABLE [HistoryTable] DROP COLUMN [Number]; """, - // - """ + // + """ DECLARE @var3 sysname; SELECT @var3 = [d].[name] FROM [sys].[default_constraints] [d] @@ -10086,8 +10088,8 @@ FROM [sys].[default_constraints] [d] IF @var3 IS NOT NULL EXEC(N'ALTER TABLE [Customers] DROP CONSTRAINT [' + @var3 + '];'); ALTER TABLE [Customers] DROP COLUMN [Start]; """, - // - """ + // + """ DROP TABLE [HistoryTable]; """); } @@ -10142,12 +10144,12 @@ await Test( """ ALTER TABLE [Customers] SET (SYSTEM_VERSIONING = OFF) """, - // - """ + // + """ ALTER TABLE [Customers] DROP PERIOD FOR SYSTEM_TIME """, - // - """ + // + """ DECLARE @var0 sysname; SELECT @var0 = [d].[name] FROM [sys].[default_constraints] [d] @@ -10156,8 +10158,8 @@ FROM [sys].[default_constraints] [d] IF @var0 IS NOT NULL EXEC(N'ALTER TABLE [Customers] DROP CONSTRAINT [' + @var0 + '];'); ALTER TABLE [Customers] DROP COLUMN [End]; """, - // - """ + // + """ DECLARE @var1 sysname; SELECT @var1 = [d].[name] FROM [sys].[default_constraints] [d] @@ -10166,12 +10168,12 @@ FROM [sys].[default_constraints] [d] IF @var1 IS NOT NULL EXEC(N'ALTER TABLE [Customers] DROP CONSTRAINT [' + @var1 + '];'); ALTER TABLE [Customers] DROP COLUMN [Start]; """, - // - """ + // + """ EXEC sp_rename N'[Customers].[Number]', N'NewNumber', 'COLUMN'; """, - // - """ + // + """ DROP TABLE [HistoryTable]; """); } @@ -10710,19 +10712,18 @@ await Test( Assert.Same( historyTable.Columns.Single(c => c.Name == "Id"), Assert.Single(historyTable.PrimaryKey!.Columns)); - }); AssertSql( """ ALTER TABLE [Customers] SET (SYSTEM_VERSIONING = OFF) """, - // - """ + // + """ ALTER TABLE [Customers] DROP PERIOD FOR SYSTEM_TIME """, - // - """ + // + """ DECLARE @var0 sysname; SELECT @var0 = [d].[name] FROM [sys].[default_constraints] [d] @@ -10731,8 +10732,8 @@ FROM [sys].[default_constraints] [d] IF @var0 IS NOT NULL EXEC(N'ALTER TABLE [Customers] DROP CONSTRAINT [' + @var0 + '];'); ALTER TABLE [Customers] DROP COLUMN [End]; """, - // - """ + // + """ DECLARE @var1 sysname; SELECT @var1 = [d].[name] FROM [sys].[default_constraints] [d] @@ -10741,12 +10742,12 @@ FROM [sys].[default_constraints] [d] IF @var1 IS NOT NULL EXEC(N'ALTER TABLE [Customers] DROP CONSTRAINT [' + @var1 + '];'); ALTER TABLE [Customers] DROP COLUMN [Start]; """, - // - """ + // + """ DROP TABLE [HistoryTable]; """, - // - """ + // + """ CREATE TABLE [HistoryTable] ( [Id] int NOT NULL IDENTITY, [Name] nvarchar(max) NULL, @@ -10762,7 +10763,7 @@ public override async Task Add_required_primitive_collection_to_existing_table() await base.Add_required_primitive_collection_to_existing_table(); AssertSql( -""" + """ ALTER TABLE [Customers] ADD [Numbers] nvarchar(max) NOT NULL DEFAULT N'[]'; """); } @@ -10773,7 +10774,7 @@ public override async Task Add_required_primitive_collection_with_custom_default await base.Add_required_primitive_collection_with_custom_default_value_to_existing_table(); AssertSql( -""" + """ ALTER TABLE [Customers] ADD [Numbers] nvarchar(max) NOT NULL DEFAULT N'[1,2,3]'; """); } @@ -10784,7 +10785,7 @@ public override async Task Add_required_primitive_collection_with_custom_default await base.Add_required_primitive_collection_with_custom_default_value_sql_to_existing_table_core("N'[3, 2, 1]'"); AssertSql( -""" + """ ALTER TABLE [Customers] ADD [Numbers] nvarchar(max) NOT NULL DEFAULT (N'[3, 2, 1]'); """); } @@ -10795,7 +10796,7 @@ public override async Task Add_required_primitive_collection_with_custom_convert await base.Add_required_primitive_collection_with_custom_converter_to_existing_table(); AssertSql( -""" + """ ALTER TABLE [Customers] ADD [Numbers] nvarchar(max) NOT NULL DEFAULT N'nothing'; """); } @@ -10806,7 +10807,7 @@ public override async Task Add_required_primitive_collection_with_custom_convert await base.Add_required_primitive_collection_with_custom_converter_and_custom_default_value_to_existing_table(); AssertSql( -""" + """ ALTER TABLE [Customers] ADD [Numbers] nvarchar(max) NOT NULL DEFAULT N'some numbers'; """); } @@ -10817,7 +10818,7 @@ public override async Task Add_optional_primitive_collection_to_existing_table() await base.Add_optional_primitive_collection_to_existing_table(); AssertSql( -""" + """ ALTER TABLE [Customers] ADD [Numbers] nvarchar(max) NULL; """); } @@ -10828,7 +10829,7 @@ public override async Task Create_table_with_required_primitive_collection() await base.Create_table_with_required_primitive_collection(); AssertSql( -""" + """ CREATE TABLE [Customers] ( [Id] int NOT NULL IDENTITY, [Name] nvarchar(max) NULL, @@ -10844,7 +10845,7 @@ public override async Task Create_table_with_optional_primitive_collection() await base.Create_table_with_optional_primitive_collection(); AssertSql( -""" + """ CREATE TABLE [Customers] ( [Id] int NOT NULL IDENTITY, [Name] nvarchar(max) NULL, @@ -10860,7 +10861,7 @@ public override async Task Create_table_with_complex_type_with_required_properti await base.Create_table_with_complex_type_with_required_properties_on_derived_entity_in_TPH(); AssertSql( -""" + """ CREATE TABLE [Contacts] ( [Id] int NOT NULL IDENTITY, [Discriminator] nvarchar(8) NOT NULL, @@ -10880,7 +10881,7 @@ public override async Task Add_required_primitve_collection_to_existing_table() await base.Add_required_primitve_collection_to_existing_table(); AssertSql( -""" + """ ALTER TABLE [Customers] ADD [Numbers] nvarchar(max) NOT NULL DEFAULT N'[]'; """); } @@ -10891,7 +10892,7 @@ public override async Task Add_required_primitve_collection_with_custom_default_ await base.Add_required_primitve_collection_with_custom_default_value_to_existing_table(); AssertSql( -""" + """ ALTER TABLE [Customers] ADD [Numbers] nvarchar(max) NOT NULL DEFAULT N'[1,2,3]'; """); } @@ -10902,7 +10903,7 @@ public override async Task Add_required_primitve_collection_with_custom_default_ await base.Add_required_primitve_collection_with_custom_default_value_sql_to_existing_table_core("N'[3, 2, 1]'"); AssertSql( -""" + """ ALTER TABLE [Customers] ADD [Numbers] nvarchar(max) NOT NULL DEFAULT (N'[3, 2, 1]'); """); } @@ -10913,7 +10914,7 @@ public override async Task Add_required_primitve_collection_with_custom_converte await base.Add_required_primitve_collection_with_custom_converter_to_existing_table(); AssertSql( -""" + """ ALTER TABLE [Customers] ADD [Numbers] nvarchar(max) NOT NULL DEFAULT N'nothing'; """); } @@ -10924,7 +10925,7 @@ public override async Task Add_required_primitve_collection_with_custom_converte await base.Add_required_primitve_collection_with_custom_converter_and_custom_default_value_to_existing_table(); AssertSql( -""" + """ ALTER TABLE [Customers] ADD [Numbers] nvarchar(max) NOT NULL DEFAULT N'some numbers'; """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderGenericTest.cs b/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderGenericTest.cs index 1a15b80ea0c..daad9ed50d9 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderGenericTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderGenericTest.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // ReSharper disable InconsistentNaming + namespace Microsoft.EntityFrameworkCore.ModelBuilding; public class SqlServerModelBuilderGenericTest : SqlServerModelBuilderTestBase diff --git a/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderNonGenericTest.cs b/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderNonGenericTest.cs index 2dad5cd3892..02d2093ec15 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderNonGenericTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderNonGenericTest.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // ReSharper disable InconsistentNaming + namespace Microsoft.EntityFrameworkCore.ModelBuilding; public class SqlServerModelBuilderNonGenericTest : SqlServerModelBuilderTestBase diff --git a/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderTestBase.cs b/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderTestBase.cs index d71b777c2b9..5f76da6288e 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderTestBase.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ModelBuilding/SqlServerModelBuilderTestBase.cs @@ -8,7 +8,8 @@ namespace Microsoft.EntityFrameworkCore.ModelBuilding; public class SqlServerModelBuilderTestBase : RelationalModelBuilderTest { - public abstract class SqlServerNonRelationship(SqlServerModelBuilderFixture fixture) : RelationalNonRelationshipTestBase(fixture), IClassFixture + public abstract class SqlServerNonRelationship(SqlServerModelBuilderFixture fixture) + : RelationalNonRelationshipTestBase(fixture), IClassFixture { [ConditionalFact] public virtual void Index_has_a_filter_if_nonclustered_unique_with_nullable_properties() @@ -269,9 +270,10 @@ public virtual void Can_set_collation_for_primitive_collection() [InlineData(false)] public virtual void Can_avoid_attributes_when_discovering_properties(bool useAttributes) { - var modelBuilder = CreateModelBuilder(c => c.Conventions.Replace( - s => new PropertyDiscoveryConvention( - s.GetService()!, useAttributes))); + var modelBuilder = CreateModelBuilder( + c => c.Conventions.Replace( + s => new PropertyDiscoveryConvention( + s.GetService()!, useAttributes))); modelBuilder.Entity(); if (useAttributes) @@ -279,12 +281,14 @@ public virtual void Can_avoid_attributes_when_discovering_properties(bool useAtt var model = modelBuilder.FinalizeModel(); var entityType = model.FindEntityType(typeof(SqlVariantEntity))!; - Assert.Equal([nameof(SqlVariantEntity.Id), nameof(SqlVariantEntity.Value),], + Assert.Equal( + [nameof(SqlVariantEntity.Id), nameof(SqlVariantEntity.Value),], entityType.GetProperties().Select(p => p.Name)); } else { - Assert.Equal(CoreStrings.PropertyNotAdded(nameof(SqlVariantEntity), nameof(SqlVariantEntity.Value), "object"), + Assert.Equal( + CoreStrings.PropertyNotAdded(nameof(SqlVariantEntity), nameof(SqlVariantEntity.Value), "object"), Assert.Throws(modelBuilder.FinalizeModel).Message); } } @@ -292,14 +296,17 @@ public virtual void Can_avoid_attributes_when_discovering_properties(bool useAtt protected class SqlVariantEntity { public int Id { get; set; } + [Column(TypeName = "sql_variant")] public object? Value { get; set; } } } - public abstract class SqlServerComplexType(SqlServerModelBuilderFixture fixture) : RelationalComplexTypeTestBase(fixture), IClassFixture; + public abstract class SqlServerComplexType(SqlServerModelBuilderFixture fixture) + : RelationalComplexTypeTestBase(fixture), IClassFixture; - public abstract class SqlServerInheritance(SqlServerModelBuilderFixture fixture) : RelationalInheritanceTestBase(fixture), IClassFixture + public abstract class SqlServerInheritance(SqlServerModelBuilderFixture fixture) + : RelationalInheritanceTestBase(fixture), IClassFixture { [ConditionalFact] // #7240 public void Can_use_shadow_FK_that_collides_with_convention_shadow_FK_on_other_derived_type() @@ -642,7 +649,8 @@ protected class DisjointChildSubclass1 : Child; protected class DisjointChildSubclass2 : Child; } - public abstract class SqlServerOneToMany(SqlServerModelBuilderFixture fixture) : RelationalOneToManyTestBase(fixture), IClassFixture + public abstract class SqlServerOneToMany(SqlServerModelBuilderFixture fixture) + : RelationalOneToManyTestBase(fixture), IClassFixture { [ConditionalFact] public virtual void Shadow_foreign_keys_to_generic_types_have_terrible_names_that_should_not_change() @@ -695,11 +703,14 @@ protected class Company; protected class User; } - public abstract class SqlServerManyToOne(SqlServerModelBuilderFixture fixture) : RelationalManyToOneTestBase(fixture), IClassFixture; + public abstract class SqlServerManyToOne(SqlServerModelBuilderFixture fixture) + : RelationalManyToOneTestBase(fixture), IClassFixture; - public abstract class SqlServerOneToOne(SqlServerModelBuilderFixture fixture) : RelationalOneToOneTestBase(fixture), IClassFixture; + public abstract class SqlServerOneToOne(SqlServerModelBuilderFixture fixture) + : RelationalOneToOneTestBase(fixture), IClassFixture; - public abstract class SqlServerManyToMany(SqlServerModelBuilderFixture fixture) : RelationalManyToManyTestBase(fixture), IClassFixture + public abstract class SqlServerManyToMany(SqlServerModelBuilderFixture fixture) + : RelationalManyToManyTestBase(fixture), IClassFixture { [ConditionalFact] public virtual void Join_entity_type_uses_same_schema() @@ -758,7 +769,8 @@ public virtual void Join_entity_type_uses_default_schema_if_related_are_differen } } - public abstract class SqlServerOwnedTypes(SqlServerModelBuilderFixture fixture) : RelationalOwnedTypesTestBase(fixture), IClassFixture + public abstract class SqlServerOwnedTypes(SqlServerModelBuilderFixture fixture) + : RelationalOwnedTypesTestBase(fixture), IClassFixture { [ConditionalFact] public virtual void Owned_types_use_table_splitting_by_default() @@ -2095,7 +2107,8 @@ public virtual void Json_entity_with_nested_structure_same_property_names_() public class SqlServerModelBuilderFixture : RelationalModelBuilderFixture { - public override TestHelpers TestHelpers => SqlServerTestHelpers.Instance; + public override TestHelpers TestHelpers + => SqlServerTestHelpers.Instance; } public abstract class TestTemporalTableBuilder @@ -2106,8 +2119,9 @@ public abstract class TestTemporalTableBuilder public abstract TestTemporalPeriodPropertyBuilder HasPeriodEnd(string propertyName); } - public class GenericTestTemporalTableBuilder(TemporalTableBuilder temporalTableBuilder) : TestTemporalTableBuilder, - IInfrastructure> + public class GenericTestTemporalTableBuilder(TemporalTableBuilder temporalTableBuilder) + : TestTemporalTableBuilder, + IInfrastructure> where TEntity : class { private TemporalTableBuilder TemporalTableBuilder { get; } = temporalTableBuilder; @@ -2128,7 +2142,8 @@ public override TestTemporalPeriodPropertyBuilder HasPeriodEnd(string propertyNa => new(TemporalTableBuilder.HasPeriodEnd(propertyName)); } - public class NonGenericTestTemporalTableBuilder(TemporalTableBuilder temporalTableBuilder) : TestTemporalTableBuilder, IInfrastructure + public class NonGenericTestTemporalTableBuilder(TemporalTableBuilder temporalTableBuilder) + : TestTemporalTableBuilder, IInfrastructure where TEntity : class { private TemporalTableBuilder TemporalTableBuilder { get; } = temporalTableBuilder; @@ -2187,7 +2202,8 @@ public override TestOwnedNavigationTemporalPeriodPropertyBuilder HasPeriodEnd(st => new(TemporalTableBuilder.HasPeriodEnd(propertyName)); } - public class NonGenericTestOwnedNavigationTemporalTableBuilder(OwnedNavigationTemporalTableBuilder temporalTableBuilder) : + public class NonGenericTestOwnedNavigationTemporalTableBuilder( + OwnedNavigationTemporalTableBuilder temporalTableBuilder) : TestOwnedNavigationTemporalTableBuilder, IInfrastructure where TOwnerEntity : class @@ -2220,7 +2236,8 @@ public TestTemporalPeriodPropertyBuilder HasColumnName(string name) => new(TemporalPeriodPropertyBuilder.HasColumnName(name)); } - public class TestOwnedNavigationTemporalPeriodPropertyBuilder(OwnedNavigationTemporalPeriodPropertyBuilder temporalPeriodPropertyBuilder) + public class TestOwnedNavigationTemporalPeriodPropertyBuilder( + OwnedNavigationTemporalPeriodPropertyBuilder temporalPeriodPropertyBuilder) { protected OwnedNavigationTemporalPeriodPropertyBuilder TemporalPeriodPropertyBuilder { get; } = temporalPeriodPropertyBuilder; diff --git a/test/EFCore.SqlServer.FunctionalTests/MonsterFixupChangedChangingSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/MonsterFixupChangedChangingSqlServerTest.cs index 9b7f4b9158d..5a122723726 100644 --- a/test/EFCore.SqlServer.FunctionalTests/MonsterFixupChangedChangingSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/MonsterFixupChangedChangingSqlServerTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class MonsterFixupChangedChangingSqlServerTest(MonsterFixupChangedChangingSqlServerTest.MonsterFixupChangedChangingSqlServerFixture fixture) : +public class MonsterFixupChangedChangingSqlServerTest( + MonsterFixupChangedChangingSqlServerTest.MonsterFixupChangedChangingSqlServerFixture fixture) : MonsterFixupTestBase(fixture) { public class MonsterFixupChangedChangingSqlServerFixture : MonsterFixupChangedChangingFixtureBase diff --git a/test/EFCore.SqlServer.FunctionalTests/MusicStoreSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/MusicStoreSqlServerTest.cs index 4ce9c31380a..c5913da5417 100644 --- a/test/EFCore.SqlServer.FunctionalTests/MusicStoreSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/MusicStoreSqlServerTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class MusicStoreSqlServerTest(MusicStoreSqlServerTest.MusicStoreSqlServerFixture fixture) : MusicStoreTestBase(fixture) +public class MusicStoreSqlServerTest(MusicStoreSqlServerTest.MusicStoreSqlServerFixture fixture) + : MusicStoreTestBase(fixture) { public class MusicStoreSqlServerFixture : MusicStoreFixtureBase { diff --git a/test/EFCore.SqlServer.FunctionalTests/OptimisticConcurrencySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/OptimisticConcurrencySqlServerTest.cs index d0ec7df169d..dc032d134bf 100644 --- a/test/EFCore.SqlServer.FunctionalTests/OptimisticConcurrencySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/OptimisticConcurrencySqlServerTest.cs @@ -8,7 +8,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class OptimisticConcurrencyULongSqlServerTest(F1ULongSqlServerFixture fixture) : OptimisticConcurrencySqlServerTestBase(fixture) +public class OptimisticConcurrencyULongSqlServerTest(F1ULongSqlServerFixture fixture) + : OptimisticConcurrencySqlServerTestBase(fixture) { [ConditionalFact] public async Task ULong_row_version_can_handle_empty_array_from_the_database() @@ -67,7 +68,8 @@ public Task Ulong_row_version_with_TPC_and_table_splitting(bool updateDependentF => Row_version_with_table_splitting(updateDependentFirst, Mapping.Tpc, "ULongVersion"); } -public class OptimisticConcurrencySqlServerTest(F1SqlServerFixture fixture) : OptimisticConcurrencySqlServerTestBase(fixture) +public class OptimisticConcurrencySqlServerTest(F1SqlServerFixture fixture) + : OptimisticConcurrencySqlServerTestBase(fixture) { [ConditionalTheory] [InlineData(true)] diff --git a/test/EFCore.SqlServer.FunctionalTests/OverzealousInitializationSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/OverzealousInitializationSqlServerTest.cs index 4d4edc012c2..a224f14ec3b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/OverzealousInitializationSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/OverzealousInitializationSqlServerTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class OverzealousInitializationSqlServerTest(OverzealousInitializationSqlServerTest.OverzealousInitializationSqlServerFixture fixture) +public class OverzealousInitializationSqlServerTest( + OverzealousInitializationSqlServerTest.OverzealousInitializationSqlServerFixture fixture) : OverzealousInitializationTestBase(fixture) { public class OverzealousInitializationSqlServerFixture : OverzealousInitializationFixtureBase diff --git a/test/EFCore.SqlServer.FunctionalTests/PropertyValuesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/PropertyValuesSqlServerTest.cs index 32cd97b4ecf..0802d269a13 100644 --- a/test/EFCore.SqlServer.FunctionalTests/PropertyValuesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/PropertyValuesSqlServerTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class PropertyValuesSqlServerTest(PropertyValuesSqlServerTest.PropertyValuesSqlServerFixture fixture) : PropertyValuesTestBase(fixture) +public class PropertyValuesSqlServerTest(PropertyValuesSqlServerTest.PropertyValuesSqlServerFixture fixture) + : PropertyValuesTestBase(fixture) { public class PropertyValuesSqlServerFixture : PropertyValuesFixtureBase { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocAdvancedMappingsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocAdvancedMappingsQuerySqlServerTest.cs index cd5b5c20dcc..6f0bce9d4dd 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocAdvancedMappingsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocAdvancedMappingsQuerySqlServerTest.cs @@ -15,7 +15,7 @@ public override async Task Setting_IsUnicode_generates_unicode_literal_in_SQL() await base.Setting_IsUnicode_generates_unicode_literal_in_SQL(); AssertSql( -""" + """ SELECT [t].[Id], [t].[Nombre] FROM [TipoServicio] AS [t] WHERE [t].[Nombre] LIKE '%lla%' @@ -53,7 +53,7 @@ public override async Task Projection_failing_with_EnumToStringConverter() await base.Projection_failing_with_EnumToStringConverter(); AssertSql( -""" + """ SELECT [p].[Id], [p].[Name], CASE WHEN [c].[Id] IS NULL THEN N'Other' ELSE [c].[Name] @@ -71,26 +71,26 @@ public override async Task Expression_tree_constructed_via_interface_works() await base.Expression_tree_constructed_via_interface_works(); AssertSql( -""" + """ SELECT [r].[Id], [r].[IsRemoved], [r].[Removed], [r].[RemovedByUser], [r].[OwnedEntity_Exists], [r].[OwnedEntity_OwnedValue] FROM [RemovableEntities] AS [r] WHERE [r].[IsRemoved] = CAST(0 AS bit) """, - // - """ + // + """ SELECT [p].[Id], [p].[RemovableEntityId] FROM [Parents] AS [p] LEFT JOIN [RemovableEntities] AS [r] ON [p].[RemovableEntityId] = [r].[Id] WHERE [r].[IsRemoved] = CAST(1 AS bit) """, - // - """ + // + """ SELECT [r].[Id], [r].[IsRemoved], [r].[Removed], [r].[RemovedByUser], [r].[OwnedEntity_Exists], [r].[OwnedEntity_OwnedValue] FROM [RemovableEntities] AS [r] WHERE [r].[OwnedEntity_OwnedValue] = N'Abc' """, - // - """ + // + """ @__id_0='1' SELECT [p].[Id], [p].[RemovableEntityId] @@ -104,7 +104,7 @@ public override async Task Double_convert_interface_created_expression_tree() await base.Double_convert_interface_created_expression_tree(); AssertSql( -""" + """ @__action_0='1' SELECT COUNT(*) @@ -121,15 +121,15 @@ public override async Task Casts_are_removed_from_expression_tree_when_redundant await base.Casts_are_removed_from_expression_tree_when_redundant(); AssertSql( -""" + """ @__id_0='1' SELECT TOP(1) [m].[Id], [m].[Name], [m].[NavigationEntityId] FROM [MockEntities] AS [m] WHERE [m].[Id] = @__id_0 """, - // - """ + // + """ SELECT COUNT(*) FROM [MockEntities] AS [m] """); @@ -140,7 +140,7 @@ public override async Task Can_query_hierarchy_with_non_nullable_property_on_der await base.Can_query_hierarchy_with_non_nullable_property_on_derived(); AssertSql( -""" + """ SELECT [b].[Id], [b].[Name], [b].[Type], [b].[IsOnline] FROM [Businesses] AS [b] """); @@ -151,7 +151,7 @@ public override async Task Query_generates_correct_datetime2_parameter_definitio await base.Query_generates_correct_datetime2_parameter_definition(fractionalSeconds, postfix); AssertSql( -$""" + $""" @__parameter_0='2021-11-12T13:14:15.1234567'{postfix} SELECT TOP(1) [e].[DateTime] @@ -165,7 +165,7 @@ public override async Task Query_generates_correct_datetimeoffset_parameter_defi await base.Query_generates_correct_datetimeoffset_parameter_definition(fractionalSeconds, postfix); AssertSql( -$""" + $""" @__parameter_0='2021-11-12T13:14:15.1234567+10:00'{postfix} SELECT TOP(1) [e].[DateTimeOffset] @@ -179,7 +179,7 @@ public override async Task Query_generates_correct_timespan_parameter_definition await base.Query_generates_correct_timespan_parameter_definition(fractionalSeconds, postfix); AssertSql( -$""" + $""" @__parameter_0='12:34:56.7890123'{postfix} SELECT TOP(1) [e].[TimeSpan] @@ -241,13 +241,13 @@ public override async Task Two_similar_complex_properties_projected_with_split_q await base.Two_similar_complex_properties_projected_with_split_query1(); AssertSql( -""" + """ SELECT [o].[Id] FROM [Offers] AS [o] ORDER BY [o].[Id] """, - // - """ + // + """ SELECT [s].[Id], [s].[NestedId], [s].[OfferId], [s].[payment_brutto], [s].[payment_netto], [s].[Id0], [s].[payment_brutto0], [s].[payment_netto0], [o].[Id] FROM [Offers] AS [o] INNER JOIN ( @@ -264,14 +264,14 @@ public override async Task Two_similar_complex_properties_projected_with_split_q await base.Two_similar_complex_properties_projected_with_split_query2(); AssertSql( -""" + """ SELECT TOP(2) [o].[Id] FROM [Offers] AS [o] WHERE [o].[Id] = 1 ORDER BY [o].[Id] """, - // - """ + // + """ SELECT [s].[Id], [s].[NestedId], [s].[OfferId], [s].[payment_brutto], [s].[payment_netto], [s].[Id0], [s].[payment_brutto0], [s].[payment_netto0], [o0].[Id] FROM ( SELECT TOP(1) [o].[Id] @@ -292,7 +292,7 @@ public override async Task Projecting_one_of_two_similar_complex_types_picks_the await base.Projecting_one_of_two_similar_complex_types_picks_the_correct_one(); AssertSql( -""" + """ @__p_0='10' SELECT [a].[Id], [s].[Info_Created0] AS [Created] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocJsonQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocJsonQuerySqlServerTest.cs index 02bdd29574b..a9da97566d4 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocJsonQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocJsonQuerySqlServerTest.cs @@ -3,8 +3,6 @@ namespace Microsoft.EntityFrameworkCore.Query; -#nullable disable - public class AdHocJsonQuerySqlServerTest : AdHocJsonQuerySqlServerTestBase { } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocJsonQuerySqlServerTestBase.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocJsonQuerySqlServerTestBase.cs index 97c07f97af5..ee179b3d6f4 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocJsonQuerySqlServerTestBase.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocJsonQuerySqlServerTestBase.cs @@ -28,9 +28,9 @@ protected override async Task Seed29219(DbContext ctx) Reference = new MyJsonEntity29219 { NonNullableScalar = 10, NullableScalar = 11 }, Collection = [ - new() { NonNullableScalar = 100, NullableScalar = 101 }, - new() { NonNullableScalar = 200, NullableScalar = 201 }, - new() { NonNullableScalar = 300, NullableScalar = null } + new MyJsonEntity29219 { NonNullableScalar = 100, NullableScalar = 101 }, + new MyJsonEntity29219 { NonNullableScalar = 200, NullableScalar = 201 }, + new MyJsonEntity29219 { NonNullableScalar = 300, NullableScalar = null } ] }; @@ -38,7 +38,7 @@ protected override async Task Seed29219(DbContext ctx) { Id = 2, Reference = new MyJsonEntity29219 { NonNullableScalar = 20, NullableScalar = null }, - Collection = [new() { NonNullableScalar = 1001, NullableScalar = null }] + Collection = [new MyJsonEntity29219 { NonNullableScalar = 1001, NullableScalar = null }] }; ctx.AddRange(entity1, entity2); @@ -114,8 +114,8 @@ protected override Task SeedArrayOfPrimitives(DbContext ctx) }, Collection = [ - new() { IntArray = [111, 112, 113], ListOfString = ["Foo11", "Bar11"] }, - new() { IntArray = [211, 212, 213], ListOfString = ["Foo12", "Bar12"] } + new MyJsonEntityArrayOfPrimitives { IntArray = [111, 112, 113], ListOfString = ["Foo11", "Bar11"] }, + new MyJsonEntityArrayOfPrimitives { IntArray = [211, 212, 213], ListOfString = ["Foo12", "Bar12"] } ] }; @@ -134,8 +134,8 @@ protected override Task SeedArrayOfPrimitives(DbContext ctx) }, Collection = [ - new() { IntArray = [110, 120, 130], ListOfString = ["A1", "Z1"] }, - new() { IntArray = [210, 220, 230], ListOfString = ["A2", "Z2"] } + new MyJsonEntityArrayOfPrimitives { IntArray = [110, 120, 130], ListOfString = ["A1", "Z1"] }, + new MyJsonEntityArrayOfPrimitives { IntArray = [210, 220, 230], ListOfString = ["A2", "Z2"] } ] }; @@ -350,12 +350,16 @@ private class MyJsonEntityEnumLegacyValues // ReSharper disable once UnusedAutoPropertyAccessor.Local public IntEnumLegacyValues IntEnum { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public ByteEnumLegacyValues ByteEnum { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public LongEnumLegacyValues LongEnum { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public ULongEnumLegacyValues ULongEnum { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public IntEnumLegacyValues? NullableEnum { get; set; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocMiscellaneousQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocMiscellaneousQuerySqlServerTest.cs index b37228e5028..bebe075c633 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocMiscellaneousQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocMiscellaneousQuerySqlServerTest.cs @@ -100,7 +100,8 @@ await Parallel.ForAsync( }); } - private class Context5456(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context5456(DbContextOptions options) : DbContext(options) { public DbSet Blogs { get; set; } public DbSet Posts { get; set; } @@ -112,7 +113,7 @@ public Task SeedAsync() for (var i = 0; i < 100; i++) { Add( - new Blog { Posts = [new() { Comments = [new(), new()] }, new()], Author = new Author() }); + new Blog { Posts = [new Post { Comments = [new Comment(), new Comment()] }, new Post()], Author = new Author() }); } return SaveChangesAsync(); @@ -191,7 +192,8 @@ FROM [Customers] AS [c] """); } - private class Context8864(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context8864(DbContextOptions options) : DbContext(options) { public DbSet Customers { get; set; } @@ -295,7 +297,6 @@ RETURNS int END """); - await Database.ExecuteSqlRawAsync( """ CREATE FUNCTION dbo.AddTwo (@num int) @@ -427,7 +428,8 @@ WHEN NOT MATCHED THEN } } - private class Context12482(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context12482(DbContextOptions options) : DbContext(options) { public virtual DbSet BaseEntities { get; set; } @@ -550,7 +552,8 @@ FROM OPENJSON(@__testDateList_0) WITH ([value] smalldatetime '$') AS [t] """); } - private class Context13118(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context13118(DbContextOptions options) : DbContext(options) { public virtual DbSet ReproEntity { get; set; } @@ -567,7 +570,7 @@ public Task SeedAsync() } } - private class ReproEntity13118 + protected class ReproEntity13118 { public Guid Id { get; set; } public DateTime MyTime { get; set; } @@ -907,7 +910,8 @@ ORDER BY [r].[Id] """); } - private class Context15518(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context15518(DbContextOptions options) : DbContext(options) { public DbSet Repos { get; set; } @@ -966,7 +970,8 @@ CROSS JOIN ( } } - private class Context19206(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context19206(DbContextOptions options) : DbContext(options) { public DbSet Tests { get; set; } @@ -1018,7 +1023,8 @@ public virtual async Task Thread_safety_in_relational_command_cache() }); } - private class Context21666(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context21666(DbContextOptions options) : DbContext(options) { public DbSet Lists { get; set; } @@ -1059,7 +1065,8 @@ FROM [Locations] AS [l] """); } - private class Context23282(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context23282(DbContextOptions options) : DbContext(options) { public DbSet Locations { get; set; } @@ -1166,14 +1173,14 @@ ORDER BY [m0].[Id] """); } - private class Gender24216 + protected class Gender24216 { public long Id { get; set; } public string Description { get; set; } } - private class Message24216 + protected class Message24216 { public long Id { get; set; } @@ -1182,7 +1189,7 @@ private class Message24216 public DateTime Timestamp { get; set; } } - private class PersonStatus24216 + protected class PersonStatus24216 { public long Id { get; set; } @@ -1193,10 +1200,10 @@ private class PersonStatus24216 public string StatusMessage { get; set; } } - private class Context24216(DbContextOptions options) : DbContext(options) + // Protected so that it can be used by inheriting tests, and so that things like unused setters are not removed. + protected class Context24216(DbContextOptions options) : DbContext(options) { public DbSet Gender { get; set; } - public DbSet Message { get; set; } public IQueryable GetPersonStatusAsOf(long personId, DateTime asOf) @@ -1411,7 +1418,6 @@ public async Task SeedAsync() new Json30478 { Name = "c21", Nested = new JsonNested30478 { Number = 21 } }, new Json30478 { Name = "c22", Nested = new JsonNested30478 { Number = 22 } } - ] }; @@ -1421,7 +1427,6 @@ public async Task SeedAsync() RemoveRange(e1, e2); await SaveChangesAsync(); - await Database.ExecuteSqlRawAsync("ALTER TABLE [Entities] SET (SYSTEM_VERSIONING = OFF)"); await Database.ExecuteSqlRawAsync("ALTER TABLE [Entities] DROP PERIOD FOR SYSTEM_TIME"); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocNavigationsQuerySqlServerTest.cs index b265e957cf7..268bedeab25 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocNavigationsQuerySqlServerTest.cs @@ -82,13 +82,13 @@ public Task SeedAsync() { Posts = [ - new(), - new(), - new() + new Post(), + new Post(), + new Post() ] }, - new Blog { Posts = [new(), new()] }, - new Blog { Posts = [new()] }); + new Blog { Posts = [new Post(), new Post()] }, + new Blog { Posts = [new Post()] }); return SaveChangesAsync(); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocPrecompiledQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocPrecompiledQuerySqlServerTest.cs index bafbc35c492..2063c4bcd97 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AdHocPrecompiledQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/AdHocPrecompiledQuerySqlServerTest.cs @@ -14,7 +14,8 @@ public override async Task Index_no_evaluatability() { await base.Index_no_evaluatability(); - AssertSql(""" + AssertSql( + """ SELECT [j].[Id], [j].[IntList], [j].[JsonThing] FROM [JsonEntities] AS [j] WHERE CAST(JSON_VALUE([j].[IntList], '$[' + CAST([j].[Id] AS nvarchar(max)) + ']') AS int) = 2 @@ -26,7 +27,8 @@ public override async Task Index_with_captured_variable() { await base.Index_with_captured_variable(); - AssertSql(""" + AssertSql( + """ @__id_0='1' SELECT [j].[Id], [j].[IntList], [j].[JsonThing] @@ -39,7 +41,8 @@ public override async Task JsonScalar() { await base.JsonScalar(); - AssertSql(""" + AssertSql( + """ SELECT [j].[Id], [j].[IntList], [j].[JsonThing] FROM [JsonEntities] AS [j] WHERE JSON_VALUE([j].[JsonThing], '$.StringProperty') = N'foo' diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs index a1ecbbafe29..1d20f4b4a60 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs @@ -35,7 +35,7 @@ where l1.Id < 3 select l3).Distinct().Skip(1).OrderBy(e => e.Id).FirstOrDefault().Name); AssertSql( -""" + """ SELECT ( SELECT TOP(1) [l2].[Name] FROM ( @@ -58,14 +58,14 @@ WHERE [l].[Id] < 3 public virtual async Task Distinct_take_without_orderby(bool async) { await AssertQuery( - async, - ss => from l1 in ss.Set() - where l1.Id < 3 - select (from l3 in ss.Set() - select l3).Distinct().Take(1).OrderBy(e => e.Id).FirstOrDefault().Name); + async, + ss => from l1 in ss.Set() + where l1.Id < 3 + select (from l3 in ss.Set() + select l3).Distinct().Take(1).OrderBy(e => e.Id).FirstOrDefault().Name); AssertSql( -""" + """ SELECT ( SELECT TOP(1) [l1].[Name] FROM ( @@ -4760,7 +4760,7 @@ public override async Task Multiple_optional_navs_should_not_deadlock(bool async await base.Multiple_optional_navs_should_not_deadlock(async); AssertSql( -""" + """ SELECT COUNT(*) FROM [LevelTwo] AS [l] LEFT JOIN [LevelOne] AS [l0] ON [l].[OneToMany_Optional_Inverse2Id] = [l0].[Id] @@ -4774,7 +4774,7 @@ public override async Task Null_check_removal_applied_recursively_complex(bool a await base.Null_check_removal_applied_recursively_complex(async); AssertSql( -""" + """ SELECT [l].[Id], [l].[Level2_Optional_Id], [l].[Level2_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse3Id], [l].[OneToMany_Optional_Self_Inverse3Id], [l].[OneToMany_Required_Inverse3Id], [l].[OneToMany_Required_Self_Inverse3Id], [l].[OneToOne_Optional_PK_Inverse3Id], [l].[OneToOne_Optional_Self3Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Date], [l1].[Name], [l1].[OneToMany_Optional_Self_Inverse1Id], [l1].[OneToMany_Required_Self_Inverse1Id], [l1].[OneToOne_Optional_Self1Id], [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] FROM [LevelThree] AS [l] INNER JOIN [LevelTwo] AS [l0] ON [l].[OneToMany_Required_Inverse3Id] = [l0].[Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServer160Test.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServer160Test.cs index a9fa36d942e..ce59551f86f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServer160Test.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServer160Test.cs @@ -1018,7 +1018,7 @@ WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] """); } - [ConditionalTheory()] + [ConditionalTheory] public override async Task GroupBy_aggregate_where_required_relationship_2(bool async) { await base.GroupBy_aggregate_where_required_relationship_2(async); @@ -1169,7 +1169,7 @@ WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] """); } - [ConditionalTheory()] + [ConditionalTheory] public override async Task GroupBy_aggregate_where_required_relationship(bool async) { await base.GroupBy_aggregate_where_required_relationship(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs index 2fbb10dca51..dfd4f46b829 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs @@ -36,7 +36,7 @@ where l1.Id < 3 select l3).Distinct().Skip(1).OrderBy(e => e.Id).FirstOrDefault().Name); AssertSql( -""" + """ SELECT ( SELECT TOP(1) [s0].[Level3_Name] FROM ( @@ -78,14 +78,14 @@ WHERE [l].[Id] < 3 public virtual async Task Distinct_take_without_orderby(bool async) { await AssertQuery( - async, - ss => from l1 in ss.Set() - where l1.Id < 3 - select (from l3 in ss.Set() - select l3).Distinct().Take(1).OrderBy(e => e.Id).FirstOrDefault().Name); + async, + ss => from l1 in ss.Set() + where l1.Id < 3 + select (from l3 in ss.Set() + select l3).Distinct().Take(1).OrderBy(e => e.Id).FirstOrDefault().Name); AssertSql( -""" + """ SELECT ( SELECT TOP(1) [s].[Level3_Name] FROM ( @@ -1020,7 +1020,7 @@ WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] """); } - [ConditionalTheory()] + [ConditionalTheory] public override async Task GroupBy_aggregate_where_required_relationship_2(bool async) { await base.GroupBy_aggregate_where_required_relationship_2(async); @@ -1171,7 +1171,7 @@ WHERE [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] """); } - [ConditionalTheory()] + [ConditionalTheory] public override async Task GroupBy_aggregate_where_required_relationship(bool async) { await base.GroupBy_aggregate_where_required_relationship(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexTypeQuerySqlServerTest.cs index b62c0570bf0..c3aca53a5b9 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexTypeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexTypeQuerySqlServerTest.cs @@ -481,7 +481,8 @@ WHERE [v0].[ShippingAddress_ZipCode] <> 7728 // purpose of knowing that it's there. public override async Task Project_struct_complex_type_via_optional_navigation(bool async) { - var exception = await Assert.ThrowsAsync(() => base.Project_struct_complex_type_via_optional_navigation(async)); + var exception = + await Assert.ThrowsAsync(() => base.Project_struct_complex_type_via_optional_navigation(async)); Assert.Equal(RelationalStrings.CannotProjectNullableComplexType("ValuedCustomer.ShippingAddress#AddressStruct"), exception.Message); } @@ -866,7 +867,7 @@ public override async Task Project_same_entity_with_nested_complex_type_twice_wi await base.Project_same_entity_with_nested_complex_type_twice_with_pushdown(async); AssertSql( -""" + """ SELECT [s].[Id], [s].[Name], [s].[BillingAddress_AddressLine1], [s].[BillingAddress_AddressLine2], [s].[BillingAddress_Tags], [s].[BillingAddress_ZipCode], [s].[BillingAddress_Country_Code], [s].[BillingAddress_Country_FullName], [s].[ShippingAddress_AddressLine1], [s].[ShippingAddress_AddressLine2], [s].[ShippingAddress_Tags], [s].[ShippingAddress_ZipCode], [s].[ShippingAddress_Country_Code], [s].[ShippingAddress_Country_FullName], [s].[Id0], [s].[Name0], [s].[BillingAddress_AddressLine10], [s].[BillingAddress_AddressLine20], [s].[BillingAddress_Tags0], [s].[BillingAddress_ZipCode0], [s].[BillingAddress_Country_Code0], [s].[BillingAddress_Country_FullName0], [s].[ShippingAddress_AddressLine10], [s].[ShippingAddress_AddressLine20], [s].[ShippingAddress_Tags0], [s].[ShippingAddress_ZipCode0], [s].[ShippingAddress_Country_Code0], [s].[ShippingAddress_Country_FullName0] FROM ( SELECT DISTINCT [c].[Id], [c].[Name], [c].[BillingAddress_AddressLine1], [c].[BillingAddress_AddressLine2], [c].[BillingAddress_Tags], [c].[BillingAddress_ZipCode], [c].[BillingAddress_Country_Code], [c].[BillingAddress_Country_FullName], [c].[ShippingAddress_AddressLine1], [c].[ShippingAddress_AddressLine2], [c].[ShippingAddress_Tags], [c].[ShippingAddress_ZipCode], [c].[ShippingAddress_Country_Code], [c].[ShippingAddress_Country_FullName], [c0].[Id] AS [Id0], [c0].[Name] AS [Name0], [c0].[BillingAddress_AddressLine1] AS [BillingAddress_AddressLine10], [c0].[BillingAddress_AddressLine2] AS [BillingAddress_AddressLine20], [c0].[BillingAddress_Tags] AS [BillingAddress_Tags0], [c0].[BillingAddress_ZipCode] AS [BillingAddress_ZipCode0], [c0].[BillingAddress_Country_Code] AS [BillingAddress_Country_Code0], [c0].[BillingAddress_Country_FullName] AS [BillingAddress_Country_FullName0], [c0].[ShippingAddress_AddressLine1] AS [ShippingAddress_AddressLine10], [c0].[ShippingAddress_AddressLine2] AS [ShippingAddress_AddressLine20], [c0].[ShippingAddress_Tags] AS [ShippingAddress_Tags0], [c0].[ShippingAddress_ZipCode] AS [ShippingAddress_ZipCode0], [c0].[ShippingAddress_Country_Code] AS [ShippingAddress_Country_Code0], [c0].[ShippingAddress_Country_FullName] AS [ShippingAddress_Country_FullName0] @@ -881,7 +882,7 @@ public override async Task Project_same_nested_complex_type_twice_with_pushdown( await base.Project_same_nested_complex_type_twice_with_pushdown(async); AssertSql( -""" + """ SELECT [s].[BillingAddress_AddressLine1], [s].[BillingAddress_AddressLine2], [s].[BillingAddress_Tags], [s].[BillingAddress_ZipCode], [s].[BillingAddress_Country_Code], [s].[BillingAddress_Country_FullName], [s].[BillingAddress_AddressLine10], [s].[BillingAddress_AddressLine20], [s].[BillingAddress_Tags0], [s].[BillingAddress_ZipCode0], [s].[BillingAddress_Country_Code0], [s].[BillingAddress_Country_FullName0] FROM ( SELECT DISTINCT [c].[BillingAddress_AddressLine1], [c].[BillingAddress_AddressLine2], [c].[BillingAddress_Tags], [c].[BillingAddress_ZipCode], [c].[BillingAddress_Country_Code], [c].[BillingAddress_Country_FullName], [c0].[BillingAddress_AddressLine1] AS [BillingAddress_AddressLine10], [c0].[BillingAddress_AddressLine2] AS [BillingAddress_AddressLine20], [c0].[BillingAddress_Tags] AS [BillingAddress_Tags0], [c0].[BillingAddress_ZipCode] AS [BillingAddress_ZipCode0], [c0].[BillingAddress_Country_Code] AS [BillingAddress_Country_Code0], [c0].[BillingAddress_Country_FullName] AS [BillingAddress_Country_FullName0] @@ -896,7 +897,7 @@ public override async Task Project_same_entity_with_nested_complex_type_twice_wi await base.Project_same_entity_with_nested_complex_type_twice_with_double_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT [s0].[Id], [s0].[Name], [s0].[BillingAddress_AddressLine1], [s0].[BillingAddress_AddressLine2], [s0].[BillingAddress_Tags], [s0].[BillingAddress_ZipCode], [s0].[BillingAddress_Country_Code], [s0].[BillingAddress_Country_FullName], [s0].[ShippingAddress_AddressLine1], [s0].[ShippingAddress_AddressLine2], [s0].[ShippingAddress_Tags], [s0].[ShippingAddress_ZipCode], [s0].[ShippingAddress_Country_Code], [s0].[ShippingAddress_Country_FullName], [s0].[Id0], [s0].[Name0], [s0].[BillingAddress_AddressLine10], [s0].[BillingAddress_AddressLine20], [s0].[BillingAddress_Tags0], [s0].[BillingAddress_ZipCode0], [s0].[BillingAddress_Country_Code0], [s0].[BillingAddress_Country_FullName0], [s0].[ShippingAddress_AddressLine10], [s0].[ShippingAddress_AddressLine20], [s0].[ShippingAddress_Tags0], [s0].[ShippingAddress_ZipCode0], [s0].[ShippingAddress_Country_Code0], [s0].[ShippingAddress_Country_FullName0] @@ -917,7 +918,7 @@ public override async Task Project_same_nested_complex_type_twice_with_double_pu await base.Project_same_nested_complex_type_twice_with_double_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT [s0].[BillingAddress_AddressLine1], [s0].[BillingAddress_AddressLine2], [s0].[BillingAddress_Tags], [s0].[BillingAddress_ZipCode], [s0].[BillingAddress_Country_Code], [s0].[BillingAddress_Country_FullName], [s0].[BillingAddress_AddressLine10], [s0].[BillingAddress_AddressLine20], [s0].[BillingAddress_Tags0], [s0].[BillingAddress_ZipCode0], [s0].[BillingAddress_Country_Code0], [s0].[BillingAddress_Country_FullName0] @@ -938,7 +939,7 @@ public override async Task Project_same_entity_with_struct_nested_complex_type_t await base.Project_same_entity_with_struct_nested_complex_type_twice_with_pushdown(async); AssertSql( -""" + """ SELECT [s].[Id], [s].[Name], [s].[BillingAddress_AddressLine1], [s].[BillingAddress_AddressLine2], [s].[BillingAddress_ZipCode], [s].[BillingAddress_Country_Code], [s].[BillingAddress_Country_FullName], [s].[ShippingAddress_AddressLine1], [s].[ShippingAddress_AddressLine2], [s].[ShippingAddress_ZipCode], [s].[ShippingAddress_Country_Code], [s].[ShippingAddress_Country_FullName], [s].[Id0], [s].[Name0], [s].[BillingAddress_AddressLine10], [s].[BillingAddress_AddressLine20], [s].[BillingAddress_ZipCode0], [s].[BillingAddress_Country_Code0], [s].[BillingAddress_Country_FullName0], [s].[ShippingAddress_AddressLine10], [s].[ShippingAddress_AddressLine20], [s].[ShippingAddress_ZipCode0], [s].[ShippingAddress_Country_Code0], [s].[ShippingAddress_Country_FullName0] FROM ( SELECT DISTINCT [v].[Id], [v].[Name], [v].[BillingAddress_AddressLine1], [v].[BillingAddress_AddressLine2], [v].[BillingAddress_ZipCode], [v].[BillingAddress_Country_Code], [v].[BillingAddress_Country_FullName], [v].[ShippingAddress_AddressLine1], [v].[ShippingAddress_AddressLine2], [v].[ShippingAddress_ZipCode], [v].[ShippingAddress_Country_Code], [v].[ShippingAddress_Country_FullName], [v0].[Id] AS [Id0], [v0].[Name] AS [Name0], [v0].[BillingAddress_AddressLine1] AS [BillingAddress_AddressLine10], [v0].[BillingAddress_AddressLine2] AS [BillingAddress_AddressLine20], [v0].[BillingAddress_ZipCode] AS [BillingAddress_ZipCode0], [v0].[BillingAddress_Country_Code] AS [BillingAddress_Country_Code0], [v0].[BillingAddress_Country_FullName] AS [BillingAddress_Country_FullName0], [v0].[ShippingAddress_AddressLine1] AS [ShippingAddress_AddressLine10], [v0].[ShippingAddress_AddressLine2] AS [ShippingAddress_AddressLine20], [v0].[ShippingAddress_ZipCode] AS [ShippingAddress_ZipCode0], [v0].[ShippingAddress_Country_Code] AS [ShippingAddress_Country_Code0], [v0].[ShippingAddress_Country_FullName] AS [ShippingAddress_Country_FullName0] @@ -953,7 +954,7 @@ public override async Task Project_same_struct_nested_complex_type_twice_with_pu await base.Project_same_struct_nested_complex_type_twice_with_pushdown(async); AssertSql( -""" + """ SELECT [s].[BillingAddress_AddressLine1], [s].[BillingAddress_AddressLine2], [s].[BillingAddress_ZipCode], [s].[BillingAddress_Country_Code], [s].[BillingAddress_Country_FullName], [s].[BillingAddress_AddressLine10], [s].[BillingAddress_AddressLine20], [s].[BillingAddress_ZipCode0], [s].[BillingAddress_Country_Code0], [s].[BillingAddress_Country_FullName0] FROM ( SELECT DISTINCT [v].[BillingAddress_AddressLine1], [v].[BillingAddress_AddressLine2], [v].[BillingAddress_ZipCode], [v].[BillingAddress_Country_Code], [v].[BillingAddress_Country_FullName], [v0].[BillingAddress_AddressLine1] AS [BillingAddress_AddressLine10], [v0].[BillingAddress_AddressLine2] AS [BillingAddress_AddressLine20], [v0].[BillingAddress_ZipCode] AS [BillingAddress_ZipCode0], [v0].[BillingAddress_Country_Code] AS [BillingAddress_Country_Code0], [v0].[BillingAddress_Country_FullName] AS [BillingAddress_Country_FullName0] @@ -968,7 +969,7 @@ public override async Task Project_same_entity_with_struct_nested_complex_type_t await base.Project_same_entity_with_struct_nested_complex_type_twice_with_double_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT [s0].[Id], [s0].[Name], [s0].[BillingAddress_AddressLine1], [s0].[BillingAddress_AddressLine2], [s0].[BillingAddress_ZipCode], [s0].[BillingAddress_Country_Code], [s0].[BillingAddress_Country_FullName], [s0].[ShippingAddress_AddressLine1], [s0].[ShippingAddress_AddressLine2], [s0].[ShippingAddress_ZipCode], [s0].[ShippingAddress_Country_Code], [s0].[ShippingAddress_Country_FullName], [s0].[Id0], [s0].[Name0], [s0].[BillingAddress_AddressLine10], [s0].[BillingAddress_AddressLine20], [s0].[BillingAddress_ZipCode0], [s0].[BillingAddress_Country_Code0], [s0].[BillingAddress_Country_FullName0], [s0].[ShippingAddress_AddressLine10], [s0].[ShippingAddress_AddressLine20], [s0].[ShippingAddress_ZipCode0], [s0].[ShippingAddress_Country_Code0], [s0].[ShippingAddress_Country_FullName0] @@ -989,7 +990,7 @@ public override async Task Project_same_struct_nested_complex_type_twice_with_do await base.Project_same_struct_nested_complex_type_twice_with_double_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT [s0].[BillingAddress_AddressLine1], [s0].[BillingAddress_AddressLine2], [s0].[BillingAddress_ZipCode], [s0].[BillingAddress_Country_Code], [s0].[BillingAddress_Country_FullName], [s0].[BillingAddress_AddressLine10], [s0].[BillingAddress_AddressLine20], [s0].[BillingAddress_ZipCode0], [s0].[BillingAddress_Country_Code0], [s0].[BillingAddress_Country_FullName0] @@ -1010,7 +1011,7 @@ public override async Task Union_of_same_entity_with_nested_complex_type_project await base.Union_of_same_entity_with_nested_complex_type_projected_twice_with_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT TOP(@__p_0) [u].[Id], [u].[Name], [u].[BillingAddress_AddressLine1], [u].[BillingAddress_AddressLine2], [u].[BillingAddress_Tags], [u].[BillingAddress_ZipCode], [u].[BillingAddress_Country_Code], [u].[BillingAddress_Country_FullName], [u].[ShippingAddress_AddressLine1], [u].[ShippingAddress_AddressLine2], [u].[ShippingAddress_Tags], [u].[ShippingAddress_ZipCode], [u].[ShippingAddress_Country_Code], [u].[ShippingAddress_Country_FullName], [u].[Id0], [u].[Name0], [u].[BillingAddress_AddressLine10], [u].[BillingAddress_AddressLine20], [u].[BillingAddress_Tags0], [u].[BillingAddress_ZipCode0], [u].[BillingAddress_Country_Code0], [u].[BillingAddress_Country_FullName0], [u].[ShippingAddress_AddressLine10], [u].[ShippingAddress_AddressLine20], [u].[ShippingAddress_Tags0], [u].[ShippingAddress_ZipCode0], [u].[ShippingAddress_Country_Code0], [u].[ShippingAddress_Country_FullName0] @@ -1032,7 +1033,7 @@ public override async Task Union_of_same_entity_with_nested_complex_type_project await base.Union_of_same_entity_with_nested_complex_type_projected_twice_with_double_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT TOP(@__p_0) [u1].[Id], [u1].[Name], [u1].[BillingAddress_AddressLine1], [u1].[BillingAddress_AddressLine2], [u1].[BillingAddress_Tags], [u1].[BillingAddress_ZipCode], [u1].[BillingAddress_Country_Code], [u1].[BillingAddress_Country_FullName], [u1].[ShippingAddress_AddressLine1], [u1].[ShippingAddress_AddressLine2], [u1].[ShippingAddress_Tags], [u1].[ShippingAddress_ZipCode], [u1].[ShippingAddress_Country_Code], [u1].[ShippingAddress_Country_FullName], [u1].[Id0], [u1].[Name0], [u1].[BillingAddress_AddressLine10], [u1].[BillingAddress_AddressLine20], [u1].[BillingAddress_Tags0], [u1].[BillingAddress_ZipCode0], [u1].[BillingAddress_Country_Code0], [u1].[BillingAddress_Country_FullName0], [u1].[ShippingAddress_AddressLine10], [u1].[ShippingAddress_AddressLine20], [u1].[ShippingAddress_Tags0], [u1].[ShippingAddress_ZipCode0], [u1].[ShippingAddress_Country_Code0], [u1].[ShippingAddress_Country_FullName0] @@ -1061,7 +1062,7 @@ public override async Task Union_of_same_nested_complex_type_projected_twice_wit await base.Union_of_same_nested_complex_type_projected_twice_with_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT TOP(@__p_0) [u].[BillingAddress_AddressLine1], [u].[BillingAddress_AddressLine2], [u].[BillingAddress_Tags], [u].[BillingAddress_ZipCode], [u].[BillingAddress_Country_Code], [u].[BillingAddress_Country_FullName], [u].[BillingAddress_AddressLine10], [u].[BillingAddress_AddressLine20], [u].[BillingAddress_Tags0], [u].[BillingAddress_ZipCode0], [u].[BillingAddress_Country_Code0], [u].[BillingAddress_Country_FullName0] @@ -1083,7 +1084,7 @@ public override async Task Union_of_same_nested_complex_type_projected_twice_wit await base.Union_of_same_nested_complex_type_projected_twice_with_double_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT TOP(@__p_0) [u1].[BillingAddress_AddressLine1], [u1].[BillingAddress_AddressLine2], [u1].[BillingAddress_Tags], [u1].[BillingAddress_ZipCode], [u1].[BillingAddress_Country_Code], [u1].[BillingAddress_Country_FullName], [u1].[BillingAddress_AddressLine10], [u1].[BillingAddress_AddressLine20], [u1].[BillingAddress_Tags0], [u1].[BillingAddress_ZipCode0], [u1].[BillingAddress_Country_Code0], [u1].[BillingAddress_Country_FullName0] @@ -1112,7 +1113,7 @@ public override async Task Same_entity_with_complex_type_projected_twice_with_pu await base.Same_entity_with_complex_type_projected_twice_with_pushdown_as_part_of_another_projection(async); AssertSql( -""" + """ SELECT [c].[Id], [s].[Id], [s].[Name], [s].[BillingAddress_AddressLine1], [s].[BillingAddress_AddressLine2], [s].[BillingAddress_Tags], [s].[BillingAddress_ZipCode], [s].[BillingAddress_Country_Code], [s].[BillingAddress_Country_FullName], [s].[ShippingAddress_AddressLine1], [s].[ShippingAddress_AddressLine2], [s].[ShippingAddress_Tags], [s].[ShippingAddress_ZipCode], [s].[ShippingAddress_Country_Code], [s].[ShippingAddress_Country_FullName], [s].[Id0], [s].[Name0], [s].[BillingAddress_AddressLine10], [s].[BillingAddress_AddressLine20], [s].[BillingAddress_Tags0], [s].[BillingAddress_ZipCode0], [s].[BillingAddress_Country_Code0], [s].[BillingAddress_Country_FullName0], [s].[ShippingAddress_AddressLine10], [s].[ShippingAddress_AddressLine20], [s].[ShippingAddress_Tags0], [s].[ShippingAddress_ZipCode0], [s].[ShippingAddress_Country_Code0], [s].[ShippingAddress_Country_FullName0], [s].[c] FROM [Customer] AS [c] OUTER APPLY ( @@ -1199,7 +1200,7 @@ public override async Task Projecting_property_of_complex_type_using_left_join_w await base.Projecting_property_of_complex_type_using_left_join_with_pushdown(async); AssertSql( -""" + """ SELECT [c1].[BillingAddress_ZipCode] FROM [CustomerGroup] AS [c] LEFT JOIN ( @@ -1215,7 +1216,7 @@ public override async Task Projecting_complex_from_optional_navigation_using_con await base.Projecting_complex_from_optional_navigation_using_conditional(async); AssertSql( -""" + """ @__p_0='20' SELECT [s0].[ShippingAddress_ZipCode] @@ -1236,7 +1237,7 @@ public override async Task Project_entity_with_complex_type_pushdown_and_then_le await base.Project_entity_with_complex_type_pushdown_and_then_left_join(async); AssertSql( -""" + """ @__p_0='20' @__p_1='30' diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs index 2736d073256..fe7d1a30e22 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs @@ -12,9 +12,7 @@ public class FromSqlQuerySqlServerTest : FromSqlQueryTestBase Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); public override async Task FromSqlRaw_queryable_simple(bool async) { @@ -70,7 +68,9 @@ public override async Task FromSqlRaw_queryable_composed_after_removing_whitespa FROM ( -""" + " " + """ +""" + + " " + + """ @@ -1002,9 +1002,10 @@ public virtual void FromSql_output_parameter_works_with_transient_errors() }; var orders = context.Set() - .FromSqlRaw(@"SET @returnValue = 3 -SELECT * FROM [Customers] WHERE [CustomerID] = 'ALFKI'", [output]) - .ToList(); + .FromSqlRaw( + @"SET @returnValue = 3 +SELECT * FROM [Customers] WHERE [CustomerID] = 'ALFKI'", output) + .ToList(); Assert.Equal(1, orders.Count); Assert.Equal(3, output.Value); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlSprocQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlSprocQuerySqlServerTest.cs index 563e83e40d8..5720d8d818f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlSprocQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlSprocQuerySqlServerTest.cs @@ -9,9 +9,7 @@ public class FromSqlSprocQuerySqlServerTest : FromSqlSprocQueryTestBase fixture) : base(fixture) - { - fixture.TestSqlLoggerFactory.Clear(); - } + => fixture.TestSqlLoggerFactory.Clear(); public override async Task From_sql_queryable_stored_procedure(bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs index 45af4624f1e..b7e8da920f1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs @@ -172,44 +172,44 @@ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] WHERE [f].[FirstName] LIKE N'\%B%' ESCAPE N'\' """, - // - """ + // + """ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] WHERE [f].[FirstName] LIKE N'\_B%' ESCAPE N'\' """, - // - """ + // + """ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] WHERE 0 = 1 """, - // - """ + // + """ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] WHERE [f].[FirstName] IS NOT NULL """, - // - """ + // + """ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] WHERE [f].[FirstName] LIKE N'\_Ba\_%' ESCAPE N'\' """, - // - """ + // + """ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] WHERE [f].[FirstName] NOT LIKE N'\%B\%a\%r%' ESCAPE N'\' OR [f].[FirstName] IS NULL """, - // - """ + // + """ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] WHERE [f].[FirstName] IS NULL """, - // - """ + // + """ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] """); @@ -370,44 +370,44 @@ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] WHERE [f].[FirstName] LIKE N'%\%r' ESCAPE N'\' """, - // - """ + // + """ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] WHERE [f].[FirstName] LIKE N'%r\_' ESCAPE N'\' """, - // - """ + // + """ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] WHERE 0 = 1 """, - // - """ + // + """ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] WHERE [f].[FirstName] IS NOT NULL """, - // - """ + // + """ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] WHERE [f].[FirstName] LIKE N'%\_r\_' ESCAPE N'\' """, - // - """ + // + """ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] WHERE [f].[FirstName] NOT LIKE N'%a\%r\%' ESCAPE N'\' OR [f].[FirstName] IS NULL """, - // - """ + // + """ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] WHERE [f].[FirstName] IS NULL """, - // - """ + // + """ SELECT [f].[FirstName] FROM [FunkyCustomers] AS [f] """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarFromSqlQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarFromSqlQuerySqlServerTest.cs index afa6ad9b26e..76303866868 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarFromSqlQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarFromSqlQuerySqlServerTest.cs @@ -9,9 +9,7 @@ public class GearsOfWarFromSqlQuerySqlServerTest : GearsOfWarFromSqlQueryTestBas { public GearsOfWarFromSqlQuerySqlServerTest(GearsOfWarQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) - { - fixture.TestSqlLoggerFactory.Clear(); - } + => fixture.TestSqlLoggerFactory.Clear(); public override void From_sql_queryable_simple_columns_out_of_order() { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index ee1bf84c519..14db73c59cb 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -4040,7 +4040,7 @@ public override async Task ToString_nullable_enum_property_projection(bool async await base.ToString_nullable_enum_property_projection(async); AssertSql( -""" + """ SELECT CASE [w].[AmmunitionType] WHEN 1 THEN N'Cartridge' WHEN 2 THEN N'Shell' @@ -4067,7 +4067,7 @@ public override async Task ToString_nullable_enum_contains(bool async) await base.ToString_nullable_enum_contains(async); AssertSql( -""" + """ SELECT [w].[Name] FROM [Weapons] AS [w] WHERE CASE [w].[AmmunitionType] @@ -9254,7 +9254,7 @@ public override async Task Where_TimeOnly_FromDateTime_compared_to_property(bool await base.Where_TimeOnly_FromDateTime_compared_to_property(async); AssertSql( -""" + """ SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] FROM [Tags] AS [t] CROSS JOIN [Missions] AS [m] @@ -9267,7 +9267,7 @@ public override async Task Where_TimeOnly_FromDateTime_compared_to_parameter(boo await base.Where_TimeOnly_FromDateTime_compared_to_parameter(async); AssertSql( -""" + """ @__time_0='02:00' (DbType = Time) SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] @@ -9282,7 +9282,7 @@ public override async Task Where_TimeOnly_FromDateTime_compared_to_constant(bool await base.Where_TimeOnly_FromDateTime_compared_to_constant(async); AssertSql( -""" + """ SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] WHERE CAST(DATEADD(hour, CAST(CAST(CAST(LEN([t].[Note]) AS int) AS float) AS int), [t].[IssueDate]) AS time) > '09:00:00' @@ -9294,7 +9294,7 @@ public override async Task Where_TimeOnly_FromTimeSpan_compared_to_property(bool await base.Where_TimeOnly_FromTimeSpan_compared_to_property(async); AssertSql( -""" + """ SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE CAST([m].[Duration] AS time) < [m].[Time] @@ -9306,7 +9306,7 @@ public override async Task Where_TimeOnly_FromTimeSpan_compared_to_parameter(boo await base.Where_TimeOnly_FromTimeSpan_compared_to_parameter(async); AssertSql( -""" + """ @__time_0='01:02' (DbType = Time) SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] @@ -9320,7 +9320,7 @@ public override async Task Order_by_TimeOnly_FromTimeSpan(bool async) await base.Order_by_TimeOnly_FromTimeSpan(async); AssertSql( -""" + """ SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] ORDER BY CAST([m].[Duration] AS time) @@ -9332,7 +9332,7 @@ public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool await base.Where_DateOnly_FromDateTime_compared_to_property(async); AssertSql( -""" + """ SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] FROM [Tags] AS [t] CROSS JOIN [Missions] AS [m] @@ -9345,7 +9345,7 @@ public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_ await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); AssertSql( -""" + """ @__prm_0='10/11/0002' (DbType = Date) SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeOneToOneSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/IncludeOneToOneSqlServerTest.cs index 5306ebbf7e2..8bad9f3ed48 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeOneToOneSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/IncludeOneToOneSqlServerTest.cs @@ -9,9 +9,7 @@ public class IncludeOneToOneSqlServerTest : IncludeOneToOneTestBase fixture.TestSqlLoggerFactory.Clear(); public override void Include_person() { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs index e33e06fcbae..a59684c3a3d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs @@ -13,9 +13,7 @@ public InheritanceRelationshipsQuerySqlServerTest( InheritanceRelationshipsQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) - { - fixture.TestSqlLoggerFactory.Clear(); - } + => fixture.TestSqlLoggerFactory.Clear(); [ConditionalFact] public virtual void Check_all_tests_overridden() diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/JsonQueryJsonTypeSqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/JsonQueryJsonTypeSqlServerFixture.cs index e59e6565b88..81642e9c14f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/JsonQueryJsonTypeSqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/JsonQueryJsonTypeSqlServerFixture.cs @@ -25,7 +25,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con modelBuilder.Entity( b => { - b.OwnsOne(x => x.OwnedReferenceRoot).ToJson("json_reference_custom_naming").HasColumnType("json");; + b.OwnsOne(x => x.OwnedReferenceRoot).ToJson("json_reference_custom_naming").HasColumnType("json"); + ; b.OwnsMany(x => x.OwnedCollectionRoot).HasColumnType("json").ToJson("json_collection_custom_naming"); }); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/JsonQueryJsonTypeSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/JsonQueryJsonTypeSqlServerTest.cs index 95f302374ec..600aaa36c4d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/JsonQueryJsonTypeSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/JsonQueryJsonTypeSqlServerTest.cs @@ -448,7 +448,8 @@ public override async Task Json_subquery_reference_pushdown_reference_pushdown_r // TODO:SQLJSON Json type is not comparable Assert.StartsWith( "The json data type cannot be selected as DISTINCT because it is not comparable.", - (await Assert.ThrowsAsync(() => base.Json_subquery_reference_pushdown_reference_pushdown_reference(async))).Message); + (await Assert.ThrowsAsync(() => base.Json_subquery_reference_pushdown_reference_pushdown_reference(async))) + .Message); AssertSql( """ @@ -478,7 +479,8 @@ public override async Task Json_subquery_reference_pushdown_reference_pushdown_c // TODO:SQLJSON Json type is not comparable Assert.StartsWith( "The json data type cannot be selected as DISTINCT because it is not comparable.", - (await Assert.ThrowsAsync(() => base.Json_subquery_reference_pushdown_reference_pushdown_collection(async))).Message); + (await Assert.ThrowsAsync(() => base.Json_subquery_reference_pushdown_reference_pushdown_collection(async))) + .Message); AssertSql( """ @@ -3071,7 +3073,6 @@ ORDER BY [m].[Id] """); } - public override async Task Json_projection_nothing_interesting_AsNoTrackingWithIdentityResolution(bool async) { await base.Json_projection_nothing_interesting_AsNoTrackingWithIdentityResolution(async); @@ -3094,7 +3095,8 @@ FROM [JsonEntitiesBasic] AS [j] """); } - public override async Task Json_nested_collection_anonymous_projection_of_primitives_in_projection_NoTrackingWithIdentityResolution(bool async) + public override async Task Json_nested_collection_anonymous_projection_of_primitives_in_projection_NoTrackingWithIdentityResolution( + bool async) { await base.Json_nested_collection_anonymous_projection_of_primitives_in_projection_NoTrackingWithIdentityResolution(async); @@ -3111,9 +3113,13 @@ OUTER APPLY OPENJSON(CAST(JSON_QUERY([o].[value], '$.OwnedCollectionBranch') AS """); } - public override async Task Json_projection_second_element_through_collection_element_constant_projected_after_owner_nested_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_second_element_through_collection_element_constant_projected_after_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) { - await base.Json_projection_second_element_through_collection_element_constant_projected_after_owner_nested_AsNoTrackingWithIdentityResolution(async); + await base + .Json_projection_second_element_through_collection_element_constant_projected_after_owner_nested_AsNoTrackingWithIdentityResolution( + async); AssertSql( """ @@ -3122,7 +3128,8 @@ FROM [JsonEntitiesBasic] AS [j] """); } - public override async Task Json_projection_reference_collection_and_collection_element_nested_AsNoTrackingWithIdentityResolution(bool async) + public override async Task Json_projection_reference_collection_and_collection_element_nested_AsNoTrackingWithIdentityResolution( + bool async) { await base.Json_projection_reference_collection_and_collection_element_nested_AsNoTrackingWithIdentityResolution(async); @@ -3134,9 +3141,13 @@ FROM [JsonEntitiesBasic] AS [j] } [SqlServerCondition(SqlServerCondition.SupportsJsonPathExpressions)] - public override async Task Json_projection_second_element_through_collection_element_parameter_correctly_projected_after_owner_nested_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_second_element_through_collection_element_parameter_correctly_projected_after_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) { - await base.Json_projection_second_element_through_collection_element_parameter_correctly_projected_after_owner_nested_AsNoTrackingWithIdentityResolution(async); + await base + .Json_projection_second_element_through_collection_element_parameter_correctly_projected_after_owner_nested_AsNoTrackingWithIdentityResolution( + async); AssertSql( """ @@ -3147,9 +3158,13 @@ FROM [JsonEntitiesBasic] AS [j] """); } - public override async Task Json_projection_only_second_element_through_collection_element_constant_projected_nested_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_only_second_element_through_collection_element_constant_projected_nested_AsNoTrackingWithIdentityResolution( + bool async) { - await base.Json_projection_only_second_element_through_collection_element_constant_projected_nested_AsNoTrackingWithIdentityResolution(async); + await base + .Json_projection_only_second_element_through_collection_element_constant_projected_nested_AsNoTrackingWithIdentityResolution( + async); AssertSql( """ @@ -3159,9 +3174,13 @@ FROM [JsonEntitiesBasic] AS [j] } [SqlServerCondition(SqlServerCondition.SupportsJsonPathExpressions)] - public override async Task Json_projection_only_second_element_through_collection_element_parameter_projected_nested_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_only_second_element_through_collection_element_parameter_projected_nested_AsNoTrackingWithIdentityResolution( + bool async) { - await base.Json_projection_only_second_element_through_collection_element_parameter_projected_nested_AsNoTrackingWithIdentityResolution(async); + await base + .Json_projection_only_second_element_through_collection_element_parameter_projected_nested_AsNoTrackingWithIdentityResolution( + async); AssertSql( """ @@ -3173,9 +3192,13 @@ FROM [JsonEntitiesBasic] AS [j] """); } - public override async Task Json_projection_second_element_through_collection_element_constant_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_second_element_through_collection_element_constant_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) { - await base.Json_projection_second_element_through_collection_element_constant_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution(async); + await base + .Json_projection_second_element_through_collection_element_constant_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution( + async); AssertSql( """ @@ -3196,9 +3219,13 @@ FROM [JsonEntitiesBasic] AS [j] } [SqlServerCondition(SqlServerCondition.SupportsJsonPathExpressions)] - public override async Task Json_projection_nested_collection_element_using_parameter_and_the_owner_in_correct_order_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_nested_collection_element_using_parameter_and_the_owner_in_correct_order_AsNoTrackingWithIdentityResolution( + bool async) { - await base.Json_projection_nested_collection_element_using_parameter_and_the_owner_in_correct_order_AsNoTrackingWithIdentityResolution(async); + await base + .Json_projection_nested_collection_element_using_parameter_and_the_owner_in_correct_order_AsNoTrackingWithIdentityResolution( + async); AssertSql( """ @@ -3209,7 +3236,8 @@ FROM [JsonEntitiesBasic] AS [j] """); } - public override async Task Json_projection_second_element_projected_before_owner_as_well_as_root_AsNoTrackingWithIdentityResolution(bool async) + public override async Task Json_projection_second_element_projected_before_owner_as_well_as_root_AsNoTrackingWithIdentityResolution( + bool async) { await base.Json_projection_second_element_projected_before_owner_as_well_as_root_AsNoTrackingWithIdentityResolution(async); @@ -3220,7 +3248,8 @@ FROM [JsonEntitiesBasic] AS [j] """); } - public override async Task Json_projection_second_element_projected_before_owner_nested_as_well_as_root_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_second_element_projected_before_owner_nested_as_well_as_root_AsNoTrackingWithIdentityResolution(bool async) { await base.Json_projection_second_element_projected_before_owner_nested_as_well_as_root_AsNoTrackingWithIdentityResolution(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/JsonQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/JsonQuerySqlServerTest.cs index 3ff397d292d..dc0cf62266c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/JsonQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/JsonQuerySqlServerTest.cs @@ -530,7 +530,7 @@ public override async Task Custom_naming_projection_owned_reference(bool async) await base.Custom_naming_projection_owned_reference(async); AssertSql( -""" + """ SELECT JSON_QUERY([j].[json_reference_custom_naming], '$."Custom#OwnedReferenceBranch\u0060-=[]\\;\u0027,./~!@#$%^\u0026*()_\u002B{}|:\u0022\u003C\u003E?\u72EC\u89D2\u517D\u03C0\u7368\u89D2\u7378"'), [j].[Id] FROM [JsonEntitiesCustomNaming] AS [j] """); @@ -553,7 +553,7 @@ public override async Task Custom_naming_projection_owned_scalar(bool async) await base.Custom_naming_projection_owned_scalar(async); AssertSql( -""" + """ SELECT CAST(JSON_VALUE([j].[json_reference_custom_naming], '$."Custom#OwnedReferenceBranch\u0060-=[]\\;\u0027,./~!@#$%^\u0026*()_\u002B{}|:\u0022\u003C\u003E?\u72EC\u89D2\u517D\u03C0\u7368\u89D2\u7378"."\u30E6\u30CB\u30B3\u30FC\u30F3Fraction\u4E00\u89D2\u7363"') AS float) FROM [JsonEntitiesCustomNaming] AS [j] """); @@ -564,7 +564,7 @@ public override async Task Custom_naming_projection_everything(bool async) await base.Custom_naming_projection_everything(async); AssertSql( -""" + """ SELECT [j].[Id], [j].[Title], [j].[json_collection_custom_naming], [j].[json_reference_custom_naming], [j].[json_reference_custom_naming], JSON_QUERY([j].[json_reference_custom_naming], '$."Custom#OwnedReferenceBranch\u0060-=[]\\;\u0027,./~!@#$%^\u0026*()_\u002B{}|:\u0022\u003C\u003E?\u72EC\u89D2\u517D\u03C0\u7368\u89D2\u7378"'), [j].[json_collection_custom_naming], JSON_QUERY([j].[json_reference_custom_naming], '$.CustomOwnedCollectionBranch'), JSON_VALUE([j].[json_reference_custom_naming], '$.CustomName'), CAST(JSON_VALUE([j].[json_reference_custom_naming], '$."Custom#OwnedReferenceBranch\u0060-=[]\\;\u0027,./~!@#$%^\u0026*()_\u002B{}|:\u0022\u003C\u003E?\u72EC\u89D2\u517D\u03C0\u7368\u89D2\u7378"."\u30E6\u30CB\u30B3\u30FC\u30F3Fraction\u4E00\u89D2\u7363"') AS float) FROM [JsonEntitiesCustomNaming] AS [j] """); @@ -2966,13 +2966,12 @@ ORDER BY [m].[Id] """); } - public override async Task Json_projection_nothing_interesting_AsNoTrackingWithIdentityResolution(bool async) { await base.Json_projection_nothing_interesting_AsNoTrackingWithIdentityResolution(async); AssertSql( -""" + """ SELECT [j].[Id], [j].[Name] FROM [JsonEntitiesBasic] AS [j] """); @@ -2983,18 +2982,19 @@ public override async Task Json_projection_owner_entity_AsNoTrackingWithIdentity await base.Json_projection_owner_entity_AsNoTrackingWithIdentityResolution(async); AssertSql( -""" + """ SELECT [j].[Id], [j].[EntityBasicId], [j].[Name], [j].[OwnedCollectionRoot], [j].[OwnedReferenceRoot] FROM [JsonEntitiesBasic] AS [j] """); } - public override async Task Json_nested_collection_anonymous_projection_of_primitives_in_projection_NoTrackingWithIdentityResolution(bool async) + public override async Task Json_nested_collection_anonymous_projection_of_primitives_in_projection_NoTrackingWithIdentityResolution( + bool async) { await base.Json_nested_collection_anonymous_projection_of_primitives_in_projection_NoTrackingWithIdentityResolution(async); AssertSql( -""" + """ SELECT [j].[Id], [s].[key], [s].[c], [s].[c0], [s].[c1], [s].[c2], [s].[key0] FROM [JsonEntitiesBasic] AS [j] OUTER APPLY ( @@ -3006,35 +3006,44 @@ OUTER APPLY OPENJSON(JSON_QUERY([o].[value], '$.OwnedCollectionBranch'), '$') AS """); } - public override async Task Json_projection_second_element_through_collection_element_constant_projected_after_owner_nested_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_second_element_through_collection_element_constant_projected_after_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) { - await base.Json_projection_second_element_through_collection_element_constant_projected_after_owner_nested_AsNoTrackingWithIdentityResolution(async); + await base + .Json_projection_second_element_through_collection_element_constant_projected_after_owner_nested_AsNoTrackingWithIdentityResolution( + async); AssertSql( -""" + """ SELECT [j].[Id], JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch[0].OwnedCollectionLeaf'), JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch[0].OwnedCollectionLeaf[1]') FROM [JsonEntitiesBasic] AS [j] """); } - public override async Task Json_projection_reference_collection_and_collection_element_nested_AsNoTrackingWithIdentityResolution(bool async) + public override async Task Json_projection_reference_collection_and_collection_element_nested_AsNoTrackingWithIdentityResolution( + bool async) { await base.Json_projection_reference_collection_and_collection_element_nested_AsNoTrackingWithIdentityResolution(async); AssertSql( -""" + """ SELECT [j].[Id], JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch[0].OwnedReferenceLeaf'), JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch[0].OwnedCollectionLeaf'), JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch[0].OwnedCollectionLeaf[1]') FROM [JsonEntitiesBasic] AS [j] """); } [SqlServerCondition(SqlServerCondition.SupportsJsonPathExpressions)] - public override async Task Json_projection_second_element_through_collection_element_parameter_correctly_projected_after_owner_nested_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_second_element_through_collection_element_parameter_correctly_projected_after_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) { - await base.Json_projection_second_element_through_collection_element_parameter_correctly_projected_after_owner_nested_AsNoTrackingWithIdentityResolution(async); + await base + .Json_projection_second_element_through_collection_element_parameter_correctly_projected_after_owner_nested_AsNoTrackingWithIdentityResolution( + async); AssertSql( -""" + """ @__prm_0='1' SELECT [j].[Id], JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch[0].OwnedCollectionLeaf'), JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch[0].OwnedCollectionLeaf[' + CAST(@__prm_0 AS nvarchar(max)) + ']'), @__prm_0 @@ -3042,24 +3051,32 @@ FROM [JsonEntitiesBasic] AS [j] """); } - public override async Task Json_projection_only_second_element_through_collection_element_constant_projected_nested_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_only_second_element_through_collection_element_constant_projected_nested_AsNoTrackingWithIdentityResolution( + bool async) { - await base.Json_projection_only_second_element_through_collection_element_constant_projected_nested_AsNoTrackingWithIdentityResolution(async); + await base + .Json_projection_only_second_element_through_collection_element_constant_projected_nested_AsNoTrackingWithIdentityResolution( + async); AssertSql( -""" + """ SELECT [j].[Id], JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch[0].OwnedCollectionLeaf[1]') FROM [JsonEntitiesBasic] AS [j] """); } [SqlServerCondition(SqlServerCondition.SupportsJsonPathExpressions)] - public override async Task Json_projection_only_second_element_through_collection_element_parameter_projected_nested_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_only_second_element_through_collection_element_parameter_projected_nested_AsNoTrackingWithIdentityResolution( + bool async) { - await base.Json_projection_only_second_element_through_collection_element_parameter_projected_nested_AsNoTrackingWithIdentityResolution(async); + await base + .Json_projection_only_second_element_through_collection_element_parameter_projected_nested_AsNoTrackingWithIdentityResolution( + async); AssertSql( -""" + """ @__prm1_0='0' @__prm2_1='1' @@ -3068,12 +3085,16 @@ FROM [JsonEntitiesBasic] AS [j] """); } - public override async Task Json_projection_second_element_through_collection_element_constant_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_second_element_through_collection_element_constant_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution( + bool async) { - await base.Json_projection_second_element_through_collection_element_constant_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution(async); + await base + .Json_projection_second_element_through_collection_element_constant_different_values_projected_before_owner_nested_AsNoTrackingWithIdentityResolution( + async); AssertSql( -""" + """ SELECT [j].[Id], JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch[0].OwnedCollectionLeaf[1]'), JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch[1].OwnedCollectionLeaf') FROM [JsonEntitiesBasic] AS [j] """); @@ -3084,19 +3105,23 @@ public override async Task Json_projection_nested_collection_and_element_correct await base.Json_projection_nested_collection_and_element_correct_order_AsNoTrackingWithIdentityResolution(async); AssertSql( -""" + """ SELECT [j].[Id], JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch[0].OwnedCollectionLeaf'), JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch[0].OwnedCollectionLeaf[1]') FROM [JsonEntitiesBasic] AS [j] """); } [SqlServerCondition(SqlServerCondition.SupportsJsonPathExpressions)] - public override async Task Json_projection_nested_collection_element_using_parameter_and_the_owner_in_correct_order_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_nested_collection_element_using_parameter_and_the_owner_in_correct_order_AsNoTrackingWithIdentityResolution( + bool async) { - await base.Json_projection_nested_collection_element_using_parameter_and_the_owner_in_correct_order_AsNoTrackingWithIdentityResolution(async); + await base + .Json_projection_nested_collection_element_using_parameter_and_the_owner_in_correct_order_AsNoTrackingWithIdentityResolution( + async); AssertSql( -""" + """ @__prm_0='0' SELECT [j].[Id], [j].[OwnedReferenceRoot], JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch[' + CAST(@__prm_0 AS nvarchar(max)) + '].OwnedCollectionLeaf[1]'), @__prm_0 @@ -3104,23 +3129,25 @@ FROM [JsonEntitiesBasic] AS [j] """); } - public override async Task Json_projection_second_element_projected_before_owner_as_well_as_root_AsNoTrackingWithIdentityResolution(bool async) + public override async Task Json_projection_second_element_projected_before_owner_as_well_as_root_AsNoTrackingWithIdentityResolution( + bool async) { await base.Json_projection_second_element_projected_before_owner_as_well_as_root_AsNoTrackingWithIdentityResolution(async); AssertSql( -""" + """ SELECT [j].[Id], JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedCollectionBranch[1]'), [j].[OwnedReferenceRoot], [j].[EntityBasicId], [j].[Name], [j].[OwnedCollectionRoot], [j].[OwnedReferenceRoot] FROM [JsonEntitiesBasic] AS [j] """); } - public override async Task Json_projection_second_element_projected_before_owner_nested_as_well_as_root_AsNoTrackingWithIdentityResolution(bool async) + public override async Task + Json_projection_second_element_projected_before_owner_nested_as_well_as_root_AsNoTrackingWithIdentityResolution(bool async) { await base.Json_projection_second_element_projected_before_owner_nested_as_well_as_root_AsNoTrackingWithIdentityResolution(async); AssertSql( -""" + """ SELECT [j].[Id], JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedReferenceBranch.OwnedCollectionLeaf[1]'), JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedReferenceBranch.OwnedCollectionLeaf'), JSON_QUERY([j].[OwnedReferenceRoot], '$.OwnedReferenceBranch'), [j].[EntityBasicId], [j].[Name], [j].[OwnedCollectionRoot], [j].[OwnedReferenceRoot] FROM [JsonEntitiesBasic] AS [j] """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/MappingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/MappingQuerySqlServerTest.cs index 019de4e990d..4b380debfb0 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/MappingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/MappingQuerySqlServerTest.cs @@ -53,9 +53,7 @@ FROM [dbo].[Orders] AS [o] public MappingQuerySqlServerTest(MappingQuerySqlServerFixture fixture) : base(fixture) - { - Fixture.TestSqlLoggerFactory.Clear(); - } + => Fixture.TestSqlLoggerFactory.Clear(); private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySqlServerTest.cs index 31ec7f7f27e..3c7166fd2c1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySqlServerTest.cs @@ -6,7 +6,6 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable - using static Expression; public class NonSharedPrimitiveCollectionsQuerySqlServerTest : NonSharedPrimitiveCollectionsQueryRelationalTestBase @@ -714,7 +713,7 @@ public override async Task Column_with_custom_converter() await base.Column_with_custom_converter(); AssertSql( -""" + """ @__ints_0='1,2,3' (Size = 4000) SELECT TOP(2) [t].[Id], [t].[Ints] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs index 033b0de4407..a34a4630461 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs @@ -1888,7 +1888,7 @@ FROM OPENJSON(@__ids_0) WITH ([value] nchar(5) '$') AS [i] ) """, // -""" + """ @__ids_0='["ABCDE"]' (Size = 4000) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] @@ -1970,7 +1970,7 @@ FROM OPENJSON(@__ids_0) WITH ([value] nchar(5) '$') AS [i] ) """, // -""" + """ @__ids_0='["ABCDE"]' (Size = 4000) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] @@ -2044,7 +2044,7 @@ FROM OPENJSON(@__Order_0) WITH ([value] nchar(5) '$') AS [o] ) """, // -""" + """ @__Order_0='["ABCDE","ANATR"]' (Size = 4000) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] @@ -2071,8 +2071,8 @@ SELECT [i].[value] FROM OPENJSON(@__ids_0) WITH ([value] nchar(5) '$') AS [i] ) """, - // - """ + // + """ @__ids_0='["ABCDE"]' (Size = 4000) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] @@ -2145,8 +2145,8 @@ SELECT [a].[value] FROM OPENJSON(@__AsReadOnly_0) WITH ([value] nchar(5) '$') AS [a] ) """, - // - """ + // + """ @__AsReadOnly_0='["ABCDE","ANATR"]' (Size = 4000) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] @@ -3169,38 +3169,38 @@ public override async Task Return_type_of_singular_operator_is_preserved(bool as await base.Return_type_of_singular_operator_is_preserved(async); AssertSql( -""" + """ SELECT TOP(1) [c].[CustomerID], [c].[City] FROM [Customers] AS [c] WHERE [c].[CustomerID] = N'ALFKI' """, - // - """ + // + """ SELECT TOP(1) [c].[CustomerID], [c].[City] FROM [Customers] AS [c] WHERE [c].[CustomerID] = N'ALFKI' """, - // - """ + // + """ SELECT TOP(2) [c].[CustomerID], [c].[City] FROM [Customers] AS [c] WHERE [c].[CustomerID] = N'ALFKI' """, - // - """ + // + """ SELECT TOP(2) [c].[CustomerID], [c].[City] FROM [Customers] AS [c] WHERE [c].[CustomerID] = N'ALFKI' """, - // - """ + // + """ SELECT TOP(1) [c].[CustomerID], [c].[City] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY [c].[CustomerID] DESC """, - // - """ + // + """ SELECT TOP(1) [c].[CustomerID], [c].[City] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' @@ -3213,7 +3213,7 @@ public override async Task Type_casting_inside_sum(bool async) await base.Type_casting_inside_sum(async); AssertSql( -""" + """ SELECT COALESCE(SUM(CAST([o].[Discount] AS decimal(18,2))), 0.0) FROM [Order Details] AS [o] """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsTrackingQuerySqlServerTest.cs index 5bcce95ac8a..46d8f9a3731 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsTrackingQuerySqlServerTest.cs @@ -10,9 +10,7 @@ public class NorthwindAsTrackingQuerySqlServerTest : NorthwindAsTrackingQueryTes { public NorthwindAsTrackingQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture) : base(fixture) - { - Fixture.TestSqlLoggerFactory.Clear(); - } + => Fixture.TestSqlLoggerFactory.Clear(); [ConditionalFact] public virtual void Check_all_tests_overridden() diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindChangeTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindChangeTrackingQuerySqlServerTest.cs index 0401997f13d..1751f95bd89 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindChangeTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindChangeTrackingQuerySqlServerTest.cs @@ -12,9 +12,7 @@ public class NorthwindChangeTrackingQuerySqlServerTest : NorthwindChangeTracking { public NorthwindChangeTrackingQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture) : base(fixture) - { - Fixture.TestSqlLoggerFactory.Clear(); - } + => Fixture.TestSqlLoggerFactory.Clear(); [ConditionalFact] public virtual void Check_all_tests_overridden() diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySqlServerTest.cs index da37c8b4f3c..3cfb0e6340a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySqlServerTest.cs @@ -10,9 +10,7 @@ public class NorthwindEFPropertyIncludeQuerySqlServerTest : NorthwindEFPropertyI { public NorthwindEFPropertyIncludeQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture) : base(fixture) - { - Fixture.TestSqlLoggerFactory.Clear(); - } + => Fixture.TestSqlLoggerFactory.Clear(); [ConditionalFact] public virtual void Check_all_tests_overridden() diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServer160Test.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServer160Test.cs index 555f1733719..84fc4b39966 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServer160Test.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServer160Test.cs @@ -2686,7 +2686,7 @@ WHERE RTRIM([c].[ContactTitle]) = N'Owner' public override async Task TrimEnd_with_char_argument_in_predicate(bool async) { - await base.TrimEnd_with_char_argument_in_predicate(async); + await base.TrimEnd_with_char_argument_in_predicate(async); AssertSql( """ diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs index 12e35480552..ee401529e9f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs @@ -447,32 +447,32 @@ public override async Task String_Compare_simple_zero(bool async) FROM [Customers] AS [c] WHERE [c].[CustomerID] = N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] <> N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] > N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] <= N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] > N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] <= N'AROUT' @@ -489,32 +489,32 @@ public override async Task String_Compare_simple_one(bool async) FROM [Customers] AS [c] WHERE [c].[CustomerID] > N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] < N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] <= N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] <= N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] >= N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] >= N'AROUT' @@ -533,40 +533,40 @@ public override async Task String_compare_with_parameter(bool async) FROM [Customers] AS [c] WHERE [c].[CustomerID] > @__customer_CustomerID_0 """, - // - """ + // + """ @__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] < @__customer_CustomerID_0 """, - // - """ + // + """ @__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] <= @__customer_CustomerID_0 """, - // - """ + // + """ @__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] <= @__customer_CustomerID_0 """, - // - """ + // + """ @__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] >= @__customer_CustomerID_0 """, - // - """ + // + """ @__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] @@ -681,32 +681,32 @@ public override async Task String_Compare_to_simple_zero(bool async) FROM [Customers] AS [c] WHERE [c].[CustomerID] = N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] <> N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] > N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] <= N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] > N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] <= N'AROUT' @@ -723,32 +723,32 @@ public override async Task String_Compare_to_simple_one(bool async) FROM [Customers] AS [c] WHERE [c].[CustomerID] > N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] < N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] <= N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] <= N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] >= N'AROUT' """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] >= N'AROUT' @@ -767,40 +767,40 @@ public override async Task String_compare_to_with_parameter(bool async) FROM [Customers] AS [c] WHERE [c].[CustomerID] > @__customer_CustomerID_0 """, - // - """ + // + """ @__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] < @__customer_CustomerID_0 """, - // - """ + // + """ @__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] <= @__customer_CustomerID_0 """, - // - """ + // + """ @__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] <= @__customer_CustomerID_0 """, - // - """ + // + """ @__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] >= @__customer_CustomerID_0 """, - // - """ + // + """ @__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] @@ -855,32 +855,32 @@ public override async Task String_Compare_to_nested(bool async) FROM [Customers] AS [c] WHERE [c].[CustomerID] <> N'M' + [c].[CustomerID] """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] = UPPER([c].[CustomerID]) """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] > REPLACE(N'AROUT', N'OUT', [c].[CustomerID]) """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] <= N'M' + [c].[CustomerID] """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] > UPPER([c].[CustomerID]) """, - // - """ + // + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[CustomerID] < REPLACE(N'AROUT', N'OUT', [c].[CustomerID]) @@ -2791,7 +2791,7 @@ public override async Task String_Contains_in_projection(bool async) await base.String_Contains_in_projection(async); AssertSql( -""" + """ SELECT [c].[CustomerID] AS [Id], CASE WHEN [c].[ContactName] IS NOT NULL AND (CHARINDEX([c].[ContactName], [c].[CompanyName]) > 0 OR [c].[ContactName] LIKE N'') THEN CAST(1 AS bit) ELSE CAST(0 AS bit) @@ -2805,7 +2805,7 @@ public override async Task String_Contains_negated_in_predicate(bool async) await base.String_Contains_negated_in_predicate(async); AssertSql( -""" + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] WHERE [c].[ContactName] IS NULL OR (CHARINDEX([c].[ContactName], [c].[CompanyName]) <= 0 AND [c].[ContactName] NOT LIKE N'') @@ -2817,7 +2817,7 @@ public override async Task String_Contains_negated_in_projection(bool async) await base.String_Contains_negated_in_projection(async); AssertSql( -""" + """ SELECT [c].[CustomerID] AS [Id], CASE WHEN [c].[ContactName] IS NULL OR (CHARINDEX([c].[ContactName], [c].[CompanyName]) <= 0 AND [c].[ContactName] NOT LIKE N'') THEN CAST(1 AS bit) ELSE CAST(0 AS bit) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs index 2481d8e6f9d..911848c713f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs @@ -10,9 +10,7 @@ public class NorthwindIncludeNoTrackingQuerySqlServerTest : NorthwindIncludeNoTr { public NorthwindIncludeNoTrackingQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture) : base(fixture) - { - Fixture.TestSqlLoggerFactory.Clear(); - } + => Fixture.TestSqlLoggerFactory.Clear(); [ConditionalFact] public virtual void Check_all_tests_overridden() diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs index 56098a08b67..0c04fa77819 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs @@ -7392,13 +7392,10 @@ FROM [Customers] AS [c] } public override async Task Compiler_generated_local_closure_produces_valid_parameter_name(bool async) - { - await base.Compiler_generated_local_closure_produces_valid_parameter_name(async); - - // No AssertSQL since compiler generated variable names are different between local and CI - //AssertSql(""); - } + => await base.Compiler_generated_local_closure_produces_valid_parameter_name(async); + // No AssertSQL since compiler generated variable names are different between local and CI + //AssertSql(""); public override async Task Static_member_access_gets_parameterized_within_larger_evaluatable(bool async) { await base.Static_member_access_gets_parameterized_within_larger_evaluatable(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs index 30732589058..7df93c2dc01 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs @@ -2791,7 +2791,7 @@ public override async Task Entity_passed_to_DTO_constructor_works(bool async) await base.Entity_passed_to_DTO_constructor_works(async); AssertSql( -""" + """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSqlQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSqlQuerySqlServerTest.cs index 959908d7c53..a54443c7781 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSqlQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSqlQuerySqlServerTest.cs @@ -11,9 +11,7 @@ public class NorthwindSqlQuerySqlServerTest : NorthwindSqlQueryTestBase fixture, ITestOutputHelper testOutputHelper) : base(fixture) - { - Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); - } + => Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); [ConditionalFact] public virtual void Check_all_tests_overridden() diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs index 81178b22899..dec936ceca5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs @@ -10,9 +10,7 @@ public class NorthwindStringIncludeQuerySqlServerTest : NorthwindStringIncludeQu { public NorthwindStringIncludeQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture) : base(fixture) - { - Fixture.TestSqlLoggerFactory.Clear(); - } + => Fixture.TestSqlLoggerFactory.Clear(); [ConditionalFact] public virtual void Check_all_tests_overridden() diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs index c40a5fc7c4a..132b41e85bb 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs @@ -2033,8 +2033,8 @@ public override async Task Enclosing_class_settable_member_generates_parameter(b FROM [Orders] AS [o] WHERE [o].[OrderID] = @__SettableProperty_0 """, - // - """ + // + """ @__SettableProperty_0='10275' SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] @@ -3356,37 +3356,37 @@ public override async Task Implicit_cast_in_predicate(bool async) await base.Implicit_cast_in_predicate(async); AssertSql( -""" + """ SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] WHERE [o].[CustomerID] = N'1337' """, - // - """ + // + """ @__prm_Value_0='1337' (Size = 5) SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] WHERE [o].[CustomerID] = @__prm_Value_0 """, - // - """ + // + """ @__ToString_0='1337' (Size = 5) SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] WHERE [o].[CustomerID] = @__ToString_0 """, - // - """ + // + """ @__p_0='1337' (Size = 5) SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] WHERE [o].[CustomerID] = @__p_0 """, - // - """ + // + """ SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] WHERE [o].[CustomerID] = N'1337' @@ -3398,27 +3398,27 @@ public override async Task Interface_casting_though_generic_method(bool async) await base.Interface_casting_though_generic_method(async); AssertSql( -""" + """ @__id_0='10252' SELECT [o].[OrderID] AS [Id] FROM [Orders] AS [o] WHERE [o].[OrderID] = @__id_0 """, - // - """ + // + """ SELECT [o].[OrderID] AS [Id] FROM [Orders] AS [o] WHERE [o].[OrderID] = 10252 """, - // - """ + // + """ SELECT [o].[OrderID] AS [Id] FROM [Orders] AS [o] WHERE [o].[OrderID] = 10252 """, - // - """ + // + """ SELECT [o].[OrderID] AS [Id] FROM [Orders] AS [o] WHERE [o].[OrderID] = 10252 diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NullKeysSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NullKeysSqlServerTest.cs index 5108682f98a..dee8fcdfca5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NullKeysSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NullKeysSqlServerTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class NullKeysSqlServerTest(NullKeysSqlServerTest.NullKeysSqlServerFixture fixture) : NullKeysTestBase(fixture) +public class NullKeysSqlServerTest(NullKeysSqlServerTest.NullKeysSqlServerFixture fixture) + : NullKeysTestBase(fixture) { public class NullKeysSqlServerFixture : NullKeysFixtureBase { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs index 70a2c9ced58..2581e0a3baa 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs @@ -3099,8 +3099,8 @@ SELECT 1 FROM [Entities2] AS [e0] WHERE [e0].[NullableStringA] = [e].[NullableStringB] OR ([e0].[NullableStringA] IS NULL AND [e].[NullableStringB] IS NULL)) """, - // - """ + // + """ SELECT [e].[Id] FROM [Entities1] AS [e] WHERE NOT EXISTS ( diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/OptionalDependentQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/OptionalDependentQuerySqlServerTest.cs index 59d7289d21d..3249890f7cb 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/OptionalDependentQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/OptionalDependentQuerySqlServerTest.cs @@ -13,6 +13,7 @@ public OptionalDependentQuerySqlServerTest(OptionalDependentQuerySqlServerFixtur Fixture.TestSqlLoggerFactory.Clear(); Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + public override async Task Basic_projection_entity_with_all_optional(bool async) { await base.Basic_projection_entity_with_all_optional(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedEntityQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedEntityQuerySqlServerTest.cs index c70570a8c7d..5eb74c50918 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedEntityQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedEntityQuerySqlServerTest.cs @@ -319,13 +319,16 @@ public Task SeedAsync() Add( new Owner23211 { - Dependents = [new(), new()], + Dependents = [new Dependent23211(), new Dependent23211()], Owned1 = new OwnedType23211 { Value = "A" }, Owned2 = new OwnedType23211 { Value = "B" } }); Add( - new SecondOwner23211 { Dependents = [new(), new()], Owned = new OwnedType23211 { Value = "A" } }); + new SecondOwner23211 + { + Dependents = [new SecondDependent23211(), new SecondDependent23211()], Owned = new OwnedType23211 { Value = "A" } + }); return SaveChangesAsync(); } @@ -415,7 +418,6 @@ ORDER BY [p].[Id] """); } - public override async Task Owned_entity_multiple_level_in_aggregate() { await base.Owned_entity_multiple_level_in_aggregate(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs index df65d197ba4..1e7744a2e35 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs @@ -9,9 +9,7 @@ public class OwnedQuerySqlServerTest : OwnedQueryRelationalTestBase Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); public override async Task Query_with_owned_entity_equality_operator(bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/PrecompiledQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/PrecompiledQuerySqlServerTest.cs index 760bf5794f4..fd90fe63e59 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/PrecompiledQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/PrecompiledQuerySqlServerTest.cs @@ -67,27 +67,27 @@ public override async Task Invoke_no_evaluatability_is_not_supported() AssertSql(); } - public override async Task ListInit_no_evaluatability() - { - await base.ListInit_no_evaluatability(); + public override async Task ListInit_no_evaluatability() + { + await base.ListInit_no_evaluatability(); - AssertSql( - """ + AssertSql( + """ SELECT [b].[Id], [b].[Id] + 1 FROM [Blogs] AS [b] """); - } + } - public override async Task ListInit_with_evaluatable_with_captured_variable() - { - await base.ListInit_with_evaluatable_with_captured_variable(); + public override async Task ListInit_with_evaluatable_with_captured_variable() + { + await base.ListInit_with_evaluatable_with_captured_variable(); - AssertSql( - """ + AssertSql( + """ SELECT [b].[Id] FROM [Blogs] AS [b] """); - } + } public override async Task ListInit_with_evaluatable_without_captured_variable() { @@ -112,17 +112,17 @@ WHERE [b].[Id] IN (7, 8) """); } - public override async Task MethodCallExpression_no_evaluatability() - { - await base.MethodCallExpression_no_evaluatability(); + public override async Task MethodCallExpression_no_evaluatability() + { + await base.MethodCallExpression_no_evaluatability(); - AssertSql( - """ + AssertSql( + """ SELECT [b].[Id], [b].[Name], [b].[Json] FROM [Blogs] AS [b] WHERE [b].[Name] IS NOT NULL AND LEFT([b].[Name], LEN([b].[Name])) = [b].[Name] """); - } + } public override async Task MethodCallExpression_with_evaluatable_with_captured_variable() { @@ -2094,6 +2094,7 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build return builder; } - public override PrecompiledQueryTestHelpers PrecompiledQueryTestHelpers => SqlServerPrecompiledQueryTestHelpers.Instance; + public override PrecompiledQueryTestHelpers PrecompiledQueryTestHelpers + => SqlServerPrecompiledQueryTestHelpers.Instance; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/PrecompiledSqlPregenerationQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/PrecompiledSqlPregenerationQuerySqlServerTest.cs index b187615aee8..2dee871227b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/PrecompiledSqlPregenerationQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/PrecompiledSqlPregenerationQuerySqlServerTest.cs @@ -6,7 +6,6 @@ namespace Microsoft.EntityFrameworkCore.Query; // ReSharper disable InconsistentNaming - public class PrecompiledSqlPregenerationQuerySqlServerTest( PrecompiledSqlPregenerationQuerySqlServerTest.PrecompiledSqlPregenerationQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) @@ -263,6 +262,7 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build return builder; } - public override PrecompiledQueryTestHelpers PrecompiledQueryTestHelpers => SqlServerPrecompiledQueryTestHelpers.Instance; + public override PrecompiledQueryTestHelpers PrecompiledQueryTestHelpers + => SqlServerPrecompiledQueryTestHelpers.Instance; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerJsonTypeTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerJsonTypeTest.cs index d83e60993a8..f5b0b9d9380 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerJsonTypeTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerJsonTypeTest.cs @@ -9,7 +9,9 @@ namespace Microsoft.EntityFrameworkCore.Query; public class PrimitiveCollectionsQuerySqlServerJsonTypeTest : PrimitiveCollectionsQueryRelationalTestBase< PrimitiveCollectionsQuerySqlServerJsonTypeTest.PrimitiveCollectionsQuerySqlServerFixture> { - public PrimitiveCollectionsQuerySqlServerJsonTypeTest(PrimitiveCollectionsQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public PrimitiveCollectionsQuerySqlServerJsonTypeTest( + PrimitiveCollectionsQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/QueryNoClientEvalSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/QueryNoClientEvalSqlServerTest.cs index 47c6dc2580c..7a2c7756c13 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/QueryNoClientEvalSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/QueryNoClientEvalSqlServerTest.cs @@ -5,4 +5,5 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class QueryNoClientEvalSqlServerTest(NorthwindQuerySqlServerFixture fixture) : QueryNoClientEvalTestBase>(fixture); +public class QueryNoClientEvalSqlServerTest(NorthwindQuerySqlServerFixture fixture) + : QueryNoClientEvalTestBase>(fixture); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SqlQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SqlQuerySqlServerTest.cs index 5d03c225058..6162a35617d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SqlQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SqlQuerySqlServerTest.cs @@ -11,9 +11,7 @@ public class SqlQuerySqlServerTest : SqlQueryTestBase fixture, ITestOutputHelper testOutputHelper) : base(fixture) - { - Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); - } + => Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); public override async Task SqlQueryRaw_queryable_simple(bool async) { @@ -456,7 +454,7 @@ public override async Task SqlQueryRaw_composed_with_predicate(bool async) await base.SqlQueryRaw_composed_with_predicate(async); AssertSql( -""" + """ SELECT [m].[Address], [m].[City], [m].[CompanyName], [m].[ContactName], [m].[ContactTitle], [m].[Country], [m].[CustomerID], [m].[Fax], [m].[Phone], [m].[Region], [m].[PostalCode] FROM ( SELECT * FROM "Customers" diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs index 5f691f3504a..f8d41c87f63 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs @@ -896,7 +896,7 @@ public override async Task Where_enum_has_flag_subquery_with_pushdown(bool async await base.Where_enum_has_flag_subquery_with_pushdown(async); AssertSql( -""" + """ SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] @@ -934,8 +934,8 @@ FROM [Officers] AS [o0] ) AS [u0] ORDER BY [u0].[Nickname], [u0].[SquadId]) IS NULL """, - // - """ + // + """ SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] @@ -5408,7 +5408,7 @@ public override async Task ToString_nullable_enum_property_projection(bool async await base.ToString_nullable_enum_property_projection(async); AssertSql( -""" + """ SELECT CASE [w].[AmmunitionType] WHEN 1 THEN N'Cartridge' WHEN 2 THEN N'Shell' @@ -5423,7 +5423,7 @@ public override async Task ToString_enum_contains(bool async) await base.ToString_enum_contains(async); AssertSql( -""" + """ SELECT [m].[CodeName] FROM [Missions] AS [m] WHERE CAST([m].[Difficulty] AS nvarchar(max)) LIKE N'%Med%' @@ -5435,7 +5435,7 @@ public override async Task ToString_nullable_enum_contains(bool async) await base.ToString_nullable_enum_contains(async); AssertSql( -""" + """ SELECT [w].[Name] FROM [Weapons] AS [w] WHERE CASE [w].[AmmunitionType] @@ -11854,7 +11854,7 @@ public override async Task Where_TimeOnly_FromDateTime_compared_to_property(bool await base.Where_TimeOnly_FromDateTime_compared_to_property(async); AssertSql( -""" + """ SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] FROM [Tags] AS [t] CROSS JOIN [Missions] AS [m] @@ -11867,7 +11867,7 @@ public override async Task Where_TimeOnly_FromDateTime_compared_to_parameter(boo await base.Where_TimeOnly_FromDateTime_compared_to_parameter(async); AssertSql( -""" + """ @__time_0='02:00' (DbType = Time) SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] @@ -11888,7 +11888,7 @@ public override async Task Where_TimeOnly_FromDateTime_compared_to_constant(bool await base.Where_TimeOnly_FromDateTime_compared_to_constant(async); AssertSql( -""" + """ SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] WHERE CAST(DATEADD(hour, CAST(CAST(CAST(LEN([t].[Note]) AS int) AS float) AS int), [t].[IssueDate]) AS time) > '09:00:00' @@ -11900,7 +11900,7 @@ public override async Task Where_TimeOnly_FromTimeSpan_compared_to_property(bool await base.Where_TimeOnly_FromTimeSpan_compared_to_property(async); AssertSql( -""" + """ SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE CAST([m].[Duration] AS time) < [m].[Time] @@ -11912,7 +11912,7 @@ public override async Task Where_TimeOnly_FromTimeSpan_compared_to_parameter(boo await base.Where_TimeOnly_FromTimeSpan_compared_to_parameter(async); AssertSql( -""" + """ @__time_0='01:02' (DbType = Time) SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] @@ -11926,7 +11926,7 @@ public override async Task Order_by_TimeOnly_FromTimeSpan(bool async) await base.Order_by_TimeOnly_FromTimeSpan(async); AssertSql( -""" + """ SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] ORDER BY CAST([m].[Duration] AS time) @@ -11938,7 +11938,7 @@ public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool await base.Where_DateOnly_FromDateTime_compared_to_property(async); AssertSql( -""" + """ SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] FROM [Tags] AS [t] CROSS JOIN [Missions] AS [m] @@ -11951,7 +11951,7 @@ public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_ await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); AssertSql( -""" + """ @__prm_0='10/11/0002' (DbType = Date) SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQueryHiLoSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQueryHiLoSqlServerTest.cs index 6f53963afed..a7eb9d6b4eb 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQueryHiLoSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQueryHiLoSqlServerTest.cs @@ -5,4 +5,5 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class TPCInheritanceQueryHiLoSqlServerTest(TPCInheritanceQueryHiLoSqlServerFixture fixture, ITestOutputHelper testOutputHelper) : TPCInheritanceQuerySqlServerTestBase(fixture, testOutputHelper); +public class TPCInheritanceQueryHiLoSqlServerTest(TPCInheritanceQueryHiLoSqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : TPCInheritanceQuerySqlServerTestBase(fixture, testOutputHelper); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerFixture.cs index 3e1b6e9421f..c2a392dfe07 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerFixture.cs @@ -3,6 +3,4 @@ namespace Microsoft.EntityFrameworkCore.Query; -#nullable disable - public class TPCInheritanceQuerySqlServerFixture : TPCInheritanceQuerySqlServerFixtureBase; diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerTest.cs index a9dcec25621..e123f45edae 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerTest.cs @@ -7,4 +7,5 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class TPCInheritanceQuerySqlServerTest(TPCInheritanceQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : TPCInheritanceQuerySqlServerTestBase(fixture, testOutputHelper); +public class TPCInheritanceQuerySqlServerTest(TPCInheritanceQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : TPCInheritanceQuerySqlServerTestBase(fixture, testOutputHelper); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs index 060ffae67ed..e2260d6cc08 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs @@ -4680,7 +4680,7 @@ public override async Task ToString_nullable_enum_property_projection(bool async await base.ToString_nullable_enum_property_projection(async); AssertSql( -""" + """ SELECT CASE [w].[AmmunitionType] WHEN 1 THEN N'Cartridge' WHEN 2 THEN N'Shell' @@ -4707,7 +4707,7 @@ public override async Task ToString_nullable_enum_contains(bool async) await base.ToString_nullable_enum_contains(async); AssertSql( -""" + """ SELECT [w].[Name] FROM [Weapons] AS [w] WHERE CASE [w].[AmmunitionType] @@ -10070,7 +10070,7 @@ public override async Task Where_TimeOnly_FromDateTime_compared_to_property(bool await base.Where_TimeOnly_FromDateTime_compared_to_property(async); AssertSql( -""" + """ SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] FROM [Tags] AS [t] CROSS JOIN [Missions] AS [m] @@ -10083,7 +10083,7 @@ public override async Task Where_TimeOnly_FromDateTime_compared_to_parameter(boo await base.Where_TimeOnly_FromDateTime_compared_to_parameter(async); AssertSql( -""" + """ @__time_0='02:00' (DbType = Time) SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] @@ -10101,7 +10101,7 @@ public override async Task Where_TimeOnly_FromDateTime_compared_to_constant(bool await base.Where_TimeOnly_FromDateTime_compared_to_constant(async); AssertSql( -""" + """ SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] WHERE CAST(DATEADD(hour, CAST(CAST(CAST(LEN([t].[Note]) AS int) AS float) AS int), [t].[IssueDate]) AS time) > '09:00:00' @@ -10113,7 +10113,7 @@ public override async Task Where_TimeOnly_FromTimeSpan_compared_to_property(bool await base.Where_TimeOnly_FromTimeSpan_compared_to_property(async); AssertSql( -""" + """ SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] WHERE CAST([m].[Duration] AS time) < [m].[Time] @@ -10125,7 +10125,7 @@ public override async Task Where_TimeOnly_FromTimeSpan_compared_to_parameter(boo await base.Where_TimeOnly_FromTimeSpan_compared_to_parameter(async); AssertSql( -""" + """ @__time_0='01:02' (DbType = Time) SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] @@ -10139,7 +10139,7 @@ public override async Task Order_by_TimeOnly_FromTimeSpan(bool async) await base.Order_by_TimeOnly_FromTimeSpan(async); AssertSql( -""" + """ SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] ORDER BY CAST([m].[Duration] AS time) @@ -10151,7 +10151,7 @@ public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool await base.Where_DateOnly_FromDateTime_compared_to_property(async); AssertSql( -""" + """ SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] FROM [Tags] AS [t] CROSS JOIN [Missions] AS [m] @@ -10164,7 +10164,7 @@ public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_ await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); AssertSql( -""" + """ @__prm_0='10/11/0002' (DbType = Date) SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] @@ -11627,7 +11627,7 @@ public override async Task Include_one_to_many_on_composite_key_then_orderby_key await base.Include_one_to_many_on_composite_key_then_orderby_key_properties(async); AssertSql( -""" + """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] @@ -11795,7 +11795,7 @@ public override async Task Derived_reference_is_skipped_when_base_type(bool asyn await base.Derived_reference_is_skipped_when_base_type(async); AssertSql( -""" + """ SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' END AS [Discriminator], [l1].[Id], [l1].[IsOperational], [l1].[Name] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTRelationshipsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTRelationshipsQuerySqlServerTest.cs index 6e8c7d8e184..382759c61a3 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTRelationshipsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTRelationshipsQuerySqlServerTest.cs @@ -12,9 +12,7 @@ public TPTRelationshipsQuerySqlServerTest( TPTRelationshipsQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) - { - fixture.TestSqlLoggerFactory.Clear(); - } + => fixture.TestSqlLoggerFactory.Clear(); [ConditionalFact] public virtual void Check_all_tests_overridden() diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs index e9372707817..6895ee561b1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs @@ -137,7 +137,7 @@ public override async Task Query_reusing_parameter_with_inner_query_doesnt_decla { // Test infra issue await Assert.ThrowsAsync( - () => base.Query_reusing_parameter_with_inner_query_doesnt_declare_duplicate_parameter(async)); + () => base.Query_reusing_parameter_with_inner_query_doesnt_declare_duplicate_parameter(async)); AssertSql( """ @@ -436,7 +436,7 @@ public override async Task Where_TimeOnly_FromDateTime_compared_to_property(bool await base.Where_TimeOnly_FromDateTime_compared_to_property(async); AssertSql( -""" + """ SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] CROSS JOIN [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] @@ -449,7 +449,7 @@ public override async Task Where_TimeOnly_FromDateTime_compared_to_parameter(boo await base.Where_TimeOnly_FromDateTime_compared_to_parameter(async); AssertSql( -""" + """ @__time_0='02:00' (DbType = Time) SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t].[PeriodEnd], [t].[PeriodStart] @@ -464,7 +464,7 @@ public override async Task Where_TimeOnly_FromDateTime_compared_to_constant(bool await base.Where_TimeOnly_FromDateTime_compared_to_constant(async); AssertSql( -""" + """ SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t].[PeriodEnd], [t].[PeriodStart] FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] WHERE CAST(DATEADD(hour, CAST(CAST(CAST(LEN([t].[Note]) AS int) AS float) AS int), [t].[IssueDate]) AS time) > '09:00:00' @@ -476,7 +476,7 @@ public override async Task Where_TimeOnly_FromTimeSpan_compared_to_property(bool await base.Where_TimeOnly_FromTimeSpan_compared_to_property(async); AssertSql( -""" + """ SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE CAST([m].[Duration] AS time) < [m].[Time] @@ -488,7 +488,7 @@ public override async Task Where_TimeOnly_FromTimeSpan_compared_to_parameter(boo await base.Where_TimeOnly_FromTimeSpan_compared_to_parameter(async); AssertSql( -""" + """ @__time_0='01:02' (DbType = Time) SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] @@ -502,7 +502,7 @@ public override async Task Order_by_TimeOnly_FromTimeSpan(bool async) await base.Order_by_TimeOnly_FromTimeSpan(async); AssertSql( -""" + """ SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] ORDER BY CAST([m].[Duration] AS time) @@ -514,7 +514,7 @@ public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool await base.Where_DateOnly_FromDateTime_compared_to_property(async); AssertSql( -""" + """ SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] CROSS JOIN [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] @@ -527,7 +527,7 @@ public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_ await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); AssertSql( -""" + """ @__prm_0='10/11/0002' (DbType = Date) SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t].[PeriodEnd], [t].[PeriodStart] @@ -4783,7 +4783,7 @@ public override async Task ToString_nullable_enum_property_projection(bool async await base.ToString_nullable_enum_property_projection(async); AssertSql( -""" + """ SELECT CASE [w].[AmmunitionType] WHEN 1 THEN N'Cartridge' WHEN 2 THEN N'Shell' @@ -4798,7 +4798,7 @@ public override async Task ToString_enum_contains(bool async) await base.ToString_enum_contains(async); AssertSql( -""" + """ SELECT [m].[CodeName] FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] WHERE CAST([m].[Difficulty] AS nvarchar(max)) LIKE N'%Med%' @@ -4810,7 +4810,7 @@ public override async Task ToString_nullable_enum_contains(bool async) await base.ToString_nullable_enum_contains(async); AssertSql( -""" + """ SELECT [w].[Name] FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] WHERE CASE [w].[AmmunitionType] @@ -10249,7 +10249,7 @@ public override async Task Include_one_to_many_on_composite_key_then_orderby_key await base.Include_one_to_many_on_composite_key_then_orderby_key_properties(async); AssertSql( -""" + """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] LEFT JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] ON [g].[FullName] = [w].[OwnerFullName] @@ -10278,7 +10278,7 @@ public override async Task Join_include_coalesce_simple(bool async) await base.Join_include_coalesce_simple(async); AssertSql( -""" + """ SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[PeriodEnd], [g0].[PeriodStart], [g0].[Rank], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId], CASE WHEN [g].[Nickname] = N'Marcus' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) @@ -10288,16 +10288,16 @@ ELSE CAST(0 AS bit) LEFT JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] ON [g].[FullName] = [w].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId] """, - // - """ + // + """ SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[PeriodEnd], [g0].[PeriodStart], [g0].[Rank], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] LEFT JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] ON [g0].[FullName] = [w].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId] """, - // - """ + // + """ SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[PeriodEnd], [g0].[PeriodStart], [g0].[Rank], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[PeriodEnd], [w0].[PeriodStart], [w0].[SynergyWithId] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] @@ -10312,7 +10312,7 @@ public override async Task Join_include_coalesce_nested(bool async) await base.Join_include_coalesce_nested(async); AssertSql( -""" + """ SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[PeriodEnd], [g0].[PeriodStart], [g0].[Rank], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId], CASE WHEN [g].[Nickname] = N'Marcus' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) @@ -10322,8 +10322,8 @@ ELSE CAST(0 AS bit) LEFT JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] ON [g].[FullName] = [w].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId] """, - // - """ + // + """ SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[PeriodEnd], [g0].[PeriodStart], [g0].[Rank], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[PeriodEnd], [w0].[PeriodStart], [w0].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[PeriodEnd], [w1].[PeriodStart], [w1].[SynergyWithId] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] @@ -10339,7 +10339,7 @@ public override async Task Join_include_conditional(bool async) await base.Join_include_conditional(async); AssertSql( -""" + """ SELECT CASE WHEN [g0].[Nickname] IS NOT NULL AND [g0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) @@ -10359,7 +10359,7 @@ public override async Task Derived_reference_is_skipped_when_base_type(bool asyn await base.Derived_reference_is_skipped_when_base_type(async); AssertSql( -""" + """ SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[PeriodEnd], [l].[PeriodStart], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [l0].[Id], [l0].[IsOperational], [l0].[Name], [l0].[PeriodEnd], [l0].[PeriodStart] FROM [LocustLeaders] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l] LEFT JOIN [LocustHighCommands] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] ON [l].[HighCommandId] = [l0].[Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalOwnedQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalOwnedQuerySqlServerTest.cs index 67aedc24e72..cecd329a737 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalOwnedQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalOwnedQuerySqlServerTest.cs @@ -13,9 +13,7 @@ public class TemporalOwnedQuerySqlServerTest : OwnedQueryRelationalTestBase< { public TemporalOwnedQuerySqlServerTest(TemporalOwnedQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) - { - Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); - } + => Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); protected override Expression RewriteServerQueryExpression(Expression serverQueryExpression) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/WarningsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/WarningsSqlServerTest.cs index a4ec9a294f4..a70b877dd49 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/WarningsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/WarningsSqlServerTest.cs @@ -5,4 +5,5 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class WarningsSqlServerTest(NorthwindQuerySqlServerFixture fixture) : WarningsTestBase>(fixture); +public class WarningsSqlServerTest(NorthwindQuerySqlServerFixture fixture) + : WarningsTestBase>(fixture); diff --git a/test/EFCore.SqlServer.FunctionalTests/QueryExpressionInterceptionSqlServerTestBase.cs b/test/EFCore.SqlServer.FunctionalTests/QueryExpressionInterceptionSqlServerTestBase.cs index d3c8407e20f..99b20b338c0 100644 --- a/test/EFCore.SqlServer.FunctionalTests/QueryExpressionInterceptionSqlServerTestBase.cs +++ b/test/EFCore.SqlServer.FunctionalTests/QueryExpressionInterceptionSqlServerTestBase.cs @@ -30,7 +30,8 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build } public class QueryExpressionInterceptionSqlServerTest(QueryExpressionInterceptionSqlServerTest.InterceptionSqlServerFixture fixture) - : QueryExpressionInterceptionSqlServerTestBase(fixture), IClassFixture + : QueryExpressionInterceptionSqlServerTestBase(fixture), + IClassFixture { public class InterceptionSqlServerFixture : InterceptionSqlServerFixtureBase { @@ -42,7 +43,8 @@ protected override bool ShouldSubscribeToDiagnosticListener } } - public class QueryExpressionInterceptionWithDiagnosticsSqlServerTest(QueryExpressionInterceptionWithDiagnosticsSqlServerTest.InterceptionSqlServerFixture fixture) + public class QueryExpressionInterceptionWithDiagnosticsSqlServerTest( + QueryExpressionInterceptionWithDiagnosticsSqlServerTest.InterceptionSqlServerFixture fixture) : QueryExpressionInterceptionSqlServerTestBase(fixture), IClassFixture { diff --git a/test/EFCore.SqlServer.FunctionalTests/Scaffolding/CompiledModelSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Scaffolding/CompiledModelSqlServerTest.cs index dcd7744356b..2503b3bacdb 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Scaffolding/CompiledModelSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Scaffolding/CompiledModelSqlServerTest.cs @@ -5,10 +5,10 @@ using System.Runtime.CompilerServices; using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.EntityFrameworkCore.SqlServer.Metadata.Internal; using Microsoft.EntityFrameworkCore.SqlServer.Design.Internal; -using NetTopologySuite.Geometries; +using Microsoft.EntityFrameworkCore.SqlServer.Metadata.Internal; using NetTopologySuite; +using NetTopologySuite.Geometries; namespace Microsoft.EntityFrameworkCore.Scaffolding; @@ -64,7 +64,7 @@ protected override void BuildBigModel(ModelBuilder modelBuilder, bool jsonColumn eb => { eb.Property(m => m.CharToStringConverterProperty) - .IsFixedLength(true); + .IsFixedLength(); }); } @@ -104,6 +104,7 @@ protected override void AssertBigModel(IModel model, bool jsonColumns) principalId.GetAnnotations().Select(a => a.Name)); Assert.Equal(SqlServerValueGenerationStrategy.IdentityColumn, principalId.GetValueGenerationStrategy()); } + Assert.Null(principalId[SqlServerAnnotationNames.IdentitySeed]); Assert.Equal( CoreStrings.RuntimeModelMissingData, @@ -181,7 +182,7 @@ protected override void AssertBigModel(IModel model, bool jsonColumns) var dependentMoney = dependentDerived.GetDeclaredProperties().Last(); Assert.Equal("decimal(9,3)", dependentMoney.GetColumnType()); Assert.Equal( - new[] + new[] { dependentBase, dependentDerived, @@ -195,7 +196,8 @@ protected override void AssertBigModel(IModel model, bool jsonColumns) model.GetEntityTypes()); } - protected override bool UseSprocReturnValue => true; + protected override bool UseSprocReturnValue + => true; protected override void BuildTpcSprocsModel(ModelBuilder modelBuilder) { @@ -341,7 +343,8 @@ protected override void AssertComplexTypes(IModel model) [ConditionalFact] public virtual Task Key_HiLo_sequence() => Test( - modelBuilder => { + modelBuilder => + { modelBuilder.Entity( eb => { @@ -430,8 +433,11 @@ public virtual Task SpatialTypesTest() }, options: new CompiledModelCodeGenerationOptions { UseNullableReferenceTypes = true, ForNativeAot = true }); - protected override TestHelpers TestHelpers => SqlServerTestHelpers.Instance; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override TestHelpers TestHelpers + => SqlServerTestHelpers.Instance; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Scaffolding/SqlServerDatabaseModelFactoryTest.cs b/test/EFCore.SqlServer.FunctionalTests/Scaffolding/SqlServerDatabaseModelFactoryTest.cs index de336712544..a52dde1d41c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Scaffolding/SqlServerDatabaseModelFactoryTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Scaffolding/SqlServerDatabaseModelFactoryTest.cs @@ -60,10 +60,11 @@ MAXVALUE 8 Assert.Equal(-3, customSequence.MinValue); Assert.Equal(8, customSequence.MaxValue); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Empty(model.GetEntityTypes()); - Assert.Collection(model.GetSequences(), + Assert.Collection( + model.GetSequences(), s => { Assert.Equal("db2", s.Schema); @@ -116,10 +117,11 @@ public void Sequence_min_max_start_values_are_null_if_default() Assert.Null(s.MaxValue); }); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Empty(model.GetEntityTypes()); - Assert.Collection(model.GetSequences(), + Assert.Collection( + model.GetSequences(), s => { Assert.Equal("dbo", s.Schema); @@ -194,10 +196,11 @@ public void Sequence_min_max_start_values_are_not_null_if_decimal() Assert.NotNull(s.MaxValue); }); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Empty(model.GetEntityTypes()); - Assert.Collection(model.GetSequences(), + Assert.Collection( + model.GetSequences(), s => { Assert.Equal("dbo", s.Schema); @@ -253,10 +256,11 @@ MAXVALUE 99999999999999999999999999999999999999 Assert.Equal(long.MaxValue, s.MaxValue); }); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Empty(model.GetEntityTypes()); - Assert.Collection(model.GetSequences(), + Assert.Collection( + model.GetSequences(), s => { Assert.Equal("dbo", s.Schema); @@ -297,10 +301,11 @@ public void Sequence_using_type_alias() Assert.Null(sequence.MinValue); Assert.Null(sequence.MaxValue); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Empty(model.GetEntityTypes()); - Assert.Collection(model.GetSequences(), + Assert.Collection( + model.GetSequences(), s => { Assert.Equal("dbo", s.Schema); @@ -335,10 +340,11 @@ public void Sequence_using_type_with_facets() Assert.False(sequence.IsCyclic); Assert.Equal(1, sequence.IncrementBy); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Empty(model.GetEntityTypes()); - Assert.Collection(model.GetSequences(), + Assert.Collection( + model.GetSequences(), s => { Assert.Equal("dbo", s.Schema); @@ -373,10 +379,11 @@ public void Filter_sequences_based_on_schema() Assert.False(sequence.IsCyclic); Assert.Equal(1, sequence.IncrementBy); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Empty(model.GetEntityTypes()); - Assert.Collection(model.GetSequences(), + Assert.Collection( + model.GetSequences(), s => { Assert.Equal("db2", s.Schema); @@ -409,7 +416,7 @@ public void Set_default_schema() var defaultSchema = Fixture.TestStore.ExecuteScalar("SELECT SCHEMA_NAME()"); Assert.Equal(defaultSchema, dbModel.DefaultSchema); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal("dbo", model.GetDefaultSchema()); }, @@ -439,7 +446,7 @@ public void Create_tables() Assert.Equal("Everest", e.Name); }); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -564,10 +571,12 @@ ALTER TABLE [dbo].[Properties] CHECK CONSTRAINT [FK_Properties_Listings] { Assert.Equal("dbo", t.Schema); Assert.Equal("AttributesByCategory", t.Name); - Assert.Collection(t.Columns, + Assert.Collection( + t.Columns, c => Assert.Equal("IdB", c.Name), c => Assert.Equal("IdC", c.Name)); - Assert.Collection(t.PrimaryKey!.Columns, + Assert.Collection( + t.PrimaryKey!.Columns, c => Assert.Equal("IdB", c.Name), c => Assert.Equal("IdC", c.Name)); Assert.Collection( @@ -591,17 +600,21 @@ ALTER TABLE [dbo].[Properties] CHECK CONSTRAINT [FK_Properties_Listings] { Assert.Equal("dbo", t.Schema); Assert.Equal("Properties", t.Name); - Assert.Collection(t.Columns, + Assert.Collection( + t.Columns, c => Assert.Equal("IdA", c.Name), c => Assert.Equal("IdB", c.Name), c => Assert.Equal("IdC", c.Name)); - Assert.Collection(t.PrimaryKey!.Columns, + Assert.Collection( + t.PrimaryKey!.Columns, c => Assert.Equal("IdA", c.Name), c => Assert.Equal("IdB", c.Name), c => Assert.Equal("IdC", c.Name)); - Assert.Collection(t.UniqueConstraints, u => Assert.Collection(u.Columns, - c => Assert.Equal("IdA", c.Name), - c => Assert.Equal("IdC", c.Name))); + Assert.Collection( + t.UniqueConstraints, u => Assert.Collection( + u.Columns, + c => Assert.Equal("IdA", c.Name), + c => Assert.Equal("IdC", c.Name))); Assert.Collection( t.ForeignKeys, k => @@ -622,19 +635,23 @@ ALTER TABLE [dbo].[Properties] CHECK CONSTRAINT [FK_Properties_Listings] { Assert.Equal("dbo", t.Schema); Assert.Equal("TableAB", t.Name); - Assert.Collection(t.Columns, + Assert.Collection( + t.Columns, c => Assert.Equal("IdA", c.Name), c => Assert.Equal("IdB", c.Name)); Assert.Collection(t.PrimaryKey!.Columns, c => Assert.Equal("IdA", c.Name)); - Assert.Collection(t.UniqueConstraints, u => Assert.Collection(u.Columns, - c => Assert.Equal("IdA", c.Name), - c => Assert.Equal("IdB", c.Name))); - Assert.Collection(t.ForeignKeys, k => - { - Assert.Equal("TableB", k.PrincipalTable.Name); - Assert.Collection(k.Columns, c => Assert.Equal("IdB", c.Name)); - Assert.Collection(k.PrincipalColumns, c => Assert.Equal("IdB", c.Name)); - }); + Assert.Collection( + t.UniqueConstraints, u => Assert.Collection( + u.Columns, + c => Assert.Equal("IdA", c.Name), + c => Assert.Equal("IdB", c.Name))); + Assert.Collection( + t.ForeignKeys, k => + { + Assert.Equal("TableB", k.PrincipalTable.Name); + Assert.Collection(k.Columns, c => Assert.Equal("IdB", c.Name)); + Assert.Collection(k.PrincipalColumns, c => Assert.Equal("IdB", c.Name)); + }); Assert.Empty(t.Indexes); }, t => @@ -658,18 +675,21 @@ ALTER TABLE [dbo].[Properties] CHECK CONSTRAINT [FK_Properties_Listings] Assert.Empty(t.Indexes); }); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), e => { Assert.Equal("AttributesByCategory", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("IdB", p.Name), p => Assert.Equal("IdC", p.Name)); - Assert.Collection(e.GetKeys(), - c => Assert.Collection(c.Properties, + Assert.Collection( + e.GetKeys(), + c => Assert.Collection( + c.Properties, p => Assert.Equal("IdB", p.Name), p => Assert.Equal("IdC", p.Name))); Assert.Collection( @@ -690,7 +710,8 @@ ALTER TABLE [dbo].[Properties] CHECK CONSTRAINT [FK_Properties_Listings] }); Assert.Empty(e.GetIndexes()); Assert.Empty(e.GetSkipNavigations()); - Assert.Collection(e.GetNavigations(), + Assert.Collection( + e.GetNavigations(), n => { Assert.Equal("TableB", n.TargetEntityType.Name); @@ -714,11 +735,13 @@ ALTER TABLE [dbo].[Properties] CHECK CONSTRAINT [FK_Properties_Listings] e => { Assert.Equal("Property", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("IdA", p.Name), p => Assert.Equal("IdB", p.Name), p => Assert.Equal("IdC", p.Name)); - Assert.Collection(e.GetKeys(), + Assert.Collection( + e.GetKeys(), k => { Assert.Collection( @@ -733,10 +756,12 @@ ALTER TABLE [dbo].[Properties] CHECK CONSTRAINT [FK_Properties_Listings] k => { Assert.Equal("TableAb", k.PrincipalEntityType.Name); - Assert.Collection(k.Properties, + Assert.Collection( + k.Properties, p => Assert.Equal("IdA", p.Name), p => Assert.Equal("IdB", p.Name)); - Assert.Collection(k.PrincipalKey.Properties, + Assert.Collection( + k.PrincipalKey.Properties, p => Assert.Equal("IdA", p.Name), p => Assert.Equal("IdB", p.Name)); Assert.False(k.IsUnique); @@ -744,15 +769,18 @@ ALTER TABLE [dbo].[Properties] CHECK CONSTRAINT [FK_Properties_Listings] k => { Assert.Equal("AttributesByCategory", k.PrincipalEntityType.Name); - Assert.Collection(k.Properties, + Assert.Collection( + k.Properties, p => Assert.Equal("IdB", p.Name), p => Assert.Equal("IdC", p.Name)); - Assert.Collection(k.PrincipalKey.Properties, + Assert.Collection( + k.PrincipalKey.Properties, p => Assert.Equal("IdB", p.Name), p => Assert.Equal("IdC", p.Name)); Assert.False(k.IsUnique); }); - Assert.Collection(e.GetIndexes(), + Assert.Collection( + e.GetIndexes(), i => { Assert.Collection( @@ -761,7 +789,8 @@ ALTER TABLE [dbo].[Properties] CHECK CONSTRAINT [FK_Properties_Listings] p => Assert.Equal("IdC", p.Name)); Assert.True(i.IsUnique); }); - Assert.Collection(e.GetNavigations(), + Assert.Collection( + e.GetNavigations(), n => { Assert.Equal("AttributesByCategory", n.TargetEntityType.Name); @@ -779,10 +808,12 @@ ALTER TABLE [dbo].[Properties] CHECK CONSTRAINT [FK_Properties_Listings] e => { Assert.Equal("TableAb", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("IdA", p.Name), p => Assert.Equal("IdB", p.Name)); - Assert.Collection(e.GetKeys(), + Assert.Collection( + e.GetKeys(), k => { Assert.Collection(k.Properties, p => Assert.Equal("IdA", p.Name)); @@ -793,20 +824,23 @@ ALTER TABLE [dbo].[Properties] CHECK CONSTRAINT [FK_Properties_Listings] Assert.Collection(k.Properties, p => Assert.Equal("IdA", p.Name), p => Assert.Equal("IdB", p.Name)); Assert.False(k.IsPrimaryKey()); }); - Assert.Collection(e.GetForeignKeys(), k => - { - Assert.Equal("TableB", k.PrincipalEntityType.Name); - Assert.Collection(k.Properties, p => Assert.Equal("IdB", p.Name)); - Assert.Collection(k.PrincipalKey.Properties, p => Assert.Equal("IdB", p.Name)); - Assert.False(k.IsUnique); - }); - Assert.Collection(e.GetIndexes(), + Assert.Collection( + e.GetForeignKeys(), k => + { + Assert.Equal("TableB", k.PrincipalEntityType.Name); + Assert.Collection(k.Properties, p => Assert.Equal("IdB", p.Name)); + Assert.Collection(k.PrincipalKey.Properties, p => Assert.Equal("IdB", p.Name)); + Assert.False(k.IsUnique); + }); + Assert.Collection( + e.GetIndexes(), i => { Assert.Collection(i.Properties, p => Assert.Equal("IdA", p.Name), p => Assert.Equal("IdB", p.Name)); Assert.True(i.IsUnique); }); - Assert.Collection(e.GetNavigations(), + Assert.Collection( + e.GetNavigations(), n => { Assert.Equal("TableB", n.TargetEntityType.Name); @@ -828,7 +862,8 @@ ALTER TABLE [dbo].[Properties] CHECK CONSTRAINT [FK_Properties_Listings] Assert.Collection(e.GetKeys(), k => Assert.Collection(k.Properties, p => Assert.Equal("IdB", p.Name))); Assert.Empty(e.GetForeignKeys()); Assert.Empty(e.GetIndexes()); - Assert.Collection(e.GetNavigations(), + Assert.Collection( + e.GetNavigations(), n => { Assert.Equal("AttributesByCategory", n.TargetEntityType.Name); @@ -850,7 +885,8 @@ ALTER TABLE [dbo].[Properties] CHECK CONSTRAINT [FK_Properties_Listings] Assert.Collection(e.GetKeys(), k => Assert.Collection(k.Properties, p => Assert.Equal("IdC", p.Name))); Assert.Empty(e.GetForeignKeys()); Assert.Empty(e.GetIndexes()); - Assert.Collection(e.GetNavigations(), + Assert.Collection( + e.GetNavigations(), n => { Assert.Equal("AttributesByCategory", n.TargetEntityType.Name); @@ -895,10 +931,12 @@ CONSTRAINT [PK_LinkToBBlogPPosts] PRIMARY KEY (LinkId1, LinkId2), { Assert.Equal("dbo", t.Schema); Assert.Equal("BBlogPPosts", t.Name); - Assert.Collection(t.Columns, + Assert.Collection( + t.Columns, c => Assert.Equal("BBlogId", c.Name), c => Assert.Equal("PPostId", c.Name)); - Assert.Collection(t.ForeignKeys, + Assert.Collection( + t.ForeignKeys, c => { Assert.Equal("BBlogs", c.PrincipalTable.Name); @@ -922,10 +960,12 @@ CONSTRAINT [PK_LinkToBBlogPPosts] PRIMARY KEY (LinkId1, LinkId2), { Assert.Equal("dbo", t.Schema); Assert.Equal("LinkToBBlogPPosts", t.Name); - Assert.Collection(t.Columns, + Assert.Collection( + t.Columns, c => Assert.Equal("LinkId1", c.Name), c => Assert.Equal("LinkId2", c.Name)); - Assert.Collection(t.ForeignKeys, + Assert.Collection( + t.ForeignKeys, c => { Assert.Equal("BBlogPPosts", c.PrincipalTable.Name); @@ -958,10 +998,12 @@ CONSTRAINT [PK_LinkToBBlogPPosts] PRIMARY KEY (LinkId1, LinkId2), e => { Assert.Equal("BblogPpost", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("BblogId", p.Name), p => Assert.Equal("PpostId", p.Name)); - Assert.Collection(e.GetForeignKeys(), + Assert.Collection( + e.GetForeignKeys(), k => { Assert.Equal("Bblog", k.PrincipalEntityType.Name); @@ -977,7 +1019,8 @@ CONSTRAINT [PK_LinkToBBlogPPosts] PRIMARY KEY (LinkId1, LinkId2), Assert.False(k.IsUnique); }); Assert.Empty(e.GetSkipNavigations()); - Assert.Collection(e.GetNavigations(), + Assert.Collection( + e.GetNavigations(), p => Assert.Equal("Bblog", p.Name), p => Assert.Equal("LinkToBblogPpost", p.Name), p => Assert.Equal("Ppost", p.Name)); @@ -985,18 +1028,22 @@ CONSTRAINT [PK_LinkToBBlogPPosts] PRIMARY KEY (LinkId1, LinkId2), e => { Assert.Equal("LinkToBblogPpost", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("LinkId1", p.Name), p => Assert.Equal("LinkId2", p.Name)); - Assert.Collection(e.GetForeignKeys(), + Assert.Collection( + e.GetForeignKeys(), k => { Assert.Equal("BblogPpost", k.PrincipalEntityType.Name); Assert.Equal("LinkToBblogPpost", k.DeclaringEntityType.Name); - Assert.Collection(k.Properties, + Assert.Collection( + k.Properties, p => Assert.Equal("LinkId1", p.Name), p => Assert.Equal("LinkId2", p.Name)); - Assert.Collection(k.PrincipalKey.Properties, + Assert.Collection( + k.PrincipalKey.Properties, p => Assert.Equal("BblogId", p.Name), p => Assert.Equal("PpostId", p.Name)); Assert.True(k.IsUnique); @@ -1050,7 +1097,7 @@ public void Filter_schemas() Assert.Equal(1, table.UniqueConstraints.Count); Assert.Empty(table.ForeignKeys); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, @@ -1077,7 +1124,7 @@ public void Filter_tables() Assert.Equal(1, table.UniqueConstraints.Count); Assert.Empty(table.ForeignKeys); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, @@ -1104,7 +1151,7 @@ public void Filter_tables_with_quote_in_name() Assert.Equal(1, table.UniqueConstraints.Count); Assert.Empty(table.ForeignKeys); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, @@ -1131,7 +1178,7 @@ public void Filter_tables_with_qualified_name() Assert.Equal(1, table.UniqueConstraints.Count); Assert.Empty(table.ForeignKeys); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, @@ -1160,7 +1207,7 @@ public void Filter_tables_with_schema_qualified_name1() Assert.Equal(1, table.UniqueConstraints.Count); Assert.Empty(table.ForeignKeys); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, @@ -1191,7 +1238,7 @@ public void Filter_tables_with_schema_qualified_name2() Assert.Equal(1, table.UniqueConstraints.Count); Assert.Empty(table.ForeignKeys); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, @@ -1222,7 +1269,7 @@ public void Filter_tables_with_schema_qualified_name3() Assert.Equal(1, table.UniqueConstraints.Count); Assert.Empty(table.ForeignKeys); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, @@ -1253,7 +1300,7 @@ public void Filter_tables_with_schema_qualified_name4() Assert.Equal(1, table.UniqueConstraints.Count); Assert.Empty(table.ForeignKeys); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, @@ -1337,7 +1384,7 @@ FOREIGN KEY (ForeignKeyId1, ForeignKeyId2) REFERENCES [db2].[PrincipalTable](UC1 // ReSharper disable once PossibleNullReferenceException Assert.Single(dependentTable.ForeignKeys); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetSequences(), @@ -1369,15 +1416,18 @@ FOREIGN KEY (ForeignKeyId1, ForeignKeyId2) REFERENCES [db2].[PrincipalTable](UC1 Assert.Equal("PrincipalTable", n.Name); Assert.False(n.IsCollection); }); - Assert.Collection(e.GetForeignKeys(), + Assert.Collection( + e.GetForeignKeys(), k => { Assert.Equal("PrincipalTable", k.PrincipalEntityType.Name); Assert.Equal("DependentTable", k.DeclaringEntityType.Name); - Assert.Collection(k.Properties, + Assert.Collection( + k.Properties, p => Assert.Equal("ForeignKeyId1", p.Name), p => Assert.Equal("ForeignKeyId2", p.Name)); - Assert.Collection(k.PrincipalKey.Properties, + Assert.Collection( + k.PrincipalKey.Properties, p => Assert.Equal("Uc1", p.Name), p => Assert.Equal("Uc2", p.Name)); Assert.False(k.IsUnique); @@ -1423,14 +1473,16 @@ FOREIGN KEY (ForeignKeyId1, ForeignKeyId2) REFERENCES [db2].[PrincipalTable](UC1 e.GetIndexes(), i => { - Assert.Collection(i.Properties, + Assert.Collection( + i.Properties, p => Assert.Equal("Index2", p.Name), p => Assert.Equal("Index1", p.Name)); Assert.False(i.IsUnique); }, i => { - Assert.Collection(i.Properties, + Assert.Collection( + i.Properties, p => Assert.Equal("Uc1", p.Name), p => Assert.Equal("Uc2", p.Name)); Assert.True(i.IsUnique); @@ -1576,7 +1628,7 @@ CONSTRAINT [PK_Blogs] PRIMARY KEY NONCLUSTERED ([Id]) // ReSharper disable once PossibleNullReferenceException Assert.True((bool)table[SqlServerAnnotationNames.MemoryOptimized]!); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE [Blogs]"); @@ -1594,7 +1646,8 @@ [UiText] NVARCHAR(1000) NOT NULL Enumerable.Empty(), (dbModel, scaffoldingFactory) => { - Assert.Collection(dbModel.Tables, + Assert.Collection( + dbModel.Tables, t => { Assert.Equal("UIText", t.Name); @@ -1604,9 +1657,10 @@ [UiText] NVARCHAR(1000) NOT NULL c => Assert.Equal("UiText", c.Name)); }); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); - Assert.Collection(model.GetEntityTypes(), + Assert.Collection( + model.GetEntityTypes(), e => { Assert.Equal("Uitext", e.Name); @@ -1657,7 +1711,7 @@ Name nvarchar(100) NOT NULL, Assert.Single(table.Columns.Where(c => c.Comment == "Blog.Id column comment.")); Assert.Single(table.Columns.Where(c => c.Comment != null)); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -1666,7 +1720,8 @@ Name nvarchar(100) NOT NULL, Assert.Equal("dbo", e.GetSchema()); Assert.Equal("Blog", e.Name); Assert.Equal("Blogs", e.GetTableName()); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("Id", p.Name), p => Assert.Equal("Name", p.Name)); Assert.Empty(e.GetIndexes()); @@ -1704,7 +1759,7 @@ CREATE VIEW [dbo].[BlogsView] Assert.Single(table.Columns.Where(c => c.Name == "Id")); Assert.Single(table.Columns.Where(c => c.Name == "Name")); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -1713,7 +1768,8 @@ CREATE VIEW [dbo].[BlogsView] Assert.Equal("dbo", e.GetViewSchema()); Assert.Equal("BlogsView", e.Name); Assert.Equal("BlogsView", e.GetViewName()); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("Id", p.Name), p => Assert.Equal("Name", p.Name)); Assert.Empty(e.GetIndexes()); @@ -1743,18 +1799,19 @@ Id int PRIMARY KEY Assert.Null(pk[SqlServerAnnotationNames.Clustered]); Assert.Equal(["Id"], pk.Columns.Select(ic => ic.Name).ToList()); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), e => { Assert.Equal("PrimaryKeyTable", e.Name); - Assert.Collection(e.GetProperties(), p => - { - Assert.Equal("Id", p.Name); - Assert.Equal(ValueGenerated.Never, p.ValueGenerated); - }); + Assert.Collection( + e.GetProperties(), p => + { + Assert.Equal("Id", p.Name); + Assert.Equal(ValueGenerated.Never, p.ValueGenerated); + }); Assert.Collection(e.GetKeys(), k => Assert.Equal("Id", k.Properties.Single().Name)); Assert.Empty(e.GetIndexes()); Assert.Empty(e.GetForeignKeys()); @@ -1788,14 +1845,15 @@ CREATE TABLE UniqueConstraint ( Assert.Null(uniqueConstraint[SqlServerAnnotationNames.Clustered]); Assert.Equal(["Name"], uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), e => { Assert.Equal("UniqueConstraint", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("Id", p.Name), p => Assert.Equal("IndexProperty", p.Name), p => Assert.Equal("Name", p.Name)); @@ -1848,14 +1906,15 @@ CREATE TABLE IndexTable ( Assert.Single(table.Indexes.Where(c => c.Name == "IX_NAME")); Assert.Single(table.Indexes.Where(c => c.Name == "IX_INDEX")); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), e => { Assert.Equal("IndexTable", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("Id", p.Name), p => Assert.Equal("IndexProperty", p.Name), p => Assert.Equal("Name", p.Name)); @@ -1917,14 +1976,15 @@ IndexProperty int Assert.Equal(50, index[SqlServerAnnotationNames.FillFactor]); }); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), e => { Assert.Equal("IndexTable", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("Id", p.Name), p => Assert.Equal("IndexProperty", p.Name)); Assert.Empty(e.GetKeys()); @@ -1995,17 +2055,19 @@ FOREIGN KEY (Id) REFERENCES PrincipalTable(Id) ON DELETE NO ACTION, Assert.Equal(["Id"], secondFk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.NoAction, secondFk.OnDelete); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), e => { Assert.Equal("FirstDependent", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("Id", p.Name), p => Assert.Equal("ForeignKeyId", p.Name)); - Assert.Collection(e.GetForeignKeys(), + Assert.Collection( + e.GetForeignKeys(), k => { Assert.Equal("PrincipalTable", k.PrincipalEntityType.Name); @@ -2023,7 +2085,8 @@ FOREIGN KEY (Id) REFERENCES PrincipalTable(Id) ON DELETE NO ACTION, Assert.Collection(e.GetProperties(), p => Assert.Equal("Id", p.Name)); Assert.Empty(e.GetForeignKeys()); Assert.Empty(e.GetSkipNavigations()); - Assert.Collection(e.GetNavigations(), + Assert.Collection( + e.GetNavigations(), n => { Assert.Equal("FirstDependents", n.Name); @@ -2039,7 +2102,8 @@ FOREIGN KEY (Id) REFERENCES PrincipalTable(Id) ON DELETE NO ACTION, { Assert.Equal("SecondDependent", e.Name); Assert.Collection(e.GetProperties(), p => Assert.Equal("Id", p.Name)); - Assert.Collection(e.GetForeignKeys(), + Assert.Collection( + e.GetForeignKeys(), k => { Assert.Equal("PrincipalTable", k.PrincipalEntityType.Name); @@ -2095,14 +2159,15 @@ AFTER INSERT AS t => Assert.Equal("Trigger1", t.Name), t => Assert.Equal("Trigger2", t.Name)); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), e => { Assert.Equal("SomeTable", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("Id", p.Name), p => Assert.Equal("Bar", p.Name), p => Assert.Equal("Baz", p.Name), @@ -2110,7 +2175,8 @@ AFTER INSERT AS Assert.Empty(e.GetForeignKeys()); Assert.Empty(e.GetSkipNavigations()); Assert.Empty(e.GetNavigations()); - Assert.Collection(e.GetDeclaredTriggers(), + Assert.Collection( + e.GetDeclaredTriggers(), t => Assert.Equal("Trigger1", t.ModelName), t => Assert.Equal("Trigger2", t.ModelName)); }); @@ -2128,8 +2194,14 @@ AFTER INSERT AS [InlineData("event", true, true, "_event", "Id", "_class", "strings", "_", "_1")] public void Table_name_with_pluralized_keywords( string tableName, - bool useDatabaseNames, bool singularize, - string entityTypeName, string idName, string className, string stringsName, string oneName, string plusName) + bool useDatabaseNames, + bool singularize, + string entityTypeName, + string idName, + string className, + string stringsName, + string oneName, + string plusName) => Test( @$" CREATE TABLE [{tableName}] ( @@ -2143,11 +2215,13 @@ public void Table_name_with_pluralized_keywords( Enumerable.Empty(), (dbModel, scaffoldingFactory) => { - Assert.Collection(dbModel.Tables, + Assert.Collection( + dbModel.Tables, t => { Assert.Equal(tableName, t.Name); - Assert.Collection(t.Columns, + Assert.Collection( + t.Columns, c => Assert.Equal("Id", c.Name), c => Assert.Equal("class", c.Name), c => Assert.Equal("strings", c.Name), @@ -2155,9 +2229,11 @@ public void Table_name_with_pluralized_keywords( c => Assert.Equal("+", c.Name)); }); - var model = scaffoldingFactory.Create(dbModel, new() { UseDatabaseNames = useDatabaseNames, NoPluralize = !singularize }); + var model = scaffoldingFactory.Create( + dbModel, new ModelReverseEngineerOptions { UseDatabaseNames = useDatabaseNames, NoPluralize = !singularize }); - Assert.Collection(model.GetEntityTypes(), + Assert.Collection( + model.GetEntityTypes(), e => { Assert.Equal(entityTypeName, e.Name); @@ -2199,14 +2275,15 @@ typeAliasColumn dbo.TestTypeAlias NULL // ReSharper disable once PossibleNullReferenceException Assert.Equal("nvarchar(max)", column.StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), e => { Assert.Equal("TypeAlias", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("Id", p.Name), p => { @@ -2242,14 +2319,15 @@ typeAliasColumn sysname Assert.Equal("nvarchar(128)", column.StoreType); Assert.False(column.IsNullable); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), e => { Assert.Equal("TypeAlias", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("Id", p.Name), p => { @@ -2292,7 +2370,7 @@ numericDefaultPrecisionColumn numeric(38, 5) NOT NULL, Assert.Equal("numeric(18, 2)", columns.Single(c => c.Name == "numericDefaultColumn").StoreType); Assert.Equal("numeric(38, 5)", columns.Single(c => c.Name == "numericDefaultPrecisionColumn").StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -2388,7 +2466,7 @@ nationalCharacterVaryingMaxColumn national char varying(max) NULL Assert.Equal("nvarchar(max)", columns.Single(c => c.Name == "nationalCharVaryingMaxColumn").StoreType); Assert.Equal("nvarchar(max)", columns.Single(c => c.Name == "nationalCharacterVaryingMaxColumn").StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -2470,7 +2548,7 @@ jsonTypeColumn json NULL Assert.Equal("json", columns.Single(c => c.Name == "jsonTypeColumn").StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -2533,7 +2611,7 @@ nationalCharacterVarying188Column national char varying(188) NULL, Assert.Equal("nvarchar(177)", columns.Single(c => c.Name == "nationalCharVarying177Column").StoreType); Assert.Equal("nvarchar(188)", columns.Single(c => c.Name == "nationalCharacterVarying188Column").StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -2671,7 +2749,7 @@ varbinaryColumn varbinary(8000) Assert.Equal("varbinary(8000)", columns.Single(c => c.Name == "binaryVaryingColumn").StoreType); Assert.Equal("varbinary(8000)", columns.Single(c => c.Name == "varbinaryColumn").StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -2726,7 +2804,7 @@ charColumn char(8000) Assert.Equal("char(8000)", columns.Single(c => c.Name == "charColumn").StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -2767,7 +2845,7 @@ characterColumn character(8000) Assert.Equal("char(8000)", columns.Single(c => c.Name == "characterColumn").StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -2812,7 +2890,7 @@ varcharColumn varchar(8000) Assert.Equal("varchar(8000)", columns.Single(c => c.Name == "characterVaryingColumn").StoreType); Assert.Equal("varchar(8000)", columns.Single(c => c.Name == "varcharColumn").StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -2869,7 +2947,7 @@ nationalCharColumn national char(4000), Assert.Equal("nchar(4000)", columns.Single(c => c.Name == "nationalCharColumn").StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -2910,7 +2988,7 @@ nationalCharacterColumn national character(4000), Assert.Equal("nchar(4000)", columns.Single(c => c.Name == "nationalCharacterColumn").StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -2951,7 +3029,7 @@ ncharColumn nchar(4000), Assert.Equal("nchar(4000)", columns.Single(c => c.Name == "ncharColumn").StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -2996,7 +3074,7 @@ nvarcharColumn nvarchar(4000) Assert.Equal("nvarchar(4000)", columns.Single(c => c.Name == "nationalCharacterVaryingColumn").StoreType); Assert.Equal("nvarchar(4000)", columns.Single(c => c.Name == "nvarcharColumn").StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -3057,7 +3135,7 @@ datetimeoffset5Column datetimeoffset(5) NULL, Assert.Equal("datetime2(4)", columns.Single(c => c.Name == "datetime24Column").StoreType); Assert.Equal("datetimeoffset(5)", columns.Single(c => c.Name == "datetimeoffset5Column").StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -3137,7 +3215,7 @@ CREATE TABLE OneLengthColumns ( Assert.Equal("varbinary(1)", columns.Single(c => c.Name == "varbinaryColumn").StoreType); Assert.Equal("varchar(1)", columns.Single(c => c.Name == "varcharColumn").StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -3310,7 +3388,7 @@ CREATE TABLE RowversionType ( "rowversion", dbModel.Tables.Single(t => t.Name == "RowversionType").Columns.Single(c => c.Name == "rowversionColumn").StoreType); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -3493,7 +3571,7 @@ ComputedValue AS GETDATE(), Assert.Equal("([A]+[B])", sumOfAAndBPersisted.ComputedColumnSql); Assert.True(sumOfAAndBPersisted.IsStored); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -3575,7 +3653,7 @@ B bit DEFAULT ((CONVERT([bit],(CHOOSE(1, 0, 1, 2))))), Assert.Equal("(CONVERT([bit],choose((1),(0),(1),(2))))", column.DefaultValueSql); Assert.Null(column.FindAnnotation(RelationalAnnotationNames.DefaultValue)); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -3643,9 +3721,8 @@ J int DEFAULT ( ( CONVERT([int],((-8))))), Assert.Equal("(CONVERT([int],(-8)))", column.DefaultValueSql); Assert.Equal(-8, column.DefaultValue); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); - }, "DROP TABLE MyTable;"); @@ -3677,7 +3754,7 @@ C smallint DEFAULT ((CONVERT ( ""smallint"", ( (-7) ) ))), Assert.Equal("(CONVERT([smallint],(-7)))", column.DefaultValueSql); Assert.Equal((short)-7, column.DefaultValue); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -3710,9 +3787,8 @@ C bigint DEFAULT ((CONVERT ( ""bigint"", ( (-7) ) ))), Assert.Equal("(CONVERT([bigint],(-7)))", column.DefaultValueSql); Assert.Equal((long)-7, column.DefaultValue); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); - }, "DROP TABLE MyTable;"); @@ -3744,7 +3820,7 @@ C tinyint DEFAULT ((CONVERT ( ""tinyint"", ( (7) ) ))), Assert.Equal("(CONVERT([tinyint],(7)))", column.DefaultValueSql); Assert.Equal((byte)7, column.DefaultValue); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -3772,7 +3848,7 @@ B int DEFAULT ((CONVERT([int],(CHOOSE(1, 0, 1, 2))))), Assert.Equal("(CONVERT([int],choose((1),(0),(1),(2))))", column.DefaultValueSql); Assert.Null(column.FindAnnotation(RelationalAnnotationNames.DefaultValue)); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -3810,7 +3886,7 @@ D float DEFAULT ((CONVERT ( ""float"", ( (1.1234) ) ))), Assert.Equal("(CONVERT([float],(1.1234)))", column.DefaultValueSql); Assert.Equal(1.1234, column.DefaultValue); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -3848,7 +3924,7 @@ D real DEFAULT ((CONVERT ( ""real"", ( (1.1234) ) ))), Assert.Equal("(CONVERT([real],(1.1234)))", column.DefaultValueSql); Assert.Equal((float)1.1234, column.DefaultValue); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -3886,7 +3962,7 @@ D decimal DEFAULT ((CONVERT ( ""decimal"", ( (1.1234) ) ))), Assert.Equal("(CONVERT([decimal],(1.1234)))", column.DefaultValueSql); Assert.Equal((decimal)1.1234, column.DefaultValue); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -3939,7 +4015,7 @@ G bit DEFAULT ((CONVERT ( ""bit"", ( ('tRUE') ) ))), Assert.Equal("(CONVERT([bit],'tRUE'))", column.DefaultValueSql); Assert.Equal(true, column.DefaultValue); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -3979,7 +4055,7 @@ D datetime DEFAULT (CONVERT(datetime,'12:12:12')), Assert.Equal(12, ((DateTime)column.DefaultValue!).Minute); Assert.Equal(12, ((DateTime)column.DefaultValue!).Second); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -4012,7 +4088,7 @@ C datetime2 DEFAULT ((CONVERT([datetime2],('12-01-16 12:32')))), Assert.Equal("(CONVERT([datetime2],'12-01-16 12:32'))", column.DefaultValueSql); Assert.Null(column.FindAnnotation(RelationalAnnotationNames.DefaultValue)); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -4040,7 +4116,7 @@ B date DEFAULT (CONVERT([date],('1973-09-03T01:02:03'))), Assert.Equal("(CONVERT([date],'1973-09-03T01:02:03'))", column.DefaultValueSql); Assert.Equal(new DateOnly(1973, 9, 3), column.DefaultValue); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -4068,7 +4144,7 @@ B time DEFAULT (CONVERT([time],('1973-09-03T01:02:03'))), Assert.Equal("(CONVERT([time],'1973-09-03T01:02:03'))", column.DefaultValueSql); Assert.Equal(new TimeOnly(1, 2, 3), column.DefaultValue); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -4100,7 +4176,7 @@ B datetimeoffset DEFAULT (CONVERT([datetimeoffset],('1973-09-03T01:02:03'))), new DateTime(1973, 9, 3, 1, 2, 3, 0, DateTimeKind.Unspecified), ((DateTimeOffset)column.DefaultValue!).DateTime); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -4128,7 +4204,7 @@ B uniqueidentifier DEFAULT (CONVERT([uniqueidentifier],('0E984725-C51C-4BF4-9960 Assert.Equal("(CONVERT([uniqueidentifier],'0E984725-C51C-4BF4-9960-E1C80E27ABA0'))", column.DefaultValueSql); Assert.Equal(new Guid("0E984725-C51C-4BF4-9960-E1C80E27ABA0"), column.DefaultValue); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -4156,7 +4232,7 @@ B uniqueidentifier DEFAULT NEWSEQUENTIALID(), Assert.Equal("(newsequentialid())", column.DefaultValueSql); Assert.Null(column.FindAnnotation(RelationalAnnotationNames.DefaultValue)); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -4209,7 +4285,7 @@ G varchar(max) DEFAULT (CONVERT(character varying(max),('Toasted teacakes'))), Assert.Equal("(CONVERT([varchar](max),'Toasted teacakes'))", column.DefaultValueSql); Assert.Equal("Toasted teacakes", column.DefaultValue); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE MyTable;"); @@ -4237,7 +4313,7 @@ ComputedValue AS GETDATE(), Assert.Null(columns.Single(c => c.Name == "ComputedValue").ValueGenerated); Assert.Equal(ValueGenerated.OnAddOrUpdate, columns.Single(c => c.Name == "rowversionColumn").ValueGenerated); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -4297,7 +4373,7 @@ CREATE TABLE RowVersionTable ( Assert.True((bool)columns.Single(c => c.Name == "rowversionColumn")[ScaffoldingAnnotationNames.ConcurrencyToken]!); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -4322,7 +4398,6 @@ CREATE TABLE RowVersionTable ( Assert.Empty(e.GetNavigations()); Assert.Empty(e.GetSkipNavigations()); }); - }, "DROP TABLE RowVersionTable;"); @@ -4344,7 +4419,7 @@ NonNullString nvarchar(max) NOT NULL, Assert.True(columns.Single(c => c.Name == "NullableInt").IsNullable); Assert.False(columns.Single(c => c.Name == "NonNullString").IsNullable); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -4395,7 +4470,7 @@ NonDefaultCollation nvarchar(max) COLLATE German_PhoneBook_CI_AS, Assert.Null(columns.Single(c => c.Name == "DefaultCollation").Collation); Assert.Equal("German_PhoneBook_CI_AS", columns.Single(c => c.Name == "NonDefaultCollation").Collation); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -4446,7 +4521,7 @@ NonSparse nvarchar(max) NULL Assert.True((bool)columns.Single(c => c.Name == "Sparse")[SqlServerAnnotationNames.Sparse]!); Assert.Null(columns.Single(c => c.Name == "NonSparse")[SqlServerAnnotationNames.Sparse]); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -4508,7 +4583,7 @@ PERIOD FOR SYSTEM_TIME(SysStartTime, SysEndTime) Assert.DoesNotContain(columns, c => c.Name == "SysEndTime"); Assert.Equal("IX_HiddenColumnsTable_3", dbModel.Tables.Single().Indexes.Single().Name); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -4573,7 +4648,7 @@ PERIOD FOR SYSTEM_TIME(SysStartTime, SysEndTime) Assert.DoesNotContain(columns, c => c.Name == "SysEndTime"); Assert.Equal("IX_HiddenColumnsTable_3", dbModel.Tables.Single().Indexes.Single().Name); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -4633,7 +4708,7 @@ PRIMARY KEY (Id2, Id1) Assert.StartsWith("PK__Composit", pk.Name); Assert.Equal(["Id2", "Id1"], pk.Columns.Select(ic => ic.Name).ToList()); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -4641,9 +4716,11 @@ PRIMARY KEY (Id2, Id1) { Assert.Equal("dbo", e.GetSchema()); Assert.Equal("CompositePrimaryKeyTable", e.Name); - Assert.Collection(e.GetKeys(), k => Assert.Collection(k.Properties, - p => Assert.Equal("Id2", p.Name), - p => Assert.Equal("Id1", p.Name))); + Assert.Collection( + e.GetKeys(), k => Assert.Collection( + k.Properties, + p => Assert.Equal("Id2", p.Name), + p => Assert.Equal("Id1", p.Name))); Assert.Collection( e.GetProperties(), p => @@ -4686,7 +4763,7 @@ CREATE TABLE NonClusteredPrimaryKeyTable ( Assert.False((bool)pk[SqlServerAnnotationNames.Clustered]!); Assert.Equal(["Id1"], pk.Columns.Select(ic => ic.Name).ToList()); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -4694,11 +4771,12 @@ CREATE TABLE NonClusteredPrimaryKeyTable ( { Assert.Equal("dbo", e.GetSchema()); Assert.Equal("NonClusteredPrimaryKeyTable", e.Name); - Assert.Collection(e.GetKeys(), k => - { - Assert.False(k.IsClustered()); - Assert.Collection(k.Properties, p => Assert.Equal("Id1", p.Name)); - }); + Assert.Collection( + e.GetKeys(), k => + { + Assert.False(k.IsClustered()); + Assert.Collection(k.Properties, p => Assert.Equal("Id1", p.Name)); + }); Assert.Collection(e.GetProperties(), p => Assert.Equal("Id1", p.Name), p => Assert.Equal("Id2", p.Name)); Assert.Empty(e.GetForeignKeys()); Assert.Empty(e.GetIndexes()); @@ -4730,7 +4808,7 @@ CREATE TABLE NonClusteredPrimaryKeyTableWithClusteredIndex ( Assert.False((bool)pk[SqlServerAnnotationNames.Clustered]!); Assert.Equal(["Id1"], pk.Columns.Select(ic => ic.Name).ToList()); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE NonClusteredPrimaryKeyTableWithClusteredIndex;"); @@ -4756,7 +4834,7 @@ CONSTRAINT UK_Clustered UNIQUE CLUSTERED ( Id2 ), Assert.False((bool)pk[SqlServerAnnotationNames.Clustered]!); Assert.Equal(["Id1"], pk.Columns.Select(ic => ic.Name).ToList()); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE NonClusteredPrimaryKeyTableWithClusteredConstraint;"); @@ -4782,7 +4860,7 @@ CONSTRAINT MyPK PRIMARY KEY ( Id2 ), Assert.Null(pk[SqlServerAnnotationNames.Clustered]); Assert.Equal(["Id2"], pk.Columns.Select(ic => ic.Name).ToList()); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE PrimaryKeyName;"); @@ -4809,7 +4887,7 @@ [Id] ASC Assert.Equal(["Id"], pk!.Columns.Select(kc => kc.Name).ToList()); Assert.Equal(80, pk[SqlServerAnnotationNames.FillFactor]); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE PrimaryKeyFillFactor;"); @@ -4839,7 +4917,7 @@ CONSTRAINT UX UNIQUE (Id2, Id1) Assert.Equal("UX", uniqueConstraint.Name); Assert.Equal(["Id2", "Id1"], uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE CompositeUniqueConstraintTable;"); @@ -4865,7 +4943,7 @@ CREATE TABLE ClusteredUniqueConstraintTable ( Assert.True((bool)uniqueConstraint[SqlServerAnnotationNames.Clustered]!); Assert.Equal(["Id2"], uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE ClusteredUniqueConstraintTable;"); @@ -4891,7 +4969,7 @@ CONSTRAINT MyUC UNIQUE ( Id2 ), Assert.Equal("MyUC", uniqueConstraint.Name); Assert.Equal(["Id2"], uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE UniqueConstraintName;"); @@ -4919,7 +4997,7 @@ [SomethingElse] ASC Assert.Equal(["Something", "SomethingElse"], uniqueConstraint!.Columns.Select(kc => kc.Name).ToList()); Assert.Equal(80, uniqueConstraint[SqlServerAnnotationNames.FillFactor]); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE UniqueConstraintFillFactor;"); @@ -4950,7 +5028,7 @@ CREATE TABLE CompositeIndexTable ( Assert.Equal("IX_COMPOSITE", index.Name); Assert.Equal(["Id2", "Id1"], index.Columns.Select(ic => ic.Name).ToList()); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -4961,14 +5039,15 @@ CREATE TABLE CompositeIndexTable ( Assert.Empty(e.GetKeys()); Assert.Collection(e.GetProperties(), p => Assert.Equal("Id1", p.Name), p => Assert.Equal("Id2", p.Name)); Assert.Empty(e.GetForeignKeys()); - Assert.Collection(e.GetIndexes(), k => - { - Assert.Collection( - k.Properties, - p => Assert.Equal("Id2", p.Name), - p => Assert.Equal("Id1", p.Name)); - Assert.False(k.IsUnique); - }); + Assert.Collection( + e.GetIndexes(), k => + { + Assert.Collection( + k.Properties, + p => Assert.Equal("Id2", p.Name), + p => Assert.Equal("Id1", p.Name)); + Assert.False(k.IsUnique); + }); Assert.Empty(e.GetNavigations()); Assert.Empty(e.GetSkipNavigations()); }); @@ -4998,7 +5077,7 @@ CREATE TABLE ClusteredIndexTable ( Assert.True((bool)index[SqlServerAnnotationNames.Clustered]!); Assert.Equal(["Id2"], index.Columns.Select(ic => ic.Name).ToList()); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE ClusteredIndexTable;"); @@ -5027,7 +5106,7 @@ CREATE TABLE UniqueIndexTable ( Assert.Null(index.Filter); Assert.Equal(["Id2"], index.Columns.Select(ic => ic.Name).ToList()); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE UniqueIndexTable;"); @@ -5055,7 +5134,7 @@ CREATE TABLE FilteredIndexTable ( Assert.Equal("([Id2]>(10))", index.Filter); Assert.Equal(["Id2"], index.Columns.Select(ic => ic.Name).ToList()); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE FilteredIndexTable;"); @@ -5076,7 +5155,7 @@ CREATE TABLE HypotheticalIndexTable ( { Assert.Empty(dbModel.Tables.Single().Indexes); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE HypotheticalIndexTable;"); @@ -5097,7 +5176,7 @@ CREATE NONCLUSTERED COLUMNSTORE INDEX ixColumnStore ON ColumnStoreIndexTable ( I { Assert.Empty(dbModel.Tables.Single().Indexes); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE ColumnStoreIndexTable;"); @@ -5121,7 +5200,7 @@ IncludeProperty int Assert.Equal(new[] { "IndexProperty" }, index.Columns.Select(ic => ic.Name).ToList()); Assert.Null(index[SqlServerAnnotationNames.Include]); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE IncludeIndexTable;"); @@ -5149,7 +5228,7 @@ [Name] ASC Assert.Equal(new[] { "Name" }, index.Columns.Select(ic => ic.Name).ToList()); Assert.Equal(80, index[SqlServerAnnotationNames.FillFactor]); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, "DROP TABLE IndexFillFactor;"); @@ -5189,54 +5268,63 @@ FOREIGN KEY (ForeignKeyId1, ForeignKeyId2) REFERENCES PrincipalTable(Id1, Id2) O Assert.Equal(["Id1", "Id2"], fk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, fk.OnDelete); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), e => { Assert.Equal("DependentTable", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("Id", p.Name), p => Assert.Equal("ForeignKeyId1", p.Name), p => Assert.Equal("ForeignKeyId2", p.Name)); Assert.Collection(e.GetKeys(), k => Assert.Equal("Id", k.Properties.Single().Name)); - Assert.Collection(e.GetForeignKeys(), + Assert.Collection( + e.GetForeignKeys(), k => { Assert.Equal("PrincipalTable", k.PrincipalEntityType.Name); Assert.Equal("DependentTable", k.DeclaringEntityType.Name); - Assert.Collection(k.Properties, + Assert.Collection( + k.Properties, p => Assert.Equal("ForeignKeyId1", p.Name), p => Assert.Equal("ForeignKeyId2", p.Name)); - Assert.Collection(k.PrincipalKey.Properties, + Assert.Collection( + k.PrincipalKey.Properties, p => Assert.Equal("Id1", p.Name), p => Assert.Equal("Id2", p.Name)); Assert.False(k.IsUnique); }); Assert.Empty(e.GetSkipNavigations()); - Assert.Collection(e.GetNavigations(), n => - { - Assert.Equal("PrincipalTable", n.Name); - Assert.False(n.IsCollection); - }); + Assert.Collection( + e.GetNavigations(), n => + { + Assert.Equal("PrincipalTable", n.Name); + Assert.False(n.IsCollection); + }); }, e => { Assert.Equal("PrincipalTable", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("Id1", p.Name), p => Assert.Equal("Id2", p.Name)); - Assert.Collection(e.GetKeys(), k => Assert.Collection(k.Properties, - p => Assert.Equal("Id1", p.Name), - p => Assert.Equal("Id2", p.Name))); + Assert.Collection( + e.GetKeys(), k => Assert.Collection( + k.Properties, + p => Assert.Equal("Id1", p.Name), + p => Assert.Equal("Id2", p.Name))); Assert.Empty(e.GetForeignKeys()); Assert.Empty(e.GetSkipNavigations()); - Assert.Collection(e.GetNavigations(), n => - { - Assert.Equal("DependentTables", n.Name); - Assert.True(n.IsCollection); - }); + Assert.Collection( + e.GetNavigations(), n => + { + Assert.Equal("DependentTables", n.Name); + Assert.True(n.IsCollection); + }); }); }, @" @@ -5292,7 +5380,7 @@ FOREIGN KEY (ForeignKeyId2) REFERENCES AnotherPrincipalTable(Id) ON DELETE CASCA Assert.Equal(["Id"], anotherPrincipalFk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, anotherPrincipalFk.OnDelete); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), @@ -5303,21 +5391,24 @@ FOREIGN KEY (ForeignKeyId2) REFERENCES AnotherPrincipalTable(Id) ON DELETE CASCA Assert.Collection(e.GetKeys(), k => Assert.Collection(k.Properties, p => Assert.Equal("Id", p.Name))); Assert.Empty(e.GetForeignKeys()); Assert.Empty(e.GetSkipNavigations()); - Assert.Collection(e.GetNavigations(), n => - { - Assert.Equal("DependentTables", n.Name); - Assert.True(n.IsCollection); - }); + Assert.Collection( + e.GetNavigations(), n => + { + Assert.Equal("DependentTables", n.Name); + Assert.True(n.IsCollection); + }); }, e => { Assert.Equal("DependentTable", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("Id", p.Name), p => Assert.Equal("ForeignKeyId1", p.Name), p => Assert.Equal("ForeignKeyId2", p.Name)); Assert.Collection(e.GetKeys(), k => Assert.Equal("Id", k.Properties.Single().Name)); - Assert.Collection(e.GetForeignKeys(), + Assert.Collection( + e.GetForeignKeys(), k => { Assert.Equal("PrincipalTable", k.PrincipalEntityType.Name); @@ -5335,15 +5426,16 @@ FOREIGN KEY (ForeignKeyId2) REFERENCES AnotherPrincipalTable(Id) ON DELETE CASCA Assert.False(k.IsUnique); }); Assert.Empty(e.GetSkipNavigations()); - Assert.Collection(e.GetNavigations(), n => - { - Assert.Equal("ForeignKeyId1Navigation", n.Name); - Assert.False(n.IsCollection); - }, n => - { - Assert.Equal("ForeignKeyId2Navigation", n.Name); - Assert.False(n.IsCollection); - }); + Assert.Collection( + e.GetNavigations(), n => + { + Assert.Equal("ForeignKeyId1Navigation", n.Name); + Assert.False(n.IsCollection); + }, n => + { + Assert.Equal("ForeignKeyId2Navigation", n.Name); + Assert.False(n.IsCollection); + }); }, e => { @@ -5352,11 +5444,12 @@ FOREIGN KEY (ForeignKeyId2) REFERENCES AnotherPrincipalTable(Id) ON DELETE CASCA Assert.Collection(e.GetKeys(), k => Assert.Collection(k.Properties, p => Assert.Equal("Id", p.Name))); Assert.Empty(e.GetForeignKeys()); Assert.Empty(e.GetSkipNavigations()); - Assert.Collection(e.GetNavigations(), n => - { - Assert.Equal("DependentTables", n.Name); - Assert.True(n.IsCollection); - }); + Assert.Collection( + e.GetNavigations(), n => + { + Assert.Equal("DependentTables", n.Name); + Assert.True(n.IsCollection); + }); }); }, @" @@ -5393,18 +5486,20 @@ FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id2) ON DELETE CASCADE, Assert.Equal(["Id2"], fk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, fk.OnDelete); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), e => { Assert.Equal("DependentTable", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("Id", p.Name), p => Assert.Equal("ForeignKeyId", p.Name)); Assert.Collection(e.GetKeys(), k => Assert.Equal("Id", k.Properties.Single().Name)); - Assert.Collection(e.GetForeignKeys(), + Assert.Collection( + e.GetForeignKeys(), k => { Assert.Equal("PrincipalTable", k.PrincipalEntityType.Name); @@ -5414,34 +5509,39 @@ FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id2) ON DELETE CASCADE, Assert.False(k.IsUnique); }); Assert.Empty(e.GetSkipNavigations()); - Assert.Collection(e.GetNavigations(), n => - { - Assert.Equal("ForeignKey", n.Name); - Assert.False(n.IsCollection); - }); + Assert.Collection( + e.GetNavigations(), n => + { + Assert.Equal("ForeignKey", n.Name); + Assert.False(n.IsCollection); + }); }, e => { Assert.Equal("PrincipalTable", e.Name); Assert.Collection(e.GetProperties(), p => Assert.Equal("Id1", p.Name), p => Assert.Equal("Id2", p.Name)); - Assert.Collection(e.GetKeys(), - k => Assert.Collection(k.Properties, p => - { - Assert.Equal("Id1", p.Name); - Assert.True(p.IsPrimaryKey()); - }), - k => Assert.Collection(k.Properties, p => - { - Assert.Equal("Id2", p.Name); - Assert.False(p.IsPrimaryKey()); - })); + Assert.Collection( + e.GetKeys(), + k => Assert.Collection( + k.Properties, p => + { + Assert.Equal("Id1", p.Name); + Assert.True(p.IsPrimaryKey()); + }), + k => Assert.Collection( + k.Properties, p => + { + Assert.Equal("Id2", p.Name); + Assert.False(p.IsPrimaryKey()); + })); Assert.Empty(e.GetForeignKeys()); Assert.Empty(e.GetSkipNavigations()); - Assert.Collection(e.GetNavigations(), n => - { - Assert.Equal("DependentTables", n.Name); - Assert.True(n.IsCollection); - }); + Assert.Collection( + e.GetNavigations(), n => + { + Assert.Equal("DependentTables", n.Name); + Assert.True(n.IsCollection); + }); }); }, @" @@ -5477,7 +5577,7 @@ CONSTRAINT MYFK FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id) ON DELE Assert.Equal(ReferentialAction.Cascade, fk.OnDelete); Assert.Equal("MYFK", fk.Name); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(2, model.GetEntityTypes().Count()); }, @" @@ -5512,18 +5612,20 @@ FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id) ON DELETE SET NULL, Assert.Equal(["Id"], fk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.SetNull, fk.OnDelete); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Collection( model.GetEntityTypes(), e => { Assert.Equal("DependentTable", e.Name); - Assert.Collection(e.GetProperties(), + Assert.Collection( + e.GetProperties(), p => Assert.Equal("Id", p.Name), p => Assert.Equal("ForeignKeyId", p.Name)); Assert.Collection(e.GetKeys(), k => Assert.Equal("Id", k.Properties.Single().Name)); - Assert.Collection(e.GetForeignKeys(), + Assert.Collection( + e.GetForeignKeys(), k => { Assert.Equal("PrincipalTable", k.PrincipalEntityType.Name); @@ -5534,11 +5636,12 @@ FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id) ON DELETE SET NULL, Assert.False(k.IsUnique); }); Assert.Empty(e.GetSkipNavigations()); - Assert.Collection(e.GetNavigations(), n => - { - Assert.Equal("ForeignKey", n.Name); - Assert.False(n.IsCollection); - }); + Assert.Collection( + e.GetNavigations(), n => + { + Assert.Equal("ForeignKey", n.Name); + Assert.False(n.IsCollection); + }); }, e => { @@ -5547,11 +5650,12 @@ FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id) ON DELETE SET NULL, Assert.Collection(e.GetKeys(), k => Assert.Collection(k.Properties, p => Assert.Equal("Id", p.Name))); Assert.Empty(e.GetForeignKeys()); Assert.Empty(e.GetSkipNavigations()); - Assert.Collection(e.GetNavigations(), n => - { - Assert.Equal("DependentTables", n.Name); - Assert.True(n.IsCollection); - }); + Assert.Collection( + e.GetNavigations(), n => + { + Assert.Equal("DependentTables", n.Name); + Assert.True(n.IsCollection); + }); }); }, @" @@ -5581,7 +5685,7 @@ CREATE TABLE Blank ( SqlServerResources.LogMissingSchema(new TestLogger()).GenerateMessage("MySchema"), message); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Empty(model.GetEntityTypes()); }, "DROP TABLE Blank;"); @@ -5605,7 +5709,7 @@ CREATE TABLE Blank ( SqlServerResources.LogMissingTable(new TestLogger()).GenerateMessage("MyTable"), message); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Empty(model.GetEntityTypes()); }, "DROP TABLE Blank;"); @@ -5634,7 +5738,7 @@ CONSTRAINT MYFK FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id) ON DELE .GenerateMessage( "MYFK", "dbo.DependentTable", "dbo.PrincipalTable"), message); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, @" @@ -5664,7 +5768,7 @@ CONSTRAINT MYFK FOREIGN KEY (Id) REFERENCES PrincipalTable(Id) var table = Assert.Single(dbModel.Tables); Assert.Empty(table.ForeignKeys); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, @" @@ -5710,7 +5814,7 @@ CONSTRAINT MYFK5 FOREIGN KEY (ValueKey) REFERENCES PrincipalTable(Value2), var table = dbModel.Tables.Single(t => t.Name == "DependentTable"); Assert.Equal(4, table.ForeignKeys.Count); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(3, model.GetEntityTypes().Count()); }, @" @@ -5736,7 +5840,7 @@ public void No_warning_missing_view_definition() Assert.Null(message); - var model = scaffoldingFactory.Create(dbModel, new()); + var model = scaffoldingFactory.Create(dbModel, new ModelReverseEngineerOptions()); Assert.Equal(1, model.GetEntityTypes().Count()); }, @" diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/Address.cs b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/Address.cs index b0cd79f9d65..f5ec2817c57 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/Address.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/Address.cs @@ -12,9 +12,7 @@ namespace Microsoft.EntityFrameworkCore.SqlAzure.Model; public class Address { public Address() - { - CustomerAddress = new HashSet(); - } + => CustomerAddress = new HashSet(); public int AddressID { get; set; } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/Product.cs b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/Product.cs index 3feded7114f..80eeaf22467 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/Product.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/Product.cs @@ -12,9 +12,7 @@ namespace Microsoft.EntityFrameworkCore.SqlAzure.Model; public class Product { public Product() - { - OrderDetails = new HashSet(); - } + => OrderDetails = new HashSet(); public int ProductID { get; set; } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/ProductCategory.cs b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/ProductCategory.cs index 7ac2e80f3a9..5761f6d3840 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/ProductCategory.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/ProductCategory.cs @@ -11,9 +11,7 @@ namespace Microsoft.EntityFrameworkCore.SqlAzure.Model; public class ProductCategory { public ProductCategory() - { - Product = new HashSet(); - } + => Product = new HashSet(); public int ProductCategoryID { get; set; } public string Name { get; set; } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/ProductDescription.cs b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/ProductDescription.cs index cd07683389b..81845509c61 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/ProductDescription.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/ProductDescription.cs @@ -12,9 +12,7 @@ namespace Microsoft.EntityFrameworkCore.SqlAzure.Model; public class ProductDescription { public ProductDescription() - { - ProductModelProductDescription = new HashSet(); - } + => ProductModelProductDescription = new HashSet(); public int ProductDescriptionID { get; set; } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/SalesOrder.cs b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/SalesOrder.cs index 405c690f1f0..f2d4b8a35c1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/SalesOrder.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/SalesOrder.cs @@ -12,9 +12,7 @@ namespace Microsoft.EntityFrameworkCore.SqlAzure.Model; public class SalesOrder { public SalesOrder() - { - Details = new HashSet(); - } + => Details = new HashSet(); public int SalesOrderID { get; set; } public string AccountNumber { get; set; } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerApiConsistencyTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerApiConsistencyTest.cs index c22f9e261f3..79cfc3d2d42 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerApiConsistencyTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerApiConsistencyTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class SqlServerApiConsistencyTest(SqlServerApiConsistencyTest.SqlServerApiConsistencyFixture fixture) : ApiConsistencyTestBase(fixture) +public class SqlServerApiConsistencyTest(SqlServerApiConsistencyTest.SqlServerApiConsistencyFixture fixture) + : ApiConsistencyTestBase(fixture) { protected override void AddServices(ServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkSqlServer(); diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerConfigPatternsTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerConfigPatternsTest.cs index 7b21c1e444d..6d23947a4fd 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerConfigPatternsTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerConfigPatternsTest.cs @@ -257,9 +257,7 @@ private class NorthwindContext : DbContext { public NorthwindContext(DbContextOptions options) : base(options) - { - Assert.NotNull(options); - } + => Assert.NotNull(options); public DbSet Customers { get; set; } @@ -311,9 +309,7 @@ private class NorthwindContext : DbContext { public NorthwindContext(DbContextOptions options) : base(options) - { - Assert.NotNull(options); - } + => Assert.NotNull(options); public DbSet Customers { get; set; } @@ -522,28 +518,29 @@ private class NorthwindContext(bool before) : DbContext public DbSet Customers { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - optionsBuilder + => optionsBuilder .EnableServiceProviderCaching(false) - .UseSqlServer(SqlServerNorthwindTestStoreFactory.NorthwindConnectionString, + .UseSqlServer( + SqlServerNorthwindTestStoreFactory.NorthwindConnectionString, b => { if (before) { b.ExecutionStrategy(_ => new DummyExecutionStrategy()); } + b.EnableRetryOnFailure(); if (!before) { b.ExecutionStrategy(_ => new DummyExecutionStrategy()); } }); - } protected override void OnModelCreating(ModelBuilder modelBuilder) => ConfigureModel(modelBuilder); } } + public class ExplicitExecutionStrategies_AzureSql { [InlineData(true)] @@ -567,28 +564,29 @@ private class NorthwindContext(bool before) : DbContext public DbSet Customers { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - optionsBuilder + => optionsBuilder .EnableServiceProviderCaching(false) - .UseAzureSql(SqlServerNorthwindTestStoreFactory.NorthwindConnectionString, + .UseAzureSql( + SqlServerNorthwindTestStoreFactory.NorthwindConnectionString, b => { if (before) { b.ExecutionStrategy(_ => new DummyExecutionStrategy()); } + b.EnableRetryOnFailure(); if (!before) { b.ExecutionStrategy(_ => new DummyExecutionStrategy()); } }); - } protected override void OnModelCreating(ModelBuilder modelBuilder) => ConfigureModel(modelBuilder); } } + public class ExplicitExecutionStrategies_AzureSynapse { [InlineData(true)] @@ -612,28 +610,29 @@ private class NorthwindContext(bool before) : DbContext public DbSet Customers { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - optionsBuilder + => optionsBuilder .EnableServiceProviderCaching(false) - .UseAzureSynapse(SqlServerNorthwindTestStoreFactory.NorthwindConnectionString, + .UseAzureSynapse( + SqlServerNorthwindTestStoreFactory.NorthwindConnectionString, b => { if (before) { b.ExecutionStrategy(_ => new DummyExecutionStrategy()); } + b.EnableRetryOnFailure(); if (!before) { b.ExecutionStrategy(_ => new DummyExecutionStrategy()); } }); - } protected override void OnModelCreating(ModelBuilder modelBuilder) => ConfigureModel(modelBuilder); } } + public class ExplicitExecutionStrategies_ConfigureSqlEngine_AzureSql { [InlineData(true)] @@ -657,8 +656,7 @@ private class NorthwindContext(bool before) : DbContext public DbSet Customers { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - optionsBuilder + => optionsBuilder .EnableServiceProviderCaching(false) .ConfigureSqlEngine( b => @@ -667,6 +665,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { b.ExecutionStrategy(_ => new DummyExecutionStrategy()); } + b.EnableRetryOnFailure(); if (!before) { @@ -674,7 +673,6 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) } }) .UseAzureSql(); - } protected override void OnModelCreating(ModelBuilder modelBuilder) => ConfigureModel(modelBuilder); @@ -695,12 +693,10 @@ private class NorthwindContext : DbContext public DbSet Customers { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - optionsBuilder + => optionsBuilder .EnableServiceProviderCaching(false) .UseSqlServer() .UseAzureSql(); - } protected override void OnModelCreating(ModelBuilder modelBuilder) => ConfigureModel(modelBuilder); @@ -721,11 +717,9 @@ private class NorthwindContext : DbContext public DbSet Customers { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - optionsBuilder + => optionsBuilder .EnableServiceProviderCaching(false) .ConfigureSqlEngine(); - } protected override void OnModelCreating(ModelBuilder modelBuilder) => ConfigureModel(modelBuilder); @@ -855,9 +849,20 @@ private static void ConfigureModel(ModelBuilder builder) private class DummyExecutionStrategy : IExecutionStrategy { - public bool RetriesOnFailure => true; - - public TResult Execute(TState state, Func operation, Func> verifySucceeded) => throw new NotImplementedException(); - public Task ExecuteAsync(TState state, Func> operation, Func>> verifySucceeded, CancellationToken cancellationToken = default) => throw new NotImplementedException(); + public bool RetriesOnFailure + => true; + + public TResult Execute( + TState state, + Func operation, + Func> verifySucceeded) + => throw new NotImplementedException(); + + public Task ExecuteAsync( + TState state, + Func> operation, + Func>> verifySucceeded, + CancellationToken cancellationToken = default) + => throw new NotImplementedException(); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerDatabaseCreatorTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerDatabaseCreatorTest.cs index 85269729ae0..4ccab8bdd31 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerDatabaseCreatorTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerDatabaseCreatorTest.cs @@ -349,7 +349,8 @@ public async Task Throws_for_missing_seed() using var testDatabase = await SqlServerTestStore.CreateInitializedAsync("EnsureCreatedSeedTest"); using var context = new BloggingContext(testDatabase.ConnectionString, asyncSeed: true); - Assert.Equal(CoreStrings.MissingSeeder, + Assert.Equal( + CoreStrings.MissingSeeder, Assert.Throws(() => context.Database.EnsureCreated()).Message); } @@ -359,8 +360,9 @@ public async Task Throws_for_missing_seed_async() using var testDatabase = await SqlServerTestStore.CreateInitializedAsync("EnsureCreatedSeedTest"); using var context = new BloggingContext(testDatabase.ConnectionString, seed: true); - Assert.Equal(CoreStrings.MissingSeeder, - (await Assert.ThrowsAsync(() => context.Database.EnsureCreatedAsync())).Message); + Assert.Equal( + CoreStrings.MissingSeeder, + (await Assert.ThrowsAsync(() => context.Database.EnsureCreatedAsync())).Message); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSentinelSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSentinelSqlServerTest.cs index 01dad9849aa..03aaa9ddb21 100644 --- a/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSentinelSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSentinelSqlServerTest.cs @@ -3,8 +3,9 @@ namespace Microsoft.EntityFrameworkCore; -public class StoreGeneratedSentinelSqlServerTest(StoreGeneratedSentinelSqlServerTest.StoreGeneratedSentinelSqlServerFixture fixture) : StoreGeneratedSqlServerTestBase< - StoreGeneratedSentinelSqlServerTest.StoreGeneratedSentinelSqlServerFixture>(fixture) +public class StoreGeneratedSentinelSqlServerTest(StoreGeneratedSentinelSqlServerTest.StoreGeneratedSentinelSqlServerFixture fixture) + : StoreGeneratedSqlServerTestBase< + StoreGeneratedSentinelSqlServerTest.StoreGeneratedSentinelSqlServerFixture>(fixture) { public class StoreGeneratedSentinelSqlServerFixture : StoreGeneratedSqlServerFixtureBase { diff --git a/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSqlServerTest.cs index f1e11fc06f3..da2902d4f8d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSqlServerTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore; -public class StoreGeneratedSqlServerTest(StoreGeneratedSqlServerTest.StoreGeneratedSqlServerFixture fixture) : StoreGeneratedSqlServerTestBase(fixture) +public class StoreGeneratedSqlServerTest(StoreGeneratedSqlServerTest.StoreGeneratedSqlServerFixture fixture) + : StoreGeneratedSqlServerTestBase(fixture) { public class StoreGeneratedSqlServerFixture : StoreGeneratedSqlServerFixtureBase { diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs index 6ad3e77667b..226ef6fdbfd 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs @@ -112,8 +112,8 @@ protected override async Task InitializeAsync(Func createContext, Fun public override DbContextOptionsBuilder AddProviderOptions(DbContextOptionsBuilder builder) => (UseConnectionString - ? builder.UseSqlServer(ConnectionString, b => b.ApplyConfiguration()) - : builder.UseSqlServer(Connection, b => b.ApplyConfiguration())) + ? builder.UseSqlServer(ConnectionString, b => b.ApplyConfiguration()) + : builder.UseSqlServer(Connection, b => b.ApplyConfiguration())) .ConfigureWarnings(b => b.Ignore(SqlServerEventId.SavepointsDisabledBecauseOfMARS)); private async Task CreateDatabase(Func? clean) diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs index 574f5e92b8c..7d682aeb67c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs @@ -84,7 +84,7 @@ private class TestRelationalCommand( string commandText, IReadOnlyList parameters) : IRelationalCommand { - private readonly RelationalCommand _realRelationalCommand = new RelationalCommand(dependencies, commandText, parameters); + private readonly RelationalCommand _realRelationalCommand = new(dependencies, commandText, parameters); public string CommandText => _realRelationalCommand.CommandText; diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalTransaction.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalTransaction.cs index 278d037e5d6..db65a446446 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalTransaction.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalTransaction.cs @@ -21,7 +21,8 @@ public class TestRelationalTransaction( DbTransaction transaction, IDiagnosticsLogger logger, bool transactionOwned, - ISqlGenerationHelper sqlGenerationHelper) : RelationalTransaction(connection, transaction, new Guid(), logger, transactionOwned, sqlGenerationHelper) + ISqlGenerationHelper sqlGenerationHelper) : RelationalTransaction( + connection, transaction, new Guid(), logger, transactionOwned, sqlGenerationHelper) { private readonly TestSqlServerConnection _testConnection = (TestSqlServerConnection)connection; diff --git a/test/EFCore.SqlServer.FunctionalTests/TransactionInterceptionSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/TransactionInterceptionSqlServerTest.cs index 6802c817936..8f42c0f6d0d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TransactionInterceptionSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TransactionInterceptionSqlServerTest.cs @@ -24,9 +24,9 @@ protected override IServiceCollection InjectInterceptors( } public class TransactionInterceptionSqlServerTest(TransactionInterceptionSqlServerTest.InterceptionSqlServerFixture fixture) - : TransactionInterceptionSqlServerTestBase(fixture), IClassFixture + : TransactionInterceptionSqlServerTestBase(fixture), + IClassFixture { - // ReleaseSavepoint is unsupported by SQL Server and is ignored public override Task Intercept_ReleaseSavepoint(bool async) => Task.CompletedTask; @@ -38,11 +38,11 @@ protected override bool ShouldSubscribeToDiagnosticListener } } - public class TransactionInterceptionWithDiagnosticsSqlServerTest(TransactionInterceptionWithDiagnosticsSqlServerTest.InterceptionSqlServerFixture fixture) + public class TransactionInterceptionWithDiagnosticsSqlServerTest( + TransactionInterceptionWithDiagnosticsSqlServerTest.InterceptionSqlServerFixture fixture) : TransactionInterceptionSqlServerTestBase(fixture), IClassFixture { - // ReleaseSavepoint is unsupported by SQL Server and is ignored public override Task Intercept_ReleaseSavepoint(bool async) => Task.CompletedTask; diff --git a/test/EFCore.SqlServer.FunctionalTests/Update/JsonUpdateJsonTypeSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Update/JsonUpdateJsonTypeSqlServerTest.cs index 3fcc3c283f9..b21adf1969f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Update/JsonUpdateJsonTypeSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Update/JsonUpdateJsonTypeSqlServerTest.cs @@ -11,9 +11,7 @@ public class JsonUpdateJsonTypeSqlServerTest : JsonUpdateTestBase ClearLog(); [ConditionalFact] public virtual void Check_all_tests_overridden() diff --git a/test/EFCore.SqlServer.FunctionalTests/Update/JsonUpdateSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Update/JsonUpdateSqlServerTest.cs index a036f60129c..42fee62b579 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Update/JsonUpdateSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Update/JsonUpdateSqlServerTest.cs @@ -11,9 +11,7 @@ public class JsonUpdateSqlServerTest : JsonUpdateTestBase ClearLog(); public override async Task Add_element_to_json_collection_branch() { @@ -2223,6 +2221,7 @@ OUTPUT 1 WHERE [Id] = @p1; """, // + """ select OwnedCollectionRoot from JsonEntitiesBasic where Id = 2 """, @@ -2235,7 +2234,7 @@ FROM [JsonEntitiesBasic] AS [j] break; default: AssertSql( - """ + """ @p0='2' @p1=NULL (DbType = Int32) @p2='NewEntity' (Size = 4000) @@ -2246,14 +2245,14 @@ INSERT INTO [JsonEntitiesBasic] ([Id], [EntityBasicId], [Name]) VALUES (@p0, @p1, @p2); """, - // - """ + // + """ SELECT TOP(2) [j].[Id], [j].[EntityBasicId], [j].[Name], [j].[OwnedCollectionRoot], [j].[OwnedReferenceRoot] FROM [JsonEntitiesBasic] AS [j] WHERE [j].[Id] = 2 """, - // - """ + // + """ @p0='[]' (Nullable = false) (Size = 2) @p3='2' @p1=NULL (DbType = Int32) @@ -2265,12 +2264,12 @@ FROM [JsonEntitiesBasic] AS [j] OUTPUT 1 WHERE [Id] = @p3; """, - // - """ + // + """ select OwnedCollectionRoot from JsonEntitiesBasic where Id = 2 """, - // - """ + // + """ SELECT TOP(2) [j].[Id], [j].[EntityBasicId], [j].[Name], [j].[OwnedCollectionRoot], [j].[OwnedReferenceRoot] FROM [JsonEntitiesBasic] AS [j] WHERE [j].[Id] = 2 @@ -2403,28 +2402,28 @@ public override async Task Add_and_update_nested_optional_primitive_collection(b { await base.Add_and_update_nested_optional_primitive_collection(value); - string characterCollection = value switch + var characterCollection = value switch { - true => "[\"A\"]", + true => "[\"A\"]", false => "[]", - _ => "null" + _ => "null" }; - string parameterSize = value switch + var parameterSize = value switch { true => "1558", false => "1555", _ => "1557" }; - string updateParameterSize = value switch + var updateParameterSize = value switch { true => "4000", false => "5", _ => "2" }; - string updateParameter = value switch + var updateParameter = value switch { true => "NULL", false => "'[\"Z\"]'", @@ -2432,7 +2431,11 @@ public override async Task Add_and_update_nested_optional_primitive_collection(b }; AssertSql( - @"@p0='[{""TestBoolean"":false,""TestBooleanCollection"":[],""TestByte"":0,""TestByteArray"":null,""TestByteCollection"":null,""TestCharacter"":""\u0000"",""TestCharacterCollection"":" + characterCollection + @",""TestDateOnly"":""0001-01-01"",""TestDateOnlyCollection"":[],""TestDateTime"":""0001-01-01T00:00:00"",""TestDateTimeCollection"":[],""TestDateTimeOffset"":""0001-01-01T00:00:00+00:00"",""TestDateTimeOffsetCollection"":[],""TestDecimal"":0,""TestDecimalCollection"":[],""TestDefaultString"":null,""TestDefaultStringCollection"":[],""TestDouble"":0,""TestDoubleCollection"":[],""TestEnum"":0,""TestEnumCollection"":[],""TestEnumWithIntConverter"":0,""TestEnumWithIntConverterCollection"":[],""TestGuid"":""00000000-0000-0000-0000-000000000000"",""TestGuidCollection"":[],""TestInt16"":0,""TestInt16Collection"":[],""TestInt32"":0,""TestInt32Collection"":[],""TestInt64"":0,""TestInt64Collection"":[],""TestMaxLengthString"":null,""TestMaxLengthStringCollection"":[],""TestNullableEnum"":null,""TestNullableEnumCollection"":[],""TestNullableEnumWithConverterThatHandlesNulls"":null,""TestNullableEnumWithConverterThatHandlesNullsCollection"":[],""TestNullableEnumWithIntConverter"":null,""TestNullableEnumWithIntConverterCollection"":[],""TestNullableInt32"":null,""TestNullableInt32Collection"":[],""TestSignedByte"":0,""TestSignedByteCollection"":[],""TestSingle"":0,""TestSingleCollection"":[],""TestTimeOnly"":""00:00:00.0000000"",""TestTimeOnlyCollection"":[],""TestTimeSpan"":""0:00:00"",""TestTimeSpanCollection"":[],""TestUnsignedInt16"":0,""TestUnsignedInt16Collection"":[],""TestUnsignedInt32"":0,""TestUnsignedInt32Collection"":[],""TestUnsignedInt64"":0,""TestUnsignedInt64Collection"":[]}]' (Nullable = false) (Size = " + parameterSize + @") + @"@p0='[{""TestBoolean"":false,""TestBooleanCollection"":[],""TestByte"":0,""TestByteArray"":null,""TestByteCollection"":null,""TestCharacter"":""\u0000"",""TestCharacterCollection"":" + + characterCollection + + @",""TestDateOnly"":""0001-01-01"",""TestDateOnlyCollection"":[],""TestDateTime"":""0001-01-01T00:00:00"",""TestDateTimeCollection"":[],""TestDateTimeOffset"":""0001-01-01T00:00:00+00:00"",""TestDateTimeOffsetCollection"":[],""TestDecimal"":0,""TestDecimalCollection"":[],""TestDefaultString"":null,""TestDefaultStringCollection"":[],""TestDouble"":0,""TestDoubleCollection"":[],""TestEnum"":0,""TestEnumCollection"":[],""TestEnumWithIntConverter"":0,""TestEnumWithIntConverterCollection"":[],""TestGuid"":""00000000-0000-0000-0000-000000000000"",""TestGuidCollection"":[],""TestInt16"":0,""TestInt16Collection"":[],""TestInt32"":0,""TestInt32Collection"":[],""TestInt64"":0,""TestInt64Collection"":[],""TestMaxLengthString"":null,""TestMaxLengthStringCollection"":[],""TestNullableEnum"":null,""TestNullableEnumCollection"":[],""TestNullableEnumWithConverterThatHandlesNulls"":null,""TestNullableEnumWithConverterThatHandlesNullsCollection"":[],""TestNullableEnumWithIntConverter"":null,""TestNullableEnumWithIntConverterCollection"":[],""TestNullableInt32"":null,""TestNullableInt32Collection"":[],""TestSignedByte"":0,""TestSignedByteCollection"":[],""TestSingle"":0,""TestSingleCollection"":[],""TestTimeOnly"":""00:00:00.0000000"",""TestTimeOnlyCollection"":[],""TestTimeSpan"":""0:00:00"",""TestTimeSpanCollection"":[],""TestUnsignedInt16"":0,""TestUnsignedInt16Collection"":[],""TestUnsignedInt32"":0,""TestUnsignedInt32Collection"":[],""TestUnsignedInt64"":0,""TestUnsignedInt64Collection"":[]}]' (Nullable = false) (Size = " + + parameterSize + + @") @p1='7624' @p2='[]' (Size = 4000) @p3=NULL (Size = 8000) (DbType = Binary) @@ -2464,15 +2467,18 @@ public override async Task Add_and_update_nested_optional_primitive_collection(b SET NOCOUNT ON; INSERT INTO [JsonEntitiesAllTypes] ([Collection], [Id], [TestBooleanCollection], [TestByteCollection], [TestCharacterCollection], [TestDateTimeCollection], [TestDateTimeOffsetCollection], [TestDecimalCollection], [TestDefaultStringCollection], [TestDoubleCollection], [TestEnumCollection], [TestEnumWithIntConverterCollection], [TestGuidCollection], [TestInt16Collection], [TestInt32Collection], [TestInt64Collection], [TestMaxLengthStringCollection], [TestNullableEnumCollection], [TestNullableEnumWithConverterThatHandlesNullsCollection], [TestNullableEnumWithIntConverterCollection], [TestNullableInt32Collection], [TestSignedByteCollection], [TestSingleCollection], [TestTimeSpanCollection], [TestUnsignedInt16Collection], [TestUnsignedInt32Collection], [TestUnsignedInt64Collection]) VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11, @p12, @p13, @p14, @p15, @p16, @p17, @p18, @p19, @p20, @p21, @p22, @p23, @p24, @p25, @p26);", - // - """ + // + """ SELECT TOP(2) [j].[Id], [j].[TestBooleanCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDoubleCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt32Collection], [j].[TestInt64Collection], [j].[TestMaxLengthStringCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableInt32Collection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] WHERE [j].[Id] = 7624 """, - // - -"@p0=" + updateParameter + @" (Nullable = false) (Size = " + updateParameterSize + @") + // + "@p0=" + + updateParameter + + @" (Nullable = false) (Size = " + + updateParameterSize + + @") @p1='7624' SET IMPLICIT_TRANSACTIONS OFF; @@ -2480,8 +2486,8 @@ FROM [JsonEntitiesAllTypes] AS [j] UPDATE [JsonEntitiesAllTypes] SET [Collection] = JSON_MODIFY([Collection], 'strict $[0].TestCharacterCollection', JSON_QUERY(@p0)) OUTPUT 1 WHERE [Id] = @p1;", - // - """ + // + """ SELECT TOP(2) [j].[Id], [j].[TestBooleanCollection], [j].[TestByteCollection], [j].[TestCharacterCollection], [j].[TestDateTimeCollection], [j].[TestDateTimeOffsetCollection], [j].[TestDecimalCollection], [j].[TestDefaultStringCollection], [j].[TestDoubleCollection], [j].[TestEnumCollection], [j].[TestEnumWithIntConverterCollection], [j].[TestGuidCollection], [j].[TestInt16Collection], [j].[TestInt32Collection], [j].[TestInt64Collection], [j].[TestMaxLengthStringCollection], [j].[TestNullableEnumCollection], [j].[TestNullableEnumWithConverterThatHandlesNullsCollection], [j].[TestNullableEnumWithIntConverterCollection], [j].[TestNullableInt32Collection], [j].[TestSignedByteCollection], [j].[TestSingleCollection], [j].[TestTimeSpanCollection], [j].[TestUnsignedInt16Collection], [j].[TestUnsignedInt32Collection], [j].[TestUnsignedInt64Collection], [j].[Collection], [j].[Reference] FROM [JsonEntitiesAllTypes] AS [j] WHERE [j].[Id] = 7624 @@ -2514,7 +2520,8 @@ public override Task Edit_single_property_collection_of_collection_of_nullable_e // Nested collections are not mapped in the relational model, so there is no data stored in the document for them public override Task Edit_single_property_collection_of_collection_of_nullable_enum_with_int_converter() - => Assert.ThrowsAsync(base.Edit_single_property_collection_of_collection_of_nullable_enum_with_int_converter); + => Assert.ThrowsAsync( + base.Edit_single_property_collection_of_collection_of_nullable_enum_with_int_converter); // Nested collections are not mapped in the relational model, so there is no data stored in the document for them public override Task Edit_single_property_collection_of_collection_of_nullable_int32() diff --git a/test/EFCore.SqlServer.FunctionalTests/Update/UpdatesSqlServerTPTTest.cs b/test/EFCore.SqlServer.FunctionalTests/Update/UpdatesSqlServerTPTTest.cs index b90081b5225..64f37a9b476 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Update/UpdatesSqlServerTPTTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Update/UpdatesSqlServerTPTTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.Update; -public class UpdatesSqlServerTPTTest(UpdatesSqlServerTPTTest.UpdatesSqlServerTPTFixture fixture, ITestOutputHelper testOutputHelper) : UpdatesSqlServerTestBase(fixture, testOutputHelper) +public class UpdatesSqlServerTPTTest(UpdatesSqlServerTPTTest.UpdatesSqlServerTPTFixture fixture, ITestOutputHelper testOutputHelper) + : UpdatesSqlServerTestBase(fixture, testOutputHelper) { public override async Task Save_with_shared_foreign_key() { diff --git a/test/EFCore.SqlServer.FunctionalTests/WithConstructorsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/WithConstructorsSqlServerTest.cs index 8b5fadfeb69..fbfb02d2b2c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/WithConstructorsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/WithConstructorsSqlServerTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class WithConstructorsSqlServerTest(WithConstructorsSqlServerTest.WithConstructorsSqlServerFixture fixture) : WithConstructorsTestBase(fixture) +public class WithConstructorsSqlServerTest(WithConstructorsSqlServerTest.WithConstructorsSqlServerFixture fixture) + : WithConstructorsTestBase(fixture) { protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.SqlServer.HierarchyId.Tests/CSharpDbContextGeneratorTest.cs b/test/EFCore.SqlServer.HierarchyId.Tests/CSharpDbContextGeneratorTest.cs index bf5b0752820..19e7e3e67b1 100644 --- a/test/EFCore.SqlServer.HierarchyId.Tests/CSharpDbContextGeneratorTest.cs +++ b/test/EFCore.SqlServer.HierarchyId.Tests/CSharpDbContextGeneratorTest.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.EntityFrameworkCore.Scaffolding; -using Microsoft.Extensions.DependencyInjection; using Xunit; namespace Microsoft.EntityFrameworkCore.SqlServer; diff --git a/test/EFCore.SqlServer.HierarchyId.Tests/CSharpEntityTypeGeneratorTest.cs b/test/EFCore.SqlServer.HierarchyId.Tests/CSharpEntityTypeGeneratorTest.cs index b2d6a0c5f69..77c33b38c74 100644 --- a/test/EFCore.SqlServer.HierarchyId.Tests/CSharpEntityTypeGeneratorTest.cs +++ b/test/EFCore.SqlServer.HierarchyId.Tests/CSharpEntityTypeGeneratorTest.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.EntityFrameworkCore.Scaffolding; -using Microsoft.Extensions.DependencyInjection; using Xunit; namespace Microsoft.EntityFrameworkCore.SqlServer; diff --git a/test/EFCore.SqlServer.HierarchyId.Tests/QueryTests.cs b/test/EFCore.SqlServer.HierarchyId.Tests/QueryTests.cs index 8fd14580b84..b35d1e55c07 100644 --- a/test/EFCore.SqlServer.HierarchyId.Tests/QueryTests.cs +++ b/test/EFCore.SqlServer.HierarchyId.Tests/QueryTests.cs @@ -361,8 +361,8 @@ public void Contains_with_parameter_list_can_translate() { var ids = new[] { HierarchyId.Parse("/1/1/7/"), HierarchyId.Parse("/1/1/99/") }; var result = (from p in _db.Patriarchy - where ids.Contains(p.Id) - select p.Name).Single(); + where ids.Contains(p.Id) + select p.Name).Single(); Assert.Equal( """ diff --git a/test/EFCore.SqlServer.HierarchyId.Tests/SqlServerAbstractionsApiConsistencyTest.cs b/test/EFCore.SqlServer.HierarchyId.Tests/SqlServerAbstractionsApiConsistencyTest.cs index af369f1ecba..d4dad692047 100644 --- a/test/EFCore.SqlServer.HierarchyId.Tests/SqlServerAbstractionsApiConsistencyTest.cs +++ b/test/EFCore.SqlServer.HierarchyId.Tests/SqlServerAbstractionsApiConsistencyTest.cs @@ -6,7 +6,8 @@ namespace Microsoft.EntityFrameworkCore; -public class SqlServerAbstractionsApiConsistencyTest(SqlServerAbstractionsApiConsistencyTest.SqlServerAbstractionsApiConsistencyFixture fixture) : ApiConsistencyTestBase< +public class SqlServerAbstractionsApiConsistencyTest( + SqlServerAbstractionsApiConsistencyTest.SqlServerAbstractionsApiConsistencyFixture fixture) : ApiConsistencyTestBase< SqlServerAbstractionsApiConsistencyTest.SqlServerAbstractionsApiConsistencyFixture>(fixture) { protected override void AddServices(ServiceCollection serviceCollection) diff --git a/test/EFCore.SqlServer.HierarchyId.Tests/SqlServerHierarchyIdApiConsistencyTest.cs b/test/EFCore.SqlServer.HierarchyId.Tests/SqlServerHierarchyIdApiConsistencyTest.cs index f074ed04339..370d63b5169 100644 --- a/test/EFCore.SqlServer.HierarchyId.Tests/SqlServerHierarchyIdApiConsistencyTest.cs +++ b/test/EFCore.SqlServer.HierarchyId.Tests/SqlServerHierarchyIdApiConsistencyTest.cs @@ -6,7 +6,8 @@ namespace Microsoft.EntityFrameworkCore; -public class SqlServerHierarchyIdApiConsistencyTest(SqlServerHierarchyIdApiConsistencyTest.SqlServerHierarchyIdApiConsistencyFixture fixture) : ApiConsistencyTestBase< +public class SqlServerHierarchyIdApiConsistencyTest( + SqlServerHierarchyIdApiConsistencyTest.SqlServerHierarchyIdApiConsistencyFixture fixture) : ApiConsistencyTestBase< SqlServerHierarchyIdApiConsistencyTest.SqlServerHierarchyIdApiConsistencyFixture>(fixture) { protected override void AddServices(ServiceCollection serviceCollection) diff --git a/test/EFCore.SqlServer.HierarchyId.Tests/TestModels/Migrations/TypedArraySeedContext.cs b/test/EFCore.SqlServer.HierarchyId.Tests/TestModels/Migrations/TypedArraySeedContext.cs index 2a9d39e3006..6c48eb0a679 100644 --- a/test/EFCore.SqlServer.HierarchyId.Tests/TestModels/Migrations/TypedArraySeedContext.cs +++ b/test/EFCore.SqlServer.HierarchyId.Tests/TestModels/Migrations/TypedArraySeedContext.cs @@ -1,8 +1,6 @@ // 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.SqlServer.TestModels; - namespace Microsoft.EntityFrameworkCore.SqlServer.TestModels.Migrations; internal sealed class TypedArraySeedContext : MigrationContext diff --git a/test/EFCore.SqlServer.HierarchyId.Tests/TestUtilities/FakeScaffoldingModelFactory.cs b/test/EFCore.SqlServer.HierarchyId.Tests/TestUtilities/FakeScaffoldingModelFactory.cs index df1aaf5111b..d7fd85b5bc1 100644 --- a/test/EFCore.SqlServer.HierarchyId.Tests/TestUtilities/FakeScaffoldingModelFactory.cs +++ b/test/EFCore.SqlServer.HierarchyId.Tests/TestUtilities/FakeScaffoldingModelFactory.cs @@ -18,8 +18,8 @@ public class FakeScaffoldingModelFactory( ICSharpUtilities cSharpUtilities, IScaffoldingTypeMapper scaffoldingTypeMapper, IModelRuntimeInitializer modelRuntimeInitializer) : RelationalScaffoldingModelFactory( - reporter, candidateNamingService, pluralizer, cSharpUtilities, scaffoldingTypeMapper, - modelRuntimeInitializer) + reporter, candidateNamingService, pluralizer, cSharpUtilities, scaffoldingTypeMapper, + modelRuntimeInitializer) { public override IModel Create(DatabaseModel databaseModel, ModelReverseEngineerOptions options) { @@ -129,9 +129,7 @@ public override IList ForeignKeys internal class DatabaseColumnRef : DatabaseColumn { public DatabaseColumnRef(string name) - { - Name = name; - } + => Name = name; public override DatabaseTable Table { diff --git a/test/EFCore.SqlServer.HierarchyId.Tests/WrapperTests.cs b/test/EFCore.SqlServer.HierarchyId.Tests/WrapperTests.cs index 02672cd176d..04ed59232af 100644 --- a/test/EFCore.SqlServer.HierarchyId.Tests/WrapperTests.cs +++ b/test/EFCore.SqlServer.HierarchyId.Tests/WrapperTests.cs @@ -42,7 +42,7 @@ public void Parse_overloads_works_when_parentId_is_simpleId() [ConditionalFact] public void Parse_overloads_works_when_parentId_is_dottedString() - => Assert.Equal(HierarchyId.Parse(_parent, 2,1), HierarchyId.Parse("/1/2.1/")); + => Assert.Equal(HierarchyId.Parse(_parent, 2, 1), HierarchyId.Parse("/1/2.1/")); [ConditionalFact] public void Parse_overloads_works_when_parentId_is_empty() @@ -50,7 +50,7 @@ public void Parse_overloads_works_when_parentId_is_empty() [ConditionalFact] public void Parse_overloads_works_when_parentHierarchy_is_root_and_parentId_is_simple() - => Assert.Equal(HierarchyId.Parse(HierarchyId.GetRoot(),1), HierarchyId.Parse("/1/")); + => Assert.Equal(HierarchyId.Parse(HierarchyId.GetRoot(), 1), HierarchyId.Parse("/1/")); [ConditionalFact] public void Parse_overloads_works_when_parentHierarchy_is_root_and_parentId_is_empty() @@ -58,7 +58,7 @@ public void Parse_overloads_works_when_parentHierarchy_is_root_and_parentId_is_e [ConditionalFact] public void Parse_overloads_works_when_parentHierarchy_is_null_and_parentId_is_empty() - => Assert.Equal(HierarchyId.Parse(null,[]), HierarchyId.Parse("/")); + => Assert.Equal(HierarchyId.Parse(null, []), HierarchyId.Parse("/")); private readonly HierarchyId _parent = HierarchyId.Parse("/1/"); } diff --git a/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs b/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs index 2a3f79be4b5..3f04c7606b9 100644 --- a/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs +++ b/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs @@ -90,9 +90,9 @@ public void GenerateFluentApi_IUniqueConstraint_works_with_fillfactor() { x.Property("Something"); x.Property("SomethingElse"); - x.HasAlternateKey(["Something", "SomethingElse"]).HasFillFactor(80); + x.HasAlternateKey("Something", "SomethingElse").HasFillFactor(80); }); - + var uniqueConstraint = (IKey)modelBuilder.Model.FindEntityType("Post")!.GetKeys().Single(); var result = generator.GenerateFluentApiCalls(uniqueConstraint, uniqueConstraint.GetAnnotations().ToDictionary(a => a.Name, a => a)) .Single(); diff --git a/test/EFCore.SqlServer.Tests/Extensions/SqlServerDatabaseFacadeExtensionsTest.cs b/test/EFCore.SqlServer.Tests/Extensions/SqlServerDatabaseFacadeExtensionsTest.cs index aacf3e5255f..3798e2013f3 100644 --- a/test/EFCore.SqlServer.Tests/Extensions/SqlServerDatabaseFacadeExtensionsTest.cs +++ b/test/EFCore.SqlServer.Tests/Extensions/SqlServerDatabaseFacadeExtensionsTest.cs @@ -91,9 +91,7 @@ public TimeoutContext() } public TimeoutContext(int? commandTimeout) - { - Database.SetCommandTimeout(commandTimeout); - } + => Database.SetCommandTimeout(commandTimeout); protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder @@ -240,9 +238,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) private class SqlServerConstructorContext : SqlServerOnConfiguringContext { public SqlServerConstructorContext() - { - IsSqlServerSet = Database.IsSqlServer(); - } + => IsSqlServerSet = Database.IsSqlServer(); } private class SqlServerUseInOnConfiguringContext : SqlServerOnConfiguringContext @@ -265,9 +261,7 @@ private class ProviderConstructorContext : ProviderContext { public ProviderConstructorContext(DbContextOptions options) : base(options) - { - IsSqlServerSet = Database.IsSqlServer(); - } + => IsSqlServerSet = Database.IsSqlServer(); } private class ProviderUseInOnConfiguringContext(DbContextOptions options) : ProviderContext(options) diff --git a/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs b/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs index 53ceac990f7..225dc8a64f8 100644 --- a/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs +++ b/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs @@ -161,7 +161,6 @@ public virtual void Throws_for_sequence_on_bad_type() modelBuilder); } - [ConditionalFact] public virtual void Throws_for_sequence_HiLo_on_bad_type() { diff --git a/test/EFCore.SqlServer.Tests/Metadata/Conventions/RelationalForeignKeyIndexConventionTest.cs b/test/EFCore.SqlServer.Tests/Metadata/Conventions/RelationalForeignKeyIndexConventionTest.cs index 9235db2b099..445e8583ed5 100644 --- a/test/EFCore.SqlServer.Tests/Metadata/Conventions/RelationalForeignKeyIndexConventionTest.cs +++ b/test/EFCore.SqlServer.Tests/Metadata/Conventions/RelationalForeignKeyIndexConventionTest.cs @@ -64,6 +64,7 @@ public void Removing_relationship_does_not_remove_conventional_index_if_in_use() Assert.Equal(Order.CustomerIdProperty.Name, dependentEntityBuilder.Metadata.GetIndexes().First().Properties.First().Name); Assert.Empty(dependentEntityBuilder.Metadata.GetForeignKeys()); } + private static TestLogger CreateTestLogger() => new() { EnabledFor = LogLevel.Warning }; diff --git a/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerOnDeleteConventionTest.cs b/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerOnDeleteConventionTest.cs index ee369699f25..d89e6071c06 100644 --- a/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerOnDeleteConventionTest.cs +++ b/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerOnDeleteConventionTest.cs @@ -18,7 +18,7 @@ public void Convention_does_not_assume_skip_navigations_have_non_null_FK() public class SkippyDbContext : DbContext { - public DbSet Areas { get; private set; } + public DbSet Areas { get; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlServer(); diff --git a/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataExtensionsTest.cs b/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataExtensionsTest.cs index b49eb7fe9d6..9c8b921cbfb 100644 --- a/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataExtensionsTest.cs +++ b/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataExtensionsTest.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // ReSharper disable InconsistentNaming + namespace Microsoft.EntityFrameworkCore.Metadata; public class SqlServerMetadataExtensionsTest diff --git a/test/EFCore.SqlServer.Tests/SqlServerNTSApiConsistencyTest.cs b/test/EFCore.SqlServer.Tests/SqlServerNTSApiConsistencyTest.cs index b303d7eba2b..b2051cdf50f 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerNTSApiConsistencyTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerNTSApiConsistencyTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore; -public class SqlServerNTSApiConsistencyTest(SqlServerNTSApiConsistencyTest.SqlServerNTSApiConsistencyFixture fixture) : ApiConsistencyTestBase(fixture) +public class SqlServerNTSApiConsistencyTest(SqlServerNTSApiConsistencyTest.SqlServerNTSApiConsistencyFixture fixture) + : ApiConsistencyTestBase(fixture) { protected override void AddServices(ServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkSqlServerNetTopologySuite(); diff --git a/test/EFCore.SqlServer.Tests/SqlServerOptionsExtensionTest.cs b/test/EFCore.SqlServer.Tests/SqlServerOptionsExtensionTest.cs index 38db2102555..a1b01398a35 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerOptionsExtensionTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerOptionsExtensionTest.cs @@ -37,7 +37,8 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) } [DbContext(typeof(EmptyContext))] - private class EmptyContextModel(bool skipDetectChanges, Guid modelId, int entityTypeCount, int typeConfigurationCount) : RuntimeModel(skipDetectChanges, modelId, entityTypeCount, typeConfigurationCount) + private class EmptyContextModel(bool skipDetectChanges, Guid modelId, int entityTypeCount, int typeConfigurationCount) : RuntimeModel( + skipDetectChanges, modelId, entityTypeCount, typeConfigurationCount) { static EmptyContextModel() { diff --git a/test/EFCore.SqlServer.Tests/Storage/Internal/SqlServerDatabaseCreatorTest.cs b/test/EFCore.SqlServer.Tests/Storage/Internal/SqlServerDatabaseCreatorTest.cs index 62041c88486..d23d3357c50 100644 --- a/test/EFCore.SqlServer.Tests/Storage/Internal/SqlServerDatabaseCreatorTest.cs +++ b/test/EFCore.SqlServer.Tests/Storage/Internal/SqlServerDatabaseCreatorTest.cs @@ -121,7 +121,8 @@ private async Task Create_checks_for_existence_and_ultimately_gives_up_waiting_t } } - private class FakeSqlServerConnection(IDbContextOptions options, RelationalConnectionDependencies dependencies) : SqlServerConnection(dependencies) + private class FakeSqlServerConnection(IDbContextOptions options, RelationalConnectionDependencies dependencies) + : SqlServerConnection(dependencies) { private readonly IDbContextOptions _options = options; diff --git a/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs b/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs index bbbc3b9b33c..e7c0d89a840 100644 --- a/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs +++ b/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs @@ -385,7 +385,7 @@ public virtual void Char_Utf8() [ConditionalFact] public virtual void DateOnly_code_literal_generated_correctly() { - var typeMapping = new DateOnlyTypeMapping("date", DbType.Date); + var typeMapping = new DateOnlyTypeMapping("date"); Test_GenerateCodeLiteral_helper(typeMapping, new DateOnly(2020, 3, 5), "new DateOnly(2020, 3, 5)"); } @@ -393,7 +393,7 @@ public virtual void DateOnly_code_literal_generated_correctly() [ConditionalFact] public virtual void TimeOnly_code_literal_generated_correctly() { - var typeMapping = new TimeOnlyTypeMapping("time", DbType.Time); + var typeMapping = new TimeOnlyTypeMapping("time"); Test_GenerateCodeLiteral_helper(typeMapping, new TimeOnly(12, 30, 10), "new TimeOnly(12, 30, 10)"); Test_GenerateCodeLiteral_helper(typeMapping, new TimeOnly(12, 30, 10, 500), "new TimeOnly(12, 30, 10, 500)"); diff --git a/test/EFCore.SqlServer.Tests/Update/SqlServerModificationCommandBatchTest.cs b/test/EFCore.SqlServer.Tests/Update/SqlServerModificationCommandBatchTest.cs index ab4d6b65cb1..1eb35674bee 100644 --- a/test/EFCore.SqlServer.Tests/Update/SqlServerModificationCommandBatchTest.cs +++ b/test/EFCore.SqlServer.Tests/Update/SqlServerModificationCommandBatchTest.cs @@ -162,7 +162,8 @@ private static INonTrackedModificationCommand CreateModificationCommand( => new ModificationCommandFactory().CreateNonTrackedModificationCommand( new NonTrackedModificationCommandParameters(name, schema, sensitiveLoggingEnabled)); - private class TestSqlServerModificationCommandBatch(ModificationCommandBatchFactoryDependencies dependencies, int maxBatchSize) : SqlServerModificationCommandBatch(dependencies, maxBatchSize) + private class TestSqlServerModificationCommandBatch(ModificationCommandBatchFactoryDependencies dependencies, int maxBatchSize) + : SqlServerModificationCommandBatch(dependencies, maxBatchSize) { public new Dictionary ParameterValues => base.ParameterValues; diff --git a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesSqliteTest.cs index 8b6bccba5b5..295042e20aa 100644 --- a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesSqliteTest.cs @@ -5,7 +5,9 @@ namespace Microsoft.EntityFrameworkCore.BulkUpdates; #nullable disable -public class ComplexTypeBulkUpdatesSqliteTest(ComplexTypeBulkUpdatesSqliteTest.ComplexTypeBulkUpdatesSqliteFixture fixture, ITestOutputHelper testOutputHelper) : ComplexTypeBulkUpdatesRelationalTestBase< +public class ComplexTypeBulkUpdatesSqliteTest( + ComplexTypeBulkUpdatesSqliteTest.ComplexTypeBulkUpdatesSqliteFixture fixture, + ITestOutputHelper testOutputHelper) : ComplexTypeBulkUpdatesRelationalTestBase< ComplexTypeBulkUpdatesSqliteTest.ComplexTypeBulkUpdatesSqliteFixture>(fixture, testOutputHelper) { public class ComplexTypeBulkUpdatesSqliteFixture : ComplexTypeBulkUpdatesRelationalFixtureBase diff --git a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqliteTest.cs index b9d24ca7352..e5a45786588 100644 --- a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSqliteTest.cs @@ -9,7 +9,8 @@ namespace Microsoft.EntityFrameworkCore.BulkUpdates; public class NorthwindBulkUpdatesSqliteTest( NorthwindBulkUpdatesSqliteFixture fixture, - ITestOutputHelper testOutputHelper) : NorthwindBulkUpdatesRelationalTestBase>(fixture, testOutputHelper) + ITestOutputHelper testOutputHelper) + : NorthwindBulkUpdatesRelationalTestBase>(fixture, testOutputHelper) { [ConditionalFact] public virtual void Check_all_tests_overridden() diff --git a/test/EFCore.Sqlite.FunctionalTests/CommandConfigurationTest.cs b/test/EFCore.Sqlite.FunctionalTests/CommandConfigurationTest.cs index 7681a983c78..227d1c99021 100644 --- a/test/EFCore.Sqlite.FunctionalTests/CommandConfigurationTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/CommandConfigurationTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class CommandConfigurationTest(CommandConfigurationTest.CommandConfigurationTestFixture fixture) : IClassFixture +public class CommandConfigurationTest(CommandConfigurationTest.CommandConfigurationTestFixture fixture) + : IClassFixture { protected CommandConfigurationTestFixture Fixture { get; } = fixture; diff --git a/test/EFCore.Sqlite.FunctionalTests/CommandInterceptionSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/CommandInterceptionSqliteTest.cs index 469bd833856..cfe84dc7768 100644 --- a/test/EFCore.Sqlite.FunctionalTests/CommandInterceptionSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/CommandInterceptionSqliteTest.cs @@ -65,7 +65,8 @@ protected override bool ShouldSubscribeToDiagnosticListener } } - public class CommandInterceptionWithDiagnosticsSqliteTest(CommandInterceptionWithDiagnosticsSqliteTest.InterceptionSqliteFixture fixture) + public class CommandInterceptionWithDiagnosticsSqliteTest( + CommandInterceptionWithDiagnosticsSqliteTest.InterceptionSqliteFixture fixture) : CommandInterceptionSqliteTestBase(fixture), IClassFixture { public class InterceptionSqliteFixture : InterceptionSqliteFixtureBase diff --git a/test/EFCore.Sqlite.FunctionalTests/CompositeKeyEndToEndSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/CompositeKeyEndToEndSqliteTest.cs index 591408f5a0b..d7dc5a96e75 100644 --- a/test/EFCore.Sqlite.FunctionalTests/CompositeKeyEndToEndSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/CompositeKeyEndToEndSqliteTest.cs @@ -5,8 +5,9 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class CompositeKeyEndToEndSqliteTest(CompositeKeyEndToEndSqliteTest.CompositeKeyEndToEndSqliteFixture fixture) : CompositeKeyEndToEndTestBase< - CompositeKeyEndToEndSqliteTest.CompositeKeyEndToEndSqliteFixture>(fixture) +public class CompositeKeyEndToEndSqliteTest(CompositeKeyEndToEndSqliteTest.CompositeKeyEndToEndSqliteFixture fixture) + : CompositeKeyEndToEndTestBase< + CompositeKeyEndToEndSqliteTest.CompositeKeyEndToEndSqliteFixture>(fixture) { public override Task Can_use_generated_values_in_composite_key_end_to_end() // Not supported on Sqlite diff --git a/test/EFCore.Sqlite.FunctionalTests/ConcurrencyDetectorDisabledSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/ConcurrencyDetectorDisabledSqliteTest.cs index 38380c80aef..dc298c68ebc 100644 --- a/test/EFCore.Sqlite.FunctionalTests/ConcurrencyDetectorDisabledSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/ConcurrencyDetectorDisabledSqliteTest.cs @@ -5,8 +5,9 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class ConcurrencyDetectorDisabledSqliteTest(ConcurrencyDetectorDisabledSqliteTest.ConcurrencyDetectorSqlServerFixture fixture) : ConcurrencyDetectorDisabledRelationalTestBase< - ConcurrencyDetectorDisabledSqliteTest.ConcurrencyDetectorSqlServerFixture>(fixture) +public class ConcurrencyDetectorDisabledSqliteTest(ConcurrencyDetectorDisabledSqliteTest.ConcurrencyDetectorSqlServerFixture fixture) + : ConcurrencyDetectorDisabledRelationalTestBase< + ConcurrencyDetectorDisabledSqliteTest.ConcurrencyDetectorSqlServerFixture>(fixture) { public class ConcurrencyDetectorSqlServerFixture : ConcurrencyDetectorFixtureBase, ITestSqlLoggerFactory { diff --git a/test/EFCore.Sqlite.FunctionalTests/ConcurrencyDetectorEnabledSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/ConcurrencyDetectorEnabledSqliteTest.cs index 7adb84708c6..2a7ada241f5 100644 --- a/test/EFCore.Sqlite.FunctionalTests/ConcurrencyDetectorEnabledSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/ConcurrencyDetectorEnabledSqliteTest.cs @@ -5,8 +5,9 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class ConcurrencyDetectorEnabledSqliteTest(ConcurrencyDetectorEnabledSqliteTest.ConcurrencyDetectorSqlServerFixture fixture) : ConcurrencyDetectorEnabledRelationalTestBase< - ConcurrencyDetectorEnabledSqliteTest.ConcurrencyDetectorSqlServerFixture>(fixture) +public class ConcurrencyDetectorEnabledSqliteTest(ConcurrencyDetectorEnabledSqliteTest.ConcurrencyDetectorSqlServerFixture fixture) + : ConcurrencyDetectorEnabledRelationalTestBase< + ConcurrencyDetectorEnabledSqliteTest.ConcurrencyDetectorSqlServerFixture>(fixture) { public class ConcurrencyDetectorSqlServerFixture : ConcurrencyDetectorFixtureBase, ITestSqlLoggerFactory { diff --git a/test/EFCore.Sqlite.FunctionalTests/ConferencePlannerSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/ConferencePlannerSqliteTest.cs index 079ecd8b599..3623dd58059 100644 --- a/test/EFCore.Sqlite.FunctionalTests/ConferencePlannerSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/ConferencePlannerSqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class ConferencePlannerSqliteTest(ConferencePlannerSqliteTest.ConferencePlannerSqliteFixture fixture) : ConferencePlannerTestBase(fixture) +public class ConferencePlannerSqliteTest(ConferencePlannerSqliteTest.ConferencePlannerSqliteFixture fixture) + : ConferencePlannerTestBase(fixture) { protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.Sqlite.FunctionalTests/ConnectionInterceptionSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/ConnectionInterceptionSqliteTest.cs index ebd1b655da4..8fd4ec35b46 100644 --- a/test/EFCore.Sqlite.FunctionalTests/ConnectionInterceptionSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/ConnectionInterceptionSqliteTest.cs @@ -36,8 +36,10 @@ protected override bool ShouldSubscribeToDiagnosticListener } } - public class ConnectionInterceptionWithDiagnosticsSqliteTest(ConnectionInterceptionWithDiagnosticsSqliteTest.InterceptionSqliteFixture fixture) - : ConnectionInterceptionSqliteTestBase(fixture), IClassFixture + public class ConnectionInterceptionWithDiagnosticsSqliteTest( + ConnectionInterceptionWithDiagnosticsSqliteTest.InterceptionSqliteFixture fixture) + : ConnectionInterceptionSqliteTestBase(fixture), + IClassFixture { public class InterceptionSqliteFixture : InterceptionSqliteFixtureBase { diff --git a/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs index 7571112cd34..67fc5d67ed5 100644 --- a/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs @@ -9,9 +9,7 @@ public class CustomConvertersSqliteTest : CustomConvertersTestBase Fixture.TestSqlLoggerFactory.Clear(); // Disabled: SQLite database is case-sensitive public override Task Can_insert_and_read_back_with_case_insensitive_string_key() diff --git a/test/EFCore.Sqlite.FunctionalTests/DefaultValuesTest.cs b/test/EFCore.Sqlite.FunctionalTests/DefaultValuesTest.cs index b3a26062753..71aaf7eed22 100644 --- a/test/EFCore.Sqlite.FunctionalTests/DefaultValuesTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/DefaultValuesTest.cs @@ -45,7 +45,6 @@ private ChipsContext CreateChipsContext() private class ChipsContext(DbContextOptions options) : PoolableDbContext(options) { - // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Chips { get; set; } diff --git a/test/EFCore.Sqlite.FunctionalTests/DesignTimeSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/DesignTimeSqliteTest.cs index bc15df48613..df3993b67aa 100644 --- a/test/EFCore.Sqlite.FunctionalTests/DesignTimeSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/DesignTimeSqliteTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class DesignTimeSqliteTest(DesignTimeSqliteTest.DesignTimeSqliteFixture fixture) : DesignTimeTestBase(fixture) +public class DesignTimeSqliteTest(DesignTimeSqliteTest.DesignTimeSqliteFixture fixture) + : DesignTimeTestBase(fixture) { protected override Assembly ProviderAssembly => typeof(SqliteDesignTimeServices).Assembly; diff --git a/test/EFCore.Sqlite.FunctionalTests/FieldMappingSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/FieldMappingSqliteTest.cs index ce025e6c948..d43df20a56c 100644 --- a/test/EFCore.Sqlite.FunctionalTests/FieldMappingSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/FieldMappingSqliteTest.cs @@ -61,7 +61,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con public class EnforcePropertyTest(EnforcePropertyTest.EnforcePropertyFixture fixture) : FieldMappingSqliteTestBase(fixture) { - // Cannot force property access when properties missing getter/setter public override void Simple_query_read_only_props(bool tracking) { diff --git a/test/EFCore.Sqlite.FunctionalTests/FieldsOnlyLoadSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/FieldsOnlyLoadSqliteTest.cs index 1f68ac91529..2f37fed9f75 100644 --- a/test/EFCore.Sqlite.FunctionalTests/FieldsOnlyLoadSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/FieldsOnlyLoadSqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class FieldsOnlyLoadSqliteTest(FieldsOnlyLoadSqliteTest.FieldsOnlyLoadSqliteFixture fixture) : FieldsOnlyLoadTestBase(fixture) +public class FieldsOnlyLoadSqliteTest(FieldsOnlyLoadSqliteTest.FieldsOnlyLoadSqliteFixture fixture) + : FieldsOnlyLoadTestBase(fixture) { public class FieldsOnlyLoadSqliteFixture : FieldsOnlyLoadFixtureBase { diff --git a/test/EFCore.Sqlite.FunctionalTests/GraphUpdates/GraphUpdatesSqliteFullWithOriginalsNotificationsTest.cs b/test/EFCore.Sqlite.FunctionalTests/GraphUpdates/GraphUpdatesSqliteFullWithOriginalsNotificationsTest.cs index 0a6f54e48d3..bfbd3247120 100644 --- a/test/EFCore.Sqlite.FunctionalTests/GraphUpdates/GraphUpdatesSqliteFullWithOriginalsNotificationsTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/GraphUpdates/GraphUpdatesSqliteFullWithOriginalsNotificationsTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class GraphUpdatesSqliteFullWithOriginalsNotificationsTest(GraphUpdatesSqliteFullWithOriginalsNotificationsTest.SqliteFixture fixture) +public class GraphUpdatesSqliteFullWithOriginalsNotificationsTest( + GraphUpdatesSqliteFullWithOriginalsNotificationsTest.SqliteFixture fixture) : GraphUpdatesSqliteTestBase(fixture) { protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) diff --git a/test/EFCore.Sqlite.FunctionalTests/JsonTypesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/JsonTypesSqliteTest.cs index f56b95dab49..b3c437accc4 100644 --- a/test/EFCore.Sqlite.FunctionalTests/JsonTypesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/JsonTypesSqliteTest.cs @@ -6,7 +6,8 @@ namespace Microsoft.EntityFrameworkCore; public class JsonTypesSqliteTest : JsonTypesRelationalTestBase { public override Task Can_read_write_array_of_list_of_GUID_JSON_values(string expected) - => base.Can_read_write_array_of_list_of_GUID_JSON_values("""{"Prop":[["00000000-0000-0000-0000-000000000000","8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD"],[],["FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"]]}"""); + => base.Can_read_write_array_of_list_of_GUID_JSON_values( + """{"Prop":[["00000000-0000-0000-0000-000000000000","8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD"],[],["FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"]]}"""); public override Task Can_read_write_array_of_list_of_binary_JSON_values(string expected) => base.Can_read_write_array_of_list_of_binary_JSON_values("""{"Prop":[["000102","01","4D"],[],["4E"]]}"""); @@ -15,13 +16,16 @@ public override Task Can_read_write_list_of_array_of_binary_JSON_values(string e => base.Can_read_write_list_of_array_of_binary_JSON_values("""{"Prop":[["000102","01","4D"],[],["4E"]]}"""); public override Task Can_read_write_list_of_array_of_GUID_JSON_values(string expected) - => base.Can_read_write_list_of_array_of_GUID_JSON_values("""{"Prop":[["00000000-0000-0000-0000-000000000000","8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD"],[],["FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"]]}"""); + => base.Can_read_write_list_of_array_of_GUID_JSON_values( + """{"Prop":[["00000000-0000-0000-0000-000000000000","8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD"],[],["FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"]]}"""); public override Task Can_read_write_list_of_array_of_list_of_array_of_binary_JSON_values(string expected) - => base.Can_read_write_list_of_array_of_list_of_array_of_binary_JSON_values("""{"Prop":[[[["000102","01","4D"]],[],[[],[]]],[],[[[]],[["000102","01","4D"]]]]}"""); + => base.Can_read_write_list_of_array_of_list_of_array_of_binary_JSON_values( + """{"Prop":[[[["000102","01","4D"]],[],[[],[]]],[],[[[]],[["000102","01","4D"]]]]}"""); public override Task Can_read_write_list_of_array_of_nullable_GUID_JSON_values(string expected) - => base.Can_read_write_list_of_array_of_nullable_GUID_JSON_values("""{"Prop":[["00000000-0000-0000-0000-000000000000",null,"8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD"],[],["FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"]]}"""); + => base.Can_read_write_list_of_array_of_nullable_GUID_JSON_values( + """{"Prop":[["00000000-0000-0000-0000-000000000000",null,"8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD"],[],["FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"]]}"""); public override Task Can_read_write_binary_JSON_values(string value, string json) => base.Can_read_write_binary_JSON_values( @@ -35,25 +39,31 @@ public override Task Can_read_write_binary_JSON_values(string value, string json }); public override Task Can_read_write_collection_of_decimal_JSON_values(string expected) - => base.Can_read_write_collection_of_decimal_JSON_values("""{"Prop":["-79228162514264337593543950335.0","0.0","79228162514264337593543950335.0"]}"""); + => base.Can_read_write_collection_of_decimal_JSON_values( + """{"Prop":["-79228162514264337593543950335.0","0.0","79228162514264337593543950335.0"]}"""); public override Task Can_read_write_collection_of_DateTime_JSON_values(string expected) - => base.Can_read_write_collection_of_DateTime_JSON_values("""{"Prop":["0001-01-01 00:00:00","2023-05-29 10:52:47","9999-12-31 23:59:59.9999999"]}"""); + => base.Can_read_write_collection_of_DateTime_JSON_values( + """{"Prop":["0001-01-01 00:00:00","2023-05-29 10:52:47","9999-12-31 23:59:59.9999999"]}"""); public override Task Can_read_write_collection_of_DateTimeOffset_JSON_values(string expected) - => base.Can_read_write_collection_of_DateTimeOffset_JSON_values("""{"Prop":["0001-01-01 00:00:00+00:00","2023-05-29 10:52:47-02:00","2023-05-29 10:52:47+00:00","2023-05-29 10:52:47+02:00","9999-12-31 23:59:59.9999999+00:00"]}"""); + => base.Can_read_write_collection_of_DateTimeOffset_JSON_values( + """{"Prop":["0001-01-01 00:00:00+00:00","2023-05-29 10:52:47-02:00","2023-05-29 10:52:47+00:00","2023-05-29 10:52:47+02:00","9999-12-31 23:59:59.9999999+00:00"]}"""); public override Task Can_read_write_collection_of_GUID_JSON_values(string expected) - => base.Can_read_write_collection_of_GUID_JSON_values("""{"Prop":["00000000-0000-0000-0000-000000000000","8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD","FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"]}"""); + => base.Can_read_write_collection_of_GUID_JSON_values( + """{"Prop":["00000000-0000-0000-0000-000000000000","8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD","FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"]}"""); public override Task Can_read_write_collection_of_binary_JSON_values(string expected) => base.Can_read_write_collection_of_binary_JSON_values("""{"Prop":["00000001","FFFFFFFF","","01020304"]}"""); public override Task Can_read_write_collection_of_decimal_with_precision_and_scale_JSON_values(string expected) - => base.Can_read_write_collection_of_decimal_with_precision_and_scale_JSON_values("""{"Prop":["-79228162514264337593543950335.0","0.0","79228162514264337593543950335.0"]}"""); + => base.Can_read_write_collection_of_decimal_with_precision_and_scale_JSON_values( + """{"Prop":["-79228162514264337593543950335.0","0.0","79228162514264337593543950335.0"]}"""); public override Task Can_read_write_collection_of_Guid_converted_to_bytes_JSON_values(string expected) - => base.Can_read_write_collection_of_Guid_converted_to_bytes_JSON_values("""{"Prop":["00000000000000000000000000000000","2F24448C3F8E204A8BE898C7C1AADEBD","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"]}"""); + => base.Can_read_write_collection_of_Guid_converted_to_bytes_JSON_values( + """{"Prop":["00000000000000000000000000000000","2F24448C3F8E204A8BE898C7C1AADEBD","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"]}"""); public override Task Can_read_write_DateTime_JSON_values(string value, string json) => base.Can_read_write_DateTime_JSON_values( @@ -159,16 +169,20 @@ public override Task Can_read_write_collection_of_nullable_binary_JSON_values(st => base.Can_read_write_collection_of_nullable_binary_JSON_values("""{"Prop":["00000001",null,"FFFFFFFF","","01020304"]}"""); public override Task Can_read_write_collection_of_nullable_DateTime_JSON_values(string expected) - => base.Can_read_write_collection_of_nullable_DateTime_JSON_values("""{"Prop":["0001-01-01 00:00:00",null,"2023-05-29 10:52:47","9999-12-31 23:59:59.9999999"]}"""); + => base.Can_read_write_collection_of_nullable_DateTime_JSON_values( + """{"Prop":["0001-01-01 00:00:00",null,"2023-05-29 10:52:47","9999-12-31 23:59:59.9999999"]}"""); public override Task Can_read_write_collection_of_nullable_DateTimeOffset_JSON_values(string expected) - => base.Can_read_write_collection_of_nullable_DateTimeOffset_JSON_values("""{"Prop":["0001-01-01 00:00:00+00:00","2023-05-29 10:52:47-02:00","2023-05-29 10:52:47+00:00",null,"2023-05-29 10:52:47+02:00","9999-12-31 23:59:59.9999999+00:00"]}"""); + => base.Can_read_write_collection_of_nullable_DateTimeOffset_JSON_values( + """{"Prop":["0001-01-01 00:00:00+00:00","2023-05-29 10:52:47-02:00","2023-05-29 10:52:47+00:00",null,"2023-05-29 10:52:47+02:00","9999-12-31 23:59:59.9999999+00:00"]}"""); public override Task Can_read_write_collection_of_nullable_decimal_JSON_values(string expected) - => base.Can_read_write_collection_of_nullable_decimal_JSON_values("""{"Prop":["-79228162514264337593543950335.0","0.0",null,"79228162514264337593543950335.0"]}"""); + => base.Can_read_write_collection_of_nullable_decimal_JSON_values( + """{"Prop":["-79228162514264337593543950335.0","0.0",null,"79228162514264337593543950335.0"]}"""); public override Task Can_read_write_collection_of_nullable_GUID_JSON_values(string expected) - => base.Can_read_write_collection_of_nullable_GUID_JSON_values("""{"Prop":["00000000-0000-0000-0000-000000000000",null,"8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD","FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"]}"""); + => base.Can_read_write_collection_of_nullable_GUID_JSON_values( + """{"Prop":["00000000-0000-0000-0000-000000000000",null,"8C44242F-8E3F-4A20-8BE8-98C7C1AADEBD","FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"]}"""); public override Task Can_read_write_ulong_enum_JSON_values(EnumU64 value, string json) => Can_read_and_write_JSON_value(nameof(EnumU64Type.EnumU64), value, json); diff --git a/test/EFCore.Sqlite.FunctionalTests/KeysWithConvertersSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/KeysWithConvertersSqliteTest.cs index b22846d1da8..2b77e1726ce 100644 --- a/test/EFCore.Sqlite.FunctionalTests/KeysWithConvertersSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/KeysWithConvertersSqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class KeysWithConvertersSqliteTest(KeysWithConvertersSqliteTest.KeysWithConvertersSqliteFixture fixture) : KeysWithConvertersTestBase(fixture) +public class KeysWithConvertersSqliteTest(KeysWithConvertersSqliteTest.KeysWithConvertersSqliteFixture fixture) + : KeysWithConvertersTestBase(fixture) { public class KeysWithConvertersSqliteFixture : KeysWithConvertersFixtureBase { diff --git a/test/EFCore.Sqlite.FunctionalTests/LazyLoadProxySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/LazyLoadProxySqliteTest.cs index 01fbd506d96..99d375a0cf5 100644 --- a/test/EFCore.Sqlite.FunctionalTests/LazyLoadProxySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/LazyLoadProxySqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class LazyLoadProxySqliteTest(LazyLoadProxySqliteTest.LoadSqliteFixture fixture) : LazyLoadProxyTestBase(fixture) +public class LazyLoadProxySqliteTest(LazyLoadProxySqliteTest.LoadSqliteFixture fixture) + : LazyLoadProxyTestBase(fixture) { [ConditionalFact] public void IsLoaded_is_not_set_if_loading_principal_collection_fails() diff --git a/test/EFCore.Sqlite.FunctionalTests/Migrations/MigrationsInfrastructureSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Migrations/MigrationsInfrastructureSqliteTest.cs index 26799421608..44df35292fe 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Migrations/MigrationsInfrastructureSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Migrations/MigrationsInfrastructureSqliteTest.cs @@ -1,12 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable disable + using Identity30.Data; using Microsoft.EntityFrameworkCore.TestModels.AspNetIdentity; using ModelSnapshot22; -#nullable disable - namespace Microsoft.EntityFrameworkCore.Migrations { public class MigrationsInfrastructureSqliteTest(MigrationsInfrastructureSqliteTest.MigrationsInfrastructureSqliteFixture fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Migrations/MigrationsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Migrations/MigrationsSqliteTest.cs index ce333c2edef..79529ed9b1d 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Migrations/MigrationsSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Migrations/MigrationsSqliteTest.cs @@ -1102,16 +1102,16 @@ public override async Task Convert_json_entities_to_regular_owned() { await base.Convert_json_entities_to_regular_owned(); -AssertSql( + AssertSql( """ ALTER TABLE "Entity" RENAME COLUMN "OwnedReference" TO "OwnedReference_Date"; """, - // - """ + // + """ ALTER TABLE "Entity" ADD "OwnedReference_NestedReference_Number" INTEGER NULL; """, - // - """ + // + """ CREATE TABLE "Entity_NestedCollection" ( "OwnedEntityId" INTEGER NOT NULL, "Id" INTEGER NOT NULL, @@ -1120,8 +1120,8 @@ public override async Task Convert_json_entities_to_regular_owned() CONSTRAINT "FK_Entity_NestedCollection_Entity_OwnedEntityId" FOREIGN KEY ("OwnedEntityId") REFERENCES "Entity" ("Id") ON DELETE CASCADE ); """, - // - """ + // + """ CREATE TABLE "Entity_OwnedCollection" ( "EntityId" INTEGER NOT NULL, "Id" INTEGER NOT NULL, @@ -1131,8 +1131,8 @@ public override async Task Convert_json_entities_to_regular_owned() CONSTRAINT "FK_Entity_OwnedCollection_Entity_EntityId" FOREIGN KEY ("EntityId") REFERENCES "Entity" ("Id") ON DELETE CASCADE ); """, - // - """ + // + """ CREATE TABLE "Entity_OwnedCollection_NestedCollection2" ( "Owned2EntityId" INTEGER NOT NULL, "Owned2Id" INTEGER NOT NULL, @@ -1142,8 +1142,8 @@ public override async Task Convert_json_entities_to_regular_owned() CONSTRAINT "FK_Entity_OwnedCollection_NestedCollection2_Entity_OwnedCollection_Owned2EntityId_Owned2Id" FOREIGN KEY ("Owned2EntityId", "Owned2Id") REFERENCES "Entity_OwnedCollection" ("EntityId", "Id") ON DELETE CASCADE ); """, - // - """ + // + """ CREATE TABLE "ef_temp_Entity" ( "Id" INTEGER NOT NULL CONSTRAINT "PK_Entity" PRIMARY KEY AUTOINCREMENT, "Name" TEXT NULL, @@ -1151,26 +1151,26 @@ public override async Task Convert_json_entities_to_regular_owned() "OwnedReference_NestedReference_Number" INTEGER NULL ); """, - // - """ + // + """ INSERT INTO "ef_temp_Entity" ("Id", "Name", "OwnedReference_Date", "OwnedReference_NestedReference_Number") SELECT "Id", "Name", "OwnedReference_Date", "OwnedReference_NestedReference_Number" FROM "Entity"; """, - // - """ + // + """ PRAGMA foreign_keys = 0; """, - // - """ + // + """ DROP TABLE "Entity"; """, - // - """ + // + """ ALTER TABLE "ef_temp_Entity" RENAME TO "Entity"; """, - // - """ + // + """ PRAGMA foreign_keys = 1; """); } @@ -2027,7 +2027,7 @@ public override async Task Create_table_with_complex_type_with_required_properti await base.Create_table_with_complex_type_with_required_properties_on_derived_entity_in_TPH(); AssertSql( -""" + """ CREATE TABLE "Contacts" ( "Id" INTEGER NOT NULL CONSTRAINT "PK_Contacts" PRIMARY KEY AUTOINCREMENT, "Discriminator" TEXT NOT NULL, @@ -2076,7 +2076,7 @@ public override async Task Add_required_primitve_collection_to_existing_table() await base.Add_required_primitve_collection_to_existing_table(); AssertSql( -""" + """ ALTER TABLE "Customers" ADD "Numbers" TEXT NOT NULL DEFAULT '[]'; """); } @@ -2087,7 +2087,7 @@ public override async Task Add_required_primitve_collection_with_custom_default_ await base.Add_required_primitve_collection_with_custom_default_value_to_existing_table(); AssertSql( -""" + """ ALTER TABLE "Customers" ADD "Numbers" TEXT NOT NULL DEFAULT '[1,2,3]'; """); } @@ -2098,7 +2098,7 @@ public override async Task Add_required_primitve_collection_with_custom_default_ await base.Add_required_primitve_collection_with_custom_default_value_sql_to_existing_table_core("'[3, 2, 1]'"); AssertSql( -""" + """ ALTER TABLE "Customers" ADD "Numbers" TEXT NOT NULL DEFAULT ('[3, 2, 1]'); """); } @@ -2109,7 +2109,7 @@ public override async Task Add_required_primitve_collection_with_custom_converte await base.Add_required_primitve_collection_with_custom_converter_to_existing_table(); AssertSql( -""" + """ ALTER TABLE [Customers] ADD [Numbers] nvarchar(max) NOT NULL DEFAULT N'nothing'; """); } @@ -2120,7 +2120,7 @@ public override async Task Add_required_primitve_collection_with_custom_converte await base.Add_required_primitve_collection_with_custom_converter_and_custom_default_value_to_existing_table(); AssertSql( -""" + """ ALTER TABLE "Customers" ADD "Numbers" TEXT NOT NULL DEFAULT 'some numbers'; """); } @@ -2131,7 +2131,7 @@ public override async Task Add_required_primitive_collection_to_existing_table() await base.Add_required_primitive_collection_to_existing_table(); AssertSql( -""" + """ ALTER TABLE "Customers" ADD "Numbers" TEXT NOT NULL DEFAULT '[]'; """); } @@ -2142,7 +2142,7 @@ public override async Task Add_required_primitive_collection_with_custom_default await base.Add_required_primitive_collection_with_custom_default_value_to_existing_table(); AssertSql( -""" + """ ALTER TABLE "Customers" ADD "Numbers" TEXT NOT NULL DEFAULT '[1,2,3]'; """); } @@ -2153,7 +2153,7 @@ public override async Task Add_required_primitive_collection_with_custom_default await base.Add_required_primitive_collection_with_custom_default_value_sql_to_existing_table_core("'[3, 2, 1]'"); AssertSql( -""" + """ ALTER TABLE "Customers" ADD "Numbers" TEXT NOT NULL DEFAULT ('[3, 2, 1]'); """); } @@ -2164,7 +2164,7 @@ public override async Task Add_required_primitive_collection_with_custom_convert await base.Add_required_primitive_collection_with_custom_converter_to_existing_table(); AssertSql( -""" + """ ALTER TABLE [Customers] ADD [Numbers] nvarchar(max) NOT NULL DEFAULT N'nothing'; """); } @@ -2175,7 +2175,7 @@ public override async Task Add_required_primitive_collection_with_custom_convert await base.Add_required_primitive_collection_with_custom_converter_and_custom_default_value_to_existing_table(); AssertSql( -""" + """ ALTER TABLE "Customers" ADD "Numbers" TEXT NOT NULL DEFAULT 'some numbers'; """); } @@ -2186,7 +2186,7 @@ public override async Task Add_optional_primitive_collection_to_existing_table() await base.Add_optional_primitive_collection_to_existing_table(); AssertSql( -""" + """ ALTER TABLE "Customers" ADD "Numbers" TEXT NULL; """); } @@ -2197,7 +2197,7 @@ public override async Task Create_table_with_required_primitive_collection() await base.Create_table_with_required_primitive_collection(); AssertSql( -""" + """ CREATE TABLE "Customers" ( "Id" INTEGER NOT NULL CONSTRAINT "PK_Customers" PRIMARY KEY AUTOINCREMENT, "Name" TEXT NULL, @@ -2212,7 +2212,7 @@ public override async Task Create_table_with_optional_primitive_collection() await base.Create_table_with_optional_primitive_collection(); AssertSql( -""" + """ CREATE TABLE "Customers" ( "Id" INTEGER NOT NULL CONSTRAINT "PK_Customers" PRIMARY KEY AUTOINCREMENT, "Name" TEXT NULL, diff --git a/test/EFCore.Sqlite.FunctionalTests/ModelBuilding/SqliteModelBuilderGenericTest.cs b/test/EFCore.Sqlite.FunctionalTests/ModelBuilding/SqliteModelBuilderGenericTest.cs index d81996228cc..aeb872eefff 100644 --- a/test/EFCore.Sqlite.FunctionalTests/ModelBuilding/SqliteModelBuilderGenericTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/ModelBuilding/SqliteModelBuilderGenericTest.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // ReSharper disable InconsistentNaming + namespace Microsoft.EntityFrameworkCore.ModelBuilding; public class SqliteModelBuilderGenericTest : SqliteModelBuilderTestBase diff --git a/test/EFCore.Sqlite.FunctionalTests/ModelBuilding/SqliteModelBuilderTestBase.cs b/test/EFCore.Sqlite.FunctionalTests/ModelBuilding/SqliteModelBuilderTestBase.cs index 713c830c9eb..475f5d5a660 100644 --- a/test/EFCore.Sqlite.FunctionalTests/ModelBuilding/SqliteModelBuilderTestBase.cs +++ b/test/EFCore.Sqlite.FunctionalTests/ModelBuilding/SqliteModelBuilderTestBase.cs @@ -1,36 +1,45 @@ // 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.Metadata.Internal; using Microsoft.EntityFrameworkCore.Sqlite.Internal; namespace Microsoft.EntityFrameworkCore.ModelBuilding; public class SqliteModelBuilderTestBase : RelationalModelBuilderTest { - public abstract class SqliteNonRelationship(SqliteModelBuilderFixture fixture) : RelationalNonRelationshipTestBase(fixture), IClassFixture; + public abstract class SqliteNonRelationship(SqliteModelBuilderFixture fixture) + : RelationalNonRelationshipTestBase(fixture), IClassFixture; - public abstract class SqliteComplexType(SqliteModelBuilderFixture fixture) : RelationalComplexTypeTestBase(fixture), IClassFixture; + public abstract class SqliteComplexType(SqliteModelBuilderFixture fixture) + : RelationalComplexTypeTestBase(fixture), IClassFixture; - public abstract class SqliteInheritance(SqliteModelBuilderFixture fixture) : RelationalInheritanceTestBase(fixture), IClassFixture; + public abstract class SqliteInheritance(SqliteModelBuilderFixture fixture) + : RelationalInheritanceTestBase(fixture), IClassFixture; - public abstract class SqliteOneToMany(SqliteModelBuilderFixture fixture) : RelationalOneToManyTestBase(fixture), IClassFixture; + public abstract class SqliteOneToMany(SqliteModelBuilderFixture fixture) + : RelationalOneToManyTestBase(fixture), IClassFixture; - public abstract class SqliteManyToOne(SqliteModelBuilderFixture fixture) : RelationalManyToOneTestBase(fixture), IClassFixture; + public abstract class SqliteManyToOne(SqliteModelBuilderFixture fixture) + : RelationalManyToOneTestBase(fixture), IClassFixture; - public abstract class SqliteOneToOne(SqliteModelBuilderFixture fixture) : RelationalOneToOneTestBase(fixture), IClassFixture; + public abstract class SqliteOneToOne(SqliteModelBuilderFixture fixture) + : RelationalOneToOneTestBase(fixture), IClassFixture; - public abstract class SqliteManyToMany(SqliteModelBuilderFixture fixture) : RelationalManyToManyTestBase(fixture), IClassFixture; + public abstract class SqliteManyToMany(SqliteModelBuilderFixture fixture) + : RelationalManyToManyTestBase(fixture), IClassFixture; - public abstract class SqliteOwnedTypes(SqliteModelBuilderFixture fixture) : RelationalOwnedTypesTestBase(fixture), IClassFixture + public abstract class SqliteOwnedTypes(SqliteModelBuilderFixture fixture) + : RelationalOwnedTypesTestBase(fixture), IClassFixture { public override void Can_use_sproc_mapping_with_owned_reference() - => Assert.Equal(SqliteStrings.StoredProceduresNotSupported("Book.Label#BookLabel"), + => Assert.Equal( + SqliteStrings.StoredProceduresNotSupported("Book.Label#BookLabel"), Assert.Throws(base.Can_use_sproc_mapping_with_owned_reference).Message); } public class SqliteModelBuilderFixture : RelationalModelBuilderFixture { - public override TestHelpers TestHelpers => SqliteTestHelpers.Instance; + public override TestHelpers TestHelpers + => SqliteTestHelpers.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/MonsterFixupChangedOnlySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/MonsterFixupChangedOnlySqliteTest.cs index 0e2cfd05894..856a6f6db95 100644 --- a/test/EFCore.Sqlite.FunctionalTests/MonsterFixupChangedOnlySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/MonsterFixupChangedOnlySqliteTest.cs @@ -5,8 +5,9 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class MonsterFixupChangedOnlySqliteTest(MonsterFixupChangedOnlySqliteTest.MonsterFixupChangedOnlySqliteFixture fixture) : MonsterFixupTestBase< - MonsterFixupChangedOnlySqliteTest.MonsterFixupChangedOnlySqliteFixture>(fixture) +public class MonsterFixupChangedOnlySqliteTest(MonsterFixupChangedOnlySqliteTest.MonsterFixupChangedOnlySqliteFixture fixture) + : MonsterFixupTestBase< + MonsterFixupChangedOnlySqliteTest.MonsterFixupChangedOnlySqliteFixture>(fixture) { public class MonsterFixupChangedOnlySqliteFixture : MonsterFixupChangedOnlyFixtureBase { diff --git a/test/EFCore.Sqlite.FunctionalTests/MusicStoreSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/MusicStoreSqliteTest.cs index 06e703e2225..10dc7a646d8 100644 --- a/test/EFCore.Sqlite.FunctionalTests/MusicStoreSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/MusicStoreSqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class MusicStoreSqliteTest(MusicStoreSqliteTest.MusicStoreSqliteFixture fixture) : MusicStoreTestBase(fixture) +public class MusicStoreSqliteTest(MusicStoreSqliteTest.MusicStoreSqliteFixture fixture) + : MusicStoreTestBase(fixture) { public class MusicStoreSqliteFixture : MusicStoreFixtureBase { diff --git a/test/EFCore.Sqlite.FunctionalTests/NonLoadingNavigationsManyToManyLoadSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/NonLoadingNavigationsManyToManyLoadSqliteTest.cs index 30780b3b29d..382ee1ce39e 100644 --- a/test/EFCore.Sqlite.FunctionalTests/NonLoadingNavigationsManyToManyLoadSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/NonLoadingNavigationsManyToManyLoadSqliteTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class NonLoadingNavigationsManyToManyLoadSqliteTest(NonLoadingNavigationsManyToManyLoadSqliteTest.NonLoadingNavigationsManyToManyLoadSqliteFixture fixture) +public class NonLoadingNavigationsManyToManyLoadSqliteTest( + NonLoadingNavigationsManyToManyLoadSqliteTest.NonLoadingNavigationsManyToManyLoadSqliteFixture fixture) : ManyToManyLoadTestBase(fixture) { public class NonLoadingNavigationsManyToManyLoadSqliteFixture : ManyToManyLoadFixtureBase, ITestSqlLoggerFactory diff --git a/test/EFCore.Sqlite.FunctionalTests/NotificationEntitiesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/NotificationEntitiesSqliteTest.cs index 1dea0ea8f39..b07ccf6367c 100644 --- a/test/EFCore.Sqlite.FunctionalTests/NotificationEntitiesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/NotificationEntitiesSqliteTest.cs @@ -5,8 +5,9 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class NotificationEntitiesSqliteTest(NotificationEntitiesSqliteTest.NotificationEntitiesSqliteFixture fixture) : NotificationEntitiesTestBase< - NotificationEntitiesSqliteTest.NotificationEntitiesSqliteFixture>(fixture) +public class NotificationEntitiesSqliteTest(NotificationEntitiesSqliteTest.NotificationEntitiesSqliteFixture fixture) + : NotificationEntitiesTestBase< + NotificationEntitiesSqliteTest.NotificationEntitiesSqliteFixture>(fixture) { public class NotificationEntitiesSqliteFixture : NotificationEntitiesFixtureBase { diff --git a/test/EFCore.Sqlite.FunctionalTests/OptimisticConcurrencySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/OptimisticConcurrencySqliteTest.cs index eb39c58ea50..2631e9d0440 100644 --- a/test/EFCore.Sqlite.FunctionalTests/OptimisticConcurrencySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/OptimisticConcurrencySqliteTest.cs @@ -5,9 +5,11 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class OptimisticConcurrencyULongSqliteTest(F1ULongSqliteFixture fixture) : OptimisticConcurrencySqliteTestBase(fixture); +public class OptimisticConcurrencyULongSqliteTest(F1ULongSqliteFixture fixture) + : OptimisticConcurrencySqliteTestBase(fixture); -public class OptimisticConcurrencySqliteTest(F1SqliteFixture fixture) : OptimisticConcurrencySqliteTestBase(fixture); +public class OptimisticConcurrencySqliteTest(F1SqliteFixture fixture) + : OptimisticConcurrencySqliteTestBase(fixture); public abstract class OptimisticConcurrencySqliteTestBase(TFixture fixture) : OptimisticConcurrencyRelationalTestBase(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/PropertyValuesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/PropertyValuesSqliteTest.cs index c70c8064c0a..5c6f1a03ce8 100644 --- a/test/EFCore.Sqlite.FunctionalTests/PropertyValuesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/PropertyValuesSqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class PropertyValuesSqliteTest(PropertyValuesSqliteTest.PropertyValuesSqliteFixture fixture) : PropertyValuesTestBase(fixture) +public class PropertyValuesSqliteTest(PropertyValuesSqliteTest.PropertyValuesSqliteFixture fixture) + : PropertyValuesTestBase(fixture) { public class PropertyValuesSqliteFixture : PropertyValuesFixtureBase { diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/AdHocJsonQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/AdHocJsonQuerySqliteTest.cs index c9ba2346901..c0e0a9b94a4 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/AdHocJsonQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/AdHocJsonQuerySqliteTest.cs @@ -18,9 +18,9 @@ protected override async Task Seed29219(DbContext ctx) Reference = new MyJsonEntity29219 { NonNullableScalar = 10, NullableScalar = 11 }, Collection = [ - new() { NonNullableScalar = 100, NullableScalar = 101 }, - new() { NonNullableScalar = 200, NullableScalar = 201 }, - new() { NonNullableScalar = 300, NullableScalar = null } + new MyJsonEntity29219 { NonNullableScalar = 100, NullableScalar = 101 }, + new MyJsonEntity29219 { NonNullableScalar = 200, NullableScalar = 201 }, + new MyJsonEntity29219 { NonNullableScalar = 300, NullableScalar = null } ] }; @@ -28,7 +28,7 @@ protected override async Task Seed29219(DbContext ctx) { Id = 2, Reference = new MyJsonEntity29219 { NonNullableScalar = 20, NullableScalar = null }, - Collection = [new() { NonNullableScalar = 1001, NullableScalar = null }] + Collection = [new MyJsonEntity29219 { NonNullableScalar = 1001, NullableScalar = null }] }; ctx.Set().AddRange(entity1, entity2); @@ -104,8 +104,8 @@ protected override Task SeedArrayOfPrimitives(DbContext ctx) }, Collection = [ - new() { IntArray = [111, 112, 113], ListOfString = ["Foo11", "Bar11"] }, - new() { IntArray = [211, 212, 213], ListOfString = ["Foo12", "Bar12"] } + new MyJsonEntityArrayOfPrimitives { IntArray = [111, 112, 113], ListOfString = ["Foo11", "Bar11"] }, + new MyJsonEntityArrayOfPrimitives { IntArray = [211, 212, 213], ListOfString = ["Foo12", "Bar12"] } ] }; @@ -124,8 +124,8 @@ protected override Task SeedArrayOfPrimitives(DbContext ctx) }, Collection = [ - new() { IntArray = [110, 120, 130], ListOfString = ["A1", "Z1"] }, - new() { IntArray = [210, 220, 230], ListOfString = ["A2", "Z2"] } + new MyJsonEntityArrayOfPrimitives { IntArray = [110, 120, 130], ListOfString = ["A1", "Z1"] }, + new MyJsonEntityArrayOfPrimitives { IntArray = [210, 220, 230], ListOfString = ["A2", "Z2"] } ] }; diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/AdHocMiscellaneousQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/AdHocMiscellaneousQuerySqliteTest.cs index 7d49ffdfb98..2fa464a2554 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/AdHocMiscellaneousQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/AdHocMiscellaneousQuerySqliteTest.cs @@ -1,8 +1,6 @@ // 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.Sqlite.Internal; - namespace Microsoft.EntityFrameworkCore.Query; #nullable disable diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/AdHocQuerySplittingQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/AdHocQuerySplittingQuerySqliteTest.cs index 1f9a25e56dd..0889d679be4 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/AdHocQuerySplittingQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/AdHocQuerySplittingQuerySqliteTest.cs @@ -15,7 +15,9 @@ protected override ITestStoreFactory TestStoreFactory private static readonly FieldInfo _querySplittingBehaviorFieldInfo = typeof(RelationalOptionsExtension).GetField("_querySplittingBehavior", BindingFlags.NonPublic | BindingFlags.Instance); - protected override DbContextOptionsBuilder SetQuerySplittingBehavior(DbContextOptionsBuilder optionsBuilder, QuerySplittingBehavior splittingBehavior) + protected override DbContextOptionsBuilder SetQuerySplittingBehavior( + DbContextOptionsBuilder optionsBuilder, + QuerySplittingBehavior splittingBehavior) { new SqliteDbContextOptionsBuilder(optionsBuilder).UseQuerySplittingBehavior(splittingBehavior); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs index 5b2879e3b16..36810f7a589 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class ComplexNavigationsQuerySqliteTest(ComplexNavigationsQuerySqliteFixture fixture) : ComplexNavigationsQueryRelationalTestBase(fixture) +public class ComplexNavigationsQuerySqliteTest(ComplexNavigationsQuerySqliteFixture fixture) + : ComplexNavigationsQueryRelationalTestBase(fixture) { public override async Task Let_let_contains_from_outer_let(bool async) => Assert.Equal( diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexTypeQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexTypeQuerySqliteTest.cs index 066a3f2f22b..9a294ed5787 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexTypeQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexTypeQuerySqliteTest.cs @@ -481,7 +481,8 @@ public override async Task Filter_on_required_property_inside_required_struct_co // purpose of knowing that it's there. public override async Task Project_struct_complex_type_via_optional_navigation(bool async) { - var exception = await Assert.ThrowsAsync(() => base.Project_struct_complex_type_via_optional_navigation(async)); + var exception = + await Assert.ThrowsAsync(() => base.Project_struct_complex_type_via_optional_navigation(async)); Assert.Equal(RelationalStrings.CannotProjectNullableComplexType("ValuedCustomer.ShippingAddress#AddressStruct"), exception.Message); } @@ -751,7 +752,7 @@ public override async Task Project_same_entity_with_nested_complex_type_twice_wi await base.Project_same_entity_with_nested_complex_type_twice_with_pushdown(async); AssertSql( -""" + """ SELECT "s"."Id", "s"."Name", "s"."BillingAddress_AddressLine1", "s"."BillingAddress_AddressLine2", "s"."BillingAddress_Tags", "s"."BillingAddress_ZipCode", "s"."BillingAddress_Country_Code", "s"."BillingAddress_Country_FullName", "s"."ShippingAddress_AddressLine1", "s"."ShippingAddress_AddressLine2", "s"."ShippingAddress_Tags", "s"."ShippingAddress_ZipCode", "s"."ShippingAddress_Country_Code", "s"."ShippingAddress_Country_FullName", "s"."Id0", "s"."Name0", "s"."BillingAddress_AddressLine10", "s"."BillingAddress_AddressLine20", "s"."BillingAddress_Tags0", "s"."BillingAddress_ZipCode0", "s"."BillingAddress_Country_Code0", "s"."BillingAddress_Country_FullName0", "s"."ShippingAddress_AddressLine10", "s"."ShippingAddress_AddressLine20", "s"."ShippingAddress_Tags0", "s"."ShippingAddress_ZipCode0", "s"."ShippingAddress_Country_Code0", "s"."ShippingAddress_Country_FullName0" FROM ( SELECT DISTINCT "c"."Id", "c"."Name", "c"."BillingAddress_AddressLine1", "c"."BillingAddress_AddressLine2", "c"."BillingAddress_Tags", "c"."BillingAddress_ZipCode", "c"."BillingAddress_Country_Code", "c"."BillingAddress_Country_FullName", "c"."ShippingAddress_AddressLine1", "c"."ShippingAddress_AddressLine2", "c"."ShippingAddress_Tags", "c"."ShippingAddress_ZipCode", "c"."ShippingAddress_Country_Code", "c"."ShippingAddress_Country_FullName", "c0"."Id" AS "Id0", "c0"."Name" AS "Name0", "c0"."BillingAddress_AddressLine1" AS "BillingAddress_AddressLine10", "c0"."BillingAddress_AddressLine2" AS "BillingAddress_AddressLine20", "c0"."BillingAddress_Tags" AS "BillingAddress_Tags0", "c0"."BillingAddress_ZipCode" AS "BillingAddress_ZipCode0", "c0"."BillingAddress_Country_Code" AS "BillingAddress_Country_Code0", "c0"."BillingAddress_Country_FullName" AS "BillingAddress_Country_FullName0", "c0"."ShippingAddress_AddressLine1" AS "ShippingAddress_AddressLine10", "c0"."ShippingAddress_AddressLine2" AS "ShippingAddress_AddressLine20", "c0"."ShippingAddress_Tags" AS "ShippingAddress_Tags0", "c0"."ShippingAddress_ZipCode" AS "ShippingAddress_ZipCode0", "c0"."ShippingAddress_Country_Code" AS "ShippingAddress_Country_Code0", "c0"."ShippingAddress_Country_FullName" AS "ShippingAddress_Country_FullName0" @@ -766,7 +767,7 @@ public override async Task Project_same_nested_complex_type_twice_with_pushdown( await base.Project_same_nested_complex_type_twice_with_pushdown(async); AssertSql( -""" + """ SELECT "s"."BillingAddress_AddressLine1", "s"."BillingAddress_AddressLine2", "s"."BillingAddress_Tags", "s"."BillingAddress_ZipCode", "s"."BillingAddress_Country_Code", "s"."BillingAddress_Country_FullName", "s"."BillingAddress_AddressLine10", "s"."BillingAddress_AddressLine20", "s"."BillingAddress_Tags0", "s"."BillingAddress_ZipCode0", "s"."BillingAddress_Country_Code0", "s"."BillingAddress_Country_FullName0" FROM ( SELECT DISTINCT "c"."BillingAddress_AddressLine1", "c"."BillingAddress_AddressLine2", "c"."BillingAddress_Tags", "c"."BillingAddress_ZipCode", "c"."BillingAddress_Country_Code", "c"."BillingAddress_Country_FullName", "c0"."BillingAddress_AddressLine1" AS "BillingAddress_AddressLine10", "c0"."BillingAddress_AddressLine2" AS "BillingAddress_AddressLine20", "c0"."BillingAddress_Tags" AS "BillingAddress_Tags0", "c0"."BillingAddress_ZipCode" AS "BillingAddress_ZipCode0", "c0"."BillingAddress_Country_Code" AS "BillingAddress_Country_Code0", "c0"."BillingAddress_Country_FullName" AS "BillingAddress_Country_FullName0" @@ -781,7 +782,7 @@ public override async Task Project_same_entity_with_nested_complex_type_twice_wi await base.Project_same_entity_with_nested_complex_type_twice_with_double_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT "s0"."Id", "s0"."Name", "s0"."BillingAddress_AddressLine1", "s0"."BillingAddress_AddressLine2", "s0"."BillingAddress_Tags", "s0"."BillingAddress_ZipCode", "s0"."BillingAddress_Country_Code", "s0"."BillingAddress_Country_FullName", "s0"."ShippingAddress_AddressLine1", "s0"."ShippingAddress_AddressLine2", "s0"."ShippingAddress_Tags", "s0"."ShippingAddress_ZipCode", "s0"."ShippingAddress_Country_Code", "s0"."ShippingAddress_Country_FullName", "s0"."Id0", "s0"."Name0", "s0"."BillingAddress_AddressLine10", "s0"."BillingAddress_AddressLine20", "s0"."BillingAddress_Tags0", "s0"."BillingAddress_ZipCode0", "s0"."BillingAddress_Country_Code0", "s0"."BillingAddress_Country_FullName0", "s0"."ShippingAddress_AddressLine10", "s0"."ShippingAddress_AddressLine20", "s0"."ShippingAddress_Tags0", "s0"."ShippingAddress_ZipCode0", "s0"."ShippingAddress_Country_Code0", "s0"."ShippingAddress_Country_FullName0" @@ -803,7 +804,7 @@ public override async Task Project_same_nested_complex_type_twice_with_double_pu await base.Project_same_nested_complex_type_twice_with_double_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT "s0"."BillingAddress_AddressLine1", "s0"."BillingAddress_AddressLine2", "s0"."BillingAddress_Tags", "s0"."BillingAddress_ZipCode", "s0"."BillingAddress_Country_Code", "s0"."BillingAddress_Country_FullName", "s0"."BillingAddress_AddressLine10", "s0"."BillingAddress_AddressLine20", "s0"."BillingAddress_Tags0", "s0"."BillingAddress_ZipCode0", "s0"."BillingAddress_Country_Code0", "s0"."BillingAddress_Country_FullName0" @@ -825,7 +826,7 @@ public override async Task Project_same_entity_with_struct_nested_complex_type_t await base.Project_same_entity_with_struct_nested_complex_type_twice_with_pushdown(async); AssertSql( -""" + """ SELECT "s"."Id", "s"."Name", "s"."BillingAddress_AddressLine1", "s"."BillingAddress_AddressLine2", "s"."BillingAddress_ZipCode", "s"."BillingAddress_Country_Code", "s"."BillingAddress_Country_FullName", "s"."ShippingAddress_AddressLine1", "s"."ShippingAddress_AddressLine2", "s"."ShippingAddress_ZipCode", "s"."ShippingAddress_Country_Code", "s"."ShippingAddress_Country_FullName", "s"."Id0", "s"."Name0", "s"."BillingAddress_AddressLine10", "s"."BillingAddress_AddressLine20", "s"."BillingAddress_ZipCode0", "s"."BillingAddress_Country_Code0", "s"."BillingAddress_Country_FullName0", "s"."ShippingAddress_AddressLine10", "s"."ShippingAddress_AddressLine20", "s"."ShippingAddress_ZipCode0", "s"."ShippingAddress_Country_Code0", "s"."ShippingAddress_Country_FullName0" FROM ( SELECT DISTINCT "v"."Id", "v"."Name", "v"."BillingAddress_AddressLine1", "v"."BillingAddress_AddressLine2", "v"."BillingAddress_ZipCode", "v"."BillingAddress_Country_Code", "v"."BillingAddress_Country_FullName", "v"."ShippingAddress_AddressLine1", "v"."ShippingAddress_AddressLine2", "v"."ShippingAddress_ZipCode", "v"."ShippingAddress_Country_Code", "v"."ShippingAddress_Country_FullName", "v0"."Id" AS "Id0", "v0"."Name" AS "Name0", "v0"."BillingAddress_AddressLine1" AS "BillingAddress_AddressLine10", "v0"."BillingAddress_AddressLine2" AS "BillingAddress_AddressLine20", "v0"."BillingAddress_ZipCode" AS "BillingAddress_ZipCode0", "v0"."BillingAddress_Country_Code" AS "BillingAddress_Country_Code0", "v0"."BillingAddress_Country_FullName" AS "BillingAddress_Country_FullName0", "v0"."ShippingAddress_AddressLine1" AS "ShippingAddress_AddressLine10", "v0"."ShippingAddress_AddressLine2" AS "ShippingAddress_AddressLine20", "v0"."ShippingAddress_ZipCode" AS "ShippingAddress_ZipCode0", "v0"."ShippingAddress_Country_Code" AS "ShippingAddress_Country_Code0", "v0"."ShippingAddress_Country_FullName" AS "ShippingAddress_Country_FullName0" @@ -840,7 +841,7 @@ public override async Task Project_same_struct_nested_complex_type_twice_with_pu await base.Project_same_struct_nested_complex_type_twice_with_pushdown(async); AssertSql( -""" + """ SELECT "s"."BillingAddress_AddressLine1", "s"."BillingAddress_AddressLine2", "s"."BillingAddress_ZipCode", "s"."BillingAddress_Country_Code", "s"."BillingAddress_Country_FullName", "s"."BillingAddress_AddressLine10", "s"."BillingAddress_AddressLine20", "s"."BillingAddress_ZipCode0", "s"."BillingAddress_Country_Code0", "s"."BillingAddress_Country_FullName0" FROM ( SELECT DISTINCT "v"."BillingAddress_AddressLine1", "v"."BillingAddress_AddressLine2", "v"."BillingAddress_ZipCode", "v"."BillingAddress_Country_Code", "v"."BillingAddress_Country_FullName", "v0"."BillingAddress_AddressLine1" AS "BillingAddress_AddressLine10", "v0"."BillingAddress_AddressLine2" AS "BillingAddress_AddressLine20", "v0"."BillingAddress_ZipCode" AS "BillingAddress_ZipCode0", "v0"."BillingAddress_Country_Code" AS "BillingAddress_Country_Code0", "v0"."BillingAddress_Country_FullName" AS "BillingAddress_Country_FullName0" @@ -855,7 +856,7 @@ public override async Task Project_same_entity_with_struct_nested_complex_type_t await base.Project_same_entity_with_struct_nested_complex_type_twice_with_double_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT "s0"."Id", "s0"."Name", "s0"."BillingAddress_AddressLine1", "s0"."BillingAddress_AddressLine2", "s0"."BillingAddress_ZipCode", "s0"."BillingAddress_Country_Code", "s0"."BillingAddress_Country_FullName", "s0"."ShippingAddress_AddressLine1", "s0"."ShippingAddress_AddressLine2", "s0"."ShippingAddress_ZipCode", "s0"."ShippingAddress_Country_Code", "s0"."ShippingAddress_Country_FullName", "s0"."Id0", "s0"."Name0", "s0"."BillingAddress_AddressLine10", "s0"."BillingAddress_AddressLine20", "s0"."BillingAddress_ZipCode0", "s0"."BillingAddress_Country_Code0", "s0"."BillingAddress_Country_FullName0", "s0"."ShippingAddress_AddressLine10", "s0"."ShippingAddress_AddressLine20", "s0"."ShippingAddress_ZipCode0", "s0"."ShippingAddress_Country_Code0", "s0"."ShippingAddress_Country_FullName0" @@ -877,7 +878,7 @@ public override async Task Project_same_struct_nested_complex_type_twice_with_do await base.Project_same_struct_nested_complex_type_twice_with_double_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT "s0"."BillingAddress_AddressLine1", "s0"."BillingAddress_AddressLine2", "s0"."BillingAddress_ZipCode", "s0"."BillingAddress_Country_Code", "s0"."BillingAddress_Country_FullName", "s0"."BillingAddress_AddressLine10", "s0"."BillingAddress_AddressLine20", "s0"."BillingAddress_ZipCode0", "s0"."BillingAddress_Country_Code0", "s0"."BillingAddress_Country_FullName0" @@ -899,7 +900,7 @@ public override async Task Union_of_same_entity_with_nested_complex_type_project await base.Union_of_same_entity_with_nested_complex_type_projected_twice_with_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT "u"."Id", "u"."Name", "u"."BillingAddress_AddressLine1", "u"."BillingAddress_AddressLine2", "u"."BillingAddress_Tags", "u"."BillingAddress_ZipCode", "u"."BillingAddress_Country_Code", "u"."BillingAddress_Country_FullName", "u"."ShippingAddress_AddressLine1", "u"."ShippingAddress_AddressLine2", "u"."ShippingAddress_Tags", "u"."ShippingAddress_ZipCode", "u"."ShippingAddress_Country_Code", "u"."ShippingAddress_Country_FullName", "u"."Id0", "u"."Name0", "u"."BillingAddress_AddressLine10", "u"."BillingAddress_AddressLine20", "u"."BillingAddress_Tags0", "u"."BillingAddress_ZipCode0", "u"."BillingAddress_Country_Code0", "u"."BillingAddress_Country_FullName0", "u"."ShippingAddress_AddressLine10", "u"."ShippingAddress_AddressLine20", "u"."ShippingAddress_Tags0", "u"."ShippingAddress_ZipCode0", "u"."ShippingAddress_Country_Code0", "u"."ShippingAddress_Country_FullName0" @@ -922,7 +923,7 @@ public override async Task Union_of_same_entity_with_nested_complex_type_project await base.Union_of_same_entity_with_nested_complex_type_projected_twice_with_double_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT "u1"."Id", "u1"."Name", "u1"."BillingAddress_AddressLine1", "u1"."BillingAddress_AddressLine2", "u1"."BillingAddress_Tags", "u1"."BillingAddress_ZipCode", "u1"."BillingAddress_Country_Code", "u1"."BillingAddress_Country_FullName", "u1"."ShippingAddress_AddressLine1", "u1"."ShippingAddress_AddressLine2", "u1"."ShippingAddress_Tags", "u1"."ShippingAddress_ZipCode", "u1"."ShippingAddress_Country_Code", "u1"."ShippingAddress_Country_FullName", "u1"."Id0", "u1"."Name0", "u1"."BillingAddress_AddressLine10", "u1"."BillingAddress_AddressLine20", "u1"."BillingAddress_Tags0", "u1"."BillingAddress_ZipCode0", "u1"."BillingAddress_Country_Code0", "u1"."BillingAddress_Country_FullName0", "u1"."ShippingAddress_AddressLine10", "u1"."ShippingAddress_AddressLine20", "u1"."ShippingAddress_Tags0", "u1"."ShippingAddress_ZipCode0", "u1"."ShippingAddress_Country_Code0", "u1"."ShippingAddress_Country_FullName0" @@ -953,7 +954,7 @@ public override async Task Union_of_same_nested_complex_type_projected_twice_wit await base.Union_of_same_nested_complex_type_projected_twice_with_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT "u"."BillingAddress_AddressLine1", "u"."BillingAddress_AddressLine2", "u"."BillingAddress_Tags", "u"."BillingAddress_ZipCode", "u"."BillingAddress_Country_Code", "u"."BillingAddress_Country_FullName", "u"."BillingAddress_AddressLine10", "u"."BillingAddress_AddressLine20", "u"."BillingAddress_Tags0", "u"."BillingAddress_ZipCode0", "u"."BillingAddress_Country_Code0", "u"."BillingAddress_Country_FullName0" @@ -976,7 +977,7 @@ public override async Task Union_of_same_nested_complex_type_projected_twice_wit await base.Union_of_same_nested_complex_type_projected_twice_with_double_pushdown(async); AssertSql( -""" + """ @__p_0='50' SELECT "u1"."BillingAddress_AddressLine1", "u1"."BillingAddress_AddressLine2", "u1"."BillingAddress_Tags", "u1"."BillingAddress_ZipCode", "u1"."BillingAddress_Country_Code", "u1"."BillingAddress_Country_FullName", "u1"."BillingAddress_AddressLine10", "u1"."BillingAddress_AddressLine20", "u1"."BillingAddress_Tags0", "u1"."BillingAddress_ZipCode0", "u1"."BillingAddress_Country_Code0", "u1"."BillingAddress_Country_FullName0" @@ -1082,7 +1083,7 @@ public override async Task Projecting_property_of_complex_type_using_left_join_w await base.Projecting_property_of_complex_type_using_left_join_with_pushdown(async); AssertSql( -""" + """ SELECT "c1"."BillingAddress_ZipCode" FROM "CustomerGroup" AS "c" LEFT JOIN ( @@ -1098,7 +1099,7 @@ public override async Task Projecting_complex_from_optional_navigation_using_con await base.Projecting_complex_from_optional_navigation_using_conditional(async); AssertSql( -""" + """ @__p_0='20' SELECT "s0"."ShippingAddress_ZipCode" @@ -1120,7 +1121,7 @@ public override async Task Project_entity_with_complex_type_pushdown_and_then_le await base.Project_entity_with_complex_type_pushdown_and_then_left_join(async); AssertSql( -""" + """ @__p_0='20' @__p_1='30' diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs index 822b6326133..4205cf575f5 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs @@ -9,9 +9,7 @@ public class FromSqlQuerySqliteTest : FromSqlQueryTestBase fixture, ITestOutputHelper testOutputHelper) : base(fixture) - { - Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); - } + => Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); public override async Task FromSqlRaw_queryable_composed(bool async) { diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarFromSqlQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarFromSqlQuerySqliteTest.cs index 563ba252b5d..dca636023dc 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarFromSqlQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarFromSqlQuerySqliteTest.cs @@ -5,4 +5,5 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class GearsOfWarFromSqlQuerySqliteTest(GearsOfWarQuerySqliteFixture fixture) : GearsOfWarFromSqlQueryTestBase(fixture); +public class GearsOfWarFromSqlQuerySqliteTest(GearsOfWarQuerySqliteFixture fixture) + : GearsOfWarFromSqlQueryTestBase(fixture); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs index 0c822d8e003..6fff187cf93 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs @@ -27,7 +27,7 @@ public override async Task Non_string_concat_uses_appropriate_type_mapping(bool await base.Non_string_concat_uses_appropriate_type_mapping(async); AssertSql( -""" + """ SELECT "m"."Duration" FROM "Missions" AS "m" """); @@ -751,7 +751,7 @@ public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool await base.Where_DateOnly_FromDateTime_compared_to_property(async); AssertSql( -""" + """ SELECT "t"."Id" AS "TagId", "m"."Id" AS "MissionId" FROM "Tags" AS "t" CROSS JOIN "Missions" AS "m" @@ -764,7 +764,7 @@ public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_ await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); AssertSql( -""" + """ @__prm_0='10/11/0002' (DbType = Date) SELECT "t"."Id", "t"."GearNickName", "t"."GearSquadId", "t"."IssueDate", "t"."Note" @@ -3448,7 +3448,7 @@ public override async Task ToString_nullable_enum_property_projection(bool async await base.ToString_nullable_enum_property_projection(async); AssertSql( -""" + """ SELECT CASE "w"."AmmunitionType" WHEN 1 THEN 'Cartridge' WHEN 2 THEN 'Shell' @@ -3463,7 +3463,7 @@ public override async Task ToString_enum_contains(bool async) await base.ToString_enum_contains(async); AssertSql( -""" + """ SELECT "m"."CodeName" FROM "Missions" AS "m" WHERE instr(CAST("m"."Difficulty" AS TEXT), 'Med') > 0 @@ -3475,7 +3475,7 @@ public override async Task ToString_nullable_enum_contains(bool async) await base.ToString_nullable_enum_contains(async); AssertSql( -""" + """ SELECT "w"."Name" FROM "Weapons" AS "w" WHERE instr(CASE "w"."AmmunitionType" @@ -9743,7 +9743,7 @@ public override async Task Include_one_to_many_on_composite_key_then_orderby_key await base.Include_one_to_many_on_composite_key_then_orderby_key_properties(async); AssertSql( -""" + """ SELECT "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank", "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" FROM "Gears" AS "g" LEFT JOIN "Weapons" AS "w" ON "g"."FullName" = "w"."OwnerFullName" @@ -9772,23 +9772,23 @@ public override async Task Join_include_coalesce_simple(bool async) await base.Join_include_coalesce_simple(async); AssertSql( -""" + """ SELECT "g0"."Nickname", "g0"."SquadId", "g0"."AssignedCityName", "g0"."CityOfBirthName", "g0"."Discriminator", "g0"."FullName", "g0"."HasSoulPatch", "g0"."LeaderNickname", "g0"."LeaderSquadId", "g0"."Rank", "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank", "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId", "g"."Nickname" = 'Marcus' FROM "Gears" AS "g" LEFT JOIN "Gears" AS "g0" ON "g"."LeaderNickname" = "g0"."Nickname" LEFT JOIN "Weapons" AS "w" ON "g"."FullName" = "w"."OwnerFullName" ORDER BY "g"."Nickname", "g"."SquadId", "g0"."Nickname", "g0"."SquadId" """, - // - """ + // + """ SELECT "g0"."Nickname", "g0"."SquadId", "g0"."AssignedCityName", "g0"."CityOfBirthName", "g0"."Discriminator", "g0"."FullName", "g0"."HasSoulPatch", "g0"."LeaderNickname", "g0"."LeaderSquadId", "g0"."Rank", "g"."Nickname", "g"."SquadId", "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank" FROM "Gears" AS "g" LEFT JOIN "Gears" AS "g0" ON "g"."LeaderNickname" = "g0"."Nickname" LEFT JOIN "Weapons" AS "w" ON "g0"."FullName" = "w"."OwnerFullName" ORDER BY "g"."Nickname", "g"."SquadId", "g0"."Nickname", "g0"."SquadId" """, - // - """ + // + """ SELECT "g0"."Nickname", "g0"."SquadId", "g0"."AssignedCityName", "g0"."CityOfBirthName", "g0"."Discriminator", "g0"."FullName", "g0"."HasSoulPatch", "g0"."LeaderNickname", "g0"."LeaderSquadId", "g0"."Rank", "g"."Nickname", "g"."SquadId", "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank", "w0"."Id", "w0"."AmmunitionType", "w0"."IsAutomatic", "w0"."Name", "w0"."OwnerFullName", "w0"."SynergyWithId" FROM "Gears" AS "g" LEFT JOIN "Gears" AS "g0" ON "g"."LeaderNickname" = "g0"."Nickname" @@ -9803,15 +9803,15 @@ public override async Task Join_include_coalesce_nested(bool async) await base.Join_include_coalesce_nested(async); AssertSql( -""" + """ SELECT "g0"."Nickname", "g0"."SquadId", "g0"."AssignedCityName", "g0"."CityOfBirthName", "g0"."Discriminator", "g0"."FullName", "g0"."HasSoulPatch", "g0"."LeaderNickname", "g0"."LeaderSquadId", "g0"."Rank", "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank", "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId", "g"."Nickname" = 'Marcus' FROM "Gears" AS "g" LEFT JOIN "Gears" AS "g0" ON "g"."LeaderNickname" = "g0"."Nickname" LEFT JOIN "Weapons" AS "w" ON "g"."FullName" = "w"."OwnerFullName" ORDER BY "g"."Nickname", "g"."SquadId", "g0"."Nickname", "g0"."SquadId" """, - // - """ + // + """ SELECT "g0"."Nickname", "g0"."SquadId", "g0"."AssignedCityName", "g0"."CityOfBirthName", "g0"."Discriminator", "g0"."FullName", "g0"."HasSoulPatch", "g0"."LeaderNickname", "g0"."LeaderSquadId", "g0"."Rank", "g"."Nickname", "g"."SquadId", "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId", "w0"."Id", "w0"."AmmunitionType", "w0"."IsAutomatic", "w0"."Name", "w0"."OwnerFullName", "w0"."SynergyWithId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank", "w1"."Id", "w1"."AmmunitionType", "w1"."IsAutomatic", "w1"."Name", "w1"."OwnerFullName", "w1"."SynergyWithId" FROM "Gears" AS "g" LEFT JOIN "Gears" AS "g0" ON "g"."LeaderNickname" = "g0"."Nickname" @@ -9827,7 +9827,7 @@ public override async Task Join_include_conditional(bool async) await base.Join_include_conditional(async); AssertSql( -""" + """ SELECT "g0"."Nickname" IS NOT NULL AND "g0"."SquadId" IS NOT NULL, "g0"."Nickname", "g0"."SquadId", "g0"."AssignedCityName", "g0"."CityOfBirthName", "g0"."Discriminator", "g0"."FullName", "g0"."HasSoulPatch", "g0"."LeaderNickname", "g0"."LeaderSquadId", "g0"."Rank", "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank", "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId", "g"."Nickname" = 'Marcus' FROM "Gears" AS "g" LEFT JOIN "Gears" AS "g0" ON "g"."LeaderNickname" = "g0"."Nickname" @@ -9841,7 +9841,7 @@ public override async Task Derived_reference_is_skipped_when_base_type(bool asyn await base.Derived_reference_is_skipped_when_base_type(async); AssertSql( -""" + """ SELECT "l"."Name", "l"."Discriminator", "l"."LocustHordeId", "l"."ThreatLevel", "l"."ThreatLevelByte", "l"."ThreatLevelNullableByte", "l"."DefeatedByNickname", "l"."DefeatedBySquadId", "l"."HighCommandId", "l0"."Id", "l0"."IsOperational", "l0"."Name" FROM "LocustLeaders" AS "l" LEFT JOIN "LocustHighCommands" AS "l0" ON "l"."HighCommandId" = "l0"."Id" diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/IncludeOneToOneSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/IncludeOneToOneSqliteTest.cs index 0d31339197f..cf47b21fbab 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/IncludeOneToOneSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/IncludeOneToOneSqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class IncludeOneToOneSqliteTest(IncludeOneToOneSqliteTest.OneToOneQuerySqliteFixture fixture) : IncludeOneToOneTestBase(fixture) +public class IncludeOneToOneSqliteTest(IncludeOneToOneSqliteTest.OneToOneQuerySqliteFixture fixture) + : IncludeOneToOneTestBase(fixture) { public class OneToOneQuerySqliteFixture : OneToOneQueryFixtureBase, ITestSqlLoggerFactory { diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceQuerySqliteTest.cs index 4868abd1d02..b3d847c1f9d 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceQuerySqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class InheritanceQuerySqliteTest(TPHInheritanceQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : TPHInheritanceQueryTestBase(fixture, testOutputHelper) +public class InheritanceQuerySqliteTest(TPHInheritanceQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : TPHInheritanceQueryTestBase(fixture, testOutputHelper) { protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceRelationshipsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceRelationshipsQuerySqliteTest.cs index 7436bf8d93e..143c10781d2 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceRelationshipsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceRelationshipsQuerySqliteTest.cs @@ -5,8 +5,10 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class InheritanceRelationshipsQuerySqliteTest(InheritanceRelationshipsQuerySqliteTest.InheritanceRelationshipsQuerySqliteFixture fixture) : - InheritanceRelationshipsQueryRelationalTestBase(fixture) +public class InheritanceRelationshipsQuerySqliteTest( + InheritanceRelationshipsQuerySqliteTest.InheritanceRelationshipsQuerySqliteFixture fixture) : + InheritanceRelationshipsQueryRelationalTestBase( + fixture) { public class InheritanceRelationshipsQuerySqliteFixture : InheritanceRelationshipsQueryRelationalFixture { diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/JsonQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/JsonQuerySqliteFixture.cs index 691db31b098..fbbcc29d4a2 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/JsonQuerySqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/JsonQuerySqliteFixture.cs @@ -11,6 +11,7 @@ public class JsonQuerySqliteFixture : JsonQueryRelationalFixture { protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { base.OnModelCreating(modelBuilder, context); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/JsonQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/JsonQuerySqliteTest.cs index 05300c38a01..13e953bf006 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/JsonQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/JsonQuerySqliteTest.cs @@ -446,12 +446,13 @@ public override async Task Custom_naming_projection_owned_reference(bool async) """); } - public override async Task Json_nested_collection_anonymous_projection_of_primitives_in_projection_NoTrackingWithIdentityResolution(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Json_nested_collection_anonymous_projection_of_primitives_in_projection_NoTrackingWithIdentityResolution(async))) - .Message); + public override async Task Json_nested_collection_anonymous_projection_of_primitives_in_projection_NoTrackingWithIdentityResolution( + bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Json_nested_collection_anonymous_projection_of_primitives_in_projection_NoTrackingWithIdentityResolution(async))) + .Message); // Sqlit throws APPLY error, but base expects different exception public override Task Json_branch_collection_distinct_and_other_collection_AsNoTrackingWithIdentityResolution(bool async) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyNoTrackingQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyNoTrackingQuerySqliteTest.cs index 6ba6eed7e5f..00c3ee62cbb 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyNoTrackingQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyNoTrackingQuerySqliteTest.cs @@ -10,7 +10,6 @@ namespace Microsoft.EntityFrameworkCore.Query; public class ManyToManyNoTrackingQuerySqliteTest(ManyToManyQuerySqliteFixture fixture) : ManyToManyNoTrackingQueryRelationalTestBase(fixture) { - // Sqlite does not support Apply operations public override async Task Skip_navigation_order_by_single_or_default(bool async) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyNoTrackingSplitQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyNoTrackingSplitQuerySqliteTest.cs index b1ca2b34fe0..4ea7fc9278f 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyNoTrackingSplitQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyNoTrackingSplitQuerySqliteTest.cs @@ -10,7 +10,6 @@ namespace Microsoft.EntityFrameworkCore.Query; public class ManyToManyNoTrackingSplitQuerySqliteTest(ManyToManySplitQuerySqliteFixture fixture) : ManyToManyNoTrackingQueryRelationalTestBase(fixture) { - // Sqlite does not support Apply operations public override async Task Skip_navigation_order_by_single_or_default(bool async) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyQuerySqliteTest.cs index a488d8dbe90..c8b39d88c06 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyQuerySqliteTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class ManyToManyQuerySqliteTest(ManyToManyQuerySqliteFixture fixture) : ManyToManyQueryRelationalTestBase(fixture) +public class ManyToManyQuerySqliteTest(ManyToManyQuerySqliteFixture fixture) + : ManyToManyQueryRelationalTestBase(fixture) { public override async Task Skip_navigation_order_by_single_or_default(bool async) => Assert.Equal( diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManySplitQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManySplitQuerySqliteTest.cs index 5f2b1d06462..7c4798693cd 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManySplitQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManySplitQuerySqliteTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class ManyToManySplitQuerySqliteTest(ManyToManySplitQuerySqliteFixture fixture) : ManyToManyQueryRelationalTestBase(fixture) +public class ManyToManySplitQuerySqliteTest(ManyToManySplitQuerySqliteFixture fixture) + : ManyToManyQueryRelationalTestBase(fixture) { public override async Task Skip_navigation_order_by_single_or_default(bool async) => Assert.Equal( diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/MappingQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/MappingQuerySqliteTest.cs index 2ad51793417..7351435aa57 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/MappingQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/MappingQuerySqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class MappingQuerySqliteTest(MappingQuerySqliteTest.MappingQuerySqliteFixture fixture) : MappingQueryTestBase(fixture) +public class MappingQuerySqliteTest(MappingQuerySqliteTest.MappingQuerySqliteFixture fixture) + : MappingQueryTestBase(fixture) { public override void All_customers() { diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs index b60bc64d9ea..4f5c029aa42 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs @@ -63,8 +63,6 @@ SELECT ef_avg(ef_divide(CAST("o"."Quantity" AS TEXT), '2.0')) """); } - - public override async Task Average_over_max_subquery(bool async) { await base.Average_over_max_subquery(async); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqliteTest.cs index e2fe510cad3..592ac1f807c 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqliteTest.cs @@ -5,4 +5,5 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class NorthwindAsNoTrackingQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : NorthwindAsNoTrackingQueryTestBase>(fixture); +public class NorthwindAsNoTrackingQuerySqliteTest(NorthwindQuerySqliteFixture fixture) + : NorthwindAsNoTrackingQueryTestBase>(fixture); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsTrackingQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsTrackingQuerySqliteTest.cs index db5a1f6bd44..5331f1d6491 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsTrackingQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsTrackingQuerySqliteTest.cs @@ -5,4 +5,5 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class NorthwindAsTrackingQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : NorthwindAsTrackingQueryTestBase>(fixture); +public class NorthwindAsTrackingQuerySqliteTest(NorthwindQuerySqliteFixture fixture) + : NorthwindAsTrackingQueryTestBase>(fixture); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindChangeTrackingQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindChangeTrackingQuerySqliteTest.cs index ec1d09c5ae7..6cdf6312fcc 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindChangeTrackingQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindChangeTrackingQuerySqliteTest.cs @@ -7,8 +7,9 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class NorthwindChangeTrackingQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : NorthwindChangeTrackingQueryTestBase< - NorthwindQuerySqliteFixture>(fixture) +public class NorthwindChangeTrackingQuerySqliteTest(NorthwindQuerySqliteFixture fixture) + : NorthwindChangeTrackingQueryTestBase< + NorthwindQuerySqliteFixture>(fixture) { protected override NorthwindContext CreateNoTrackingContext() => new NorthwindSqliteContext( diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindCompiledQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindCompiledQuerySqliteTest.cs index a0edaa6c372..eda573f3af1 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindCompiledQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindCompiledQuerySqliteTest.cs @@ -5,4 +5,5 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class NorthwindCompiledQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : NorthwindCompiledQueryTestBase>(fixture); +public class NorthwindCompiledQuerySqliteTest(NorthwindQuerySqliteFixture fixture) + : NorthwindCompiledQueryTestBase>(fixture); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs index f409eff864f..aa552d1c51b 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs @@ -14,9 +14,7 @@ public NorthwindDbFunctionsQuerySqliteTest( NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) - { - Fixture.TestSqlLoggerFactory.Clear(); - } + => Fixture.TestSqlLoggerFactory.Clear(); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindNavigationsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindNavigationsQuerySqliteTest.cs index a1ddf661606..a5fb3a81226 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindNavigationsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindNavigationsQuerySqliteTest.cs @@ -5,5 +5,6 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class NorthwindNavigationsQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : NorthwindNavigationsQueryRelationalTestBase< - NorthwindQuerySqliteFixture>(fixture); +public class NorthwindNavigationsQuerySqliteTest(NorthwindQuerySqliteFixture fixture) + : NorthwindNavigationsQueryRelationalTestBase< + NorthwindQuerySqliteFixture>(fixture); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSqlQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSqlQuerySqliteTest.cs index 7a9f6cd369d..4748094b687 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSqlQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSqlQuerySqliteTest.cs @@ -11,9 +11,7 @@ public class NorthwindSqlQuerySqliteTest : NorthwindSqlQueryTestBase fixture, ITestOutputHelper testOutputHelper) : base(fixture) - { - Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); - } + => Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); protected override DbParameter CreateDbParameter(string name, object value) => new SqliteParameter { ParameterName = name, Value = value }; diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NullKeysSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NullKeysSqliteTest.cs index 4b4c7510770..fabd6ef8820 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NullKeysSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NullKeysSqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class NullKeysSqliteTest(NullKeysSqliteTest.NullKeysSqliteFixture fixture) : NullKeysTestBase(fixture) +public class NullKeysSqliteTest(NullKeysSqliteTest.NullKeysSqliteFixture fixture) + : NullKeysTestBase(fixture) { public class NullKeysSqliteFixture : NullKeysFixtureBase { diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteTest.cs index 5018e8481a7..e47b0c32c65 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteTest.cs @@ -12,11 +12,9 @@ public class NullSemanticsQuerySqliteTest : NullSemanticsQueryTestBase Fixture.TestSqlLoggerFactory.Clear(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); public override async Task Rewrite_compare_int_with_int(bool async) { await base.Rewrite_compare_int_with_int(async); @@ -1089,8 +1087,8 @@ SELECT 1 FROM "Entities2" AS "e0" WHERE "e0"."NullableStringA" = "e"."NullableStringB" OR ("e0"."NullableStringA" IS NULL AND "e"."NullableStringB" IS NULL)) """, - // - """ + // + """ SELECT "e"."Id" FROM "Entities1" AS "e" WHERE NOT EXISTS ( diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/OwnedQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/OwnedQuerySqliteTest.cs index 6b09cd15870..2e1fc0c3790 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/OwnedQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/OwnedQuerySqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class OwnedQuerySqliteTest(OwnedQuerySqliteTest.OwnedQuerySqliteFixture fixture) : OwnedQueryRelationalTestBase(fixture) +public class OwnedQuerySqliteTest(OwnedQuerySqliteTest.OwnedQuerySqliteFixture fixture) + : OwnedQueryRelationalTestBase(fixture) { public class OwnedQuerySqliteFixture : RelationalOwnedQueryFixture { diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/PrecompiledQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/PrecompiledQuerySqliteTest.cs index f124247ed7f..6accbe38fd6 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/PrecompiledQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/PrecompiledQuerySqliteTest.cs @@ -27,6 +27,7 @@ public class PrecompiledQuerySqliteFixture : PrecompiledQueryRelationalFixture protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; - public override PrecompiledQueryTestHelpers PrecompiledQueryTestHelpers => SqlitePrecompiledQueryTestHelpers.Instance; + public override PrecompiledQueryTestHelpers PrecompiledQueryTestHelpers + => SqlitePrecompiledQueryTestHelpers.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/PrecompiledSqlPregenerationQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/PrecompiledSqlPregenerationQuerySqliteTest.cs index 072134128f5..03176c25504 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/PrecompiledSqlPregenerationQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/PrecompiledSqlPregenerationQuerySqliteTest.cs @@ -17,6 +17,7 @@ public class PrecompiledSqlPregenerationQuerySqliteFixture : PrecompiledSqlPrege protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; - public override PrecompiledQueryTestHelpers PrecompiledQueryTestHelpers => SqlitePrecompiledQueryTestHelpers.Instance; + public override PrecompiledQueryTestHelpers PrecompiledQueryTestHelpers + => SqlitePrecompiledQueryTestHelpers.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs index 269c5dc9194..00fe2e3436a 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs @@ -525,8 +525,8 @@ public override async Task Parameter_collection_HashSet_of_ints_Contains_int(boo FROM json_each(@__ints_0) AS "i" ) """, - // - """ + // + """ @__ints_0='[10,999]' (Size = 8) SELECT "p"."Id", "p"."Bool", "p"."Bools", "p"."DateTime", "p"."DateTimes", "p"."Enum", "p"."Enums", "p"."Int", "p"."Ints", "p"."NullableInt", "p"."NullableInts", "p"."NullableString", "p"."NullableStrings", "p"."String", "p"."Strings" @@ -1955,7 +1955,8 @@ public async Task Empty_string_used_for_primitive_collection_throws(bool async) public class SimpleContext(SqliteConnection connection) : DbContext { - public DbSet SimpleEntities => Set(); + public DbSet SimpleEntities + => Set(); protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlite(connection); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/QueryNoClientEvalSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/QueryNoClientEvalSqliteTest.cs index f86ae7892f7..6fc630baf15 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/QueryNoClientEvalSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/QueryNoClientEvalSqliteTest.cs @@ -5,4 +5,5 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class QueryNoClientEvalSqliteTest(QueryNoClientEvalSqliteFixture fixture) : QueryNoClientEvalTestBase(fixture); +public class QueryNoClientEvalSqliteTest(QueryNoClientEvalSqliteFixture fixture) + : QueryNoClientEvalTestBase(fixture); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/SqlQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/SqlQuerySqliteTest.cs index 8a80cba557a..2614a5786fd 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/SqlQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/SqlQuerySqliteTest.cs @@ -11,9 +11,7 @@ public class SqlQuerySqliteTest : SqlQueryTestBase fixture, ITestOutputHelper testOutputHelper) : base(fixture) - { - Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); - } + => Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); public override async Task SqlQueryRaw_queryable_composed(bool async) { diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPCFiltersInheritanceQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPCFiltersInheritanceQuerySqliteTest.cs index 5c2b7e47f64..8617b19de0e 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPCFiltersInheritanceQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPCFiltersInheritanceQuerySqliteTest.cs @@ -5,4 +5,5 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class TPCFiltersInheritanceQuerySqliteTest(TPCFiltersInheritanceQuerySqliteFixture fixture) : TPCFiltersInheritanceQueryTestBase(fixture); +public class TPCFiltersInheritanceQuerySqliteTest(TPCFiltersInheritanceQuerySqliteFixture fixture) + : TPCFiltersInheritanceQueryTestBase(fixture); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPCGearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPCGearsOfWarQuerySqliteTest.cs index 9fe95d394df..07174a52b7b 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPCGearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPCGearsOfWarQuerySqliteTest.cs @@ -414,7 +414,7 @@ public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool await base.Where_DateOnly_FromDateTime_compared_to_property(async); AssertSql( -""" + """ SELECT "t"."Id" AS "TagId", "m"."Id" AS "MissionId" FROM "Tags" AS "t" CROSS JOIN "Missions" AS "m" @@ -427,7 +427,7 @@ public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_ await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); AssertSql( -""" + """ @__prm_0='10/11/0002' (DbType = Date) SELECT "t"."Id", "t"."GearNickName", "t"."GearSquadId", "t"."IssueDate", "t"."Note" diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPCInheritanceQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPCInheritanceQuerySqliteTest.cs index 5c5286a8daf..635b05f6158 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPCInheritanceQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPCInheritanceQuerySqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class TPCInheritanceQuerySqliteTest(TPCInheritanceQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : TPCInheritanceQueryTestBase(fixture, testOutputHelper) +public class TPCInheritanceQuerySqliteTest(TPCInheritanceQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : TPCInheritanceQueryTestBase(fixture, testOutputHelper) { protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPCManyToManyNoTrackingQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPCManyToManyNoTrackingQuerySqliteTest.cs index 5cc7a930dfd..bbfee8c56b8 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPCManyToManyNoTrackingQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPCManyToManyNoTrackingQuerySqliteTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class TPCManyToManyNoTrackingQuerySqliteTest(TPCManyToManyQuerySqliteFixture fixture) : TPCManyToManyNoTrackingQueryRelationalTestBase(fixture) +public class TPCManyToManyNoTrackingQuerySqliteTest(TPCManyToManyQuerySqliteFixture fixture) + : TPCManyToManyNoTrackingQueryRelationalTestBase(fixture) { public override async Task Skip_navigation_order_by_single_or_default(bool async) => Assert.Equal( diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPCManyToManyQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPCManyToManyQuerySqliteTest.cs index 799f133093d..b601dc89656 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPCManyToManyQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPCManyToManyQuerySqliteTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class TPCManyToManyQuerySqliteTest(TPCManyToManyQuerySqliteFixture fixture) : TPCManyToManyQueryRelationalTestBase(fixture) +public class TPCManyToManyQuerySqliteTest(TPCManyToManyQuerySqliteFixture fixture) + : TPCManyToManyQueryRelationalTestBase(fixture) { public override async Task Skip_navigation_order_by_single_or_default(bool async) => Assert.Equal( diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPHFiltersInheritanceQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPHFiltersInheritanceQuerySqliteTest.cs index 7a39fe9b968..87cd8b67fe2 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPHFiltersInheritanceQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPHFiltersInheritanceQuerySqliteTest.cs @@ -5,4 +5,5 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class TPHFiltersInheritanceQuerySqliteTest(TPHFiltersInheritanceQuerySqliteFixture fixture) : FiltersInheritanceQueryTestBase(fixture); +public class TPHFiltersInheritanceQuerySqliteTest(TPHFiltersInheritanceQuerySqliteFixture fixture) + : FiltersInheritanceQueryTestBase(fixture); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPTFiltersInheritanceQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPTFiltersInheritanceQuerySqliteTest.cs index 208b7c7258a..441f5532588 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPTFiltersInheritanceQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPTFiltersInheritanceQuerySqliteTest.cs @@ -5,4 +5,5 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class TPTFiltersInheritanceQuerySqliteTest(TPTFiltersInheritanceQuerySqliteFixture fixture) : TPTFiltersInheritanceQueryTestBase(fixture); +public class TPTFiltersInheritanceQuerySqliteTest(TPTFiltersInheritanceQuerySqliteFixture fixture) + : TPTFiltersInheritanceQueryTestBase(fixture); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs index 3b05ecd09e3..bef3059af39 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs @@ -414,7 +414,7 @@ public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool await base.Where_DateOnly_FromDateTime_compared_to_property(async); AssertSql( -""" + """ SELECT "t"."Id" AS "TagId", "m"."Id" AS "MissionId" FROM "Tags" AS "t" CROSS JOIN "Missions" AS "m" @@ -427,7 +427,7 @@ public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_ await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); AssertSql( -""" + """ @__prm_0='10/11/0002' (DbType = Date) SELECT "t"."Id", "t"."GearNickName", "t"."GearSquadId", "t"."IssueDate", "t"."Note" diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPTInheritanceQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPTInheritanceQuerySqliteTest.cs index d7c8336ec69..beb7e8261a1 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPTInheritanceQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPTInheritanceQuerySqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class TPTInheritanceQuerySqliteTest(TPTInheritanceQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : TPTInheritanceQueryTestBase(fixture, testOutputHelper) +public class TPTInheritanceQuerySqliteTest(TPTInheritanceQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : TPTInheritanceQueryTestBase(fixture, testOutputHelper) { protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqliteTest.cs index ccd93dc16d2..fed2ba01166 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqliteTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class TPTManyToManyNoTrackingQuerySqliteTest(TPTManyToManyQuerySqliteFixture fixture) : TPTManyToManyNoTrackingQueryRelationalTestBase(fixture) +public class TPTManyToManyNoTrackingQuerySqliteTest(TPTManyToManyQuerySqliteFixture fixture) + : TPTManyToManyNoTrackingQueryRelationalTestBase(fixture) { public override async Task Skip_navigation_order_by_single_or_default(bool async) => Assert.Equal( diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyQuerySqliteTest.cs index bf85cb75e25..78a619f8dfa 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyQuerySqliteTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore.Query; #nullable disable -public class TPTManyToManyQuerySqliteTest(TPTManyToManyQuerySqliteFixture fixture) : TPTManyToManyQueryRelationalTestBase(fixture) +public class TPTManyToManyQuerySqliteTest(TPTManyToManyQuerySqliteFixture fixture) + : TPTManyToManyQueryRelationalTestBase(fixture) { public override async Task Skip_navigation_order_by_single_or_default(bool async) => Assert.Equal( diff --git a/test/EFCore.Sqlite.FunctionalTests/QueryExpressionInterceptionSqliteTestBase.cs b/test/EFCore.Sqlite.FunctionalTests/QueryExpressionInterceptionSqliteTestBase.cs index 4338cba3ca1..dd91b2f023b 100644 --- a/test/EFCore.Sqlite.FunctionalTests/QueryExpressionInterceptionSqliteTestBase.cs +++ b/test/EFCore.Sqlite.FunctionalTests/QueryExpressionInterceptionSqliteTestBase.cs @@ -33,7 +33,8 @@ protected override bool ShouldSubscribeToDiagnosticListener } } - public class QueryExpressionInterceptionWithDiagnosticsSqliteTest(QueryExpressionInterceptionWithDiagnosticsSqliteTest.InterceptionSqliteFixture fixture) + public class QueryExpressionInterceptionWithDiagnosticsSqliteTest( + QueryExpressionInterceptionWithDiagnosticsSqliteTest.InterceptionSqliteFixture fixture) : QueryExpressionInterceptionSqliteTestBase(fixture), IClassFixture { diff --git a/test/EFCore.Sqlite.FunctionalTests/SaveChangesInterceptionSqliteTestBase.cs b/test/EFCore.Sqlite.FunctionalTests/SaveChangesInterceptionSqliteTestBase.cs index b6d547e3e1c..23caea566db 100644 --- a/test/EFCore.Sqlite.FunctionalTests/SaveChangesInterceptionSqliteTestBase.cs +++ b/test/EFCore.Sqlite.FunctionalTests/SaveChangesInterceptionSqliteTestBase.cs @@ -32,7 +32,8 @@ protected override bool ShouldSubscribeToDiagnosticListener } } - public class SaveChangesInterceptionWithDiagnosticsSqliteTest(SaveChangesInterceptionWithDiagnosticsSqliteTest.InterceptionSqliteFixture fixture) + public class SaveChangesInterceptionWithDiagnosticsSqliteTest( + SaveChangesInterceptionWithDiagnosticsSqliteTest.InterceptionSqliteFixture fixture) : SaveChangesInterceptionSqliteTestBase(fixture), IClassFixture { diff --git a/test/EFCore.Sqlite.FunctionalTests/Scaffolding/CompiledModelSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Scaffolding/CompiledModelSqliteTest.cs index d1a4db51221..010499c6527 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Scaffolding/CompiledModelSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Scaffolding/CompiledModelSqliteTest.cs @@ -6,8 +6,8 @@ using System.Runtime.CompilerServices; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Sqlite.Design.Internal; -using NetTopologySuite.Geometries; using NetTopologySuite; +using NetTopologySuite.Geometries; namespace Microsoft.EntityFrameworkCore.Scaffolding; @@ -92,15 +92,19 @@ public override Task Sequences() public override Task Tpc_Sprocs() => Task.CompletedTask; - protected override TestHelpers TestHelpers => SqliteTestHelpers.Instance; - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override TestHelpers TestHelpers + => SqliteTestHelpers.Instance; + + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; protected override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) { builder = base.AddOptions(builder) - .ConfigureWarnings(w => w - .Ignore(SqliteEventId.SchemaConfiguredWarning) - .Ignore(SqliteEventId.CompositeKeyWithValueGeneration)); + .ConfigureWarnings( + w => w + .Ignore(SqliteEventId.SchemaConfiguredWarning) + .Ignore(SqliteEventId.CompositeKeyWithValueGeneration)); new SqliteDbContextOptionsBuilder(builder).UseNetTopologySuite(); return builder; } diff --git a/test/EFCore.Sqlite.FunctionalTests/SqliteApiConsistencyTest.cs b/test/EFCore.Sqlite.FunctionalTests/SqliteApiConsistencyTest.cs index 262a390bc20..31825860234 100644 --- a/test/EFCore.Sqlite.FunctionalTests/SqliteApiConsistencyTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/SqliteApiConsistencyTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class SqliteApiConsistencyTest(SqliteApiConsistencyTest.SqliteApiConsistencyFixture fixture) : ApiConsistencyTestBase(fixture) +public class SqliteApiConsistencyTest(SqliteApiConsistencyTest.SqliteApiConsistencyFixture fixture) + : ApiConsistencyTestBase(fixture) { protected override void AddServices(ServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkSqlite(); @@ -34,7 +35,9 @@ public override Type ConventionExtensions, Type ConventionBuilderExtensions, Type RuntimeExtensions)> MetadataExtensionTypes - { get; } + { + get; + } = new() { { diff --git a/test/EFCore.Sqlite.FunctionalTests/StoreGeneratedFixupSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/StoreGeneratedFixupSqliteTest.cs index aa4b7ebd418..e40f6e4b3a9 100644 --- a/test/EFCore.Sqlite.FunctionalTests/StoreGeneratedFixupSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/StoreGeneratedFixupSqliteTest.cs @@ -7,8 +7,9 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class StoreGeneratedFixupSqliteTest(StoreGeneratedFixupSqliteTest.StoreGeneratedFixupSqliteFixture fixture) : StoreGeneratedFixupRelationalTestBase< - StoreGeneratedFixupSqliteTest.StoreGeneratedFixupSqliteFixture>(fixture) +public class StoreGeneratedFixupSqliteTest(StoreGeneratedFixupSqliteTest.StoreGeneratedFixupSqliteFixture fixture) + : StoreGeneratedFixupRelationalTestBase< + StoreGeneratedFixupSqliteTest.StoreGeneratedFixupSqliteFixture>(fixture) { [ConditionalFact] public void Temp_values_can_be_made_permanent() diff --git a/test/EFCore.Sqlite.FunctionalTests/TransactionInterceptionSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/TransactionInterceptionSqliteTest.cs index 028369c7f36..7396072f8b7 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TransactionInterceptionSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TransactionInterceptionSqliteTest.cs @@ -32,7 +32,8 @@ protected override bool ShouldSubscribeToDiagnosticListener } } - public class TransactionInterceptionWithDiagnosticsSqliteTest(TransactionInterceptionWithDiagnosticsSqliteTest.InterceptionSqliteFixture fixture) + public class TransactionInterceptionWithDiagnosticsSqliteTest( + TransactionInterceptionWithDiagnosticsSqliteTest.InterceptionSqliteFixture fixture) : TransactionInterceptionSqliteTestBase(fixture), IClassFixture { diff --git a/test/EFCore.Sqlite.FunctionalTests/TwoDatabasesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/TwoDatabasesSqliteTest.cs index f3b6a70ed7f..9aabe4fddb8 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TwoDatabasesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TwoDatabasesSqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class TwoDatabasesSqliteTest(TwoDatabasesSqliteTest.TwoDatabasesFixture fixture) : TwoDatabasesTestBase(fixture), IClassFixture +public class TwoDatabasesSqliteTest(TwoDatabasesSqliteTest.TwoDatabasesFixture fixture) + : TwoDatabasesTestBase(fixture), IClassFixture { protected new TwoDatabasesFixture Fixture => (TwoDatabasesFixture)base.Fixture; diff --git a/test/EFCore.Sqlite.FunctionalTests/Update/JsonUpdateSqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Update/JsonUpdateSqliteFixture.cs index d8f6ebdda8a..c6b42f3648b 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Update/JsonUpdateSqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Update/JsonUpdateSqliteFixture.cs @@ -11,6 +11,7 @@ public class JsonUpdateSqliteFixture : JsonUpdateFixtureBase { protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { base.OnModelCreating(modelBuilder, context); diff --git a/test/EFCore.Sqlite.FunctionalTests/Update/JsonUpdateSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Update/JsonUpdateSqliteTest.cs index 00af6621822..a1135663a47 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Update/JsonUpdateSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Update/JsonUpdateSqliteTest.cs @@ -11,9 +11,7 @@ public class JsonUpdateSqliteTest : JsonUpdateTestBase { public JsonUpdateSqliteTest(JsonUpdateSqliteFixture fixture) : base(fixture) - { - ClearLog(); - } + => ClearLog(); public override async Task Add_element_to_json_collection_branch() { @@ -2129,7 +2127,7 @@ LIMIT 2 break; default: AssertSql( - """ + """ @p0='2' @p1=NULL (DbType = Int32) @p2='NewEntity' (Size = 9) @@ -2137,15 +2135,15 @@ LIMIT 2 INSERT INTO "JsonEntitiesBasic" ("Id", "EntityBasicId", "Name") VALUES (@p0, @p1, @p2); """, - // - """ + // + """ SELECT "j"."Id", "j"."EntityBasicId", "j"."Name", "j"."OwnedCollectionRoot", "j"."OwnedReferenceRoot" FROM "JsonEntitiesBasic" AS "j" WHERE "j"."Id" = 2 LIMIT 2 """, - // - """ + // + """ @p0='[]' (Nullable = false) (Size = 2) @p3='2' @p1=NULL (DbType = Int32) @@ -2155,12 +2153,12 @@ LIMIT 2 WHERE "Id" = @p3 RETURNING 1; """, - // - """ + // + """ select OwnedCollectionRoot from JsonEntitiesBasic where Id = 2 """, - // - """ + // + """ SELECT "j"."Id", "j"."EntityBasicId", "j"."Name", "j"."OwnedCollectionRoot", "j"."OwnedReferenceRoot" FROM "JsonEntitiesBasic" AS "j" WHERE "j"."Id" = 2 @@ -2288,21 +2286,21 @@ public override async Task Add_and_update_nested_optional_primitive_collection(b { await base.Add_and_update_nested_optional_primitive_collection(value); - string characterCollection = value switch + var characterCollection = value switch { true => "[\"A\"]", false => "[]", _ => "null" }; - string parameterSize = value switch + var parameterSize = value switch { true => "1562", false => "1559", _ => "1561" }; - string updateParameter = value switch + var updateParameter = value switch { true => "NULL (Nullable = false)", false => "'[\"Z\"]' (Nullable = false) (Size = 5)", @@ -2310,7 +2308,11 @@ public override async Task Add_and_update_nested_optional_primitive_collection(b }; AssertSql( - @"@p0='[{""TestBoolean"":false,""TestBooleanCollection"":[],""TestByte"":0,""TestByteArray"":null,""TestByteCollection"":null,""TestCharacter"":""\u0000"",""TestCharacterCollection"":" + characterCollection + @",""TestDateOnly"":""0001-01-01"",""TestDateOnlyCollection"":[],""TestDateTime"":""0001-01-01 00:00:00"",""TestDateTimeCollection"":[],""TestDateTimeOffset"":""0001-01-01 00:00:00+00:00"",""TestDateTimeOffsetCollection"":[],""TestDecimal"":""0.0"",""TestDecimalCollection"":[],""TestDefaultString"":null,""TestDefaultStringCollection"":[],""TestDouble"":0,""TestDoubleCollection"":[],""TestEnum"":0,""TestEnumCollection"":[],""TestEnumWithIntConverter"":0,""TestEnumWithIntConverterCollection"":[],""TestGuid"":""00000000-0000-0000-0000-000000000000"",""TestGuidCollection"":[],""TestInt16"":0,""TestInt16Collection"":[],""TestInt32"":0,""TestInt32Collection"":[],""TestInt64"":0,""TestInt64Collection"":[],""TestMaxLengthString"":null,""TestMaxLengthStringCollection"":[],""TestNullableEnum"":null,""TestNullableEnumCollection"":[],""TestNullableEnumWithConverterThatHandlesNulls"":null,""TestNullableEnumWithConverterThatHandlesNullsCollection"":[],""TestNullableEnumWithIntConverter"":null,""TestNullableEnumWithIntConverterCollection"":[],""TestNullableInt32"":null,""TestNullableInt32Collection"":[],""TestSignedByte"":0,""TestSignedByteCollection"":[],""TestSingle"":0,""TestSingleCollection"":[],""TestTimeOnly"":""00:00:00.0000000"",""TestTimeOnlyCollection"":[],""TestTimeSpan"":""0:00:00"",""TestTimeSpanCollection"":[],""TestUnsignedInt16"":0,""TestUnsignedInt16Collection"":[],""TestUnsignedInt32"":0,""TestUnsignedInt32Collection"":[],""TestUnsignedInt64"":0,""TestUnsignedInt64Collection"":[]}]' (Nullable = false) (Size = " + parameterSize + @") + @"@p0='[{""TestBoolean"":false,""TestBooleanCollection"":[],""TestByte"":0,""TestByteArray"":null,""TestByteCollection"":null,""TestCharacter"":""\u0000"",""TestCharacterCollection"":" + + characterCollection + + @",""TestDateOnly"":""0001-01-01"",""TestDateOnlyCollection"":[],""TestDateTime"":""0001-01-01 00:00:00"",""TestDateTimeCollection"":[],""TestDateTimeOffset"":""0001-01-01 00:00:00+00:00"",""TestDateTimeOffsetCollection"":[],""TestDecimal"":""0.0"",""TestDecimalCollection"":[],""TestDefaultString"":null,""TestDefaultStringCollection"":[],""TestDouble"":0,""TestDoubleCollection"":[],""TestEnum"":0,""TestEnumCollection"":[],""TestEnumWithIntConverter"":0,""TestEnumWithIntConverterCollection"":[],""TestGuid"":""00000000-0000-0000-0000-000000000000"",""TestGuidCollection"":[],""TestInt16"":0,""TestInt16Collection"":[],""TestInt32"":0,""TestInt32Collection"":[],""TestInt64"":0,""TestInt64Collection"":[],""TestMaxLengthString"":null,""TestMaxLengthStringCollection"":[],""TestNullableEnum"":null,""TestNullableEnumCollection"":[],""TestNullableEnumWithConverterThatHandlesNulls"":null,""TestNullableEnumWithConverterThatHandlesNullsCollection"":[],""TestNullableEnumWithIntConverter"":null,""TestNullableEnumWithIntConverterCollection"":[],""TestNullableInt32"":null,""TestNullableInt32Collection"":[],""TestSignedByte"":0,""TestSignedByteCollection"":[],""TestSingle"":0,""TestSingleCollection"":[],""TestTimeOnly"":""00:00:00.0000000"",""TestTimeOnlyCollection"":[],""TestTimeSpan"":""0:00:00"",""TestTimeSpanCollection"":[],""TestUnsignedInt16"":0,""TestUnsignedInt16Collection"":[],""TestUnsignedInt32"":0,""TestUnsignedInt32Collection"":[],""TestUnsignedInt64"":0,""TestUnsignedInt64Collection"":[]}]' (Nullable = false) (Size = " + + parameterSize + + @") @p1='7624' @p2='[]' (Size = 2) @p3=NULL (DbType = Binary) @@ -2340,15 +2342,17 @@ public override async Task Add_and_update_nested_optional_primitive_collection(b INSERT INTO ""JsonEntitiesAllTypes"" (""Collection"", ""Id"", ""TestBooleanCollection"", ""TestByteCollection"", ""TestCharacterCollection"", ""TestDateTimeCollection"", ""TestDateTimeOffsetCollection"", ""TestDecimalCollection"", ""TestDefaultStringCollection"", ""TestDoubleCollection"", ""TestEnumCollection"", ""TestEnumWithIntConverterCollection"", ""TestGuidCollection"", ""TestInt16Collection"", ""TestInt32Collection"", ""TestInt64Collection"", ""TestMaxLengthStringCollection"", ""TestNullableEnumCollection"", ""TestNullableEnumWithConverterThatHandlesNullsCollection"", ""TestNullableEnumWithIntConverterCollection"", ""TestNullableInt32Collection"", ""TestSignedByteCollection"", ""TestSingleCollection"", ""TestTimeSpanCollection"", ""TestUnsignedInt16Collection"", ""TestUnsignedInt32Collection"", ""TestUnsignedInt64Collection"") VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11, @p12, @p13, @p14, @p15, @p16, @p17, @p18, @p19, @p20, @p21, @p22, @p23, @p24, @p25, @p26);", - // - """ + // + """ SELECT "j"."Id", "j"."TestBooleanCollection", "j"."TestByteCollection", "j"."TestCharacterCollection", "j"."TestDateTimeCollection", "j"."TestDateTimeOffsetCollection", "j"."TestDecimalCollection", "j"."TestDefaultStringCollection", "j"."TestDoubleCollection", "j"."TestEnumCollection", "j"."TestEnumWithIntConverterCollection", "j"."TestGuidCollection", "j"."TestInt16Collection", "j"."TestInt32Collection", "j"."TestInt64Collection", "j"."TestMaxLengthStringCollection", "j"."TestNullableEnumCollection", "j"."TestNullableEnumWithConverterThatHandlesNullsCollection", "j"."TestNullableEnumWithIntConverterCollection", "j"."TestNullableInt32Collection", "j"."TestSignedByteCollection", "j"."TestSingleCollection", "j"."TestTimeSpanCollection", "j"."TestUnsignedInt16Collection", "j"."TestUnsignedInt32Collection", "j"."TestUnsignedInt64Collection", "j"."Collection", "j"."Reference" FROM "JsonEntitiesAllTypes" AS "j" WHERE "j"."Id" = 7624 LIMIT 2 """, // - "@p0=" + updateParameter + @" + "@p0=" + + updateParameter + + @" @p1='7624' UPDATE ""JsonEntitiesAllTypes"" SET ""Collection"" = json_set(""Collection"", '$[0].TestCharacterCollection', json(@p0)) @@ -2389,7 +2393,8 @@ public override Task Edit_single_property_collection_of_collection_of_nullable_e // Nested collections are not mapped in the relational model, so there is no data stored in the document for them public override Task Edit_single_property_collection_of_collection_of_nullable_enum_with_int_converter() - => Assert.ThrowsAsync(base.Edit_single_property_collection_of_collection_of_nullable_enum_with_int_converter); + => Assert.ThrowsAsync( + base.Edit_single_property_collection_of_collection_of_nullable_enum_with_int_converter); // Nested collections are not mapped in the relational model, so there is no data stored in the document for them public override Task Edit_single_property_collection_of_collection_of_nullable_int32() diff --git a/test/EFCore.Sqlite.FunctionalTests/WithConstructorsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/WithConstructorsSqliteTest.cs index 3be239ea841..729174e71e3 100644 --- a/test/EFCore.Sqlite.FunctionalTests/WithConstructorsSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/WithConstructorsSqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore; #nullable disable -public class WithConstructorsSqliteTest(WithConstructorsSqliteTest.WithConstructorsSqliteFixture fixture) : WithConstructorsTestBase(fixture) +public class WithConstructorsSqliteTest(WithConstructorsSqliteTest.WithConstructorsSqliteFixture fixture) + : WithConstructorsTestBase(fixture) { protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.Sqlite.Tests/SqliteNTSApiConsistencyTest.cs b/test/EFCore.Sqlite.Tests/SqliteNTSApiConsistencyTest.cs index 807866f348c..2cf497d9c1b 100644 --- a/test/EFCore.Sqlite.Tests/SqliteNTSApiConsistencyTest.cs +++ b/test/EFCore.Sqlite.Tests/SqliteNTSApiConsistencyTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore; -public class SqliteNTSApiConsistencyTest(SqliteNTSApiConsistencyTest.SqliteNTSApiConsistencyFixture fixture) : ApiConsistencyTestBase(fixture) +public class SqliteNTSApiConsistencyTest(SqliteNTSApiConsistencyTest.SqliteNTSApiConsistencyFixture fixture) + : ApiConsistencyTestBase(fixture) { protected override void AddServices(ServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkSqliteNetTopologySuite(); diff --git a/test/EFCore.Sqlite.Tests/Storage/SqliteTypeMappingTest.cs b/test/EFCore.Sqlite.Tests/Storage/SqliteTypeMappingTest.cs index 9a3c39e603f..f51b7d0733e 100644 --- a/test/EFCore.Sqlite.Tests/Storage/SqliteTypeMappingTest.cs +++ b/test/EFCore.Sqlite.Tests/Storage/SqliteTypeMappingTest.cs @@ -18,6 +18,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlite(_connection); // ReSharper disable once UnusedAutoPropertyAccessor.Local + // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Local public DbSet NoTinnies { get; set; } = null!; } diff --git a/test/EFCore.Tests/ApiConsistencyTest.cs b/test/EFCore.Tests/ApiConsistencyTest.cs index 64752929022..c01f993d370 100644 --- a/test/EFCore.Tests/ApiConsistencyTest.cs +++ b/test/EFCore.Tests/ApiConsistencyTest.cs @@ -9,7 +9,8 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore; -public class ApiConsistencyTest(ApiConsistencyTest.ApiConsistencyFixture fixture) : ApiConsistencyTestBase(fixture) +public class ApiConsistencyTest(ApiConsistencyTest.ApiConsistencyFixture fixture) + : ApiConsistencyTestBase(fixture) { protected override Assembly TargetAssembly => typeof(EntityType).Assembly; diff --git a/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs b/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs index d5ae09f75f8..72b524727d2 100644 --- a/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs +++ b/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs @@ -4,7 +4,6 @@ #nullable enable using Microsoft.EntityFrameworkCore.Diagnostics.Internal; -using Microsoft.EntityFrameworkCore.InMemory.ValueGeneration.Internal; // ReSharper disable ClassNeverInstantiated.Local // ReSharper disable ParameterOnlyUsedForPreconditionCheck.Local @@ -507,7 +506,12 @@ public void Detect_property_change_is_logged(bool sensitive, bool callDetectChan [InlineData(true, true)] public void Detect_nested_property_change_is_logged(bool sensitive, bool callDetectChangesTwice) { - var wocket = new Wocket { Id = 1, Name = "Gollum", Pocket = new() { Contents = "Handsies" } }; + var wocket = new Wocket + { + Id = 1, + Name = "Gollum", + Pocket = new Pocket { Contents = "Handsies" } + }; using var context = sensitive ? new LikeAZooContextSensitive() : new LikeAZooContext(); context.Database.EnsureDeleted(); @@ -2206,7 +2210,6 @@ private class Cat(int id) private class Hat(int id) { - // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Local public int Id { get; private set; } = id; @@ -2218,7 +2221,6 @@ private class Hat(int id) private class Mat(int id) { - // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Local public int Id { get; private set; } = id; diff --git a/test/EFCore.Tests/ChangeTracking/ComplexPropertyEntryTest.cs b/test/EFCore.Tests/ChangeTracking/ComplexPropertyEntryTest.cs index 3dc53c49206..ff727c7a983 100644 --- a/test/EFCore.Tests/ChangeTracking/ComplexPropertyEntryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/ComplexPropertyEntryTest.cs @@ -475,11 +475,13 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) private struct Culture { public string Species { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public string? Subspecies { get; set; } public int Rating { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local - public bool? Validation { get; set; } + public bool? Validation { get; set; } public Manufacturer Manufacturer { get; set; } public License License { get; set; } } diff --git a/test/EFCore.Tests/ChangeTracking/Internal/ChangeDetectorTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/ChangeDetectorTest.cs index 4e6cfb5142a..c198ca80ef2 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/ChangeDetectorTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/ChangeDetectorTest.cs @@ -2131,8 +2131,8 @@ public override void AttachGraph( } private class TestRelationshipListener(IEntityGraphAttacher attacher) : NavigationFixer( - attacher, new EntityMaterializerSource( - new EntityMaterializerSourceDependencies(Enumerable.Empty()))) + attacher, new EntityMaterializerSource( + new EntityMaterializerSourceDependencies(Enumerable.Empty()))) { public Tuple, IEnumerable, object, object> KeyChange { diff --git a/test/EFCore.Tests/ChangeTracking/Internal/CurrentValueComparerTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/CurrentValueComparerTest.cs index 4126d2d8214..6b4517b3e8d 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/CurrentValueComparerTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/CurrentValueComparerTest.cs @@ -177,17 +177,7 @@ private void CanSort( .ToList(); Assert.Equal( - new byte[][] - { - [], - [], - [7], - [9], - [9], - [1, 1], - [3, 3], - [3, 3, 3] - }, + new byte[][] { [], [], [7], [9], [9], [1, 1], [3, 3], [3, 3, 3] }, entries); } @@ -350,17 +340,7 @@ private void CanSortNullable( .ToList(); Assert.Equal( - new[] - { - null, - null, - [7], - [9], - [9], - [1, 1], - [3, 3], - new byte[] { 3, 3, 3 } - }, + new[] { null, null, [7], [9], [9], [1, 1], [3, 3], new byte[] { 3, 3, 3 } }, entries); } diff --git a/test/EFCore.Tests/ChangeTracking/Internal/FixupCompositeTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/FixupCompositeTest.cs index 6368d5aca7a..e3721a3620d 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/FixupCompositeTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/FixupCompositeTest.cs @@ -3603,10 +3603,8 @@ public class ChildShared private class FixupContext : DbContext { public FixupContext() - { // ReSharper disable once VirtualMemberCallInConstructor - ChangeTracker.AutoDetectChangesEnabled = false; - } + => ChangeTracker.AutoDetectChangesEnabled = false; protected internal override void OnModelCreating(ModelBuilder modelBuilder) { diff --git a/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs index 873088cb00e..6cc981b6dc8 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs @@ -3481,9 +3481,7 @@ public Category() } public Category(int id) - { - _id = id; - } + => _id = id; public string Value1 { get; set; } public string Value2 { get; set; } diff --git a/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs index 26343a61b37..c44d8fb14dd 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs @@ -36,7 +36,7 @@ public void Detaching_owner_does_not_delete_owned_entities(bool delayCascade) var thing = new Thing { ThingId = Guid.NewGuid(), - OwnedByThings = [new() { OwnedByThingId = Guid.NewGuid() }, new() { OwnedByThingId = Guid.NewGuid() }] + OwnedByThings = [new OwnedByThing { OwnedByThingId = Guid.NewGuid() }, new OwnedByThing { OwnedByThingId = Guid.NewGuid() }] }; context.Attach(thing); diff --git a/test/EFCore.Tests/ChangeTracking/Internal/QueryFixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/QueryFixupTest.cs index 2a973154f3d..03c2e795e96 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/QueryFixupTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/QueryFixupTest.cs @@ -1157,9 +1157,7 @@ public class SmidgetDN private class QueryFixupContext : DbContext { public QueryFixupContext() - { - ChangeTracker.AutoDetectChangesEnabled = false; - } + => ChangeTracker.AutoDetectChangesEnabled = false; protected internal override void OnModelCreating(ModelBuilder modelBuilder) { diff --git a/test/EFCore.Tests/ChangeTracking/Internal/ShadowFixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/ShadowFixupTest.cs index 5b4fc7aa43d..8003244e3af 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/ShadowFixupTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/ShadowFixupTest.cs @@ -243,9 +243,7 @@ public Category() } public Category(int id) - { - Id = id; - } + => Id = id; public int Id { get; set; } } @@ -257,9 +255,7 @@ public Product() } public Product(int id) - { - Id = id; - } + => Id = id; public int Id { get; set; } } @@ -267,9 +263,7 @@ public Product(int id) private sealed class FixupContext : DbContext { public FixupContext() - { - ChangeTracker.AutoDetectChangesEnabled = false; - } + => ChangeTracker.AutoDetectChangesEnabled = false; protected internal override void OnModelCreating(ModelBuilder modelBuilder) { diff --git a/test/EFCore.Tests/ChangeTracking/Internal/ShadowFkFixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/ShadowFkFixupTest.cs index 64565b33be0..51decdf383f 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/ShadowFkFixupTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/ShadowFkFixupTest.cs @@ -1583,10 +1583,8 @@ private class SpecialOffer private class FixupContext : DbContext { public FixupContext() - { // ReSharper disable once VirtualMemberCallInConstructor - ChangeTracker.AutoDetectChangesEnabled = false; - } + => ChangeTracker.AutoDetectChangesEnabled = false; protected internal override void OnModelCreating(ModelBuilder modelBuilder) { diff --git a/test/EFCore.Tests/ChangeTracking/NavigationEntryTest.cs b/test/EFCore.Tests/ChangeTracking/NavigationEntryTest.cs index f6523df24d7..072e08cfd9a 100644 --- a/test/EFCore.Tests/ChangeTracking/NavigationEntryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/NavigationEntryTest.cs @@ -168,6 +168,7 @@ private class Chunky private class Cherry { public int Garcia { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public int Id { get; set; } diff --git a/test/EFCore.Tests/ChangeTracking/PropertyEntryTest.cs b/test/EFCore.Tests/ChangeTracking/PropertyEntryTest.cs index 9deb211b505..2cc539bea61 100644 --- a/test/EFCore.Tests/ChangeTracking/PropertyEntryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/PropertyEntryTest.cs @@ -4782,7 +4782,8 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) }); } - private class PrimateContext(ChangeTrackingStrategy fullNotificationStrategy = ChangeTrackingStrategy.ChangingAndChangedNotifications) : DbContext + private class PrimateContext(ChangeTrackingStrategy fullNotificationStrategy = ChangeTrackingStrategy.ChangingAndChangedNotifications) + : DbContext { private readonly ChangeTrackingStrategy _fullNotificationStrategy = fullNotificationStrategy; diff --git a/test/EFCore.Tests/ChangeTracking/TrackGraphTestBase.cs b/test/EFCore.Tests/ChangeTracking/TrackGraphTestBase.cs index 28a51fb869a..64d8c21d0c7 100644 --- a/test/EFCore.Tests/ChangeTracking/TrackGraphTestBase.cs +++ b/test/EFCore.Tests/ChangeTracking/TrackGraphTestBase.cs @@ -35,19 +35,19 @@ public async Task Can_iterate_over_graph_using_public_surface(bool async) Id = 1, Products = [ - new() + new Product { Id = 1, CategoryId = 1, Details = new ProductDetails { Id = 1 } }, - new() + new Product { Id = 2, CategoryId = 1, Details = new ProductDetails { Id = 2 } }, - new() + new Product { Id = 3, CategoryId = 1, @@ -164,9 +164,9 @@ public void Can_attach_nullable_PK_parent_with_child_collection(bool useAttach, { Products = [ - new(), - new(), - new() + new NullbileProduct(), + new NullbileProduct(), + new NullbileProduct() ] }; @@ -413,9 +413,9 @@ public void Can_attach_parent_with_child_collection() Id = 1, Products = [ - new() { Id = 1 }, - new() { Id = 2 }, - new() { Id = 3 } + new Product { Id = 1 }, + new Product { Id = 2 }, + new Product { Id = 3 } ] }; @@ -581,9 +581,9 @@ public void Entities_that_are_already_tracked_will_not_get_attached() Id = 1, Products = [ - new() { Id = 1 }, + new Product { Id = 1 }, existingProduct, - new() { Id = 3 } + new Product { Id = 3 } ] }; @@ -626,19 +626,19 @@ public void Further_graph_traversal_stops_if_an_entity_is_not_attached() Id = 1, Products = [ - new() + new Product { Id = 1, CategoryId = 1, Details = new ProductDetails { Id = 1 } }, - new() + new Product { Id = 2, CategoryId = 1, Details = new ProductDetails { Id = 2 } }, - new() + new Product { Id = 3, CategoryId = 1, @@ -795,9 +795,9 @@ public void Dependents_are_detached_not_deleted_when_principal_is_detached(bool Id = 1, Products = [ - new() { Id = 1 }, - new() { Id = 2 }, - new() { Id = 3 } + new Product { Id = 1 }, + new Product { Id = 2 }, + new Product { Id = 3 } ] }; @@ -845,9 +845,9 @@ public void Dependents_are_detached_not_deleted_when_principal_is_detached(bool { newCategory.Products = [ - new() { Id = 1 }, - new() { Id = 2 }, - new() { Id = 3 } + new Product { Id = 1 }, + new Product { Id = 2 }, + new Product { Id = 3 } ]; } @@ -940,19 +940,19 @@ public void TrackGraph_overload_can_visit_a_graph_without_attaching() Id = 1, Products = [ - new() + new Product { Id = 1, CategoryId = 1, Details = new ProductDetails { Id = 1 } }, - new() + new Product { Id = 2, CategoryId = 1, Details = new ProductDetails { Id = 2 } }, - new() + new Product { Id = 3, CategoryId = 1, @@ -1056,9 +1056,9 @@ private static void KeyValueAttachTest(string databaseName, Action( LambdaExpression equalsExpression, LambdaExpression hashCodeExpression, LambdaExpression snapshotExpression) : ValueComparer( - (Expression>)equalsExpression, - (Expression>)hashCodeExpression, - (Expression>)snapshotExpression); + (Expression>)equalsExpression, + (Expression>)hashCodeExpression, + (Expression>)snapshotExpression); private enum JustAnEnum : ushort { diff --git a/test/EFCore.Tests/CollectionComparerTest.cs b/test/EFCore.Tests/CollectionComparerTest.cs index 00ba675298f..ca3e509fa97 100644 --- a/test/EFCore.Tests/CollectionComparerTest.cs +++ b/test/EFCore.Tests/CollectionComparerTest.cs @@ -21,10 +21,10 @@ public void Can_detect_changes_to_primitive_collections_using_arrays() ArrayNullableInt = [0, null, 2], ArrayString = ["0", "1", "2"], ArrayNullableString = ["0", null, "2"], - ArrayStruct = [new("0"), new("1"), new("2")], - ArrayNullableStruct = [new("0"), null, new("2")], - ArrayClass = [new("0"), new("1"), new("2")], - ArrayNullableClass = [new("0"), null, new("2")], + ArrayStruct = [new MyStruct("0"), new MyStruct("1"), new MyStruct("2")], + ArrayNullableStruct = [new MyStruct("0"), null, new MyStruct("2")], + ArrayClass = [new MyClass("0"), new MyClass("1"), new MyClass("2")], + ArrayNullableClass = [new MyClass("0"), null, new MyClass("2")], EnumerableInt = new[] { 0, 1, 2 }, EnumerableNullableInt = new int?[] { 0, null, 2 }, EnumerableString = new[] { "0", "1", "2" }, diff --git a/test/EFCore.Tests/DbContextFactoryTest.cs b/test/EFCore.Tests/DbContextFactoryTest.cs index b1c709bff90..e620b82d4b8 100644 --- a/test/EFCore.Tests/DbContextFactoryTest.cs +++ b/test/EFCore.Tests/DbContextFactoryTest.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.InMemory.Infrastructure.Internal; using Microsoft.EntityFrameworkCore.Internal; -using static System.Formats.Asn1.AsnWriter; namespace Microsoft.EntityFrameworkCore; @@ -613,7 +612,7 @@ public void Add_factory_and_then_context_using_scope( if (validateScopes && ((factoryLifetime == ServiceLifetime.Scoped - && contextLifetime == ServiceLifetime.Singleton) + && contextLifetime == ServiceLifetime.Singleton) || (factoryLifetime == ServiceLifetime.Singleton && contextLifetime != ServiceLifetime.Singleton && optionsLifetime == ServiceLifetime.Scoped))) @@ -764,9 +763,9 @@ var effectiveOptionsLifetime if (validateScopes && ((factoryLifetime == ServiceLifetime.Singleton - && effectiveOptionsLifetime == ServiceLifetime.Scoped) - || (factoryLifetime == ServiceLifetime.Scoped - && effectiveOptionsLifetime == ServiceLifetime.Singleton))) + && effectiveOptionsLifetime == ServiceLifetime.Scoped) + || (factoryLifetime == ServiceLifetime.Scoped + && effectiveOptionsLifetime == ServiceLifetime.Singleton))) { Assert.Throws(scope.ServiceProvider.GetRequiredService>); } diff --git a/test/EFCore.Tests/DbContextTest.Services.cs b/test/EFCore.Tests/DbContextTest.Services.cs index ccbf61d15f0..96ea3531e75 100644 --- a/test/EFCore.Tests/DbContextTest.Services.cs +++ b/test/EFCore.Tests/DbContextTest.Services.cs @@ -418,7 +418,8 @@ public ApplicationService ApplicationService => _singletonOptions.RootApplicationServiceProvider!.GetService(); } - private class TestScopedService(ICurrentDbContext currentContext, IEntityEntryGraphIterator graphIterator) : EntityGraphAttacher(graphIterator) + private class TestScopedService(ICurrentDbContext currentContext, IEntityEntryGraphIterator graphIterator) + : EntityGraphAttacher(graphIterator) { private readonly ICurrentDbContext _currentContext = currentContext; @@ -426,7 +427,8 @@ public ApplicationService ApplicationService => _currentContext.Context.GetService(); } - private class TestTransientService(ICurrentDbContext currentContext, IDiagnosticsLogger logger) : LazyLoader(currentContext, logger) + private class TestTransientService(ICurrentDbContext currentContext, IDiagnosticsLogger logger) + : LazyLoader(currentContext, logger) { public ApplicationService ApplicationService => Context!.GetService(); @@ -919,15 +921,11 @@ public EarlyLearningCenter() } public EarlyLearningCenter(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider; - } + => _serviceProvider = serviceProvider; public EarlyLearningCenter(IServiceProvider serviceProvider, DbContextOptions options) : base(options) - { - _serviceProvider = serviceProvider; - } + => _serviceProvider = serviceProvider; public DbSet Products { get; set; } public DbSet Categories { get; set; } @@ -951,7 +949,8 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) } } - private class FakeEntityMaterializerSource(EntityMaterializerSourceDependencies dependencies) : EntityMaterializerSource(dependencies); + private class FakeEntityMaterializerSource(EntityMaterializerSourceDependencies dependencies) + : EntityMaterializerSource(dependencies); private class FakeModelSource : IModelSource { @@ -3042,7 +3041,8 @@ private class CustomInMemoryValueGeneratorSelector( ValueGeneratorSelectorDependencies dependencies, IInMemoryDatabase inMemoryDatabase) : InMemoryValueGeneratorSelector(dependencies, inMemoryDatabase); - private class CustomInMemoryTableFactory(ILoggingOptions loggingOptions, IInMemorySingletonOptions options) : InMemoryTableFactory(loggingOptions, options); + private class CustomInMemoryTableFactory(ILoggingOptions loggingOptions, IInMemorySingletonOptions options) + : InMemoryTableFactory(loggingOptions, options); [ConditionalFact] public void Can_replace_services_in_passed_options() diff --git a/test/EFCore.Tests/DbContextTest.cs b/test/EFCore.Tests/DbContextTest.cs index 556bbb2de26..b5c329c55e5 100644 --- a/test/EFCore.Tests/DbContextTest.cs +++ b/test/EFCore.Tests/DbContextTest.cs @@ -1335,7 +1335,8 @@ public void It_throws_with_derived_name() public class FakeServiceProvider : IServiceProvider, IDisposable { - private readonly IServiceProvider _realProvider = new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider(validateScopes: true); + private readonly IServiceProvider _realProvider = + new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider(validateScopes: true); public bool Disposed { get; set; } diff --git a/test/EFCore.Tests/DbSetInitializerTest.cs b/test/EFCore.Tests/DbSetInitializerTest.cs index f9d9559f434..c6d21df059d 100644 --- a/test/EFCore.Tests/DbSetInitializerTest.cs +++ b/test/EFCore.Tests/DbSetInitializerTest.cs @@ -46,11 +46,12 @@ public IReadOnlyList FindSets(Type contextType) private class JustAContext(DbContextOptions options) : DbContext(options) { - // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet One { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local private DbSet Two { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Three { get; private set; } diff --git a/test/EFCore.Tests/Diagnostics/CoreEventIdTest.cs b/test/EFCore.Tests/Diagnostics/CoreEventIdTest.cs index 43e03daa045..0320e663772 100644 --- a/test/EFCore.Tests/Diagnostics/CoreEventIdTest.cs +++ b/test/EFCore.Tests/Diagnostics/CoreEventIdTest.cs @@ -92,7 +92,8 @@ public object GetService(Type serviceType) => null; } - private class FakeNavigationBase(string name, ConfigurationSource configurationSource, EntityType entityType) : PropertyBase(name, null, null, configurationSource), INavigationBase + private class FakeNavigationBase(string name, ConfigurationSource configurationSource, EntityType entityType) + : PropertyBase(name, null, null, configurationSource), INavigationBase { public IEntityType DeclaringEntityType => (IEntityType)DeclaringType; diff --git a/test/EFCore.Tests/Extensions/ServiceProviderExtensionsTest.cs b/test/EFCore.Tests/Extensions/ServiceProviderExtensionsTest.cs index 2f5a596f94a..75ec353280a 100644 --- a/test/EFCore.Tests/Extensions/ServiceProviderExtensionsTest.cs +++ b/test/EFCore.Tests/Extensions/ServiceProviderExtensionsTest.cs @@ -106,8 +106,6 @@ private interface IPilkington; private class Karl : IPilkington { public Karl() - { - throw new NotSupportedException(KarlQuote); - } + => throw new NotSupportedException(KarlQuote); } } diff --git a/test/EFCore.Tests/Extensions/TypeExtensionsTest.cs b/test/EFCore.Tests/Extensions/TypeExtensionsTest.cs index d0845414f82..1933f9c6baa 100644 --- a/test/EFCore.Tests/Extensions/TypeExtensionsTest.cs +++ b/test/EFCore.Tests/Extensions/TypeExtensionsTest.cs @@ -5,6 +5,7 @@ using System.Collections; using System.Collections.ObjectModel; + namespace Microsoft.EntityFrameworkCore; public class TypeExtensionsTest @@ -576,19 +577,13 @@ public static TheoryData CreateOpenGenericsTestData() { typeof(Dictionary<,>), false, "Dictionary<,>" }, { typeof(List<>), true, "System.Collections.Generic.List<>" }, { typeof(Dictionary<,>), true, "System.Collections.Generic.Dictionary<,>" }, - { - typeof(Level1<>.Level2<>.Level3<>), true, - "Microsoft.EntityFrameworkCore.TypeExtensionsTest+Level1<>+Level2<>+Level3<>" - }, + { typeof(Level1<>.Level2<>.Level3<>), true, "Microsoft.EntityFrameworkCore.TypeExtensionsTest+Level1<>+Level2<>+Level3<>" }, { typeof(PartiallyClosedGeneric<>).BaseType, true, "Microsoft.EntityFrameworkCore.TypeExtensionsTest+C<, int>" }, { typeof(OuterGeneric<>.InnerNonGeneric.InnerGeneric<,>.InnerGenericLeafNode<>), true, "Microsoft.EntityFrameworkCore.TypeExtensionsTest+OuterGeneric<>+InnerNonGeneric+InnerGeneric<,>+InnerGenericLeafNode<>" }, - { - closedDictionaryType, true, - "System.Collections.Generic.Dictionary,>" - }, + { closedDictionaryType, true, "System.Collections.Generic.Dictionary,>" }, { closedLevelType, true, "Microsoft.EntityFrameworkCore.TypeExtensionsTest+Level1<>+Level2+Level3<>" }, { closedInnerType, true, diff --git a/test/EFCore.Tests/Infrastructure/EntityFrameworkMetricsTest.cs b/test/EFCore.Tests/Infrastructure/EntityFrameworkMetricsTest.cs index 9efee770e7d..310beb19f7c 100644 --- a/test/EFCore.Tests/Infrastructure/EntityFrameworkMetricsTest.cs +++ b/test/EFCore.Tests/Infrastructure/EntityFrameworkMetricsTest.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using Microsoft.EntityFrameworkCore.Infrastructure.Internal; using OpenTelemetry; using OpenTelemetry.Metrics; diff --git a/test/EFCore.Tests/Infrastructure/Internal/ConcurrencyDetectorTest.cs b/test/EFCore.Tests/Infrastructure/Internal/ConcurrencyDetectorTest.cs index d78fdf75a4c..fdf30dcd9c7 100644 --- a/test/EFCore.Tests/Infrastructure/Internal/ConcurrencyDetectorTest.cs +++ b/test/EFCore.Tests/Infrastructure/Internal/ConcurrencyDetectorTest.cs @@ -10,27 +10,20 @@ public void MultipleContextOnSameThread_Should_Success() { var preparingContext = new Context(); - var customer = new Customer - { - FirstName = "John", - LastName = "Doe" - }; + var customer = new Customer { FirstName = "John", LastName = "Doe" }; preparingContext.Customers.Add(customer); preparingContext.SaveChanges(); - var order = new Order - { - CustomerId = customer.CustomerId, - OrderDate = DateTime.Now - }; + var order = new Order { CustomerId = customer.CustomerId, OrderDate = DateTime.Now }; preparingContext.Orders.Add(order); preparingContext.SaveChanges(); - var context = new Context(); + var context = new Context(); - var exception = Record.Exception(() => context.Orders.Select(o => new { Date = o.OrderDate, Name = GetCustomer(o.OrderId, context) }).ToArray()); + var exception = Record.Exception( + () => context.Orders.Select(o => new { Date = o.OrderDate, Name = GetCustomer(o.OrderId, context) }).ToArray()); Assert.Null(exception); } @@ -76,7 +69,9 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) .HasForeignKey(o => o.CustomerId); } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Customers { get; set; } + // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Orders { get; set; } } @@ -98,9 +93,7 @@ public Order() } public Order(ILazyLoader lazyLoader) - { - _lazyLoader = lazyLoader; - } + => _lazyLoader = lazyLoader; public int OrderId { get; set; } public DateTime OrderDate { get; set; } diff --git a/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs b/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs index a791b9d5411..19e54bf361c 100644 --- a/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs +++ b/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs @@ -46,7 +46,8 @@ public virtual void Detects_well_known_concrete_collections_mapped_as_owned_enti { var modelBuilder = CreateConventionModelBuilder(); - modelBuilder.Entity>>().OwnsMany(x => x.JsonbFields, r => r.ToJson());; + modelBuilder.Entity>>().OwnsMany(x => x.JsonbFields, r => r.ToJson()); + ; VerifyError( CoreStrings.WarningAsErrorTemplate( @@ -312,18 +313,43 @@ public virtual void Does_not_throw_for_non_generic_collection() protected class MyCollection : IList { private readonly List _list = []; - public IEnumerator GetEnumerator() => _list.GetEnumerator(); - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - public void Add(int item) => _list.Add(item); - public void Clear() => _list.Clear(); - public bool Contains(int item) => _list.Contains(item); - public void CopyTo(int[] array, int arrayIndex) => _list.CopyTo(array, arrayIndex); - public bool Remove(int item) => _list.Remove(item); - public int Count => _list.Count; - public bool IsReadOnly => ((ICollection)_list).IsReadOnly; - public int IndexOf(int item) => _list.IndexOf(item); - public void Insert(int index, int item) => _list.Insert(index, item); - public void RemoveAt(int index) => _list.RemoveAt(index); + + public IEnumerator GetEnumerator() + => _list.GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); + + public void Add(int item) + => _list.Add(item); + + public void Clear() + => _list.Clear(); + + public bool Contains(int item) + => _list.Contains(item); + + public void CopyTo(int[] array, int arrayIndex) + => _list.CopyTo(array, arrayIndex); + + public bool Remove(int item) + => _list.Remove(item); + + public int Count + => _list.Count; + + public bool IsReadOnly + => ((ICollection)_list).IsReadOnly; + + public int IndexOf(int item) + => _list.IndexOf(item); + + public void Insert(int index, int item) + => _list.Insert(index, item); + + public void RemoveAt(int index) + => _list.RemoveAt(index); + public int this[int index] { get => _list[index]; @@ -709,9 +735,11 @@ public virtual void Detects_conflicting_converter_and_provider_type_with_relatio var dId = modelBuilder.Model.FindEntityType(typeof(D)).FindProperty(nameof(D.Id)); - Assert.Equal(CoreStrings.ConflictingRelationshipConversions("D", "Id", "string", "CastingConverter"), + Assert.Equal( + CoreStrings.ConflictingRelationshipConversions("D", "Id", "string", "CastingConverter"), Assert.Throws(dId.GetValueConverter).Message); - Assert.Equal(CoreStrings.ConflictingRelationshipConversions("D", "Id", "string", "CastingConverter"), + Assert.Equal( + CoreStrings.ConflictingRelationshipConversions("D", "Id", "string", "CastingConverter"), Assert.Throws(dId.GetProviderClrType).Message); } @@ -732,9 +760,11 @@ public virtual void Detects_conflicting_provider_types_with_relationship_cycle() var dId = modelBuilder.Model.FindEntityType(typeof(D)).FindProperty(nameof(D.Id)); - Assert.Equal(CoreStrings.ConflictingRelationshipConversions("D", "Id", "string", "long"), + Assert.Equal( + CoreStrings.ConflictingRelationshipConversions("D", "Id", "string", "long"), Assert.Throws(dId.GetValueConverter).Message); - Assert.Equal(CoreStrings.ConflictingRelationshipConversions("D", "Id", "string", "long"), + Assert.Equal( + CoreStrings.ConflictingRelationshipConversions("D", "Id", "string", "long"), Assert.Throws(dId.GetProviderClrType).Message); } diff --git a/test/EFCore.Tests/Infrastructure/ModelValidatorTestBase.cs b/test/EFCore.Tests/Infrastructure/ModelValidatorTestBase.cs index 522d2ff6986..dd0db43f636 100644 --- a/test/EFCore.Tests/Infrastructure/ModelValidatorTestBase.cs +++ b/test/EFCore.Tests/Infrastructure/ModelValidatorTestBase.cs @@ -436,9 +436,7 @@ protected class Picture } protected ModelValidatorTestBase() - { - LoggerFactory = new ListLoggerFactory(l => l == DbLoggerCategory.Model.Validation.Name || l == DbLoggerCategory.Model.Name); - } + => LoggerFactory = new ListLoggerFactory(l => l == DbLoggerCategory.Model.Validation.Name || l == DbLoggerCategory.Model.Name); protected ListLoggerFactory LoggerFactory { get; } diff --git a/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs b/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs index 352ed8d8e34..c6236e957ae 100644 --- a/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs @@ -63,7 +63,8 @@ public void OnModelInitialized_calls_conventions_in_order(bool useBuilder) Assert.Equal(1, convention2.Calls); Assert.Equal(0, convention3.Calls); - AssertSetOperations(new ModelInitializedConvention(terminate: true), + AssertSetOperations( + new ModelInitializedConvention(terminate: true), conventions, conventions.ModelInitializedConventions); } @@ -114,7 +115,8 @@ public void OnModelFinalized_calls_conventions_in_order(bool useBuilder) Assert.Equal(1, convention2.Calls); Assert.Equal(0, convention3.Calls); - AssertSetOperations(new ModelFinalizingConvention(terminate: true), + AssertSetOperations( + new ModelFinalizingConvention(terminate: true), conventions, conventions.ModelFinalizingConventions); } @@ -205,7 +207,8 @@ public void OnModelAnnotationChanged_calls_conventions_in_order(bool useBuilder, builder.Metadata[CoreAnnotationNames.ProductVersion] = "bar"; Assert.Equal(new[] { "bar", null }, convention1.Calls); - AssertSetOperations(new ModelAnnotationChangedConvention(terminate: true), + AssertSetOperations( + new ModelAnnotationChangedConvention(terminate: true), conventions, conventions.ModelAnnotationChangedConventions); } @@ -298,7 +301,8 @@ public void ModelEmbeddedDiscriminatorName_calls_conventions_in_order(bool useBu Assert.Equal(new[] { ("Cheese", null), ("Onion", "Cheese") }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new ModelEmbeddedDiscriminatorNameConvention(terminate: true), + AssertSetOperations( + new ModelEmbeddedDiscriminatorNameConvention(terminate: true), conventions, conventions.ModelEmbeddedDiscriminatorNameConventions); } @@ -307,7 +311,10 @@ private class ModelEmbeddedDiscriminatorNameConvention(bool terminate) : IModelE public readonly List<(string, string)> Calls = []; public void ProcessEmbeddedDiscriminatorName( - IConventionModelBuilder modelBuilder, string newName, string oldName, IConventionContext context) + IConventionModelBuilder modelBuilder, + string newName, + string oldName, + IConventionContext context) { Assert.NotNull(modelBuilder.Metadata.Builder); @@ -367,7 +374,8 @@ public void OnEntityTypeAdded_calls_conventions_in_order(bool useBuilder, bool u Assert.Empty(builder.Metadata.GetEntityTypes()); Assert.Null(builder.Metadata.FindEntityType(typeof(Order))); - AssertSetOperations(new EntityTypeAddedConvention(terminate: true), + AssertSetOperations( + new EntityTypeAddedConvention(terminate: true), conventions, conventions.EntityTypeAddedConventions); } @@ -448,9 +456,11 @@ public void OnEntityTypeIgnored_calls_conventions_in_order(bool useBuilder, bool Assert.Equal(1, convention5.Calls); Assert.Equal(0, convention6.Calls); - AssertSetOperations(new TypeIgnoredConvention(terminate: true), + AssertSetOperations( + new TypeIgnoredConvention(terminate: true), conventions, conventions.TypeIgnoredConventions); - AssertSetOperations(new EntityTypeRemovedConvention(terminate: true), + AssertSetOperations( + new EntityTypeRemovedConvention(terminate: true), conventions, conventions.EntityTypeRemovedConventions); } @@ -550,7 +560,8 @@ public void OnEntityTypeMemberIgnored_calls_conventions_in_order(bool useBuilder Assert.Equal(new[] { "A" }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new EntityTypeMemberIgnoredConvention(terminate: true), + AssertSetOperations( + new EntityTypeMemberIgnoredConvention(terminate: true), conventions, conventions.EntityTypeMemberIgnoredConventions); } @@ -645,7 +656,8 @@ public void OnBaseTypeChanged_calls_conventions_in_order(bool useBuilder, bool u Assert.Equal(new[] { typeof(Order), null }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new EntityTypeBaseTypeChangedConvention(terminate: true), + AssertSetOperations( + new EntityTypeBaseTypeChangedConvention(terminate: true), conventions, conventions.EntityTypeBaseTypeChangedConventions); } @@ -709,8 +721,8 @@ public void OnDiscriminatorPropertySet_calls_conventions_in_order(bool useBuilde scope.Dispose(); } - Assert.Equal(new string[] { nameof(Order.OrderId) }, convention1.Calls); - Assert.Equal(new string[] { nameof(Order.OrderId) }, convention2.Calls); + Assert.Equal(new[] { nameof(Order.OrderId) }, convention1.Calls); + Assert.Equal(new[] { nameof(Order.OrderId) }, convention2.Calls); Assert.Empty(convention3.Calls); if (useBuilder) @@ -722,8 +734,8 @@ public void OnDiscriminatorPropertySet_calls_conventions_in_order(bool useBuilde entityBuilder.Metadata.SetDiscriminatorProperty(propertyBuilder.Metadata, ConfigurationSource.Convention); } - Assert.Equal(new string[] { nameof(Order.OrderId) }, convention1.Calls); - Assert.Equal(new string[] { nameof(Order.OrderId) }, convention2.Calls); + Assert.Equal(new[] { nameof(Order.OrderId) }, convention1.Calls); + Assert.Equal(new[] { nameof(Order.OrderId) }, convention2.Calls); Assert.Empty(convention3.Calls); if (useBuilder) @@ -739,7 +751,8 @@ public void OnDiscriminatorPropertySet_calls_conventions_in_order(bool useBuilde Assert.Equal(new[] { nameof(Order.OrderId), null }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new DiscriminatorPropertySetConvention(terminate: true), + AssertSetOperations( + new DiscriminatorPropertySetConvention(terminate: true), conventions, conventions.DiscriminatorPropertySetConventions); } @@ -841,7 +854,8 @@ public void OnPrimaryKeyChanged_calls_conventions_in_order(bool useBuilder, bool Assert.Empty(convention3.Calls); Assert.Null(entityBuilder.Metadata.GetPrimaryKeyConfigurationSource()); - AssertSetOperations(new EntityTypePrimaryKeyChangedConvention(terminate: true), + AssertSetOperations( + new EntityTypePrimaryKeyChangedConvention(terminate: true), conventions, conventions.EntityTypePrimaryKeyChangedConventions); } @@ -937,7 +951,8 @@ public void OnEntityTypeAnnotationChanged_calls_conventions_in_order(bool useBui entityBuilder.Metadata[CoreAnnotationNames.PropertyAccessMode] = PropertyAccessMode.Field; Assert.Equal(new[] { "bar", null }, convention1.Calls); - AssertSetOperations(new EntityTypeAnnotationChangedConvention(terminate: true), + AssertSetOperations( + new EntityTypeAnnotationChangedConvention(terminate: true), conventions, conventions.EntityTypeAnnotationChangedConventions); } @@ -1013,7 +1028,8 @@ public void OnForeignKeyAdded_calls_conventions_in_order(bool useBuilder, bool u Assert.Equal(new[] { "OrderId1" }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new ForeignKeyAddedConvention(terminate: true), + AssertSetOperations( + new ForeignKeyAddedConvention(terminate: true), conventions, conventions.ForeignKeyAddedConventions); } @@ -1087,7 +1103,8 @@ public void OnForeignKeyRemoved_calls_conventions_in_order(bool useScope) Assert.Equal(new[] { "FK" }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new ForeignKeyRemovedConvention(terminate: true), + AssertSetOperations( + new ForeignKeyRemovedConvention(terminate: true), conventions, conventions.ForeignKeyRemovedConventions); } @@ -1213,7 +1230,8 @@ public void OnForeignKeyPrincipalEndChanged_calls_conventions_in_order(bool useS Assert.Equal(new[] { nameof(Order), nameof(Order), nameof(OrderDetails), nameof(OrderDetails) }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new ForeignKeyPrincipalEndChangedConvention(terminate: true), + AssertSetOperations( + new ForeignKeyPrincipalEndChangedConvention(terminate: true), conventions, conventions.ForeignKeyPrincipalEndChangedConventions); } @@ -1279,7 +1297,8 @@ public void OnForeignKeyPropertiesChangedConvention_calls_conventions_in_order(b Assert.Equal(new[] { ("FK2", "FK3"), ("FK", "FK3") }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new ForeignKeyPropertiesChangedConvention(terminate: true), + AssertSetOperations( + new ForeignKeyPropertiesChangedConvention(terminate: true), conventions, conventions.ForeignKeyPropertiesChangedConventions); } @@ -1394,7 +1413,8 @@ public void OnForeignKeyUniquenessChanged_calls_conventions_in_order(bool useBui dependentEntityBuilder.Metadata.RemoveForeignKey( foreignKey.Properties, foreignKey.PrincipalKey, foreignKey.PrincipalEntityType)); - AssertSetOperations(new ForeignKeyUniquenessChangedConvention(terminate: true), + AssertSetOperations( + new ForeignKeyUniquenessChangedConvention(terminate: true), conventions, conventions.ForeignKeyUniquenessChangedConventions); } @@ -1493,7 +1513,8 @@ public void OnForeignKeyRequirednessChanged_calls_conventions_in_order(bool useB dependentEntityBuilder.Metadata.RemoveForeignKey( foreignKey.Properties, foreignKey.PrincipalKey, foreignKey.PrincipalEntityType)); - AssertSetOperations(new ForeignKeyRequirednessChangedConvention(terminate: true), + AssertSetOperations( + new ForeignKeyRequirednessChangedConvention(terminate: true), conventions, conventions.ForeignKeyRequirednessChangedConventions); } @@ -1594,7 +1615,8 @@ public void OnForeignKeyDependentRequirednessChanged_calls_conventions_in_order( dependentEntityBuilder.Metadata.RemoveForeignKey( foreignKey.Properties, foreignKey.PrincipalKey, foreignKey.PrincipalEntityType)); - AssertSetOperations(new ForeignKeyDependentRequirednessChangedConvention(terminate: true), + AssertSetOperations( + new ForeignKeyDependentRequirednessChangedConvention(terminate: true), conventions, conventions.ForeignKeyDependentRequirednessChangedConventions); } @@ -1695,7 +1717,8 @@ public void OnForeignKeyOwnershipChanged_calls_conventions_in_order(bool useBuil dependentEntityBuilder.Metadata.RemoveForeignKey( foreignKey.Properties, foreignKey.PrincipalKey, foreignKey.PrincipalEntityType)); - AssertSetOperations(new ForeignKeyOwnershipChangedConvention(terminate: true), + AssertSetOperations( + new ForeignKeyOwnershipChangedConvention(terminate: true), conventions, conventions.ForeignKeyOwnershipChangedConventions); } @@ -1793,7 +1816,8 @@ public void OnForeignKeyAnnotationChanged_calls_conventions_in_order(bool useBui Assert.Equal(new[] { "bar", null }, convention1.Calls); - AssertSetOperations(new ForeignKeyAnnotationChangedConvention(terminate: true), + AssertSetOperations( + new ForeignKeyAnnotationChangedConvention(terminate: true), conventions, conventions.ForeignKeyAnnotationChangedConventions); } @@ -1882,7 +1906,8 @@ public void OnForeignKeyNullNavigationSet_calls_conventions_in_order(bool useBui Assert.Equal(new[] { true, false }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new ForeignKeyNullNavigationSetConvention(terminate: true), + AssertSetOperations( + new ForeignKeyNullNavigationSetConvention(terminate: true), conventions, conventions.ForeignKeyNullNavigationSetConventions); } @@ -1962,7 +1987,8 @@ public void OnNavigationAdded_calls_conventions_in_order(bool useBuilder, bool u Assert.Equal(new[] { nameof(OrderDetails.Order), nameof(Order.OrderDetails) }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new NavigationAddedConvention(terminate: true), + AssertSetOperations( + new NavigationAddedConvention(terminate: true), conventions, conventions.NavigationAddedConventions); } @@ -2073,7 +2099,8 @@ public void OnNavigationAnnotationChanged_calls_conventions_in_order(bool useBui Assert.Equal(new[] { "bar", null }, convention1.Calls); - AssertSetOperations(new NavigationAnnotationChangedConvention(terminate: true), + AssertSetOperations( + new NavigationAnnotationChangedConvention(terminate: true), conventions, conventions.NavigationAnnotationChangedConventions); } @@ -2168,7 +2195,8 @@ public void OnNavigationRemoved_calls_conventions_in_order(bool useBuilder, bool Assert.Equal(new[] { nameof(OrderDetails.Order) }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new NavigationRemovedConvention(terminate: true), + AssertSetOperations( + new NavigationRemovedConvention(terminate: true), conventions, conventions.NavigationRemovedConventions); } @@ -2241,7 +2269,8 @@ public void OnSkipNavigationAdded_calls_conventions_in_order(bool useBuilder, bo Assert.Equal(new[] { nameof(Order.Products) }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new SkipNavigationAddedConvention(terminate: true), + AssertSetOperations( + new SkipNavigationAddedConvention(terminate: true), conventions, conventions.SkipNavigationAddedConventions); } @@ -2342,7 +2371,8 @@ public void OnSkipNavigationAnnotationChanged_calls_conventions_in_order(bool us Assert.Equal(new[] { "bar", null }, convention1.Calls); - AssertSetOperations(new SkipNavigationAnnotationChangedConvention(terminate: true), + AssertSetOperations( + new SkipNavigationAnnotationChangedConvention(terminate: true), conventions, conventions.SkipNavigationAnnotationChangedConventions); } @@ -2432,7 +2462,8 @@ public void OnSkipNavigationForeignKeyChanged_calls_conventions_in_order(bool us Assert.Equal(new[] { foreignKey, null }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new SkipNavigationForeignKeyChangedConvention(terminate: true), + AssertSetOperations( + new SkipNavigationForeignKeyChangedConvention(terminate: true), conventions, conventions.SkipNavigationForeignKeyChangedConventions); } @@ -2528,7 +2559,8 @@ public void OnSkipNavigationInverseChanged_calls_conventions_in_order(bool useBu Assert.Empty(convention3.Calls); - AssertSetOperations(new SkipNavigationInverseChangedConvention(terminate: true), + AssertSetOperations( + new SkipNavigationInverseChangedConvention(terminate: true), conventions, conventions.SkipNavigationInverseChangedConventions); } @@ -2599,7 +2631,8 @@ public void OnSkipNavigationRemoved_calls_conventions_in_order(bool useScope) Assert.Equal(new[] { nameof(Order.Products) }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new SkipNavigationRemovedConvention(terminate: true), + AssertSetOperations( + new SkipNavigationRemovedConvention(terminate: true), conventions, conventions.SkipNavigationRemovedConventions); } @@ -2669,7 +2702,8 @@ public void OnTriggerAdded_calls_conventions_in_order(bool useBuilder, bool useS Assert.Equal(new[] { "MyTrigger" }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new TriggerAddedConvention(terminate: true), + AssertSetOperations( + new TriggerAddedConvention(terminate: true), conventions, conventions.TriggerAddedConventions); } @@ -2736,7 +2770,8 @@ public void OnTriggerRemoved_calls_conventions_in_order(bool useScope) Assert.Equal(new[] { "MyTrigger" }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new TriggerRemovedConvention(terminate: true), + AssertSetOperations( + new TriggerRemovedConvention(terminate: true), conventions, conventions.TriggerRemovedConventions); } @@ -2810,7 +2845,8 @@ public void OnKeyAdded_calls_conventions_in_order(bool useBuilder, bool useScope Assert.Equal(new[] { keyPropertyName }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new KeyAddedConvention(terminate: true), + AssertSetOperations( + new KeyAddedConvention(terminate: true), conventions, conventions.KeyAddedConventions); } @@ -2871,7 +2907,8 @@ public void OnKeyRemoved_calls_conventions_in_order(bool useScope) Assert.Equal(new[] { "OrderId" }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new KeyRemovedConvention(terminate: true), + AssertSetOperations( + new KeyRemovedConvention(terminate: true), conventions, conventions.KeyRemovedConventions); } @@ -2969,7 +3006,8 @@ public void OnKeyAnnotationChanged_calls_conventions_in_order(bool useBuilder, b Assert.Equal(new[] { "bar", null }, convention1.Calls); - AssertSetOperations(new KeyAnnotationChangedConvention(terminate: true), + AssertSetOperations( + new KeyAnnotationChangedConvention(terminate: true), conventions, conventions.KeyAnnotationChangedConventions); } @@ -3044,7 +3082,8 @@ public void OnIndexAdded_calls_conventions_in_order(bool useBuilder, bool useSco Assert.Equal(new[] { "OrderId" }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new IndexAddedConvention(terminate: true), + AssertSetOperations( + new IndexAddedConvention(terminate: true), conventions, conventions.IndexAddedConventions); } @@ -3110,7 +3149,8 @@ public void OnIndexRemoved_calls_conventions_in_order(bool useScope) Assert.Equal(new[] { "OrderId" }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new IndexRemovedConvention(terminate: true), + AssertSetOperations( + new IndexRemovedConvention(terminate: true), conventions, conventions.IndexRemovedConventions); } @@ -3206,7 +3246,8 @@ public void OnIndexUniquenessChanged_calls_conventions_in_order(bool useBuilder, Assert.Same(index, entityBuilder.Metadata.RemoveIndex(index.Properties)); - AssertSetOperations(new IndexUniquenessChangedConvention(terminate: true), + AssertSetOperations( + new IndexUniquenessChangedConvention(terminate: true), conventions, conventions.IndexUniquenessChangedConventions); } @@ -3301,7 +3342,8 @@ public void OnIndexSortOrderChanged_calls_conventions_in_order(bool useBuilder, Assert.Same(index, entityBuilder.Metadata.RemoveIndex(index.Properties)); - AssertSetOperations(new IndexSortOrderChangedConvention(terminate: true), + AssertSetOperations( + new IndexSortOrderChangedConvention(terminate: true), conventions, conventions.IndexSortOrderChangedConventions); } @@ -3398,7 +3440,8 @@ public void OnIndexAnnotationChanged_calls_conventions_in_order(bool useBuilder, Assert.Equal(new[] { "bar", null }, convention1.Calls); - AssertSetOperations(new IndexAnnotationChangedConvention(terminate: true), + AssertSetOperations( + new IndexAnnotationChangedConvention(terminate: true), conventions, conventions.IndexAnnotationChangedConventions); } @@ -3500,7 +3543,8 @@ public void OnPropertyAdded_calls_conventions_in_order(bool useBuilder, bool use Assert.Empty(entityBuilder.Metadata.GetProperties()); - AssertSetOperations(new PropertyAddedConvention(terminate: true), + AssertSetOperations( + new PropertyAddedConvention(terminate: true), conventions, conventions.PropertyAddedConventions); } @@ -3637,7 +3681,8 @@ public void OnPropertyNullabilityChanged_calls_conventions_in_order(bool useBuil Assert.Empty(convention3.Calls); - AssertSetOperations(new PropertyNullabilityChangedConvention(terminate: true), + AssertSetOperations( + new PropertyNullabilityChangedConvention(terminate: true), conventions, conventions.PropertyNullabilityChangedConventions); } @@ -3733,7 +3778,8 @@ public void OnPropertyFieldChanged_calls_conventions_in_order(bool useBuilder, b Assert.Equal(new[] { null, nameof(Order.IntField) }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new PropertyFieldChangedConvention(terminate: true), + AssertSetOperations( + new PropertyFieldChangedConvention(terminate: true), conventions, conventions.PropertyFieldChangedConventions); } @@ -3831,7 +3877,8 @@ public void OnPropertyElementTypeChanged_calls_conventions_in_order(bool useBuil Assert.Equal(new (object, object)[] { (null, elementType), (elementType, null) }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new PropertyElementTypeChangedConvention(terminate: true), + AssertSetOperations( + new PropertyElementTypeChangedConvention(terminate: true), conventions, conventions.PropertyElementTypeChangedConventions); } @@ -3929,7 +3976,8 @@ public void OnPropertyAnnotationChanged_calls_conventions_in_order(bool useBuild Assert.Equal(new[] { "bar", null }, convention1.Calls); - AssertSetOperations(new PropertyAnnotationChangedConvention(terminate: true), + AssertSetOperations( + new PropertyAnnotationChangedConvention(terminate: true), conventions, conventions.PropertyAnnotationChangedConventions); } @@ -4000,7 +4048,8 @@ public void OnPropertyRemoved_calls_conventions_in_order(bool useScope) Assert.Equal(new[] { property }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new PropertyRemovedConvention(terminate: true), + AssertSetOperations( + new PropertyRemovedConvention(terminate: true), conventions, conventions.PropertyRemovedConventions); } @@ -4499,7 +4548,8 @@ public void OnComplexPropertyAdded_calls_conventions_in_order(bool useBuilder, b Assert.Empty(entityBuilder.Metadata.GetComplexProperties()); - AssertSetOperations(new ComplexPropertyAddedConvention(terminate: true), + AssertSetOperations( + new ComplexPropertyAddedConvention(terminate: true), conventions, conventions.ComplexPropertyAddedConventions); } @@ -4636,7 +4686,8 @@ public void OnComplexPropertyNullabilityChanged_calls_conventions_in_order(bool Assert.Empty(convention3.Calls); - AssertSetOperations(new ComplexPropertyNullabilityChangedConvention(terminate: true), + AssertSetOperations( + new ComplexPropertyNullabilityChangedConvention(terminate: true), conventions, conventions.ComplexPropertyNullabilityChangedConventions); } @@ -4733,7 +4784,8 @@ public void OnComplexPropertyFieldChanged_calls_conventions_in_order(bool useBui Assert.Equal(new[] { null, nameof(Order.OrderDetailsField) }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new ComplexPropertyFieldChangedConvention(terminate: true), + AssertSetOperations( + new ComplexPropertyFieldChangedConvention(terminate: true), conventions, conventions.ComplexPropertyFieldChangedConventions); } @@ -4831,7 +4883,8 @@ public void OnComplexPropertyAnnotationChanged_calls_conventions_in_order(bool u Assert.Equal(new[] { "bar", null }, convention1.Calls); - AssertSetOperations(new ComplexPropertyAnnotationChangedConvention(terminate: true), + AssertSetOperations( + new ComplexPropertyAnnotationChangedConvention(terminate: true), conventions, conventions.ComplexPropertyAnnotationChangedConventions); } @@ -4902,7 +4955,8 @@ public void OnComplexPropertyRemoved_calls_conventions_in_order(bool useScope) Assert.Equal(new[] { property }, convention2.Calls); Assert.Empty(convention3.Calls); - AssertSetOperations(new ComplexPropertyRemovedConvention(terminate: true), + AssertSetOperations( + new ComplexPropertyRemovedConvention(terminate: true), conventions, conventions.ComplexPropertyRemovedConventions); } @@ -5000,7 +5054,8 @@ public void OnComplexTypeAnnotationChanged_calls_conventions_in_order(bool useBu Assert.Equal(new[] { "bar", null }, convention1.Calls); - AssertSetOperations(new ComplexTypeAnnotationChangedConvention(terminate: true), + AssertSetOperations( + new ComplexTypeAnnotationChangedConvention(terminate: true), conventions, conventions.ComplexTypeAnnotationChangedConventions); } @@ -5101,7 +5156,8 @@ public void OnComplexTypeMemberIgnored_calls_conventions_in_order(bool useBuilde Assert.Empty(entityBuilder.Metadata.GetIgnoredMembers()); - AssertSetOperations(new ComplexTypeMemberIgnoredConvention(terminate: true), + AssertSetOperations( + new ComplexTypeMemberIgnoredConvention(terminate: true), conventions, conventions.ComplexTypeMemberIgnoredConventions); } @@ -5199,7 +5255,8 @@ public void OnElementTypeAnnotationChanged_calls_conventions_in_order(bool useBu Assert.Equal(new[] { "bar", null }, convention1.Calls); - AssertSetOperations(new ElementTypeAnnotationChangedConvention(terminate: true), + AssertSetOperations( + new ElementTypeAnnotationChangedConvention(terminate: true), conventions, conventions.ElementTypeAnnotationChangedConventions); } @@ -5340,7 +5397,8 @@ public void OnElementTypeNullabilityChanged_calls_conventions_in_order(bool useB Assert.Empty(convention3.Calls); - AssertSetOperations(new ElementTypeNullabilityChangedConvention(terminate: true), + AssertSetOperations( + new ElementTypeNullabilityChangedConvention(terminate: true), conventions, conventions.ElementTypeNullabilityChangedConventions); } @@ -5363,7 +5421,9 @@ public void ProcessElementTypeNullabilityChanged( } private static void AssertSetOperations( - TConvention newConvention, ConventionSet conventions, List conventionList) + TConvention newConvention, + ConventionSet conventions, + List conventionList) where TConvention : class, IConvention { Assert.Equal(3, conventionList.Count); @@ -5383,6 +5443,7 @@ private class Order public static readonly PropertyInfo OtherOrderDetailsProperty = typeof(Order).GetProperty(nameof(OtherOrderDetails)); public readonly int IntField = 1; + // ReSharper disable once RedundantDefaultMemberInitializer public readonly OrderDetails OrderDetailsField = default; diff --git a/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs b/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs index a94e97b752d..2765c6de396 100644 --- a/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs @@ -189,10 +189,12 @@ public void Delegate_getter_is_returned_for_index_property() Assert.Equal( "ValueA", - ClrPropertyGetterFactory.Instance.Create((IPropertyBase)propertyA).GetClrValueUsingContainingEntity(new IndexedClass { Id = 7 })); + ClrPropertyGetterFactory.Instance.Create((IPropertyBase)propertyA) + .GetClrValueUsingContainingEntity(new IndexedClass { Id = 7 })); Assert.Equal( 123, - ClrPropertyGetterFactory.Instance.Create((IPropertyBase)propertyB).GetClrValueUsingContainingEntity(new IndexedClass { Id = 7 })); + ClrPropertyGetterFactory.Instance.Create((IPropertyBase)propertyB) + .GetClrValueUsingContainingEntity(new IndexedClass { Id = 7 })); } [ConditionalFact] diff --git a/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs b/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs index 2c41f275e15..4af00967b22 100644 --- a/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs @@ -600,7 +600,6 @@ public void Can_add_a_foreign_key_targeting_different_key() Assert.Equal([fk2, fk1], orderType.GetForeignKeys().ToArray()); } - [ConditionalFact] public void Adding_a_foreign_key_throws_if_duplicate() { @@ -3315,6 +3314,7 @@ private class SelfRef public int? SelfRefId { get; set; } public int ForeignKey { get; set; } } + private static IMutableModel CreateEmptyModel() => new Model(); diff --git a/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs b/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs index 400a19c5d07..35561bbc922 100644 --- a/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs @@ -685,14 +685,19 @@ public void Get_MemberInfos_for_auto_prop_skip_collection_navigations() MemberInfoTest(CreateSkipCollectionNavigation(field), null, field, field, field); MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, SkipCollection, SkipCollection); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.Property, SkipCollection, SkipCollection, SkipCollection); + CreateSkipCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, + SkipCollection, SkipCollection); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.Property, SkipCollection, SkipCollection, + SkipCollection); MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, SkipCollection, + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, + SkipCollection, SkipCollection); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, SkipCollection, SkipCollection, SkipCollection); + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, SkipCollection, + SkipCollection, SkipCollection); } [ConditionalFact] @@ -703,14 +708,19 @@ public void Get_MemberInfos_for_full_prop_skip_collection_navigations() MemberInfoTest(CreateSkipCollectionNavigation(field), null, field, field, field); MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, SkipCollection, SkipCollection); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.Property, SkipCollection, SkipCollection, SkipCollection); + CreateSkipCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, + SkipCollection, SkipCollection); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.Property, SkipCollection, SkipCollection, + SkipCollection); MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, SkipCollection, + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, + SkipCollection, SkipCollection); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, SkipCollection, SkipCollection, SkipCollection); + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, SkipCollection, + SkipCollection, SkipCollection); } [ConditionalFact] @@ -719,15 +729,23 @@ public void Get_MemberInfos_for_read_only_prop_skip_collection_navigations() const string field = "_skipCollection"; MemberInfoTest(CreateSkipCollectionNavigation(field), null, field, field, field); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, SkipCollection); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.Property, null, null, SkipCollection); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); + CreateSkipCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, + field, SkipCollection); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.Property, null, null, + SkipCollection); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, + field, + SkipCollection); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, field, field, SkipCollection); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, field, field, SkipCollection); } [ConditionalFact] @@ -736,16 +754,24 @@ public void Get_MemberInfos_for_read_only_auto_prop_skip_collection_navigations( const string field = "k__BackingField"; MemberInfoTest(CreateSkipCollectionNavigation(field), null, field, field, field); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, SkipCollection); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.Property, null, null, SkipCollection); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); + CreateSkipCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, + field, field, SkipCollection); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.Property, null, null, + SkipCollection); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, + field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, + CreateSkipCollectionNavigation(field), + PropertyAccessMode.PreferFieldDuringConstruction, field, field, SkipCollection); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, field, field, SkipCollection); + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, field, field, + SkipCollection); } [ConditionalFact] @@ -754,16 +780,25 @@ public void Get_MemberInfos_for_read_only_field_prop_skip_collection_navigations const string field = "_skipCollection"; MemberInfoTest(CreateSkipCollectionNavigation(field), null, field, field, field); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, SkipCollection); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.Property, null, null, SkipCollection); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); + CreateSkipCollectionNavigation(field), PropertyAccessMode.Field, field, field, + field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, + CreateSkipCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, SkipCollection); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, field, field, SkipCollection); + CreateSkipCollectionNavigation(field), PropertyAccessMode.Property, null, null, + SkipCollection); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, + field); + MemberInfoTest( + CreateSkipCollectionNavigation(field), + PropertyAccessMode.PreferFieldDuringConstruction, + field, field, SkipCollection); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, field, + field, SkipCollection); } [ConditionalFact] @@ -772,56 +807,76 @@ public void Get_MemberInfos_for_write_only_prop_skip_collection_navigations() const string field = "_skipCollection"; MemberInfoTest(CreateSkipCollectionNavigation(field), null, field, field, field); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, SkipCollection, field); + CreateSkipCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, + SkipCollection, field); MemberInfoTest( CreateSkipCollectionNavigation(field), PropertyAccessMode.Property, SkipCollection, SkipCollection, NoGetterSkipColl()); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, SkipCollection, + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, + field, SkipCollection, field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, SkipCollection, SkipCollection, field); + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, SkipCollection, + SkipCollection, field); } [ConditionalFact] public void Get_MemberInfos_for_full_prop_skip_collection_navigations_with_field_not_found() { - MemberInfoTest(CreateSkipCollectionNavigation(null), null, SkipCollection, SkipCollection, SkipCollection); MemberInfoTest( - CreateSkipCollectionNavigation(null), PropertyAccessMode.Field, null, null, NoFieldSkipColl()); + CreateSkipCollectionNavigation(null), null, SkipCollection, SkipCollection, + SkipCollection); + MemberInfoTest( + CreateSkipCollectionNavigation(null), PropertyAccessMode.Field, null, null, + NoFieldSkipColl()); MemberInfoTest( - CreateSkipCollectionNavigation(null), PropertyAccessMode.FieldDuringConstruction, null, SkipCollection, + CreateSkipCollectionNavigation(null), PropertyAccessMode.FieldDuringConstruction, null, + SkipCollection, SkipCollection); MemberInfoTest( - CreateSkipCollectionNavigation(null), PropertyAccessMode.Property, SkipCollection, SkipCollection, SkipCollection); + CreateSkipCollectionNavigation(null), PropertyAccessMode.Property, SkipCollection, + SkipCollection, SkipCollection); MemberInfoTest( - CreateSkipCollectionNavigation(null), PropertyAccessMode.PreferField, SkipCollection, SkipCollection, SkipCollection); + CreateSkipCollectionNavigation(null), PropertyAccessMode.PreferField, SkipCollection, + SkipCollection, SkipCollection); MemberInfoTest( CreateSkipCollectionNavigation(null), PropertyAccessMode.PreferFieldDuringConstruction, SkipCollection, SkipCollection, SkipCollection); MemberInfoTest( - CreateSkipCollectionNavigation(null), PropertyAccessMode.PreferProperty, SkipCollection, SkipCollection, SkipCollection); + CreateSkipCollectionNavigation(null), PropertyAccessMode.PreferProperty, SkipCollection, + SkipCollection, SkipCollection); } [ConditionalFact] public void Get_MemberInfos_for_read_only_prop_skip_collection_navigations_with_field_not_found() { - MemberInfoTest(CreateSkipCollectionNavigation(null), null, null, null, SkipCollection); + MemberInfoTest( + CreateSkipCollectionNavigation(null), null, null, null, SkipCollection); MemberInfoTest( CreateSkipCollectionNavigation(null), PropertyAccessMode.Field, null, null, NoFieldSkipColl()); MemberInfoTest( - CreateSkipCollectionNavigation(null), PropertyAccessMode.FieldDuringConstruction, null, null, SkipCollection); - MemberInfoTest(CreateSkipCollectionNavigation(null), PropertyAccessMode.Property, null, null, SkipCollection); - MemberInfoTest(CreateSkipCollectionNavigation(null), PropertyAccessMode.PreferField, null, null, SkipCollection); + CreateSkipCollectionNavigation(null), PropertyAccessMode.FieldDuringConstruction, + null, null, SkipCollection); + MemberInfoTest( + CreateSkipCollectionNavigation(null), PropertyAccessMode.Property, null, null, + SkipCollection); + MemberInfoTest( + CreateSkipCollectionNavigation(null), PropertyAccessMode.PreferField, null, null, + SkipCollection); MemberInfoTest( - CreateSkipCollectionNavigation(null), PropertyAccessMode.PreferFieldDuringConstruction, + CreateSkipCollectionNavigation(null), + PropertyAccessMode.PreferFieldDuringConstruction, null, null, SkipCollection); MemberInfoTest( - CreateSkipCollectionNavigation(null), PropertyAccessMode.PreferProperty, null, null, SkipCollection); + CreateSkipCollectionNavigation(null), PropertyAccessMode.PreferProperty, null, + null, SkipCollection); } [ConditionalFact] @@ -834,7 +889,8 @@ public void Get_MemberInfos_for_write_only_prop_skip_collection_navigations_with CreateSkipCollectionNavigation(null), PropertyAccessMode.Field, null, null, NoFieldSkipColl()); MemberInfoTest( - CreateSkipCollectionNavigation(null), PropertyAccessMode.FieldDuringConstruction, + CreateSkipCollectionNavigation(null), + PropertyAccessMode.FieldDuringConstruction, null, SkipCollection, NoFieldOrGetterSkipColl()); MemberInfoTest( CreateSkipCollectionNavigation(null), PropertyAccessMode.Property, @@ -853,15 +909,22 @@ public void Get_MemberInfos_for_full_prop_skip_collection_navigations_private_se const string field = "_skipCollection"; MemberInfoTest(CreateSkipCollectionNavigation(field), null, field, field, field); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, + CreateSkipCollectionNavigation(field), PropertyAccessMode.Field, field, field, + field); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, + field, SkipCollection, SkipCollection); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.Property, SkipCollection, SkipCollection, SkipCollection); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); + CreateSkipCollectionNavigation(field), PropertyAccessMode.Property, SkipCollection, + SkipCollection, SkipCollection); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferField, field, + field, field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, SkipCollection, SkipCollection, + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, + SkipCollection, SkipCollection, SkipCollection); } @@ -871,15 +934,21 @@ public void Get_MemberInfos_for_full_prop_skip_collection_navigations_private_ge const string field = "_skipCollection"; MemberInfoTest(CreateSkipCollectionNavigation(field), null, field, field, field); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.Field, field, field, + field); MemberInfoTest( CreateSkipCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, SkipCollection, SkipCollection); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.Property, SkipCollection, SkipCollection, SkipCollection); - MemberInfoTest(CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); + CreateSkipCollectionNavigation(field), PropertyAccessMode.Property, SkipCollection, + SkipCollection, SkipCollection); + MemberInfoTest( + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferField, field, + field, field); MemberInfoTest( - CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, SkipCollection, SkipCollection, + CreateSkipCollectionNavigation(field), PropertyAccessMode.PreferProperty, + SkipCollection, SkipCollection, SkipCollection); } diff --git a/test/EFCore.Tests/Metadata/Internal/PropertyTest.cs b/test/EFCore.Tests/Metadata/Internal/PropertyTest.cs index 21caaca29cf..f5c94dcb3f1 100644 --- a/test/EFCore.Tests/Metadata/Internal/PropertyTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/PropertyTest.cs @@ -549,9 +549,10 @@ public override string FromJsonTyped(ref Utf8JsonReaderManager manager, object e public override void ToJsonTyped(Utf8JsonWriter writer, string value) => writer.WriteStringValue(value); - private readonly Expression> _instanceLambda = () => new(); + private readonly Expression> _instanceLambda = () => new SimpleJasonValueReaderWriter(); - public override Expression ConstructorExpression => _instanceLambda.Body; + public override Expression ConstructorExpression + => _instanceLambda.Body; } private class JasonValueReaderWriterWithPrivateInstance : JsonValueReaderWriter @@ -566,7 +567,8 @@ public override void ToJsonTyped(Utf8JsonWriter writer, string value) private readonly Expression> _instanceLambda = () => Instance; - public override Expression ConstructorExpression => _instanceLambda.Body; + public override Expression ConstructorExpression + => _instanceLambda.Body; } private class JasonValueReaderWriterWithBadInstance : JsonValueReaderWriter @@ -579,7 +581,8 @@ public override string FromJsonTyped(ref Utf8JsonReaderManager manager, object e public override void ToJsonTyped(Utf8JsonWriter writer, string value) => writer.WriteStringValue(value); - public override Expression ConstructorExpression => Expression.Default(typeof(JasonValueReaderWriterWithBadInstance)); + public override Expression ConstructorExpression + => Expression.Default(typeof(JasonValueReaderWriterWithBadInstance)); } private class SimpleJasonValueReaderWriterWithInstance : JsonValueReaderWriter @@ -594,7 +597,8 @@ public override void ToJsonTyped(Utf8JsonWriter writer, string value) private readonly Expression> _instanceLambda = () => Instance; - public override Expression ConstructorExpression => _instanceLambda.Body; + public override Expression ConstructorExpression + => _instanceLambda.Body; } private class SimpleJasonValueReaderWriterWithInstanceAndPrivateConstructor : JsonValueReaderWriter @@ -613,7 +617,8 @@ public override void ToJsonTyped(Utf8JsonWriter writer, string value) private readonly Expression> _instanceLambda = () => Instance; - public override Expression ConstructorExpression => _instanceLambda.Body; + public override Expression ConstructorExpression + => _instanceLambda.Body; } private class NonDerivedJsonValueReaderWriter; @@ -629,9 +634,10 @@ public override void ToJson(Utf8JsonWriter writer, object value) public override Type ValueType => typeof(string); - private readonly Expression> _instanceLambda = () => new(); + private readonly Expression> _instanceLambda = () => new NonGenericJsonValueReaderWriter(); - public override Expression ConstructorExpression => _instanceLambda.Body; + public override Expression ConstructorExpression + => _instanceLambda.Body; } private abstract class AbstractJasonValueReaderWriter : JsonValueReaderWriter; @@ -648,9 +654,10 @@ public override string FromJsonTyped(ref Utf8JsonReaderManager manager, object e public override void ToJsonTyped(Utf8JsonWriter writer, string value) => writer.WriteStringValue(value); - private readonly Expression> _instanceLambda = () => new(); + private readonly Expression> _instanceLambda = () => new PrivateJasonValueReaderWriter(); - public override Expression ConstructorExpression => _instanceLambda.Body; + public override Expression ConstructorExpression + => _instanceLambda.Body; } private class NonParameterlessJsonValueReaderWriter(bool _) : JsonValueReaderWriter @@ -663,8 +670,8 @@ public override void ToJsonTyped(Utf8JsonWriter writer, string value) private readonly ConstructorInfo _constructorInfo = typeof(NonParameterlessJsonValueReaderWriter).GetConstructor([typeof(bool)])!; - public override Expression ConstructorExpression => - Expression.New(_constructorInfo, Expression.Constant(_)); + public override Expression ConstructorExpression + => Expression.New(_constructorInfo, Expression.Constant(_)); } private static IMutableModel CreateModel() diff --git a/test/EFCore.Tests/Query/EntityMaterializerSourceTest.cs b/test/EFCore.Tests/Query/EntityMaterializerSourceTest.cs index de96391c436..59ff9eb5dcc 100644 --- a/test/EFCore.Tests/Query/EntityMaterializerSourceTest.cs +++ b/test/EFCore.Tests/Query/EntityMaterializerSourceTest.cs @@ -3,7 +3,6 @@ using System.ComponentModel.DataAnnotations.Schema; using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Proxies.Internal; using Microsoft.EntityFrameworkCore.Query.Internal; // ReSharper disable UnusedMember.Local @@ -519,7 +518,6 @@ private Parameterless() private class WithProperties(int id) { - // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Local public int Id { get; set; } = id; } @@ -531,9 +529,7 @@ public ParameterlessAndWithProperties() } public ParameterlessAndWithProperties(int id) - { - Id = id; - } + => Id = id; // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Local public int Id { get; set; } @@ -567,9 +563,7 @@ private class WithServiceAndWithProperties(ILazyLoader lazyLoader) { public WithServiceAndWithProperties(ILazyLoader lazyLoader, int id) : this(lazyLoader) - { - Id = id; - } + => Id = id; public ILazyLoader LazyLoader { get; } = lazyLoader; diff --git a/test/EFCore.Tests/Storage/ExecutionStrategyTest.cs b/test/EFCore.Tests/Storage/ExecutionStrategyTest.cs index ec9aca9e4e9..587cbf02994 100644 --- a/test/EFCore.Tests/Storage/ExecutionStrategyTest.cs +++ b/test/EFCore.Tests/Storage/ExecutionStrategyTest.cs @@ -12,9 +12,7 @@ public class ExecutionStrategyTest : IDisposable private readonly DbContext Context; public ExecutionStrategyTest() - { - Context = CreateContext(); - } + => Context = CreateContext(); public void Dispose() => Context.Dispose(); diff --git a/test/EFCore.Tests/ValueGeneration/ValueGeneratorSelectorTest.cs b/test/EFCore.Tests/ValueGeneration/ValueGeneratorSelectorTest.cs index 6f14e9207af..7612f79ac0c 100644 --- a/test/EFCore.Tests/ValueGeneration/ValueGeneratorSelectorTest.cs +++ b/test/EFCore.Tests/ValueGeneration/ValueGeneratorSelectorTest.cs @@ -70,7 +70,8 @@ public void Returns_built_in_generators_for_types_setup_for_value_generation_usi var selector = new ValueGeneratorSelector( new ValueGeneratorSelectorDependencies(new ValueGeneratorCache(new ValueGeneratorCacheDependencies()))); - Assert.IsType(selector.TrySelect(entityType.FindProperty("Custom")!, entityType, out var generator) ? generator : null); + Assert.IsType( + selector.TrySelect(entityType.FindProperty("Custom")!, entityType, out var generator) ? generator : null); Assert.Null(selector.TrySelect(entityType.FindProperty("Id")!, entityType, out generator) ? generator : null); Assert.Null(selector.TrySelect(entityType.FindProperty("Long")!, entityType, out generator) ? generator : null); @@ -107,12 +108,16 @@ public void Returns_built_in_generators_for_types_setup_for_value_generation_usi Assert.Null(selector.TrySelect(entityType.FindProperty("DateTimeOffset")!, entityType, out generator) ? generator : null); Assert.Null(selector.TrySelect(entityType.FindProperty("NullableDateTimeOffset")!, entityType, out generator) ? generator : null); - Assert.IsType(selector.TrySelect(entityType.FindProperty("String")!, entityType, out generator) ? generator : null); + Assert.IsType( + selector.TrySelect(entityType.FindProperty("String")!, entityType, out generator) ? generator : null); - Assert.IsType(selector.TrySelect(entityType.FindProperty("Guid")!, entityType, out generator) ? generator : null); - Assert.IsType(selector.TrySelect(entityType.FindProperty("NullableGuid")!, entityType, out generator) ? generator : null); + Assert.IsType( + selector.TrySelect(entityType.FindProperty("Guid")!, entityType, out generator) ? generator : null); + Assert.IsType( + selector.TrySelect(entityType.FindProperty("NullableGuid")!, entityType, out generator) ? generator : null); - Assert.IsType(selector.TrySelect(entityType.FindProperty("Binary")!, entityType, out generator) ? generator : null); + Assert.IsType( + selector.TrySelect(entityType.FindProperty("Binary")!, entityType, out generator) ? generator : null); } [ConditionalFact] diff --git a/test/Shared/ModuleInitializer.cs b/test/Shared/ModuleInitializer.cs index 40dddc20a95..161425373e5 100644 --- a/test/Shared/ModuleInitializer.cs +++ b/test/Shared/ModuleInitializer.cs @@ -8,9 +8,7 @@ internal static class ModuleInitializer { [ModuleInitializer] internal static void Initialize() - { - InitializeLocale(); - } + => InitializeLocale(); private static void InitializeLocale() {