diff --git a/benchmark/EF.Benchmarks.Shared/EFCoreBenchmarkRunner.cs b/benchmark/EF.Benchmarks.Shared/EFCoreBenchmarkRunner.cs index 86170ed5372..2056de6d255 100644 --- a/benchmark/EF.Benchmarks.Shared/EFCoreBenchmarkRunner.cs +++ b/benchmark/EF.Benchmarks.Shared/EFCoreBenchmarkRunner.cs @@ -38,14 +38,14 @@ public static void Run(string[] args, Assembly assembly, IConfig config = null) .With(StatisticColumn.OperationsPerSecond, new ParamsSummaryColumn()) .With( MarkdownExporter.GitHub, new CsvExporter( - CsvSeparator.Comma, - new SummaryStyle - { - PrintUnitsInHeader = true, - PrintUnitsInContent = false, - TimeUnit = TimeUnit.Microsecond, - SizeUnit = SizeUnit.KB - })); + CsvSeparator.Comma, + new SummaryStyle + { + PrintUnitsInHeader = true, + PrintUnitsInContent = false, + TimeUnit = TimeUnit.Microsecond, + SizeUnit = SizeUnit.KB + })); } BenchmarkSwitcher.FromAssembly(assembly).Run(args, config); diff --git a/benchmark/EF.Benchmarks.Shared/ParamsSummaryColumn.cs b/benchmark/EF.Benchmarks.Shared/ParamsSummaryColumn.cs index bcf7a399647..302337fd863 100644 --- a/benchmark/EF.Benchmarks.Shared/ParamsSummaryColumn.cs +++ b/benchmark/EF.Benchmarks.Shared/ParamsSummaryColumn.cs @@ -23,6 +23,6 @@ public class ParamsSummaryColumn : IColumn public bool IsNumeric => false; public UnitType UnitType => UnitType.Dimensionless; public string GetValue(Summary summary, BenchmarkCase benchmark, ISummaryStyle style) => GetValue(summary, benchmark); - public string Legend => $"Summary of all parameter values"; + public string Legend => "Summary of all parameter values"; } } diff --git a/benchmark/EF6.SqlServer.Benchmarks/ChangeTracker/DbSetOperationTests.cs b/benchmark/EF6.SqlServer.Benchmarks/ChangeTracker/DbSetOperationTests.cs index 0f373afc151..1d4f8d0520b 100644 --- a/benchmark/EF6.SqlServer.Benchmarks/ChangeTracker/DbSetOperationTests.cs +++ b/benchmark/EF6.SqlServer.Benchmarks/ChangeTracker/DbSetOperationTests.cs @@ -116,13 +116,15 @@ public virtual void Update() // API for bulk update in EF6.x } - [SingleRunJob, Description("AutoDetectChanges=True")] + [SingleRunJob] + [Description("AutoDetectChanges=True")] public class AddDataVariationsWithAutoDetectChangesOn : AddDataVariations { protected override bool AutoDetectChanges => true; } - [SingleRunJob, Description("AutoDetectChanges=True")] + [SingleRunJob] + [Description("AutoDetectChanges=True")] public class ExistingDataVariationsWithAutoDetectChangesOn : ExistingDataVariations { protected override bool AutoDetectChanges => true; diff --git a/benchmark/EF6.SqlServer.Benchmarks/ChangeTracker/FixupTests.cs b/benchmark/EF6.SqlServer.Benchmarks/ChangeTracker/FixupTests.cs index 9016676c85d..27c516c6a96 100644 --- a/benchmark/EF6.SqlServer.Benchmarks/ChangeTracker/FixupTests.cs +++ b/benchmark/EF6.SqlServer.Benchmarks/ChangeTracker/FixupTests.cs @@ -122,13 +122,15 @@ public virtual void QueryChildren() } } - [SingleRunJob, Description("AutoDetectChanges=True")] + [SingleRunJob] + [Description("AutoDetectChanges=True")] public class ChildVariationsWithAutoDetectChangesOn : ChildVariations { protected override bool AutoDetectChanges => true; } - [SingleRunJob, Description("AutoDetectChanges=True")] + [SingleRunJob] + [Description("AutoDetectChanges=True")] public class ParentVariationsWithAutoDetectChangesOn : ParentVariations { protected override bool AutoDetectChanges => true; diff --git a/benchmark/EF6.SqlServer.Benchmarks/ChangeTracker/SingleRunJobAttribute.cs b/benchmark/EF6.SqlServer.Benchmarks/ChangeTracker/SingleRunJobAttribute.cs index 2a73096ccce..0022055adfe 100644 --- a/benchmark/EF6.SqlServer.Benchmarks/ChangeTracker/SingleRunJobAttribute.cs +++ b/benchmark/EF6.SqlServer.Benchmarks/ChangeTracker/SingleRunJobAttribute.cs @@ -13,10 +13,11 @@ public class SingleRunJobAttribute : Attribute, IConfigSource { public SingleRunJobAttribute() { - Config = ManualConfig.CreateEmpty().With(new Job() - .WithWarmupCount(1) - .WithIterationCount(1) - .With(RunStrategy.Monitoring)); + Config = ManualConfig.CreateEmpty().With( + new Job() + .WithWarmupCount(1) + .WithIterationCount(1) + .With(RunStrategy.Monitoring)); } public IConfig Config { get; } diff --git a/benchmark/EF6.SqlServer.Benchmarks/Initialization/InitializationTests.cs b/benchmark/EF6.SqlServer.Benchmarks/Initialization/InitializationTests.cs index dfab8c9c3a7..a67cd3e69bb 100644 --- a/benchmark/EF6.SqlServer.Benchmarks/Initialization/InitializationTests.cs +++ b/benchmark/EF6.SqlServer.Benchmarks/Initialization/InitializationTests.cs @@ -98,11 +98,7 @@ public virtual void InitializeAndSaveChanges_AdventureWorks(int count) using (var context = AdventureWorksFixture.CreateContext()) { context.Currency.Add( - new Currency - { - CurrencyCode = "TMP", - Name = "Temporary" - }); + new Currency { CurrencyCode = "TMP", Name = "Temporary" }); using (context.Database.BeginTransaction()) { diff --git a/benchmark/EF6.SqlServer.Benchmarks/Models/AdventureWorks/AdventureWorksContext.cs b/benchmark/EF6.SqlServer.Benchmarks/Models/AdventureWorks/AdventureWorksContext.cs index 4c379f1c814..ae68bda1e56 100644 --- a/benchmark/EF6.SqlServer.Benchmarks/Models/AdventureWorks/AdventureWorksContext.cs +++ b/benchmark/EF6.SqlServer.Benchmarks/Models/AdventureWorks/AdventureWorksContext.cs @@ -119,7 +119,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().Property(e => e.UnitMeasureCode).IsRequired(); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity().Property(e => e.StartDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); @@ -140,23 +141,21 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("BusinessEntity", "Person"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity().Property(e => e.rowguid).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity().HasKey( - e => new - { - e.BusinessEntityID, - e.AddressID, - e.AddressTypeID - }); + e => new { e.BusinessEntityID, e.AddressID, e.AddressTypeID }); modelBuilder.Entity().ToTable("BusinessEntityAddress", "Person"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); - modelBuilder.Entity().Property(e => e.rowguid).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.rowguid) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.Address) @@ -177,9 +176,11 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("BusinessEntityContact", "Person"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); - modelBuilder.Entity().Property(e => e.rowguid).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.rowguid) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.BusinessEntity) @@ -214,7 +215,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("CountryRegionCurrency", "Sales"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.CountryRegionCodeNavigation) @@ -338,11 +340,13 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) .HasRequired(d => d.BusinessEntity) .WithOptional(p => p.Employee); - modelBuilder.Entity().HasKey(e => new { e.BusinessEntityID, e.StartDate, e.DepartmentID, e.ShiftID }); + modelBuilder.Entity() + .HasKey(e => new { e.BusinessEntityID, e.StartDate, e.DepartmentID, e.ShiftID }); modelBuilder.Entity().ToTable("EmployeeDepartmentHistory", "HumanResources"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.BusinessEntity) @@ -363,7 +367,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("EmployeePayHistory", "HumanResources"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.BusinessEntity) @@ -429,7 +434,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("PersonCreditCard", "Sales"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.BusinessEntity) @@ -461,7 +467,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().Property(e => e.Name).IsRequired(); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity().ToTable("Product", "Production"); @@ -498,7 +505,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().Property(e => e.Name).IsRequired(); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity().Property(e => e.rowguid).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); @@ -506,7 +514,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("ProductCostHistory", "Production"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.Product) @@ -517,7 +526,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().Property(e => e.Description).IsRequired(); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity().Property(e => e.rowguid).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); @@ -525,7 +535,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("ProductDocument", "Production"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.Product) @@ -538,7 +549,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().Property(e => e.Shelf).IsRequired(); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity().Property(e => e.rowguid).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); @@ -556,7 +568,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("ProductListPriceHistory", "Production"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.Product) @@ -575,7 +588,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("ProductModelIllustration", "Production"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.Illustration) @@ -587,11 +601,13 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) .WithMany(p => p.ProductModelIllustration) .HasForeignKey(d => d.ProductModelID); - modelBuilder.Entity().HasKey(e => new { e.ProductModelID, e.ProductDescriptionID, e.CultureID }); + modelBuilder.Entity() + .HasKey(e => new { e.ProductModelID, e.ProductDescriptionID, e.CultureID }); modelBuilder.Entity().ToTable("ProductModelProductDescriptionCulture", "Production"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.Culture) @@ -616,7 +632,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("ProductProductPhoto", "Production"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.Product) @@ -647,7 +664,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().Property(e => e.Name).IsRequired(); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity().Property(e => e.rowguid).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); @@ -687,7 +705,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().Property(e => e.RejectedQty).HasPrecision(8, 2); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity().Property(e => e.StockedQty) .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity) @@ -707,11 +726,14 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("PurchaseOrderHeader", "Purchasing"); - modelBuilder.Entity().Property(e => e.TotalDue).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); + modelBuilder.Entity().Property(e => e.TotalDue) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); - modelBuilder.Entity().Property(e => e.OrderDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); + modelBuilder.Entity().Property(e => e.OrderDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); modelBuilder.Entity() .HasRequired(d => d.Employee) @@ -732,7 +754,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("SalesOrderDetail", "Sales"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity().Property(e => e.rowguid).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); @@ -761,7 +784,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().Property(e => e.TotalDue).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity().Property(e => e.rowguid).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); @@ -811,7 +835,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("SalesOrderHeaderSalesReason", "Sales"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.SalesOrder) @@ -844,9 +869,11 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("SalesPersonQuotaHistory", "Sales"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); - modelBuilder.Entity().Property(e => e.rowguid).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.rowguid) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.BusinessEntity) @@ -884,7 +911,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().Property(e => e.Name).IsRequired(); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity().Property(e => e.rowguid).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); @@ -897,9 +925,11 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("SalesTerritoryHistory", "Sales"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); - modelBuilder.Entity().Property(e => e.rowguid).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.rowguid) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.BusinessEntity) @@ -933,9 +963,11 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("ShoppingCartItem", "Sales"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); - modelBuilder.Entity().Property(e => e.DateCreated).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); + modelBuilder.Entity().Property(e => e.DateCreated) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); modelBuilder.Entity() .HasRequired(d => d.Product) @@ -958,9 +990,11 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().ToTable("SpecialOfferProduct", "Sales"); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); - modelBuilder.Entity().Property(e => e.rowguid).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.rowguid) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.Product) @@ -1019,9 +1053,11 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().Property(e => e.TransactionType).IsRequired(); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); - modelBuilder.Entity().Property(e => e.TransactionDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); + modelBuilder.Entity().Property(e => e.TransactionDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); modelBuilder.Entity() .HasRequired(d => d.Product) @@ -1034,9 +1070,11 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().Property(e => e.TransactionType).IsRequired(); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); - modelBuilder.Entity().Property(e => e.TransactionDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); + modelBuilder.Entity().Property(e => e.TransactionDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); modelBuilder.Entity().HasKey(e => e.UnitMeasureCode); @@ -1082,7 +1120,8 @@ public static void ConfigureModel(DbModelBuilder modelBuilder) modelBuilder.Entity().Property(e => e.ActualResourceHrs).HasPrecision(9, 4); - modelBuilder.Entity().Property(e => e.ModifiedDate).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); + modelBuilder.Entity().Property(e => e.ModifiedDate) + .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); modelBuilder.Entity() .HasRequired(d => d.Location) diff --git a/benchmark/EF6.SqlServer.Benchmarks/Models/AdventureWorks/AdventureWorksFixture.cs b/benchmark/EF6.SqlServer.Benchmarks/Models/AdventureWorks/AdventureWorksFixture.cs index 8b5fbe52c4e..8bc597da593 100644 --- a/benchmark/EF6.SqlServer.Benchmarks/Models/AdventureWorks/AdventureWorksFixture.cs +++ b/benchmark/EF6.SqlServer.Benchmarks/Models/AdventureWorks/AdventureWorksFixture.cs @@ -1,8 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.EntityFrameworkCore.Benchmarks; - namespace Microsoft.EntityFrameworkCore.Benchmarks.Models.AdventureWorks { public static class AdventureWorksFixture diff --git a/benchmark/EF6.SqlServer.Benchmarks/Models/Orders/OrdersFixture.cs b/benchmark/EF6.SqlServer.Benchmarks/Models/Orders/OrdersFixture.cs index bbb54b0656c..6fecabd0965 100644 --- a/benchmark/EF6.SqlServer.Benchmarks/Models/Orders/OrdersFixture.cs +++ b/benchmark/EF6.SqlServer.Benchmarks/Models/Orders/OrdersFixture.cs @@ -16,7 +16,8 @@ public class OrdersFixture : OrdersFixtureSeedBase private readonly int _ordersPerCustomer; private readonly int _linesPerOrder; - public OrdersFixture(string databaseName, int productCount, int customerCount, + public OrdersFixture( + string databaseName, int productCount, int customerCount, int ordersPerCustomer, int linesPerOrder, Action seedAction = null) { _connectionString = SqlServerBenchmarkEnvironment.CreateConnectionString(databaseName); @@ -58,10 +59,10 @@ private void EnsureDatabaseCreated(Action seedAction) private bool IsDatabaseCorrect(OrdersContext context) { return context.Database.CompatibleWithModel(throwIfNoMetadata: true) - && _productCount == context.Products.Count() - && _customerCount == context.Customers.Count() - && (_customerCount * _ordersPerCustomer == context.Orders.Count()) - && (_customerCount * _ordersPerCustomer * _linesPerOrder == context.OrderLines.Count()); + && _productCount == context.Products.Count() + && _customerCount == context.Customers.Count() + && (_customerCount * _ordersPerCustomer == context.Orders.Count()) + && (_customerCount * _ordersPerCustomer * _linesPerOrder == context.OrderLines.Count()); } private void InsertSeedData() diff --git a/benchmark/EF6.SqlServer.Benchmarks/Query/FuncletizationTests.cs b/benchmark/EF6.SqlServer.Benchmarks/Query/FuncletizationTests.cs index dd6bacdc939..616513e89bb 100644 --- a/benchmark/EF6.SqlServer.Benchmarks/Query/FuncletizationTests.cs +++ b/benchmark/EF6.SqlServer.Benchmarks/Query/FuncletizationTests.cs @@ -14,6 +14,7 @@ public class FuncletizationTests { private static readonly OrdersFixture _fixture = new OrdersFixture("Perf_Query_Funcletization_EF6", 100, 0, 0, 0); + private const int _funcletizationIterationCount = 100; private OrdersContext _context; diff --git a/benchmark/EF6.SqlServer.Benchmarks/Query/QueryCompilationTests.cs b/benchmark/EF6.SqlServer.Benchmarks/Query/QueryCompilationTests.cs index a79a6c25b28..043cdc65b4d 100644 --- a/benchmark/EF6.SqlServer.Benchmarks/Query/QueryCompilationTests.cs +++ b/benchmark/EF6.SqlServer.Benchmarks/Query/QueryCompilationTests.cs @@ -14,6 +14,7 @@ public class QueryCompilationTests { private static readonly OrdersFixture _fixture = new OrdersFixture("Perf_Query_Compilation_EF6", 0, 0, 0, 0); + private OrdersContext _context; private IQueryable _simpleQuery; private IQueryable _complexQuery; diff --git a/benchmark/EF6.SqlServer.Benchmarks/Query/RawSqlQueryTests.cs b/benchmark/EF6.SqlServer.Benchmarks/Query/RawSqlQueryTests.cs index 4bb9d6ffdb7..99b5bc220c9 100644 --- a/benchmark/EF6.SqlServer.Benchmarks/Query/RawSqlQueryTests.cs +++ b/benchmark/EF6.SqlServer.Benchmarks/Query/RawSqlQueryTests.cs @@ -14,7 +14,8 @@ namespace Microsoft.EntityFrameworkCore.Benchmarks.Query public class RawSqlQueryTests { private static readonly OrdersFixture _fixture - = new OrdersFixture("Perf_Query_RawSql_EF6", 1000, 1000, 2, 2, + = new OrdersFixture( + "Perf_Query_RawSql_EF6", 1000, 1000, 2, 2, ctx => ctx.Database.ExecuteSqlCommand( @"CREATE PROCEDURE dbo.SearchProducts @minPrice decimal(18, 2), @@ -23,6 +24,7 @@ @maxPrice decimal(18, 2) BEGIN SELECT * FROM dbo.Products WHERE CurrentPrice >= @minPrice AND CurrentPrice <= @maxPrice END")); + private OrdersContext _context; [Params(true, false)] @@ -34,7 +36,6 @@ @maxPrice decimal(18, 2) [GlobalSetup] public virtual void CreateContext() { - _context = _fixture.CreateContext(); Assert.Equal(1000, _context.Products.Count()); diff --git a/benchmark/EF6.SqlServer.Benchmarks/Query/SimpleQueryTests.cs b/benchmark/EF6.SqlServer.Benchmarks/Query/SimpleQueryTests.cs index f3f26ab38d9..4adff728597 100644 --- a/benchmark/EF6.SqlServer.Benchmarks/Query/SimpleQueryTests.cs +++ b/benchmark/EF6.SqlServer.Benchmarks/Query/SimpleQueryTests.cs @@ -16,6 +16,7 @@ public class SimpleQueryTests { private static readonly OrdersFixture _fixture = new OrdersFixture("Perf_Query_Simple_EF6", 1000, 1000, 2, 2); + private OrdersContext _context; [Params(true, false)] @@ -130,11 +131,7 @@ public virtual async Task GroupBy() var query = _context.Products .GroupBy(p => p.Retail) .Select( - g => new - { - Retail = g.Key, - Products = g - }); + g => new { Retail = g.Key, Products = g }); if (Async) { diff --git a/benchmark/EF6.SqlServer.Benchmarks/Support/Extensions.cs b/benchmark/EF6.SqlServer.Benchmarks/Support/Extensions.cs index 726299d40a6..dabe1e63926 100644 --- a/benchmark/EF6.SqlServer.Benchmarks/Support/Extensions.cs +++ b/benchmark/EF6.SqlServer.Benchmarks/Support/Extensions.cs @@ -24,7 +24,8 @@ public static IQueryable DisableQueryCache(this IQueryable) - .GetProperty("System.Data.Entity.Internal.Linq.IInternalQueryAdapter.InternalQuery", BindingFlags.NonPublic | BindingFlags.Instance) + .GetProperty( + "System.Data.Entity.Internal.Linq.IInternalQueryAdapter.InternalQuery", BindingFlags.NonPublic | BindingFlags.Instance) .GetMethod .Invoke(query, Array.Empty()); diff --git a/benchmark/EF6.SqlServer.Benchmarks/Support/Program.cs b/benchmark/EF6.SqlServer.Benchmarks/Support/Program.cs index 6c209d3444c..dfbc9c83601 100644 --- a/benchmark/EF6.SqlServer.Benchmarks/Support/Program.cs +++ b/benchmark/EF6.SqlServer.Benchmarks/Support/Program.cs @@ -1,17 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; -using System.Linq; -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Columns; -using BenchmarkDotNet.Configs; -using BenchmarkDotNet.Diagnosers; -using BenchmarkDotNet.Exporters; -using BenchmarkDotNet.Exporters.Csv; -using BenchmarkDotNet.Horology; -using BenchmarkDotNet.Reports; -using BenchmarkDotNet.Running; + // ReSharper disable once CheckNamespace namespace Microsoft.EntityFrameworkCore.Benchmarks diff --git a/benchmark/EF6.SqlServer.Benchmarks/Support/SqlServerBenchmarkEnvironment.cs b/benchmark/EF6.SqlServer.Benchmarks/Support/SqlServerBenchmarkEnvironment.cs index 191dfb4f5b0..1159072ee4a 100644 --- a/benchmark/EF6.SqlServer.Benchmarks/Support/SqlServerBenchmarkEnvironment.cs +++ b/benchmark/EF6.SqlServer.Benchmarks/Support/SqlServerBenchmarkEnvironment.cs @@ -1,8 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.IO; using System.Data.SqlClient; +using System.IO; using Microsoft.Extensions.Configuration; // ReSharper disable once CheckNamespace diff --git a/benchmark/EF6.SqlServer.Benchmarks/UpdatePipeline/SimpleUpdatePipelineTests.cs b/benchmark/EF6.SqlServer.Benchmarks/UpdatePipeline/SimpleUpdatePipelineTests.cs index 664d41d695b..8cd8adf5aed 100644 --- a/benchmark/EF6.SqlServer.Benchmarks/UpdatePipeline/SimpleUpdatePipelineTests.cs +++ b/benchmark/EF6.SqlServer.Benchmarks/UpdatePipeline/SimpleUpdatePipelineTests.cs @@ -20,6 +20,7 @@ public abstract class UpdatePipelineBase { protected static readonly OrdersFixture _fixture = new OrdersFixture("Perf_UpdatePipeline_Simple_EF6", 0, 1000, 0, 0); + protected OrdersContext _context; private DbContextTransaction _transaction; private int _recordsAffected = -1; diff --git a/benchmark/EFCore.Benchmarks/Initialization/ColdStartEnabledTests.cs b/benchmark/EFCore.Benchmarks/Initialization/ColdStartEnabledTests.cs index 6830d374343..b0bf1d24288 100644 --- a/benchmark/EFCore.Benchmarks/Initialization/ColdStartEnabledTests.cs +++ b/benchmark/EFCore.Benchmarks/Initialization/ColdStartEnabledTests.cs @@ -43,11 +43,7 @@ public void InitializeAndSaveChanges_AdventureWorks(int count) using (var context = CreateContext()) { context.Currency.Add( - new Currency - { - CurrencyCode = "TMP", - Name = "Temporary" - }); + new Currency { CurrencyCode = "TMP", Name = "Temporary" }); using (context.Database.BeginTransaction()) { diff --git a/benchmark/EFCore.Benchmarks/Models/AdventureWorks/AdventureWorksContextBase.cs b/benchmark/EFCore.Benchmarks/Models/AdventureWorks/AdventureWorksContextBase.cs index 3d41d924048..9905233cce9 100644 --- a/benchmark/EFCore.Benchmarks/Models/AdventureWorks/AdventureWorksContextBase.cs +++ b/benchmark/EFCore.Benchmarks/Models/AdventureWorks/AdventureWorksContextBase.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - namespace Microsoft.EntityFrameworkCore.Benchmarks.Models.AdventureWorks { public abstract class AdventureWorksContextBase : DbContext @@ -90,1277 +89,1277 @@ public static void ConfigureModel(ModelBuilder modelBuilder) { modelBuilder.Entity
( entity => - { - entity.ToTable("Address", "Person"); + { + entity.ToTable("Address", "Person"); - entity.Property(e => e.AddressLine1).IsRequired(); + entity.Property(e => e.AddressLine1).IsRequired(); - entity.Property(e => e.City).IsRequired(); + entity.Property(e => e.City).IsRequired(); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.PostalCode).IsRequired(); + entity.Property(e => e.PostalCode).IsRequired(); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.HasOne(d => d.StateProvince) - .WithMany(p => p.Address) - .HasForeignKey(d => d.StateProvinceID); - }); + entity.HasOne(d => d.StateProvince) + .WithMany(p => p.Address) + .HasForeignKey(d => d.StateProvinceID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("AddressType", "Person"); + { + entity.ToTable("AddressType", "Person"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); + entity.Property(e => e.Name).IsRequired(); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - }); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + }); modelBuilder.Entity( entity => - { - entity.ToTable("BillOfMaterials", "Production"); + { + entity.ToTable("BillOfMaterials", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.PerAssemblyQty) - .HasColumnType("decimal(8, 2)") - .HasDefaultValue(1.00m); + entity.Property(e => e.PerAssemblyQty) + .HasColumnType("decimal(8, 2)") + .HasDefaultValue(1.00m); - entity.Property(e => e.StartDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.StartDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.UnitMeasureCode).IsRequired(); + entity.Property(e => e.UnitMeasureCode).IsRequired(); - entity.HasOne(d => d.Component) - .WithMany(p => p.BillOfMaterials) - .HasForeignKey(d => d.ComponentID); + entity.HasOne(d => d.Component) + .WithMany(p => p.BillOfMaterials) + .HasForeignKey(d => d.ComponentID); - entity.HasOne(d => d.ProductAssembly) - .WithMany(p => p.BillOfMaterialsNavigation) - .HasForeignKey(d => d.ProductAssemblyID); + entity.HasOne(d => d.ProductAssembly) + .WithMany(p => p.BillOfMaterialsNavigation) + .HasForeignKey(d => d.ProductAssemblyID); - entity.HasOne(d => d.UnitMeasureCodeNavigation) - .WithMany(p => p.BillOfMaterials) - .HasForeignKey(d => d.UnitMeasureCode); - }); + entity.HasOne(d => d.UnitMeasureCodeNavigation) + .WithMany(p => p.BillOfMaterials) + .HasForeignKey(d => d.UnitMeasureCode); + }); modelBuilder.Entity( entity => - { - entity.ToTable("BusinessEntity", "Person"); + { + entity.ToTable("BusinessEntity", "Person"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - }); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.BusinessEntityID, e.AddressID, e.AddressTypeID }); + { + entity.HasKey(e => new { e.BusinessEntityID, e.AddressID, e.AddressTypeID }); - entity.ToTable("BusinessEntityAddress", "Person"); + entity.ToTable("BusinessEntityAddress", "Person"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.HasOne(d => d.Address) - .WithMany(p => p.BusinessEntityAddress) - .HasForeignKey(d => d.AddressID); + entity.HasOne(d => d.Address) + .WithMany(p => p.BusinessEntityAddress) + .HasForeignKey(d => d.AddressID); - entity.HasOne(d => d.AddressType) - .WithMany(p => p.BusinessEntityAddress) - .HasForeignKey(d => d.AddressTypeID); + entity.HasOne(d => d.AddressType) + .WithMany(p => p.BusinessEntityAddress) + .HasForeignKey(d => d.AddressTypeID); - entity.HasOne(d => d.BusinessEntity) - .WithMany(p => p.BusinessEntityAddress) - .HasForeignKey(d => d.BusinessEntityID); - }); + entity.HasOne(d => d.BusinessEntity) + .WithMany(p => p.BusinessEntityAddress) + .HasForeignKey(d => d.BusinessEntityID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.BusinessEntityID, e.PersonID, e.ContactTypeID }); + { + entity.HasKey(e => new { e.BusinessEntityID, e.PersonID, e.ContactTypeID }); - entity.ToTable("BusinessEntityContact", "Person"); + entity.ToTable("BusinessEntityContact", "Person"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.HasOne(d => d.BusinessEntity) - .WithMany(p => p.BusinessEntityContact) - .HasForeignKey(d => d.BusinessEntityID); + entity.HasOne(d => d.BusinessEntity) + .WithMany(p => p.BusinessEntityContact) + .HasForeignKey(d => d.BusinessEntityID); - entity.HasOne(d => d.ContactType) - .WithMany(p => p.BusinessEntityContact) - .HasForeignKey(d => d.ContactTypeID); + entity.HasOne(d => d.ContactType) + .WithMany(p => p.BusinessEntityContact) + .HasForeignKey(d => d.ContactTypeID); - entity.HasOne(d => d.Person) - .WithMany(p => p.BusinessEntityContact) - .HasForeignKey(d => d.PersonID); - }); + entity.HasOne(d => d.Person) + .WithMany(p => p.BusinessEntityContact) + .HasForeignKey(d => d.PersonID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("ContactType", "Person"); + { + entity.ToTable("ContactType", "Person"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); - }); + entity.Property(e => e.Name).IsRequired(); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => e.CountryRegionCode); + { + entity.HasKey(e => e.CountryRegionCode); - entity.ToTable("CountryRegion", "Person"); + entity.ToTable("CountryRegion", "Person"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); - }); + entity.Property(e => e.Name).IsRequired(); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.CountryRegionCode, e.CurrencyCode }); + { + entity.HasKey(e => new { e.CountryRegionCode, e.CurrencyCode }); - entity.ToTable("CountryRegionCurrency", "Sales"); + entity.ToTable("CountryRegionCurrency", "Sales"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.HasOne(d => d.CountryRegionCodeNavigation) - .WithMany(p => p.CountryRegionCurrency) - .HasForeignKey(d => d.CountryRegionCode); + entity.HasOne(d => d.CountryRegionCodeNavigation) + .WithMany(p => p.CountryRegionCurrency) + .HasForeignKey(d => d.CountryRegionCode); - entity.HasOne(d => d.CurrencyCodeNavigation) - .WithMany(p => p.CountryRegionCurrency) - .HasForeignKey(d => d.CurrencyCode); - }); + entity.HasOne(d => d.CurrencyCodeNavigation) + .WithMany(p => p.CountryRegionCurrency) + .HasForeignKey(d => d.CurrencyCode); + }); modelBuilder.Entity( entity => - { - entity.ToTable("CreditCard", "Sales"); + { + entity.ToTable("CreditCard", "Sales"); - entity.Property(e => e.CardNumber).IsRequired(); + entity.Property(e => e.CardNumber).IsRequired(); - entity.Property(e => e.CardType).IsRequired(); + entity.Property(e => e.CardType).IsRequired(); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - }); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + }); modelBuilder.Entity( entity => - { - entity.ToTable("Culture", "Production"); + { + entity.ToTable("Culture", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); - }); + entity.Property(e => e.Name).IsRequired(); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => e.CurrencyCode); + { + entity.HasKey(e => e.CurrencyCode); - entity.ToTable("Currency", "Sales"); + entity.ToTable("Currency", "Sales"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); - }); + entity.Property(e => e.Name).IsRequired(); + }); modelBuilder.Entity( entity => - { - entity.ToTable("CurrencyRate", "Sales"); + { + entity.ToTable("CurrencyRate", "Sales"); - entity.Property(e => e.FromCurrencyCode).IsRequired(); + entity.Property(e => e.FromCurrencyCode).IsRequired(); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.ToCurrencyCode).IsRequired(); + entity.Property(e => e.ToCurrencyCode).IsRequired(); - entity.HasOne(d => d.FromCurrencyCodeNavigation) - .WithMany(p => p.CurrencyRate) - .HasForeignKey(d => d.FromCurrencyCode); + entity.HasOne(d => d.FromCurrencyCodeNavigation) + .WithMany(p => p.CurrencyRate) + .HasForeignKey(d => d.FromCurrencyCode); - entity.HasOne(d => d.ToCurrencyCodeNavigation) - .WithMany(p => p.CurrencyRateNavigation) - .HasForeignKey(d => d.ToCurrencyCode); - }); + entity.HasOne(d => d.ToCurrencyCodeNavigation) + .WithMany(p => p.CurrencyRateNavigation) + .HasForeignKey(d => d.ToCurrencyCode); + }); modelBuilder.Entity( entity => - { - entity.ToTable("Customer", "Sales"); + { + entity.ToTable("Customer", "Sales"); - entity.Property(e => e.AccountNumber) - .IsRequired() - .ValueGeneratedOnAddOrUpdate(); + entity.Property(e => e.AccountNumber) + .IsRequired() + .ValueGeneratedOnAddOrUpdate(); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.HasOne(d => d.Person) - .WithMany(p => p.Customer) - .HasForeignKey(d => d.PersonID); + entity.HasOne(d => d.Person) + .WithMany(p => p.Customer) + .HasForeignKey(d => d.PersonID); - entity.HasOne(d => d.Store) - .WithMany(p => p.Customer) - .HasForeignKey(d => d.StoreID); + entity.HasOne(d => d.Store) + .WithMany(p => p.Customer) + .HasForeignKey(d => d.StoreID); - entity.HasOne(d => d.Territory) - .WithMany(p => p.Customer) - .HasForeignKey(d => d.TerritoryID); - }); + entity.HasOne(d => d.Territory) + .WithMany(p => p.Customer) + .HasForeignKey(d => d.TerritoryID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("Department", "HumanResources"); + { + entity.ToTable("Department", "HumanResources"); - entity.Property(e => e.GroupName).IsRequired(); + entity.Property(e => e.GroupName).IsRequired(); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); - }); + entity.Property(e => e.Name).IsRequired(); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.BusinessEntityID, e.EmailAddressID }); + { + entity.HasKey(e => new { e.BusinessEntityID, e.EmailAddressID }); - entity.ToTable("EmailAddress", "Person"); + entity.ToTable("EmailAddress", "Person"); - entity.Property(e => e.EmailAddress1).HasColumnName("EmailAddress"); + entity.Property(e => e.EmailAddress1).HasColumnName("EmailAddress"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.HasOne(d => d.BusinessEntity) - .WithMany(p => p.EmailAddress) - .HasForeignKey(d => d.BusinessEntityID); - }); + entity.HasOne(d => d.BusinessEntity) + .WithMany(p => p.EmailAddress) + .HasForeignKey(d => d.BusinessEntityID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => e.BusinessEntityID); + { + entity.HasKey(e => e.BusinessEntityID); - entity.ToTable("Employee", "HumanResources"); + entity.ToTable("Employee", "HumanResources"); - entity.Property(e => e.CurrentFlag).HasDefaultValue(true); + entity.Property(e => e.CurrentFlag).HasDefaultValue(true); - entity.Property(e => e.Gender).IsRequired(); + entity.Property(e => e.Gender).IsRequired(); - entity.Property(e => e.JobTitle).IsRequired(); + entity.Property(e => e.JobTitle).IsRequired(); - entity.Property(e => e.LoginID).IsRequired(); + entity.Property(e => e.LoginID).IsRequired(); - entity.Property(e => e.MaritalStatus).IsRequired(); + entity.Property(e => e.MaritalStatus).IsRequired(); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.NationalIDNumber).IsRequired(); + entity.Property(e => e.NationalIDNumber).IsRequired(); - entity.Property(e => e.OrganizationLevel).ValueGeneratedOnAddOrUpdate(); + entity.Property(e => e.OrganizationLevel).ValueGeneratedOnAddOrUpdate(); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.Property(e => e.SalariedFlag).HasDefaultValue(true); + entity.Property(e => e.SalariedFlag).HasDefaultValue(true); - entity.Property(e => e.SickLeaveHours).HasDefaultValue((short)0); + entity.Property(e => e.SickLeaveHours).HasDefaultValue((short)0); - entity.Property(e => e.VacationHours).HasDefaultValue((short)0); + entity.Property(e => e.VacationHours).HasDefaultValue((short)0); - entity.HasOne(d => d.BusinessEntity) - .WithOne(p => p.Employee) - .HasForeignKey(d => d.BusinessEntityID); - }); + entity.HasOne(d => d.BusinessEntity) + .WithOne(p => p.Employee) + .HasForeignKey(d => d.BusinessEntityID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.BusinessEntityID, e.StartDate, e.DepartmentID, e.ShiftID }); + { + entity.HasKey(e => new { e.BusinessEntityID, e.StartDate, e.DepartmentID, e.ShiftID }); - entity.ToTable("EmployeeDepartmentHistory", "HumanResources"); + entity.ToTable("EmployeeDepartmentHistory", "HumanResources"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.HasOne(d => d.BusinessEntity) - .WithMany(p => p.EmployeeDepartmentHistory) - .HasForeignKey(d => d.BusinessEntityID); + entity.HasOne(d => d.BusinessEntity) + .WithMany(p => p.EmployeeDepartmentHistory) + .HasForeignKey(d => d.BusinessEntityID); - entity.HasOne(d => d.Department) - .WithMany(p => p.EmployeeDepartmentHistory) - .HasForeignKey(d => d.DepartmentID); + entity.HasOne(d => d.Department) + .WithMany(p => p.EmployeeDepartmentHistory) + .HasForeignKey(d => d.DepartmentID); - entity.HasOne(d => d.Shift) - .WithMany(p => p.EmployeeDepartmentHistory) - .HasForeignKey(d => d.ShiftID); - }); + entity.HasOne(d => d.Shift) + .WithMany(p => p.EmployeeDepartmentHistory) + .HasForeignKey(d => d.ShiftID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.BusinessEntityID, e.RateChangeDate }); + { + entity.HasKey(e => new { e.BusinessEntityID, e.RateChangeDate }); - entity.ToTable("EmployeePayHistory", "HumanResources"); + entity.ToTable("EmployeePayHistory", "HumanResources"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.HasOne(d => d.BusinessEntity) - .WithMany(p => p.EmployeePayHistory) - .HasForeignKey(d => d.BusinessEntityID); - }); + entity.HasOne(d => d.BusinessEntity) + .WithMany(p => p.EmployeePayHistory) + .HasForeignKey(d => d.BusinessEntityID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("Illustration", "Production"); + { + entity.ToTable("Illustration", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - }); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + }); modelBuilder.Entity( entity => - { - entity.ToTable("JobCandidate", "HumanResources"); + { + entity.ToTable("JobCandidate", "HumanResources"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.HasOne(d => d.BusinessEntity) - .WithMany(p => p.JobCandidate) - .HasForeignKey(d => d.BusinessEntityID); - }); + entity.HasOne(d => d.BusinessEntity) + .WithMany(p => p.JobCandidate) + .HasForeignKey(d => d.BusinessEntityID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("Location", "Production"); + { + entity.ToTable("Location", "Production"); - entity.Property(e => e.Availability) - .HasColumnType("decimal(8, 2)") - .HasDefaultValue(0.00m); + entity.Property(e => e.Availability) + .HasColumnType("decimal(8, 2)") + .HasDefaultValue(0.00m); - entity.Property(e => e.CostRate).HasDefaultValue(0.00m); + entity.Property(e => e.CostRate).HasDefaultValue(0.00m); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); - }); + entity.Property(e => e.Name).IsRequired(); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => e.BusinessEntityID); + { + entity.HasKey(e => e.BusinessEntityID); - entity.ToTable("Password", "Person"); + entity.ToTable("Password", "Person"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.PasswordHash).IsRequired(); + entity.Property(e => e.PasswordHash).IsRequired(); - entity.Property(e => e.PasswordSalt).IsRequired(); + entity.Property(e => e.PasswordSalt).IsRequired(); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.HasOne(d => d.BusinessEntity).WithOne(p => p.Password).HasForeignKey(d => d.BusinessEntityID); - }); + entity.HasOne(d => d.BusinessEntity).WithOne(p => p.Password).HasForeignKey(d => d.BusinessEntityID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => e.BusinessEntityID); + { + entity.HasKey(e => e.BusinessEntityID); - entity.ToTable("Person", "Person"); + entity.ToTable("Person", "Person"); - entity.Property(e => e.EmailPromotion).HasDefaultValue(0); + entity.Property(e => e.EmailPromotion).HasDefaultValue(0); - entity.Property(e => e.FirstName).IsRequired(); + entity.Property(e => e.FirstName).IsRequired(); - entity.Property(e => e.LastName).IsRequired(); + entity.Property(e => e.LastName).IsRequired(); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.NameStyle).HasDefaultValue(false); + entity.Property(e => e.NameStyle).HasDefaultValue(false); - entity.Property(e => e.PersonType).IsRequired(); + entity.Property(e => e.PersonType).IsRequired(); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.HasOne(d => d.BusinessEntity) - .WithOne(p => p.Person) - .HasForeignKey(d => d.BusinessEntityID); - }); + entity.HasOne(d => d.BusinessEntity) + .WithOne(p => p.Person) + .HasForeignKey(d => d.BusinessEntityID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.BusinessEntityID, e.CreditCardID }); + { + entity.HasKey(e => new { e.BusinessEntityID, e.CreditCardID }); - entity.ToTable("PersonCreditCard", "Sales"); + entity.ToTable("PersonCreditCard", "Sales"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.HasOne(d => d.BusinessEntity) - .WithMany(p => p.PersonCreditCard) - .HasForeignKey(d => d.BusinessEntityID); + entity.HasOne(d => d.BusinessEntity) + .WithMany(p => p.PersonCreditCard) + .HasForeignKey(d => d.BusinessEntityID); - entity.HasOne(d => d.CreditCard) - .WithMany(p => p.PersonCreditCard) - .HasForeignKey(d => d.CreditCardID); - }); + entity.HasOne(d => d.CreditCard) + .WithMany(p => p.PersonCreditCard) + .HasForeignKey(d => d.CreditCardID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.BusinessEntityID, e.PhoneNumber, e.PhoneNumberTypeID }); + { + entity.HasKey(e => new { e.BusinessEntityID, e.PhoneNumber, e.PhoneNumberTypeID }); - entity.ToTable("PersonPhone", "Person"); + entity.ToTable("PersonPhone", "Person"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.HasOne(d => d.BusinessEntity) - .WithMany(p => p.PersonPhone) - .HasForeignKey(d => d.BusinessEntityID); + entity.HasOne(d => d.BusinessEntity) + .WithMany(p => p.PersonPhone) + .HasForeignKey(d => d.BusinessEntityID); - entity.HasOne(d => d.PhoneNumberType) - .WithMany(p => p.PersonPhone) - .HasForeignKey(d => d.PhoneNumberTypeID); - }); + entity.HasOne(d => d.PhoneNumberType) + .WithMany(p => p.PersonPhone) + .HasForeignKey(d => d.PhoneNumberTypeID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("PhoneNumberType", "Person"); + { + entity.ToTable("PhoneNumberType", "Person"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); - }); + entity.Property(e => e.Name).IsRequired(); + }); modelBuilder.Entity( entity => - { - entity.ToTable("Product", "Production"); + { + entity.ToTable("Product", "Production"); - entity.Property(e => e.FinishedGoodsFlag).HasDefaultValue(true); + entity.Property(e => e.FinishedGoodsFlag).HasDefaultValue(true); - entity.Property(e => e.MakeFlag).HasDefaultValue(true); + entity.Property(e => e.MakeFlag).HasDefaultValue(true); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); + entity.Property(e => e.Name).IsRequired(); - entity.Property(e => e.ProductNumber).IsRequired(); + entity.Property(e => e.ProductNumber).IsRequired(); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.Property(e => e.Weight).HasColumnType("decimal(8, 2)"); + entity.Property(e => e.Weight).HasColumnType("decimal(8, 2)"); - entity.HasOne(d => d.ProductModel) - .WithMany(p => p.Product) - .HasForeignKey(d => d.ProductModelID); + entity.HasOne(d => d.ProductModel) + .WithMany(p => p.Product) + .HasForeignKey(d => d.ProductModelID); - entity.HasOne(d => d.ProductSubcategory) - .WithMany(p => p.Product) - .HasForeignKey(d => d.ProductSubcategoryID); + entity.HasOne(d => d.ProductSubcategory) + .WithMany(p => p.Product) + .HasForeignKey(d => d.ProductSubcategoryID); - entity.HasOne(d => d.SizeUnitMeasureCodeNavigation) - .WithMany(p => p.Product) - .HasForeignKey(d => d.SizeUnitMeasureCode); + entity.HasOne(d => d.SizeUnitMeasureCodeNavigation) + .WithMany(p => p.Product) + .HasForeignKey(d => d.SizeUnitMeasureCode); - entity.HasOne(d => d.WeightUnitMeasureCodeNavigation) - .WithMany(p => p.ProductNavigation) - .HasForeignKey(d => d.WeightUnitMeasureCode); - }); + entity.HasOne(d => d.WeightUnitMeasureCodeNavigation) + .WithMany(p => p.ProductNavigation) + .HasForeignKey(d => d.WeightUnitMeasureCode); + }); modelBuilder.Entity( entity => - { - entity.ToTable("ProductCategory", "Production"); + { + entity.ToTable("ProductCategory", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); + entity.Property(e => e.Name).IsRequired(); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - }); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.ProductID, e.StartDate }); + { + entity.HasKey(e => new { e.ProductID, e.StartDate }); - entity.ToTable("ProductCostHistory", "Production"); + entity.ToTable("ProductCostHistory", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.HasOne(d => d.Product) - .WithMany(p => p.ProductCostHistory) - .HasForeignKey(d => d.ProductID); - }); + entity.HasOne(d => d.Product) + .WithMany(p => p.ProductCostHistory) + .HasForeignKey(d => d.ProductID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("ProductDescription", "Production"); + { + entity.ToTable("ProductDescription", "Production"); - entity.Property(e => e.Description).IsRequired(); + entity.Property(e => e.Description).IsRequired(); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - }); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.ProductID, e.DocumentNode }); + { + entity.HasKey(e => new { e.ProductID, e.DocumentNode }); - entity.ToTable("ProductDocument", "Production"); + entity.ToTable("ProductDocument", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.HasOne(d => d.Product) - .WithMany(p => p.ProductDocument) - .HasForeignKey(d => d.ProductID); - }); + entity.HasOne(d => d.Product) + .WithMany(p => p.ProductDocument) + .HasForeignKey(d => d.ProductID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.ProductID, e.LocationID }); + { + entity.HasKey(e => new { e.ProductID, e.LocationID }); - entity.ToTable("ProductInventory", "Production"); + entity.ToTable("ProductInventory", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Quantity).HasDefaultValue((short)0); + entity.Property(e => e.Quantity).HasDefaultValue((short)0); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.Property(e => e.Shelf).IsRequired(); + entity.Property(e => e.Shelf).IsRequired(); - entity.HasOne(d => d.Location) - .WithMany(p => p.ProductInventory) - .HasForeignKey(d => d.LocationID); + entity.HasOne(d => d.Location) + .WithMany(p => p.ProductInventory) + .HasForeignKey(d => d.LocationID); - entity.HasOne(d => d.Product) - .WithMany(p => p.ProductInventory) - .HasForeignKey(d => d.ProductID); - }); + entity.HasOne(d => d.Product) + .WithMany(p => p.ProductInventory) + .HasForeignKey(d => d.ProductID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.ProductID, e.StartDate }); + { + entity.HasKey(e => new { e.ProductID, e.StartDate }); - entity.ToTable("ProductListPriceHistory", "Production"); + entity.ToTable("ProductListPriceHistory", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.HasOne(d => d.Product) - .WithMany(p => p.ProductListPriceHistory) - .HasForeignKey(d => d.ProductID); - }); + entity.HasOne(d => d.Product) + .WithMany(p => p.ProductListPriceHistory) + .HasForeignKey(d => d.ProductID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("ProductModel", "Production"); + { + entity.ToTable("ProductModel", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); + entity.Property(e => e.Name).IsRequired(); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - }); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.ProductModelID, e.IllustrationID }); + { + entity.HasKey(e => new { e.ProductModelID, e.IllustrationID }); - entity.ToTable("ProductModelIllustration", "Production"); + entity.ToTable("ProductModelIllustration", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.HasOne(d => d.Illustration) - .WithMany(p => p.ProductModelIllustration) - .HasForeignKey(d => d.IllustrationID); + entity.HasOne(d => d.Illustration) + .WithMany(p => p.ProductModelIllustration) + .HasForeignKey(d => d.IllustrationID); - entity.HasOne(d => d.ProductModel) - .WithMany(p => p.ProductModelIllustration) - .HasForeignKey(d => d.ProductModelID); - }); + entity.HasOne(d => d.ProductModel) + .WithMany(p => p.ProductModelIllustration) + .HasForeignKey(d => d.ProductModelID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.ProductModelID, e.ProductDescriptionID, e.CultureID }); + { + entity.HasKey(e => new { e.ProductModelID, e.ProductDescriptionID, e.CultureID }); - entity.ToTable("ProductModelProductDescriptionCulture", "Production"); + entity.ToTable("ProductModelProductDescriptionCulture", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.HasOne(d => d.Culture) - .WithMany(p => p.ProductModelProductDescriptionCulture) - .HasForeignKey(d => d.CultureID); + entity.HasOne(d => d.Culture) + .WithMany(p => p.ProductModelProductDescriptionCulture) + .HasForeignKey(d => d.CultureID); - entity.HasOne(d => d.ProductDescription) - .WithMany(p => p.ProductModelProductDescriptionCulture) - .HasForeignKey(d => d.ProductDescriptionID); + entity.HasOne(d => d.ProductDescription) + .WithMany(p => p.ProductModelProductDescriptionCulture) + .HasForeignKey(d => d.ProductDescriptionID); - entity.HasOne(d => d.ProductModel) - .WithMany(p => p.ProductModelProductDescriptionCulture) - .HasForeignKey(d => d.ProductModelID); - }); + entity.HasOne(d => d.ProductModel) + .WithMany(p => p.ProductModelProductDescriptionCulture) + .HasForeignKey(d => d.ProductModelID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("ProductPhoto", "Production"); + { + entity.ToTable("ProductPhoto", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - }); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.ProductID, e.ProductPhotoID }); + { + entity.HasKey(e => new { e.ProductID, e.ProductPhotoID }); - entity.ToTable("ProductProductPhoto", "Production"); + entity.ToTable("ProductProductPhoto", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Primary).HasDefaultValue(false); + entity.Property(e => e.Primary).HasDefaultValue(false); - entity.HasOne(d => d.Product) - .WithMany(p => p.ProductProductPhoto) - .HasForeignKey(d => d.ProductID); + entity.HasOne(d => d.Product) + .WithMany(p => p.ProductProductPhoto) + .HasForeignKey(d => d.ProductID); - entity.HasOne(d => d.ProductPhoto) - .WithMany(p => p.ProductProductPhoto) - .HasForeignKey(d => d.ProductPhotoID); - }); + entity.HasOne(d => d.ProductPhoto) + .WithMany(p => p.ProductProductPhoto) + .HasForeignKey(d => d.ProductPhotoID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("ProductReview", "Production"); + { + entity.ToTable("ProductReview", "Production"); - entity.Property(e => e.EmailAddress).IsRequired(); + entity.Property(e => e.EmailAddress).IsRequired(); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.ReviewDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ReviewDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.ReviewerName).IsRequired(); + entity.Property(e => e.ReviewerName).IsRequired(); - entity.HasOne(d => d.Product) - .WithMany(p => p.ProductReview) - .HasForeignKey(d => d.ProductID); - }); + entity.HasOne(d => d.Product) + .WithMany(p => p.ProductReview) + .HasForeignKey(d => d.ProductID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("ProductSubcategory", "Production"); + { + entity.ToTable("ProductSubcategory", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); + entity.Property(e => e.Name).IsRequired(); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.HasOne(d => d.ProductCategory) - .WithMany(p => p.ProductSubcategory) - .HasForeignKey(d => d.ProductCategoryID); - }); + entity.HasOne(d => d.ProductCategory) + .WithMany(p => p.ProductSubcategory) + .HasForeignKey(d => d.ProductCategoryID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.ProductID, e.BusinessEntityID }); + { + entity.HasKey(e => new { e.ProductID, e.BusinessEntityID }); - entity.ToTable("ProductVendor", "Purchasing"); + entity.ToTable("ProductVendor", "Purchasing"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.UnitMeasureCode).IsRequired(); + entity.Property(e => e.UnitMeasureCode).IsRequired(); - entity.HasOne(d => d.BusinessEntity) - .WithMany(p => p.ProductVendor) - .HasForeignKey(d => d.BusinessEntityID); + entity.HasOne(d => d.BusinessEntity) + .WithMany(p => p.ProductVendor) + .HasForeignKey(d => d.BusinessEntityID); - entity.HasOne(d => d.Product) - .WithMany(p => p.ProductVendor) - .HasForeignKey(d => d.ProductID); + entity.HasOne(d => d.Product) + .WithMany(p => p.ProductVendor) + .HasForeignKey(d => d.ProductID); - entity.HasOne(d => d.UnitMeasureCodeNavigation) - .WithMany(p => p.ProductVendor) - .HasForeignKey(d => d.UnitMeasureCode); - }); + entity.HasOne(d => d.UnitMeasureCodeNavigation) + .WithMany(p => p.ProductVendor) + .HasForeignKey(d => d.UnitMeasureCode); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.PurchaseOrderID, e.PurchaseOrderDetailID }); + { + entity.HasKey(e => new { e.PurchaseOrderID, e.PurchaseOrderDetailID }); - entity.ToTable("PurchaseOrderDetail", "Purchasing"); + entity.ToTable("PurchaseOrderDetail", "Purchasing"); - entity.Property(e => e.LineTotal).ValueGeneratedOnAddOrUpdate(); + entity.Property(e => e.LineTotal).ValueGeneratedOnAddOrUpdate(); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.ReceivedQty).HasColumnType("decimal(8, 2)"); + entity.Property(e => e.ReceivedQty).HasColumnType("decimal(8, 2)"); - entity.Property(e => e.RejectedQty).HasColumnType("decimal(8, 2)"); + entity.Property(e => e.RejectedQty).HasColumnType("decimal(8, 2)"); - entity.Property(e => e.StockedQty) - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("decimal(9, 2)"); + entity.Property(e => e.StockedQty) + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("decimal(9, 2)"); - entity.HasOne(d => d.Product) - .WithMany(p => p.PurchaseOrderDetail) - .HasForeignKey(d => d.ProductID); + entity.HasOne(d => d.Product) + .WithMany(p => p.PurchaseOrderDetail) + .HasForeignKey(d => d.ProductID); - entity.HasOne(d => d.PurchaseOrder) - .WithMany(p => p.PurchaseOrderDetail) - .HasForeignKey(d => d.PurchaseOrderID); - }); + entity.HasOne(d => d.PurchaseOrder) + .WithMany(p => p.PurchaseOrderDetail) + .HasForeignKey(d => d.PurchaseOrderID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => e.PurchaseOrderID); + { + entity.HasKey(e => e.PurchaseOrderID); - entity.ToTable("PurchaseOrderHeader", "Purchasing"); + entity.ToTable("PurchaseOrderHeader", "Purchasing"); - entity.Property(e => e.Freight).HasDefaultValue(0.00m); + entity.Property(e => e.Freight).HasDefaultValue(0.00m); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.OrderDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.OrderDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.RevisionNumber).HasDefaultValue((byte)0); + entity.Property(e => e.RevisionNumber).HasDefaultValue((byte)0); - entity.Property(e => e.Status).HasDefaultValue((byte)1); + entity.Property(e => e.Status).HasDefaultValue((byte)1); - entity.Property(e => e.SubTotal).HasDefaultValue(0.00m); + entity.Property(e => e.SubTotal).HasDefaultValue(0.00m); - entity.Property(e => e.TaxAmt).HasDefaultValue(0.00m); + entity.Property(e => e.TaxAmt).HasDefaultValue(0.00m); - entity.Property(e => e.TotalDue).ValueGeneratedOnAddOrUpdate(); + entity.Property(e => e.TotalDue).ValueGeneratedOnAddOrUpdate(); - entity.HasOne(d => d.Employee) - .WithMany(p => p.PurchaseOrderHeader) - .HasForeignKey(d => d.EmployeeID); + entity.HasOne(d => d.Employee) + .WithMany(p => p.PurchaseOrderHeader) + .HasForeignKey(d => d.EmployeeID); - entity.HasOne(d => d.ShipMethod) - .WithMany(p => p.PurchaseOrderHeader) - .HasForeignKey(d => d.ShipMethodID); + entity.HasOne(d => d.ShipMethod) + .WithMany(p => p.PurchaseOrderHeader) + .HasForeignKey(d => d.ShipMethodID); - entity.HasOne(d => d.Vendor) - .WithMany(p => p.PurchaseOrderHeader) - .HasForeignKey(d => d.VendorID); - }); + entity.HasOne(d => d.Vendor) + .WithMany(p => p.PurchaseOrderHeader) + .HasForeignKey(d => d.VendorID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.SalesOrderID, e.SalesOrderDetailID }); + { + entity.HasKey(e => new { e.SalesOrderID, e.SalesOrderDetailID }); - entity.ToTable("SalesOrderDetail", "Sales"); + entity.ToTable("SalesOrderDetail", "Sales"); - entity.Property(e => e.LineTotal) - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("numeric(38, 6)"); + entity.Property(e => e.LineTotal) + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("numeric(38, 6)"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.Property(e => e.UnitPriceDiscount).HasDefaultValue(0.0m); + entity.Property(e => e.UnitPriceDiscount).HasDefaultValue(0.0m); - entity.HasOne(d => d.SalesOrder) - .WithMany(p => p.SalesOrderDetail) - .HasForeignKey(d => d.SalesOrderID); + entity.HasOne(d => d.SalesOrder) + .WithMany(p => p.SalesOrderDetail) + .HasForeignKey(d => d.SalesOrderID); - entity.HasOne(d => d.SpecialOfferProduct) - .WithMany(p => p.SalesOrderDetail) - .HasForeignKey(d => new { d.SpecialOfferID, d.ProductID }); - }); + entity.HasOne(d => d.SpecialOfferProduct) + .WithMany(p => p.SalesOrderDetail) + .HasForeignKey(d => new { d.SpecialOfferID, d.ProductID }); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => e.SalesOrderID); + { + entity.HasKey(e => e.SalesOrderID); - entity.ToTable("SalesOrderHeader", "Sales"); + entity.ToTable("SalesOrderHeader", "Sales"); - entity.Property(e => e.Freight).HasDefaultValue(0.00m); + entity.Property(e => e.Freight).HasDefaultValue(0.00m); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.OnlineOrderFlag).HasDefaultValue(true); + entity.Property(e => e.OnlineOrderFlag).HasDefaultValue(true); - entity.Property(e => e.OrderDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.OrderDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.RevisionNumber).HasDefaultValue((byte)0); + entity.Property(e => e.RevisionNumber).HasDefaultValue((byte)0); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.Property(e => e.SalesOrderNumber) - .IsRequired() - .ValueGeneratedOnAddOrUpdate(); + entity.Property(e => e.SalesOrderNumber) + .IsRequired() + .ValueGeneratedOnAddOrUpdate(); - entity.Property(e => e.Status).HasDefaultValue((byte)1); + entity.Property(e => e.Status).HasDefaultValue((byte)1); - entity.Property(e => e.SubTotal).HasDefaultValue(0.00m); + entity.Property(e => e.SubTotal).HasDefaultValue(0.00m); - entity.Property(e => e.TaxAmt).HasDefaultValue(0.00m); + entity.Property(e => e.TaxAmt).HasDefaultValue(0.00m); - entity.Property(e => e.TotalDue).ValueGeneratedOnAddOrUpdate(); + entity.Property(e => e.TotalDue).ValueGeneratedOnAddOrUpdate(); - entity.HasOne(d => d.BillToAddress) - .WithMany(p => p.SalesOrderHeader) - .HasForeignKey(d => d.BillToAddressID); + entity.HasOne(d => d.BillToAddress) + .WithMany(p => p.SalesOrderHeader) + .HasForeignKey(d => d.BillToAddressID); - entity.HasOne(d => d.CreditCard) - .WithMany(p => p.SalesOrderHeader) - .HasForeignKey(d => d.CreditCardID); + entity.HasOne(d => d.CreditCard) + .WithMany(p => p.SalesOrderHeader) + .HasForeignKey(d => d.CreditCardID); - entity.HasOne(d => d.CurrencyRate) - .WithMany(p => p.SalesOrderHeader) - .HasForeignKey(d => d.CurrencyRateID); + entity.HasOne(d => d.CurrencyRate) + .WithMany(p => p.SalesOrderHeader) + .HasForeignKey(d => d.CurrencyRateID); - entity.HasOne(d => d.Customer) - .WithMany(p => p.SalesOrderHeader) - .HasForeignKey(d => d.CustomerID); + entity.HasOne(d => d.Customer) + .WithMany(p => p.SalesOrderHeader) + .HasForeignKey(d => d.CustomerID); - entity.HasOne(d => d.SalesPerson) - .WithMany(p => p.SalesOrderHeader) - .HasForeignKey(d => d.SalesPersonID); + entity.HasOne(d => d.SalesPerson) + .WithMany(p => p.SalesOrderHeader) + .HasForeignKey(d => d.SalesPersonID); - entity.HasOne(d => d.ShipMethod) - .WithMany(p => p.SalesOrderHeader) - .HasForeignKey(d => d.ShipMethodID); + entity.HasOne(d => d.ShipMethod) + .WithMany(p => p.SalesOrderHeader) + .HasForeignKey(d => d.ShipMethodID); - entity.HasOne(d => d.ShipToAddress) - .WithMany(p => p.SalesOrderHeaderNavigation) - .HasForeignKey(d => d.ShipToAddressID); + entity.HasOne(d => d.ShipToAddress) + .WithMany(p => p.SalesOrderHeaderNavigation) + .HasForeignKey(d => d.ShipToAddressID); - entity.HasOne(d => d.Territory) - .WithMany(p => p.SalesOrderHeader) - .HasForeignKey(d => d.TerritoryID); - }); + entity.HasOne(d => d.Territory) + .WithMany(p => p.SalesOrderHeader) + .HasForeignKey(d => d.TerritoryID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.SalesOrderID, e.SalesReasonID }); + { + entity.HasKey(e => new { e.SalesOrderID, e.SalesReasonID }); - entity.ToTable("SalesOrderHeaderSalesReason", "Sales"); + entity.ToTable("SalesOrderHeaderSalesReason", "Sales"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.HasOne(d => d.SalesOrder) - .WithMany(p => p.SalesOrderHeaderSalesReason) - .HasForeignKey(d => d.SalesOrderID); + entity.HasOne(d => d.SalesOrder) + .WithMany(p => p.SalesOrderHeaderSalesReason) + .HasForeignKey(d => d.SalesOrderID); - entity.HasOne(d => d.SalesReason) - .WithMany(p => p.SalesOrderHeaderSalesReason) - .HasForeignKey(d => d.SalesReasonID); - }); + entity.HasOne(d => d.SalesReason) + .WithMany(p => p.SalesOrderHeaderSalesReason) + .HasForeignKey(d => d.SalesReasonID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => e.BusinessEntityID); + { + entity.HasKey(e => e.BusinessEntityID); - entity.ToTable("SalesPerson", "Sales"); + entity.ToTable("SalesPerson", "Sales"); - entity.Property(e => e.Bonus).HasDefaultValue(0.00m); + entity.Property(e => e.Bonus).HasDefaultValue(0.00m); - entity.Property(e => e.CommissionPct).HasDefaultValue(0.00m); + entity.Property(e => e.CommissionPct).HasDefaultValue(0.00m); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.Property(e => e.SalesLastYear).HasDefaultValue(0.00m); + entity.Property(e => e.SalesLastYear).HasDefaultValue(0.00m); - entity.Property(e => e.SalesYTD).HasDefaultValue(0.00m); + entity.Property(e => e.SalesYTD).HasDefaultValue(0.00m); - entity.HasOne(d => d.BusinessEntity) - .WithOne(p => p.SalesPerson) - .HasForeignKey(d => d.BusinessEntityID); + entity.HasOne(d => d.BusinessEntity) + .WithOne(p => p.SalesPerson) + .HasForeignKey(d => d.BusinessEntityID); - entity.HasOne(d => d.Territory) - .WithMany(p => p.SalesPerson) - .HasForeignKey(d => d.TerritoryID); - }); + entity.HasOne(d => d.Territory) + .WithMany(p => p.SalesPerson) + .HasForeignKey(d => d.TerritoryID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.BusinessEntityID, e.QuotaDate }); + { + entity.HasKey(e => new { e.BusinessEntityID, e.QuotaDate }); - entity.ToTable("SalesPersonQuotaHistory", "Sales"); + entity.ToTable("SalesPersonQuotaHistory", "Sales"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.HasOne(d => d.BusinessEntity) - .WithMany(p => p.SalesPersonQuotaHistory) - .HasForeignKey(d => d.BusinessEntityID); - }); + entity.HasOne(d => d.BusinessEntity) + .WithMany(p => p.SalesPersonQuotaHistory) + .HasForeignKey(d => d.BusinessEntityID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("SalesReason", "Sales"); + { + entity.ToTable("SalesReason", "Sales"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); + entity.Property(e => e.Name).IsRequired(); - entity.Property(e => e.ReasonType).IsRequired(); - }); + entity.Property(e => e.ReasonType).IsRequired(); + }); modelBuilder.Entity( entity => - { - entity.ToTable("SalesTaxRate", "Sales"); + { + entity.ToTable("SalesTaxRate", "Sales"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); + entity.Property(e => e.Name).IsRequired(); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.Property(e => e.TaxRate).HasDefaultValue(0.00m); + entity.Property(e => e.TaxRate).HasDefaultValue(0.00m); - entity.HasOne(d => d.StateProvince) - .WithMany(p => p.SalesTaxRate) - .HasForeignKey(d => d.StateProvinceID); - }); + entity.HasOne(d => d.StateProvince) + .WithMany(p => p.SalesTaxRate) + .HasForeignKey(d => d.StateProvinceID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => e.TerritoryID); + { + entity.HasKey(e => e.TerritoryID); - entity.ToTable("SalesTerritory", "Sales"); + entity.ToTable("SalesTerritory", "Sales"); - entity.Property(e => e.CostLastYear).HasDefaultValue(0.00m); + entity.Property(e => e.CostLastYear).HasDefaultValue(0.00m); - entity.Property(e => e.CostYTD).HasDefaultValue(0.00m); + entity.Property(e => e.CostYTD).HasDefaultValue(0.00m); - entity.Property(e => e.CountryRegionCode).IsRequired(); + entity.Property(e => e.CountryRegionCode).IsRequired(); - entity.Property(e => e.Group).IsRequired(); + entity.Property(e => e.Group).IsRequired(); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); + entity.Property(e => e.Name).IsRequired(); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.Property(e => e.SalesLastYear).HasDefaultValue(0.00m); + entity.Property(e => e.SalesLastYear).HasDefaultValue(0.00m); - entity.Property(e => e.SalesYTD).HasDefaultValue(0.00m); + entity.Property(e => e.SalesYTD).HasDefaultValue(0.00m); - entity.HasOne(d => d.CountryRegionCodeNavigation) - .WithMany(p => p.SalesTerritory) - .HasForeignKey(d => d.CountryRegionCode); - }); + entity.HasOne(d => d.CountryRegionCodeNavigation) + .WithMany(p => p.SalesTerritory) + .HasForeignKey(d => d.CountryRegionCode); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.BusinessEntityID, e.StartDate, e.TerritoryID }); + { + entity.HasKey(e => new { e.BusinessEntityID, e.StartDate, e.TerritoryID }); - entity.ToTable("SalesTerritoryHistory", "Sales"); + entity.ToTable("SalesTerritoryHistory", "Sales"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.HasOne(d => d.BusinessEntity) - .WithMany(p => p.SalesTerritoryHistory) - .HasForeignKey(d => d.BusinessEntityID); + entity.HasOne(d => d.BusinessEntity) + .WithMany(p => p.SalesTerritoryHistory) + .HasForeignKey(d => d.BusinessEntityID); - entity.HasOne(d => d.Territory) - .WithMany(p => p.SalesTerritoryHistory) - .HasForeignKey(d => d.TerritoryID); - }); + entity.HasOne(d => d.Territory) + .WithMany(p => p.SalesTerritoryHistory) + .HasForeignKey(d => d.TerritoryID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("ScrapReason", "Production"); + { + entity.ToTable("ScrapReason", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); - }); + entity.Property(e => e.Name).IsRequired(); + }); modelBuilder.Entity( entity => - { - entity.ToTable("Shift", "HumanResources"); + { + entity.ToTable("Shift", "HumanResources"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); - }); + entity.Property(e => e.Name).IsRequired(); + }); modelBuilder.Entity( entity => - { - entity.ToTable("ShipMethod", "Purchasing"); + { + entity.ToTable("ShipMethod", "Purchasing"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); + entity.Property(e => e.Name).IsRequired(); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.Property(e => e.ShipBase).HasDefaultValue(0.00m); + entity.Property(e => e.ShipBase).HasDefaultValue(0.00m); - entity.Property(e => e.ShipRate).HasDefaultValue(0.00m); - }); + entity.Property(e => e.ShipRate).HasDefaultValue(0.00m); + }); modelBuilder.Entity( entity => - { - entity.ToTable("ShoppingCartItem", "Sales"); + { + entity.ToTable("ShoppingCartItem", "Sales"); - entity.Property(e => e.DateCreated).HasDefaultValueSql("getdate()"); + entity.Property(e => e.DateCreated).HasDefaultValueSql("getdate()"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Quantity).HasDefaultValue(1); + entity.Property(e => e.Quantity).HasDefaultValue(1); - entity.HasOne(d => d.Product) - .WithMany(p => p.ShoppingCartItem) - .HasForeignKey(d => d.ProductID); - }); + entity.HasOne(d => d.Product) + .WithMany(p => p.ShoppingCartItem) + .HasForeignKey(d => d.ProductID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("SpecialOffer", "Sales"); + { + entity.ToTable("SpecialOffer", "Sales"); - entity.Property(e => e.Category).IsRequired(); + entity.Property(e => e.Category).IsRequired(); - entity.Property(e => e.Description).IsRequired(); + entity.Property(e => e.Description).IsRequired(); - entity.Property(e => e.DiscountPct).HasDefaultValue(0.00m); + entity.Property(e => e.DiscountPct).HasDefaultValue(0.00m); - entity.Property(e => e.MinQty).HasDefaultValue(0); + entity.Property(e => e.MinQty).HasDefaultValue(0); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.Property(e => e.Type).IsRequired(); - }); + entity.Property(e => e.Type).IsRequired(); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.SpecialOfferID, e.ProductID }); + { + entity.HasKey(e => new { e.SpecialOfferID, e.ProductID }); - entity.ToTable("SpecialOfferProduct", "Sales"); + entity.ToTable("SpecialOfferProduct", "Sales"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.HasOne(d => d.Product) - .WithMany(p => p.SpecialOfferProduct) - .HasForeignKey(d => d.ProductID); + entity.HasOne(d => d.Product) + .WithMany(p => p.SpecialOfferProduct) + .HasForeignKey(d => d.ProductID); - entity.HasOne(d => d.SpecialOffer) - .WithMany(p => p.SpecialOfferProduct) - .HasForeignKey(d => d.SpecialOfferID); - }); + entity.HasOne(d => d.SpecialOffer) + .WithMany(p => p.SpecialOfferProduct) + .HasForeignKey(d => d.SpecialOfferID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("StateProvince", "Person"); + { + entity.ToTable("StateProvince", "Person"); - entity.Property(e => e.CountryRegionCode).IsRequired(); + entity.Property(e => e.CountryRegionCode).IsRequired(); - entity.Property(e => e.IsOnlyStateProvinceFlag).HasDefaultValue(true); + entity.Property(e => e.IsOnlyStateProvinceFlag).HasDefaultValue(true); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); + entity.Property(e => e.Name).IsRequired(); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.Property(e => e.StateProvinceCode).IsRequired(); + entity.Property(e => e.StateProvinceCode).IsRequired(); - entity.HasOne(d => d.CountryRegionCodeNavigation) - .WithMany(p => p.StateProvince) - .HasForeignKey(d => d.CountryRegionCode); + entity.HasOne(d => d.CountryRegionCodeNavigation) + .WithMany(p => p.StateProvince) + .HasForeignKey(d => d.CountryRegionCode); - entity.HasOne(d => d.Territory) - .WithMany(p => p.StateProvince) - .HasForeignKey(d => d.TerritoryID); - }); + entity.HasOne(d => d.Territory) + .WithMany(p => p.StateProvince) + .HasForeignKey(d => d.TerritoryID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => e.BusinessEntityID); + { + entity.HasKey(e => e.BusinessEntityID); - entity.ToTable("Store", "Sales"); + entity.ToTable("Store", "Sales"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); + entity.Property(e => e.Name).IsRequired(); - entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); + entity.Property(e => e.rowguid).HasDefaultValueSql("newid()"); - entity.HasOne(d => d.BusinessEntity) - .WithOne(p => p.Store) - .HasForeignKey(d => d.BusinessEntityID); + entity.HasOne(d => d.BusinessEntity) + .WithOne(p => p.Store) + .HasForeignKey(d => d.BusinessEntityID); - entity.HasOne(d => d.SalesPerson) - .WithMany(p => p.Store) - .HasForeignKey(d => d.SalesPersonID); - }); + entity.HasOne(d => d.SalesPerson) + .WithMany(p => p.Store) + .HasForeignKey(d => d.SalesPersonID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => e.TransactionID); + { + entity.HasKey(e => e.TransactionID); - entity.ToTable("TransactionHistory", "Production"); + entity.ToTable("TransactionHistory", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.ReferenceOrderLineID).HasDefaultValue(0); + entity.Property(e => e.ReferenceOrderLineID).HasDefaultValue(0); - entity.Property(e => e.TransactionDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.TransactionDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.TransactionType).IsRequired(); + entity.Property(e => e.TransactionType).IsRequired(); - entity.HasOne(d => d.Product) - .WithMany(p => p.TransactionHistory) - .HasForeignKey(d => d.ProductID); - }); + entity.HasOne(d => d.Product) + .WithMany(p => p.TransactionHistory) + .HasForeignKey(d => d.ProductID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => e.TransactionID); + { + entity.HasKey(e => e.TransactionID); - entity.ToTable("TransactionHistoryArchive", "Production"); + entity.ToTable("TransactionHistoryArchive", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.ReferenceOrderLineID).HasDefaultValue(0); + entity.Property(e => e.ReferenceOrderLineID).HasDefaultValue(0); - entity.Property(e => e.TransactionDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.TransactionDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.TransactionType).IsRequired(); - }); + entity.Property(e => e.TransactionType).IsRequired(); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => e.UnitMeasureCode); + { + entity.HasKey(e => e.UnitMeasureCode); - entity.ToTable("UnitMeasure", "Production"); + entity.ToTable("UnitMeasure", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); - }); + entity.Property(e => e.Name).IsRequired(); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => e.BusinessEntityID); + { + entity.HasKey(e => e.BusinessEntityID); - entity.ToTable("Vendor", "Purchasing"); + entity.ToTable("Vendor", "Purchasing"); - entity.Property(e => e.AccountNumber).IsRequired(); + entity.Property(e => e.AccountNumber).IsRequired(); - entity.Property(e => e.ActiveFlag).HasDefaultValue(true); + entity.Property(e => e.ActiveFlag).HasDefaultValue(true); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.Name).IsRequired(); + entity.Property(e => e.Name).IsRequired(); - entity.Property(e => e.PreferredVendorStatus).HasDefaultValue(true); + entity.Property(e => e.PreferredVendorStatus).HasDefaultValue(true); - entity.HasOne(d => d.BusinessEntity) - .WithOne(p => p.Vendor) - .HasForeignKey(d => d.BusinessEntityID); - }); + entity.HasOne(d => d.BusinessEntity) + .WithOne(p => p.Vendor) + .HasForeignKey(d => d.BusinessEntityID); + }); modelBuilder.Entity( entity => - { - entity.ToTable("WorkOrder", "Production"); + { + entity.ToTable("WorkOrder", "Production"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.Property(e => e.StockedQty).ValueGeneratedOnAddOrUpdate(); + entity.Property(e => e.StockedQty).ValueGeneratedOnAddOrUpdate(); - entity.HasOne(d => d.Product) - .WithMany(p => p.WorkOrder) - .HasForeignKey(d => d.ProductID); + entity.HasOne(d => d.Product) + .WithMany(p => p.WorkOrder) + .HasForeignKey(d => d.ProductID); - entity.HasOne(d => d.ScrapReason) - .WithMany(p => p.WorkOrder) - .HasForeignKey(d => d.ScrapReasonID); - }); + entity.HasOne(d => d.ScrapReason) + .WithMany(p => p.WorkOrder) + .HasForeignKey(d => d.ScrapReasonID); + }); modelBuilder.Entity( entity => - { - entity.HasKey(e => new { e.WorkOrderID, e.ProductID, e.OperationSequence }); + { + entity.HasKey(e => new { e.WorkOrderID, e.ProductID, e.OperationSequence }); - entity.ToTable("WorkOrderRouting", "Production"); + entity.ToTable("WorkOrderRouting", "Production"); - entity.Property(e => e.ActualResourceHrs).HasColumnType("decimal(9, 4)"); + entity.Property(e => e.ActualResourceHrs).HasColumnType("decimal(9, 4)"); - entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); + entity.Property(e => e.ModifiedDate).HasDefaultValueSql("getdate()"); - entity.HasOne(d => d.Location) - .WithMany(p => p.WorkOrderRouting) - .HasForeignKey(d => d.LocationID); + entity.HasOne(d => d.Location) + .WithMany(p => p.WorkOrderRouting) + .HasForeignKey(d => d.LocationID); - entity.HasOne(d => d.WorkOrder) - .WithMany(p => p.WorkOrderRouting) - .HasForeignKey(d => d.WorkOrderID); - }); + entity.HasOne(d => d.WorkOrder) + .WithMany(p => p.WorkOrderRouting) + .HasForeignKey(d => d.WorkOrderID); + }); } } } diff --git a/benchmark/EFCore.Benchmarks/Models/Orders/OrdersFixtureBase.cs b/benchmark/EFCore.Benchmarks/Models/Orders/OrdersFixtureBase.cs index 2dfdd76a07b..ed4c51aac6e 100644 --- a/benchmark/EFCore.Benchmarks/Models/Orders/OrdersFixtureBase.cs +++ b/benchmark/EFCore.Benchmarks/Models/Orders/OrdersFixtureBase.cs @@ -18,7 +18,8 @@ public abstract class OrdersFixtureBase : OrdersFixtureSeedBase private int _ordersPerCustomer; private int _linesPerOrder; - public void Initialize(int productCount, int customerCount, int ordersPerCustomer, int linesPerOrder, Action seedAction = null) + public void Initialize( + int productCount, int customerCount, int ordersPerCustomer, int linesPerOrder, Action seedAction = null) { _productCount = productCount; _customerCount = customerCount; diff --git a/benchmark/EFCore.Benchmarks/Query/SimpleQueryTests.cs b/benchmark/EFCore.Benchmarks/Query/SimpleQueryTests.cs index ee10e9e9316..ad3a4d8b807 100644 --- a/benchmark/EFCore.Benchmarks/Query/SimpleQueryTests.cs +++ b/benchmark/EFCore.Benchmarks/Query/SimpleQueryTests.cs @@ -135,11 +135,7 @@ public virtual async Task GroupBy() var query = _context.Products .GroupBy(p => p.ActualStockLevel) .Select( - g => new - { - ActualStockLevel = g.Key, - Products = g - }); + g => new { ActualStockLevel = g.Key, Products = g }); if (Async) { diff --git a/benchmark/EFCore.SqlServer.Benchmarks/Models/AdventureWorks/AdventureWorksSqlServerContext.cs b/benchmark/EFCore.SqlServer.Benchmarks/Models/AdventureWorks/AdventureWorksSqlServerContext.cs index ed6b3f55a86..90c487adc66 100644 --- a/benchmark/EFCore.SqlServer.Benchmarks/Models/AdventureWorks/AdventureWorksSqlServerContext.cs +++ b/benchmark/EFCore.SqlServer.Benchmarks/Models/AdventureWorks/AdventureWorksSqlServerContext.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - namespace Microsoft.EntityFrameworkCore.Benchmarks.Models.AdventureWorks { public class AdventureWorksSqlServerContext : AdventureWorksContextBase diff --git a/benchmark/EFCore.SqlServer.Benchmarks/Models/Orders/OrdersSqlServerContext.cs b/benchmark/EFCore.SqlServer.Benchmarks/Models/Orders/OrdersSqlServerContext.cs index 2698f9ae038..4055f4a039e 100644 --- a/benchmark/EFCore.SqlServer.Benchmarks/Models/Orders/OrdersSqlServerContext.cs +++ b/benchmark/EFCore.SqlServer.Benchmarks/Models/Orders/OrdersSqlServerContext.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - using System; namespace Microsoft.EntityFrameworkCore.Benchmarks.Models.Orders @@ -20,7 +19,11 @@ public OrdersSqlServerContext(string connectionString, IServiceProvider serviceP protected override void ConfigureProvider(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseSqlServer(_connectionString, b => { if (_disableBatching) { b.MaxBatchSize(1); } }); + optionsBuilder.UseSqlServer( + _connectionString, b => + { + if (_disableBatching) { b.MaxBatchSize(1); } + }); } } } diff --git a/benchmark/EFCore.SqlServer.Benchmarks/Support/Program.cs b/benchmark/EFCore.SqlServer.Benchmarks/Support/Program.cs index 6c209d3444c..dfbc9c83601 100644 --- a/benchmark/EFCore.SqlServer.Benchmarks/Support/Program.cs +++ b/benchmark/EFCore.SqlServer.Benchmarks/Support/Program.cs @@ -1,17 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; -using System.Linq; -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Columns; -using BenchmarkDotNet.Configs; -using BenchmarkDotNet.Diagnosers; -using BenchmarkDotNet.Exporters; -using BenchmarkDotNet.Exporters.Csv; -using BenchmarkDotNet.Horology; -using BenchmarkDotNet.Reports; -using BenchmarkDotNet.Running; + // ReSharper disable once CheckNamespace namespace Microsoft.EntityFrameworkCore.Benchmarks diff --git a/benchmark/EFCore.Sqlite.Benchmarks/Models/AdventureWorks/AdventureWorksSqliteContext.cs b/benchmark/EFCore.Sqlite.Benchmarks/Models/AdventureWorks/AdventureWorksSqliteContext.cs index 3b2be9697f5..75bc7e5dc29 100644 --- a/benchmark/EFCore.Sqlite.Benchmarks/Models/AdventureWorks/AdventureWorksSqliteContext.cs +++ b/benchmark/EFCore.Sqlite.Benchmarks/Models/AdventureWorks/AdventureWorksSqliteContext.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - namespace Microsoft.EntityFrameworkCore.Benchmarks.Models.AdventureWorks { public class AdventureWorksSqliteContext : AdventureWorksContextBase diff --git a/benchmark/EFCore.Sqlite.Benchmarks/Models/Orders/OrdersSqliteContext.cs b/benchmark/EFCore.Sqlite.Benchmarks/Models/Orders/OrdersSqliteContext.cs index 558047511f2..82378fb4e81 100644 --- a/benchmark/EFCore.Sqlite.Benchmarks/Models/Orders/OrdersSqliteContext.cs +++ b/benchmark/EFCore.Sqlite.Benchmarks/Models/Orders/OrdersSqliteContext.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - using System; namespace Microsoft.EntityFrameworkCore.Benchmarks.Models.Orders @@ -20,7 +19,11 @@ public OrdersSqliteContext(string connectionString, IServiceProvider serviceProv protected override void ConfigureProvider(DbContextOptionsBuilder optionsBuilder) { - optionsBuilder.UseSqlite(_connectionString, b => { if (_disableBatching) { b.MaxBatchSize(1); } }); + optionsBuilder.UseSqlite( + _connectionString, b => + { + if (_disableBatching) { b.MaxBatchSize(1); } + }); } } } diff --git a/benchmark/EFCore.Sqlite.Benchmarks/Support/Program.cs b/benchmark/EFCore.Sqlite.Benchmarks/Support/Program.cs index 6c209d3444c..dfbc9c83601 100644 --- a/benchmark/EFCore.Sqlite.Benchmarks/Support/Program.cs +++ b/benchmark/EFCore.Sqlite.Benchmarks/Support/Program.cs @@ -1,17 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; -using System.Linq; -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Columns; -using BenchmarkDotNet.Configs; -using BenchmarkDotNet.Diagnosers; -using BenchmarkDotNet.Exporters; -using BenchmarkDotNet.Exporters.Csv; -using BenchmarkDotNet.Horology; -using BenchmarkDotNet.Reports; -using BenchmarkDotNet.Running; + // ReSharper disable once CheckNamespace namespace Microsoft.EntityFrameworkCore.Benchmarks diff --git a/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTest.cs b/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTest.cs index 6945a42826a..f7b4acc1950 100644 --- a/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTest.cs +++ b/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved.// +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Linq; @@ -16,7 +16,8 @@ public class InternalUsageDiagnosticAnalyzerTest : DiagnosticAnalyzerTestBase [ConditionalFact] public async Task No_warning_on_ef_non_internal() - => await AssertNoDiagnostics(@" + => await AssertNoDiagnostics( + @" var a = new Microsoft.EntityFrameworkCore.Infrastructure.Annotatable(); var x = a.GetAnnotations(); "); @@ -26,7 +27,8 @@ public async Task No_warning_on_ef_non_internal() [ConditionalFact] public async Task Warning_on_ef_internal_namespace_invocation() { - var (diagnostics, source) = await GetDiagnosticsAsync(@"var x = typeof(object).GetMethod(nameof(object.ToString), Type.EmptyTypes).DisplayName();"); + var (diagnostics, source) = await GetDiagnosticsAsync( + @"var x = typeof(object).GetMethod(nameof(object.ToString), Type.EmptyTypes).DisplayName();"); var diagnostic = diagnostics.Single(); Assert.Equal(InternalUsageDiagnosticAnalyzer.Id, diagnostic.Id); @@ -69,18 +71,21 @@ class MyClass : Microsoft.EntityFrameworkCore.Storage.Internal.RawRelationalPara Assert.Equal(InternalUsageDiagnosticAnalyzer.Id, diagnostic.Id); Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity); Assert.Equal( - string.Format(InternalUsageDiagnosticAnalyzer.MessageFormat, "Microsoft.EntityFrameworkCore.Storage.Internal.RawRelationalParameter"), + string.Format( + InternalUsageDiagnosticAnalyzer.MessageFormat, "Microsoft.EntityFrameworkCore.Storage.Internal.RawRelationalParameter"), diagnostic.GetMessage()); var span = diagnostic.Location.SourceSpan; - Assert.Equal("Microsoft.EntityFrameworkCore.Storage.Internal.RawRelationalParameter", + Assert.Equal( + "Microsoft.EntityFrameworkCore.Storage.Internal.RawRelationalParameter", source[span.Start..span.End]); } [ConditionalFact] public async Task No_warning_on_ef_internal_namespace_in_same_assembly() { - var diagnostics = await GetDiagnosticsFullSourceAsync(@" + var diagnostics = await GetDiagnosticsFullSourceAsync( + @" namespace My.EntityFrameworkCore.Internal { class MyClass @@ -109,14 +114,17 @@ public void Main(string[] args) { [ConditionalFact] public async Task Warning_on_ef_internal_attribute_property_access() { - var (diagnostics, source) = await GetDiagnosticsAsync(@"var x = Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkRelationalServicesBuilder.RelationalServices.Count;"); + var (diagnostics, source) = await GetDiagnosticsAsync( + @"var x = Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkRelationalServicesBuilder.RelationalServices.Count;"); //throw new Exception("FOO: " + string.Join(", ", diagnostics.Select(d => d.ToString()))); var diagnostic = diagnostics.Single(); Assert.Equal(InternalUsageDiagnosticAnalyzer.Id, diagnostic.Id); Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity); Assert.Equal( - string.Format(InternalUsageDiagnosticAnalyzer.MessageFormat, "Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkRelationalServicesBuilder.RelationalServices"), + string.Format( + InternalUsageDiagnosticAnalyzer.MessageFormat, + "Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkRelationalServicesBuilder.RelationalServices"), diagnostic.GetMessage()); var span = diagnostic.Location.SourceSpan; @@ -126,17 +134,20 @@ public async Task Warning_on_ef_internal_attribute_property_access() [ConditionalFact] public async Task Warning_on_ef_internal_name_instantiation() { - var (diagnostics, source) = await GetDiagnosticsAsync(@"new Microsoft.EntityFrameworkCore.Update.UpdateSqlGeneratorDependencies(null, null);"); + var (diagnostics, source) = + await GetDiagnosticsAsync(@"new Microsoft.EntityFrameworkCore.Update.UpdateSqlGeneratorDependencies(null, null);"); var diagnostic = diagnostics.Single(); Assert.Equal(InternalUsageDiagnosticAnalyzer.Id, diagnostic.Id); Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity); Assert.Equal( - string.Format(InternalUsageDiagnosticAnalyzer.MessageFormat, "Microsoft.EntityFrameworkCore.Update.UpdateSqlGeneratorDependencies"), + string.Format( + InternalUsageDiagnosticAnalyzer.MessageFormat, "Microsoft.EntityFrameworkCore.Update.UpdateSqlGeneratorDependencies"), diagnostic.GetMessage()); var span = diagnostic.Location.SourceSpan; - Assert.Equal("new Microsoft.EntityFrameworkCore.Update.UpdateSqlGeneratorDependencies(null, null)", source[span.Start..span.End]); + Assert.Equal( + "new Microsoft.EntityFrameworkCore.Update.UpdateSqlGeneratorDependencies(null, null)", source[span.Start..span.End]); } #endregion Attribute diff --git a/test/EFCore.Analyzers.Tests/TestUtilities/DiagnosticAnalyzerTestBase.cs b/test/EFCore.Analyzers.Tests/TestUtilities/DiagnosticAnalyzerTestBase.cs index 38c49e44b50..c420ef4d65a 100644 --- a/test/EFCore.Analyzers.Tests/TestUtilities/DiagnosticAnalyzerTestBase.cs +++ b/test/EFCore.Analyzers.Tests/TestUtilities/DiagnosticAnalyzerTestBase.cs @@ -16,10 +16,7 @@ namespace EFCore.Analyzers.Test.TestUtilities { public abstract class DiagnosticAnalyzerTestBase { - private static readonly string[] _usings = new[] { - "System", - "Microsoft.EntityFrameworkCore" - }; + private static readonly string[] _usings = { "System", "Microsoft.EntityFrameworkCore" }; protected abstract DiagnosticAnalyzer CreateDiagnosticAnalyzer(); @@ -39,6 +36,7 @@ protected async Task AssertNoDiagnostics(string source, params string[] extraUsi .Append(@using) .AppendLine(";"); } + sb .AppendLine() .AppendLine("class C {") diff --git a/test/EFCore.Cosmos.FunctionalTests/ConfigPatternsCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/ConfigPatternsCosmosTest.cs index bd45c18b9ac..0b8290bab6d 100644 --- a/test/EFCore.Cosmos.FunctionalTests/ConfigPatternsCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/ConfigPatternsCosmosTest.cs @@ -1,3 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + using System; using System.Threading.Tasks; using Microsoft.Azure.Cosmos; @@ -76,24 +79,25 @@ public async Task Should_not_throw_if_specified_region_is_right() [ConditionalFact] public async Task Should_throw_if_specified_region_is_wrong() { - var exception = await Assert.ThrowsAsync(async () => - { - await using (var testDatabase = CosmosTestStore.CreateInitialized(DatabaseName, o => o.Region("FakeRegion"))) + var exception = await Assert.ThrowsAsync( + async () => { - var options = CreateOptions(testDatabase); + await using (var testDatabase = CosmosTestStore.CreateInitialized(DatabaseName, o => o.Region("FakeRegion"))) + { + var options = CreateOptions(testDatabase); - var customer = new Customer { Id = 42, Name = "Theon" }; + var customer = new Customer { Id = 42, Name = "Theon" }; - using (var context = new CustomerContext(options)) - { - context.Database.EnsureCreated(); + using (var context = new CustomerContext(options)) + { + context.Database.EnsureCreated(); - context.Add(customer); + context.Add(customer); - context.SaveChanges(); + context.SaveChanges(); + } } - } - }); + }); Assert.Equal("Current location is not a valid Azure region.", exception.Message); } @@ -122,24 +126,26 @@ public async Task Should_not_throw_if_specified_connection_mode_is_right() [ConditionalFact] public async Task Should_throw_if_specified_connection_mode_is_wrong() { - var exception = await Assert.ThrowsAsync(async () => - { - await using (var testDatabase = CosmosTestStore.CreateInitialized(DatabaseName, o => o.ConnectionMode((ConnectionMode) 123456))) + var exception = await Assert.ThrowsAsync( + async () => { - var options = CreateOptions(testDatabase); + await using (var testDatabase = CosmosTestStore.CreateInitialized( + DatabaseName, o => o.ConnectionMode((ConnectionMode)123456))) + { + var options = CreateOptions(testDatabase); - var customer = new Customer { Id = 42, Name = "Theon" }; + var customer = new Customer { Id = 42, Name = "Theon" }; - using (var context = new CustomerContext(options)) - { - context.Database.EnsureCreated(); + using (var context = new CustomerContext(options)) + { + context.Database.EnsureCreated(); - context.Add(customer); + context.Add(customer); - context.SaveChanges(); + context.SaveChanges(); + } } - } - }); + }); } private DbContextOptions CreateOptions(CosmosTestStore testDatabase) diff --git a/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs b/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs index fb9cbb3b74b..65b21cc7c4e 100644 --- a/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs @@ -198,14 +198,7 @@ public virtual async Task Can_query_just_nested_collection() Id = 3, Addresses = new[] { - new Address - { - Street = "First", City = "City" - }, - new Address - { - Street = "Second", City = "City" - } + new Address { Street = "First", City = "City" }, new Address { Street = "Second", City = "City" } } }); @@ -229,12 +222,7 @@ public virtual async Task Inserting_dependent_without_principal_throws() using (var context = CreateContext()) { context.Add( - new LicensedOperator - { - Name = "Jack Jackson", - LicenseType = "Class A CDC", - VehicleName = "Fuel transport" - }); + new LicensedOperator { Name = "Jack Jackson", LicenseType = "Class A CDC", VehicleName = "Fuel transport" }); Assert.Equal( CosmosStrings.OrphanedNestedDocumentSensitive( @@ -253,17 +241,11 @@ public virtual async Task Can_change_nested_instance_non_derived() { var bike = context.Vehicles.Single(v => v.Name == "Trek Pro Fit Madone 6 Series"); - bike.Operator = new Operator - { - Name = "Chris Horner" - }; + bike.Operator = new Operator { Name = "Chris Horner" }; context.ChangeTracker.DetectChanges(); - bike.Operator = new LicensedOperator - { - Name = "repairman" - }; + bike.Operator = new LicensedOperator { Name = "repairman" }; TestSqlLoggerFactory.Clear(); context.SaveChanges(); @@ -286,12 +268,7 @@ public virtual async Task Can_change_principal_instance_non_derived() { var bike = context.Vehicles.Single(v => v.Name == "Trek Pro Fit Madone 6 Series"); - var newBike = new Vehicle - { - Name = "Trek Pro Fit Madone 6 Series", - Operator = bike.Operator, - SeatingCapacity = 2 - }; + var newBike = new Vehicle { Name = "Trek Pro Fit Madone 6 Series", Operator = bike.Operator, SeatingCapacity = 2 }; var oldEntry = context.Remove(bike); var newEntry = context.Add(newBike); @@ -355,7 +332,8 @@ protected virtual EmbeddedTransportationContext CreateContext() protected class EmbeddedTransportationContext : TransportationContext { - public EmbeddedTransportationContext(DbContextOptions options) : base(options) + public EmbeddedTransportationContext(DbContextOptions options) + : base(options) { } @@ -394,10 +372,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Ignore(); modelBuilder.Entity( - eb => eb.OwnsMany(v => v.Addresses, b => - { - b.ToJsonProperty("Stored Addresses"); - })); + eb => eb.OwnsMany( + v => v.Addresses, b => + { + b.ToJsonProperty("Stored Addresses"); + })); } } diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs index 95a611d94ee..a2cd3d6aabd 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs @@ -157,7 +157,8 @@ public override void Navigation_rewrite_on_owned_reference_followed_by_regular_e } [ConditionalFact(Skip = "LeftJoin #12086")] - public override void Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference_in_predicate_and_projection() + public override void + Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference_in_predicate_and_projection() { base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference_in_predicate_and_projection(); } @@ -241,55 +242,23 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb => { eb.HasData( - new - { - Id = 1, - id = Guid.NewGuid().ToString() - }); + new { Id = 1, id = Guid.NewGuid().ToString() }); eb.OwnsOne( p => p.PersonAddress, ab => { ab.HasData( - new - { - OwnedPersonId = 1 - }, new - { - OwnedPersonId = 2 - }, new - { - OwnedPersonId = 3 - }, new - { - OwnedPersonId = 4 - }); + new { OwnedPersonId = 1 }, new { OwnedPersonId = 2 }, new { OwnedPersonId = 3 }, + new { OwnedPersonId = 4 }); ab.OwnsOne( a => a.Country, cb => { cb.HasData( - new - { - OwnedAddressOwnedPersonId = 1, - PlanetId = 1, - Name = "USA" - }, new - { - OwnedAddressOwnedPersonId = 2, - PlanetId = 1, - Name = "USA" - }, new - { - OwnedAddressOwnedPersonId = 3, - PlanetId = 1, - Name = "USA" - }, new - { - OwnedAddressOwnedPersonId = 4, - PlanetId = 1, - Name = "USA" - }); + new { OwnedAddressOwnedPersonId = 1, PlanetId = 1, Name = "USA" }, + new { OwnedAddressOwnedPersonId = 2, PlanetId = 1, Name = "USA" }, + new { OwnedAddressOwnedPersonId = 3, PlanetId = 1, Name = "USA" }, + new { OwnedAddressOwnedPersonId = 4, PlanetId = 1, Name = "USA" }); cb.HasOne(cc => cc.Planet).WithMany().HasForeignKey(ee => ee.PlanetId) .OnDelete(DeleteBehavior.Restrict); @@ -301,31 +270,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con { ob.HasKey(o => o.Id); ob.HasData( - new - { - Id = -10, - ClientId = 1 - }, - new - { - Id = -11, - ClientId = 1 - }, - new - { - Id = -20, - ClientId = 2 - }, - new - { - Id = -30, - ClientId = 3 - }, - new - { - Id = -40, - ClientId = 4 - } + new { Id = -10, ClientId = 1 }, + new { Id = -11, ClientId = 1 }, + new { Id = -20, ClientId = 2 }, + new { Id = -30, ClientId = 3 }, + new { Id = -40, ClientId = 4 } ); }); }); @@ -334,39 +283,20 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb => { eb.HasData( - new - { - Id = 2, - id = Guid.NewGuid().ToString() - }); + new { Id = 2, id = Guid.NewGuid().ToString() }); eb.OwnsOne( p => p.BranchAddress, ab => { ab.HasData( - new - { - BranchId = 2 - }, new - { - BranchId = 3 - }); + new { BranchId = 2 }, new { BranchId = 3 }); ab.OwnsOne( a => a.Country, cb => { cb.HasData( - new - { - OwnedAddressBranchId = 2, - PlanetId = 1, - Name = "Canada" - }, new - { - OwnedAddressBranchId = 3, - PlanetId = 1, - Name = "Canada" - }); + new { OwnedAddressBranchId = 2, PlanetId = 1, Name = "Canada" }, + new { OwnedAddressBranchId = 3, PlanetId = 1, Name = "Canada" }); }); }); }); @@ -375,31 +305,19 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb => { eb.HasData( - new - { - Id = 3, - id = Guid.NewGuid().ToString() - }); + new { Id = 3, id = Guid.NewGuid().ToString() }); eb.OwnsOne( p => p.LeafAAddress, ab => { ab.HasData( - new - { - LeafAId = 3 - }); + new { LeafAId = 3 }); ab.OwnsOne( a => a.Country, cb => { cb.HasData( - new - { - OwnedAddressLeafAId = 3, - PlanetId = 1, - Name = "Mexico" - }); + new { OwnedAddressLeafAId = 3, PlanetId = 1, Name = "Mexico" }); }); }); }); @@ -408,31 +326,19 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb => { eb.HasData( - new - { - Id = 4, - id = Guid.NewGuid().ToString() - }); + new { Id = 4, id = Guid.NewGuid().ToString() }); eb.OwnsOne( p => p.LeafBAddress, ab => { ab.HasData( - new - { - LeafBId = 4 - }); + new { LeafBId = 4 }); ab.OwnsOne( a => a.Country, cb => { cb.HasData( - new - { - OwnedAddressLeafBId = 4, - PlanetId = 1, - Name = "Panama" - }); + new { OwnedAddressLeafBId = 4, PlanetId = 1, Name = "Panama" }); }); }); }); @@ -441,37 +347,21 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con pb => { pb.HasData( - new - { - Id = 1, - id = Guid.NewGuid().ToString(), - StarId = 1 - }); + new { Id = 1, id = Guid.NewGuid().ToString(), StarId = 1 }); }); modelBuilder.Entity( mb => { mb.HasData( - new - { - Id = 1, - id = Guid.NewGuid().ToString(), - PlanetId = 1, - Diameter = 3474 - }); + new { Id = 1, id = Guid.NewGuid().ToString(), PlanetId = 1, Diameter = 3474 }); }); modelBuilder.Entity( sb => { sb.HasData( - new - { - Id = 1, - id = Guid.NewGuid().ToString(), - Name = "Sol" - }); + new { Id = 1, id = Guid.NewGuid().ToString(), Name = "Sol" }); sb.OwnsMany( s => s.Composition, ob => @@ -488,25 +378,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con { b.OwnsOne( e => e.Throned, b => b.HasData( - new - { - BartonId = 1, - Property = "Property" - })); + new { BartonId = 1, Property = "Property" })); b.HasData( - new Barton - { - Id = 1, Simple = "Simple" - }); - + new Barton { Id = 1, Simple = "Simple" }); }); modelBuilder.Entity().HasData( - new - { - Id = 1, - BartonId = 1 - }); + new { Id = 1, BartonId = 1 }); } } } diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.JoinGroupJoin.cs b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.JoinGroupJoin.cs index 64f486ce1a1..43e3b87763a 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.JoinGroupJoin.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.JoinGroupJoin.cs @@ -41,12 +41,7 @@ await AssertQuery( from c in cs.Where(c => c.CustomerID == "ALFKI") join o in os on c.CustomerID equals o.CustomerID from e in es - select new - { - c, - o, - e - }, + select new { c, o, e }, e => e.c.CustomerID + " " + e.o.OrderID + " " + e.e.EmployeeID, entryCount: 16); @@ -606,12 +601,7 @@ from c in cs.Where(c => c.CustomerID == "ALFKI") from o0 in os.OrderBy(o => o.OrderID).Take(1) join o1 in os on c.CustomerID equals o1.CustomerID into orders from o2 in orders - select new - { - A = c.CustomerID, - B = o0.CustomerID, - C = o2.CustomerID - }, + select new { A = c.CustomerID, B = o0.CustomerID, C = o2.CustomerID }, e => e.A + " " + e.B + " " + e.C); AssertSql( diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.KeylessEntities.cs b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.KeylessEntities.cs index 40bdab7cff5..a4b4acc1ce9 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.KeylessEntities.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.KeylessEntities.cs @@ -59,11 +59,7 @@ await AssertQuery( (cs, ovs) => from c in cs.Where(ct => ct.City == "London") from o in ovs.Where(ov => ov.CustomerID == c.CustomerID) - select new - { - c, - o - }, + select new { c, o }, e => e.c.CustomerID); AssertSql( diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.ResultOperators.cs b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.ResultOperators.cs index 6e95fd69464..b46693aa792 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.ResultOperators.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.ResultOperators.cs @@ -167,11 +167,7 @@ public override async Task Sum_on_float_column_in_subquery(bool isAsync) await AssertQuery( isAsync, os => os.Where(o => o.OrderID < 10250).Select( - o => new - { - o.OrderID, - Sum = o.OrderDetails.Sum(od => od.Discount) - }), + o => new { o.OrderID, Sum = o.OrderDetails.Sum(od => od.Discount) }), e => e.OrderID); AssertSql( @@ -186,7 +182,6 @@ public override void Average_no_data() base.Average_no_data(); } - [ConditionalFact(Skip = "Issue#16146")] public override void Average_no_data_nullable() { @@ -375,11 +370,7 @@ public override async Task Average_on_float_column_in_subquery(bool isAsync) await AssertQuery( isAsync, os => os.Where(o => o.OrderID < 10250).Select( - o => new - { - o.OrderID, - Sum = o.OrderDetails.Average(od => od.Discount) - }), + o => new { o.OrderID, Sum = o.OrderDetails.Average(od => od.Discount) }), e => e.OrderID); AssertSql( @@ -395,11 +386,7 @@ await AssertQuery( isAsync, os => os.Where(o => o.OrderID < 10250) .Select( - o => new - { - o.OrderID, - Sum = o.OrderDetails.Average(od => (float?)od.Discount) - }), + o => new { o.OrderID, Sum = o.OrderDetails.Average(od => (float?)od.Discount) }), e => e.OrderID); AssertSql( @@ -430,7 +417,6 @@ FROM root c WHERE (c[""Discriminator""] = ""Order"")"); } - [ConditionalFact(Skip = "Issue#16146")] public override void Min_no_data_nullable() { diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Select.cs b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Select.cs index 5a4057684c1..3cc0b3e036f 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Select.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Select.cs @@ -170,7 +170,7 @@ public override async Task Select_anonymous_constant_in_expression(bool isAsync) await base.Select_anonymous_constant_in_expression(isAsync); AssertSql( - @"SELECT c[""CustomerID""] + @"SELECT c[""CustomerID""] FROM root c WHERE (c[""Discriminator""] = ""Customer"")"); } @@ -501,10 +501,12 @@ FROM root c } [ConditionalTheory(Skip = "Issue #17246")] - public override async Task Project_single_element_from_collection_with_OrderBy_Distinct_and_FirstOrDefault_followed_by_projecting_length( - bool isAsync) + public override async Task + Project_single_element_from_collection_with_OrderBy_Distinct_and_FirstOrDefault_followed_by_projecting_length( + bool isAsync) { - await base.Project_single_element_from_collection_with_OrderBy_Distinct_and_FirstOrDefault_followed_by_projecting_length(isAsync); + await base.Project_single_element_from_collection_with_OrderBy_Distinct_and_FirstOrDefault_followed_by_projecting_length( + isAsync); AssertSql(""); } diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.SetOperations.cs b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.SetOperations.cs index 1162737d6da..0d3e13a3790 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.SetOperations.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.SetOperations.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; -using Xunit; namespace Microsoft.EntityFrameworkCore.Query { @@ -21,7 +20,7 @@ public partial class SimpleQueryCosmosTest public override Task Intersect_non_entity(bool isAsync) => Task.CompletedTask; public override Task Union(bool isAsync) => Task.CompletedTask; public override Task Union_nested(bool isAsync) => Task.CompletedTask; - public override void Union_non_entity(bool isAsync) {} + public override void Union_non_entity(bool isAsync) { } public override Task Union_OrderBy_Skip_Take(bool isAsync) => Task.CompletedTask; public override Task Union_Where(bool isAsync) => Task.CompletedTask; public override Task Union_Skip_Take_OrderBy_ThenBy_Where(bool isAsync) => Task.CompletedTask; @@ -36,8 +35,8 @@ public override void Union_non_entity(bool isAsync) {} public override Task Union_Include(bool isAsync) => Task.CompletedTask; public override Task Include_Union(bool isAsync) => Task.CompletedTask; public override Task Select_Except_reference_projection(bool isAsync) => Task.CompletedTask; - public override void Include_Union_only_on_one_side_throws() {} - public override void Include_Union_different_includes_throws() {} + public override void Include_Union_only_on_one_side_throws() { } + public override void Include_Union_different_includes_throws() { } public override Task SubSelect_Union(bool isAsync) => Task.CompletedTask; public override Task Client_eval_Union_FirstOrDefault(bool isAsync) => Task.CompletedTask; public override Task GroupBy_Select_Union(bool isAsync) => Task.CompletedTask; diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Where.cs b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Where.cs index 5c203509d71..6cf52bc5f09 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Where.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.Where.cs @@ -254,8 +254,7 @@ public virtual async Task Where_lessthan(bool isAsync) { await AssertQuery( isAsync, - es => es.Where(e => e.ReportsTo < 2), - entryCount: 0); + es => es.Where(e => e.ReportsTo < 2)); AssertSql( @"SELECT c @@ -1844,10 +1843,7 @@ public override async Task Where_subquery_FirstOrDefault_compared_to_entity(bool await AssertQuery( isAsync, cs => cs.Where(c => c.CustomerID == "ALFKI").Where( - c => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault() == new Order - { - OrderID = 10243 - })); + c => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault() == new Order { OrderID = 10243 })); AssertSql( @"SELECT c diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.cs index 595e27f8d4e..ea02b2c90a7 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/SimpleQueryCosmosTest.cs @@ -539,26 +539,14 @@ await AssertQuery( from c in cs.Where(c => c.CustomerID == "VINET") from o in os.OrderBy(o => o.OrderID).Take(3) where c.CustomerID == o.CustomerID - select new - { - c.ContactName, - o.OrderID - }, + select new { c.ContactName, o.OrderID }, (cs, os) => cs.Where(c => c.CustomerID == "VINET") .SelectMany( _ => os.OrderBy(o => o.OrderID).Take(3), - (c, o) => new - { - c, - o - }).Where(t => t.c.CustomerID == t.o.CustomerID) + (c, o) => new { c, o }).Where(t => t.c.CustomerID == t.o.CustomerID) .Select( - t => new - { - t.c.ContactName, - t.o.OrderID - }), + t => new { t.c.ContactName, t.o.OrderID }), assertOrder: true); AssertSql( @@ -1173,12 +1161,7 @@ await AssertQuery( from e1 in es.Where(ct => ct.City == "London") from c in cs.Where(ct => ct.City == "London") from e2 in es.Where(ct => ct.City == "London") - select new - { - e1, - c, - e2.FirstName - }, + select new { e1, c, e2.FirstName }, e => e.e1.EmployeeID + " " + e.c.CustomerID + " " + e.FirstName, entryCount: 10); @@ -1198,13 +1181,7 @@ from e1 in es.Where(e => e.EmployeeID == 1) from e2 in es from e3 in es from e4 in es - select new - { - e2, - e3, - e1, - e4 - }, + select new { e2, e3, e1, e4 }, e => e.e2.EmployeeID + " " + e.e3.EmployeeID + " " + e.e1.EmployeeID + e.e4.EmployeeID, entryCount: 9); @@ -1245,11 +1222,7 @@ await AssertQuery( from c in cs.Where(ct => ct.City == "London") from o in os where c.CustomerID == o.CustomerID - select new - { - c.ContactName, - o.OrderID - }, + select new { c.ContactName, o.OrderID }, e => e.OrderID); AssertSql( @@ -1463,11 +1436,7 @@ await AssertQuery( (cs, os) => from c in cs.Where(cst => cst.CustomerID == "ALFKI") from o in os.Where(o => o.CustomerID == c.CustomerID).DefaultIfEmpty() - select new - { - c.ContactName, - o - }, + select new { c.ContactName, o }, e => e.ContactName + " " + e.o?.OrderID, entryCount: 6); @@ -1503,11 +1472,7 @@ await AssertQuery( (cs, os) => from c in cs.Where(cst => cst.CustomerID == "ALFKI") from o in os.Where(o => o.CustomerID == c.CustomerID) - select new - { - c.ContactName, - o.OrderDate - }, + select new { c.ContactName, o.OrderDate }, e => e.ContactName + " " + e.OrderDate); AssertSql( @@ -1524,11 +1489,7 @@ await AssertQuery( (cs, os) => from c in cs.Where(cst => cst.CustomerID == "ALFKI") from o in os.Where(o => o.CustomerID == c.CustomerID).Take(1000) - select new - { - c.ContactName, - o - }, + select new { c.ContactName, o }, e => e.o.OrderID, entryCount: 6); @@ -1558,11 +1519,7 @@ await AssertSingle( (from c in cs.Where(cu => cu.CustomerID == "ALFKI") from o in os.Where(or => or.OrderID < 10300) orderby c.CustomerID, o.OrderID - select new - { - c, - o - }) + select new { c, o }) .Take(1) .Cast(), entryCount: 2); @@ -2655,11 +2612,7 @@ await AssertQuery( (from c in cs.Where(c => c.City == "London") from o in os.Where(o => o.CustomerID == c.CustomerID).DefaultIfEmpty() where o != null - select new - { - c.CustomerID, - o.OrderID - }), + select new { c.CustomerID, o.OrderID }), e => e.CustomerID + " " + e.OrderID); AssertSql( @@ -2685,12 +2638,7 @@ from o1 in os.Where(o => o.OrderID > 11000).DefaultIfEmpty() from o2 in os.Where(o => o.OrderID < 10250).Where(o => o.CustomerID == c.CustomerID).DefaultIfEmpty() where o1 != null && o2 != null orderby o1.OrderID, o2.OrderDate - select new - { - c.CustomerID, - o1.OrderID, - o2.OrderDate - }), + select new { c.CustomerID, o1.OrderID, o2.OrderDate }), e => e.CustomerID + " " + e.OrderID); AssertSql( @@ -2997,10 +2945,7 @@ public override async Task Anonymous_subquery_orderby(bool isAsync) await AssertQuery( isAsync, cs => cs.Where(c => c.City == "London").Where(c => c.Orders.Count > 1).Select( - c => new - { - A = c.Orders.OrderByDescending(o => o.OrderID).FirstOrDefault().OrderDate - }).OrderBy(n => n.A), + c => new { A = c.Orders.OrderByDescending(o => o.OrderID).FirstOrDefault().OrderDate }).OrderBy(n => n.A), assertOrder: true); AssertSql( @@ -3092,10 +3037,8 @@ public override async Task DTO_subquery_orderby(bool isAsync) await AssertQuery( isAsync, cs => cs.Where(c => c.CustomerID == "ALFKI").Where(c => c.Orders.Count > 1).Select( - c => new DTO - { - Property = c.Orders.OrderByDescending(o => o.OrderID).FirstOrDefault().OrderDate - }).OrderBy(n => n.Property), + c => new DTO { Property = c.Orders.OrderByDescending(o => o.OrderID).FirstOrDefault().OrderDate }) + .OrderBy(n => n.Property), assertOrder: true, elementAsserter: (e, a) => Assert.Equal(e.Property, a.Property)); @@ -3137,8 +3080,7 @@ from c in cs.Where(c => c.CustomerID == "ALFKI") .Select(o => o.CustomerID) .FirstOrDefault() where lastOrder == null - select c, - entryCount: 0); + select c); AssertSql( @"SELECT c @@ -3470,11 +3412,7 @@ where o1.CustomerID.StartsWith("A") from o2 in os2 where o1.Customer.Equals(o2.Customer) orderby o1.OrderID, o2.OrderID - select new - { - Id1 = o1.OrderID, - Id2 = o2.OrderID - }, + select new { Id1 = o1.OrderID, Id2 = o2.OrderID }, e => e.Id1 + " " + e.Id2); AssertSql( @@ -3494,11 +3432,7 @@ where o1.CustomerID.StartsWith("A") from o2 in os2 where Equals(o1.Customer, o2.Customer) orderby o1.OrderID, o2.OrderID - select new - { - Id1 = o1.OrderID, - Id2 = o2.OrderID - }, + select new { Id1 = o1.OrderID, Id2 = o2.OrderID }, e => e.Id1 + " " + e.Id2); AssertSql( @@ -3517,11 +3451,7 @@ from c in cs where c.CustomerID == "ALFKI" from o in os where Equals(c, o) - select new - { - Id1 = c.CustomerID, - Id2 = o.OrderID - }, + select new { Id1 = c.CustomerID, Id2 = o.OrderID }, e => e.Id1 + " " + e.Id2); AssertSql( @@ -3540,11 +3470,7 @@ from c in cs where c.CustomerID == "ALFKI" from o in os where c.Orders.Equals(o.OrderDetails) - select new - { - Id1 = c.CustomerID, - Id2 = o.OrderID - }, + select new { Id1 = c.CustomerID, Id2 = o.OrderID }, e => e.Id1 + " " + e.Id2); AssertSql( @@ -3661,8 +3587,7 @@ await AssertQuery( .Select( c => new { - c.CustomerID, - OuterOrders = c.Orders.Where(o => o.OrderID < 10250).Count(o => c.Orders.Count() > 0) + c.CustomerID, OuterOrders = c.Orders.Where(o => o.OrderID < 10250).Count(o => c.Orders.Count() > 0) })); AssertSql( @@ -3705,20 +3630,13 @@ public override void Streaming_chained_sync_query() var results = (context.Customers.Where(c => c.CustomerID == "ALFKI") .Select( - c => new - { - c.CustomerID, - Orders = context.Orders.Where(o => o.Customer.CustomerID == c.CustomerID) - }).ToList()) + c => new { c.CustomerID, Orders = context.Orders.Where(o => o.Customer.CustomerID == c.CustomerID) }).ToList()) .Select( x => new { Orders = x.Orders .GroupJoin( - new[] { "ALFKI" }, y => x.CustomerID, y => y, (h, id) => new - { - h.Customer - }) + new[] { "ALFKI" }, y => x.CustomerID, y => y, (h, id) => new { h.Customer }) }) .ToList(); @@ -3784,10 +3702,7 @@ from od in o.OrderDetails where od.Quantity < 10 select od.Quantity where details.Any() - select new - { - Count = details.Count() - }); + select new { Count = details.Count() }); AssertSql( @"SELECT c diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosDbConfiguredConditionAttribute.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosDbConfiguredConditionAttribute.cs index b97e4d8beeb..dd7a70ce22a 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosDbConfiguredConditionAttribute.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosDbConfiguredConditionAttribute.cs @@ -69,7 +69,9 @@ private static bool IsNotConfigured(Exception firstException) case HttpRequestException re: return true; default: - return firstException.Message.StartsWith("The input authorization token can't serve the request. Please check that the expected payload is built as per the protocol, and check the key being used.", StringComparison.Ordinal); + return firstException.Message.StartsWith( + "The input authorization token can't serve the request. Please check that the expected payload is built as per the protocol, and check the key being used.", + StringComparison.Ordinal); } } } diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs index 18c55f5963c..853829c9f37 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs @@ -24,7 +24,7 @@ public static CosmosTestStore Create(string name, Action new CosmosTestStore(name, shared: false, extensionConfiguration: extensionConfiguration); public static CosmosTestStore CreateInitialized(string name, Action extensionConfiguration = null) - => (CosmosTestStore)Create(name, extensionConfiguration).Initialize(null, (Func)null, null, null); + => (CosmosTestStore)Create(name, extensionConfiguration).Initialize(null, (Func)null); public static CosmosTestStore GetOrCreate(string name) => new CosmosTestStore(name); @@ -32,7 +32,8 @@ public static CosmosTestStore GetOrCreate(string name, string dataFilePath) => new CosmosTestStore(name, dataFilePath: dataFilePath); private CosmosTestStore( - string name, bool shared = true, string dataFilePath = null, Action extensionConfiguration = null) + string name, bool shared = true, string dataFilePath = null, + Action extensionConfiguration = null) : base(CreateName(name), shared) { ConnectionUri = TestEnvironment.DefaultConnection; @@ -49,7 +50,7 @@ private CosmosTestStore( } } - private static string CreateName(string name) => name == "Northwind" ? name : (name + _runId.ToString()); + private static string CreateName(string name) => name == "Northwind" ? name : (name + _runId); public string ConnectionUri { get; } public string AuthToken { get; } @@ -126,6 +127,7 @@ private async Task CreateFromFile(DbContext context) goto NextEntityType; } } + break; } } diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs index b3d99a3eb0f..ae43f0f91e8 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs @@ -59,8 +59,8 @@ public void AssertBaseline(string[] expected, bool assertOrder = true) catch { var methodCallLine = Environment.StackTrace.Split( - new[] { _eol }, - StringSplitOptions.RemoveEmptyEntries)[3].Substring(6); + new[] { _eol }, + StringSplitOptions.RemoveEmptyEntries)[3].Substring(6); var testName = methodCallLine.Substring(0, methodCallLine.IndexOf(')') + 1); var lineIndex = methodCallLine.LastIndexOf("line", StringComparison.Ordinal); diff --git a/test/EFCore.Cosmos.Tests/ApiConsistencyTest.cs b/test/EFCore.Cosmos.Tests/ApiConsistencyTest.cs index 5423150258a..08d507fb6b8 100644 --- a/test/EFCore.Cosmos.Tests/ApiConsistencyTest.cs +++ b/test/EFCore.Cosmos.Tests/ApiConsistencyTest.cs @@ -4,8 +4,8 @@ using System; using System.Collections.Generic; using System.Reflection; -using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal; +using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Cosmos @@ -14,9 +14,7 @@ public class ApiConsistencyTest : ApiConsistencyTestBase { private static readonly Type[] _fluentApiTypes = { - typeof(CosmosServiceCollectionExtensions), - typeof(CosmosDbContextOptionsExtensions), - typeof(CosmosDbContextOptionsBuilder) + typeof(CosmosServiceCollectionExtensions), typeof(CosmosDbContextOptionsExtensions), typeof(CosmosDbContextOptionsBuilder) }; protected override IEnumerable FluentApiTypes => _fluentApiTypes; diff --git a/test/EFCore.Cosmos.Tests/Extensions/CosmosDbContextOptionsExtensionsTests.cs b/test/EFCore.Cosmos.Tests/Extensions/CosmosDbContextOptionsExtensionsTests.cs index 88e3835ab96..b180a86936b 100644 --- a/test/EFCore.Cosmos.Tests/Extensions/CosmosDbContextOptionsExtensionsTests.cs +++ b/test/EFCore.Cosmos.Tests/Extensions/CosmosDbContextOptionsExtensionsTests.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; using Microsoft.Azure.Cosmos; using Microsoft.EntityFrameworkCore.Cosmos.Infrastructure.Internal; using Xunit; @@ -59,13 +62,14 @@ public void Can_create_options_with_correct_connection_mode() [ConditionalFact] public void Throws_if_wrong_connection_mode() { - var connectionMode = (ConnectionMode) 958410610; - var options = Assert.Throws(() => - new DbContextOptionsBuilder().UseCosmos( - "serviceEndPoint", - "authKeyOrResourceToken", - "databaseName", - o => { o.ConnectionMode(connectionMode); })); + var connectionMode = (ConnectionMode)958410610; + var options = Assert.Throws( + () => + new DbContextOptionsBuilder().UseCosmos( + "serviceEndPoint", + "authKeyOrResourceToken", + "databaseName", + o => { o.ConnectionMode(connectionMode); })); } } } diff --git a/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs b/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs index 31008ed106b..4e4a4b17bde 100644 --- a/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs +++ b/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs @@ -74,8 +74,10 @@ public virtual void Detects_partition_keys_mapped_to_different_properties() modelBuilder.Entity().ToContainer("Orders").HasPartitionKey(c => c.PartitionId); var model = modelBuilder.Model; - VerifyError(CosmosStrings.PartitionKeyStoreNameMismatch( - nameof(Customer.PartitionId), typeof(Customer).Name, "pk", nameof(Order.PartitionId), typeof(Order).Name, nameof(Order.PartitionId)), model); + VerifyError( + CosmosStrings.PartitionKeyStoreNameMismatch( + nameof(Customer.PartitionId), typeof(Customer).Name, "pk", nameof(Order.PartitionId), typeof(Order).Name, + nameof(Order.PartitionId)), model); } [ConditionalFact] @@ -87,8 +89,9 @@ public virtual void Detects_partition_key_of_different_type() .Property(c => c.PartitionId).HasConversion(); var model = modelBuilder.Model; - VerifyError(CosmosStrings.PartitionKeyNonStringStoreType( - nameof(Customer.PartitionId), typeof(Order).Name, "int"), model); + VerifyError( + CosmosStrings.PartitionKeyNonStringStoreType( + nameof(Customer.PartitionId), typeof(Order).Name, "int"), model); } [ConditionalFact] diff --git a/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs b/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs index 16d1180c492..4b36f990696 100644 --- a/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs +++ b/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs @@ -39,12 +39,14 @@ public void Can_get_and_set_partition_key_name() ((IConventionEntityType)entityType).Builder.HasPartitionKey("pk"); Assert.Equal("pk", entityType.GetCosmosPartitionKeyPropertyName()); - Assert.Equal(ConfigurationSource.Convention, + Assert.Equal( + ConfigurationSource.Convention, ((IConventionEntityType)entityType).GetCosmosPartitionKeyPropertyNameConfigurationSource()); entityTypeBuilder.HasPartitionKey("pk"); Assert.Equal("pk", entityType.GetCosmosPartitionKeyPropertyName()); - Assert.Equal(ConfigurationSource.Explicit, + Assert.Equal( + ConfigurationSource.Explicit, ((IConventionEntityType)entityType).GetCosmosPartitionKeyPropertyNameConfigurationSource()); Assert.False(((IConventionEntityType)entityType).Builder.CanSetPartitionKey("partition")); diff --git a/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.cs b/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.cs index 888f9f3ac3c..3d04d7ecdbd 100644 --- a/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.cs +++ b/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.cs @@ -48,11 +48,13 @@ public void Can_get_and_set_partition_key_name() ((IConventionEntityType)entityType).SetCosmosPartitionKeyPropertyName("pk"); Assert.Equal("pk", entityType.GetCosmosPartitionKeyPropertyName()); - Assert.Equal(ConfigurationSource.Convention, ((IConventionEntityType)entityType).GetCosmosPartitionKeyPropertyNameConfigurationSource()); + Assert.Equal( + ConfigurationSource.Convention, ((IConventionEntityType)entityType).GetCosmosPartitionKeyPropertyNameConfigurationSource()); entityType.SetCosmosPartitionKeyPropertyName("pk"); Assert.Equal("pk", entityType.GetCosmosPartitionKeyPropertyName()); - Assert.Equal(ConfigurationSource.Explicit, ((IConventionEntityType)entityType).GetCosmosPartitionKeyPropertyNameConfigurationSource()); + Assert.Equal( + ConfigurationSource.Explicit, ((IConventionEntityType)entityType).GetCosmosPartitionKeyPropertyNameConfigurationSource()); entityType.SetCosmosPartitionKeyPropertyName(null); Assert.Null(entityType.GetCosmosPartitionKeyPropertyName()); diff --git a/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs b/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs index ab1439a056d..257458a0299 100644 --- a/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs +++ b/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs @@ -25,15 +25,15 @@ public void Generated_ids_do_not_clash() var ids = new HashSet { (string)CosmosTestHelpers.Instance.CreateInternalEntry(model, EntityState.Added, new Blog { Id = 1, OtherId = 1 }) - [blogIdProperty], + [blogIdProperty], (string)CosmosTestHelpers.Instance.CreateInternalEntry(model, EntityState.Added, new Blog { Id = 1, OtherId = 1 }) - [blogIdProperty], + [blogIdProperty], (string)CosmosTestHelpers.Instance.CreateInternalEntry(model, EntityState.Added, new Post { Id = "1", OtherId = "1" }) - [postIdProperty], + [postIdProperty], (string)CosmosTestHelpers.Instance.CreateInternalEntry(model, EntityState.Added, new Post { Id = "1", OtherId = "1|" }) - [postIdProperty], + [postIdProperty], (string)CosmosTestHelpers.Instance.CreateInternalEntry(model, EntityState.Added, new Post { Id = "|1", OtherId = "1" }) - [postIdProperty] + [postIdProperty] }; Assert.Equal(4, ids.Count); diff --git a/test/EFCore.CrossStore.FunctionalTests/ConfigurationPatternsTest.cs b/test/EFCore.CrossStore.FunctionalTests/ConfigurationPatternsTest.cs index 71294832060..a68bce12a81 100644 --- a/test/EFCore.CrossStore.FunctionalTests/ConfigurationPatternsTest.cs +++ b/test/EFCore.CrossStore.FunctionalTests/ConfigurationPatternsTest.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -267,11 +266,7 @@ private async Task NestedContextTest(Func createBlogContext, Func e.Entity).Single()); await context0.SaveChangesAsync(); diff --git a/test/EFCore.CrossStore.FunctionalTests/CrossStoreFixture.cs b/test/EFCore.CrossStore.FunctionalTests/CrossStoreFixture.cs index 00513c04ef1..435363ed7df 100644 --- a/test/EFCore.CrossStore.FunctionalTests/CrossStoreFixture.cs +++ b/test/EFCore.CrossStore.FunctionalTests/CrossStoreFixture.cs @@ -24,7 +24,7 @@ public TestStore CreateTestStore(ITestStoreFactory testStoreFactory) return testStoreFactory.GetOrCreate(StoreName) .Initialize( AddServices(testStoreFactory.AddProviderServices(new ServiceCollection())) - .BuildServiceProvider(validateScopes: true), CreateContext, c => { }, null); + .BuildServiceProvider(validateScopes: true), CreateContext, c => { }); } protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) diff --git a/test/EFCore.CrossStore.FunctionalTests/DiscriminatorTest.cs b/test/EFCore.CrossStore.FunctionalTests/DiscriminatorTest.cs index e14f962e966..c52e1fd2095 100644 --- a/test/EFCore.CrossStore.FunctionalTests/DiscriminatorTest.cs +++ b/test/EFCore.CrossStore.FunctionalTests/DiscriminatorTest.cs @@ -16,13 +16,7 @@ public void Can_save_entities_with_discriminators() using (var context = new Context4285()) { context.AddRange( - new SubProduct - { - SomeName = "One" - }, new SubProduct2 - { - SomeName2 = "Two" - }); + new SubProduct { SomeName = "One" }, new SubProduct2 { SomeName2 = "Two" }); context.SaveChanges(); } @@ -44,13 +38,7 @@ public void Can_save_entities_with_int_discriminators() using (var context = new Context4285()) { context.AddRange( - new SubIntProduct - { - SomeName = "One" - }, new SubIntProduct2 - { - SomeName2 = "Two" - }); + new SubIntProduct { SomeName = "One" }, new SubIntProduct2 { SomeName2 = "Two" }); context.SaveChanges(); } diff --git a/test/EFCore.CrossStore.FunctionalTests/EndToEndTest.cs b/test/EFCore.CrossStore.FunctionalTests/EndToEndTest.cs index 717e17d82ad..7fd000cd8e4 100644 --- a/test/EFCore.CrossStore.FunctionalTests/EndToEndTest.cs +++ b/test/EFCore.CrossStore.FunctionalTests/EndToEndTest.cs @@ -5,7 +5,6 @@ using System.Linq; using Microsoft.EntityFrameworkCore.TestModels; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable InconsistentNaming @@ -31,18 +30,12 @@ public virtual void Can_save_changes_and_query() using (var context = CreateContext()) { context.SimpleEntities.Add( - new SimpleEntity - { - StringProperty = "Entity 1" - }); + new SimpleEntity { StringProperty = "Entity 1" }); Assert.Equal(1, context.SaveChanges()); var second = context.SimpleEntities.Add( - new SimpleEntity - { - StringProperty = "Entity 2" - }).Entity; + new SimpleEntity { StringProperty = "Entity 2" }).Entity; context.Entry(second).Property(SimpleEntity.ShadowPropertyName).CurrentValue = "shadow"; Assert.Equal(1, context.SaveChanges()); diff --git a/test/EFCore.Design.Tests/ApiConsistencyTest.cs b/test/EFCore.Design.Tests/ApiConsistencyTest.cs index 045bfc82657..2ab56a9a3a9 100644 --- a/test/EFCore.Design.Tests/ApiConsistencyTest.cs +++ b/test/EFCore.Design.Tests/ApiConsistencyTest.cs @@ -11,10 +11,7 @@ namespace Microsoft.EntityFrameworkCore { public class ApiConsistencyTest : ApiConsistencyTestBase { - private static readonly Type[] _fluentApiTypes = - { - typeof(DesignTimeServiceCollectionExtensions) - }; + private static readonly Type[] _fluentApiTypes = { typeof(DesignTimeServiceCollectionExtensions) }; protected override IEnumerable FluentApiTypes => _fluentApiTypes; diff --git a/test/EFCore.Design.Tests/Design/Internal/DbContextOperationsTest.cs b/test/EFCore.Design.Tests/Design/Internal/DbContextOperationsTest.cs index 203cdbb341d..2698b9bc644 100644 --- a/test/EFCore.Design.Tests/Design/Internal/DbContextOperationsTest.cs +++ b/test/EFCore.Design.Tests/Design/Internal/DbContextOperationsTest.cs @@ -31,9 +31,10 @@ private static TestWebHost BuildWebHost(string[] args) #pragma warning restore RCS1213 // Remove unused member declaration. => new TestWebHost( new ServiceCollection() - .AddDbContext(b => - b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(Guid.NewGuid().ToString())) + .AddDbContext( + b => + b.EnableServiceProviderCaching(false) + .UseInMemoryDatabase(Guid.NewGuid().ToString())) .BuildServiceProvider()); } diff --git a/test/EFCore.Design.Tests/DesignExceptionTest.cs b/test/EFCore.Design.Tests/DesignExceptionTest.cs index 193df67c153..5071c59b4ef 100644 --- a/test/EFCore.Design.Tests/DesignExceptionTest.cs +++ b/test/EFCore.Design.Tests/DesignExceptionTest.cs @@ -47,7 +47,8 @@ public void Deserialized_OperationException_can_be_serialized_and_deserialized_a Assert.Equal("Bang!", transportedException.InnerException.Message); } - private TException SerializeAndDeserialize(TException exception) where TException : Exception + private TException SerializeAndDeserialize(TException exception) + where TException : Exception { var stream = new MemoryStream(); var formatter = new BinaryFormatter(); diff --git a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs index e903052693a..fe4435789cb 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs @@ -35,17 +35,7 @@ public void Generate_separates_operations_by_a_blank_line() generator.Generate( "mb", - new[] - { - new SqlOperation - { - Sql = "-- Don't stand so" - }, - new SqlOperation - { - Sql = "-- close to me" - } - }, + new[] { new SqlOperation { Sql = "-- Don't stand so" }, new SqlOperation { Sql = "-- close to me" } }, builder); Assert.Equal( @@ -59,12 +49,7 @@ public void Generate_separates_operations_by_a_blank_line() public void AddColumnOperation_required_args() { Test( - new AddColumnOperation - { - Name = "Id", - Table = "Post", - ClrType = typeof(int) - }, + new AddColumnOperation { Name = "Id", Table = "Post", ClrType = typeof(int) }, "mb.AddColumn(" + _eol + " name: \"Id\"," + _eol + " table: \"Post\"," + _eol + @@ -127,13 +112,7 @@ public void AddColumnOperation_all_args() public void AddColumnOperation_DefaultValueSql() { Test( - new AddColumnOperation - { - Name = "Id", - Table = "Post", - ClrType = typeof(int), - DefaultValueSql = "1" - }, + new AddColumnOperation { Name = "Id", Table = "Post", ClrType = typeof(int), DefaultValueSql = "1" }, "mb.AddColumn(" + _eol + " name: \"Id\"," + _eol + " table: \"Post\"," + _eol + @@ -152,13 +131,7 @@ public void AddColumnOperation_DefaultValueSql() public void AddColumnOperation_ComputedExpression() { Test( - new AddColumnOperation - { - Name = "Id", - Table = "Post", - ClrType = typeof(int), - ComputedColumnSql = "1" - }, + new AddColumnOperation { Name = "Id", Table = "Post", ClrType = typeof(int), ComputedColumnSql = "1" }, "mb.AddColumn(" + _eol + " name: \"Id\"," + _eol + " table: \"Post\"," + _eol + @@ -271,12 +244,7 @@ public void AddForeignKeyOperation_composite() public void AddPrimaryKey_required_args() { Test( - new AddPrimaryKeyOperation - { - Name = "PK_Post", - Table = "Post", - Columns = new[] { "Id" } - }, + new AddPrimaryKeyOperation { Name = "PK_Post", Table = "Post", Columns = new[] { "Id" } }, "mb.AddPrimaryKey(" + _eol + " name: \"PK_Post\"," + _eol + " table: \"Post\"," + _eol + @@ -293,13 +261,7 @@ public void AddPrimaryKey_required_args() public void AddPrimaryKey_all_args() { Test( - new AddPrimaryKeyOperation - { - Name = "PK_Post", - Schema = "dbo", - Table = "Post", - Columns = new[] { "Id" } - }, + new AddPrimaryKeyOperation { Name = "PK_Post", Schema = "dbo", Table = "Post", Columns = new[] { "Id" } }, "mb.AddPrimaryKey(" + _eol + " name: \"PK_Post\"," + _eol + " schema: \"dbo\"," + _eol + @@ -318,12 +280,7 @@ public void AddPrimaryKey_all_args() public void AddPrimaryKey_composite() { Test( - new AddPrimaryKeyOperation - { - Name = "PK_Post", - Table = "Post", - Columns = new[] { "Id1", "Id2" } - }, + new AddPrimaryKeyOperation { Name = "PK_Post", Table = "Post", Columns = new[] { "Id1", "Id2" } }, "mb.AddPrimaryKey(" + _eol + " name: \"PK_Post\"," + _eol + " table: \"Post\"," + _eol + @@ -340,12 +297,7 @@ public void AddPrimaryKey_composite() public void AddUniqueConstraint_required_args() { Test( - new AddUniqueConstraintOperation - { - Name = "AK_Post_AltId", - Table = "Post", - Columns = new[] { "AltId" } - }, + new AddUniqueConstraintOperation { Name = "AK_Post_AltId", Table = "Post", Columns = new[] { "AltId" } }, "mb.AddUniqueConstraint(" + _eol + " name: \"AK_Post_AltId\"," + _eol + " table: \"Post\"," + _eol + @@ -362,13 +314,7 @@ public void AddUniqueConstraint_required_args() public void AddUniqueConstraint_all_args() { Test( - new AddUniqueConstraintOperation - { - Name = "AK_Post_AltId", - Schema = "dbo", - Table = "Post", - Columns = new[] { "AltId" } - }, + new AddUniqueConstraintOperation { Name = "AK_Post_AltId", Schema = "dbo", Table = "Post", Columns = new[] { "AltId" } }, "mb.AddUniqueConstraint(" + _eol + " name: \"AK_Post_AltId\"," + _eol + " schema: \"dbo\"," + _eol + @@ -387,12 +333,7 @@ public void AddUniqueConstraint_all_args() public void AddUniqueConstraint_composite() { Test( - new AddUniqueConstraintOperation - { - Name = "AK_Post_AltId1_AltId2", - Table = "Post", - Columns = new[] { "AltId1", "AltId2" } - }, + new AddUniqueConstraintOperation { Name = "AK_Post_AltId1_AltId2", Table = "Post", Columns = new[] { "AltId1", "AltId2" } }, "mb.AddUniqueConstraint(" + _eol + " name: \"AK_Post_AltId1_AltId2\"," + _eol + " table: \"Post\"," + _eol + @@ -409,12 +350,7 @@ public void AddUniqueConstraint_composite() public void CreateCheckConstraint_required_args() { Test( - new CreateCheckConstraintOperation - { - Name = "CK_Post_AltId1_AltId2", - Table = "Post", - Sql = "AltId1 > AltId2" - }, + new CreateCheckConstraintOperation { Name = "CK_Post_AltId1_AltId2", Table = "Post", Sql = "AltId1 > AltId2" }, "mb.CreateCheckConstraint(" + _eol + " name: \"CK_Post_AltId1_AltId2\"," + _eol + " table: \"Post\"," + _eol + @@ -433,10 +369,7 @@ public void CreateCheckConstraint_all_args() Test( new CreateCheckConstraintOperation { - Name = "CK_Post_AltId1_AltId2", - Schema = "dbo", - Table = "Post", - Sql = "AltId1 > AltId2" + Name = "CK_Post_AltId1_AltId2", Schema = "dbo", Table = "Post", Sql = "AltId1 > AltId2" }, "mb.CreateCheckConstraint(" + _eol + " name: \"CK_Post_AltId1_AltId2\"," + _eol + @@ -456,12 +389,7 @@ public void CreateCheckConstraint_all_args() public void AlterColumnOperation_required_args() { Test( - new AlterColumnOperation - { - Name = "Id", - Table = "Post", - ClrType = typeof(int) - }, + new AlterColumnOperation { Name = "Id", Table = "Post", ClrType = typeof(int) }, "mb.AlterColumn(" + _eol + " name: \"Id\"," + _eol + " table: \"Post\"," + _eol + @@ -521,7 +449,7 @@ public void AlterColumnOperation_all_args() IsNullable = true, DefaultValue = 0, IsFixedLength = true, - Comment = "My Comment", + Comment = "My Comment" } }, "mb.AlterColumn(" + _eol + @@ -579,13 +507,7 @@ public void AlterColumnOperation_all_args() public void AlterColumnOperation_DefaultValueSql() { Test( - new AlterColumnOperation - { - Name = "Id", - Table = "Post", - ClrType = typeof(int), - DefaultValueSql = "1" - }, + new AlterColumnOperation { Name = "Id", Table = "Post", ClrType = typeof(int), DefaultValueSql = "1" }, "mb.AlterColumn(" + _eol + " name: \"Id\"," + _eol + " table: \"Post\"," + _eol + @@ -622,13 +544,7 @@ public void AlterColumnOperation_DefaultValueSql() public void AlterColumnOperation_computedColumnSql() { Test( - new AlterColumnOperation - { - Name = "Id", - Table = "Post", - ClrType = typeof(int), - ComputedColumnSql = "1" - }, + new AlterColumnOperation { Name = "Id", Table = "Post", ClrType = typeof(int), ComputedColumnSql = "1" }, "mb.AlterColumn(" + _eol + " name: \"Id\"," + _eol + " table: \"Post\"," + _eol + @@ -665,14 +581,7 @@ public void AlterColumnOperation_computedColumnSql() public void AlterDatabaseOperation() { Test( - new AlterDatabaseOperation - { - ["foo"] = "bar", - OldDatabase = - { - ["bar"] = "foo" - } - }, + new AlterDatabaseOperation { ["foo"] = "bar", OldDatabase = { ["bar"] = "foo" } }, "mb.AlterDatabase()" + _eol + " .Annotation(\"foo\", \"bar\")" + _eol + " .OldAnnotation(\"bar\", \"foo\");", @@ -687,10 +596,7 @@ public void AlterDatabaseOperation() public void AlterSequenceOperation_required_args() { Test( - new AlterSequenceOperation - { - Name = "EntityFrameworkHiLoSequence" - }, + new AlterSequenceOperation { Name = "EntityFrameworkHiLoSequence" }, "mb.AlterSequence(" + _eol + " name: \"EntityFrameworkHiLoSequence\");", o => @@ -720,13 +626,7 @@ public void AlterSequenceOperation_all_args() MinValue = 2, MaxValue = 4, IsCyclic = true, - OldSequence = - { - IncrementBy = 4, - MinValue = 3, - MaxValue = 5, - IsCyclic = true - } + OldSequence = { IncrementBy = 4, MinValue = 3, MaxValue = 5, IsCyclic = true } }, "mb.AlterSequence(" + _eol + " name: \"EntityFrameworkHiLoSequence\"," + _eol + @@ -758,10 +658,7 @@ public void AlterSequenceOperation_all_args() public void AlterTableOperation_required_args() { Test( - new AlterTableOperation - { - Name = "Customer" - }, + new AlterTableOperation { Name = "Customer" }, "mb.AlterTable(" + _eol + " name: \"Customer\");", o => @@ -776,13 +673,7 @@ public void AlterTableOperation_all_args() Test( new AlterTableOperation { - Name = "Customer", - Schema = "dbo", - Comment = "My Comment 2", - OldTable = - { - Comment = "My Comment" - } + Name = "Customer", Schema = "dbo", Comment = "My Comment 2", OldTable = { Comment = "My Comment" } }, "mb.AlterTable(" + _eol + " name: \"Customer\"," + _eol + @@ -802,12 +693,7 @@ public void AlterTableOperation_all_args() public void CreateIndexOperation_required_args() { Test( - new CreateIndexOperation - { - Name = "IX_Post_Title", - Table = "Post", - Columns = new[] { "Title" } - }, + new CreateIndexOperation { Name = "IX_Post_Title", Table = "Post", Columns = new[] { "Title" } }, "mb.CreateIndex(" + _eol + " name: \"IX_Post_Title\"," + _eol + " table: \"Post\"," + _eol + @@ -854,12 +740,7 @@ public void CreateIndexOperation_all_args() public void CreateIndexOperation_composite() { Test( - new CreateIndexOperation - { - Name = "IX_Post_Title_Subtitle", - Table = "Post", - Columns = new[] { "Title", "Subtitle" } - }, + new CreateIndexOperation { Name = "IX_Post_Title_Subtitle", Table = "Post", Columns = new[] { "Title", "Subtitle" } }, "mb.CreateIndex(" + _eol + " name: \"IX_Post_Title_Subtitle\"," + _eol + " table: \"Post\"," + _eol + @@ -876,10 +757,7 @@ public void CreateIndexOperation_composite() public void CreateSchemaOperation_required_args() { Test( - new EnsureSchemaOperation - { - Name = "my" - }, + new EnsureSchemaOperation { Name = "my" }, "mb.EnsureSchema(" + _eol + " name: \"my\");", o => Assert.Equal("my", o.Name)); @@ -889,11 +767,7 @@ public void CreateSchemaOperation_required_args() public void CreateSequenceOperation_required_args() { Test( - new CreateSequenceOperation - { - Name = "EntityFrameworkHiLoSequence", - ClrType = typeof(long) - }, + new CreateSequenceOperation { Name = "EntityFrameworkHiLoSequence", ClrType = typeof(long) }, "mb.CreateSequence(" + _eol + " name: \"EntityFrameworkHiLoSequence\");", o => @@ -907,11 +781,7 @@ public void CreateSequenceOperation_required_args() public void CreateSequenceOperation_required_args_not_long() { Test( - new CreateSequenceOperation - { - Name = "EntityFrameworkHiLoSequence", - ClrType = typeof(int) - }, + new CreateSequenceOperation { Name = "EntityFrameworkHiLoSequence", ClrType = typeof(int) }, "mb.CreateSequence(" + _eol + " name: \"EntityFrameworkHiLoSequence\");", o => @@ -999,16 +869,7 @@ public void CreateTableOperation_Columns_required_args() Test( new CreateTableOperation { - Name = "Post", - Columns = - { - new AddColumnOperation - { - Name = "Id", - Table = "Post", - ClrType = typeof(int) - } - } + Name = "Post", Columns = { new AddColumnOperation { Name = "Id", Table = "Post", ClrType = typeof(int) } } }, "mb.CreateTable(" + _eol + " name: \"Post\"," + _eol + @@ -1092,16 +953,7 @@ public void CreateTableOperation_Columns_DefaultValueSql() new CreateTableOperation { Name = "Post", - Columns = - { - new AddColumnOperation - { - Name = "Id", - Table = "Post", - ClrType = typeof(int), - DefaultValueSql = "1" - } - } + Columns = { new AddColumnOperation { Name = "Id", Table = "Post", ClrType = typeof(int), DefaultValueSql = "1" } } }, "mb.CreateTable(" + _eol + " name: \"Post\"," + _eol + @@ -1130,16 +982,7 @@ public void CreateTableOperation_Columns_computedColumnSql() new CreateTableOperation { Name = "Post", - Columns = - { - new AddColumnOperation - { - Name = "Id", - Table = "Post", - ClrType = typeof(int), - ComputedColumnSql = "1" - } - } + Columns = { new AddColumnOperation { Name = "Id", Table = "Post", ClrType = typeof(int), ComputedColumnSql = "1" } } }, "mb.CreateTable(" + _eol + " name: \"Post\"," + _eol + @@ -1168,14 +1011,7 @@ public void CreateTableOperation_ForeignKeys_required_args() new CreateTableOperation { Name = "Post", - Columns = - { - new AddColumnOperation - { - Name = "BlogId", - ClrType = typeof(int) - } - }, + Columns = { new AddColumnOperation { Name = "BlogId", ClrType = typeof(int) } }, ForeignKeys = { new AddForeignKeyOperation @@ -1222,14 +1058,7 @@ public void CreateTableOperation_ForeignKeys_all_args() { Schema = "dbo", Name = "Post", - Columns = - { - new AddColumnOperation - { - Name = "BlogId", - ClrType = typeof(int) - } - }, + Columns = { new AddColumnOperation { Name = "BlogId", ClrType = typeof(int) } }, ForeignKeys = { new AddForeignKeyOperation @@ -1290,16 +1119,8 @@ public void CreateTableOperation_ForeignKeys_composite() Name = "Post", Columns = { - new AddColumnOperation - { - Name = "BlogId1", - ClrType = typeof(int) - }, - new AddColumnOperation - { - Name = "BlogId2", - ClrType = typeof(int) - } + new AddColumnOperation { Name = "BlogId1", ClrType = typeof(int) }, + new AddColumnOperation { Name = "BlogId2", ClrType = typeof(int) } }, ForeignKeys = { @@ -1347,20 +1168,8 @@ public void CreateTableOperation_PrimaryKey_required_args() new CreateTableOperation { Name = "Post", - Columns = - { - new AddColumnOperation - { - Name = "Id", - ClrType = typeof(int) - } - }, - PrimaryKey = new AddPrimaryKeyOperation - { - Name = "PK_Post", - Table = "Post", - Columns = new[] { "Id" } - } + Columns = { new AddColumnOperation { Name = "Id", ClrType = typeof(int) } }, + PrimaryKey = new AddPrimaryKeyOperation { Name = "PK_Post", Table = "Post", Columns = new[] { "Id" } } }, "mb.CreateTable(" + _eol + " name: \"Post\"," + _eol + @@ -1390,20 +1199,10 @@ public void CreateTableOperation_PrimaryKey_all_args() { Name = "Post", Schema = "dbo", - Columns = - { - new AddColumnOperation - { - Name = "Id", - ClrType = typeof(int) - } - }, + Columns = { new AddColumnOperation { Name = "Id", ClrType = typeof(int) } }, PrimaryKey = new AddPrimaryKeyOperation { - Name = "PK_Post", - Schema = "dbo", - Table = "Post", - Columns = new[] { "Id" } + Name = "PK_Post", Schema = "dbo", Table = "Post", Columns = new[] { "Id" } } }, "mb.CreateTable(" + _eol + @@ -1437,23 +1236,10 @@ public void CreateTableOperation_PrimaryKey_composite() Name = "Post", Columns = { - new AddColumnOperation - { - Name = "Id1", - ClrType = typeof(int) - }, - new AddColumnOperation - { - Name = "Id2", - ClrType = typeof(int) - } + new AddColumnOperation { Name = "Id1", ClrType = typeof(int) }, + new AddColumnOperation { Name = "Id2", ClrType = typeof(int) } }, - PrimaryKey = new AddPrimaryKeyOperation - { - Name = "PK_Post", - Table = "Post", - Columns = new[] { "Id1", "Id2" } - } + PrimaryKey = new AddPrimaryKeyOperation { Name = "PK_Post", Table = "Post", Columns = new[] { "Id1", "Id2" } } }, "mb.CreateTable(" + _eol + " name: \"Post\"," + _eol + @@ -1483,22 +1269,10 @@ public void CreateTableOperation_UniqueConstraints_required_args() new CreateTableOperation { Name = "Post", - Columns = - { - new AddColumnOperation - { - Name = "AltId", - ClrType = typeof(int) - } - }, + Columns = { new AddColumnOperation { Name = "AltId", ClrType = typeof(int) } }, UniqueConstraints = { - new AddUniqueConstraintOperation - { - Name = "AK_Post_AltId", - Table = "Post", - Columns = new[] { "AltId" } - } + new AddUniqueConstraintOperation { Name = "AK_Post_AltId", Table = "Post", Columns = new[] { "AltId" } } } }, "mb.CreateTable(" + _eol + @@ -1529,22 +1303,12 @@ public void CreateTableOperation_UniqueConstraints_all_args() { Name = "Post", Schema = "dbo", - Columns = - { - new AddColumnOperation - { - Name = "AltId", - ClrType = typeof(int) - } - }, + Columns = { new AddColumnOperation { Name = "AltId", ClrType = typeof(int) } }, UniqueConstraints = { new AddUniqueConstraintOperation { - Name = "AK_Post_AltId", - Schema = "dbo", - Table = "Post", - Columns = new[] { "AltId" } + Name = "AK_Post_AltId", Schema = "dbo", Table = "Post", Columns = new[] { "AltId" } } } }, @@ -1579,24 +1343,14 @@ public void CreateTableOperation_UniqueConstraints_composite() Name = "Post", Columns = { - new AddColumnOperation - { - Name = "AltId1", - ClrType = typeof(int) - }, - new AddColumnOperation - { - Name = "AltId2", - ClrType = typeof(int) - } + new AddColumnOperation { Name = "AltId1", ClrType = typeof(int) }, + new AddColumnOperation { Name = "AltId2", ClrType = typeof(int) } }, UniqueConstraints = { new AddUniqueConstraintOperation { - Name = "AK_Post_AltId1_AltId2", - Table = "Post", - Columns = new[] { "AltId1", "AltId2" } + Name = "AK_Post_AltId1_AltId2", Table = "Post", Columns = new[] { "AltId1", "AltId2" } } } }, @@ -1630,24 +1384,14 @@ public void CreateTableOperation_CheckConstraints_required_args() Name = "Post", Columns = { - new AddColumnOperation - { - Name = "AltId1", - ClrType = typeof(int) - }, - new AddColumnOperation - { - Name = "AltId2", - ClrType = typeof(int) - } + new AddColumnOperation { Name = "AltId1", ClrType = typeof(int) }, + new AddColumnOperation { Name = "AltId2", ClrType = typeof(int) } }, CheckConstraints = { new CreateCheckConstraintOperation { - Name = "CK_Post_AltId1_AltId2", - Table = "Post", - Sql = "AltId1 > AltId2" + Name = "CK_Post_AltId1_AltId2", Table = "Post", Sql = "AltId1 > AltId2" } } }, @@ -1682,25 +1426,14 @@ public void CreateTableOperation_ChecksConstraints_all_args() Schema = "dbo", Columns = { - new AddColumnOperation - { - Name = "AltId1", - ClrType = typeof(int) - }, - new AddColumnOperation - { - Name = "AltId2", - ClrType = typeof(int) - } + new AddColumnOperation { Name = "AltId1", ClrType = typeof(int) }, + new AddColumnOperation { Name = "AltId2", ClrType = typeof(int) } }, CheckConstraints = { new CreateCheckConstraintOperation { - Name = "CK_Post_AltId1_AltId2", - Schema = "dbo", - Table = "Post", - Sql = "AltId1 > AltId2" + Name = "CK_Post_AltId1_AltId2", Schema = "dbo", Table = "Post", Sql = "AltId1 > AltId2" } } }, @@ -1735,14 +1468,7 @@ public void CreateTableOperation_Comment() { Name = "Post", Schema = "dbo", - Columns = - { - new AddColumnOperation - { - Name = "AltId1", - ClrType = typeof(int) - } - }, + Columns = { new AddColumnOperation { Name = "AltId1", ClrType = typeof(int) } }, Comment = "My Comment" }, "mb.CreateTable(" + _eol + @@ -1766,11 +1492,7 @@ public void CreateTableOperation_Comment() public void DropColumnOperation_required_args() { Test( - new DropColumnOperation - { - Name = "Id", - Table = "Post" - }, + new DropColumnOperation { Name = "Id", Table = "Post" }, "mb.DropColumn(" + _eol + " name: \"Id\"," + _eol + " table: \"Post\");", @@ -1785,12 +1507,7 @@ public void DropColumnOperation_required_args() public void DropColumnOperation_all_args() { Test( - new DropColumnOperation - { - Name = "Id", - Schema = "dbo", - Table = "Post" - }, + new DropColumnOperation { Name = "Id", Schema = "dbo", Table = "Post" }, "mb.DropColumn(" + _eol + " name: \"Id\"," + _eol + " schema: \"dbo\"," + _eol + @@ -1807,11 +1524,7 @@ public void DropColumnOperation_all_args() public void DropForeignKeyOperation_required_args() { Test( - new DropForeignKeyOperation - { - Name = "FK_Post_BlogId", - Table = "Post" - }, + new DropForeignKeyOperation { Name = "FK_Post_BlogId", Table = "Post" }, "mb.DropForeignKey(" + _eol + " name: \"FK_Post_BlogId\"," + _eol + " table: \"Post\");", @@ -1826,12 +1539,7 @@ public void DropForeignKeyOperation_required_args() public void DropForeignKeyOperation_all_args() { Test( - new DropForeignKeyOperation - { - Name = "FK_Post_BlogId", - Schema = "dbo", - Table = "Post" - }, + new DropForeignKeyOperation { Name = "FK_Post_BlogId", Schema = "dbo", Table = "Post" }, "mb.DropForeignKey(" + _eol + " name: \"FK_Post_BlogId\"," + _eol + " schema: \"dbo\"," + _eol + @@ -1848,11 +1556,7 @@ public void DropForeignKeyOperation_all_args() public void DropIndexOperation_required_args() { Test( - new DropIndexOperation - { - Name = "IX_Post_Title", - Table = "Post" - }, + new DropIndexOperation { Name = "IX_Post_Title", Table = "Post" }, "mb.DropIndex(" + _eol + " name: \"IX_Post_Title\"," + _eol + " table: \"Post\");", @@ -1867,12 +1571,7 @@ public void DropIndexOperation_required_args() public void DropIndexOperation_all_args() { Test( - new DropIndexOperation - { - Name = "IX_Post_Title", - Schema = "dbo", - Table = "Post" - }, + new DropIndexOperation { Name = "IX_Post_Title", Schema = "dbo", Table = "Post" }, "mb.DropIndex(" + _eol + " name: \"IX_Post_Title\"," + _eol + " schema: \"dbo\"," + _eol + @@ -1889,11 +1588,7 @@ public void DropIndexOperation_all_args() public void DropPrimaryKeyOperation_required_args() { Test( - new DropPrimaryKeyOperation - { - Name = "PK_Post", - Table = "Post" - }, + new DropPrimaryKeyOperation { Name = "PK_Post", Table = "Post" }, "mb.DropPrimaryKey(" + _eol + " name: \"PK_Post\"," + _eol + " table: \"Post\");", @@ -1908,12 +1603,7 @@ public void DropPrimaryKeyOperation_required_args() public void DropPrimaryKeyOperation_all_args() { Test( - new DropPrimaryKeyOperation - { - Name = "PK_Post", - Schema = "dbo", - Table = "Post" - }, + new DropPrimaryKeyOperation { Name = "PK_Post", Schema = "dbo", Table = "Post" }, "mb.DropPrimaryKey(" + _eol + " name: \"PK_Post\"," + _eol + " schema: \"dbo\"," + _eol + @@ -1930,10 +1620,7 @@ public void DropPrimaryKeyOperation_all_args() public void DropSchemaOperation_required_args() { Test( - new DropSchemaOperation - { - Name = "my" - }, + new DropSchemaOperation { Name = "my" }, "mb.DropSchema(" + _eol + " name: \"my\");", o => Assert.Equal("my", o.Name)); @@ -1943,10 +1630,7 @@ public void DropSchemaOperation_required_args() public void DropSequenceOperation_required_args() { Test( - new DropSequenceOperation - { - Name = "EntityFrameworkHiLoSequence" - }, + new DropSequenceOperation { Name = "EntityFrameworkHiLoSequence" }, "mb.DropSequence(" + _eol + " name: \"EntityFrameworkHiLoSequence\");", o => Assert.Equal("EntityFrameworkHiLoSequence", o.Name)); @@ -1956,11 +1640,7 @@ public void DropSequenceOperation_required_args() public void DropSequenceOperation_all_args() { Test( - new DropSequenceOperation - { - Name = "EntityFrameworkHiLoSequence", - Schema = "dbo" - }, + new DropSequenceOperation { Name = "EntityFrameworkHiLoSequence", Schema = "dbo" }, "mb.DropSequence(" + _eol + " name: \"EntityFrameworkHiLoSequence\"," + _eol + " schema: \"dbo\");", @@ -1975,10 +1655,7 @@ public void DropSequenceOperation_all_args() public void DropTableOperation_required_args() { Test( - new DropTableOperation - { - Name = "Post" - }, + new DropTableOperation { Name = "Post" }, "mb.DropTable(" + _eol + " name: \"Post\");", o => Assert.Equal("Post", o.Name)); @@ -1988,11 +1665,7 @@ public void DropTableOperation_required_args() public void DropTableOperation_all_args() { Test( - new DropTableOperation - { - Name = "Post", - Schema = "dbo" - }, + new DropTableOperation { Name = "Post", Schema = "dbo" }, "mb.DropTable(" + _eol + " name: \"Post\"," + _eol + " schema: \"dbo\");", @@ -2007,11 +1680,7 @@ public void DropTableOperation_all_args() public void DropUniqueConstraintOperation_required_args() { Test( - new DropUniqueConstraintOperation - { - Name = "AK_Post_AltId", - Table = "Post" - }, + new DropUniqueConstraintOperation { Name = "AK_Post_AltId", Table = "Post" }, "mb.DropUniqueConstraint(" + _eol + " name: \"AK_Post_AltId\"," + _eol + " table: \"Post\");", @@ -2026,12 +1695,7 @@ public void DropUniqueConstraintOperation_required_args() public void DropUniqueConstraintOperation_all_args() { Test( - new DropUniqueConstraintOperation - { - Name = "AK_Post_AltId", - Schema = "dbo", - Table = "Post" - }, + new DropUniqueConstraintOperation { Name = "AK_Post_AltId", Schema = "dbo", Table = "Post" }, "mb.DropUniqueConstraint(" + _eol + " name: \"AK_Post_AltId\"," + _eol + " schema: \"dbo\"," + _eol + @@ -2048,11 +1712,7 @@ public void DropUniqueConstraintOperation_all_args() public void DropCheckConstraintOperation_required_args() { Test( - new DropCheckConstraintOperation - { - Name = "CK_Post_AltId1_AltId2", - Table = "Post" - }, + new DropCheckConstraintOperation { Name = "CK_Post_AltId1_AltId2", Table = "Post" }, "mb.DropCheckConstraint(" + _eol + " name: \"CK_Post_AltId1_AltId2\"," + _eol + " table: \"Post\");", @@ -2067,12 +1727,7 @@ public void DropCheckConstraintOperation_required_args() public void DropCheckConstraintOperation_all_args() { Test( - new DropCheckConstraintOperation - { - Name = "CK_Post_AltId1_AltId2", - Schema = "dbo", - Table = "Post" - }, + new DropCheckConstraintOperation { Name = "CK_Post_AltId1_AltId2", Schema = "dbo", Table = "Post" }, "mb.DropCheckConstraint(" + _eol + " name: \"CK_Post_AltId1_AltId2\"," + _eol + " schema: \"dbo\"," + _eol + @@ -2089,12 +1744,7 @@ public void DropCheckConstraintOperation_all_args() public void RenameColumnOperation_required_args() { Test( - new RenameColumnOperation - { - Name = "Id", - Table = "Post", - NewName = "PostId" - }, + new RenameColumnOperation { Name = "Id", Table = "Post", NewName = "PostId" }, "mb.RenameColumn(" + _eol + " name: \"Id\"," + _eol + " table: \"Post\"," + _eol + @@ -2111,13 +1761,7 @@ public void RenameColumnOperation_required_args() public void RenameColumnOperation_all_args() { Test( - new RenameColumnOperation - { - Name = "Id", - Schema = "dbo", - Table = "Post", - NewName = "PostId" - }, + new RenameColumnOperation { Name = "Id", Schema = "dbo", Table = "Post", NewName = "PostId" }, "mb.RenameColumn(" + _eol + " name: \"Id\"," + _eol + " schema: \"dbo\"," + _eol + @@ -2136,12 +1780,7 @@ public void RenameColumnOperation_all_args() public void RenameIndexOperation_required_args() { Test( - new RenameIndexOperation - { - Name = "IX_Post_Title", - Table = "Post", - NewName = "IX_Post_PostTitle" - }, + new RenameIndexOperation { Name = "IX_Post_Title", Table = "Post", NewName = "IX_Post_PostTitle" }, "mb.RenameIndex(" + _eol + " name: \"IX_Post_Title\"," + _eol + " table: \"Post\"," + _eol + @@ -2158,13 +1797,7 @@ public void RenameIndexOperation_required_args() public void RenameIndexOperation_all_args() { Test( - new RenameIndexOperation - { - Name = "IX_dbo.Post_Title", - Schema = "dbo", - Table = "Post", - NewName = "IX_dbo.Post_PostTitle" - }, + new RenameIndexOperation { Name = "IX_dbo.Post_Title", Schema = "dbo", Table = "Post", NewName = "IX_dbo.Post_PostTitle" }, "mb.RenameIndex(" + _eol + " name: \"IX_dbo.Post_Title\"," + _eol + " schema: \"dbo\"," + _eol + @@ -2183,10 +1816,7 @@ public void RenameIndexOperation_all_args() public void RenameSequenceOperation_required_args() { Test( - new RenameSequenceOperation - { - Name = "EntityFrameworkHiLoSequence" - }, + new RenameSequenceOperation { Name = "EntityFrameworkHiLoSequence" }, "mb.RenameSequence(" + _eol + " name: \"EntityFrameworkHiLoSequence\");", o => Assert.Equal("EntityFrameworkHiLoSequence", o.Name)); @@ -2198,10 +1828,7 @@ public void RenameSequenceOperation_all_args() Test( new RenameSequenceOperation { - Name = "EntityFrameworkHiLoSequence", - Schema = "dbo", - NewName = "MySequence", - NewSchema = "my" + Name = "EntityFrameworkHiLoSequence", Schema = "dbo", NewName = "MySequence", NewSchema = "my" }, "mb.RenameSequence(" + _eol + " name: \"EntityFrameworkHiLoSequence\"," + _eol + @@ -2221,10 +1848,7 @@ public void RenameSequenceOperation_all_args() public void RenameTableOperation_required_args() { Test( - new RenameTableOperation - { - Name = "Post" - }, + new RenameTableOperation { Name = "Post" }, "mb.RenameTable(" + _eol + " name: \"Post\");", o => Assert.Equal("Post", o.Name)); @@ -2234,13 +1858,7 @@ public void RenameTableOperation_required_args() public void RenameTableOperation_all_args() { Test( - new RenameTableOperation - { - Name = "Post", - Schema = "dbo", - NewName = "Posts", - NewSchema = "my" - }, + new RenameTableOperation { Name = "Post", Schema = "dbo", NewName = "Posts", NewSchema = "my" }, "mb.RenameTable(" + _eol + " name: \"Post\"," + _eol + " schema: \"dbo\"," + _eol + @@ -2259,11 +1877,7 @@ public void RenameTableOperation_all_args() public void RestartSequenceOperation_required_args() { Test( - new RestartSequenceOperation - { - Name = "EntityFrameworkHiLoSequence", - StartValue = 1 - }, + new RestartSequenceOperation { Name = "EntityFrameworkHiLoSequence", StartValue = 1 }, "mb.RestartSequence(" + _eol + " name: \"EntityFrameworkHiLoSequence\"," + _eol + " startValue: 1L);", @@ -2278,12 +1892,7 @@ public void RestartSequenceOperation_required_args() public void RestartSequenceOperation_all_args() { Test( - new RestartSequenceOperation - { - Name = "EntityFrameworkHiLoSequence", - Schema = "dbo", - StartValue = 1 - }, + new RestartSequenceOperation { Name = "EntityFrameworkHiLoSequence", Schema = "dbo", StartValue = 1 }, "mb.RestartSequence(" + _eol + " name: \"EntityFrameworkHiLoSequence\"," + _eol + " schema: \"dbo\"," + _eol + @@ -2300,10 +1909,7 @@ public void RestartSequenceOperation_all_args() public void SqlOperation_required_args() { Test( - new SqlOperation - { - Sql = "-- I <3 DDL" - }, + new SqlOperation { Sql = "-- I <3 DDL" }, "mb.Sql(\"-- I <3 DDL\");", o => Assert.Equal("-- I <3 DDL", o.Sql)); } @@ -2321,10 +1927,7 @@ public void SqlOperation_required_args() }; private static readonly MultiPoint _multiPoint = new MultiPoint( - new Point[] { new Point(1.1, 2.2), new Point(2.2, 2.2), new Point(2.2, 1.1) }) - { - SRID = 4326 - }; + 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 Polygon( new LinearRing( @@ -2340,22 +1943,13 @@ public void SqlOperation_required_args() SRID = 4326 }; - private static readonly Point _point1 = new Point(1.1, 2.2, 3.3) - { - SRID = 4326 - }; + private static readonly Point _point1 = new Point(1.1, 2.2, 3.3) { SRID = 4326 }; private static readonly MultiLineString _multiLineString = new MultiLineString( - new LineString[] { _lineString1, _lineString2 }) - { - SRID = 4326 - }; + new[] { _lineString1, _lineString2 }) { SRID = 4326 }; private static readonly MultiPolygon _multiPolygon = new MultiPolygon( - new Polygon[] { _polygon2, _polygon1 }) - { - SRID = 4326 - }; + new[] { _polygon2, _polygon1 }) { SRID = 4326 }; private static readonly GeometryCollection _geometryCollection = new GeometryCollection( new Geometry[] { _lineString1, _lineString2, _multiPoint, _polygon1, _polygon2, _point1, _multiLineString, _multiPolygon }) @@ -2428,13 +2022,7 @@ public void InsertDataOperation_all_args() public void InsertDataOperation_required_args() { Test( - new InsertDataOperation - { - Table = "People", - Columns = new[] { "Geometry" }, - Values = new object[,] - { { _point1 } } - }, + new InsertDataOperation { Table = "People", Columns = new[] { "Geometry" }, Values = new object[,] { { _point1 } } }, "mb.InsertData(" + _eol + " table: \"People\"," + _eol + " column: \"Geometry\"," + _eol + @@ -2457,8 +2045,7 @@ public void InsertDataOperation_required_args_composite() { Table = "People", Columns = new[] { "First Name", "Last Name", "Geometry" }, - Values = new object[,] - { { "John", "Snow", _polygon1 } } + Values = new object[,] { { "John", "Snow", _polygon1 } } }, "mb.InsertData(" + _eol + " table: \"People\"," + _eol + @@ -2481,13 +2068,7 @@ public void InsertDataOperation_required_args_multiple_rows() Test( new InsertDataOperation { - Table = "People", - Columns = new[] { "Geometries" }, - Values = new object[,] - { - { _lineString1 }, - { _multiPoint } - } + Table = "People", Columns = new[] { "Geometries" }, Values = new object[,] { { _lineString1 }, { _multiPoint } } }, "mb.InsertData(" + _eol + " table: \"People\"," + _eol + @@ -2519,14 +2100,7 @@ public void DeleteDataOperation_all_args() Schema = "dbo", Table = "People", KeyColumns = new[] { "First Name" }, - KeyValues = new object[,] - { - { "Hodor" }, - { "Daenerys" }, - { "John" }, - { "Arya" }, - { "Harry" } - } + KeyValues = new object[,] { { "Hodor" }, { "Daenerys" }, { "John" }, { "Arya" }, { "Harry" } } }, "mb.DeleteData(" + _eol + " schema: \"dbo\"," + _eol + @@ -2593,13 +2167,7 @@ public void DeleteDataOperation_all_args_composite() public void DeleteDataOperation_required_args() { Test( - new DeleteDataOperation - { - Table = "People", - KeyColumns = new[] { "Last Name" }, - KeyValues = new object[,] - { { "Snow" } } - }, + new DeleteDataOperation { Table = "People", KeyColumns = new[] { "Last Name" }, KeyValues = new object[,] { { "Snow" } } }, "mb.DeleteData(" + _eol + " table: \"People\"," + _eol + " keyColumn: \"Last Name\"," + _eol + @@ -2620,10 +2188,7 @@ public void DeleteDataOperation_required_args_composite() Test( new DeleteDataOperation { - Table = "People", - KeyColumns = new[] { "First Name", "Last Name" }, - KeyValues = new object[,] - { { "John", "Snow" } } + Table = "People", KeyColumns = new[] { "First Name", "Last Name" }, KeyValues = new object[,] { { "John", "Snow" } } }, "mb.DeleteData(" + _eol + " table: \"People\"," + _eol + @@ -2648,17 +2213,9 @@ public void UpdateDataOperation_all_args() Schema = "dbo", Table = "People", KeyColumns = new[] { "First Name" }, - KeyValues = new object[,] - { - { "Hodor" }, - { "Daenerys" } - }, + KeyValues = new object[,] { { "Hodor" }, { "Daenerys" } }, Columns = new[] { "Birthplace", "House Allegiance", "Culture" }, - Values = new object[,] - { - { "Winterfell", "Stark", "Northmen" }, - { "Dragonstone", "Targaryen", "Valyrian" } - } + Values = new object[,] { { "Winterfell", "Stark", "Northmen" }, { "Dragonstone", "Targaryen", "Valyrian" } } }, "mb.UpdateData(" + _eol + " schema: \"dbo\"," + _eol + @@ -2698,17 +2255,9 @@ public void UpdateDataOperation_all_args_composite() { Table = "People", KeyColumns = new[] { "First Name", "Last Name" }, - KeyValues = new object[,] - { - { "Hodor", null }, - { "Daenerys", "Targaryen" } - }, + KeyValues = new object[,] { { "Hodor", null }, { "Daenerys", "Targaryen" } }, Columns = new[] { "House Allegiance" }, - Values = new object[,] - { - { "Stark" }, - { "Targaryen" } - } + Values = new object[,] { { "Stark" }, { "Targaryen" } } }, "mb.UpdateData(" + _eol + " table: \"People\"," + _eol + @@ -2746,17 +2295,9 @@ public void UpdateDataOperation_all_args_composite_multi() { Table = "People", KeyColumns = new[] { "First Name", "Last Name" }, - KeyValues = new object[,] - { - { "Hodor", null }, - { "Daenerys", "Targaryen" } - }, + KeyValues = new object[,] { { "Hodor", null }, { "Daenerys", "Targaryen" } }, Columns = new[] { "Birthplace", "House Allegiance", "Culture" }, - Values = new object[,] - { - { "Winterfell", "Stark", "Northmen" }, - { "Dragonstone", "Targaryen", "Valyrian" } - } + Values = new object[,] { { "Winterfell", "Stark", "Northmen" }, { "Dragonstone", "Targaryen", "Valyrian" } } }, "mb.UpdateData(" + _eol + " table: \"People\"," + _eol + @@ -2795,11 +2336,9 @@ public void UpdateDataOperation_all_args_multi() Schema = "dbo", Table = "People", KeyColumns = new[] { "Full Name" }, - KeyValues = new object[,] - { { "Daenerys Targaryen" } }, + KeyValues = new object[,] { { "Daenerys Targaryen" } }, Columns = new[] { "Birthplace", "House Allegiance", "Culture" }, - Values = new object[,] - { { "Dragonstone", "Targaryen", "Valyrian" } } + Values = new object[,] { { "Dragonstone", "Targaryen", "Valyrian" } } }, "mb.UpdateData(" + _eol + " schema: \"dbo\"," + _eol + @@ -2831,11 +2370,9 @@ public void UpdateDataOperation_required_args() { Table = "People", KeyColumns = new[] { "First Name" }, - KeyValues = new object[,] - { { "Daenerys" } }, + KeyValues = new object[,] { { "Daenerys" } }, Columns = new[] { "House Allegiance" }, - Values = new object[,] - { { "Targaryen" } } + Values = new object[,] { { "Targaryen" } } }, "mb.UpdateData(" + _eol + " table: \"People\"," + _eol + @@ -2865,17 +2402,9 @@ public void UpdateDataOperation_required_args_multiple_rows() { Table = "People", KeyColumns = new[] { "First Name" }, - KeyValues = new object[,] - { - { "Hodor" }, - { "Daenerys" } - }, + KeyValues = new object[,] { { "Hodor" }, { "Daenerys" } }, Columns = new[] { "House Allegiance" }, - Values = new object[,] - { - { "Stark" }, - { "Targaryen" } - } + Values = new object[,] { { "Stark" }, { "Targaryen" } } }, "mb.UpdateData(" + _eol + " table: \"People\"," + _eol + @@ -2913,11 +2442,9 @@ public void UpdateDataOperation_required_args_composite() { Table = "People", KeyColumns = new[] { "First Name", "Last Name" }, - KeyValues = new object[,] - { { "Daenerys", "Targaryen" } }, + KeyValues = new object[,] { { "Daenerys", "Targaryen" } }, Columns = new[] { "House Allegiance" }, - Values = new object[,] - { { "Targaryen" } } + Values = new object[,] { { "Targaryen" } } }, "mb.UpdateData(" + _eol + " table: \"People\"," + _eol + @@ -2947,11 +2474,9 @@ public void UpdateDataOperation_required_args_composite_multi() { Table = "People", KeyColumns = new[] { "First Name", "Last Name" }, - KeyValues = new object[,] - { { "Daenerys", "Targaryen" } }, + KeyValues = new object[,] { { "Daenerys", "Targaryen" } }, Columns = new[] { "Birthplace", "House Allegiance", "Culture" }, - Values = new object[,] - { { "Dragonstone", "Targaryen", "Valyrian" } } + Values = new object[,] { { "Dragonstone", "Targaryen", "Valyrian" } } }, "mb.UpdateData(" + _eol + " table: \"People\"," + _eol + @@ -2981,11 +2506,9 @@ public void UpdateDataOperation_required_args_multi() { Table = "People", KeyColumns = new[] { "Full Name" }, - KeyValues = new object[,] - { { "Daenerys Targaryen" } }, + KeyValues = new object[,] { { "Daenerys Targaryen" } }, Columns = new[] { "Birthplace", "House Allegiance", "Culture" }, - Values = new object[,] - { { "Dragonstone", "Targaryen", "Valyrian" } } + Values = new object[,] { { "Dragonstone", "Targaryen", "Valyrian" } } }, "mb.UpdateData(" + _eol + " table: \"People\"," + _eol + @@ -3017,7 +2540,9 @@ private void Test(T operation, string expectedCode, Action assert) TestServiceFactory.Instance.Create(), new RelationalTypeMappingSourceDependencies( new IRelationalTypeMappingSourcePlugin[] - { new SqlServerNetTopologySuiteTypeMappingSourcePlugin(NtsGeometryServices.Instance) }))))); + { + new SqlServerNetTopologySuiteTypeMappingSourcePlugin(NtsGeometryServices.Instance) + }))))); var builder = new IndentedStringBuilder(); generator.Generate("mb", new[] { operation }, builder); @@ -3029,8 +2554,7 @@ private void Test(T operation, string expectedCode, Action assert) { References = { - BuildReference.ByName("Microsoft.EntityFrameworkCore.Relational"), - BuildReference.ByName("NetTopologySuite") + BuildReference.ByName("Microsoft.EntityFrameworkCore.Relational"), BuildReference.ByName("NetTopologySuite") }, Sources = { diff --git a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs index 764deaa6dca..abefd22fcc6 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs @@ -81,29 +81,25 @@ public void Test_new_annotations_handled_for_entity_types() ("MyTable", _nl + "modelBuilder." + nameof(RelationalEntityTypeBuilderExtensions.ToTable) + @"(""MyTable"");" + _nl) }, { - RelationalAnnotationNames.Schema, - ("MySchema", + RelationalAnnotationNames.Schema, ("MySchema", _nl + "modelBuilder." + nameof(RelationalEntityTypeBuilderExtensions.ToTable) + @"(""WithAnnotations"",""MySchema"");" + _nl) }, { - CoreAnnotationNames.DiscriminatorProperty, - ("Id", + CoreAnnotationNames.DiscriminatorProperty, ("Id", _toTable + _nl + "modelBuilder.HasDiscriminator" + @"(""Id"");" + _nl) }, { - CoreAnnotationNames.DiscriminatorValue, - ("MyDiscriminatorValue", + CoreAnnotationNames.DiscriminatorValue, ("MyDiscriminatorValue", _toTable + _nl + "modelBuilder.HasDiscriminator" + "()." + nameof(DiscriminatorBuilder.HasValue) + @"(""MyDiscriminatorValue"");" + _nl) }, { - RelationalAnnotationNames.Comment, - ("My Comment", + RelationalAnnotationNames.Comment, ("My Comment", _toTable + _nl + "modelBuilder.HasComment" + @"(""My Comment"");" + _nl) - }, + } }; MissingAnnotationCheck( @@ -150,17 +146,10 @@ public void Test_new_annotations_handled_for_properties() // Note that other tests should be added to check code is generated correctly var forProperty = new Dictionary { + { CoreAnnotationNames.MaxLength, (256, $@"{columnMapping}{_nl}.{nameof(PropertyBuilder.HasMaxLength)}(256)") }, + { CoreAnnotationNames.Unicode, (false, $@"{columnMapping}{_nl}.{nameof(PropertyBuilder.IsUnicode)}(false)") }, { - CoreAnnotationNames.MaxLength, - (256, $@"{columnMapping}{_nl}.{nameof(PropertyBuilder.HasMaxLength)}(256)") - }, - { - CoreAnnotationNames.Unicode, - (false, $@"{columnMapping}{_nl}.{nameof(PropertyBuilder.IsUnicode)}(false)") - }, - { - CoreAnnotationNames.ValueConverter, - (new ValueConverter(v => v, v => (int)v), + CoreAnnotationNames.ValueConverter, (new ValueConverter(v => v, v => (int)v), $@"{_nl}.{nameof(RelationalPropertyBuilderExtensions.HasColumnType)}(""default_long_mapping"")") }, { @@ -231,7 +220,8 @@ private static void MissingAnnotationCheck( { var annotationName = (string)field.GetValue(null); - Assert.True(CoreAnnotationNames.AllNames.Contains(annotationName), + Assert.True( + CoreAnnotationNames.AllNames.Contains(annotationName), nameof(CoreAnnotationNames) + "." + nameof(CoreAnnotationNames.AllNames) + " doesn't contain " + annotationName); } @@ -378,27 +368,15 @@ public void Migrations_compile() "MyMigration", new MigrationOperation[] { - new SqlOperation - { - Sql = "-- TEST", - ["Some:EnumValue"] = RegexOptions.Multiline - }, + new SqlOperation { Sql = "-- TEST", ["Some:EnumValue"] = RegexOptions.Multiline }, new AlterColumnOperation { Name = "C2", Table = "T1", ClrType = typeof(Database), - OldColumn = new ColumnOperation - { - ClrType = typeof(Property) - } + OldColumn = new ColumnOperation { ClrType = typeof(Property) } }, - new AddColumnOperation - { - Name = "C3", - Table = "T1", - ClrType = typeof(PropertyEntry) - } + new AddColumnOperation { Name = "C3", Table = "T1", ClrType = typeof(PropertyEntry) } }, Array.Empty()); Assert.Equal( @@ -444,11 +422,7 @@ protected override void Down(MigrationBuilder migrationBuilder) typeof(MyContext), "MyMigration", "20150511161616_MyMigration", - new Model - { - ["Some:EnumValue"] = RegexOptions.Multiline, - ["Relational:DbFunction:MyFunc"] = new object() - }); + new Model { ["Some:EnumValue"] = RegexOptions.Multiline, ["Relational:DbFunction:MyFunc"] = new object() }); Assert.Equal( @"// using System.Text.RegularExpressions; @@ -485,11 +459,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) BuildReference.ByName("Microsoft.EntityFrameworkCore"), BuildReference.ByName("Microsoft.EntityFrameworkCore.Relational") }, - Sources = - { - migrationCode, - migrationMetadataCode - } + Sources = { migrationCode, migrationMetadataCode } }; var assembly = build.BuildInMemory(); @@ -776,10 +746,7 @@ private ModelSnapshot CompileModelSnapshot(string modelSnapshotCode, string mode BuildReference.ByName("Microsoft.EntityFrameworkCore"), BuildReference.ByName("Microsoft.EntityFrameworkCore.Relational") }, - Sources = - { - modelSnapshotCode - } + Sources = { modelSnapshotCode } }; var assembly = build.BuildInMemory(); @@ -811,11 +778,7 @@ public void Namespaces_imported_for_insert_data() { Table = "MyTable", Columns = new[] { "Id", "MyColumn" }, - Values = new object[,] - { - { 1, null }, - { 2, RegexOptions.Multiline } - } + Values = new object[,] { { 1, null }, { 2, RegexOptions.Multiline } } } }, Array.Empty()); @@ -883,9 +846,7 @@ public void Namespaces_imported_for_delete_data() { new DeleteDataOperation { - Table = "MyTable", - KeyColumns = new[] { "Id" }, - KeyValues = new object[,] { { RegexOptions.Multiline } } + Table = "MyTable", KeyColumns = new[] { "Id" }, KeyValues = new object[,] { { RegexOptions.Multiline } } } }, Array.Empty()); diff --git a/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs b/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs index e365f587b8d..94bcfa02541 100644 --- a/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs +++ b/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs @@ -657,11 +657,7 @@ public virtual void Primary_key_is_stored_in_snapshot() builder => { builder.Entity().HasKey( - t => new - { - t.Id, - t.AlternateId - }); + t => new { t.Id, t.AlternateId }); builder.Ignore(); }, AddBoilerPlate( @@ -706,7 +702,8 @@ public void HasNoKey_is_handled() o => { var entityType = Assert.Single(o.GetEntityTypes()); - Assert.Equal("Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithOneProperty", entityType.Name); + Assert.Equal( + "Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithOneProperty", entityType.Name); Assert.Null(entityType.FindPrimaryKey()); }); } @@ -718,11 +715,7 @@ public virtual void Alternate_keys_are_stored_in_snapshot() builder => { builder.Entity().HasAlternateKey( - t => new - { - t.Id, - t.AlternateId - }); + t => new { t.Id, t.AlternateId }); builder.Ignore(); }, AddBoilerPlate( @@ -794,11 +787,7 @@ public virtual void Indexes_are_stored_in_snapshot_including_composite_index() builder => { builder.Entity().HasIndex( - t => new - { - t.Id, - t.AlternateId - }); + t => new { t.Id, t.AlternateId }); builder.Ignore(); }, AddBoilerPlate( @@ -1087,25 +1076,18 @@ public virtual void Owned_types_are_stored_in_snapshot() { eb.HasKey(e => e.AlternateId).HasName("PK_Custom"); eb.WithOwner(e => e.EntityWithOneProperty) - .HasForeignKey(e => e.AlternateId) - .HasConstraintName("FK_Custom"); + .HasForeignKey(e => e.AlternateId) + .HasConstraintName("FK_Custom"); eb.HasIndex(e => e.Id); eb.HasOne(e => e.EntityWithStringKey).WithOne(); eb.HasData( - new EntityWithTwoProperties - { - AlternateId = 1, - Id = -1 - }); + new EntityWithTwoProperties { AlternateId = 1, Id = -1 }); }); b.HasData( - new EntityWithOneProperty - { - Id = 1 - }); + new EntityWithOneProperty { Id = 1 }); }); builder.Entity( @@ -1628,7 +1610,7 @@ public virtual void Property_unicodeness_is_stored_in_snapshot() public virtual void Property_fixedlengthness_is_stored_in_snapshot() { Test( - builder => builder.Entity().Property("Name").IsFixedLength(true), + builder => builder.Entity().Property("Name").IsFixedLength(), AddBoilerPlate( GetHeading() + @" modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithStringProperty"", b => @@ -1901,11 +1883,7 @@ public virtual void Property_enum_type_is_stored_in_snapshot_with_custom_convers eb.Property(e => e.Day).HasDefaultValue(Days.Wed) .HasConversion(v => v.ToString(), v => (Days)Enum.Parse(typeof(Days), v)); eb.HasData( - new - { - Id = 1, - Day = Days.Fri - }); + new { Id = 1, Day = Days.Fri }); }), AddBoilerPlate( GetHeading() + @" @@ -3042,10 +3020,7 @@ static List getAllProperties(IModel model) }; var multiPoint = new MultiPoint( - new Point[] { new Point(1.1, 2.2), new Point(2.2, 2.2), new Point(2.2, 1.1) }) - { - SRID = 4326 - }; + new[] { 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( @@ -3059,27 +3034,15 @@ static List getAllProperties(IModel model) new[] { new Coordinate(10.1, 20.2), new Coordinate(20.2, 20.2), new Coordinate(20.2, 10.1), new Coordinate(10.1, 20.2) - })) - { - SRID = 4326 - }; + })) { SRID = 4326 }; - var point1 = new Point(1.1, 2.2, 3.3) - { - SRID = 4326 - }; + var point1 = new Point(1.1, 2.2, 3.3) { SRID = 4326 }; var multiLineString = new MultiLineString( - new LineString[] { lineString1, lineString2 }) - { - SRID = 4326 - }; + new[] { lineString1, lineString2 }) { SRID = 4326 }; var multiPolygon = new MultiPolygon( - new Polygon[] { polygon2, polygon1 }) - { - SRID = 4326 - }; + new[] { polygon2, polygon1 }) { SRID = 4326 }; var geometryCollection = new GeometryCollection( new Geometry[] { lineString1, lineString2, multiPoint, polygon1, polygon2, point1, multiLineString, multiPolygon }) @@ -3438,10 +3401,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) Assert.Equal(42, seed["Id"]); Assert.Equal("FortyThree", seed["String"]); Assert.Equal( - new byte[] - { - 44, 45 - }, seed["Bytes"]); + new byte[] { 44, 45 }, seed["Bytes"]); Assert.Equal((short)46, seed["Int16"]); Assert.Equal(47, seed["Int32"]); Assert.Equal((long)48, seed["Int64"]); @@ -3503,10 +3463,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) Assert.Equal(43, seed["Id"]); Assert.Equal("FortyThree", seed["String"]); Assert.Equal( - new byte[] - { - 44, 45 - }, seed["Bytes"]); + new byte[] { 44, 45 }, seed["Bytes"]); Assert.Equal((short)-46, seed["Int16"]); Assert.Equal(-47, seed["Int32"]); Assert.Equal((long)-48, seed["Int64"]); @@ -3542,7 +3499,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) protected virtual string GetHeading(bool empty = false) => @" modelBuilder .HasAnnotation(""Relational:MaxIdentifierLength"", 128) - .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn);" + (empty ? null : @" + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn);" + (empty + ? null + : @" "); protected virtual ICollection GetReferences() => new List @@ -3593,7 +3552,9 @@ protected void Test(Action buildModel, string expectedCode, Action TestServiceFactory.Instance.Create(), new RelationalTypeMappingSourceDependencies( new IRelationalTypeMappingSourcePlugin[] - { new SqlServerNetTopologySuiteTypeMappingSourcePlugin(NtsGeometryServices.Instance) })); + { + new SqlServerNetTopologySuiteTypeMappingSourcePlugin(NtsGeometryServices.Instance) + })); var codeHelper = new CSharpHelper( sqlServerTypeMappingSource); @@ -3612,13 +3573,7 @@ protected void Test(Action buildModel, string expectedCode, Action Assert.Equal(expectedCode, code, ignoreLineEndingDifferences: true); - var build = new BuildSource - { - Sources = - { - code - } - }; + var build = new BuildSource { Sources = { code } }; foreach (var buildReference in GetReferences()) { @@ -3652,9 +3607,10 @@ protected ModelBuilder CreateConventionalModelBuilder() var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlServer() .AddEntityFrameworkSqlServerNetTopologySuite() - .AddDbContext((p, o) => - o.UseSqlServer("Server=.", b => b.UseNetTopologySuite()) - .UseInternalServiceProvider(p)) + .AddDbContext( + (p, o) => + o.UseSqlServer("Server=.", b => b.UseNetTopologySuite()) + .UseInternalServiceProvider(p)) .BuildServiceProvider(); using (var serviceScope = serviceProvider.GetRequiredService().CreateScope()) diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs index 6c269c7fcd1..674491e5c4a 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs @@ -70,10 +70,7 @@ public void SuppressConnectionStringWarning_works() { Test( modelBuilder => { }, - new ModelCodeGenerationOptions - { - SuppressConnectionStringWarning = true - }, + new ModelCodeGenerationOptions { SuppressConnectionStringWarning = true }, code => { Assert.Equal( @@ -193,7 +190,8 @@ public void Views_work() modelBuilder => modelBuilder.Entity("Vista").ToView("Vista"), new ModelCodeGenerationOptions { UseDataAnnotations = true }, code => Assert.Contains(".ToView(\"Vista\")", code.ContextFile.Code), - model => Assert.NotNull(model.FindEntityType("TestNamespace.Vista").FindAnnotation(RelationalAnnotationNames.ViewDefinition))); + model => Assert.NotNull( + model.FindEntityType("TestNamespace.Vista").FindAnnotation(RelationalAnnotationNames.ViewDefinition))); } private class TestCodeGeneratorPlugin : ProviderCodeGeneratorPlugin diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpEntityTypeGeneratorTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpEntityTypeGeneratorTest.cs index 774f1e4d991..ca01106bede 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpEntityTypeGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpEntityTypeGeneratorTest.cs @@ -28,10 +28,7 @@ public void Navigation_properties() x.HasOne("Person", "Author").WithMany("Posts"); x.HasMany("Contribution", "Contributions").WithOne(); }), - new ModelCodeGenerationOptions - { - UseDataAnnotations = true - }, + new ModelCodeGenerationOptions { UseDataAnnotations = true }, code => { var postFile = code.AdditionalFiles.First(f => f.Path == "Post.cs"); @@ -144,10 +141,7 @@ public void Composite_key() x.Property("Serial"); x.HasKey("Key", "Serial"); }), - new ModelCodeGenerationOptions - { - UseDataAnnotations = true - }, + new ModelCodeGenerationOptions { UseDataAnnotations = true }, code => { var postFile = code.AdditionalFiles.First(f => f.Path == "Post.cs"); diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpUniqueNamerTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpUniqueNamerTest.cs index 734cb07360b..4fd7960f44d 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpUniqueNamerTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpUniqueNamerTest.cs @@ -14,14 +14,8 @@ public class CSharpUniqueNamerTest public void Returns_unique_name_for_type() { var namer = new CSharpUniqueNamer(s => s.Name, new CSharpUtilities(), null); - var input1 = new DatabaseColumn - { - Name = "Id" - }; - var input2 = new DatabaseColumn - { - Name = "Id" - }; + var input1 = new DatabaseColumn { Name = "Id" }; + var input2 = new DatabaseColumn { Name = "Id" }; Assert.Equal("Id", namer.GetName(input1)); Assert.Equal("Id", namer.GetName(input1)); @@ -33,14 +27,8 @@ public void Returns_unique_name_for_type() public void Uses_comparer() { var namer = new CSharpUniqueNamer(t => t.Name, new CSharpUtilities(), null); - var table1 = new DatabaseTable - { - Name = "A B C" - }; - var table2 = new DatabaseTable - { - Name = "A_B_C" - }; + var table1 = new DatabaseTable { Name = "A B C" }; + var table2 = new DatabaseTable { Name = "A_B_C" }; Assert.Equal("A_B_C", namer.GetName(table1)); Assert.Equal("A_B_C1", namer.GetName(table2)); } @@ -52,10 +40,7 @@ public void Singularizes_names(string input, string output) { var fakePluralizer = new RelationalDatabaseModelFactoryTest.FakePluralizer(); var namer = new CSharpUniqueNamer(t => t.Name, new CSharpUtilities(), fakePluralizer.Singularize); - var table = new DatabaseTable - { - Name = input - }; + var table = new DatabaseTable { Name = input }; Assert.Equal(output, namer.GetName(table)); } @@ -66,10 +51,7 @@ public void Pluralizes_names(string input, string output) { var fakePluralizer = new RelationalDatabaseModelFactoryTest.FakePluralizer(); var namer = new CSharpUniqueNamer(t => t.Name, new CSharpUtilities(), fakePluralizer.Pluralize); - var table = new DatabaseTable - { - Name = input - }; + var table = new DatabaseTable { Name = input }; Assert.Equal(output, namer.GetName(table)); } } diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/CandidateNamingServiceTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/CandidateNamingServiceTest.cs index 064da862cc8..fd9a41fe9a5 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/CandidateNamingServiceTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/CandidateNamingServiceTest.cs @@ -24,10 +24,7 @@ public void Generates_candidate_identifiers(string input, string output) { Assert.Equal( output, new CandidateNamingService().GenerateCandidateIdentifier( - new DatabaseTable - { - Name = input - })); + new DatabaseTable { Name = input })); } } } diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs index 21723b08be0..b59e282bc39 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs @@ -22,19 +22,9 @@ public class RelationalDatabaseModelFactoryTest private readonly IScaffoldingModelFactory _factory; private readonly TestOperationReporter _reporter; - private static DatabaseColumn IdColumn => new DatabaseColumn - { - Name = "Id", - StoreType = "int" - }; + private static DatabaseColumn IdColumn => new DatabaseColumn { Name = "Id", StoreType = "int" }; - private static readonly DatabasePrimaryKey IdPrimaryKey = new DatabasePrimaryKey - { - Columns = - { - IdColumn - } - }; + private static readonly DatabasePrimaryKey IdPrimaryKey = new DatabasePrimaryKey { Columns = { IdColumn } }; public RelationalDatabaseModelFactoryTest() { @@ -59,31 +49,11 @@ public void Creates_entity_types() { new DatabaseTable { - Name = "tableWithSchema", - Schema = "public", - Columns = - { - IdColumn - }, - PrimaryKey = IdPrimaryKey - }, - new DatabaseTable - { - Name = "noSchema", - Columns = - { - IdColumn - }, - PrimaryKey = IdPrimaryKey - }, - new DatabaseTable - { - Name = "noPrimaryKey" + Name = "tableWithSchema", Schema = "public", Columns = { IdColumn }, PrimaryKey = IdPrimaryKey }, - new DatabaseView - { - Name = "view" - } + new DatabaseTable { Name = "noSchema", Columns = { IdColumn }, PrimaryKey = IdPrimaryKey }, + new DatabaseTable { Name = "noPrimaryKey" }, + new DatabaseView { Name = "view" } } }; var model = _factory.Create(info, false); @@ -120,24 +90,8 @@ public void Creates_entity_types_case_insensitive() { Tables = { - new DatabaseTable - { - Name = "TestTable", - Columns = - { - IdColumn - }, - PrimaryKey = IdPrimaryKey - }, - new DatabaseTable - { - Name = "TESTTABLE", - Columns = - { - IdColumn - }, - PrimaryKey = IdPrimaryKey - } + new DatabaseTable { Name = "TestTable", Columns = { IdColumn }, PrimaryKey = IdPrimaryKey }, + new DatabaseTable { Name = "TESTTABLE", Columns = { IdColumn }, PrimaryKey = IdPrimaryKey } } }; var model = _factory.Create(info, false); @@ -159,16 +113,9 @@ public void Loads_column_types() IdColumn, new DatabaseColumn { - Name = "occupation", - StoreType = "nvarchar(max)", - DefaultValueSql = "\"dev\"" - }, - new DatabaseColumn - { - Name = "salary", - StoreType = "int", - IsNullable = true + Name = "occupation", StoreType = "nvarchar(max)", DefaultValueSql = "\"dev\"" }, + new DatabaseColumn { Name = "salary", StoreType = "int", IsNullable = true }, new DatabaseColumn { Name = "modified", @@ -178,15 +125,11 @@ public void Loads_column_types() }, new DatabaseColumn { - Name = "created", - StoreType = "nvarchar(max)", - ValueGenerated = ValueGenerated.OnAdd + Name = "created", StoreType = "nvarchar(max)", ValueGenerated = ValueGenerated.OnAdd }, new DatabaseColumn { - Name = "current", - StoreType = "nvarchar(max)", - ComputedColumnSql = "compute_this()" + Name = "current", StoreType = "nvarchar(max)", ComputedColumnSql = "compute_this()" } }, PrimaryKey = IdPrimaryKey @@ -249,21 +192,9 @@ public void Use_database_names_for_columns() Columns = { IdColumn, - new DatabaseColumn - { - Name = "ProductSKU", - StoreType = "nvarchar(max)" - }, - new DatabaseColumn - { - Name = "supplierID", - StoreType = "nvarchar(max)" - }, - new DatabaseColumn - { - Name = "Vendor_Discount", - StoreType = "nvarchar(max)" - } + new DatabaseColumn { Name = "ProductSKU", StoreType = "nvarchar(max)" }, + new DatabaseColumn { Name = "supplierID", StoreType = "nvarchar(max)" }, + new DatabaseColumn { Name = "Vendor_Discount", StoreType = "nvarchar(max)" } }, PrimaryKey = IdPrimaryKey } @@ -293,21 +224,9 @@ public void Do_not_use_database_names_for_columns() Columns = { IdColumn, - new DatabaseColumn - { - Name = "ProductSKU", - StoreType = "nvarchar(max)" - }, - new DatabaseColumn - { - Name = "supplierID", - StoreType = "nvarchar(max)" - }, - new DatabaseColumn - { - Name = "Vendor_Discount", - StoreType = "nvarchar(max)" - } + new DatabaseColumn { Name = "ProductSKU", StoreType = "nvarchar(max)" }, + new DatabaseColumn { Name = "supplierID", StoreType = "nvarchar(max)" }, + new DatabaseColumn { Name = "Vendor_Discount", StoreType = "nvarchar(max)" } }, PrimaryKey = IdPrimaryKey } @@ -329,11 +248,7 @@ public void Do_not_use_database_names_for_columns() [InlineData("datetime2(4)", "datetime2(4)")] public void Column_type_annotation(string StoreType, string expectedColumnType) { - var column = new DatabaseColumn - { - Name = "Col", - StoreType = StoreType - }; + var column = new DatabaseColumn { Name = "Col", StoreType = StoreType }; var info = new DatabaseModel { @@ -341,18 +256,7 @@ public void Column_type_annotation(string StoreType, string expectedColumnType) { new DatabaseTable { - Name = "A", - Columns = - { - column - }, - PrimaryKey = new DatabasePrimaryKey - { - Columns = - { - column - } - } + Name = "A", Columns = { column }, PrimaryKey = new DatabasePrimaryKey { Columns = { column } } } } }; @@ -365,11 +269,7 @@ public void Column_type_annotation(string StoreType, string expectedColumnType) [ConditionalFact] public void Column_ordinal_annotation() { - var col1 = new DatabaseColumn - { - Name = "Col1", - StoreType = "nvarchar(max)" - }; + var col1 = new DatabaseColumn { Name = "Col1", StoreType = "nvarchar(max)" }; var info = new DatabaseModel { Tables = @@ -380,24 +280,10 @@ public void Column_ordinal_annotation() Columns = { col1, - new DatabaseColumn - { - Name = "Col2", - StoreType = "nvarchar(max)" - }, - new DatabaseColumn - { - Name = "Col3", - StoreType = "nvarchar(max)" - } + new DatabaseColumn { Name = "Col2", StoreType = "nvarchar(max)" }, + new DatabaseColumn { Name = "Col3", StoreType = "nvarchar(max)" } }, - PrimaryKey = new DatabasePrimaryKey - { - Columns = - { - col1 - } - } + PrimaryKey = new DatabasePrimaryKey { Columns = { col1 } } } } }; @@ -419,28 +305,12 @@ public void Unmappable_column_type(string StoreType) { var info = new DatabaseModel { - Tables = - { - new DatabaseTable - { - Name = "E", - Columns = - { - IdColumn - }, - PrimaryKey = IdPrimaryKey - } - } + Tables = { new DatabaseTable { Name = "E", Columns = { IdColumn }, PrimaryKey = IdPrimaryKey } } }; info.Tables.First() .Columns.Add( - new DatabaseColumn - { - Table = info.Tables.First(), - Name = "Coli", - StoreType = StoreType - }); + new DatabaseColumn { Table = info.Tables.First(), Name = "Coli", StoreType = StoreType }); Assert.Single(_factory.Create(info, false).FindEntityType("E").GetProperties()); Assert.Single(_reporter.Messages, t => t.Contains(DesignStrings.CannotFindTypeMappingForColumn("E.Coli", StoreType))); @@ -454,21 +324,10 @@ public void Primary_key(string[] keyProps, int length) { var info = new DatabaseModel { - Tables = - { - new DatabaseTable - { - Name = "PkTable", - PrimaryKey = new DatabasePrimaryKey { Name = "MyPk" } - } - } + Tables = { new DatabaseTable { Name = "PkTable", PrimaryKey = new DatabasePrimaryKey { Name = "MyPk" } } } }; foreach (var column in keyProps.Select( - k => new DatabaseColumn - { - Name = k, - StoreType = "int" - })) + k => new DatabaseColumn { Name = k, StoreType = "int" })) { info.Tables[0].Columns.Add(column); info.Tables[0].PrimaryKey.Columns.Add(column); @@ -483,11 +342,7 @@ public void Primary_key(string[] keyProps, int length) [ConditionalFact] public void Unique_constraint() { - var myColumn = new DatabaseColumn - { - Name = "MyColumn", - StoreType = "int" - }; + var myColumn = new DatabaseColumn { Name = "MyColumn", StoreType = "int" }; var databaseModel = new DatabaseModel { @@ -496,19 +351,11 @@ public void Unique_constraint() new DatabaseTable { Name = "MyTable", - Columns = - { - IdColumn, - myColumn - }, + Columns = { IdColumn, myColumn }, PrimaryKey = IdPrimaryKey, UniqueConstraints = { - new DatabaseUniqueConstraint - { - Name = "MyUniqueConstraint", - Columns = { myColumn } - } + new DatabaseUniqueConstraint { Name = "MyUniqueConstraint", Columns = { myColumn } } } } } @@ -525,86 +372,33 @@ public void Unique_constraint() [ConditionalFact] public void Indexes_and_alternate_keys() { - var c1 = new DatabaseColumn - { - Name = "C1", - StoreType = "int" - }; + var c1 = new DatabaseColumn { Name = "C1", StoreType = "int" }; var table = new DatabaseTable { Name = "T", Columns = { - c1, - new DatabaseColumn - { - Name = "C2", - StoreType = "int" - }, - new DatabaseColumn - { - Name = "C3", - StoreType = "int" - } + c1, new DatabaseColumn { Name = "C2", StoreType = "int" }, new DatabaseColumn { Name = "C3", StoreType = "int" } }, - PrimaryKey = new DatabasePrimaryKey - { - Columns = - { - c1 - } - } + PrimaryKey = new DatabasePrimaryKey { Columns = { c1 } } }; table.Indexes.Add( - new DatabaseIndex - { - Name = "IDX_C1", - Columns = - { - table.Columns.ElementAt(0) - }, - IsUnique = false - }); + new DatabaseIndex { Name = "IDX_C1", Columns = { table.Columns.ElementAt(0) }, IsUnique = false }); table.Indexes.Add( - new DatabaseIndex - { - Name = "UNQ_C2", - Columns = - { - table.Columns.ElementAt(1) - }, - IsUnique = true - }); + new DatabaseIndex { Name = "UNQ_C2", Columns = { table.Columns.ElementAt(1) }, IsUnique = true }); table.Indexes.Add( new DatabaseIndex { - Name = "IDX_C2_C1", - Columns = - { - table.Columns.ElementAt(1), - table.Columns.ElementAt(0) - }, - IsUnique = false + Name = "IDX_C2_C1", Columns = { table.Columns.ElementAt(1), table.Columns.ElementAt(0) }, IsUnique = false }); table.Indexes.Add( new DatabaseIndex { /*Name ="UNQ_C3_C1",*/ - Columns = - { - table.Columns.ElementAt(2), - table.Columns.ElementAt(0) - }, - IsUnique = true + Columns = { table.Columns.ElementAt(2), table.Columns.ElementAt(0) }, IsUnique = true }); - var info = new DatabaseModel - { - Tables = - { - table - } - }; + var info = new DatabaseModel { Tables = { table } }; var entityType = (EntityType)_factory.Create(info, false).GetEntityTypes().Single(); @@ -640,28 +434,11 @@ public void Indexes_and_alternate_keys() [ConditionalFact] public void Foreign_key() { - var parentTable = new DatabaseTable - { - Name = "Parent", - Columns = - { - IdColumn - }, - PrimaryKey = IdPrimaryKey - }; + var parentTable = new DatabaseTable { Name = "Parent", Columns = { IdColumn }, PrimaryKey = IdPrimaryKey }; var childrenTable = new DatabaseTable { Name = "Children", - Columns = - { - IdColumn, - new DatabaseColumn - { - Name = "ParentId", - StoreType = "int", - IsNullable = true - } - }, + Columns = { IdColumn, new DatabaseColumn { Name = "ParentId", StoreType = "int", IsNullable = true } }, PrimaryKey = IdPrimaryKey }; childrenTable.ForeignKeys.Add( @@ -670,25 +447,12 @@ public void Foreign_key() Table = childrenTable, PrincipalTable = parentTable, OnDelete = ReferentialAction.Cascade, - Columns = - { - childrenTable.Columns.ElementAt(1) - }, - PrincipalColumns = - { - parentTable.Columns.ElementAt(0) - } + Columns = { childrenTable.Columns.ElementAt(1) }, + PrincipalColumns = { parentTable.Columns.ElementAt(0) } }); var model = _factory.Create( - new DatabaseModel - { - Tables = - { - parentTable, - childrenTable - } - }, + new DatabaseModel { Tables = { parentTable, childrenTable } }, false); var parent = (EntityType)model.FindEntityType("Parent"); @@ -709,43 +473,14 @@ public void Foreign_key() [ConditionalFact] public void Foreign_key_to_unique_constraint() { - var keyColumn = new DatabaseColumn - { - Name = "Key", - StoreType = "int", - IsNullable = false - }; + var keyColumn = new DatabaseColumn { Name = "Key", StoreType = "int", IsNullable = false }; - var parentTable = new DatabaseTable - { - Name = "Parent", - Columns = - { - IdColumn, - keyColumn - }, - PrimaryKey = IdPrimaryKey - }; + var parentTable = new DatabaseTable { Name = "Parent", Columns = { IdColumn, keyColumn }, PrimaryKey = IdPrimaryKey }; parentTable.UniqueConstraints.Add( - new DatabaseUniqueConstraint - { - Table = parentTable, - Columns = - { - keyColumn - } - }); + new DatabaseUniqueConstraint { Table = parentTable, Columns = { keyColumn } }); - var childrenTable = new DatabaseTable - { - Name = "Children", - Columns = - { - IdColumn - }, - PrimaryKey = IdPrimaryKey - }; + var childrenTable = new DatabaseTable { Name = "Children", Columns = { IdColumn }, PrimaryKey = IdPrimaryKey }; childrenTable.ForeignKeys.Add( new DatabaseForeignKey @@ -753,25 +488,12 @@ public void Foreign_key_to_unique_constraint() Table = childrenTable, PrincipalTable = parentTable, OnDelete = ReferentialAction.Cascade, - Columns = - { - childrenTable.Columns.ElementAt(0) - }, - PrincipalColumns = - { - parentTable.Columns.ElementAt(1) - } + Columns = { childrenTable.Columns.ElementAt(0) }, + PrincipalColumns = { parentTable.Columns.ElementAt(1) } }); var model = _factory.Create( - new DatabaseModel - { - Tables = - { - parentTable, - childrenTable - } - }, + new DatabaseModel { Tables = { parentTable, childrenTable } }, false); var parent = (EntityType)model.FindEntityType("Parent"); @@ -792,49 +514,20 @@ public void Foreign_key_to_unique_constraint() [ConditionalFact] public void Unique_foreign_key() { - var parentTable = new DatabaseTable - { - Name = "Parent", - Columns = - { - IdColumn - }, - PrimaryKey = IdPrimaryKey - }; - var childrenTable = new DatabaseTable - { - Name = "Children", - Columns = - { - IdColumn - }, - PrimaryKey = IdPrimaryKey - }; + var parentTable = new DatabaseTable { Name = "Parent", Columns = { IdColumn }, PrimaryKey = IdPrimaryKey }; + var childrenTable = new DatabaseTable { Name = "Children", Columns = { IdColumn }, PrimaryKey = IdPrimaryKey }; childrenTable.ForeignKeys.Add( new DatabaseForeignKey { Table = childrenTable, PrincipalTable = parentTable, OnDelete = ReferentialAction.NoAction, - Columns = - { - childrenTable.Columns.ElementAt(0) - }, - PrincipalColumns = - { - parentTable.Columns.ElementAt(0) - } + Columns = { childrenTable.Columns.ElementAt(0) }, + PrincipalColumns = { parentTable.Columns.ElementAt(0) } }); var model = _factory.Create( - new DatabaseModel - { - Tables = - { - parentTable, - childrenTable - } - }, + new DatabaseModel { Tables = { parentTable, childrenTable } }, false); var children = (EntityType)model.FindEntityType("Children"); @@ -847,32 +540,11 @@ public void Unique_foreign_key() [ConditionalFact] public void Composite_foreign_key() { - var ida = new DatabaseColumn - { - Name = "Id_A", - StoreType = "int" - }; - var idb = new DatabaseColumn - { - Name = "Id_B", - StoreType = "int" - }; + var ida = new DatabaseColumn { Name = "Id_A", StoreType = "int" }; + var idb = new DatabaseColumn { Name = "Id_B", StoreType = "int" }; var parentTable = new DatabaseTable { - Name = "Parent", - Columns = - { - ida, - idb - }, - PrimaryKey = new DatabasePrimaryKey - { - Columns = - { - ida, - idb - } - } + Name = "Parent", Columns = { ida, idb }, PrimaryKey = new DatabasePrimaryKey { Columns = { ida, idb } } }; var childrenTable = new DatabaseTable { @@ -880,16 +552,8 @@ public void Composite_foreign_key() Columns = { IdColumn, - new DatabaseColumn - { - Name = "ParentId_A", - StoreType = "int" - }, - new DatabaseColumn - { - Name = "ParentId_B", - StoreType = "int" - } + new DatabaseColumn { Name = "ParentId_A", StoreType = "int" }, + new DatabaseColumn { Name = "ParentId_B", StoreType = "int" } }, PrimaryKey = IdPrimaryKey }; @@ -899,27 +563,12 @@ public void Composite_foreign_key() Table = childrenTable, PrincipalTable = parentTable, OnDelete = ReferentialAction.SetNull, - Columns = - { - childrenTable.Columns.ElementAt(1), - childrenTable.Columns.ElementAt(2) - }, - PrincipalColumns = - { - parentTable.Columns.ElementAt(0), - parentTable.Columns.ElementAt(1) - } + Columns = { childrenTable.Columns.ElementAt(1), childrenTable.Columns.ElementAt(2) }, + PrincipalColumns = { parentTable.Columns.ElementAt(0), parentTable.Columns.ElementAt(1) } }); var model = _factory.Create( - new DatabaseModel - { - Tables = - { - parentTable, - childrenTable - } - }, + new DatabaseModel { Tables = { parentTable, childrenTable } }, false); var parent = (EntityType)model.FindEntityType("Parent"); @@ -945,16 +594,7 @@ public void It_loads_self_referencing_foreign_key() var table = new DatabaseTable { Name = "ItemsList", - Columns = - { - IdColumn, - new DatabaseColumn - { - Name = "ParentId", - StoreType = "int", - IsNullable = false - } - }, + Columns = { IdColumn, new DatabaseColumn { Name = "ParentId", StoreType = "int", IsNullable = false } }, PrimaryKey = IdPrimaryKey }; table.ForeignKeys.Add( @@ -962,24 +602,12 @@ public void It_loads_self_referencing_foreign_key() { Table = table, PrincipalTable = table, - Columns = - { - table.Columns.ElementAt(1) - }, - PrincipalColumns = - { - table.Columns.ElementAt(0) - } + Columns = { table.Columns.ElementAt(1) }, + PrincipalColumns = { table.Columns.ElementAt(0) } }); var model = _factory.Create( - new DatabaseModel - { - Tables = - { - table - } - }, + new DatabaseModel { Tables = { table } }, false); var list = model.FindEntityType("ItemsList"); @@ -997,29 +625,13 @@ public void It_logs_warning_for_bad_foreign_key() var parentTable = new DatabaseTable { Name = "Parent", - Columns = - { - IdColumn, - new DatabaseColumn - { - Name = "NotPkId", - StoreType = "int" - } - }, + Columns = { IdColumn, new DatabaseColumn { Name = "NotPkId", StoreType = "int" } }, PrimaryKey = IdPrimaryKey }; var childrenTable = new DatabaseTable { Name = "Children", - Columns = - { - IdColumn, - new DatabaseColumn - { - Name = "ParentId", - StoreType = "int" - } - }, + Columns = { IdColumn, new DatabaseColumn { Name = "ParentId", StoreType = "int" } }, PrimaryKey = IdPrimaryKey }; childrenTable.ForeignKeys.Add( @@ -1027,25 +639,12 @@ public void It_logs_warning_for_bad_foreign_key() { Table = childrenTable, PrincipalTable = parentTable, - Columns = - { - childrenTable.Columns.ElementAt(1) - }, - PrincipalColumns = - { - parentTable.Columns.ElementAt(1) - } + Columns = { childrenTable.Columns.ElementAt(1) }, + PrincipalColumns = { parentTable.Columns.ElementAt(1) } }); _factory.Create( - new DatabaseModel - { - Tables = - { - parentTable, - childrenTable - } - }, + new DatabaseModel { Tables = { parentTable, childrenTable } }, false); Assert.Single( @@ -1061,50 +660,22 @@ public void Unique_nullable_index_unused_by_foreign_key() var table = new DatabaseTable { Name = "Friends", - Columns = - { - IdColumn, - new DatabaseColumn - { - Name = "BuddyId", - StoreType = "int", - IsNullable = true - } - }, + Columns = { IdColumn, new DatabaseColumn { Name = "BuddyId", StoreType = "int", IsNullable = true } }, PrimaryKey = IdPrimaryKey }; table.Indexes.Add( - new DatabaseIndex - { - Columns = - { - table.Columns.ElementAt(1) - }, - IsUnique = true - }); + new DatabaseIndex { Columns = { table.Columns.ElementAt(1) }, IsUnique = true }); table.ForeignKeys.Add( new DatabaseForeignKey { Table = table, PrincipalTable = table, - Columns = - { - table.Columns.ElementAt(1) - }, - PrincipalColumns = - { - table.Columns.ElementAt(0) - } + Columns = { table.Columns.ElementAt(1) }, + PrincipalColumns = { table.Columns.ElementAt(0) } }); var model = _factory.Create( - new DatabaseModel - { - Tables = - { - table - } - }, + new DatabaseModel { Tables = { table } }, false).FindEntityType("Friends"); var buddyIdProperty = model.FindProperty("BuddyId"); @@ -1124,51 +695,22 @@ public void Unique_nullable_index_used_by_foreign_key() var table = new DatabaseTable { Name = "Friends", - Columns = - { - IdColumn, - new DatabaseColumn - { - Name = "BuddyId", - StoreType = "int", - IsNullable = true - } - }, + Columns = { IdColumn, new DatabaseColumn { Name = "BuddyId", StoreType = "int", IsNullable = true } }, PrimaryKey = IdPrimaryKey }; table.Indexes.Add( - new DatabaseIndex - { - Name = "FriendsNameUniqueIndex", - Columns = - { - table.Columns.ElementAt(1) - }, - IsUnique = true - }); + new DatabaseIndex { Name = "FriendsNameUniqueIndex", Columns = { table.Columns.ElementAt(1) }, IsUnique = true }); table.ForeignKeys.Add( new DatabaseForeignKey { Table = table, PrincipalTable = table, - Columns = - { - table.Columns.ElementAt(1) - }, - PrincipalColumns = - { - table.Columns.ElementAt(1) - } + Columns = { table.Columns.ElementAt(1) }, + PrincipalColumns = { table.Columns.ElementAt(1) } }); var model = _factory.Create( - new DatabaseModel - { - Tables = - { - table - } - }, + new DatabaseModel { Tables = { table } }, false).FindEntityType("Friends"); var buddyIdProperty = model.FindProperty("BuddyId"); @@ -1191,32 +733,11 @@ public void Unique_nullable_index_used_by_foreign_key() [ConditionalFact] public void Unique_index_composite_foreign_key() { - var ida = new DatabaseColumn - { - Name = "Id_A", - StoreType = "int" - }; - var idb = new DatabaseColumn - { - Name = "Id_B", - StoreType = "int" - }; + var ida = new DatabaseColumn { Name = "Id_A", StoreType = "int" }; + var idb = new DatabaseColumn { Name = "Id_B", StoreType = "int" }; var parentTable = new DatabaseTable { - Name = "Parent", - Columns = - { - ida, - idb - }, - PrimaryKey = new DatabasePrimaryKey - { - Columns = - { - ida, - idb - } - } + Name = "Parent", Columns = { ida, idb }, PrimaryKey = new DatabasePrimaryKey { Columns = { ida, idb } } }; var childrenTable = new DatabaseTable { @@ -1224,55 +745,27 @@ public void Unique_index_composite_foreign_key() Columns = { IdColumn, - new DatabaseColumn - { - Name = "ParentId_A", - StoreType = "int" - }, - new DatabaseColumn - { - Name = "ParentId_B", - StoreType = "int" - } + new DatabaseColumn { Name = "ParentId_A", StoreType = "int" }, + new DatabaseColumn { Name = "ParentId_B", StoreType = "int" } }, PrimaryKey = IdPrimaryKey }; childrenTable.Indexes.Add( new DatabaseIndex { - IsUnique = true, - Columns = - { - childrenTable.Columns.ElementAt(1), - childrenTable.Columns.ElementAt(2) - } + IsUnique = true, Columns = { childrenTable.Columns.ElementAt(1), childrenTable.Columns.ElementAt(2) } }); childrenTable.ForeignKeys.Add( new DatabaseForeignKey { Table = childrenTable, PrincipalTable = parentTable, - Columns = - { - childrenTable.Columns.ElementAt(1), - childrenTable.Columns.ElementAt(2) - }, - PrincipalColumns = - { - parentTable.Columns.ElementAt(0), - parentTable.Columns.ElementAt(1) - } + Columns = { childrenTable.Columns.ElementAt(1), childrenTable.Columns.ElementAt(2) }, + PrincipalColumns = { parentTable.Columns.ElementAt(0), parentTable.Columns.ElementAt(1) } }); var model = _factory.Create( - new DatabaseModel - { - Tables = - { - parentTable, - childrenTable - } - }, + new DatabaseModel { Tables = { parentTable, childrenTable } }, false); var parent = model.FindEntityType("Parent"); var children = model.FindEntityType("Children"); @@ -1296,28 +789,12 @@ public void Unique_names() Columns = { IdColumn, - new DatabaseColumn - { - Name = "San itized", - StoreType = "int" - }, - new DatabaseColumn - { - Name = "San+itized", - StoreType = "int" - } + new DatabaseColumn { Name = "San itized", StoreType = "int" }, + new DatabaseColumn { Name = "San+itized", StoreType = "int" } }, PrimaryKey = IdPrimaryKey }, - new DatabaseTable - { - Name = "E+F", - Columns = - { - IdColumn - }, - PrimaryKey = IdPrimaryKey - } + new DatabaseTable { Name = "E+F", Columns = { IdColumn }, PrimaryKey = IdPrimaryKey } } }; @@ -1356,17 +833,7 @@ public void Unique_names() [ConditionalFact] public void Sequences() { - var info = new DatabaseModel - { - Sequences = - { - new DatabaseSequence - { - Name = "CountByThree", - IncrementBy = 3 - } - } - }; + var info = new DatabaseModel { Sequences = { new DatabaseSequence { Name = "CountByThree", IncrementBy = 3 } } }; var model = _factory.Create(info, false); @@ -1388,18 +855,7 @@ public void DbSet_annotation_is_set() { var info = new DatabaseModel { - Tables = - { - new DatabaseTable - { - Name = "Blog", - Columns = - { - IdColumn - }, - PrimaryKey = IdPrimaryKey - } - } + Tables = { new DatabaseTable { Name = "Blog", Columns = { IdColumn }, PrimaryKey = IdPrimaryKey } } }; var model = _factory.Create(info, false); @@ -1413,24 +869,8 @@ public void Pluralization_of_entity_and_DbSet() { Tables = { - new DatabaseTable - { - Name = "Blog", - Columns = - { - IdColumn - }, - PrimaryKey = IdPrimaryKey - }, - new DatabaseTable - { - Name = "Posts", - Columns = - { - IdColumn - }, - PrimaryKey = IdPrimaryKey - } + new DatabaseTable { Name = "Blog", Columns = { IdColumn }, PrimaryKey = IdPrimaryKey }, + new DatabaseTable { Name = "Posts", Columns = { IdColumn }, PrimaryKey = IdPrimaryKey } } }; @@ -1484,28 +924,11 @@ public void Pluralization_of_entity_and_DbSet() [ConditionalFact] public void Pluralization_of_collection_navigations() { - var blogTable = new DatabaseTable - { - Name = "Blog", - Columns = - { - IdColumn - }, - PrimaryKey = IdPrimaryKey - }; + var blogTable = new DatabaseTable { Name = "Blog", Columns = { IdColumn }, PrimaryKey = IdPrimaryKey }; var postTable = new DatabaseTable { Name = "Post", - Columns = - { - IdColumn, - new DatabaseColumn - { - Name = "BlogId", - StoreType = "int", - IsNullable = true - } - }, + Columns = { IdColumn, new DatabaseColumn { Name = "BlogId", StoreType = "int", IsNullable = true } }, PrimaryKey = IdPrimaryKey }; @@ -1515,24 +938,11 @@ public void Pluralization_of_collection_navigations() Table = postTable, PrincipalTable = blogTable, OnDelete = ReferentialAction.Cascade, - Columns = - { - postTable.Columns.ElementAt(1) - }, - PrincipalColumns = - { - blogTable.Columns.ElementAt(0) - } + Columns = { postTable.Columns.ElementAt(1) }, + PrincipalColumns = { blogTable.Columns.ElementAt(0) } }); - var info = new DatabaseModel - { - Tables = - { - blogTable, - postTable - } - }; + var info = new DatabaseModel { Tables = { blogTable, postTable } }; var services = new ServiceCollection() .AddEntityFrameworkDesignTimeServices(_reporter) @@ -1581,12 +991,7 @@ public void Not_null_bool_column_with_default_value_is_made_nullable() DefaultValueSql = "Default", IsNullable = false }, - new DatabaseColumn - { - Name = "NonNullBoolWithoutDefault", - StoreType = "bit", - IsNullable = false - } + new DatabaseColumn { Name = "NonNullBoolWithoutDefault", StoreType = "bit", IsNullable = false } }, PrimaryKey = IdPrimaryKey } @@ -1644,21 +1049,9 @@ public void Nullable_column_with_default_value_sql_does_not_generate_warning() [ConditionalFact] public void Correct_arguments_to_scaffolding_typemapper() { - var principalPkColumn = new DatabaseColumn - { - Name = "PrimaryKey", - StoreType = "nvarchar(450)" - }; - var principalAkColumn = new DatabaseColumn - { - Name = "AlternateKey", - StoreType = "nvarchar(450)" - }; - var principalIndexColumn = new DatabaseColumn - { - Name = "Index", - StoreType = "nvarchar(450)" - }; + var principalPkColumn = new DatabaseColumn { Name = "PrimaryKey", StoreType = "nvarchar(450)" }; + var principalAkColumn = new DatabaseColumn { Name = "AlternateKey", StoreType = "nvarchar(450)" }; + var principalIndexColumn = new DatabaseColumn { Name = "Index", StoreType = "nvarchar(450)" }; var rowversionColumn = new DatabaseColumn { Name = "Rowversion", @@ -1670,103 +1063,33 @@ public void Correct_arguments_to_scaffolding_typemapper() var principalTable = new DatabaseTable { Name = "Principal", - Columns = - { - principalPkColumn, - principalAkColumn, - principalIndexColumn, - rowversionColumn - }, - PrimaryKey = new DatabasePrimaryKey - { - Columns = - { - principalPkColumn - } - }, - UniqueConstraints = - { - new DatabaseUniqueConstraint - { - Columns = - { - principalAkColumn - } - } - }, - Indexes = - { - new DatabaseIndex - { - Columns = - { - principalIndexColumn - } - } - } + Columns = { principalPkColumn, principalAkColumn, principalIndexColumn, rowversionColumn }, + PrimaryKey = new DatabasePrimaryKey { Columns = { principalPkColumn } }, + UniqueConstraints = { new DatabaseUniqueConstraint { Columns = { principalAkColumn } } }, + Indexes = { new DatabaseIndex { Columns = { principalIndexColumn } } } }; - var dependentIdColumn = new DatabaseColumn - { - Name = "Id", - StoreType = "int" - }; - var dependentFkColumn = new DatabaseColumn - { - Name = "BlogAlternateKey", - StoreType = "nvarchar(450)" - }; + var dependentIdColumn = new DatabaseColumn { Name = "Id", StoreType = "int" }; + var dependentFkColumn = new DatabaseColumn { Name = "BlogAlternateKey", StoreType = "nvarchar(450)" }; var dependentTable = new DatabaseTable { Name = "Dependent", - Columns = - { - dependentIdColumn, - dependentFkColumn - }, - PrimaryKey = new DatabasePrimaryKey - { - Columns = - { - dependentIdColumn - } - }, - Indexes = - { - new DatabaseIndex - { - Columns = - { - dependentFkColumn - } - } - }, + Columns = { dependentIdColumn, dependentFkColumn }, + PrimaryKey = new DatabasePrimaryKey { Columns = { dependentIdColumn } }, + Indexes = { new DatabaseIndex { Columns = { dependentFkColumn } } }, ForeignKeys = { new DatabaseForeignKey { - Columns = - { - dependentFkColumn - }, + Columns = { dependentFkColumn }, PrincipalTable = principalTable, - PrincipalColumns = - { - principalAkColumn - } + PrincipalColumns = { principalAkColumn } } } }; - var dbModel = new DatabaseModel - { - Tables = - { - principalTable, - dependentTable - } - }; + var dbModel = new DatabaseModel { Tables = { principalTable, dependentTable } }; var model = _factory.Create(dbModel, false); @@ -1780,26 +1103,13 @@ public void Correct_arguments_to_scaffolding_typemapper() [ConditionalFact] public void Unmapped_column_is_ignored() { - var columnWithUnknownType = new DatabaseColumn - { - Name = "ColumnWithUnknownStoreType", - StoreType = "unknown_type" - }; + var columnWithUnknownType = new DatabaseColumn { Name = "ColumnWithUnknownStoreType", StoreType = "unknown_type" }; var dbModel = new DatabaseModel { Tables = { - new DatabaseTable - { - Name = "Table", - Columns = - { - IdColumn, - columnWithUnknownType - }, - PrimaryKey = IdPrimaryKey - } + new DatabaseTable { Name = "Table", Columns = { IdColumn, columnWithUnknownType }, PrimaryKey = IdPrimaryKey } } }; @@ -1823,13 +1133,7 @@ public void Column_and_table_comments() Comment = "A table", Columns = { - IdColumn, - new DatabaseColumn - { - Name = "Column", - StoreType = "int", - Comment = "An int column" - } + IdColumn, new DatabaseColumn { Name = "Column", StoreType = "int", Comment = "An int column" } } } } @@ -1856,7 +1160,7 @@ public string Pluralize(string name) public string Singularize(string name) { return name.EndsWith("s") - ? name[0..^1] + ? name[..^1] : name; } } diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineerScaffolderTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineerScaffolderTest.cs index e82673ac0cc..dd8086e2688 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineerScaffolderTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineerScaffolderTest.cs @@ -23,19 +23,8 @@ public void Save_works() var scaffolder = CreateScaffolder(); var scaffoldedModel = new ScaffoldedModel { - ContextFile = new ScaffoldedFile - { - Path = Path.Combine("..", "Data", "TestContext.cs"), - Code = "// TestContext" - }, - AdditionalFiles = - { - new ScaffoldedFile - { - Path = "TestEntity.cs", - Code = "// TestEntity" - } - } + ContextFile = new ScaffoldedFile { Path = Path.Combine("..", "Data", "TestContext.cs"), Code = "// TestContext" }, + AdditionalFiles = { new ScaffoldedFile { Path = "TestEntity.cs", Code = "// TestEntity" } } }; var result = scaffolder.Save( @@ -68,19 +57,8 @@ public void Save_throws_when_existing_files() var scaffolder = CreateScaffolder(); var scaffoldedModel = new ScaffoldedModel { - ContextFile = new ScaffoldedFile - { - Path = "TestContext.cs", - Code = "// TestContext" - }, - AdditionalFiles = - { - new ScaffoldedFile - { - Path = "TestEntity.cs", - Code = "// TestEntity" - } - } + ContextFile = new ScaffoldedFile { Path = "TestContext.cs", Code = "// TestContext" }, + AdditionalFiles = { new ScaffoldedFile { Path = "TestEntity.cs", Code = "// TestEntity" } } }; var ex = Assert.Throws( @@ -103,14 +81,7 @@ public void Save_works_when_overwriteFiles() File.WriteAllText(path, "// Old"); var scaffolder = CreateScaffolder(); - var scaffoldedModel = new ScaffoldedModel - { - ContextFile = new ScaffoldedFile - { - Path = "Test.cs", - Code = "// Test" - } - }; + var scaffoldedModel = new ScaffoldedModel { ContextFile = new ScaffoldedFile { Path = "Test.cs", Code = "// Test" } }; var result = scaffolder.Save(scaffoldedModel, directory.Path, overwriteFiles: true); @@ -138,19 +109,8 @@ public void Save_throws_when_readonly_files() var scaffolder = CreateScaffolder(); var scaffoldedModel = new ScaffoldedModel { - ContextFile = new ScaffoldedFile - { - Path = "TestContext.cs", - Code = "// TestContext" - }, - AdditionalFiles = - { - new ScaffoldedFile - { - Path = "TestEntity.cs", - Code = "// TestEntity" - } - } + ContextFile = new ScaffoldedFile { Path = "TestContext.cs", Code = "// TestContext" }, + AdditionalFiles = { new ScaffoldedFile { Path = "TestEntity.cs", Code = "// TestEntity" } } }; var ex = Assert.Throws( diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineeringConfigurationTests.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineeringConfigurationTests.cs index a1e555a53f6..67d18e5453f 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineeringConfigurationTests.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineeringConfigurationTests.cs @@ -42,11 +42,7 @@ private void ValidateContextNameInReverseEngineerGenerator(string contextName) "connectionstring", new DatabaseModelFactoryOptions(), new ModelReverseEngineerOptions(), - new ModelCodeGenerationOptions() - { - ModelNamespace = "FakeNamespace", - ContextName = contextName, - })) + new ModelCodeGenerationOptions { ModelNamespace = "FakeNamespace", ContextName = contextName })) .Message); } } diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqliteTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqliteTest.cs index e2f4722d9dc..104c271928f 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqliteTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqliteTest.cs @@ -1,10 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using Microsoft.EntityFrameworkCore.Scaffolding.Internal; using Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal; -using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; diff --git a/test/EFCore.Design.Tests/TestUtilities/BuildReference.cs b/test/EFCore.Design.Tests/TestUtilities/BuildReference.cs index 490f9f79900..41248bc6732 100644 --- a/test/EFCore.Design.Tests/TestUtilities/BuildReference.cs +++ b/test/EFCore.Design.Tests/TestUtilities/BuildReference.cs @@ -3,9 +3,9 @@ using System; using System.Collections.Generic; +using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.Extensions.DependencyModel; -using System.Linq; using IOPath = System.IO.Path; namespace Microsoft.EntityFrameworkCore.TestUtilities diff --git a/test/EFCore.InMemory.FunctionalTests/BuiltInDataTypesInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/BuiltInDataTypesInMemoryTest.cs index 3fa64fc7c23..d785e134314 100644 --- a/test/EFCore.InMemory.FunctionalTests/BuiltInDataTypesInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/BuiltInDataTypesInMemoryTest.cs @@ -3,7 +3,6 @@ using System; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable InconsistentNaming diff --git a/test/EFCore.InMemory.FunctionalTests/CompositeKeyEndToEndTest.cs b/test/EFCore.InMemory.FunctionalTests/CompositeKeyEndToEndTest.cs index eb379c33929..f54aee92514 100644 --- a/test/EFCore.InMemory.FunctionalTests/CompositeKeyEndToEndTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/CompositeKeyEndToEndTest.cs @@ -25,12 +25,7 @@ public async Task Can_use_two_non_generated_integers_as_composite_key_end_to_end using (var context = new BronieContext(serviceProvider)) { context.Add( - new Pegasus - { - Id1 = ticks, - Id2 = ticks + 1, - Name = "Rainbow Dash" - }); + new Pegasus { Id1 = ticks, Id2 = ticks + 1, Name = "Rainbow Dash" }); await context.SaveChangesAsync(); } @@ -74,11 +69,7 @@ public async Task Can_use_generated_values_in_composite_key_end_to_end() using (var context = new BronieContext(serviceProvider)) { var added = context.Add( - new Unicorn - { - Id2 = id2, - Name = "Rarity" - }).Entity; + new Unicorn { Id2 = id2, Name = "Rarity" }).Entity; Assert.True(added.Id1 > 0); Assert.NotEqual(Guid.Empty, added.Id3); @@ -132,23 +123,11 @@ public async Task Only_one_part_of_a_composite_key_needs_to_vary_for_uniqueness( using (var context = new BronieContext(serviceProvider)) { var pony1 = context.Add( - new EarthPony - { - Id2 = 7, - Name = "Apple Jack 1" - }).Entity; + new EarthPony { Id2 = 7, Name = "Apple Jack 1" }).Entity; var pony2 = context.Add( - new EarthPony - { - Id2 = 7, - Name = "Apple Jack 2" - }).Entity; + new EarthPony { Id2 = 7, Name = "Apple Jack 2" }).Entity; var pony3 = context.Add( - new EarthPony - { - Id2 = 7, - Name = "Apple Jack 3" - }).Entity; + new EarthPony { Id2 = 7, Name = "Apple Jack 3" }).Entity; await context.SaveChangesAsync(); @@ -210,61 +189,35 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity().HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); modelBuilder .Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); b.Property(e => e.Id1).ValueGeneratedOnAdd(); b.Property(e => e.Id2).ValueGeneratedOnAdd(); }); modelBuilder.Entity().HasKey( - e => new - { - e.Id1, - e.Id2, - e.Id3 - }); + e => new { e.Id1, e.Id2, e.Id3 }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2, - e.Id3 - }); + e => new { e.Id1, e.Id2, e.Id3 }); b.Property(e => e.Id1).ValueGeneratedOnAdd(); b.Property(e => e.Id3).ValueGeneratedOnAdd(); }); modelBuilder.Entity().HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); b.Property(e => e.Id1).ValueGeneratedOnAdd(); b.Property(e => e.Id2).ValueGeneratedOnAdd(); }); diff --git a/test/EFCore.InMemory.FunctionalTests/ConfigPatternsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/ConfigPatternsInMemoryTest.cs index 2d75fe47d80..651ead4f950 100644 --- a/test/EFCore.InMemory.FunctionalTests/ConfigPatternsInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ConfigPatternsInMemoryTest.cs @@ -18,10 +18,7 @@ public void Can_save_and_query_with_implicit_services_and_OnConfiguring() using (var context = new ImplicitServicesAndConfigBlogContext()) { context.Blogs.Add( - new Blog - { - Name = "The Waffle Cart" - }); + new Blog { Name = "The Waffle Cart" }); context.SaveChanges(); } @@ -57,10 +54,7 @@ public void Can_save_and_query_with_implicit_services_and_explicit_config() using (var context = new ImplicitServicesExplicitConfigBlogContext(optionsBuilder.Options)) { context.Blogs.Add( - new Blog - { - Name = "The Waffle Cart" - }); + new Blog { Name = "The Waffle Cart" }); context.SaveChanges(); } @@ -98,10 +92,7 @@ public void Can_save_and_query_with_explicit_services_and_OnConfiguring() using (var context = new ExplicitServicesImplicitConfigBlogContext(serviceProvider)) { context.Blogs.Add( - new Blog - { - Name = "The Waffle Cart" - }); + new Blog { Name = "The Waffle Cart" }); context.SaveChanges(); } @@ -148,10 +139,7 @@ public void Can_save_and_query_with_explicit_services_and_explicit_config() using (var context = new ExplicitServicesAndConfigBlogContext(optionsBuilder.Options)) { context.Blogs.Add( - new Blog - { - Name = "The Waffle Cart" - }); + new Blog { Name = "The Waffle Cart" }); context.SaveChanges(); } @@ -190,10 +178,7 @@ public void Throws_on_attempt_to_use_context_with_no_store() using (var context = new NoServicesAndNoConfigBlogContext()) { context.Blogs.Add( - new Blog - { - Name = "The Waffle Cart" - }); + new Blog { Name = "The Waffle Cart" }); context.SaveChanges(); } }).Message); @@ -222,10 +207,7 @@ public void Throws_on_attempt_to_use_store_with_no_store_services() using (var context = new ImplicitConfigButNoServicesBlogContext(serviceProvider)) { context.Blogs.Add( - new Blog - { - Name = "The Waffle Cart" - }); + new Blog { Name = "The Waffle Cart" }); context.SaveChanges(); } }).Message); @@ -275,10 +257,7 @@ public InjectContextController(InjectContextBlogContext context) public void Test() { _context.Blogs.Add( - new Blog - { - Name = "The Waffle Cart" - }); + new Blog { Name = "The Waffle Cart" }); _context.SaveChanges(); var blog = _context.Blogs.SingleOrDefault(); @@ -336,10 +315,7 @@ public InjectContextAndConfigurationController(InjectContextAndConfigurationBlog public void Test() { _context.Blogs.Add( - new Blog - { - Name = "The Waffle Cart" - }); + new Blog { Name = "The Waffle Cart" }); _context.SaveChanges(); var blog = _context.Blogs.SingleOrDefault(); @@ -393,10 +369,7 @@ public InjectConfigurationController(InjectConfigurationBlogContext context) public void Test() { _context.Blogs.Add( - new Blog - { - Name = "The Waffle Cart" - }); + new Blog { Name = "The Waffle Cart" }); _context.SaveChanges(); var blog = _context.Blogs.SingleOrDefault(); @@ -460,10 +433,7 @@ public void Test() _context.GetService()); _context.Blogs.Add( - new Blog - { - Name = "The Waffle Cart" - }); + new Blog { Name = "The Waffle Cart" }); _context.SaveChanges(); var blog = _context.Blogs.SingleOrDefault(); @@ -490,10 +460,7 @@ public void Test() _context.GetService()); _context.Accounts.Add( - new Account - { - Name = "Eeky Bear" - }); + new Account { Name = "Eeky Bear" }); _context.SaveChanges(); var account = _context.Accounts.SingleOrDefault(); diff --git a/test/EFCore.InMemory.FunctionalTests/CustomValueGeneratorTest.cs b/test/EFCore.InMemory.FunctionalTests/CustomValueGeneratorTest.cs index bb20e967a22..22504d8407c 100644 --- a/test/EFCore.InMemory.FunctionalTests/CustomValueGeneratorTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/CustomValueGeneratorTest.cs @@ -28,10 +28,7 @@ public void Can_use_custom_value_generators() { entities.Add( context.Add( - new SomeEntity - { - Name = _names[i] - }).Entity); + new SomeEntity { Name = _names[i] }).Entity); } Assert.Equal(entities.Select(e => e.Id), entities.OrderBy(e => ToCounter(e.Id)).Select(e => e.Id)); @@ -61,11 +58,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) b => { b.HasAlternateKey( - e => new - { - e.SpecialId, - e.SpecialString - }); + e => new { e.SpecialId, e.SpecialString }); b.Property(e => e.SpecialId) .HasAnnotation("SpecialGuid", true) .ValueGeneratedOnAdd(); @@ -85,10 +78,7 @@ public void Can_use_custom_value_generator_from_annotated_type() { entities.Add( context.Add( - new SomeEntity - { - Name = _names[i] - }).Entity); + new SomeEntity { Name = _names[i] }).Entity); } Assert.Equal(entities.Select(e => e.Id), entities.OrderBy(e => ToCounter(e.Id)).Select(e => e.Id)); @@ -132,10 +122,7 @@ public void Can_use_custom_value_generator_from_annotated_factory() { entities.Add( context.Add( - new SomeEntity - { - Name = _names[i] - }).Entity); + new SomeEntity { Name = _names[i] }).Entity); } Assert.Equal(entities.Select(e => e.Id), entities.OrderBy(e => ToCounter(e.Id)).Select(e => e.Id)); @@ -188,8 +175,14 @@ private class SomeEntity private readonly string[] _names = { - "Jamie Vardy", "Danny Drinkwater", "Andy King", "Riyad Mahrez", - "Kasper Schmeichel", "Wes Morgan", "Robert Huth", "Leonardo Ulloa" + "Jamie Vardy", + "Danny Drinkwater", + "Andy King", + "Riyad Mahrez", + "Kasper Schmeichel", + "Wes Morgan", + "Robert Huth", + "Leonardo Ulloa" }; private static long ToCounter(Guid guid) @@ -233,8 +226,14 @@ private class CustomGuidValueGenerator : ValueGenerator { public static Guid[] SpecialGuids { get; } = { - Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), - Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() + Guid.NewGuid(), + Guid.NewGuid(), + Guid.NewGuid(), + Guid.NewGuid(), + Guid.NewGuid(), + Guid.NewGuid(), + Guid.NewGuid(), + Guid.NewGuid() }; private int _counter = -1; diff --git a/test/EFCore.InMemory.FunctionalTests/DatabaseErrorLogStateTest.cs b/test/EFCore.InMemory.FunctionalTests/DatabaseErrorLogStateTest.cs index d8e9fd0d84b..30e155b7a91 100644 --- a/test/EFCore.InMemory.FunctionalTests/DatabaseErrorLogStateTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/DatabaseErrorLogStateTest.cs @@ -39,10 +39,7 @@ private async Task SaveChanges_logs_DatabaseErrorLogState_test(bool async) using (var context = new BloggingContext(serviceProvider)) { context.Blogs.Add( - new BloggingContext.Blog(jimSaysThrow: false) - { - Url = "http://sample.com" - }); + new BloggingContext.Blog(jimSaysThrow: false) { Url = "http://sample.com" }); context.SaveChanges(); context.ChangeTracker.Entries().Single().State = EntityState.Added; @@ -114,10 +111,7 @@ private async Task Query_logs_DatabaseErrorLogState_test(Func().StopTracking(entry, entry.EntityState); diff --git a/test/EFCore.InMemory.FunctionalTests/DatabaseInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/DatabaseInMemoryTest.cs index 8953a4a1d8d..8f330f63bfc 100644 --- a/test/EFCore.InMemory.FunctionalTests/DatabaseInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/DatabaseInMemoryTest.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Xunit; @@ -39,11 +38,7 @@ public async Task Can_add_update_delete_end_to_end() .UseInMemoryDatabase(nameof(DatabaseInMemoryTest)) .Options; - var customer = new Customer - { - Id = 42, - Name = "Theon" - }; + var customer = new Customer { Id = 42, Name = "Theon" }; using (var context = new DbContext(options)) { @@ -119,11 +114,7 @@ public async Task Can_share_instance_between_contexts_with_sugar_experience() using (var db = new SimpleContext()) { db.Artists.Add( - new SimpleContext.Artist - { - ArtistId = "JDId", - Name = "John Doe" - }); + new SimpleContext.Artist { ArtistId = "JDId", Name = "John Doe" }); await db.SaveChangesAsync(); } diff --git a/test/EFCore.InMemory.FunctionalTests/EndToEndTest.cs b/test/EFCore.InMemory.FunctionalTests/EndToEndTest.cs index 6a33ffdf72f..f5195edddd7 100644 --- a/test/EFCore.InMemory.FunctionalTests/EndToEndTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/EndToEndTest.cs @@ -32,11 +32,12 @@ private void Can_add_update_delete_end_to_end() where T : class, new() { var modelBuilder = new ModelBuilder(InMemoryConventionSetBuilder.Build()); - modelBuilder.Entity(eb => - { - eb.Property("Id"); - eb.Property("Name"); - }); + modelBuilder.Entity( + eb => + { + eb.Property("Id"); + eb.Property("Name"); + }); var optionsBuilder = new DbContextOptionsBuilder() .UseModel(modelBuilder.FinalizeModel()) diff --git a/test/EFCore.InMemory.FunctionalTests/GlobalDatabaseTest.cs b/test/EFCore.InMemory.FunctionalTests/GlobalDatabaseTest.cs index 5ee1086882e..d09322eca7c 100644 --- a/test/EFCore.InMemory.FunctionalTests/GlobalDatabaseTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/GlobalDatabaseTest.cs @@ -101,9 +101,10 @@ public void Global_store_can_be_used_when_AddDbContext_force_different_internal_ } var serviceProvider = new ServiceCollection() - .AddDbContext(b => - b.UseInMemoryDatabase(nameof(BooFooContext), _databaseRoot) - .EnableServiceProviderCaching(false)) + .AddDbContext( + b => + b.UseInMemoryDatabase(nameof(BooFooContext), _databaseRoot) + .EnableServiceProviderCaching(false)) .BuildServiceProvider(); using (var scope = serviceProvider.CreateScope()) diff --git a/test/EFCore.InMemory.FunctionalTests/GuidValueGeneratorEndToEndTest.cs b/test/EFCore.InMemory.FunctionalTests/GuidValueGeneratorEndToEndTest.cs index 9d11adbafd5..c17678b9242 100644 --- a/test/EFCore.InMemory.FunctionalTests/GuidValueGeneratorEndToEndTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/GuidValueGeneratorEndToEndTest.cs @@ -27,10 +27,7 @@ public async Task Can_use_GUIDs_end_to_end_async() { guids.Add( context.Add( - new Pegasus - { - Name = "Rainbow Dash " + i - }).Entity.Id); + new Pegasus { Name = "Rainbow Dash " + i }).Entity.Id); guidsHash.Add(guids.Last()); } diff --git a/test/EFCore.InMemory.FunctionalTests/IntegerGeneratorEndToEndInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/IntegerGeneratorEndToEndInMemoryTest.cs index 6be4c51bb56..92ebf622b41 100644 --- a/test/EFCore.InMemory.FunctionalTests/IntegerGeneratorEndToEndInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/IntegerGeneratorEndToEndInMemoryTest.cs @@ -41,15 +41,9 @@ private static void AddEntities(IServiceProvider serviceProvider) for (var i = 0; i < 50; i++) { context.Add( - new Pegasus - { - Name = "Rainbow Dash " + i - }); + new Pegasus { Name = "Rainbow Dash " + i }); context.Add( - new Pegasus - { - Name = "Fluttershy " + i - }); + new Pegasus { Name = "Fluttershy " + i }); } context.SaveChanges(); @@ -86,15 +80,9 @@ private static async Task AddEntitiesAsync(IServiceProvider serviceProvider) for (var i = 0; i < 50; i++) { context.Add( - new Pegasus - { - Name = "Rainbow Dash " + i - }); + new Pegasus { Name = "Rainbow Dash " + i }); context.Add( - new Pegasus - { - Name = "Fluttershy " + i - }); + new Pegasus { Name = "Fluttershy " + i }); } await context.SaveChangesAsync(); diff --git a/test/EFCore.InMemory.FunctionalTests/LazyLoadProxyInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/LazyLoadProxyInMemoryTest.cs index efe535cda0c..f8dae4294fd 100644 --- a/test/EFCore.InMemory.FunctionalTests/LazyLoadProxyInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/LazyLoadProxyInMemoryTest.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; diff --git a/test/EFCore.InMemory.FunctionalTests/NamedDatabaseTest.cs b/test/EFCore.InMemory.FunctionalTests/NamedDatabaseTest.cs index baea9b2fbbf..a74c9a07b5e 100644 --- a/test/EFCore.InMemory.FunctionalTests/NamedDatabaseTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/NamedDatabaseTest.cs @@ -16,10 +16,7 @@ public void Transient_databases_are_not_shared() using (var context = new PusheenContext()) { context.Add( - new Pusheen - { - Activity = "In a box" - }); + new Pusheen { Activity = "In a box" }); context.SaveChanges(); } @@ -35,10 +32,7 @@ public void Database_per_app_domain_is_default_with_internal_service_provider() using (var context = new PusheenContext(nameof(PusheenContext))) { context.Add( - new Pusheen - { - Activity = "In a box" - }); + new Pusheen { Activity = "In a box" }); context.SaveChanges(); } @@ -57,10 +51,7 @@ public void Database_per_service_provider_is_default() using (var context = new PusheenContext(nameof(PusheenContext), provider1)) { context.Add( - new Pusheen - { - Activity = "In a box" - }); + new Pusheen { Activity = "In a box" }); context.SaveChanges(); } @@ -69,10 +60,7 @@ public void Database_per_service_provider_is_default() Assert.Empty(context.Pusheens); context.Add( - new Pusheen - { - Activity = "With some yarn" - }); + new Pusheen { Activity = "With some yarn" }); context.SaveChanges(); } @@ -93,10 +81,7 @@ public void Named_databases_shared_per_app_domain_with_internal_service_provider using (var context = new PusheenContext("Cats")) { context.Add( - new Pusheen - { - Activity = "In a box" - }); + new Pusheen { Activity = "In a box" }); context.SaveChanges(); } @@ -105,10 +90,7 @@ public void Named_databases_shared_per_app_domain_with_internal_service_provider Assert.Empty(context.Pusheens); context.Add( - new Pusheen - { - Activity = "With some yarn" - }); + new Pusheen { Activity = "With some yarn" }); context.SaveChanges(); } @@ -132,10 +114,7 @@ public void Named_databases_shared_per_service_provider() using (var context = new PusheenContext("Cats", provider1)) { context.Add( - new Pusheen - { - Activity = "In a box" - }); + new Pusheen { Activity = "In a box" }); context.SaveChanges(); } @@ -144,10 +123,7 @@ public void Named_databases_shared_per_service_provider() Assert.Empty(context.Pusheens); context.Add( - new Pusheen - { - Activity = "With some yarn" - }); + new Pusheen { Activity = "With some yarn" }); context.SaveChanges(); } @@ -156,10 +132,7 @@ public void Named_databases_shared_per_service_provider() Assert.Empty(context.Pusheens); context.Add( - new Pusheen - { - Activity = "On a scooter" - }); + new Pusheen { Activity = "On a scooter" }); context.SaveChanges(); } @@ -168,10 +141,7 @@ public void Named_databases_shared_per_service_provider() Assert.Empty(context.Pusheens); context.Add( - new Pusheen - { - Activity = "Is a DJ" - }); + new Pusheen { Activity = "Is a DJ" }); context.SaveChanges(); } @@ -180,10 +150,7 @@ public void Named_databases_shared_per_service_provider() Assert.Empty(context.Pusheens); context.Add( - new Pusheen - { - Activity = "Goes to sleep" - }); + new Pusheen { Activity = "Goes to sleep" }); context.SaveChanges(); } @@ -192,10 +159,7 @@ public void Named_databases_shared_per_service_provider() Assert.Empty(context.Pusheens); context.Add( - new Pusheen - { - Activity = "Loves magic unicorns" - }); + new Pusheen { Activity = "Loves magic unicorns" }); context.SaveChanges(); } diff --git a/test/EFCore.InMemory.FunctionalTests/NotificationEntitiesInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/NotificationEntitiesInMemoryTest.cs index c1eae90e5e5..1bede531cd6 100644 --- a/test/EFCore.InMemory.FunctionalTests/NotificationEntitiesInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/NotificationEntitiesInMemoryTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore { - public class NotificationEntitiesInMemoryTest : NotificationEntitiesTestBase + public class NotificationEntitiesInMemoryTest : NotificationEntitiesTestBase< + NotificationEntitiesInMemoryTest.NotificationEntitiesInMemoryFixture> { public NotificationEntitiesInMemoryTest(NotificationEntitiesInMemoryFixture fixture) : base(fixture) diff --git a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryTest.cs index f9f98205c6a..6ac14637c4a 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryTest.cs @@ -90,7 +90,8 @@ public override Task Optional_navigation_inside_method_call_translated_to_join(b } [ConditionalTheory(Skip = "issue #16963")] - public override Task SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany3(bool isAsync) + public override Task SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany3( + bool isAsync) { return base.SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany3(isAsync); } @@ -156,7 +157,8 @@ public override Task Join_navigation_in_outer_selector_translated_to_extra_join( } [ConditionalTheory(Skip = "issue #16963")] - public override Task SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany4(bool isAsync) + public override Task SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany4( + bool isAsync) { return base.SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany4(isAsync); } @@ -174,9 +176,11 @@ public override Task Optional_navigation_inside_nested_method_call_translated_to } [ConditionalTheory(Skip = "issue #16963")] - public override Task Optional_navigation_inside_nested_method_call_translated_to_join_keeps_original_nullability_also_for_arguments(bool isAsync) + public override Task Optional_navigation_inside_nested_method_call_translated_to_join_keeps_original_nullability_also_for_arguments( + bool isAsync) { - return base.Optional_navigation_inside_nested_method_call_translated_to_join_keeps_original_nullability_also_for_arguments(isAsync); + return base.Optional_navigation_inside_nested_method_call_translated_to_join_keeps_original_nullability_also_for_arguments( + isAsync); } } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs index 1d45aaca666..1f4edcea72d 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs @@ -22,9 +22,11 @@ public override Task Double_order_by_on_nullable_bool_coming_from_optional_navig } [ConditionalTheory(Skip = "issue #13746")] - public override Task Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool isAsync) + public override Task + Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool isAsync) { - return base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(isAsync); + return base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex( + isAsync); } [ConditionalTheory(Skip = "issue #16963")] diff --git a/test/EFCore.InMemory.FunctionalTests/Query/IncludeInMemoryFixture.cs b/test/EFCore.InMemory.FunctionalTests/Query/IncludeInMemoryFixture.cs index 97af7fece3e..7c703a70cc2 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/IncludeInMemoryFixture.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/IncludeInMemoryFixture.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestUtilities; namespace Microsoft.EntityFrameworkCore.Query diff --git a/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs index 1fbefc28c57..5caed58e861 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs @@ -164,11 +164,7 @@ on instance.Id equals question.ExamId where instance.Id != 3 group question by question.QuestionId into gQuestions - select new - { - gQuestions.Key, - MaxDate = gQuestions.Max(q => q.Modified) - }; + select new { gQuestions.Key, MaxDate = gQuestions.Max(q => q.Modified) }; var result = q0.ToList(); @@ -181,11 +177,7 @@ private static void Seed3595(Context3595 context) { var question = new Question3595(); var examInstance = new Exam3595(); - var examInstanceQuestion = new ExamQuestion3595 - { - Question = question, - Exam = examInstance - }; + var examInstanceQuestion = new ExamQuestion3595 { Question = question, Exam = examInstance }; context.Add(question); context.Add(examInstance); @@ -309,11 +301,7 @@ join eRoot in ctx.Entities on eVersion.RootEntityId equals (int?)eRoot.Id into RootEntities from eRootJoined in RootEntities.DefaultIfEmpty() - select new - { - One = 1, - Coalesce = eRootJoined ?? eVersion - }; + select new { One = 1, Coalesce = eRootJoined ?? eVersion }; var result = query.ToList(); Assert.True(result.All(e => e.Coalesce.Children.Count > 0)); @@ -333,11 +321,7 @@ join eRoot in ctx.Entities.Include(e => e.Children) on eVersion.RootEntityId equals (int?)eRoot.Id into RootEntities from eRootJoined in RootEntities.DefaultIfEmpty() - select new - { - Root = eRootJoined, - Coalesce = eRootJoined ?? eVersion - }; + select new { Root = eRootJoined, Coalesce = eRootJoined ?? eVersion }; var result = query.ToList(); Assert.Equal(2, result.Count(e => e.Coalesce.Children.Count > 0)); @@ -357,11 +341,7 @@ join eRoot in ctx.Entities.Include(e => e.Children) on eVersion.RootEntityId equals (int?)eRoot.Id into RootEntities from eRootJoined in RootEntities.DefaultIfEmpty() - select new - { - One = 1, - Coalesce = eRootJoined ?? (eVersion ?? eRootJoined) - }; + select new { One = 1, Coalesce = eRootJoined ?? (eVersion ?? eRootJoined) }; var result = query.ToList(); Assert.Equal(2, result.Count(e => e.Coalesce.Children.Count > 0)); @@ -381,12 +361,7 @@ join eRoot in ctx.Entities on eVersion.RootEntityId equals (int?)eRoot.Id into RootEntities from eRootJoined in RootEntities.DefaultIfEmpty() - select new - { - One = eRootJoined, - Two = 2, - Coalesce = eRootJoined ?? (eVersion ?? eRootJoined) - }; + select new { One = eRootJoined, Two = 2, Coalesce = eRootJoined ?? (eVersion ?? eRootJoined) }; var result = query.ToList(); Assert.True(result.All(e => e.Coalesce.Children.Count > 0)); @@ -428,12 +403,7 @@ join eRoot in ctx.Entities on eVersion.RootEntityId equals (int?)eRoot.Id into RootEntities from eRootJoined in RootEntities.DefaultIfEmpty() - select new - { - eRootJoined, - eVersion, - foo = eRootJoined ?? eVersion - }; + select new { eRootJoined, eVersion, foo = eRootJoined ?? eVersion }; Assert.Equal(3, query.ToList().Count); @@ -444,52 +414,19 @@ from eRootJoined in RootEntities.DefaultIfEmpty() private static void Seed3101(MyContext3101 context) { - var c11 = new Child3101 - { - Name = "c11" - }; - var c12 = new Child3101 - { - Name = "c12" - }; - var c13 = new Child3101 - { - Name = "c13" - }; - var c21 = new Child3101 - { - Name = "c21" - }; - var c22 = new Child3101 - { - Name = "c22" - }; - var c31 = new Child3101 - { - Name = "c31" - }; - var c32 = new Child3101 - { - Name = "c32" - }; + var c11 = new Child3101 { Name = "c11" }; + var c12 = new Child3101 { Name = "c12" }; + var c13 = new Child3101 { Name = "c13" }; + var c21 = new Child3101 { Name = "c21" }; + var c22 = new Child3101 { Name = "c22" }; + var c31 = new Child3101 { Name = "c31" }; + var c32 = new Child3101 { Name = "c32" }; context.Children.AddRange(c11, c12, c13, c21, c22, c31, c32); - var e1 = new Entity3101 - { - Id = 1, - Children = new[] { c11, c12, c13 } - }; - var e2 = new Entity3101 - { - Id = 2, - Children = new[] { c21, c22 } - }; - var e3 = new Entity3101 - { - Id = 3, - Children = new[] { c31, c32 } - }; + var e1 = new Entity3101 { Id = 1, Children = new[] { c11, c12, c13 } }; + var e2 = new Entity3101 { Id = 2, Children = new[] { c21, c22 } }; + var e3 = new Entity3101 { Id = 3, Children = new[] { c31, c32 } }; e2.RootEntity = e1; @@ -662,14 +599,7 @@ private void Seed5456(MyContext5456 context) Id = i + 1, Posts = new List { - new Post5456 - { - Comments = new List - { - new Comment5456(), - new Comment5456() - } - }, + new Post5456 { Comments = new List { new Comment5456(), new Comment5456() } }, new Post5456() }, Author = new Author5456() diff --git a/test/EFCore.InMemory.FunctionalTests/Query/SimpleQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/SimpleQueryInMemoryTest.cs index 9f3c9875f83..d07f4bc878e 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/SimpleQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/SimpleQueryInMemoryTest.cs @@ -37,7 +37,7 @@ public override void KeylessEntity_by_database_view() { } - // InMemory can mimic throw behavior for subquery + // InMemory can mimic throw behavior for subquery public override void Average_no_data_subquery() { } @@ -190,7 +190,8 @@ public override void OfType_Select_OfType_Select() } [ConditionalTheory(Skip = "Issue#16575")] - public override Task Project_single_element_from_collection_with_OrderBy_Distinct_and_FirstOrDefault_followed_by_projecting_length(bool isAsync) => null; + public override Task Project_single_element_from_collection_with_OrderBy_Distinct_and_FirstOrDefault_followed_by_projecting_length( + bool isAsync) => null; [ConditionalTheory(Skip = "Issue #16963")] public override Task KeylessEntity_with_included_nav(bool isAsync) => null; @@ -330,7 +331,6 @@ public override void Random_next_is_not_funcletized_6() { } - [ConditionalTheory(Skip = "Issue#16963")] public override Task Projection_when_client_evald_subquery(bool isAsync) { diff --git a/test/EFCore.InMemory.FunctionalTests/Query/WarningsTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/WarningsTest.cs index 82e3c34a76f..b156178965e 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/WarningsTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/WarningsTest.cs @@ -130,7 +130,9 @@ public void Logs_by_default_for_ignored_includes() { var _ = context.WarningAsErrorEntities.Include(e => e.Nav).OrderBy(e => e.Id).Select(e => e.Id).ToList(); - Assert.Contains(CoreResources.LogIgnoredInclude(new TestLogger()).GenerateMessage("[e].Nav"), loggerFactory.Log.Select(l => l.Message)); + Assert.Contains( + CoreResources.LogIgnoredInclude(new TestLogger()).GenerateMessage("[e].Nav"), + loggerFactory.Log.Select(l => l.Message)); } } @@ -168,10 +170,7 @@ public void Throws_by_default_for_lazy_load_with_disposed_context() using (var context = new WarningAsErrorContext(serviceProvider, defaultThrow: false)) { context.Add( - new WarningAsErrorEntity - { - Nav = new IncludedEntity() - }); + new WarningAsErrorEntity { Nav = new IncludedEntity() }); context.SaveChanges(); } @@ -185,7 +184,8 @@ public void Throws_by_default_for_lazy_load_with_disposed_context() Assert.Equal( CoreStrings.WarningAsErrorTemplate( CoreEventId.LazyLoadOnDisposedContextWarning.ToString(), - CoreResources.LogLazyLoadOnDisposedContext(new TestLogger()).GenerateMessage("Nav", "WarningAsErrorEntity"), + CoreResources.LogLazyLoadOnDisposedContext(new TestLogger()) + .GenerateMessage("Nav", "WarningAsErrorEntity"), "CoreEventId.LazyLoadOnDisposedContextWarning"), Assert.Throws( () => entity.Nav).Message); @@ -207,10 +207,7 @@ public void Lazy_load_with_disposed_context_can_be_configured_to_log() CoreEventId.LazyLoadOnDisposedContextWarning)) { context.Add( - new WarningAsErrorEntity - { - Nav = new IncludedEntity() - }); + new WarningAsErrorEntity { Nav = new IncludedEntity() }); context.SaveChanges(); } @@ -250,10 +247,7 @@ public void Lazy_load_with_disposed_context_can_be_configured_to_log_at_debug_le toChangeLevel: (CoreEventId.LazyLoadOnDisposedContextWarning, LogLevel.Debug))) { context.Add( - new WarningAsErrorEntity - { - Nav = new IncludedEntity() - }); + new WarningAsErrorEntity { Nav = new IncludedEntity() }); context.SaveChanges(); } @@ -290,10 +284,7 @@ public void Lazy_loading_is_logged_only_when_actually_loading() using (var context = new WarningAsErrorContext(serviceProvider, defaultThrow: false)) { context.Add( - new WarningAsErrorEntity - { - Nav = new IncludedEntity() - }); + new WarningAsErrorEntity { Nav = new IncludedEntity() }); context.SaveChanges(); } @@ -305,13 +296,15 @@ public void Lazy_loading_is_logged_only_when_actually_loading() Assert.NotNull(entity.Nav); Assert.Contains( - CoreResources.LogNavigationLazyLoading(new TestLogger()).GenerateMessage("Nav", "WarningAsErrorEntity"), + CoreResources.LogNavigationLazyLoading(new TestLogger()) + .GenerateMessage("Nav", "WarningAsErrorEntity"), loggerFactory.Log.Select(l => l.Message)); loggerFactory.Clear(); Assert.NotNull(entity.Nav); Assert.DoesNotContain( - CoreResources.LogNavigationLazyLoading(new TestLogger()).GenerateMessage("Nav", "WarningAsErrorEntity"), + CoreResources.LogNavigationLazyLoading(new TestLogger()) + .GenerateMessage("Nav", "WarningAsErrorEntity"), loggerFactory.Log.Select(l => l.Message)); } } diff --git a/test/EFCore.InMemory.FunctionalTests/SeedingInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/SeedingInMemoryTest.cs index e00085ced2a..8752ad7d0a7 100644 --- a/test/EFCore.InMemory.FunctionalTests/SeedingInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/SeedingInMemoryTest.cs @@ -1,5 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + namespace Microsoft.EntityFrameworkCore { public class SeedingInMemoryTest : SeedingTestBase diff --git a/test/EFCore.InMemory.FunctionalTests/ShadowStateUpdateTest.cs b/test/EFCore.InMemory.FunctionalTests/ShadowStateUpdateTest.cs index 00b5a0e9317..30fa231ba80 100644 --- a/test/EFCore.InMemory.FunctionalTests/ShadowStateUpdateTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ShadowStateUpdateTest.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.InMemory.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Xunit; @@ -27,10 +26,7 @@ public async Task Can_add_update_delete_end_to_end_using_partial_shadow_state() .UseInMemoryDatabase(nameof(ShadowStateUpdateTest)) .UseInternalServiceProvider(_fixture.ServiceProvider); - var customer = new Customer - { - Id = 42 - }; + var customer = new Customer { Id = 42 }; using (var context = new DbContext(optionsBuilder.Options)) { diff --git a/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestHelpers.cs b/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestHelpers.cs index 3eb205f852c..e322a4d9838 100644 --- a/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestHelpers.cs +++ b/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestHelpers.cs @@ -2,12 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.InMemory.Diagnostics.Internal; -using Microsoft.EntityFrameworkCore.InMemory.Storage.Internal; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Storage; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.TestUtilities diff --git a/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStore.cs b/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStore.cs index 01215def8e2..623d18e33f8 100644 --- a/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStore.cs +++ b/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStore.cs @@ -29,11 +29,11 @@ public static InMemoryTestStore CreateInitialized(string name) public InMemoryTestStore InitializeInMemory( IServiceProvider serviceProvider, Func createContext, Action seed) - => (InMemoryTestStore)Initialize(serviceProvider, createContext, seed, null); + => (InMemoryTestStore)Initialize(serviceProvider, createContext, seed); public InMemoryTestStore InitializeInMemory( IServiceProvider serviceProvider, Func createContext, Action seed) - => (InMemoryTestStore)Initialize(serviceProvider, () => createContext(this), seed, null); + => (InMemoryTestStore)Initialize(serviceProvider, () => createContext(this), seed); protected override TestStoreIndex GetTestStoreIndex(IServiceProvider serviceProvider) => serviceProvider == null diff --git a/test/EFCore.InMemory.FunctionalTests/WithConstructorsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/WithConstructorsInMemoryTest.cs index 167374aee45..d03f62e0466 100644 --- a/test/EFCore.InMemory.FunctionalTests/WithConstructorsInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/WithConstructorsInMemoryTest.cs @@ -4,7 +4,6 @@ using System.Linq; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; namespace Microsoft.EntityFrameworkCore diff --git a/test/EFCore.InMemory.Tests/InMemoryDatabaseCreatorTest.cs b/test/EFCore.InMemory.Tests/InMemoryDatabaseCreatorTest.cs index 8810b706aee..4d923975ba0 100644 --- a/test/EFCore.InMemory.Tests/InMemoryDatabaseCreatorTest.cs +++ b/test/EFCore.InMemory.Tests/InMemoryDatabaseCreatorTest.cs @@ -74,31 +74,9 @@ private static async Task Delete_clears_all_in_memory_data_test(bool async) using (var context = new FraggleContext()) { context.Fraggles.AddRange( - new Fraggle - { - Id = 1, - Name = "Gobo" - }, new Fraggle - { - Id = 2, - Name = "Monkey" - }, new Fraggle - { - Id = 3, - Name = "Red" - }, new Fraggle - { - Id = 4, - Name = "Wembley" - }, new Fraggle - { - Id = 5, - Name = "Boober" - }, new Fraggle - { - Id = 6, - Name = "Uncle Traveling Matt" - }); + new Fraggle { Id = 1, Name = "Gobo" }, new Fraggle { Id = 2, Name = "Monkey" }, new Fraggle { Id = 3, Name = "Red" }, + new Fraggle { Id = 4, Name = "Wembley" }, new Fraggle { Id = 5, Name = "Boober" }, + new Fraggle { Id = 6, Name = "Uncle Traveling Matt" }); await context.SaveChangesAsync(); } diff --git a/test/EFCore.InMemory.Tests/InMemoryDatabaseTest.cs b/test/EFCore.InMemory.Tests/InMemoryDatabaseTest.cs index ae80cd13ccc..216ed53da54 100644 --- a/test/EFCore.InMemory.Tests/InMemoryDatabaseTest.cs +++ b/test/EFCore.InMemory.Tests/InMemoryDatabaseTest.cs @@ -11,7 +11,6 @@ using Microsoft.EntityFrameworkCore.InMemory.Metadata.Conventions; using Microsoft.EntityFrameworkCore.InMemory.Storage.Internal; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -76,11 +75,7 @@ private static IServiceProvider CreateContextServices(IServiceProvider servicePr public async Task Save_changes_adds_new_objects_to_store() { var serviceProvider = InMemoryTestHelpers.Instance.CreateContextServices(CreateModel()); - var customer = new Customer - { - Id = 42, - Name = "Unikorn" - }; + var customer = new Customer { Id = 42, Name = "Unikorn" }; var entityEntry = serviceProvider.GetRequiredService().GetOrCreateEntry(customer); entityEntry.SetEntityState(EntityState.Added); @@ -97,11 +92,7 @@ public async Task Save_changes_updates_changed_objects_in_store() { var serviceProvider = InMemoryTestHelpers.Instance.CreateContextServices(CreateModel()); - var customer = new Customer - { - Id = 42, - Name = "Unikorn" - }; + var customer = new Customer { Id = 42, Name = "Unikorn" }; var entityEntry = serviceProvider.GetRequiredService().GetOrCreateEntry(customer); entityEntry.SetEntityState(EntityState.Added); @@ -125,11 +116,7 @@ public async Task Save_changes_removes_deleted_objects_from_store() { var serviceProvider = InMemoryTestHelpers.Instance.CreateContextServices(CreateModel()); - var customer = new Customer - { - Id = 42, - Name = "Unikorn" - }; + var customer = new Customer { Id = 42, Name = "Unikorn" }; var entityEntry = serviceProvider.GetRequiredService().GetOrCreateEntry(customer); entityEntry.SetEntityState(EntityState.Added); @@ -158,11 +145,7 @@ public async Task Should_log_writes() var scopedServices = InMemoryTestHelpers.Instance.CreateContextServices(serviceCollection, CreateModel()); - var customer = new Customer - { - Id = 42, - Name = "Unikorn" - }; + var customer = new Customer { Id = 42, Name = "Unikorn" }; var entityEntry = scopedServices.GetRequiredService().GetOrCreateEntry(customer); entityEntry.SetEntityState(EntityState.Added); diff --git a/test/EFCore.Proxies.Tests/LazyLoadingProxyTests.cs b/test/EFCore.Proxies.Tests/LazyLoadingProxyTests.cs index 5bca024e86a..0de88c6d517 100644 --- a/test/EFCore.Proxies.Tests/LazyLoadingProxyTests.cs +++ b/test/EFCore.Proxies.Tests/LazyLoadingProxyTests.cs @@ -274,10 +274,11 @@ public void Throws_when_context_is_disposed() var serviceProvider = new ServiceCollection() .AddEntityFrameworkInMemoryDatabase() .AddEntityFrameworkProxies() - .AddDbContext((p, b) => - b.UseInMemoryDatabase("Jammie") - .UseInternalServiceProvider(p) - .UseLazyLoadingProxies()) + .AddDbContext( + (p, b) => + b.UseInMemoryDatabase("Jammie") + .UseInternalServiceProvider(p) + .UseLazyLoadingProxies()) .BuildServiceProvider(); using (var scope = serviceProvider.CreateScope()) @@ -297,7 +298,8 @@ public void Throws_when_context_is_disposed() Assert.Equal( CoreStrings.WarningAsErrorTemplate( CoreEventId.LazyLoadOnDisposedContextWarning.ToString(), - CoreResources.LogLazyLoadOnDisposedContext(new TestLogger()).GenerateMessage("Texts", "PhoneProxy"), + CoreResources.LogLazyLoadOnDisposedContext(new TestLogger()) + .GenerateMessage("Texts", "PhoneProxy"), "CoreEventId.LazyLoadOnDisposedContextWarning"), Assert.Throws( () => phone.Texts).Message); @@ -426,10 +428,11 @@ private class NeweyContextN : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .UseLazyLoadingProxies() - .UseInternalServiceProvider(new ServiceCollection() - .AddEntityFrameworkInMemoryDatabase() - .AddEntityFrameworkProxies() - .BuildServiceProvider()) + .UseInternalServiceProvider( + new ServiceCollection() + .AddEntityFrameworkInMemoryDatabase() + .AddEntityFrameworkProxies() + .BuildServiceProvider()) .UseInMemoryDatabase(Guid.NewGuid().ToString()); } @@ -502,10 +505,11 @@ private class NeweyContextN6 : DbContext { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseInternalServiceProvider(new ServiceCollection() - .AddEntityFrameworkInMemoryDatabase() - .AddEntityFrameworkProxies() - .BuildServiceProvider()) + .UseInternalServiceProvider( + new ServiceCollection() + .AddEntityFrameworkInMemoryDatabase() + .AddEntityFrameworkProxies() + .BuildServiceProvider()) .UseInMemoryDatabase(Guid.NewGuid().ToString()); protected override void OnModelCreating(ModelBuilder modelBuilder) @@ -517,10 +521,11 @@ private class NeweyContextN7 : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .UseLazyLoadingProxies(false) - .UseInternalServiceProvider(new ServiceCollection() - .AddEntityFrameworkInMemoryDatabase() - .AddEntityFrameworkProxies() - .BuildServiceProvider()) + .UseInternalServiceProvider( + new ServiceCollection() + .AddEntityFrameworkInMemoryDatabase() + .AddEntityFrameworkProxies() + .BuildServiceProvider()) .UseInMemoryDatabase(Guid.NewGuid().ToString()); protected override void OnModelCreating(ModelBuilder modelBuilder) diff --git a/test/EFCore.Relational.Specification.Tests/CommandInterceptionTestBase.cs b/test/EFCore.Relational.Specification.Tests/CommandInterceptionTestBase.cs index a3e8358ba55..6638fff312e 100644 --- a/test/EFCore.Relational.Specification.Tests/CommandInterceptionTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/CommandInterceptionTestBase.cs @@ -1364,7 +1364,7 @@ public virtual async Task Intercept_query_with_two_injected_interceptors(bool as var injectedInterceptor1 = new MutatingReaderCommandInterceptor(); var injectedInterceptor2 = new ResultReplacingReaderCommandInterceptor(); - using (var context = CreateContext(null,injectedInterceptor1, injectedInterceptor2)) + using (var context = CreateContext(null, injectedInterceptor1, injectedInterceptor2)) { await TestCompoisteQueryInterceptors(context, injectedInterceptor2, injectedInterceptor1, async); } @@ -1402,10 +1402,7 @@ public virtual async Task Intercept_non_query_with_two_injected_interceptors(boo public virtual async Task Intercept_query_with_explicitly_composed_app_interceptor(bool async) { using (var context = CreateContext( - new IInterceptor[] - { - new MutatingReaderCommandInterceptor(), new ResultReplacingReaderCommandInterceptor() - })) + new IInterceptor[] { new MutatingReaderCommandInterceptor(), new ResultReplacingReaderCommandInterceptor() })) { var results = async ? await context.Set().ToListAsync() @@ -1436,10 +1433,7 @@ private static void AssertCompositeResults(List results) public virtual async Task Intercept_scalar_with_explicitly_composed_app_interceptor(bool async) { using (var context = CreateContext( - new IInterceptor[] - { - new MutatingScalarCommandInterceptor(), new ResultReplacingScalarCommandInterceptor() - })) + new IInterceptor[] { new MutatingScalarCommandInterceptor(), new ResultReplacingScalarCommandInterceptor() })) { await TestCompositeScalarInterceptors(context, async); } @@ -1451,10 +1445,7 @@ public virtual async Task Intercept_scalar_with_explicitly_composed_app_intercep public virtual async Task Intercept_non_query_with_explicitly_composed_app_interceptor(bool async) { using (var context = CreateContext( - new IInterceptor[] - { - new MutatingNonQueryCommandInterceptor(), new ResultReplacingNonQueryCommandInterceptor() - })) + new IInterceptor[] { new MutatingNonQueryCommandInterceptor(), new ResultReplacingNonQueryCommandInterceptor() })) { await TestCompositeNonQueryInterceptors(context, async); } @@ -1470,42 +1461,51 @@ private class WrappingDbCommand : DbCommand public override int ExecuteNonQuery() => _command.ExecuteNonQuery(); public override object ExecuteScalar() => _command.ExecuteScalar(); public override void Prepare() => _command.Prepare(); + public override string CommandText { get => _command.CommandText; set => _command.CommandText = value; } + public override int CommandTimeout { get => _command.CommandTimeout; set => _command.CommandTimeout = value; } + public override CommandType CommandType { get => _command.CommandType; set => _command.CommandType = value; } + public override UpdateRowSource UpdatedRowSource { get => _command.UpdatedRowSource; set => _command.UpdatedRowSource = value; } + protected override DbConnection DbConnection { get => _command.Connection; set => _command.Connection = value; } + protected override DbParameterCollection DbParameterCollection => _command.Parameters; + protected override DbTransaction DbTransaction { get => _command.Transaction; set => _command.Transaction = value; } + public override bool DesignTimeVisible { get => _command.DesignTimeVisible; set => _command.DesignTimeVisible = value; } + protected override DbParameter CreateDbParameter() => _command.CreateParameter(); protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) => _command.ExecuteReader(); } @@ -1514,15 +1514,9 @@ private class FakeDbDataReader : DbDataReader { private int _index; - private readonly int[] _ints = - { - 977, 988, 999 - }; + private readonly int[] _ints = { 977, 988, 999 }; - private readonly string[] _strings = - { - "<977>", "<988>", "<999>" - }; + private readonly string[] _strings = { "<977>", "<988>", "<999>" }; public override bool Read() => _index++ < _ints.Length; diff --git a/test/EFCore.Relational.Specification.Tests/ConnectionInterceptionTestBase.cs b/test/EFCore.Relational.Specification.Tests/ConnectionInterceptionTestBase.cs index 231a72291bc..38af13057d2 100644 --- a/test/EFCore.Relational.Specification.Tests/ConnectionInterceptionTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/ConnectionInterceptionTestBase.cs @@ -132,14 +132,8 @@ public virtual async Task Intercept_connection_with_multiple_interceptors(bool a var interceptor3 = new ConnectionInterceptor(); var interceptor4 = new ConnectionOverridingInterceptor(); using (var context = CreateContext( - new IInterceptor[] - { - new NoOpConnectionInterceptor(), interceptor1, interceptor2 - }, - new IInterceptor[] - { - interceptor3, interceptor4, new NoOpConnectionInterceptor() - })) + new IInterceptor[] { new NoOpConnectionInterceptor(), interceptor1, interceptor2 }, + new IInterceptor[] { interceptor3, interceptor4, new NoOpConnectionInterceptor() })) { // Test infrastructure uses an open connection, so close it first. var connection = context.Database.GetDbConnection(); diff --git a/test/EFCore.Relational.Specification.Tests/MigrationSqlGeneratorTestBase.cs b/test/EFCore.Relational.Specification.Tests/MigrationSqlGeneratorTestBase.cs index c3fa1937df2..b2335c7273e 100644 --- a/test/EFCore.Relational.Specification.Tests/MigrationSqlGeneratorTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/MigrationSqlGeneratorTestBase.cs @@ -3,7 +3,6 @@ using System; using System.Linq; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations.Operations; @@ -27,10 +26,7 @@ public virtual void CreateIndexOperation_with_filter_where_clause() modelBuilder => modelBuilder.Entity("People").Property("Name").IsRequired(), new CreateIndexOperation { - Name = "IX_People_Name", - Table = "People", - Columns = new[] { "Name" }, - Filter = "[Name] IS NOT NULL" + Name = "IX_People_Name", Table = "People", Columns = new[] { "Name" }, Filter = "[Name] IS NOT NULL" }); [ConditionalFact] @@ -76,12 +72,7 @@ public virtual void AddColumnOperation_with_defaultValueSql() [ConditionalFact] public virtual void AddColumnOperation_without_column_type() => Generate( - new AddColumnOperation - { - Table = "People", - Name = "Alias", - ClrType = typeof(string) - }); + new AddColumnOperation { Table = "People", Name = "Alias", ClrType = typeof(string) }); [ConditionalFact] public virtual void AddColumnOperation_with_ansi() @@ -219,13 +210,7 @@ public virtual void AddColumnOperation_with_shared_column() modelBuilder.Entity(); modelBuilder.Entity(); }, - new AddColumnOperation - { - Table = "Base", - Name = "Foo", - ClrType = typeof(string), - IsNullable = true - }); + new AddColumnOperation { Table = "Base", Name = "Foo", ClrType = typeof(string), IsNullable = true }); private class Base { @@ -265,41 +250,23 @@ public virtual void AddForeignKeyOperation_without_name() => Generate( new AddForeignKeyOperation { - Table = "People", - Columns = new[] { "SpouseId" }, - PrincipalTable = "People", - PrincipalColumns = new[] { "Id" } + Table = "People", Columns = new[] { "SpouseId" }, PrincipalTable = "People", PrincipalColumns = new[] { "Id" } }); [ConditionalFact] public virtual void AddForeignKeyOperation_without_principal_columns() => Generate( - new AddForeignKeyOperation - { - Table = "People", - Columns = new[] { "SpouseId" }, - PrincipalTable = "People" - }); + new AddForeignKeyOperation { Table = "People", Columns = new[] { "SpouseId" }, PrincipalTable = "People" }); [ConditionalFact] public virtual void AddPrimaryKeyOperation_with_name() => Generate( - new AddPrimaryKeyOperation - { - Table = "People", - Schema = "dbo", - Name = "PK_People", - Columns = new[] { "Id1", "Id2" } - }); + new AddPrimaryKeyOperation { Table = "People", Schema = "dbo", Name = "PK_People", Columns = new[] { "Id1", "Id2" } }); [ConditionalFact] public virtual void AddPrimaryKeyOperation_without_name() => Generate( - new AddPrimaryKeyOperation - { - Table = "People", - Columns = new[] { "Id" } - }); + new AddPrimaryKeyOperation { Table = "People", Columns = new[] { "Id" } }); [ConditionalFact] public virtual void AddUniqueConstraintOperation_with_name() @@ -315,21 +282,14 @@ public virtual void AddUniqueConstraintOperation_with_name() [ConditionalFact] public virtual void AddUniqueConstraintOperation_without_name() => Generate( - new AddUniqueConstraintOperation - { - Table = "People", - Columns = new[] { "SSN" } - }); + new AddUniqueConstraintOperation { Table = "People", Columns = new[] { "SSN" } }); [ConditionalFact] public virtual void CreateCheckConstraintOperation_with_name() => Generate( new CreateCheckConstraintOperation { - Table = "People", - Schema = "dbo", - Name = "CK_People_DriverLicense", - Sql = "DriverLicense_Number > 0" + Table = "People", Schema = "dbo", Name = "CK_People_DriverLicense", Sql = "DriverLicense_Number > 0" }); [ConditionalFact] @@ -349,12 +309,7 @@ public virtual void AlterColumnOperation() [ConditionalFact] public virtual void AlterColumnOperation_without_column_type() => Generate( - new AlterColumnOperation - { - Table = "People", - Name = "LuckyNumber", - ClrType = typeof(int) - }); + new AlterColumnOperation { Table = "People", Name = "LuckyNumber", ClrType = typeof(int) }); [ConditionalFact] public virtual void AlterSequenceOperation_with_minValue_and_maxValue() @@ -372,33 +327,18 @@ public virtual void AlterSequenceOperation_with_minValue_and_maxValue() [ConditionalFact] public virtual void AlterSequenceOperation_without_minValue_and_maxValue() => Generate( - new AlterSequenceOperation - { - Name = "EntityFrameworkHiLoSequence", - IncrementBy = 1 - }); + new AlterSequenceOperation { Name = "EntityFrameworkHiLoSequence", IncrementBy = 1 }); [ConditionalFact] public virtual void RenameTableOperation_legacy() => Generate( - new RenameTableOperation - { - Name = "People", - Schema = "dbo", - NewName = "Person" - }); + new RenameTableOperation { Name = "People", Schema = "dbo", NewName = "Person" }); [ConditionalFact] public virtual void RenameTableOperation() => Generate( modelBuilder => modelBuilder.HasAnnotation(CoreAnnotationNames.ProductVersion, "2.1.0"), - new RenameTableOperation - { - Name = "People", - Schema = "dbo", - NewName = "Person", - NewSchema = "dbo" - }); + new RenameTableOperation { Name = "People", Schema = "dbo", NewName = "Person", NewSchema = "dbo" }); [ConditionalFact] public virtual void CreateIndexOperation_unique() @@ -415,13 +355,7 @@ public virtual void CreateIndexOperation_unique() [ConditionalFact] public virtual void CreateIndexOperation_nonunique() => Generate( - new CreateIndexOperation - { - Name = "IX_People_Name", - Table = "People", - Columns = new[] { "Name" }, - IsUnique = false - }); + new CreateIndexOperation { Name = "IX_People_Name", Table = "People", Columns = new[] { "Name" }, IsUnique = false }); [ConditionalFact] public virtual void CreateIndexOperation_with_where_clauses() @@ -470,10 +404,7 @@ public virtual void CreateSequenceOperation_without_minValue_and_maxValue() => Generate( new CreateSequenceOperation { - Name = "EntityFrameworkHiLoSequence", - ClrType = typeof(long), - StartValue = 3, - IncrementBy = 1 + Name = "EntityFrameworkHiLoSequence", ClrType = typeof(long), StartValue = 3, IncrementBy = 1 }); [ConditionalFact] @@ -485,13 +416,7 @@ public virtual void CreateTableOperation() Schema = "dbo", Columns = { - new AddColumnOperation - { - Name = "Id", - Table = "People", - ClrType = typeof(int), - IsNullable = false - }, + new AddColumnOperation { Name = "Id", Table = "People", ClrType = typeof(int), IsNullable = false }, new AddColumnOperation { Name = "EmployerId", @@ -509,31 +434,14 @@ public virtual void CreateTableOperation() IsNullable = true } }, - PrimaryKey = new AddPrimaryKeyOperation - { - Columns = new[] { "Id" } - }, - UniqueConstraints = - { - new AddUniqueConstraintOperation - { - Columns = new[] { "SSN" } - } - }, - CheckConstraints = - { - new CreateCheckConstraintOperation - { - Sql = "SSN > 0" - } - }, + PrimaryKey = new AddPrimaryKeyOperation { Columns = new[] { "Id" } }, + UniqueConstraints = { new AddUniqueConstraintOperation { Columns = new[] { "SSN" } } }, + CheckConstraints = { new CreateCheckConstraintOperation { Sql = "SSN > 0" } }, ForeignKeys = { new AddForeignKeyOperation { - Columns = new[] { "EmployerId" }, - PrincipalTable = "Companies", - PrincipalColumns = new[] { "Id" } + Columns = new[] { "EmployerId" }, PrincipalTable = "Companies", PrincipalColumns = new[] { "Id" } } }, Comment = "Table comment" @@ -547,101 +455,54 @@ public virtual void CreateTableOperation_no_key() Name = "Anonymous", Columns = { - new AddColumnOperation - { - Name = "Value", - Table = "Anonymous", - ClrType = typeof(int), - IsNullable = false - } + new AddColumnOperation { Name = "Value", Table = "Anonymous", ClrType = typeof(int), IsNullable = false } } }); [ConditionalFact] public virtual void DropColumnOperation() => Generate( - new DropColumnOperation - { - Table = "People", - Schema = "dbo", - Name = "LuckyNumber" - }); + new DropColumnOperation { Table = "People", Schema = "dbo", Name = "LuckyNumber" }); [ConditionalFact] public virtual void DropForeignKeyOperation() => Generate( - new DropForeignKeyOperation - { - Table = "People", - Schema = "dbo", - Name = "FK_People_Companies" - }); + new DropForeignKeyOperation { Table = "People", Schema = "dbo", Name = "FK_People_Companies" }); [ConditionalFact] public virtual void DropIndexOperation() => Generate( - new DropIndexOperation - { - Name = "IX_People_Name", - Table = "People", - Schema = "dbo" - }); + new DropIndexOperation { Name = "IX_People_Name", Table = "People", Schema = "dbo" }); [ConditionalFact] public virtual void DropPrimaryKeyOperation() => Generate( - new DropPrimaryKeyOperation - { - Table = "People", - Schema = "dbo", - Name = "PK_People" - }); + new DropPrimaryKeyOperation { Table = "People", Schema = "dbo", Name = "PK_People" }); [ConditionalFact] public virtual void DropSequenceOperation() => Generate( - new DropSequenceOperation - { - Name = "EntityFrameworkHiLoSequence", - Schema = "dbo" - }); + new DropSequenceOperation { Name = "EntityFrameworkHiLoSequence", Schema = "dbo" }); [ConditionalFact] public virtual void DropTableOperation() => Generate( - new DropTableOperation - { - Name = "People", - Schema = "dbo" - }); + new DropTableOperation { Name = "People", Schema = "dbo" }); [ConditionalFact] public virtual void DropUniqueConstraintOperation() => Generate( - new DropUniqueConstraintOperation - { - Table = "People", - Schema = "dbo", - Name = "AK_People_SSN" - }); + new DropUniqueConstraintOperation { Table = "People", Schema = "dbo", Name = "AK_People_SSN" }); [ConditionalFact] public virtual void DropCheckConstraintOperation() => Generate( - new DropCheckConstraintOperation - { - Table = "People", - Schema = "dbo", - Name = "CK_People_SSN" - }); + new DropCheckConstraintOperation { Table = "People", Schema = "dbo", Name = "CK_People_SSN" }); [ConditionalFact] public virtual void SqlOperation() => Generate( - new SqlOperation - { - Sql = "-- I <3 DDL" - }); + new SqlOperation { Sql = "-- I <3 DDL" }); [ConditionalFact] public virtual void InsertDataOperation() @@ -652,27 +513,14 @@ public virtual void InsertDataOperation() Columns = new[] { "Id", "Full Name" }, Values = new object[,] { - { 0, null }, - { 1, "Daenerys Targaryen" }, - { 2, "John Snow" }, - { 3, "Arya Stark" }, - { 4, "Harry Strickland" } + { 0, null }, { 1, "Daenerys Targaryen" }, { 2, "John Snow" }, { 3, "Arya Stark" }, { 4, "Harry Strickland" } } }); [ConditionalFact] public virtual void DeleteDataOperation_simple_key() => Generate( - new DeleteDataOperation - { - Table = "People", - KeyColumns = new[] { "Id" }, - KeyValues = new object[,] - { - { 2 }, - { 4 } - } - }); + new DeleteDataOperation { Table = "People", KeyColumns = new[] { "Id" }, KeyValues = new object[,] { { 2 }, { 4 } } }); [ConditionalFact] public virtual void DeleteDataOperation_composite_key() @@ -681,11 +529,7 @@ public virtual void DeleteDataOperation_composite_key() { Table = "People", KeyColumns = new[] { "First Name", "Last Name" }, - KeyValues = new object[,] - { - { "Hodor", null }, - { "Daenerys", "Targaryen" } - } + KeyValues = new object[,] { { "Hodor", null }, { "Daenerys", "Targaryen" } } }); [ConditionalFact] @@ -695,17 +539,9 @@ public virtual void UpdateDataOperation_simple_key() { Table = "People", KeyColumns = new[] { "Id" }, - KeyValues = new object[,] - { - { 1 }, - { 4 } - }, + KeyValues = new object[,] { { 1 }, { 4 } }, Columns = new[] { "Full Name" }, - Values = new object[,] - { - { "Daenerys Stormborn" }, - { "Homeless Harry Strickland" } - } + Values = new object[,] { { "Daenerys Stormborn" }, { "Homeless Harry Strickland" } } }); [ConditionalFact] @@ -715,17 +551,9 @@ public virtual void UpdateDataOperation_composite_key() { Table = "People", KeyColumns = new[] { "Id", "Last Name" }, - KeyValues = new object[,] - { - { 0, null }, - { 4, "Strickland" } - }, + KeyValues = new object[,] { { 0, null }, { 4, "Strickland" } }, Columns = new[] { "First Name" }, - Values = new object[,] - { - { "Hodor" }, - { "Harry" } - } + Values = new object[,] { { "Hodor" }, { "Harry" } } }); [ConditionalFact] @@ -735,17 +563,9 @@ public virtual void UpdateDataOperation_multiple_columns() { Table = "People", KeyColumns = new[] { "Id" }, - KeyValues = new object[,] - { - { 1 }, - { 4 } - }, + KeyValues = new object[,] { { 1 }, { 4 } }, Columns = new[] { "First Name", "Nickname" }, - Values = new object[,] - { - { "Daenerys", "Dany" }, - { "Harry", "Homeless" } - } + Values = new object[,] { { "Daenerys", "Dany" }, { "Harry", "Homeless" } } }); protected TestHelpers TestHelpers { get; } diff --git a/test/EFCore.Relational.Specification.Tests/MigrationsFixtureBase.cs b/test/EFCore.Relational.Specification.Tests/MigrationsFixtureBase.cs index 38600e25508..17fdb2ce673 100644 --- a/test/EFCore.Relational.Specification.Tests/MigrationsFixtureBase.cs +++ b/test/EFCore.Relational.Specification.Tests/MigrationsFixtureBase.cs @@ -60,11 +60,7 @@ protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder .CreateTable( name: "Table1", - columns: x => new - { - Id = x.Column(), - Foo = x.Column() - }) + columns: x => new { Id = x.Column(), Foo = x.Column() }) .PrimaryKey( name: "PK_Table1", columns: x => x.Id); diff --git a/test/EFCore.Relational.Specification.Tests/MigrationsTestBase.cs b/test/EFCore.Relational.Specification.Tests/MigrationsTestBase.cs index 9051933c8d8..7b360b4d033 100644 --- a/test/EFCore.Relational.Specification.Tests/MigrationsTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/MigrationsTestBase.cs @@ -7,11 +7,8 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Migrations.Internal; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Microsoft.Extensions.DependencyInjection; using Xunit; diff --git a/test/EFCore.Relational.Specification.Tests/Query/AsyncFromSqlQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/AsyncFromSqlQueryTestBase.cs index becd7c57b54..a046f0872a0 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/AsyncFromSqlQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/AsyncFromSqlQueryTestBase.cs @@ -90,11 +90,7 @@ var actual = await (from c in context.Set().FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers]")) from o in context.Set().FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Orders]")) where c.CustomerID == o.CustomerID - select new - { - c, - o - }) + select new { c, o }) .ToArrayAsync(); Assert.Equal(830, actual.Length); @@ -112,13 +108,10 @@ public virtual async Task FromSqlRaw_queryable_multiple_composed_with_closure_pa var actual = await (from c in context.Set().FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers]")) from o in context.Set().FromSqlRaw( - NormalizeDelimetersInRawString("SELECT * FROM [Orders] WHERE [OrderDate] BETWEEN {0} AND {1}"), startDate, endDate) + NormalizeDelimetersInRawString("SELECT * FROM [Orders] WHERE [OrderDate] BETWEEN {0} AND {1}"), startDate, + endDate) where c.CustomerID == o.CustomerID - select new - { - c, - o - }) + select new { c, o }) .ToArrayAsync(); Assert.Equal(411, actual.Length); @@ -138,13 +131,10 @@ var actual = await (from c in context.Set().FromSqlRaw( NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = {0}"), city) from o in context.Set().FromSqlRaw( - NormalizeDelimetersInRawString("SELECT * FROM [Orders] WHERE [OrderDate] BETWEEN {0} AND {1}"), startDate, endDate) + NormalizeDelimetersInRawString("SELECT * FROM [Orders] WHERE [OrderDate] BETWEEN {0} AND {1}"), startDate, + endDate) where c.CustomerID == o.CustomerID - select new - { - c, - o - }) + select new { c, o }) .ToArrayAsync(); Assert.Equal(25, actual.Length); @@ -194,7 +184,8 @@ public virtual async Task FromSqlRaw_queryable_with_parameters() using (var context = CreateContext()) { var actual = await context.Set().FromSqlRaw( - NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = {0} AND [ContactTitle] = {1}"), city, contactTitle) + NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = {0} AND [ContactTitle] = {1}"), city, + contactTitle) .ToArrayAsync(); Assert.Equal(3, actual.Length); @@ -227,13 +218,15 @@ public virtual async Task FromSqlRaw_queryable_simple_cache_key_includes_query_s { using (var context = CreateContext()) { - var actual = await context.Set().FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = 'London'")) + var actual = await context.Set() + .FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = 'London'")) .ToArrayAsync(); Assert.Equal(6, actual.Length); Assert.True(actual.All(c => c.City == "London")); - actual = await context.Set().FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = 'Seattle'")) + actual = await context.Set() + .FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = 'Seattle'")) .ToArrayAsync(); Assert.Equal(1, actual.Length); @@ -290,11 +283,7 @@ public virtual async Task FromSqlRaw_queryable_simple_projection_not_composed() { var actual = await context.Set().FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers]")) .Select( - c => new - { - c.CustomerID, - c.City - }) + c => new { c.CustomerID, c.City }) .AsNoTracking() .ToArrayAsync(); diff --git a/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs index 5c02232fe0a..d5ffcf5e626 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs @@ -7,7 +7,6 @@ using System.Linq; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -258,7 +257,8 @@ public virtual void FromSqlRaw_queryable_composed_after_removing_whitespaces() public virtual void FromSqlRaw_queryable_composed_compiled() { var query = EF.CompileQuery( - (NorthwindContext context) => context.Set().FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers]")) + (NorthwindContext context) => context.Set() + .FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers]")) .Where(c => c.ContactName.Contains("z"))); using (var context = CreateContext()) @@ -367,11 +367,7 @@ var actual = (from c in context.Set().FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers]")) from o in context.Set().FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Orders]")) where c.CustomerID == o.CustomerID - select new - { - c, - o - }) + select new { c, o }) .ToArray(); Assert.Equal(830, actual.Length); @@ -393,11 +389,7 @@ from o in context.Set().FromSqlRaw( startDate, endDate) where c.CustomerID == o.CustomerID - select new - { - c, - o - }) + select new { c, o }) .ToArray(); Assert.Equal(411, actual.Length); @@ -421,11 +413,7 @@ from o in context.Set().FromSqlRaw( startDate, endDate) where c.CustomerID == o.CustomerID - select new - { - c, - o - }) + select new { c, o }) .ToArray(); Assert.Equal(25, actual.Length); @@ -442,11 +430,7 @@ from o in context.Set().FromSqlRaw( startDate, endDate) where c.CustomerID == o.CustomerID - select new - { - c, - o - }) + select new { c, o }) .ToArray(); Assert.Equal(1, actual.Length); @@ -496,7 +480,8 @@ public virtual void FromSqlRaw_queryable_with_parameters() using (var context = CreateContext()) { var actual = context.Set().FromSqlRaw( - NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = {0} AND [ContactTitle] = {1}"), city, contactTitle) + NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = {0} AND [ContactTitle] = {1}"), city, + contactTitle) .ToArray(); Assert.Equal(3, actual.Length); @@ -566,15 +551,13 @@ public virtual void FromSqlInterpolated_queryable_multiple_composed_with_paramet using (var context = CreateContext()) { var actual - = (from c in context.Set().FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = {0}"), city) + = (from c in context.Set().FromSqlRaw( + NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = {0}"), city) from o in context.Set().FromSqlInterpolated( - NormalizeDelimetersInInterpolatedString($"SELECT * FROM [Orders] WHERE [OrderDate] BETWEEN {startDate} AND {endDate}")) + NormalizeDelimetersInInterpolatedString( + $"SELECT * FROM [Orders] WHERE [OrderDate] BETWEEN {startDate} AND {endDate}")) where c.CustomerID == o.CustomerID - select new - { - c, - o - }) + select new { c, o }) .ToArray(); Assert.Equal(25, actual.Length); @@ -584,15 +567,13 @@ from o in context.Set().FromSqlInterpolated( endDate = new DateTime(1998, 5, 1); actual - = (from c in context.Set().FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = {0}"), city) + = (from c in context.Set().FromSqlRaw( + NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = {0}"), city) from o in context.Set().FromSqlInterpolated( - NormalizeDelimetersInInterpolatedString($"SELECT * FROM [Orders] WHERE [OrderDate] BETWEEN {startDate} AND {endDate}")) + NormalizeDelimetersInInterpolatedString( + $"SELECT * FROM [Orders] WHERE [OrderDate] BETWEEN {startDate} AND {endDate}")) where c.CustomerID == o.CustomerID - select new - { - c, - o - }) + select new { c, o }) .ToArray(); Assert.Equal(1, actual.Length); @@ -624,7 +605,8 @@ public virtual void FromSqlRaw_queryable_with_parameters_and_closure() using (var context = CreateContext()) { - var actual = context.Set().FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = {0}"), city) + var actual = context.Set().FromSqlRaw( + NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = {0}"), city) .Where(c => c.ContactTitle == contactTitle) .ToArray(); @@ -639,13 +621,15 @@ public virtual void FromSqlRaw_queryable_simple_cache_key_includes_query_string( { using (var context = CreateContext()) { - var actual = context.Set().FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = 'London'")) + var actual = context.Set() + .FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = 'London'")) .ToArray(); Assert.Equal(6, actual.Length); Assert.True(actual.All(c => c.City == "London")); - actual = context.Set().FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = 'Seattle'")) + actual = context.Set() + .FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = 'Seattle'")) .ToArray(); Assert.Equal(1, actual.Length); @@ -746,7 +730,8 @@ public virtual void FromSqlRaw_annotations_do_not_affect_successive_calls() { using (var context = CreateContext()) { - var actual = context.Customers.FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [ContactName] LIKE '%z%'")) + var actual = context.Customers + .FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [ContactName] LIKE '%z%'")) .ToArray(); Assert.Equal(14, actual.Length); @@ -778,7 +763,8 @@ public virtual void FromSqlRaw_with_dbParameter() { var parameter = CreateDbParameter("@city", "London"); - var actual = context.Customers.FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = @city"), parameter) + var actual = context.Customers.FromSqlRaw( + NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = @city"), parameter) .ToArray(); Assert.Equal(6, actual.Length); @@ -793,7 +779,8 @@ public virtual void FromSqlRaw_with_dbParameter_without_name_prefix() { var parameter = CreateDbParameter("city", "London"); - var actual = context.Customers.FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = @city"), parameter) + var actual = context.Customers.FromSqlRaw( + NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = @city"), parameter) .ToArray(); Assert.Equal(6, actual.Length); @@ -870,7 +857,8 @@ public virtual void FromSqlRaw_with_db_parameters_called_multiple_times() { var parameter = CreateDbParameter("@id", "ALFKI"); - var query = context.Customers.FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [CustomerID] = @id"), parameter); + var query = context.Customers.FromSqlRaw( + NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [CustomerID] = @id"), parameter); // ReSharper disable PossibleMultipleEnumeration var result1 = query.ToList(); @@ -894,11 +882,7 @@ public virtual void FromSqlRaw_with_SelectMany_and_include() from c2 in context.Set().FromSqlRaw( NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [CustomerID] = 'AROUT'")) .Include(c => c.Orders) - select new - { - c1, - c2 - }; + select new { c1, c2 }; var result = query.ToList(); Assert.Equal(1, result.Count); @@ -924,14 +908,11 @@ public virtual void FromSqlRaw_with_join_and_include() { var query = from c in context.Set() .FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [CustomerID] = 'ALFKI'")) - join o in context.Set().FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Orders] WHERE [OrderID] <> 1")) + join o in context.Set().FromSqlRaw( + NormalizeDelimetersInRawString("SELECT * FROM [Orders] WHERE [OrderID] <> 1")) .Include(o => o.OrderDetails) on c.CustomerID equals o.CustomerID - select new - { - c, - o - }; + select new { c, o }; var result = query.ToList(); @@ -973,7 +954,8 @@ public virtual void FromSqlInterpolated_with_inlined_db_parameter() var parameter = CreateDbParameter("@somename", "ALFKI"); var actual = context.Customers - .FromSqlInterpolated(NormalizeDelimetersInInterpolatedString($"SELECT * FROM [Customers] WHERE [CustomerID] = {parameter}")) + .FromSqlInterpolated( + NormalizeDelimetersInInterpolatedString($"SELECT * FROM [Customers] WHERE [CustomerID] = {parameter}")) .ToList(); Assert.Equal(1, actual.Count); @@ -989,7 +971,8 @@ public virtual void FromSqlInterpolated_with_inlined_db_parameter_without_name_p var parameter = CreateDbParameter("somename", "ALFKI"); var actual = context.Customers - .FromSqlInterpolated(NormalizeDelimetersInInterpolatedString($"SELECT * FROM [Customers] WHERE [CustomerID] = {parameter}")) + .FromSqlInterpolated( + NormalizeDelimetersInInterpolatedString($"SELECT * FROM [Customers] WHERE [CustomerID] = {parameter}")) .ToList(); Assert.Equal(1, actual.Count); @@ -1019,7 +1002,8 @@ public virtual void FromSqlInterpolated_parameterization_issue_12213() .Where( o => o.OrderID <= max && context.Orders - .FromSqlInterpolated(NormalizeDelimetersInInterpolatedString($"SELECT * FROM [Orders] WHERE [OrderID] >= {min}")) + .FromSqlInterpolated( + NormalizeDelimetersInInterpolatedString($"SELECT * FROM [Orders] WHERE [OrderID] >= {min}")) .Select(i => i.OrderID) .Contains(o.OrderID)) .Select(o => o.OrderID); @@ -1049,10 +1033,7 @@ public virtual void Entity_equality_through_fromsql() { var actual = context.Set() .FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Orders]")) - .Where(o => o.Customer == new Customer - { - CustomerID = "VINET" - }) + .Where(o => o.Customer == new Customer { CustomerID = "VINET" }) .ToArray(); Assert.Equal(5, actual.Length); diff --git a/test/EFCore.Relational.Specification.Tests/Query/FromSqlSprocQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/FromSqlSprocQueryTestBase.cs index c1d997f90ca..7d3006438b1 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/FromSqlSprocQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/FromSqlSprocQueryTestBase.cs @@ -2,11 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; @@ -79,11 +76,7 @@ public virtual async Task From_sql_queryable_stored_procedure_re_proj .FromSqlRaw(TenMostExpensiveProductsSproc, GetTenMostExpensiveProductsParameters()) .Select( mep => - new MostExpensiveProduct - { - TenMostExpensiveProducts = "Foo", - UnitPrice = mep.UnitPrice - }); + new MostExpensiveProduct { TenMostExpensiveProducts = "Foo", UnitPrice = mep.UnitPrice }); try { var _ = async @@ -114,11 +107,7 @@ public virtual async Task From_sql_queryable_stored_procedure_re_projection_on_c var actual = (async ? await query.ToListAsync() : query.ToList()) .Select( mep => - new MostExpensiveProduct - { - TenMostExpensiveProducts = "Foo", - UnitPrice = mep.UnitPrice - }).ToArray(); + new MostExpensiveProduct { TenMostExpensiveProducts = "Foo", UnitPrice = mep.UnitPrice }).ToArray(); Assert.Equal(10, actual.Length); Assert.True(actual.All(mep => mep.TenMostExpensiveProducts == "Foo")); @@ -256,7 +245,6 @@ public virtual async Task From_sql_queryable_stored_procedure_with_parameter_com } } - [ConditionalTheory] [InlineData(false)] [InlineData(true)] @@ -394,10 +382,7 @@ public virtual async Task From_sql_queryable_with_multiple_stored_pro from b in context.Set() .FromSqlRaw(TenMostExpensiveProductsSproc, GetTenMostExpensiveProductsParameters()) where a.TenMostExpensiveProducts == b.TenMostExpensiveProducts - select new - { - a, b - }; + select new { a, b }; try { @@ -434,10 +419,7 @@ public virtual async Task From_sql_queryable_with_multiple_stored_procedures_on_ var actual = (from a in results1 from b in results2 where a.TenMostExpensiveProducts == b.TenMostExpensiveProducts - select new - { - a, b - }).ToArray(); + select new { a, b }).ToArray(); Assert.Equal(10, actual.Length); } @@ -455,10 +437,7 @@ public virtual async Task From_sql_queryable_stored_procedure_and_sel from p in context.Set() .FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Products]")) where mep.TenMostExpensiveProducts == p.ProductName - select new - { - mep, p - }; + select new { mep, p }; try { @@ -476,7 +455,6 @@ from p in context.Set() } } - [ConditionalTheory] [InlineData(false)] [InlineData(true)] @@ -495,10 +473,7 @@ public virtual async Task From_sql_queryable_stored_procedure_and_select_on_clie var actual = (from mep in results1 from p in results2 where mep.TenMostExpensiveProducts == p.ProductName - select new - { - mep, p - }).ToArray(); + select new { mep, p }).ToArray(); Assert.Equal(10, actual.Length); } @@ -515,10 +490,7 @@ public virtual async Task From_sql_queryable_select_and_stored_proced from mep in context.Set() .FromSqlRaw(TenMostExpensiveProductsSproc, GetTenMostExpensiveProductsParameters()) where mep.TenMostExpensiveProducts == p.ProductName - select new - { - mep, p - }; + select new { mep, p }; try { @@ -554,10 +526,7 @@ public virtual async Task From_sql_queryable_select_and_stored_procedure_on_clie var actual = (from p in results1 from mep in results2 where mep.TenMostExpensiveProducts == p.ProductName - select new - { - mep, p - }).ToArray(); + select new { mep, p }).ToArray(); Assert.Equal(10, actual.Length); } diff --git a/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs index 57a1d187eaa..ec7314bcc7e 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestUtilities; namespace Microsoft.EntityFrameworkCore.Query diff --git a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs index 6a8c74ce33b..fe9306b4b06 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using Microsoft.EntityFrameworkCore.TestModels.NullSemanticsModel; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable SimplifyConditionalTernaryExpression @@ -286,13 +285,7 @@ public virtual void Join_uses_database_semantics() { var query = from e1 in context.Entities1 join e2 in context.Entities2 on e1.NullableIntA equals e2.NullableIntB - select new - { - Id1 = e1.Id, - Id2 = e2.Id, - e1.NullableIntA, - e2.NullableIntB - }; + select new { Id1 = e1.Id, Id2 = e2.Id, e1.NullableIntA, e2.NullableIntB }; query.ToList(); } @@ -543,7 +536,8 @@ public virtual void Null_comparison_in_join_key_with_relational_nulls() { using (var ctx = CreateContext(useRelationalNulls: true)) { - var query = ctx.Entities1.Join(ctx.Entities2, e1 => e1.NullableStringA != "Foo", e2 => e2.NullableBoolB != true, (o, i) => new { o, i }); + var query = ctx.Entities1.Join( + ctx.Entities2, e1 => e1.NullableStringA != "Foo", e2 => e2.NullableBoolB != true, (o, i) => new { o, i }); var result = query.ToList(); Assert.Equal(162, result.Count); @@ -757,21 +751,13 @@ public virtual void Projecting_nullable_bool_with_coalesce() { var expected = context.Entities1.ToList() .Select( - e => new - { - e.Id, - Coalesce = e.NullableBoolA ?? false - }); + e => new { e.Id, Coalesce = e.NullableBoolA ?? false }); ClearLog(); var query = context.Entities1 .Select( - e => new - { - e.Id, - Coalesce = e.NullableBoolA ?? false - }); + e => new { e.Id, Coalesce = e.NullableBoolA ?? false }); var results = query.ToList(); Assert.Equal(expected.Count(), results.Count); @@ -789,21 +775,13 @@ public virtual void Projecting_nullable_bool_with_coalesce_nested() { var expected = context.Entities1.ToList() .Select( - e => new - { - e.Id, - Coalesce = e.NullableBoolA ?? (e.NullableBoolB ?? false) - }); + e => new { e.Id, Coalesce = e.NullableBoolA ?? (e.NullableBoolB ?? false) }); ClearLog(); var query = context.Entities1 .Select( - e => new - { - e.Id, - Coalesce = e.NullableBoolA ?? (e.NullableBoolB ?? false) - }); + e => new { e.Id, Coalesce = e.NullableBoolA ?? (e.NullableBoolB ?? false) }); var results = query.ToList(); Assert.Equal(expected.Count(), results.Count); @@ -900,7 +878,11 @@ public virtual void Null_semantics_conditional() { AssertQuery(es => es.Where(e => e.BoolA == (e.BoolB ? e.NullableBoolB : e.NullableBoolC))); AssertQuery(es => es.Where(e => (e.NullableBoolA != e.NullableBoolB ? e.BoolB : e.BoolC) == e.BoolA)); - AssertQuery(es => es.Where(e => (e.BoolA ? e.NullableBoolA != e.NullableBoolB : e.BoolC) != e.BoolB ? e.BoolA : e.NullableBoolB == e.NullableBoolC)); + AssertQuery( + es => es.Where( + e => (e.BoolA ? e.NullableBoolA != e.NullableBoolB : e.BoolC) != e.BoolB + ? e.BoolA + : e.NullableBoolB == e.NullableBoolC)); } [ConditionalFact] @@ -919,36 +901,16 @@ public virtual void Null_semantics_join_with_composite_key() { var query = from e1 in ctx.Entities1 join e2 in ctx.Entities2 - on new - { - one = e1.NullableStringA, - two = e1.NullableStringB != e1.NullableStringC, - three = true - } - equals new - { - one = e2.NullableStringB, - two = e2.NullableBoolA ?? e2.BoolC, - three = true - } + on new { one = e1.NullableStringA, two = e1.NullableStringB != e1.NullableStringC, three = true } + equals new { one = e2.NullableStringB, two = e2.NullableBoolA ?? e2.BoolC, three = true } select new { e1, e2 }; var result = query.ToList(); var expected = (from e1 in ctx.Entities1.ToList() join e2 in ctx.Entities2.ToList() - on new - { - one = e1.NullableStringA, - two = e1.NullableStringB != e1.NullableStringC, - three = true - } - equals new - { - one = e2.NullableStringB, - two = e2.NullableBoolA ?? e2.BoolC, - three = true - } + on new { one = e1.NullableStringA, two = e1.NullableStringB != e1.NullableStringC, three = true } + equals new { one = e2.NullableStringB, two = e2.NullableBoolA ?? e2.BoolC, three = true } select new { e1, e2 }).ToList(); Assert.Equal(result.Count, expected.Count); diff --git a/test/EFCore.Relational.Specification.Tests/Query/QueryNoClientEvalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/QueryNoClientEvalTestBase.cs index dea268a8426..e01dea223fd 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/QueryNoClientEvalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/QueryNoClientEvalTestBase.cs @@ -149,10 +149,7 @@ public virtual void Throws_when_select_many() Assert.Throws( () => (from c1 in context.Customers - from i in new[] - { - 1, 2, 3 - } + from i in new[] { 1, 2, 3 } select c1) .ToList()).Message); } @@ -165,15 +162,13 @@ public virtual void Throws_when_join() { Assert.Equal( CoreStrings.QueryFailed( - @"Join( outer: DbSet, inner: (Unhandled parameter: __p_0), outerKeySelector: (e1) => e1.EmployeeID, innerKeySelector: (i) => i, resultSelector: (e1, i) => e1)", "NavigationExpandingExpressionVisitor"), + @"Join( outer: DbSet, inner: (Unhandled parameter: __p_0), outerKeySelector: (e1) => e1.EmployeeID, innerKeySelector: (i) => i, resultSelector: (e1, i) => e1)", + "NavigationExpandingExpressionVisitor"), RemoveNewLines( Assert.Throws( () => (from e1 in context.Employees - join i in new uint[] - { - 1, 2, 3 - } on e1.EmployeeID equals i + join i in new uint[] { 1, 2, 3 } on e1.EmployeeID equals i select e1) .ToList()).Message)); } @@ -186,15 +181,13 @@ public virtual void Throws_when_group_join() { Assert.Equal( CoreStrings.QueryFailed( - "GroupJoin( outer: DbSet, inner: (Unhandled parameter: __p_0), outerKeySelector: (e1) => e1.EmployeeID, innerKeySelector: (i) => i, resultSelector: (e1, g) => e1)", "NavigationExpandingExpressionVisitor"), + "GroupJoin( outer: DbSet, inner: (Unhandled parameter: __p_0), outerKeySelector: (e1) => e1.EmployeeID, innerKeySelector: (i) => i, resultSelector: (e1, g) => e1)", + "NavigationExpandingExpressionVisitor"), RemoveNewLines( Assert.Throws( () => (from e1 in context.Employees - join i in new uint[] - { - 1, 2, 3 - } on e1.EmployeeID equals i into g + join i in new uint[] { 1, 2, 3 } on e1.EmployeeID equals i into g select e1) .ToList()).Message)); } diff --git a/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs index 4840c17e8d4..4f358f56b28 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs @@ -258,73 +258,19 @@ protected override void Seed(DbContext context) { context.Database.EnsureCreatedResiliently(); - var order11 = new Order - { - Name = "Order11", - ItemCount = 4, - OrderDate = new DateTime(2000, 1, 20) - }; - var order12 = new Order - { - Name = "Order12", - ItemCount = 8, - OrderDate = new DateTime(2000, 2, 21) - }; - var order13 = new Order - { - Name = "Order13", - ItemCount = 15, - OrderDate = new DateTime(2000, 3, 20) - }; - var order21 = new Order - { - Name = "Order21", - ItemCount = 16, - OrderDate = new DateTime(2000, 4, 21) - }; - var order22 = new Order - { - Name = "Order22", - ItemCount = 23, - OrderDate = new DateTime(2000, 5, 20) - }; - var order31 = new Order - { - Name = "Order31", - ItemCount = 42, - OrderDate = new DateTime(2000, 6, 21) - }; + var order11 = new Order { Name = "Order11", ItemCount = 4, OrderDate = new DateTime(2000, 1, 20) }; + var order12 = new Order { Name = "Order12", ItemCount = 8, OrderDate = new DateTime(2000, 2, 21) }; + var order13 = new Order { Name = "Order13", ItemCount = 15, OrderDate = new DateTime(2000, 3, 20) }; + var order21 = new Order { Name = "Order21", ItemCount = 16, OrderDate = new DateTime(2000, 4, 21) }; + var order22 = new Order { Name = "Order22", ItemCount = 23, OrderDate = new DateTime(2000, 5, 20) }; + var order31 = new Order { Name = "Order31", ItemCount = 42, OrderDate = new DateTime(2000, 6, 21) }; var customer1 = new Customer { - FirstName = "Customer", - LastName = "One", - Orders = new List - { - order11, - order12, - order13 - } - }; - var customer2 = new Customer - { - FirstName = "Customer", - LastName = "Two", - Orders = new List - { - order21, - order22 - } - }; - var customer3 = new Customer - { - FirstName = "Customer", - LastName = "Three", - Orders = new List - { - order31 - } + FirstName = "Customer", LastName = "One", Orders = new List { order11, order12, order13 } }; + var customer2 = new Customer { FirstName = "Customer", LastName = "Two", Orders = new List { order21, order22 } }; + var customer3 = new Customer { FirstName = "Customer", LastName = "Three", Orders = new List { order31 } }; ((UDFSqlContext)context).Customers.AddRange(customer1, customer2, customer3); ((UDFSqlContext)context).Orders.AddRange(order11, order12, order13, order21, order22, order31); @@ -372,8 +318,7 @@ public virtual void Scalar_Function_ClientEval_Method_As_Translateable_Method_Pa where c.Id == 1 select new { - c.FirstName, - OrderCount = UDFSqlContext.CustomerOrderCountStatic(UDFSqlContext.AddFiveStatic(c.Id - 5)) + c.FirstName, OrderCount = UDFSqlContext.CustomerOrderCountStatic(UDFSqlContext.AddFiveStatic(c.Id - 5)) }).Single()); } } @@ -398,11 +343,7 @@ public virtual void Scalar_Function_Anonymous_Type_Select_Correlated_Static() { var cust = (from c in context.Customers where c.Id == 1 - select new - { - c.LastName, - OrderCount = UDFSqlContext.CustomerOrderCountStatic(c.Id) - }).Single(); + select new { c.LastName, OrderCount = UDFSqlContext.CustomerOrderCountStatic(c.Id) }).Single(); Assert.Equal("One", cust.LastName); Assert.Equal(3, cust.OrderCount); @@ -416,11 +357,7 @@ public virtual void Scalar_Function_Anonymous_Type_Select_Not_Correlated_Static( { var cust = (from c in context.Customers where c.Id == 1 - select new - { - c.LastName, - OrderCount = UDFSqlContext.CustomerOrderCountStatic(1) - }).Single(); + select new { c.LastName, OrderCount = UDFSqlContext.CustomerOrderCountStatic(1) }).Single(); Assert.Equal("One", cust.LastName); Assert.Equal(3, cust.OrderCount); @@ -436,11 +373,7 @@ public virtual void Scalar_Function_Anonymous_Type_Select_Parameter_Static() var cust = (from c in context.Customers where c.Id == customerId - select new - { - c.LastName, - OrderCount = UDFSqlContext.CustomerOrderCountStatic(customerId) - }).Single(); + select new { c.LastName, OrderCount = UDFSqlContext.CustomerOrderCountStatic(customerId) }).Single(); Assert.Equal("One", cust.LastName); Assert.Equal(3, cust.OrderCount); @@ -460,7 +393,8 @@ public virtual void Scalar_Function_Anonymous_Type_Select_Nested_Static() select new { c.LastName, - OrderCount = UDFSqlContext.StarValueStatic(starCount, UDFSqlContext.CustomerOrderCountStatic(customerId)) + OrderCount = UDFSqlContext.StarValueStatic( + starCount, UDFSqlContext.CustomerOrderCountStatic(customerId)) }).Single(); Assert.Equal("Three", cust.LastName); @@ -535,11 +469,7 @@ public virtual void Scalar_Function_Let_Correlated_Static() var cust = (from c in context.Customers let orderCount = UDFSqlContext.CustomerOrderCountStatic(c.Id) where c.Id == 2 - select new - { - c.LastName, - OrderCount = orderCount - }).Single(); + select new { c.LastName, OrderCount = orderCount }).Single(); Assert.Equal("Two", cust.LastName); Assert.Equal(2, cust.OrderCount); @@ -554,11 +484,7 @@ public virtual void Scalar_Function_Let_Not_Correlated_Static() var cust = (from c in context.Customers let orderCount = UDFSqlContext.CustomerOrderCountStatic(2) where c.Id == 2 - select new - { - c.LastName, - OrderCount = orderCount - }).Single(); + select new { c.LastName, OrderCount = orderCount }).Single(); Assert.Equal("Two", cust.LastName); Assert.Equal(2, cust.OrderCount); @@ -575,11 +501,7 @@ public virtual void Scalar_Function_Let_Not_Parameter_Static() var cust = (from c in context.Customers let orderCount = UDFSqlContext.CustomerOrderCountStatic(customerId) where c.Id == customerId - select new - { - c.LastName, - OrderCount = orderCount - }).Single(); + select new { c.LastName, OrderCount = orderCount }).Single(); Assert.Equal("Two", cust.LastName); Assert.Equal(2, cust.OrderCount); @@ -597,11 +519,7 @@ public virtual void Scalar_Function_Let_Nested_Static() var cust = (from c in context.Customers let orderCount = UDFSqlContext.StarValueStatic(starCount, UDFSqlContext.CustomerOrderCountStatic(customerId)) where c.Id == customerId - select new - { - c.LastName, - OrderCount = orderCount - }).Single(); + select new { c.LastName, OrderCount = orderCount }).Single(); Assert.Equal("One", cust.LastName); Assert.Equal("***3", cust.OrderCount); @@ -849,8 +767,7 @@ public virtual void Scalar_Function_Non_Static() where c.Id == 1 select new { - Id = context.StarValueInstance(4, c.Id), - LastName = context.DollarValueInstance(2, c.LastName) + Id = context.StarValueInstance(4, c.Id), LastName = context.DollarValueInstance(2, c.LastName) }).Single(); Assert.Equal(custName.LastName, "$$One"); @@ -890,11 +807,8 @@ public virtual void Scalar_Function_ClientEval_Method_As_Translateable_Method_Pa Assert.Throws( () => (from c in context.Customers where c.Id == 1 - select new - { - c.FirstName, - OrderCount = context.CustomerOrderCountInstance(context.AddFiveInstance(c.Id - 5)) - }).Single()); + select new { c.FirstName, OrderCount = context.CustomerOrderCountInstance(context.AddFiveInstance(c.Id - 5)) }) + .Single()); } } @@ -918,11 +832,7 @@ public virtual void Scalar_Function_Anonymous_Type_Select_Correlated_Instance() { var cust = (from c in context.Customers where c.Id == 1 - select new - { - c.LastName, - OrderCount = context.CustomerOrderCountInstance(c.Id) - }).Single(); + select new { c.LastName, OrderCount = context.CustomerOrderCountInstance(c.Id) }).Single(); Assert.Equal("One", cust.LastName); Assert.Equal(3, cust.OrderCount); @@ -936,11 +846,7 @@ public virtual void Scalar_Function_Anonymous_Type_Select_Not_Correlated_Instanc { var cust = (from c in context.Customers where c.Id == 1 - select new - { - c.LastName, - OrderCount = context.CustomerOrderCountInstance(1) - }).Single(); + select new { c.LastName, OrderCount = context.CustomerOrderCountInstance(1) }).Single(); Assert.Equal("One", cust.LastName); Assert.Equal(3, cust.OrderCount); @@ -956,11 +862,7 @@ public virtual void Scalar_Function_Anonymous_Type_Select_Parameter_Instance() var cust = (from c in context.Customers where c.Id == customerId - select new - { - c.LastName, - OrderCount = context.CustomerOrderCountInstance(customerId) - }).Single(); + select new { c.LastName, OrderCount = context.CustomerOrderCountInstance(customerId) }).Single(); Assert.Equal("One", cust.LastName); Assert.Equal(3, cust.OrderCount); @@ -1055,11 +957,7 @@ public virtual void Scalar_Function_Let_Correlated_Instance() var cust = (from c in context.Customers let orderCount = context.CustomerOrderCountInstance(c.Id) where c.Id == 2 - select new - { - c.LastName, - OrderCount = orderCount - }).Single(); + select new { c.LastName, OrderCount = orderCount }).Single(); Assert.Equal("Two", cust.LastName); Assert.Equal(2, cust.OrderCount); @@ -1074,11 +972,7 @@ public virtual void Scalar_Function_Let_Not_Correlated_Instance() var cust = (from c in context.Customers let orderCount = context.CustomerOrderCountInstance(2) where c.Id == 2 - select new - { - c.LastName, - OrderCount = orderCount - }).Single(); + select new { c.LastName, OrderCount = orderCount }).Single(); Assert.Equal("Two", cust.LastName); Assert.Equal(2, cust.OrderCount); @@ -1095,11 +989,7 @@ public virtual void Scalar_Function_Let_Not_Parameter_Instance() var cust = (from c in context.Customers let orderCount = context.CustomerOrderCountInstance(customerId) where c.Id == customerId - select new - { - c.LastName, - OrderCount = orderCount - }).Single(); + select new { c.LastName, OrderCount = orderCount }).Single(); Assert.Equal("Two", cust.LastName); Assert.Equal(2, cust.OrderCount); @@ -1117,11 +1007,7 @@ public virtual void Scalar_Function_Let_Nested_Instance() var cust = (from c in context.Customers let orderCount = context.StarValueInstance(starCount, context.CustomerOrderCountInstance(customerId)) where c.Id == customerId - select new - { - c.LastName, - OrderCount = orderCount - }).Single(); + select new { c.LastName, OrderCount = orderCount }).Single(); Assert.Equal("One", cust.LastName); Assert.Equal("***3", cust.OrderCount); @@ -1206,7 +1092,8 @@ public virtual void Scalar_Nested_Function_BCL_Client_UDF_Instance() using (var context = CreateContext()) { Assert.Equal( - CoreStrings.TranslationFailed("(c) => 2 == Abs((Unhandled parameter: __context_0).AddOneInstance((Unhandled parameter: __context_0).CustomerOrderCountWithClientInstance(c.Id)))"), + CoreStrings.TranslationFailed( + "(c) => 2 == Abs((Unhandled parameter: __context_0).AddOneInstance((Unhandled parameter: __context_0).CustomerOrderCountWithClientInstance(c.Id)))"), Assert.Throws( () => (from c in context.Customers where 2 == Math.Abs(context.AddOneInstance(context.CustomerOrderCountWithClientInstance(c.Id))) diff --git a/test/EFCore.Relational.Specification.Tests/StoreGeneratedFixupRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/StoreGeneratedFixupRelationalTestBase.cs index 6e5955cc903..2fdc4ec5d58 100644 --- a/test/EFCore.Relational.Specification.Tests/StoreGeneratedFixupRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/StoreGeneratedFixupRelationalTestBase.cs @@ -23,11 +23,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb.HasOne(i => i.Game).WithMany(g => g.Items).HasConstraintName("FK_GameEntity_Game_GameId"); eb.HasOne(i => i.Level).WithMany(g => g.Items).HasConstraintName("FK_GameEntity_Level_GameId_LevelId"); eb.HasIndex( - i => new - { - i.GameId, - i.LevelId - }).HasName("IX_GameEntity_GameId_LevelId"); + i => new { i.GameId, i.LevelId }).HasName("IX_GameEntity_GameId_LevelId"); }); modelBuilder.Entity( @@ -36,11 +32,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb.HasOne(a => a.Game).WithMany(g => g.Actors).HasConstraintName("FK_GameEntity_Game_GameId"); eb.HasOne(a => a.Level).WithMany(g => g.Actors).HasConstraintName("FK_GameEntity_Level_GameId_LevelId"); eb.HasIndex( - a => new - { - a.GameId, - a.LevelId - }).HasName("IX_GameEntity_GameId_LevelId"); + a => new { a.GameId, a.LevelId }).HasName("IX_GameEntity_GameId_LevelId"); }); } } diff --git a/test/EFCore.Relational.Specification.Tests/TableSplittingTestBase.cs b/test/EFCore.Relational.Specification.Tests/TableSplittingTestBase.cs index 23a50e3823a..bc53dfdb94c 100644 --- a/test/EFCore.Relational.Specification.Tests/TableSplittingTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/TableSplittingTestBase.cs @@ -133,11 +133,12 @@ public virtual void Can_query_shared_derived_nonhierarchy_all_required() { OnModelCreating(modelBuilder); modelBuilder.Ignore(); - modelBuilder.Entity(eb => - { - eb.Property(t => t.Capacity).IsRequired(); - eb.Property(t => t.FuelType).IsRequired(); - }); + modelBuilder.Entity( + eb => + { + eb.Property(t => t.Capacity).IsRequired(); + eb.Property(t => t.FuelType).IsRequired(); + }); })) { using (var context = CreateContext()) @@ -198,19 +199,10 @@ public virtual void Inserting_dependent_with_just_one_parent_throws() { Name = "Fuel transport", SeatingCapacity = 1, - Operator = new LicensedOperator - { - Name = "Jack Jackson", - LicenseType = "Class A CDC" - } + Operator = new LicensedOperator { Name = "Jack Jackson", LicenseType = "Class A CDC" } }); context.Add( - new FuelTank - { - Capacity = "10000 l", - FuelType = "Gas", - VehicleName = "Fuel transport" - }); + new FuelTank { Capacity = "10000 l", FuelType = "Gas", VehicleName = "Fuel transport" }); Assert.Equal( RelationalStrings.SharedRowEntryCountMismatchSensitive( @@ -245,18 +237,11 @@ public virtual void Can_change_dependent_instance_non_derived() { var bike = context.Vehicles.Include(v => v.Operator).Single(v => v.Name == "Trek Pro Fit Madone 6 Series"); - bike.Operator = new Operator - { - Name = "Chris Horner" - }; + bike.Operator = new Operator { Name = "Chris Horner" }; context.ChangeTracker.DetectChanges(); - bike.Operator = new LicensedOperator - { - Name = "repairman", - LicenseType = "Repair" - }; + bike.Operator = new LicensedOperator { Name = "repairman", LicenseType = "Repair" }; TestSqlLoggerFactory.Clear(); context.SaveChanges(); @@ -298,12 +283,7 @@ public virtual void Can_change_principal_instance_non_derived() { var bike = context.Vehicles.Single(v => v.Name == "Trek Pro Fit Madone 6 Series"); - var newBike = new Vehicle - { - Name = "Trek Pro Fit Madone 6 Series", - Operator = bike.Operator, - SeatingCapacity = 2 - }; + var newBike = new Vehicle { Name = "Trek Pro Fit Madone 6 Series", Operator = bike.Operator, SeatingCapacity = 2 }; context.Remove(bike); context.Add(newBike); @@ -352,11 +332,7 @@ public virtual void Can_change_principal_and_dependent_instance_non_derived() var newBike = new Vehicle { Name = "Trek Pro Fit Madone 6 Series", - Operator = new LicensedOperator - { - Name = "repairman", - LicenseType = "Repair" - }, + Operator = new LicensedOperator { Name = "repairman", LicenseType = "Repair" }, SeatingCapacity = 2 }; @@ -413,7 +389,7 @@ protected TestStore CreateTestStore(Action onModelCreating) .AddSingleton(TestSqlLoggerFactory) .BuildServiceProvider(validateScopes: true); - TestStore.Initialize(ServiceProvider, CreateContext, c => ((TransportationContext)c).Seed(), null); + TestStore.Initialize(ServiceProvider, CreateContext, c => ((TransportationContext)c).Seed()); TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.Relational.Specification.Tests/TestModels/Northwind/NorthwindRelationalContext.cs b/test/EFCore.Relational.Specification.Tests/TestModels/Northwind/NorthwindRelationalContext.cs index 8e67f38ac4f..8e460648f9d 100644 --- a/test/EFCore.Relational.Specification.Tests/TestModels/Northwind/NorthwindRelationalContext.cs +++ b/test/EFCore.Relational.Specification.Tests/TestModels/Northwind/NorthwindRelationalContext.cs @@ -29,8 +29,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) #pragma warning disable CS0618 // Type or member is obsolete modelBuilder.Query().HasNoKey().ToQuery( - () => CustomerQueries.FromSqlInterpolated($"SELECT [c].[CustomerID] + {_empty} as [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]" -)); + () => CustomerQueries.FromSqlInterpolated( + $"SELECT [c].[CustomerID] + {_empty} as [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]" + )); modelBuilder .Query() @@ -38,10 +39,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) () => Orders .FromSqlRaw(@"select * from ""Orders""") .Select( - o => new OrderQuery - { - CustomerID = o.CustomerID - })); + o => new OrderQuery { CustomerID = o.CustomerID })); modelBuilder.Query().ToView("Alphabetical list of products"); #pragma warning restore CS0618 // Type or member is obsolete diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalDatabaseCleaner.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalDatabaseCleaner.cs index 54c44f58a77..f70684727c1 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalDatabaseCleaner.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalDatabaseCleaner.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations.Operations; @@ -85,7 +84,7 @@ public virtual void Clean(DatabaseFacade facade) { sqlBuilder.Build(customSql).ExecuteNonQuery( new RelationalCommandParameterObject( - connection,null, null,null)); + connection, null, null, null)); } if (operations.Count > 0) @@ -111,33 +110,15 @@ public virtual void Clean(DatabaseFacade facade) } protected virtual MigrationOperation Drop(DatabaseSequence sequence) - => new DropSequenceOperation - { - Name = sequence.Name, - Schema = sequence.Schema - }; + => new DropSequenceOperation { Name = sequence.Name, Schema = sequence.Schema }; protected virtual MigrationOperation Drop(DatabaseTable table) - => new DropTableOperation - { - Name = table.Name, - Schema = table.Schema - }; + => new DropTableOperation { Name = table.Name, Schema = table.Schema }; protected virtual MigrationOperation Drop(DatabaseForeignKey foreignKey) - => new DropForeignKeyOperation - { - Name = foreignKey.Name, - Table = foreignKey.Table.Name, - Schema = foreignKey.Table.Schema - }; + => new DropForeignKeyOperation { Name = foreignKey.Name, Table = foreignKey.Table.Name, Schema = foreignKey.Table.Schema }; protected virtual MigrationOperation Drop(DatabaseIndex index) - => new DropIndexOperation - { - Name = index.Name, - Table = index.Table.Name, - Schema = index.Table.Schema - }; + => new DropIndexOperation { Name = index.Name, Table = index.Table.Name, Schema = index.Table.Schema }; } } diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs index 262a4a19ab4..6322be68355 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs @@ -52,8 +52,8 @@ public void AssertBaseline(string[] expected) catch { var methodCallLine = Environment.StackTrace.Split( - new[] { _eol }, - StringSplitOptions.RemoveEmptyEntries)[3].Substring(6); + new[] { _eol }, + StringSplitOptions.RemoveEmptyEntries)[3].Substring(6); var testName = methodCallLine.Substring(0, methodCallLine.IndexOf(')') + 1); var lineIndex = methodCallLine.LastIndexOf("line", StringComparison.Ordinal); diff --git a/test/EFCore.Relational.Specification.Tests/TransactionInterceptionTestBase.cs b/test/EFCore.Relational.Specification.Tests/TransactionInterceptionTestBase.cs index 15e6b9039b8..25902f6ff47 100644 --- a/test/EFCore.Relational.Specification.Tests/TransactionInterceptionTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/TransactionInterceptionTestBase.cs @@ -529,14 +529,8 @@ public virtual async Task Intercept_connection_with_multiple_interceptors(bool a var interceptor3 = new TransactionInterceptor(); var interceptor4 = new WrappingTransactionInterceptor(); using (var context = CreateContext( - new IInterceptor[] - { - new NoOpTransactionInterceptor(), interceptor1, interceptor2 - }, - new IInterceptor[] - { - interceptor3, interceptor4, new NoOpTransactionInterceptor() - })) + new IInterceptor[] { new NoOpTransactionInterceptor(), interceptor1, interceptor2 }, + new IInterceptor[] { interceptor3, interceptor4, new NoOpTransactionInterceptor() })) { using (var listener = Fixture.SubscribeToDiagnosticListener(context.ContextId)) { @@ -544,7 +538,6 @@ public virtual async Task Intercept_connection_with_multiple_interceptors(bool a ? await context.Database.BeginTransactionAsync() : context.Database.BeginTransaction()) { - Assert.IsType(contextTransaction.GetDbTransaction()); AssertBeginTransaction(context, interceptor1, async); diff --git a/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs b/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs index 0c57fc3b605..352edc1f682 100644 --- a/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs @@ -14,6 +14,7 @@ using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; +using IsolationLevel = System.Data.IsolationLevel; // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore @@ -44,12 +45,7 @@ public virtual void SaveChanges_can_be_used_with_no_transaction() context.Database.AutoTransactionsEnabled = false; context.Add( - new TransactionCustomer - { - Id = 77, - Name = "Bobble" - }); - + new TransactionCustomer { Id = 77, Name = "Bobble" }); context.Entry(context.Set().OrderBy(c => c.Id).Last()).State = EntityState.Added; @@ -61,12 +57,7 @@ public virtual void SaveChanges_can_be_used_with_no_transaction() using (var context = CreateContext()) { Assert.Equal( - new List - { - 1, - 2, - 77 - }, + new List { 1, 2, 77 }, context.Set().OrderBy(c => c.Id).Select(e => e.Id).ToList()); } } @@ -79,11 +70,7 @@ public virtual async Task SaveChangesAsync_can_be_used_with_no_transaction() context.Database.AutoTransactionsEnabled = false; context.Add( - new TransactionCustomer - { - Id = 77, - Name = "Bobble" - }); + new TransactionCustomer { Id = 77, Name = "Bobble" }); context.Entry(context.Set().OrderBy(c => c.Id).Last()).State = EntityState.Added; @@ -95,12 +82,7 @@ public virtual async Task SaveChangesAsync_can_be_used_with_no_transaction() using (var context = CreateContext()) { Assert.Equal( - new List - { - 1, - 2, - 77 - }, + new List { 1, 2, 77 }, context.Set().OrderBy(c => c.Id).Select(e => e.Id).ToList()); } } @@ -113,11 +95,7 @@ public virtual void SaveChanges_implicitly_starts_transaction() Assert.True(context.Database.AutoTransactionsEnabled); context.Add( - new TransactionCustomer - { - Id = 77, - Name = "Bobble" - }); + new TransactionCustomer { Id = 77, Name = "Bobble" }); context.Entry(context.Set().OrderBy(c => c.Id).Last()).State = EntityState.Added; @@ -135,11 +113,7 @@ public virtual async Task SaveChangesAsync_implicitly_starts_transaction() Assert.True(context.Database.AutoTransactionsEnabled); context.Add( - new TransactionCustomer - { - Id = 77, - Name = "Bobble" - }); + new TransactionCustomer { Id = 77, Name = "Bobble" }); context.Entry(context.Set().OrderBy(c => c.Id).Last()).State = EntityState.Added; @@ -170,11 +144,7 @@ public virtual async Task SaveChanges_uses_enlisted_transaction(bool async, bool context.Database.AutoTransactionsEnabled = autoTransactionsEnabled; context.Add( - new TransactionCustomer - { - Id = 77, - Name = "Bobble" - }); + new TransactionCustomer { Id = 77, Name = "Bobble" }); context.Entry(context.Set().OrderBy(c => c.Id).Last()).State = EntityState.Added; @@ -193,7 +163,8 @@ public virtual async Task SaveChanges_uses_enlisted_transaction(bool async, bool if (AmbientTransactionsSupported) { Assert.Equal( - RelationalResources.LogExplicitTransactionEnlisted(new TestLogger()).GenerateMessage("Serializable"), + RelationalResources.LogExplicitTransactionEnlisted(new TestLogger()) + .GenerateMessage("Serializable"), Fixture.ListLoggerFactory.Log.First().Message); } else @@ -244,11 +215,7 @@ public virtual async Task SaveChanges_uses_enlisted_transaction_after_connection context.Database.AutoTransactionsEnabled = autoTransactionsEnabled; context.Add( - new TransactionCustomer - { - Id = 77, - Name = "Bobble" - }); + new TransactionCustomer { Id = 77, Name = "Bobble" }); context.Entry(context.Set().OrderBy(c => c.Id).Last()).State = EntityState.Added; @@ -296,11 +263,7 @@ public virtual async Task SaveChanges_uses_enlisted_transaction_connectionString context.Database.AutoTransactionsEnabled = autoTransactionsEnabled; context.Add( - new TransactionCustomer - { - Id = 77, - Name = "Bobble" - }); + new TransactionCustomer { Id = 77, Name = "Bobble" }); context.Entry(context.Set().OrderBy(c => c.Id).Last()).State = EntityState.Added; @@ -341,11 +304,7 @@ public virtual async Task SaveChanges_uses_ambient_transaction(bool async, bool context.Database.AutoTransactionsEnabled = autoTransactionsEnabled; context.Add( - new TransactionCustomer - { - Id = 77, - Name = "Bobble" - }); + new TransactionCustomer { Id = 77, Name = "Bobble" }); context.Entry(context.Set().OrderBy(c => c.Id).Last()).State = EntityState.Added; @@ -364,7 +323,8 @@ public virtual async Task SaveChanges_uses_ambient_transaction(bool async, bool if (AmbientTransactionsSupported) { Assert.Equal( - RelationalResources.LogAmbientTransactionEnlisted(new TestLogger()).GenerateMessage("Serializable"), + RelationalResources.LogAmbientTransactionEnlisted(new TestLogger()) + .GenerateMessage("Serializable"), Fixture.ListLoggerFactory.Log.Skip(2).First().Message); } else @@ -415,11 +375,7 @@ public virtual async Task SaveChanges_uses_ambient_transaction_with_connectionSt Assert.Equal(ConnectionState.Closed, connection.State); context.Add( - new TransactionCustomer - { - Id = 77, - Name = "Bobble" - }); + new TransactionCustomer { Id = 77, Name = "Bobble" }); context.Entry(context.Set().OrderBy(c => c.Id).Last()).State = EntityState.Added; @@ -458,17 +414,14 @@ public virtual void SaveChanges_throws_for_suppressed_ambient_transactions(bool using (TestUtilities.TestStore.CreateTransactionScope()) { context.Add( - new TransactionCustomer - { - Id = 77, - Name = "Bobble" - }); + new TransactionCustomer { Id = 77, Name = "Bobble" }); context.Entry(context.Set().OrderBy(c => c.Id).Last()).State = EntityState.Added; using (new TransactionScope(TransactionScopeOption.Suppress)) { - Assert.Equal(RelationalStrings.PendingAmbientTransaction, + Assert.Equal( + RelationalStrings.PendingAmbientTransaction, Assert.Throws(() => context.SaveChanges()).Message); } } @@ -495,11 +448,7 @@ public virtual void SaveChanges_uses_enlisted_transaction_after_ambient_transact using (TestUtilities.TestStore.CreateTransactionScope()) { context.Add( - new TransactionCustomer - { - Id = 77, - Name = "Bobble" - }); + new TransactionCustomer { Id = 77, Name = "Bobble" }); context.Entry(context.Set().OrderBy(c => c.Id).Last()).State = EntityState.Added; } @@ -526,11 +475,7 @@ public virtual void SaveChanges_does_not_close_connection_opened_by_user() Assert.Equal(ConnectionState.Open, connection.State); context.Add( - new TransactionCustomer - { - Id = 77, - Name = "Bobble" - }); + new TransactionCustomer { Id = 77, Name = "Bobble" }); context.SaveChanges(); Assert.Equal(ConnectionState.Open, connection.State); @@ -540,12 +485,7 @@ public virtual void SaveChanges_does_not_close_connection_opened_by_user() using (var context = CreateContext()) { Assert.Equal( - new List - { - 1, - 2, - 77 - }, + new List { 1, 2, 77 }, context.Set().OrderBy(c => c.Id).Select(e => e.Id).ToList()); } } @@ -561,11 +501,7 @@ public virtual async Task SaveChangesAsync_does_not_close_connection_opened_by_u Assert.Equal(ConnectionState.Open, connection.State); context.Add( - new TransactionCustomer - { - Id = 77, - Name = "Bobble" - }); + new TransactionCustomer { Id = 77, Name = "Bobble" }); await context.SaveChangesAsync(); Assert.Equal(ConnectionState.Open, connection.State); @@ -575,12 +511,7 @@ public virtual async Task SaveChangesAsync_does_not_close_connection_opened_by_u using (var context = CreateContext()) { Assert.Equal( - new List - { - 1, - 2, - 77 - }, + new List { 1, 2, 77 }, context.Set().OrderBy(c => c.Id).Select(e => e.Id).ToList()); } } @@ -876,7 +807,7 @@ public virtual void Query_uses_explicit_transaction(bool autoTransaction) if (DirtyReadsOccur) { - using (innerContext.Database.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted)) + using (innerContext.Database.BeginTransaction(IsolationLevel.ReadUncommitted)) { Assert.Equal(Customers.Count - 1, innerContext.Set().Count()); } @@ -884,7 +815,7 @@ public virtual void Query_uses_explicit_transaction(bool autoTransaction) if (SnapshotSupported) { - using (innerContext.Database.BeginTransaction(System.Data.IsolationLevel.Snapshot)) + using (innerContext.Database.BeginTransaction(IsolationLevel.Snapshot)) { Assert.Equal(Customers, innerContext.Set().OrderBy(c => c.Id).ToList()); } @@ -928,7 +859,7 @@ public virtual async Task QueryAsync_uses_explicit_transaction(bool autoTransact if (DirtyReadsOccur) { - using (await innerContext.Database.BeginTransactionAsync(System.Data.IsolationLevel.ReadUncommitted)) + using (await innerContext.Database.BeginTransactionAsync(IsolationLevel.ReadUncommitted)) { Assert.Equal(Customers.Count - 1, await innerContext.Set().CountAsync()); } @@ -936,7 +867,7 @@ public virtual async Task QueryAsync_uses_explicit_transaction(bool autoTransact if (SnapshotSupported) { - using (await innerContext.Database.BeginTransactionAsync(System.Data.IsolationLevel.Snapshot)) + using (await innerContext.Database.BeginTransactionAsync(IsolationLevel.Snapshot)) { Assert.Equal(Customers, await innerContext.Set().OrderBy(c => c.Id).ToListAsync()); } @@ -1007,8 +938,8 @@ public virtual void UseTransaction_throws_if_another_transaction_started() { using (context.Database.BeginTransaction( DirtyReadsOccur - ? System.Data.IsolationLevel.ReadUncommitted - : System.Data.IsolationLevel.Unspecified)) + ? IsolationLevel.ReadUncommitted + : IsolationLevel.Unspecified)) { var ex = Assert.Throws( () => @@ -1136,8 +1067,8 @@ public virtual void BeginTransaction_throws_if_enlisted_in_transaction() var ex = Assert.Throws( () => context.Database.BeginTransaction( DirtyReadsOccur - ? System.Data.IsolationLevel.ReadUncommitted - : System.Data.IsolationLevel.Unspecified)); + ? IsolationLevel.ReadUncommitted + : IsolationLevel.Unspecified)); Assert.Equal(RelationalStrings.ConflictingEnlistedTransaction, ex.Message); context.Database.CloseConnection(); } @@ -1363,16 +1294,7 @@ protected override void Seed(PoolableDbContext context) protected static readonly IReadOnlyList Customers = new List { - new TransactionCustomer - { - Id = 1, - Name = "Bob" - }, - new TransactionCustomer - { - Id = 2, - Name = "Dave" - } + new TransactionCustomer { Id = 1, Name = "Bob" }, new TransactionCustomer { Id = 2, Name = "Dave" } }; protected class TransactionCustomer diff --git a/test/EFCore.Relational.Specification.Tests/UpdatesRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/UpdatesRelationalFixture.cs index 3f1decca72f..fd8cb23a6e9 100644 --- a/test/EFCore.Relational.Specification.Tests/UpdatesRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/UpdatesRelationalFixture.cs @@ -21,16 +21,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb => { eb.HasKey( - l => new - { - l.ProfileId - }) + l => new { l.ProfileId }) .HasName("PK_LoginDetails"); eb.HasOne(d => d.Login).WithOne() - .HasConstraintName("FK_LoginDetails_Login"); + .HasConstraintName("FK_LoginDetails_Login"); }); - } } } diff --git a/test/EFCore.Relational.Tests/ApiConsistencyTest.cs b/test/EFCore.Relational.Tests/ApiConsistencyTest.cs index 13f0758b5a0..2153074057c 100644 --- a/test/EFCore.Relational.Tests/ApiConsistencyTest.cs +++ b/test/EFCore.Relational.Tests/ApiConsistencyTest.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Reflection; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders; using Microsoft.EntityFrameworkCore.Storage; diff --git a/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs b/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs index 7b377a6802a..dfa9ae4f2a8 100644 --- a/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs +++ b/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs @@ -51,7 +51,9 @@ public virtual void Detects_bool_with_default_value_not_false() property.SetDefaultValue(true); property.ValueGenerated = ValueGenerated.OnAdd; - VerifyWarning(RelationalResources.LogBoolWithDefaultWarning(new TestLogger()).GenerateMessage("ImBool", "E"), model); + VerifyWarning( + RelationalResources.LogBoolWithDefaultWarning(new TestLogger()) + .GenerateMessage("ImBool", "E"), model); } [ConditionalFact] @@ -67,7 +69,9 @@ public virtual void Detects_bool_with_default_expression() property.SetDefaultValueSql("TRUE"); property.ValueGenerated = ValueGenerated.OnAddOrUpdate; - VerifyWarning(RelationalResources.LogBoolWithDefaultWarning(new TestLogger()).GenerateMessage("ImBool", "E"), model); + VerifyWarning( + RelationalResources.LogBoolWithDefaultWarning(new TestLogger()) + .GenerateMessage("ImBool", "E"), model); } [ConditionalFact] @@ -82,8 +86,9 @@ public virtual void Detects_primary_key_with_default_value() entityA.FindProperty("Id").SetDefaultValue(1); - VerifyWarning(RelationalResources.LogKeyHasDefaultValue( - new TestLogger()).GenerateMessage("Id", "A"), model); + VerifyWarning( + RelationalResources.LogKeyHasDefaultValue( + new TestLogger()).GenerateMessage("Id", "A"), model); } [ConditionalFact] @@ -102,7 +107,9 @@ public virtual void Detects_alternate_key_with_default_value() entityA.AddKey(new[] { property }); property.SetDefaultValue(1); - VerifyWarning(RelationalResources.LogKeyHasDefaultValue(new TestLogger()).GenerateMessage("P0", "A"), model); + VerifyWarning( + RelationalResources.LogKeyHasDefaultValue(new TestLogger()).GenerateMessage("P0", "A"), + model); } [ConditionalFact] @@ -507,11 +514,7 @@ public virtual void Detects_duplicate_foreignKey_names_within_hierarchy_with_dif modelBuilder.Entity().Property("FriendId"); modelBuilder.Entity().Property("Shadow"); modelBuilder.Entity().HasOne().WithMany().HasForeignKey("FriendId", "Shadow").HasPrincipalKey( - p => new - { - p.Id, - p.Name - }).HasConstraintName("FK"); + p => new { p.Id, p.Name }).HasConstraintName("FK"); modelBuilder.Entity().HasOne().WithMany().HasForeignKey("FriendId").HasConstraintName("FK"); VerifyError( @@ -536,17 +539,9 @@ public virtual void Detects_duplicate_foreignKey_names_within_hierarchy_with_dif et.Property(c => c.Breed).HasColumnName("Breed"); et.HasOne().WithMany() .HasForeignKey( - c => new - { - c.Name, - c.Breed - }) + c => new { c.Name, c.Breed }) .HasPrincipalKey( - p => new - { - p.Name, - p.FavoriteBreed - }) + p => new { p.Name, p.FavoriteBreed }) .HasConstraintName("FK"); }); modelBuilder.Entity( @@ -555,17 +550,9 @@ public virtual void Detects_duplicate_foreignKey_names_within_hierarchy_with_dif et.Property(c => c.Breed).HasColumnName("Breed"); et.HasOne().WithMany() .HasForeignKey( - d => new - { - d.Breed, - d.Name - }) + d => new { d.Breed, d.Name }) .HasPrincipalKey( - p => new - { - p.FavoriteBreed, - p.Name - }) + p => new { p.FavoriteBreed, p.Name }) .HasConstraintName("FK"); }); @@ -585,27 +572,11 @@ public virtual void Detects_duplicate_foreignKey_names_within_hierarchy_mapped_t var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.Entity(); modelBuilder.Entity().HasOne().WithMany().HasForeignKey( - c => new - { - c.Name, - c.Breed - }).HasPrincipalKey( - p => new - { - p.Name, - p.FavoriteBreed - }).HasConstraintName("FK"); + c => new { c.Name, c.Breed }).HasPrincipalKey( + p => new { p.Name, p.FavoriteBreed }).HasConstraintName("FK"); modelBuilder.Entity().HasOne().WithMany().HasForeignKey( - d => new - { - d.Name, - d.Breed - }).HasPrincipalKey( - p => new - { - p.Name, - p.FavoriteBreed - }).HasConstraintName("FK"); + d => new { d.Name, d.Breed }).HasPrincipalKey( + p => new { p.Name, p.FavoriteBreed }).HasConstraintName("FK"); modelBuilder.Entity().Property(d => d.Breed).HasColumnName("DogBreed"); VerifyError( @@ -742,17 +713,9 @@ public virtual void Passes_for_compatible_duplicate_foreignKey_names_within_hier .HasOne(a => a.FavoritePerson) .WithMany() .HasForeignKey( - c => new - { - c.Name, - c.Breed - }) + c => new { c.Name, c.Breed }) .HasPrincipalKey( - p => new - { - p.Name, - p.FavoriteBreed - }) + p => new { p.Name, p.FavoriteBreed }) .Metadata; }); modelBuilder.Entity( @@ -763,17 +726,9 @@ public virtual void Passes_for_compatible_duplicate_foreignKey_names_within_hier .HasOne(a => (Customer)a.FavoritePerson) .WithMany() .HasForeignKey( - c => new - { - c.Name, - c.Breed - }) + c => new { c.Name, c.Breed }) .HasPrincipalKey( - p => new - { - p.Name, - p.FavoriteBreed - }) + p => new { p.Name, p.FavoriteBreed }) .Metadata; }); @@ -804,17 +759,9 @@ public virtual void Passes_for_compatible_duplicate_foreignKey_names_within_hier .HasOne() .WithMany() .HasForeignKey( - c => new - { - c.Name, - c.Breed - }) + c => new { c.Name, c.Breed }) .HasPrincipalKey( - p => new - { - p.Name, - p.FavoriteBreed - }) + p => new { p.Name, p.FavoriteBreed }) .HasConstraintName("FK") .Metadata; }); @@ -826,17 +773,9 @@ public virtual void Passes_for_compatible_duplicate_foreignKey_names_within_hier .HasOne() .WithMany() .HasForeignKey( - c => new - { - c.Name, - c.Breed - }) + c => new { c.Name, c.Breed }) .HasPrincipalKey( - p => new - { - p.Name, - p.FavoriteBreed - }) + p => new { p.Name, p.FavoriteBreed }) .HasConstraintName("FK") .Metadata; }); @@ -881,22 +820,14 @@ public virtual void Detects_duplicate_index_names_within_hierarchy_with_differen { et.Property(c => c.Breed).HasColumnName("Breed"); et.HasIndex( - c => new - { - c.Name, - c.Breed - }).HasName("IX"); + c => new { c.Name, c.Breed }).HasName("IX"); }); modelBuilder.Entity( et => { et.Property(c => c.Breed).HasColumnName("Breed"); et.HasIndex( - d => new - { - d.Breed, - d.Name - }).HasName("IX"); + d => new { d.Breed, d.Name }).HasName("IX"); }); VerifyError( @@ -915,17 +846,9 @@ public virtual void Detects_duplicate_index_names_within_hierarchy_mapped_to_dif var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.Entity(); modelBuilder.Entity().HasIndex( - c => new - { - c.Name, - c.Breed - }).HasName("IX"); + c => new { c.Name, c.Breed }).HasName("IX"); modelBuilder.Entity().HasIndex( - d => new - { - d.Name, - d.Breed - }).HasName("IX"); + d => new { d.Name, d.Breed }).HasName("IX"); modelBuilder.Entity().Property(d => d.Breed).HasColumnName("DogBreed"); VerifyError( @@ -1043,8 +966,9 @@ public virtual void Passes_for_correctly_mapped_concurrency_tokens_with_owned() { var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.Entity(); - modelBuilder.Entity().OwnsOne(a => a.FavoritePerson, - pb => pb.Property("Version").IsRowVersion().HasColumnName("Version")); + modelBuilder.Entity().OwnsOne( + a => a.FavoritePerson, + pb => pb.Property("Version").IsRowVersion().HasColumnName("Version")); modelBuilder.Entity(); Validate(modelBuilder.Model); diff --git a/test/EFCore.Relational.Tests/Metadata/DbFunctionMetadataTests.cs b/test/EFCore.Relational.Tests/Metadata/DbFunctionMetadataTests.cs index 198ee0ec6bb..d6bbb24be8c 100644 --- a/test/EFCore.Relational.Tests/Metadata/DbFunctionMetadataTests.cs +++ b/test/EFCore.Relational.Tests/Metadata/DbFunctionMetadataTests.cs @@ -605,7 +605,8 @@ private ModelBuilder GetModelBuilder(DbContext dbContext = null) { var conventionSet = new ConventionSet(); - var dependencies = CreateDependencies().With(new CurrentDbContext(dbContext ?? new DbContext(new DbContextOptions()))); + var dependencies = CreateDependencies() + .With(new CurrentDbContext(dbContext ?? new DbContext(new DbContextOptions()))); var relationalDependencies = CreateRelationalDependencies(); var dbFunctionAttributeConvention = new RelationalDbFunctionAttributeConvention(dependencies, relationalDependencies); conventionSet.ModelInitializedConventions.Add(dbFunctionAttributeConvention); diff --git a/test/EFCore.Relational.Tests/Metadata/RelationalBuilderExtensionsTest.cs b/test/EFCore.Relational.Tests/Metadata/RelationalBuilderExtensionsTest.cs index 64007fa7074..8af7dbaa583 100644 --- a/test/EFCore.Relational.Tests/Metadata/RelationalBuilderExtensionsTest.cs +++ b/test/EFCore.Relational.Tests/Metadata/RelationalBuilderExtensionsTest.cs @@ -10,6 +10,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; + // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Metadata @@ -541,8 +542,9 @@ public void AddCheckConstraint_with_duplicate_names_throws_exception() Assert.Equal( RelationalStrings.DuplicateCheckConstraint("CK_Customer_AlternateId", entityType.DisplayName()), - Assert.Throws(() => - entityType.AddCheckConstraint("CK_Customer_AlternateId", "AlternateId < Id")).Message); + Assert.Throws( + () => + entityType.AddCheckConstraint("CK_Customer_AlternateId", "AlternateId < Id")).Message); } [ConditionalFact] diff --git a/test/EFCore.Relational.Tests/Metadata/SequenceTest.cs b/test/EFCore.Relational.Tests/Metadata/SequenceTest.cs index 37fc0c2a073..1c58be9a6d3 100644 --- a/test/EFCore.Relational.Tests/Metadata/SequenceTest.cs +++ b/test/EFCore.Relational.Tests/Metadata/SequenceTest.cs @@ -27,7 +27,7 @@ public void Can_be_created_with_default_values() [ConditionalFact] public void Can_be_created_with_specified_values() { - var sequence = ((IMutableModel)new Model()).AddSequence("Foo", "Smoo"); + var sequence = new Model().AddSequence("Foo", "Smoo"); sequence.StartValue = 1729; sequence.IncrementBy = 11; sequence.MinValue = 2001; diff --git a/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsAssemblyTest.cs b/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsAssemblyTest.cs index a3e8b9f98a0..9c35d9fa749 100644 --- a/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsAssemblyTest.cs +++ b/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsAssemblyTest.cs @@ -43,10 +43,7 @@ public void GetMigrationId_throws_when_no_match() [ConditionalFact] public void Migrations_ignores_the_unattributed() { - var logger = new TestLogger - { - EnabledFor = LogLevel.Warning - }; + var logger = new TestLogger { EnabledFor = LogLevel.Warning }; var assembly = CreateMigrationsAssembly(logger); var result = assembly.Migrations; diff --git a/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs b/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs index 93633c5e076..b4b012dbe27 100644 --- a/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs +++ b/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs @@ -330,11 +330,7 @@ public void Create_table_columns_use_dependent_to_principal_and_key_order_when_s { modelBuilder.Entity(); modelBuilder.Entity().HasKey( - e => new - { - e.C, - e.B - }); + e => new { e.C, e.B }); }, operations => { @@ -883,11 +879,7 @@ public void Move_type_from_one_shared_table_to_another_with_seed_data() x.Property("Id"); x.Property("MouseId"); x.HasData( - new - { - Id = 42, - MouseId = "Jerry" - }); + new { Id = 42, MouseId = "Jerry" }); }); modelBuilder.Entity( "Dog", @@ -896,11 +888,7 @@ public void Move_type_from_one_shared_table_to_another_with_seed_data() x.Property("Id"); x.Property("BoneId"); x.HasData( - new - { - Id = 42, - BoneId = "Brook" - }); + new { Id = 42, BoneId = "Brook" }); }); modelBuilder.Entity( "Animal", @@ -909,11 +897,7 @@ public void Move_type_from_one_shared_table_to_another_with_seed_data() x.Property("Id"); x.Property("HandlerId"); x.HasData( - new - { - Id = 42, - HandlerId = "Brenda" - }); + new { Id = 42, HandlerId = "Brenda" }); }); }, modelBuilder => @@ -1008,12 +992,7 @@ public void Can_split_entity_in_two_using_shared_table_with_seed_data() x.Property("MouseId"); x.Property("BoneId"); x.HasData( - new - { - Id = 42, - MouseId = "1", - BoneId = "2" - }); + new { Id = 42, MouseId = "1", BoneId = "2" }); }); }, modelBuilder => @@ -1026,11 +1005,7 @@ public void Can_split_entity_in_two_using_shared_table_with_seed_data() x.Property("MouseId"); x.ToTable("Animal"); x.HasData( - new - { - Id = 42, - MouseId = "1" - }); + new { Id = 42, MouseId = "1" }); }); modelBuilder.Entity( "Dog", @@ -1041,11 +1016,7 @@ public void Can_split_entity_in_two_using_shared_table_with_seed_data() x.HasOne("Cat").WithOne().HasForeignKey("Dog", "Id"); x.ToTable("Animal"); x.HasData( - new - { - Id = 42, - BoneId = "2" - }); + new { Id = 42, BoneId = "2" }); }); }, operations => Assert.Equal(0, operations.Count)); @@ -1063,10 +1034,7 @@ public void Add_owned_type_with_seed_data() { x.Property("Id"); x.HasData( - new - { - Id = 42 - }); + new { Id = 42 }); }); }, _ => { }, @@ -1082,12 +1050,7 @@ public void Add_owned_type_with_seed_data() s.Property("Street"); s.Property("City"); s.HasData( - new - { - OrderId = 42, - Street = "Lombard", - City = "San Francisco" - }); + new { OrderId = 42, Street = "Lombard", City = "San Francisco" }); }); x.OwnsOne( "Address", "BillingAddress", s => @@ -1095,12 +1058,7 @@ public void Add_owned_type_with_seed_data() s.Property("Street"); s.Property("City"); s.HasData( - new - { - OrderId = 42, - Street = "Abbey Road", - City = "London" - }); + new { OrderId = 42, Street = "Abbey Road", City = "London" }); }); }); }, @@ -1189,14 +1147,8 @@ public void Rename_entity_type_with_seed_data() x.Property("Id"); x.HasKey("Id").HasName("PK_EntityId"); x.HasData( - new - { - Id = 42 - }, - new - { - Id = 27 - }); + new { Id = 42 }, + new { Id = 27 }); }), target => target.Entity( "EntityWithId", @@ -1206,14 +1158,8 @@ public void Rename_entity_type_with_seed_data() x.Property("Id"); x.HasKey("Id").HasName("PK_EntityId"); x.HasData( - new - { - Id = 42 - }, - new - { - Id = 27 - }); + new { Id = 42 }, + new { Id = 27 }); }), Assert.Empty, Assert.Empty); @@ -1370,10 +1316,7 @@ public void Add_column_with_seed_data() x.ToTable("Firefly", "dbo"); x.Property("Id"); x.HasData( - new - { - Id = 42 - }); + new { Id = 42 }); }), target => target.Entity( "Firefly", @@ -1383,16 +1326,8 @@ public void Add_column_with_seed_data() x.Property("Id"); x.Property("Name").HasColumnType("nvarchar(30)"); x.HasData( - new - { - Id = 42, - Name = "Firefly 1" - }, - new - { - Id = 43, - Name = "Firefly 2" - }); + new { Id = 42, Name = "Firefly 1" }, + new { Id = 43, Name = "Firefly 2" }); }), upOps => Assert.Collection( upOps, @@ -1491,18 +1426,8 @@ public void Rename_column_with_seed_data() x.Property("Value1"); x.Property("Value2"); x.HasData( - new - { - IdBeforeRename = 42, - Value1 = 32, - Value2 = "equal" - }, - new - { - IdBeforeRename = 24, - Value1 = 72, - Value2 = "not equal1" - }); + new { IdBeforeRename = 42, Value1 = 32, Value2 = "equal" }, + new { IdBeforeRename = 24, Value1 = 72, Value2 = "not equal1" }); }), target => target.Entity( "EntityWithTwoProperties", @@ -1512,18 +1437,8 @@ public void Rename_column_with_seed_data() x.Property("Value1"); x.Property("Value2"); x.HasData( - new - { - Id = 42, - Value1 = 27, - Value2 = "equal" - }, // modified - new - { - Id = 24, - Value1 = 99, - Value2 = "not equal2" - }); // modified + new { Id = 42, Value1 = 27, Value2 = "equal" }, // modified + new { Id = 24, Value1 = 99, Value2 = "not equal2" }); // modified }), upOps => Assert.Collection( upOps, @@ -1625,11 +1540,7 @@ public void Rename_property_with_same_seed_data() x.Property("Id"); x.Property("ZebraName").HasColumnType("nvarchar(30)"); x.HasData( - new - { - Id = 42, - ZebraName = "equal" - }); + new { Id = 42, ZebraName = "equal" }); }), source => source.Entity( "Zebra", @@ -1639,11 +1550,7 @@ public void Rename_property_with_same_seed_data() x.Property("Id"); x.Property("Name").HasColumnName("ZebraName").HasColumnType("nvarchar(30)"); x.HasData( - new - { - Id = 42, - Name = "equal" - }); + new { Id = 42, Name = "equal" }); }), Assert.Empty, Assert.Empty); @@ -1863,11 +1770,7 @@ public void Alter_column_type_with_seed_data() x.Property("ClawCount") .HasColumnType("int"); x.HasData( - new - { - Id = 42, - ClawCount = (short)20 - }); + new { Id = 42, ClawCount = (short)20 }); }), target => target.Entity( "Puma", @@ -1875,11 +1778,7 @@ public void Alter_column_type_with_seed_data() { x.Property("ClawCount"); x.HasData( - new - { - Id = 42, - ClawCount = 20 - }); + new { Id = 42, ClawCount = 20 }); }), operations => { @@ -1911,14 +1810,8 @@ public void Alter_key_column_type_with_seed_data() x.ToTable("Firefly", "dbo"); x.Property("Id"); x.HasData( - new - { - Id = 42 - }, - new - { - Id = 43 - }); + new { Id = 42 }, + new { Id = 43 }); }), target => target.Entity( "Firefly", @@ -1927,10 +1820,7 @@ public void Alter_key_column_type_with_seed_data() x.ToTable("Firefly", "dbo"); x.Property("Id").HasColumnType("nvarchar(30)"); x.HasData( - new - { - Id = "42" - }); + new { Id = "42" }); }), upOps => Assert.Collection( upOps, @@ -2653,11 +2543,7 @@ public void Alter_primary_key_column_order_with_seed_data() x.Property("Id"); x.Property("RavenId"); x.HasData( - new - { - Id = 42, - RavenId = "42" - }); + new { Id = 42, RavenId = "42" }); }), source => source.Entity( "Raven", @@ -4521,11 +4407,7 @@ public void Create_table_with_seed_data() x.Property("Id"); x.Property("Name").HasColumnType("nvarchar(30)"); x.HasData( - new - { - Id = 42, - Name = "equal" - }); + new { Id = 42, Name = "equal" }); }), upOps => Assert.Collection( upOps, @@ -4935,11 +4817,7 @@ public void Add_subtype_with_shared_column_with_seed_data() { x.HasBaseType("Animal").Property("BreederId").HasColumnName("BreederId"); x.HasData( - new - { - Id = 42, - BreederId = "42" - }); + new { Id = 42, BreederId = "42" }); }); }, _ => { }, @@ -4950,11 +4828,7 @@ public void Add_subtype_with_shared_column_with_seed_data() { x.HasBaseType("Animal").Property("BreederId").HasColumnName("BreederId"); x.HasData( - new - { - Id = 43, - BreederId = "43" - }); + new { Id = 43, BreederId = "43" }); }); }, upOps => Assert.Collection( @@ -5262,10 +5136,7 @@ public void Split_out_subtype_with_seed_data() x.Property("Name"); x.ToTable("Animal", "dbo"); x.HasData( - new - { - Id = 42 - }); + new { Id = 42 }); }); common.Entity( @@ -5273,32 +5144,21 @@ public void Split_out_subtype_with_seed_data() { x.HasBaseType("Animal"); x.HasData( - new - { - Id = 41 - }); + new { Id = 41 }); }); }, source => source.Entity( "Animal", x => { x.HasData( - new - { - Id = 43, - Name = "Bob" - }); + new { Id = 43, Name = "Bob" }); }), target => target.Entity( "Shark", x => { x.HasBaseType("Animal"); x.HasData( - new - { - Id = 43, - Name = "Bob" - }); + new { Id = 43, Name = "Bob" }); }), upOps => Assert.Collection( upOps, @@ -5527,10 +5387,7 @@ public void Add_foreign_key_referencing_renamed_column_with_seed_data() { x.HasIndex("ForeignId"); x.HasData( - new - { - Id = 43 - }); + new { Id = 43 }); }), target => target .Entity( @@ -5538,10 +5395,7 @@ public void Add_foreign_key_referencing_renamed_column_with_seed_data() { x.Property("Id").HasColumnName("ReferencedTableId"); x.HasData( - new - { - Id = 42 - }); + new { Id = 42 }); }) .Entity( "Table", @@ -5549,11 +5403,7 @@ public void Add_foreign_key_referencing_renamed_column_with_seed_data() { x.HasOne("ReferencedTable").WithMany().HasForeignKey("ForeignId"); x.HasData( - new - { - Id = 43, - ForeignId = 42 - }); + new { Id = 43, ForeignId = 42 }); }), upOps => Assert.Collection( upOps, @@ -6268,11 +6118,7 @@ public void Add_foreign_key_referencing_added_alternate_key_with_seed_data() { x.HasAlternateKey("AlternateId"); x.HasData( - new - { - Id = 42, - AlternateId = 4242 - }); + new { Id = 42, AlternateId = 4242 }); }) .Entity( "ReferencingTable", @@ -6284,11 +6130,7 @@ public void Add_foreign_key_referencing_added_alternate_key_with_seed_data() .HasForeignKey("ReferencedAlternateId") .HasPrincipalKey("AlternateId"); x.HasData( - new - { - Id = 43, - ReferencedAlternateId = 4242 - }); + new { Id = 43, ReferencedAlternateId = 4242 }); }), upOps => Assert.Collection( upOps, @@ -6350,7 +6192,6 @@ public void Add_foreign_key_referencing_added_alternate_key_with_seed_data() })); } - [ConditionalFact] public void Update_AK_seed_value_with_a_referencing_foreign_key() { @@ -6372,33 +6213,21 @@ public void Update_AK_seed_value_with_a_referencing_foreign_key() x.HasIndex("ForeignId"); x.HasOne("ReferencedTable").WithMany().HasForeignKey("ForeignId").IsRequired(); x.HasData( - new - { - Id = 43, - ForeignId = 42 - }); + new { Id = 43, ForeignId = 42 }); }), source => source .Entity( "ReferencedTable", x => { x.HasData( - new - { - Id = 42, - AlternateId = 4242 - }); + new { Id = 42, AlternateId = 4242 }); }), target => target .Entity( "ReferencedTable", x => { x.HasData( - new - { - Id = 42, - AlternateId = 4343 - }); + new { Id = 42, AlternateId = 4343 }); }), upOps => Assert.Collection( upOps, @@ -6495,11 +6324,7 @@ public void SeedData_add_on_existing_table() x.Property("Value1"); x.Property("Value2"); x.HasData( - new - { - Id = 42, - Value1 = 32 - }); + new { Id = 42, Value1 = 32 }); }), upOps => Assert.Collection( upOps, @@ -6536,11 +6361,7 @@ public void SeedData_remove() x.Property("Value1"); x.Property("Value2"); x.HasData( - new - { - Id = 42, - Value1 = 32 - }); + new { Id = 42, Value1 = 32 }); }), target => target.Entity( "EntityWithTwoProperties", @@ -6584,11 +6405,7 @@ public void SeedData_binary_change() x.Property("Id"); x.Property("Value1"); x.HasData( - new - { - Id = 42, - Value1 = new byte[] { 2, 1 } - }); + new { Id = 42, Value1 = new byte[] { 2, 1 } }); }), target => target.Entity( "EntityWithTwoProperties", @@ -6597,11 +6414,7 @@ public void SeedData_binary_change() x.Property("Id"); x.Property("Value1"); x.HasData( - new - { - Id = 42, - Value1 = new byte[] { 1, 2 } - }); + new { Id = 42, Value1 = new byte[] { 1, 2 } }); }), upOps => Assert.Collection( upOps, @@ -6641,11 +6454,7 @@ public void SeedData_binary_no_change() x.Property("Id"); x.Property("Value1"); x.HasData( - new - { - Id = 42, - Value1 = new byte[] { 1, 2 } - }); + new { Id = 42, Value1 = new byte[] { 1, 2 } }); }), target => target.Entity( "EntityWithTwoProperties", @@ -6654,11 +6463,7 @@ public void SeedData_binary_no_change() x.Property("Id"); x.Property("Value1"); x.HasData( - new - { - Id = 42, - Value1 = new byte[] { 1, 2 } - }); + new { Id = 42, Value1 = new byte[] { 1, 2 } }); }), upOps => Assert.Empty(upOps), downOps => Assert.Empty(downOps)); @@ -6679,18 +6484,8 @@ public void SeedData_update_with_table_rename() x.Property("Value1"); x.Property("Value2"); x.HasData( - new - { - Id = 42, - Value1 = 32, - Value2 = "equal" - }, // modified - new - { - Id = 24, - Value1 = 72, - Value2 = "not equal1" - }); // modified + new { Id = 42, Value1 = 32, Value2 = "equal" }, // modified + new { Id = 24, Value1 = 72, Value2 = "not equal1" }); // modified }), target => target.Entity( "EntityWithTwoProperties", @@ -6702,18 +6497,8 @@ public void SeedData_update_with_table_rename() x.Property("Value1"); x.Property("Value2"); x.HasData( - new - { - Id = 42, - Value1 = 27, - Value2 = "equal" - }, // modified - new - { - Id = 24, - Value1 = 99, - Value2 = "not equal2" - }); // modified + new { Id = 42, Value1 = 27, Value2 = "equal" }, // modified + new { Id = 24, Value1 = 99, Value2 = "not equal2" }); // modified }), upOps => Assert.Collection( upOps, @@ -6800,11 +6585,7 @@ public void SeedData_nonkey_refactoring_value_conversion() { x.Property("Value1").IsRequired(); x.HasData( - new - { - Id = 42, - Value1 = "32" - }); + new { Id = 42, Value1 = "32" }); }), target => target.Entity( "EntityWithOneProperty", @@ -6813,11 +6594,7 @@ public void SeedData_nonkey_refactoring_value_conversion() x.Property("Value1") .HasConversion(e => e.ToString(), e => int.Parse(e)); x.HasData( - new - { - Id = 42, - Value1 = 32 - }); + new { Id = 42, Value1 = 32 }); }), Assert.Empty, Assert.Empty); @@ -6838,11 +6615,7 @@ public void SeedData_nonkey_refactoring_value_conversion_with_structural_provide .IsRequired() .HasConversion(e => new[] { e }, e => e[0]); x.HasData( - new - { - Id = 42, - Value1 = 32 - }); + new { Id = 42, Value1 = 32 }); }), target => target.Entity( "EntityWithOneProperty", @@ -6852,11 +6625,7 @@ public void SeedData_nonkey_refactoring_value_conversion_with_structural_provide .IsRequired() .HasConversion(e => new[] { int.Parse(e) }, e => e[0].ToString()); x.HasData( - new - { - Id = 42, - Value1 = "32" - }); + new { Id = 42, Value1 = "32" }); }), Assert.Empty, Assert.Empty); @@ -6875,11 +6644,7 @@ public void SeedData_key_refactoring_value_conversion() { x.Property("Id"); x.HasData( - new - { - Id = "42", - Value1 = 32 - }); + new { Id = "42", Value1 = 32 }); }), target => target.Entity( "EntityWithOneProperty", @@ -6888,11 +6653,7 @@ public void SeedData_key_refactoring_value_conversion() x.Property("Id") .HasConversion(e => e.ToString(), e => int.Parse(e)); x.HasData( - new - { - Id = 42, - Value1 = 32 - }); + new { Id = 42, Value1 = 32 }); }), Assert.Empty, Assert.Empty); @@ -6911,11 +6672,7 @@ public void SeedData_change_enum_conversion() x.HasKey("Id"); x.Property("Enum").HasDefaultValue(SomeEnum.Default); x.HasData( - new - { - Id = 1, - Enum = SomeEnum.NonDefault - }); + new { Id = 1, Enum = SomeEnum.NonDefault }); }), _ => { }, target => target.Entity( @@ -6986,10 +6743,7 @@ public void SeedData_no_change_enum_key() x.Property("Enum"); x.HasKey("Enum"); x.HasData( - new - { - Enum = 1 - }); + new { Enum = 1 }); }), target => target.Entity( "EntityWithEnumKey", @@ -6999,10 +6753,7 @@ public void SeedData_no_change_enum_key() x.Property("Enum"); x.HasKey("Enum"); x.HasData( - new - { - Enum = SomeEnum.NonDefault - }); + new { Enum = SomeEnum.NonDefault }); }), Assert.Empty, Assert.Empty); @@ -7021,31 +6772,10 @@ public void SeedData_all_operations() x.Property("Value1"); x.Property("Value2"); x.HasData( - new - { - Id = 99999, - Value1 = 0, - Value2 = "" - }, // deleted - new - { - Id = 42, - Value1 = 32, - Value2 = "equal", - InvalidProperty = "is ignored" - }, // modified - new - { - Id = 8, - Value1 = 100, - Value2 = "equal" - }, // unchanged - new - { - Id = 24, - Value1 = 72, - Value2 = "not equal1" - }); // modified + new { Id = 99999, Value1 = 0, Value2 = "" }, // deleted + new { Id = 42, Value1 = 32, Value2 = "equal", InvalidProperty = "is ignored" }, // modified + new { Id = 8, Value1 = 100, Value2 = "equal" }, // unchanged + new { Id = 24, Value1 = 72, Value2 = "not equal1" }); // modified }), target => target.Entity( "EntityWithTwoProperties", @@ -7055,37 +6785,11 @@ public void SeedData_all_operations() x.Property("Value1"); x.Property("Value2"); x.HasData( - new - { - Id = 11111, - Value1 = 0, - Value2 = "" - }, // added - new - { - Id = 11112, - Value1 = 1, - Value2 = "new" - }, // added - new - { - Id = 42, - Value1 = 27, - Value2 = "equal", - InvalidProperty = "is ignored here too" - }, // modified - new - { - Id = 8, - Value1 = 100, - Value2 = "equal" - }, // unchanged - new - { - Id = 24, - Value1 = 99, - Value2 = "not equal2" - }); // modified + new { Id = 11111, Value1 = 0, Value2 = "" }, // added + new { Id = 11112, Value1 = 1, Value2 = "new" }, // added + new { Id = 42, Value1 = 27, Value2 = "equal", InvalidProperty = "is ignored here too" }, // modified + new { Id = 8, Value1 = 100, Value2 = "equal" }, // unchanged + new { Id = 24, Value1 = 99, Value2 = "not equal2" }); // modified }), upOps => Assert.Collection( upOps, @@ -7199,11 +6903,7 @@ public void SeedData_with_timestamp_column() x.Property("ComputedValueSql").HasComputedColumnSql("5"); x.Property("TimeStamp").IsRowVersion(); x.HasData( - new - { - Id = 11, - Value = "Value" - }, //Modified + new { Id = 11, Value = "Value" }, //Modified new { Id = 12, @@ -7212,11 +6912,7 @@ public void SeedData_with_timestamp_column() DefaultValueSql = 5, ComputedValueSql = 5 }, //Modified - new - { - Id = 21, - Value = "Deleted" - }); //Deleted + new { Id = 21, Value = "Deleted" }); //Deleted }), target => target.Entity( "EntityWithTimeStamp", @@ -7229,11 +6925,7 @@ public void SeedData_with_timestamp_column() x.Property("ComputedValueSql").HasComputedColumnSql("5"); x.Property("TimeStamp").IsRowVersion(); x.HasData( - new - { - Id = 11, - Value = "Modified" - }, //Modified + new { Id = 11, Value = "Modified" }, //Modified new { Id = 12, @@ -7242,11 +6934,7 @@ public void SeedData_with_timestamp_column() DefaultValueSql = 6, ComputedValueSql = 5 }, //Modified - new - { - Id = 31, - Value = "Added" - }, //Added + new { Id = 31, Value = "Added" }, //Added new { Id = 32, @@ -7372,21 +7060,9 @@ public void SeedData_with_shadow_navigation_properties() x.Property("BlogId"); x.Property("Url"); x.HasData( - new - { - BlogId = 32, - Url = "updated.url" - }, - new - { - BlogId = 38, - Url = "newblog.url" - }, - new - { - BlogId = 316, - Url = "nowitexists.blog" - }); + new { BlogId = 32, Url = "updated.url" }, + new { BlogId = 38, Url = "newblog.url" }, + new { BlogId = 316, Url = "nowitexists.blog" }); }); target.Entity( "Post", @@ -7399,24 +7075,9 @@ public void SeedData_with_shadow_navigation_properties() .HasForeignKey("BlogId") .OnDelete(DeleteBehavior.Cascade); x.HasData( - new - { - PostId = 416, - Title = "Post To Non-existent BlogId", - BlogId = 316 - }, - new - { - PostId = 545, - Title = "Updated Title", - BlogId = 38 - }, - new - { - PostId = 546, - Title = "New Post", - BlogId = 32 - }); + new { PostId = 416, Title = "Post To Non-existent BlogId", BlogId = 316 }, + new { PostId = 545, Title = "Updated Title", BlogId = 38 }, + new { PostId = 546, Title = "New Post", BlogId = 32 }); }); }); } @@ -7433,21 +7094,9 @@ public void SeedData_with_CLR_navigation_properties() x.Property("BlogId"); x.Property("Url"); x.HasData( - new - { - BlogId = 32, - Url = "updated.url" - }, - new - { - BlogId = 38, - Url = "newblog.url" - }, - new - { - BlogId = 316, - Url = "nowitexists.blog" - }); + new { BlogId = 32, Url = "updated.url" }, + new { BlogId = 38, Url = "newblog.url" }, + new { BlogId = 316, Url = "nowitexists.blog" }); }); target.Entity( x => @@ -7459,24 +7108,9 @@ public void SeedData_with_CLR_navigation_properties() .HasForeignKey("BlogId") .OnDelete(DeleteBehavior.Cascade); x.HasData( - new - { - PostId = 416, - Title = "Post To Non-existent BlogId", - BlogId = 316 - }, - new - { - PostId = 545, - Title = "Updated Title", - BlogId = 38 - }, - new - { - PostId = 546, - Title = "New Post", - BlogId = 32 - }); + new { PostId = 416, Title = "Post To Non-existent BlogId", BlogId = 316 }, + new { PostId = 545, Title = "Updated Title", BlogId = 38 }, + new { PostId = 546, Title = "New Post", BlogId = 32 }); }); }); } @@ -7494,11 +7128,7 @@ private void SeedData_with_navigation_properties(Action buildTarge x.Property("BlogId"); x.Property("Url"); x.HasData( - new - { - BlogId = 32, - Url = "original.url" - }); + new { BlogId = 32, Url = "original.url" }); }); source.Entity( "Post", @@ -7511,24 +7141,9 @@ private void SeedData_with_navigation_properties(Action buildTarge .HasForeignKey("BlogId") .OnDelete(DeleteBehavior.Cascade); x.HasData( - new - { - PostId = 545, - Title = "Original Title", - BlogId = 32 - }, - new - { - PostId = 416, - Title = "Post To Non-existent BlogId", - BlogId = 316 - }, - new - { - PostId = 390, - Title = "Post To Be Removed", - BlogId = 32 - }); + new { PostId = 545, Title = "Original Title", BlogId = 32 }, + new { PostId = 416, Title = "Post To Non-existent BlogId", BlogId = 316 }, + new { PostId = 390, Title = "Post To Be Removed", BlogId = 32 }); }); }, buildTargetAction, @@ -7818,22 +7433,11 @@ public void Add_type_with_ownership_SeedData() { x.Property("_secretId"); x.HasData( - new Order(42) - { - Id = 1 - }); + new Order(42) { Id = 1 }); x.OwnsOne(y => y.Billing).HasData( - new - { - OrderId = 1, - AddressLine1 = "billing" - }); + new { OrderId = 1, AddressLine1 = "billing" }); x.OwnsOne(y => y.Shipping).HasData( - new - { - OrderId = 1, - AddressLine2 = "shipping" - }); + new { OrderId = 1, AddressLine2 = "shipping" }); }), upOps => Assert.Collection( upOps, @@ -7876,22 +7480,11 @@ public void SeedData_type_with_ownership_no_changes() { x.Property("_secretId"); x.HasData( - new Order(42) - { - Id = 1 - }); + new Order(42) { Id = 1 }); x.OwnsOne(y => y.Billing).HasData( - new - { - OrderId = 1, - AddressLine1 = "billing" - }); + new { OrderId = 1, AddressLine1 = "billing" }); x.OwnsOne(y => y.Shipping).HasData( - new - { - OrderId = 1, - AddressLine2 = "shipping" - }); + new { OrderId = 1, AddressLine2 = "shipping" }); }); }, _ => { }, @@ -7906,53 +7499,58 @@ public void Old_style_ownership_to_new_style() Execute( common => { - common.Entity("Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); + common.Entity( + "Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("Order"); - }); + b.ToTable("Order"); + }); }, source => { - source.Entity("Order", b => - { - b.OwnsOne("OrderInfo", "OrderInfo", b1 => + source.Entity( + "Order", b => { - b1.Property("OrderId") - .ValueGeneratedOnAdd(); + b.OwnsOne( + "OrderInfo", "OrderInfo", b1 => + { + b1.Property("OrderId") + .ValueGeneratedOnAdd(); - b1.HasKey("OrderId"); + b1.HasKey("OrderId"); - b1.ToTable("Order"); + b1.ToTable("Order"); - b1.HasOne("Order") - .WithOne("OrderInfo") - .HasForeignKey("OrderInfo", "OrderId") - .OnDelete(DeleteBehavior.Cascade); + b1.HasOne("Order") + .WithOne("OrderInfo") + .HasForeignKey("OrderInfo", "OrderId") + .OnDelete(DeleteBehavior.Cascade); + }); }); - }); }, target => { - target.Entity("Order", b => - { - b.OwnsOne("OrderInfo", "OrderInfo", b1 => + target.Entity( + "Order", b => { - b1.Property("OrderId") - .ValueGeneratedOnAdd(); + b.OwnsOne( + "OrderInfo", "OrderInfo", b1 => + { + b1.Property("OrderId") + .ValueGeneratedOnAdd(); - b1.HasKey("OrderId"); + b1.HasKey("OrderId"); - b1.ToTable("Order"); + b1.ToTable("Order"); - b1.WithOwner() - .HasForeignKey("OrderId"); + b1.WithOwner() + .HasForeignKey("OrderId"); + }); }); - }); }, Assert.Empty, Assert.Empty); diff --git a/test/EFCore.Relational.Tests/Migrations/MigrationCommandExecutorTest.cs b/test/EFCore.Relational.Tests/Migrations/MigrationCommandExecutorTest.cs index 82182dc2d77..9bd6c5b296f 100644 --- a/test/EFCore.Relational.Tests/Migrations/MigrationCommandExecutorTest.cs +++ b/test/EFCore.Relational.Tests/Migrations/MigrationCommandExecutorTest.cs @@ -258,10 +258,7 @@ public async Task Disposes_transaction_on_exception(bool async) var logger = new FakeDiagnosticsLogger(); - var commandList = new List - { - new MigrationCommand(CreateRelationalCommand(), null, logger) - }; + var commandList = new List { new MigrationCommand(CreateRelationalCommand(), null, logger) }; var migrationCommandExecutor = new MigrationCommandExecutor(); diff --git a/test/EFCore.Relational.Tests/Migrations/MigrationSqlGeneratorTest.cs b/test/EFCore.Relational.Tests/Migrations/MigrationSqlGeneratorTest.cs index af7d60a7127..593a9b31b21 100644 --- a/test/EFCore.Relational.Tests/Migrations/MigrationSqlGeneratorTest.cs +++ b/test/EFCore.Relational.Tests/Migrations/MigrationSqlGeneratorTest.cs @@ -13,7 +13,8 @@ public override void AddColumnOperation_with_defaultValue() { base.AddColumnOperation_with_defaultValue(); - AssertSql(@"ALTER TABLE ""dbo"".""People"" ADD ""Name"" varchar(30) NOT NULL DEFAULT 'John Doe'; + AssertSql( + @"ALTER TABLE ""dbo"".""People"" ADD ""Name"" varchar(30) NOT NULL DEFAULT 'John Doe'; "); } @@ -21,7 +22,8 @@ public override void AddColumnOperation_with_defaultValueSql() { base.AddColumnOperation_with_defaultValueSql(); - AssertSql(@"ALTER TABLE ""People"" ADD ""Birthday"" date NULL DEFAULT (CURRENT_TIMESTAMP); + AssertSql( + @"ALTER TABLE ""People"" ADD ""Birthday"" date NULL DEFAULT (CURRENT_TIMESTAMP); "); } @@ -29,7 +31,8 @@ public override void AddColumnOperation_without_column_type() { base.AddColumnOperation_without_column_type(); - AssertSql(@"ALTER TABLE ""People"" ADD ""Alias"" just_string(max) NOT NULL; + AssertSql( + @"ALTER TABLE ""People"" ADD ""Alias"" just_string(max) NOT NULL; "); } @@ -37,7 +40,8 @@ public override void AddColumnOperation_with_maxLength() { base.AddColumnOperation_with_maxLength(); - AssertSql(@"ALTER TABLE ""Person"" ADD ""Name"" just_string(30) NULL; + AssertSql( + @"ALTER TABLE ""Person"" ADD ""Name"" just_string(30) NULL; "); } @@ -45,7 +49,8 @@ public override void AddColumnOperation_with_maxLength_on_derived() { base.AddColumnOperation_with_maxLength_on_derived(); - AssertSql(@"ALTER TABLE ""Person"" ADD ""Name"" just_string(30) NULL; + AssertSql( + @"ALTER TABLE ""Person"" ADD ""Name"" just_string(30) NULL; "); } @@ -53,7 +58,8 @@ public override void AddColumnOperation_with_shared_column() { base.AddColumnOperation_with_shared_column(); - AssertSql(@"ALTER TABLE ""Base"" ADD ""Foo"" just_string(max) NULL; + AssertSql( + @"ALTER TABLE ""Base"" ADD ""Foo"" just_string(max) NULL; "); } @@ -61,7 +67,8 @@ public override void AddForeignKeyOperation_with_name() { base.AddForeignKeyOperation_with_name(); - AssertSql(@"ALTER TABLE ""dbo"".""People"" ADD CONSTRAINT ""FK_People_Companies"" FOREIGN KEY (""EmployerId1"", ""EmployerId2"") REFERENCES ""hr"".""Companies"" (""Id1"", ""Id2"") ON DELETE CASCADE; + AssertSql( + @"ALTER TABLE ""dbo"".""People"" ADD CONSTRAINT ""FK_People_Companies"" FOREIGN KEY (""EmployerId1"", ""EmployerId2"") REFERENCES ""hr"".""Companies"" (""Id1"", ""Id2"") ON DELETE CASCADE; "); } @@ -69,7 +76,8 @@ public override void AddForeignKeyOperation_without_name() { base.AddForeignKeyOperation_without_name(); - AssertSql(@"ALTER TABLE ""People"" ADD FOREIGN KEY (""SpouseId"") REFERENCES ""People"" (""Id""); + AssertSql( + @"ALTER TABLE ""People"" ADD FOREIGN KEY (""SpouseId"") REFERENCES ""People"" (""Id""); "); } @@ -77,7 +85,8 @@ public override void AddForeignKeyOperation_without_principal_columns() { base.AddForeignKeyOperation_without_principal_columns(); - AssertSql(@"ALTER TABLE ""People"" ADD FOREIGN KEY (""SpouseId"") REFERENCES ""People""; + AssertSql( + @"ALTER TABLE ""People"" ADD FOREIGN KEY (""SpouseId"") REFERENCES ""People""; "); } @@ -85,7 +94,8 @@ public override void AddPrimaryKeyOperation_with_name() { base.AddPrimaryKeyOperation_with_name(); - AssertSql(@"ALTER TABLE ""dbo"".""People"" ADD CONSTRAINT ""PK_People"" PRIMARY KEY (""Id1"", ""Id2""); + AssertSql( + @"ALTER TABLE ""dbo"".""People"" ADD CONSTRAINT ""PK_People"" PRIMARY KEY (""Id1"", ""Id2""); "); } @@ -93,7 +103,8 @@ public override void AddPrimaryKeyOperation_without_name() { base.AddPrimaryKeyOperation_without_name(); - AssertSql(@"ALTER TABLE ""People"" ADD PRIMARY KEY (""Id""); + AssertSql( + @"ALTER TABLE ""People"" ADD PRIMARY KEY (""Id""); "); } @@ -101,7 +112,8 @@ public override void AddUniqueConstraintOperation_with_name() { base.AddUniqueConstraintOperation_with_name(); - AssertSql(@"ALTER TABLE ""dbo"".""People"" ADD CONSTRAINT ""AK_People_DriverLicense"" UNIQUE (""DriverLicense_State"", ""DriverLicense_Number""); + AssertSql( + @"ALTER TABLE ""dbo"".""People"" ADD CONSTRAINT ""AK_People_DriverLicense"" UNIQUE (""DriverLicense_State"", ""DriverLicense_Number""); "); } @@ -109,7 +121,8 @@ public override void AddUniqueConstraintOperation_without_name() { base.AddUniqueConstraintOperation_without_name(); - AssertSql(@"ALTER TABLE ""People"" ADD UNIQUE (""SSN""); + AssertSql( + @"ALTER TABLE ""People"" ADD UNIQUE (""SSN""); "); } @@ -117,7 +130,8 @@ public override void CreateCheckConstraintOperation_with_name() { base.CreateCheckConstraintOperation_with_name(); - AssertSql(@"ALTER TABLE ""dbo"".""People"" ADD CONSTRAINT ""CK_People_DriverLicense"" CHECK (DriverLicense_Number > 0); + AssertSql( + @"ALTER TABLE ""dbo"".""People"" ADD CONSTRAINT ""CK_People_DriverLicense"" CHECK (DriverLicense_Number > 0); "); } @@ -125,7 +139,8 @@ public override void AlterSequenceOperation_with_minValue_and_maxValue() { base.AlterSequenceOperation_with_minValue_and_maxValue(); - AssertSql(@"ALTER SEQUENCE ""dbo"".""EntityFrameworkHiLoSequence"" INCREMENT BY 1 MINVALUE 2 MAXVALUE 816 CYCLE; + AssertSql( + @"ALTER SEQUENCE ""dbo"".""EntityFrameworkHiLoSequence"" INCREMENT BY 1 MINVALUE 2 MAXVALUE 816 CYCLE; "); } @@ -133,7 +148,8 @@ public override void AlterSequenceOperation_without_minValue_and_maxValue() { base.AlterSequenceOperation_without_minValue_and_maxValue(); - AssertSql(@"ALTER SEQUENCE ""EntityFrameworkHiLoSequence"" INCREMENT BY 1 NO MINVALUE NO MAXVALUE NO CYCLE; + AssertSql( + @"ALTER SEQUENCE ""EntityFrameworkHiLoSequence"" INCREMENT BY 1 NO MINVALUE NO MAXVALUE NO CYCLE; "); } @@ -141,7 +157,8 @@ public override void CreateIndexOperation_unique() { base.CreateIndexOperation_unique(); - AssertSql(@"CREATE UNIQUE INDEX ""IX_People_Name"" ON ""dbo"".""People"" (""FirstName"", ""LastName""); + AssertSql( + @"CREATE UNIQUE INDEX ""IX_People_Name"" ON ""dbo"".""People"" (""FirstName"", ""LastName""); "); } @@ -149,7 +166,8 @@ public override void CreateIndexOperation_nonunique() { base.CreateIndexOperation_nonunique(); - AssertSql(@"CREATE INDEX ""IX_People_Name"" ON ""People"" (""Name""); + AssertSql( + @"CREATE INDEX ""IX_People_Name"" ON ""People"" (""Name""); "); } @@ -157,7 +175,8 @@ public override void CreateIndexOperation_with_where_clauses() { base.CreateIndexOperation_with_where_clauses(); - AssertSql(@"CREATE INDEX ""IX_People_Name"" ON ""People"" (""Name"") WHERE [Id] > 2; + AssertSql( + @"CREATE INDEX ""IX_People_Name"" ON ""People"" (""Name"") WHERE [Id] > 2; "); } @@ -165,7 +184,8 @@ public override void CreateSequenceOperation_with_minValue_and_maxValue() { base.CreateSequenceOperation_with_minValue_and_maxValue(); - AssertSql(@"CREATE SEQUENCE ""dbo"".""EntityFrameworkHiLoSequence"" START WITH 3 INCREMENT BY 1 MINVALUE 2 MAXVALUE 816 CYCLE; + AssertSql( + @"CREATE SEQUENCE ""dbo"".""EntityFrameworkHiLoSequence"" START WITH 3 INCREMENT BY 1 MINVALUE 2 MAXVALUE 816 CYCLE; "); } @@ -173,7 +193,8 @@ public override void CreateSequenceOperation_with_minValue_and_maxValue_not_long { base.CreateSequenceOperation_with_minValue_and_maxValue_not_long(); - AssertSql(@"CREATE SEQUENCE ""dbo"".""EntityFrameworkHiLoSequence"" AS default_int_mapping START WITH 3 INCREMENT BY 1 MINVALUE 2 MAXVALUE 816 CYCLE; + AssertSql( + @"CREATE SEQUENCE ""dbo"".""EntityFrameworkHiLoSequence"" AS default_int_mapping START WITH 3 INCREMENT BY 1 MINVALUE 2 MAXVALUE 816 CYCLE; "); } @@ -181,7 +202,8 @@ public override void CreateSequenceOperation_without_minValue_and_maxValue() { base.CreateSequenceOperation_without_minValue_and_maxValue(); - AssertSql(@"CREATE SEQUENCE ""EntityFrameworkHiLoSequence"" START WITH 3 INCREMENT BY 1 NO MINVALUE NO MAXVALUE NO CYCLE; + AssertSql( + @"CREATE SEQUENCE ""EntityFrameworkHiLoSequence"" START WITH 3 INCREMENT BY 1 NO MINVALUE NO MAXVALUE NO CYCLE; "); } @@ -217,7 +239,8 @@ public override void DropColumnOperation() { base.DropColumnOperation(); - AssertSql(@"ALTER TABLE ""dbo"".""People"" DROP COLUMN ""LuckyNumber""; + AssertSql( + @"ALTER TABLE ""dbo"".""People"" DROP COLUMN ""LuckyNumber""; "); } @@ -225,7 +248,8 @@ public override void DropForeignKeyOperation() { base.DropForeignKeyOperation(); - AssertSql(@"ALTER TABLE ""dbo"".""People"" DROP CONSTRAINT ""FK_People_Companies""; + AssertSql( + @"ALTER TABLE ""dbo"".""People"" DROP CONSTRAINT ""FK_People_Companies""; "); } @@ -233,7 +257,8 @@ public override void DropPrimaryKeyOperation() { base.DropPrimaryKeyOperation(); - AssertSql(@"ALTER TABLE ""dbo"".""People"" DROP CONSTRAINT ""PK_People""; + AssertSql( + @"ALTER TABLE ""dbo"".""People"" DROP CONSTRAINT ""PK_People""; "); } @@ -241,7 +266,8 @@ public override void DropSequenceOperation() { base.DropSequenceOperation(); - AssertSql(@"DROP SEQUENCE ""dbo"".""EntityFrameworkHiLoSequence""; + AssertSql( + @"DROP SEQUENCE ""dbo"".""EntityFrameworkHiLoSequence""; "); } @@ -249,7 +275,8 @@ public override void DropTableOperation() { base.DropTableOperation(); - AssertSql(@"DROP TABLE ""dbo"".""People""; + AssertSql( + @"DROP TABLE ""dbo"".""People""; "); } @@ -257,7 +284,8 @@ public override void DropUniqueConstraintOperation() { base.DropUniqueConstraintOperation(); - AssertSql(@"ALTER TABLE ""dbo"".""People"" DROP CONSTRAINT ""AK_People_SSN""; + AssertSql( + @"ALTER TABLE ""dbo"".""People"" DROP CONSTRAINT ""AK_People_SSN""; "); } @@ -265,7 +293,8 @@ public override void DropCheckConstraintOperation() { base.DropCheckConstraintOperation(); - AssertSql(@"ALTER TABLE ""dbo"".""People"" DROP CONSTRAINT ""CK_People_SSN""; + AssertSql( + @"ALTER TABLE ""dbo"".""People"" DROP CONSTRAINT ""CK_People_SSN""; "); } @@ -273,7 +302,8 @@ public override void SqlOperation() { base.SqlOperation(); - AssertSql(@"-- I <3 DDL + AssertSql( + @"-- I <3 DDL "); } @@ -281,14 +311,8 @@ public override void SqlOperation() public void Generate_doesnt_batch_by_default() { Generate( - new SqlOperation - { - Sql = "SELECT 1;" - }, - new SqlOperation - { - Sql = "SELECT 2;" - }); + new SqlOperation { Sql = "SELECT 1;" }, + new SqlOperation { Sql = "SELECT 2;" }); AssertSql( @"SELECT 1; diff --git a/test/EFCore.Relational.Tests/RelationalConnectionTest.cs b/test/EFCore.Relational.Tests/RelationalConnectionTest.cs index 6a534ccd24a..a8789df37ce 100644 --- a/test/EFCore.Relational.Tests/RelationalConnectionTest.cs +++ b/test/EFCore.Relational.Tests/RelationalConnectionTest.cs @@ -386,8 +386,7 @@ public void Existing_connection_can_start_in_opened_state() public void Existing_connection_can_be_opened_and_closed_externally() { var dbConnection = new FakeDbConnection( - "Database=FrodoLives", - state: ConnectionState.Closed); + "Database=FrodoLives"); using (var connection = new FakeRelationalConnection( CreateOptions(new FakeRelationalOptionsExtension().WithConnection(dbConnection)))) @@ -468,8 +467,7 @@ public void Existing_connection_can_be_opened_and_closed_externally() public async Task Existing_connection_can_be_opened_and_closed_externally_async() { var dbConnection = new FakeDbConnection( - "Database=FrodoLives", - state: ConnectionState.Closed); + "Database=FrodoLives"); using (var connection = new FakeRelationalConnection( CreateOptions(new FakeRelationalOptionsExtension().WithConnection(dbConnection)))) diff --git a/test/EFCore.Relational.Tests/RelationalDatabaseFacadeExtensionsTest.cs b/test/EFCore.Relational.Tests/RelationalDatabaseFacadeExtensionsTest.cs index d5986794afc..09571440bc3 100644 --- a/test/EFCore.Relational.Tests/RelationalDatabaseFacadeExtensionsTest.cs +++ b/test/EFCore.Relational.Tests/RelationalDatabaseFacadeExtensionsTest.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Data; using System.Linq; using System.Reflection; using System.Threading; @@ -18,6 +17,7 @@ using Microsoft.EntityFrameworkCore.TestUtilities.FakeProvider; using Microsoft.Extensions.DependencyInjection; using Xunit; +using IsolationLevel = System.Data.IsolationLevel; namespace Microsoft.EntityFrameworkCore { @@ -104,11 +104,11 @@ public async Task Can_begin_transaction_with_isolation_level(bool async) ((FakeRelationalConnection)context.GetService()).UseConnection(dbConnection); var transaction = async - ? await context.Database.BeginTransactionAsync(System.Data.IsolationLevel.Chaos) - : context.Database.BeginTransaction(System.Data.IsolationLevel.Chaos); + ? await context.Database.BeginTransactionAsync(IsolationLevel.Chaos) + : context.Database.BeginTransaction(IsolationLevel.Chaos); Assert.Same(dbConnection.DbTransactions.Single(), transaction.GetDbTransaction()); - Assert.Equal(System.Data.IsolationLevel.Chaos, transaction.GetDbTransaction().IsolationLevel); + Assert.Equal(IsolationLevel.Chaos, transaction.GetDbTransaction().IsolationLevel); } [ConditionalFact] @@ -117,7 +117,7 @@ public void Can_use_transaction() var dbConnection = new FakeDbConnection("A=B"); var context = RelationalTestHelpers.Instance.CreateContext(); ((FakeRelationalConnection)context.GetService()).UseConnection(dbConnection); - var transaction = new FakeDbTransaction(dbConnection, System.Data.IsolationLevel.Chaos); + var transaction = new FakeDbTransaction(dbConnection, IsolationLevel.Chaos); Assert.Same(transaction, context.Database.UseTransaction(transaction).GetDbTransaction()); } @@ -134,12 +134,12 @@ public async Task Begin_transaction_ignores_isolation_level_on_non_relational_pr if (async) { - await context.Database.BeginTransactionAsync(System.Data.IsolationLevel.Chaos); + await context.Database.BeginTransactionAsync(IsolationLevel.Chaos); Assert.Equal(1, transactionManager.BeginAsyncCount); } else { - context.Database.BeginTransaction(System.Data.IsolationLevel.Chaos); + context.Database.BeginTransaction(IsolationLevel.Chaos); Assert.Equal(1, transactionManager.BeginCount); } } @@ -199,17 +199,9 @@ public void use_transaction_throws_on_non_relational_provider() [ConditionalFact] public void GetMigrations_works() { - var migrations = new[] - { - "00000000000001_One", - "00000000000002_Two", - "00000000000003_Three" - }; + var migrations = new[] { "00000000000001_One", "00000000000002_Two", "00000000000003_Three" }; - var migrationsAssembly = new FakeIMigrationsAssembly - { - Migrations = migrations.ToDictionary(x => x, x => default(TypeInfo)) - }; + var migrationsAssembly = new FakeIMigrationsAssembly { Migrations = migrations.ToDictionary(x => x, x => default(TypeInfo)) }; var db = RelationalTestHelpers.Instance.CreateContext( new ServiceCollection().AddSingleton(migrationsAssembly)); @@ -231,11 +223,7 @@ private class FakeIMigrationsAssembly : IMigrationsAssembly [InlineData(false)] public async Task GetAppliedMigrations_works(bool async) { - var migrations = new[] - { - "00000000000001_One", - "00000000000002_Two" - }; + var migrations = new[] { "00000000000001_One", "00000000000002_Two" }; var repository = new FakeHistoryRepository { @@ -278,23 +266,11 @@ public Task> GetAppliedMigrationsAsync(CancellationTok [InlineData(false)] public async Task GetPendingMigrations_works(bool async) { - var migrations = new[] - { - "00000000000001_One", - "00000000000002_Two", - "00000000000003_Three" - }; + var migrations = new[] { "00000000000001_One", "00000000000002_Two", "00000000000003_Three" }; - var appliedMigrations = new[] - { - "00000000000001_One", - "00000000000002_Two" - }; + var appliedMigrations = new[] { "00000000000001_One", "00000000000002_Two" }; - var migrationsAssembly = new FakeIMigrationsAssembly - { - Migrations = migrations.ToDictionary(x => x, x => default(TypeInfo)) - }; + var migrationsAssembly = new FakeIMigrationsAssembly { Migrations = migrations.ToDictionary(x => x, x => default(TypeInfo)) }; var repository = new FakeHistoryRepository { diff --git a/test/EFCore.Relational.Tests/RelationalEventIdTest.cs b/test/EFCore.Relational.Tests/RelationalEventIdTest.cs index 7eb752ed91d..851b18941c2 100644 --- a/test/EFCore.Relational.Tests/RelationalEventIdTest.cs +++ b/test/EFCore.Relational.Tests/RelationalEventIdTest.cs @@ -24,6 +24,7 @@ using Microsoft.EntityFrameworkCore.Update; using Microsoft.Extensions.DependencyInjection; using Xunit; +using IsolationLevel = System.Data.IsolationLevel; // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore @@ -43,13 +44,7 @@ public void Every_eventId_has_a_logger_method_and_logs_when_level_enabled() var fakeFactories = new Dictionary> { { typeof(string), () => "Fake" }, - { - typeof(IList), () => new List - { - "Fake1", - "Fake2" - } - }, + { typeof(IList), () => new List { "Fake1", "Fake2" } }, { typeof(IEnumerable), () => new List { @@ -85,25 +80,27 @@ public void Every_eventId_has_a_logger_method_and_logs_when_level_enabled() new Dictionary> { { - nameof(RelationalEventId.CommandExecuting), new List + nameof(RelationalEventId.CommandExecuting), + new List { nameof(RelationalLoggerExtensions.CommandReaderExecuting), nameof(RelationalLoggerExtensions.CommandScalarExecuting), nameof(RelationalLoggerExtensions.CommandNonQueryExecuting), nameof(RelationalLoggerExtensions.CommandReaderExecutingAsync), nameof(RelationalLoggerExtensions.CommandScalarExecutingAsync), - nameof(RelationalLoggerExtensions.CommandNonQueryExecutingAsync), + nameof(RelationalLoggerExtensions.CommandNonQueryExecutingAsync) } }, { - nameof(RelationalEventId.CommandExecuted), new List + nameof(RelationalEventId.CommandExecuted), + new List { nameof(RelationalLoggerExtensions.CommandReaderExecutedAsync), nameof(RelationalLoggerExtensions.CommandScalarExecutedAsync), nameof(RelationalLoggerExtensions.CommandNonQueryExecutedAsync), nameof(RelationalLoggerExtensions.CommandReaderExecuted), nameof(RelationalLoggerExtensions.CommandScalarExecuted), - nameof(RelationalLoggerExtensions.CommandNonQueryExecuted), + nameof(RelationalLoggerExtensions.CommandNonQueryExecuted) } } }); @@ -149,11 +146,11 @@ private class FakeRelationalConnection : IRelationalConnection public bool IsMultipleActiveResultSetsEnabled => throw new NotImplementedException(); public IDbContextTransaction CurrentTransaction => throw new NotImplementedException(); public SemaphoreSlim Semaphore => throw new NotImplementedException(); - public IDbContextTransaction BeginTransaction(System.Data.IsolationLevel isolationLevel) => throw new NotImplementedException(); + public IDbContextTransaction BeginTransaction(IsolationLevel isolationLevel) => throw new NotImplementedException(); public IDbContextTransaction BeginTransaction() => throw new NotImplementedException(); public Task BeginTransactionAsync( - System.Data.IsolationLevel isolationLevel, CancellationToken cancellationToken = default) => throw new NotImplementedException(); + IsolationLevel isolationLevel, CancellationToken cancellationToken = default) => throw new NotImplementedException(); public Task BeginTransactionAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException(); @@ -171,6 +168,7 @@ public Task OpenAsync(CancellationToken cancellationToken, bool errorsExpe public void RollbackTransaction() => throw new NotImplementedException(); public IDbContextTransaction UseTransaction(DbTransaction transaction) => throw new NotImplementedException(); + public Task UseTransactionAsync( DbTransaction transaction, CancellationToken cancellationToken = default) => throw new NotImplementedException(); @@ -187,7 +185,7 @@ private class FakeDbConnection : DbConnection public override void ChangeDatabase(string databaseName) => throw new NotImplementedException(); public override void Close() => throw new NotImplementedException(); public override void Open() => throw new NotImplementedException(); - protected override DbTransaction BeginDbTransaction(System.Data.IsolationLevel isolationLevel) => throw new NotImplementedException(); + protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) => throw new NotImplementedException(); protected override DbCommand CreateDbCommand() => throw new NotImplementedException(); } @@ -239,7 +237,7 @@ private class FakeDbParameterCollection : DbParameterCollection private class FakeDbTransaction : DbTransaction { - public override System.Data.IsolationLevel IsolationLevel => System.Data.IsolationLevel.Chaos; + public override IsolationLevel IsolationLevel => IsolationLevel.Chaos; protected override DbConnection DbConnection => throw new NotImplementedException(); public override void Commit() => throw new NotImplementedException(); public override void Rollback() => throw new NotImplementedException(); diff --git a/test/EFCore.Relational.Tests/Storage/NamedConnectionStringResolverTest.cs b/test/EFCore.Relational.Tests/Storage/NamedConnectionStringResolverTest.cs index ad158243d6e..e9094d3426f 100644 --- a/test/EFCore.Relational.Tests/Storage/NamedConnectionStringResolverTest.cs +++ b/test/EFCore.Relational.Tests/Storage/NamedConnectionStringResolverTest.cs @@ -77,10 +77,7 @@ public void Returns_given_string_named_connection_string_doesnt_match_pattern() new FakeOptions( new ConfigurationBuilder() .AddInMemoryCollection( - new Dictionary - { - { "Nope", "NoThanks" } - }) + new Dictionary { { "Nope", "NoThanks" } }) .Build())); Assert.Equal("name=Fox;DataSource=Jimony", resolver.ResolveConnectionString("name=Fox;DataSource=Jimony")); diff --git a/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs b/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs index aaaca7c05cb..82d004bb960 100644 --- a/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs +++ b/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs @@ -364,48 +364,42 @@ public static TheoryData CommandActions (connection, command, parameterValues, logger) => command.ExecuteNonQuery( new RelationalCommandParameterObject(connection, parameterValues, null, logger))), - DbCommandMethod.ExecuteNonQuery, - false + DbCommandMethod.ExecuteNonQuery, false }, { new CommandAction( (connection, command, parameterValues, logger) => command.ExecuteScalar( new RelationalCommandParameterObject(connection, parameterValues, null, logger))), - DbCommandMethod.ExecuteScalar, - false + DbCommandMethod.ExecuteScalar, false }, { new CommandAction( (connection, command, parameterValues, logger) => command.ExecuteReader( new RelationalCommandParameterObject(connection, parameterValues, null, logger))), - DbCommandMethod.ExecuteReader, - false + DbCommandMethod.ExecuteReader, false }, { new CommandFunc( (connection, command, parameterValues, logger) => command.ExecuteNonQueryAsync( new RelationalCommandParameterObject(connection, parameterValues, null, logger))), - DbCommandMethod.ExecuteNonQuery, - true + DbCommandMethod.ExecuteNonQuery, true }, { new CommandFunc( (connection, command, parameterValues, logger) => command.ExecuteScalarAsync( new RelationalCommandParameterObject(connection, parameterValues, null, logger))), - DbCommandMethod.ExecuteScalar, - true + DbCommandMethod.ExecuteScalar, true }, { new CommandFunc( (connection, command, parameterValues, logger) => command.ExecuteReaderAsync( new RelationalCommandParameterObject(connection, parameterValues, null, logger))), - DbCommandMethod.ExecuteReader, - true + DbCommandMethod.ExecuteReader, true } }; @@ -464,11 +458,7 @@ public async Task Throws_when_parameters_are_configured_and_value_is_missing( new TypeMappedRelationalParameter("ThirdInvariant", "ThirdParameter", RelationalTypeMapping.NullMapping, null) }); - var parameterValues = new Dictionary - { - { "FirstInvariant", 17 }, - { "SecondInvariant", 18L } - }; + var parameterValues = new Dictionary { { "FirstInvariant", 17 }, { "SecondInvariant", 18L } }; if (async) { @@ -509,9 +499,7 @@ public async Task Configures_DbCommand_with_type_mapped_parameters( var parameterValues = new Dictionary { - { "FirstInvariant", 17 }, - { "SecondInvariant", 18L }, - { "ThirdInvariant", null } + { "FirstInvariant", 17 }, { "SecondInvariant", 18L }, { "ThirdInvariant", null } }; if (async) @@ -565,12 +553,7 @@ public async Task Configures_DbCommand_with_dynamic_parameters( TestServiceFactory.Instance.Create(), TestServiceFactory.Instance.Create()); - var dbParameter = new FakeDbParameter - { - ParameterName = "FirstParameter", - Value = 17, - DbType = DbType.Int32 - }; + var dbParameter = new FakeDbParameter { ParameterName = "FirstParameter", Value = 17, DbType = DbType.Int32 }; var relationalCommand = CreateRelationalCommand( parameters: new[] @@ -582,9 +565,7 @@ public async Task Configures_DbCommand_with_dynamic_parameters( var parameterValues = new Dictionary { - { "FirstInvariant", dbParameter }, - { "SecondInvariant", 18L }, - { "ThirdInvariant", null } + { "FirstInvariant", dbParameter }, { "SecondInvariant", 18L }, { "ThirdInvariant", null } }; if (async) @@ -646,10 +627,7 @@ public async Task Configures_DbCommand_with_composite_parameters( }) }); - var parameterValues = new Dictionary - { - { "CompositeInvariant", new object[] { 17, 18L, null } } - }; + var parameterValues = new Dictionary { { "CompositeInvariant", new object[] { 17, 18L, null } } }; if (async) { @@ -713,10 +691,7 @@ public async Task Throws_when_composite_parameters_are_configured_and_value_is_m }) }); - var parameterValues = new Dictionary - { - { "CompositeInvariant", new object[] { 17, 18L } } - }; + var parameterValues = new Dictionary { { "CompositeInvariant", new object[] { 17, 18L } } }; if (async) { @@ -758,10 +733,7 @@ public async Task Throws_when_composite_parameters_are_configured_and_value_is_n }) }); - var parameterValues = new Dictionary - { - { "CompositeInvariant", 17 } - }; + var parameterValues = new Dictionary { { "CompositeInvariant", 17 } }; if (async) { @@ -942,13 +914,11 @@ public async Task Logs_commands_without_parameter_values( commandText: "Logged Command", parameters: new[] { - new TypeMappedRelationalParameter("FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false) + new TypeMappedRelationalParameter( + "FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false) }); - var parameterValues = new Dictionary - { - { "FirstInvariant", 17 } - }; + var parameterValues = new Dictionary { { "FirstInvariant", 17 } }; if (async) { @@ -1000,13 +970,11 @@ public async Task Logs_commands_parameter_values( commandText: "Logged Command", parameters: new[] { - new TypeMappedRelationalParameter("FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false) + new TypeMappedRelationalParameter( + "FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false) }); - var parameterValues = new Dictionary - { - { "FirstInvariant", 17 } - }; + var parameterValues = new Dictionary { { "FirstInvariant", 17 } }; if (async) { @@ -1021,7 +989,9 @@ public async Task Logs_commands_parameter_values( Assert.Equal(LogLevel.Debug, logFactory.Log[0].Level); Assert.Equal(LogLevel.Debug, logFactory.Log[1].Level); Assert.Equal(LogLevel.Warning, logFactory.Log[2].Level); - Assert.Equal(CoreResources.LogSensitiveDataLoggingEnabled(new TestLogger()).GenerateMessage(), logFactory.Log[2].Message); + Assert.Equal( + CoreResources.LogSensitiveDataLoggingEnabled(new TestLogger()).GenerateMessage(), + logFactory.Log[2].Message); Assert.Equal(LogLevel.Information, logFactory.Log[3].Level); Assert.Equal(LogLevel.Debug, logFactory.Log[4].Level); @@ -1057,13 +1027,11 @@ public async Task Reports_command_diagnostic( var relationalCommand = CreateRelationalCommand( parameters: new[] { - new TypeMappedRelationalParameter("FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false) + new TypeMappedRelationalParameter( + "FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false) }); - var parameterValues = new Dictionary - { - { "FirstInvariant", 17 } - }; + var parameterValues = new Dictionary { { "FirstInvariant", 17 } }; if (async) { @@ -1129,13 +1097,11 @@ public async Task Reports_command_diagnostic_on_exception( var relationalCommand = CreateRelationalCommand( parameters: new[] { - new TypeMappedRelationalParameter("FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false) + new TypeMappedRelationalParameter( + "FirstInvariant", "FirstParameter", new IntTypeMapping("int", DbType.Int32), false) }); - var parameterValues = new Dictionary - { - { "FirstInvariant", 17 } - }; + var parameterValues = new Dictionary { { "FirstInvariant", 17 } }; if (async) { diff --git a/test/EFCore.Relational.Tests/Storage/RelationalDatabaseFacadeExtensionsTest.cs b/test/EFCore.Relational.Tests/Storage/RelationalDatabaseFacadeExtensionsTest.cs index a4691760d6a..5c71467d2e4 100644 --- a/test/EFCore.Relational.Tests/Storage/RelationalDatabaseFacadeExtensionsTest.cs +++ b/test/EFCore.Relational.Tests/Storage/RelationalDatabaseFacadeExtensionsTest.cs @@ -75,11 +75,7 @@ public async Task Can_pass_array_of_int_params_as_object(bool async, bool cancel Assert.Equal("", commandBuilder.Sql); Assert.Equal( - new List - { - 1, - 2 - }, commandBuilder.Parameters); + new List { 1, 2 }, commandBuilder.Parameters); } } @@ -103,11 +99,7 @@ public async Task Can_pass_ints_as_params(bool async) Assert.Equal("", commandBuilder.Sql); Assert.Equal( - new List - { - 1, - 2 - }, commandBuilder.Parameters); + new List { 1, 2 }, commandBuilder.Parameters); } } @@ -140,11 +132,7 @@ public async Task Can_pass_mixed_array_of_params(bool async, bool cancellation) Assert.Equal("", commandBuilder.Sql); Assert.Equal( - new List - { - 1, - "Cheese" - }, commandBuilder.Parameters); + new List { 1, "Cheese" }, commandBuilder.Parameters); } } @@ -164,39 +152,23 @@ public async Task Can_pass_list_of_int_params_as_object(bool async, bool cancell { var cancellationToken = new CancellationToken(); await context.Database.ExecuteSqlRawAsync( - "", new List - { - 1, - 2 - }, cancellationToken); + "", new List { 1, 2 }, cancellationToken); } else { await context.Database.ExecuteSqlRawAsync( - "", new List - { - 1, - 2 - }); + "", new List { 1, 2 }); } } else { context.Database.ExecuteSqlRaw( - "", new List - { - 1, - 2 - }); + "", new List { 1, 2 }); } Assert.Equal("", commandBuilder.Sql); Assert.Equal( - new List - { - 1, - 2 - }, commandBuilder.Parameters); + new List { 1, 2 }, commandBuilder.Parameters); } } @@ -216,39 +188,23 @@ public async Task Can_pass_mixed_list_of_params(bool async, bool cancellation) { var cancellationToken = new CancellationToken(); await context.Database.ExecuteSqlRawAsync( - "", new List - { - 1, - "Pickle" - }, cancellationToken); + "", new List { 1, "Pickle" }, cancellationToken); } else { await context.Database.ExecuteSqlRawAsync( - "", new List - { - 1, - "Pickle" - }); + "", new List { 1, "Pickle" }); } } else { context.Database.ExecuteSqlRaw( - "", new List - { - 1, - "Pickle" - }); + "", new List { 1, "Pickle" }); } Assert.Equal("", commandBuilder.Sql); Assert.Equal( - new List - { - 1, - "Pickle" - }, commandBuilder.Parameters); + new List { 1, "Pickle" }, commandBuilder.Parameters); } } @@ -281,10 +237,7 @@ public async Task Can_pass_single_int_as_object(bool async, bool cancellation) Assert.Equal("", commandBuilder.Sql); Assert.Equal( - new List - { - 1 - }, commandBuilder.Parameters); + new List { 1 }, commandBuilder.Parameters); } } @@ -317,10 +270,7 @@ public async Task Can_pass_single_string(bool async, bool cancellation) Assert.Equal("", commandBuilder.Sql); Assert.Equal( - new List - { - "Branston" - }, commandBuilder.Parameters); + new List { "Branston" }, commandBuilder.Parameters); } } diff --git a/test/EFCore.Relational.Tests/Storage/RelationalParameterBuilderTest.cs b/test/EFCore.Relational.Tests/Storage/RelationalParameterBuilderTest.cs index 06183676e8c..744fce671bd 100644 --- a/test/EFCore.Relational.Tests/Storage/RelationalParameterBuilderTest.cs +++ b/test/EFCore.Relational.Tests/Storage/RelationalParameterBuilderTest.cs @@ -77,7 +77,7 @@ public void Can_add_type_mapped_parameter_by_property(bool nullable) TestServiceFactory.Instance.Create(), TestServiceFactory.Instance.Create()); - var property = ((IMutableModel) new Model()).AddEntityType("MyType").AddProperty("MyProp", typeof(string)); + var property = ((IMutableModel)new Model()).AddEntityType("MyType").AddProperty("MyProp", typeof(string)); property.IsNullable = nullable; property[CoreAnnotationNames.TypeMapping] = GetMapping(typeMapper, property); diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalOptionsExtension.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalOptionsExtension.cs index efa85c17d43..c58bcbb76a1 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalOptionsExtension.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalOptionsExtension.cs @@ -65,6 +65,5 @@ public override void PopulateDebugInfo(IDictionary debugInfo) { } } - } } diff --git a/test/EFCore.Relational.Tests/TestUtilities/TestRelationalMigrationSqlGenerator.cs b/test/EFCore.Relational.Tests/TestUtilities/TestRelationalMigrationSqlGenerator.cs index 4e10366ee5a..9ed2518d655 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/TestRelationalMigrationSqlGenerator.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/TestRelationalMigrationSqlGenerator.cs @@ -18,7 +18,8 @@ protected override void Generate(RenameTableOperation operation, IModel model, M { } - protected override void Generate(DropIndexOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true) + protected override void Generate( + DropIndexOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true) { } diff --git a/test/EFCore.Relational.Tests/Update/BatchExecutorTest.cs b/test/EFCore.Relational.Tests/Update/BatchExecutorTest.cs index 5ae83cbab36..90ef8be1349 100644 --- a/test/EFCore.Relational.Tests/Update/BatchExecutorTest.cs +++ b/test/EFCore.Relational.Tests/Update/BatchExecutorTest.cs @@ -27,10 +27,7 @@ public async Task ExecuteAsync_calls_Commit_if_no_transaction(bool async) var connection = SetupConnection(context); context.Add( - new Foo - { - Id = "1" - }); + new Foo { Id = "1" }); if (async) { @@ -57,10 +54,7 @@ public async Task ExecuteAsync_does_not_call_Commit_if_existing_transaction(bool context.Database.UseTransaction(transaction); context.Add( - new Foo - { - Id = "1" - }); + new Foo { Id = "1" }); if (async) { @@ -79,10 +73,7 @@ public async Task ExecuteAsync_does_not_call_Commit_if_existing_transaction(bool private static FakeDbConnection SetupConnection(TestContext context) { var dataReader = new FakeDbDataReader( - new[] { "RowsAffected" }, new List - { - new object[] { 1 } - }); + new[] { "RowsAffected" }, new List { new object[] { 1 } }); var connection = new FakeDbConnection( "A=B", new FakeCommandExecutor( diff --git a/test/EFCore.Relational.Tests/Update/CommandBatchPreparerTest.cs b/test/EFCore.Relational.Tests/Update/CommandBatchPreparerTest.cs index 68d8a2554bd..920dae958ff 100644 --- a/test/EFCore.Relational.Tests/Update/CommandBatchPreparerTest.cs +++ b/test/EFCore.Relational.Tests/Update/CommandBatchPreparerTest.cs @@ -27,11 +27,7 @@ public void BatchCommands_creates_valid_batch_for_added_entities() var stateManager = CreateContextServices(CreateSimpleFKModel()).GetRequiredService(); var entry = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 42, - Value = "Test" - }); + new FakeEntity { Id = 42, Value = "Test" }); entry.SetEntityState(EntityState.Added); @@ -72,11 +68,7 @@ public void BatchCommands_creates_valid_batch_for_modified_entities() var stateManager = CreateContextServices(CreateSimpleFKModel()).GetRequiredService(); var entry = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 42, - Value = "Test" - }); + new FakeEntity { Id = 42, Value = "Test" }); entry.SetEntityState(EntityState.Modified); @@ -117,11 +109,7 @@ public void BatchCommands_creates_valid_batch_for_deleted_entities() var stateManager = CreateContextServices(CreateSimpleFKModel()).GetRequiredService(); var entry = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 42, - Value = "Test" - }); + new FakeEntity { Id = 42, Value = "Test" }); entry.SetEntityState(EntityState.Deleted); @@ -153,20 +141,13 @@ public void BatchCommands_sorts_related_added_entities() var stateManager = configuration.GetRequiredService(); var entry = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 42, - Value = "Test" - }); + new FakeEntity { Id = 42, Value = "Test" }); entry.SetEntityState(EntityState.Added); var modelData = new UpdateAdapter(stateManager); var relatedEntry = stateManager.GetOrCreateEntry( - new RelatedFakeEntity - { - Id = 42 - }); + new RelatedFakeEntity { Id = 42 }); relatedEntry.SetEntityState(EntityState.Added); var commandBatches = CreateCommandBatchPreparer().BatchCommands(new[] { relatedEntry, entry }, modelData).ToArray(); @@ -183,20 +164,13 @@ public void BatchCommands_sorts_added_and_related_modified_entities() var stateManager = configuration.GetRequiredService(); var entry = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 42, - Value = "Test" - }); + new FakeEntity { Id = 42, Value = "Test" }); entry.SetEntityState(EntityState.Added); var modelData = new UpdateAdapter(stateManager); var relatedEntry = stateManager.GetOrCreateEntry( - new RelatedFakeEntity - { - Id = 42 - }); + new RelatedFakeEntity { Id = 42 }); relatedEntry.SetEntityState(EntityState.Modified); var commandBatches = CreateCommandBatchPreparer().BatchCommands(new[] { relatedEntry, entry }, modelData).ToArray(); @@ -213,18 +187,11 @@ public void BatchCommands_sorts_unrelated_entities() var stateManager = configuration.GetRequiredService(); var firstEntry = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 42, - Value = "Test" - }); + new FakeEntity { Id = 42, Value = "Test" }); firstEntry.SetEntityState(EntityState.Added); var secondEntry = stateManager.GetOrCreateEntry( - new RelatedFakeEntity - { - Id = 1 - }); + new RelatedFakeEntity { Id = 1 }); secondEntry.SetEntityState(EntityState.Added); var modelData = new UpdateAdapter(stateManager); @@ -243,33 +210,22 @@ public void BatchCommands_sorts_entities_when_reparenting() var stateManager = configuration.GetRequiredService(); var previousParent = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 42, - Value = "Test" - }); + new FakeEntity { Id = 42, Value = "Test" }); previousParent.SetEntityState(EntityState.Deleted); var newParent = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 3, - Value = "Test" - }); + new FakeEntity { Id = 3, Value = "Test" }); newParent.SetEntityState(EntityState.Added); var relatedEntry = stateManager.GetOrCreateEntry( - new RelatedFakeEntity - { - Id = 1, - RelatedId = 3 - }); + new RelatedFakeEntity { Id = 1, RelatedId = 3 }); relatedEntry.SetEntityState(EntityState.Modified); relatedEntry.SetOriginalValue(relatedEntry.EntityType.FindProperty("RelatedId"), 42); var modelData = new UpdateAdapter(stateManager); - var commandBatches = CreateCommandBatchPreparer().BatchCommands(new[] { relatedEntry, previousParent, newParent }, modelData).ToArray(); + var commandBatches = CreateCommandBatchPreparer().BatchCommands(new[] { relatedEntry, previousParent, newParent }, modelData) + .ToArray(); Assert.Equal( new[] { newParent, relatedEntry, previousParent }, @@ -283,27 +239,15 @@ public void BatchCommands_sorts_when_reassigning_child() var stateManager = configuration.GetRequiredService(); var parentEntity = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 1, - Value = "Test" - }); + new FakeEntity { Id = 1, Value = "Test" }); parentEntity.SetEntityState(EntityState.Unchanged); var previousChild = stateManager.GetOrCreateEntry( - new RelatedFakeEntity - { - Id = 42, - RelatedId = 1 - }); + new RelatedFakeEntity { Id = 42, RelatedId = 1 }); previousChild.SetEntityState(EntityState.Deleted); var newChild = stateManager.GetOrCreateEntry( - new RelatedFakeEntity - { - Id = 23, - RelatedId = 1 - }); + new RelatedFakeEntity { Id = 23, RelatedId = 1 }); newChild.SetEntityState(EntityState.Added); var modelData = new UpdateAdapter(stateManager); @@ -322,43 +266,23 @@ public void BatchCommands_sorts_entities_while_reassigning_child_tree() var stateManager = configuration.GetRequiredService(); var parentEntity = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 1, - Value = "Test" - }); + new FakeEntity { Id = 1, Value = "Test" }); parentEntity.SetEntityState(EntityState.Unchanged); var oldEntity = stateManager.GetOrCreateEntry( - new RelatedFakeEntity - { - Id = 2, - RelatedId = 1 - }); + new RelatedFakeEntity { Id = 2, RelatedId = 1 }); oldEntity.SetEntityState(EntityState.Deleted); var oldChildEntity = stateManager.GetOrCreateEntry( - new AnotherFakeEntity - { - Id = 3, - AnotherId = 2 - }); + new AnotherFakeEntity { Id = 3, AnotherId = 2 }); oldChildEntity.SetEntityState(EntityState.Deleted); var newEntity = stateManager.GetOrCreateEntry( - new RelatedFakeEntity - { - Id = 4, - RelatedId = 1 - }); + new RelatedFakeEntity { Id = 4, RelatedId = 1 }); newEntity.SetEntityState(EntityState.Added); var newChildEntity = stateManager.GetOrCreateEntry( - new AnotherFakeEntity - { - Id = 5, - AnotherId = 4 - }); + new AnotherFakeEntity { Id = 5, AnotherId = 4 }); newChildEntity.SetEntityState(EntityState.Added); var modelData = new UpdateAdapter(stateManager); @@ -381,19 +305,12 @@ public void BatchCommands_creates_batches_lazily() var stateManager = configuration.GetRequiredService(); - var fakeEntity = new FakeEntity - { - Id = 42, - Value = "Test" - }; + var fakeEntity = new FakeEntity { Id = 42, Value = "Test" }; var entry = stateManager.GetOrCreateEntry(fakeEntity); entry.SetEntityState(EntityState.Added); var relatedEntry = stateManager.GetOrCreateEntry( - new RelatedFakeEntity - { - Id = 42 - }); + new RelatedFakeEntity { Id = 42 }); relatedEntry.SetEntityState(EntityState.Added); var factory = (TestModificationCommandBatchFactory)configuration.GetService(); @@ -422,28 +339,15 @@ public void Batch_command_does_not_order_non_unique_index_values() var stateManager = configuration.GetRequiredService(); var fakeEntry = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 42, - Value = "Test" - }); + new FakeEntity { Id = 42, Value = "Test" }); fakeEntry.SetEntityState(EntityState.Added); var relatedFakeEntry = stateManager.GetOrCreateEntry( - new RelatedFakeEntity - { - Id = 1, - RelatedId = 42 - }); + new RelatedFakeEntity { Id = 1, RelatedId = 42 }); relatedFakeEntry.SetEntityState(EntityState.Added); var fakeEntry2 = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 2, - RelatedId = 1, - Value = "Test2" - }); + new FakeEntity { Id = 2, RelatedId = 1, Value = "Test2" }); fakeEntry2.SetEntityState(EntityState.Modified); fakeEntry2.SetOriginalValue(fakeEntry2.EntityType.FindProperty(nameof(FakeEntity.Value)), "Test"); @@ -465,11 +369,7 @@ public void BatchCommands_throws_on_non_store_generated_temporary_values() var stateManager = configuration.GetRequiredService(); var entry = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 1, - Value = "Test" - }); + new FakeEntity { Id = 1, Value = "Test" }); entry.SetEntityState(EntityState.Added); Assert.Equal( @@ -488,19 +388,11 @@ public void Batch_command_throws_on_commands_with_circular_dependencies(bool sen var stateManager = configuration.GetRequiredService(); var fakeEntry = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 42, - RelatedId = 1 - }); + new FakeEntity { Id = 42, RelatedId = 1 }); fakeEntry.SetEntityState(EntityState.Added); var relatedFakeEntry = stateManager.GetOrCreateEntry( - new RelatedFakeEntity - { - Id = 1, - RelatedId = 42 - }); + new RelatedFakeEntity { Id = 1, RelatedId = 42 }); relatedFakeEntry.SetEntityState(EntityState.Added); var modelData = new UpdateAdapter(stateManager); @@ -526,28 +418,15 @@ public void Batch_command_throws_on_commands_with_circular_dependencies_includin var stateManager = configuration.GetRequiredService(); var fakeEntry = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 42, - UniqueValue = "Test" - }); + new FakeEntity { Id = 42, UniqueValue = "Test" }); fakeEntry.SetEntityState(EntityState.Added); var relatedFakeEntry = stateManager.GetOrCreateEntry( - new RelatedFakeEntity - { - Id = 1, - RelatedId = 42 - }); + new RelatedFakeEntity { Id = 1, RelatedId = 42 }); relatedFakeEntry.SetEntityState(EntityState.Added); var fakeEntry2 = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 2, - RelatedId = 1, - UniqueValue = "Test2" - }); + new FakeEntity { Id = 2, RelatedId = 1, UniqueValue = "Test2" }); fakeEntry2.SetEntityState(EntityState.Modified); fakeEntry2.SetOriginalValue(fakeEntry2.EntityType.FindProperty(nameof(FakeEntity.UniqueValue)), "Test"); @@ -574,27 +453,15 @@ public void Batch_command_throws_on_delete_commands_with_circular_dependencies(b var stateManager = configuration.GetRequiredService(); var fakeEntry = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 1, - RelatedId = 2 - }); + new FakeEntity { Id = 1, RelatedId = 2 }); fakeEntry.SetEntityState(EntityState.Deleted); var relatedFakeEntry = stateManager.GetOrCreateEntry( - new RelatedFakeEntity - { - Id = 2, - RelatedId = 1 - }); + new RelatedFakeEntity { Id = 2, RelatedId = 1 }); relatedFakeEntry.SetEntityState(EntityState.Deleted); var anotherFakeEntry = stateManager.GetOrCreateEntry( - new AnotherFakeEntity - { - Id = 3, - AnotherId = 2 - }); + new AnotherFakeEntity { Id = 3, AnotherId = 2 }); anotherFakeEntry.SetEntityState(EntityState.Deleted); var modelData = new UpdateAdapter(stateManager); @@ -619,19 +486,11 @@ public void BatchCommands_works_with_duplicate_values_for_unique_indexes() var stateManager = configuration.GetRequiredService(); var fakeEntry = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 1, - UniqueValue = "Test" - }); + new FakeEntity { Id = 1, UniqueValue = "Test" }); fakeEntry.SetEntityState(EntityState.Deleted); var fakeEntry2 = stateManager.GetOrCreateEntry( - new FakeEntity - { - Id = 2, - UniqueValue = "Test2" - }); + new FakeEntity { Id = 2, UniqueValue = "Test2" }); fakeEntry2.SetEntityState(EntityState.Modified); fakeEntry2.SetOriginalValue(fakeEntry.EntityType.FindProperty(nameof(FakeEntity.UniqueValue)), "Test"); @@ -649,17 +508,10 @@ public void BatchCommands_creates_valid_batch_for_shared_table_added_entities() var currentDbContext = CreateContextServices(CreateSharedTableModel()).GetRequiredService(); var stateManager = currentDbContext.GetDependencies().StateManager; - var first = new FakeEntity - { - Id = 42, - Value = "Test" - }; + var first = new FakeEntity { Id = 42, Value = "Test" }; var firstEntry = stateManager.GetOrCreateEntry(first); firstEntry.SetEntityState(EntityState.Added); - var second = new RelatedFakeEntity - { - Id = 42 - }; + var second = new RelatedFakeEntity { Id = 42 }; var secondEntry = stateManager.GetOrCreateEntry(second); secondEntry.SetEntityState(EntityState.Added); @@ -712,11 +564,7 @@ public void BatchCommands_creates_valid_batch_for_shared_table_modified_entities var currentDbContext = CreateContextServices(CreateSharedTableModel()).GetRequiredService(); var stateManager = currentDbContext.GetDependencies().StateManager; - var entity = new FakeEntity - { - Id = 42, - Value = "Null" - }; + var entity = new FakeEntity { Id = 42, Value = "Null" }; var entry = stateManager.GetOrCreateEntry(entity); entry.SetEntityState(EntityState.Modified); @@ -771,17 +619,10 @@ public void BatchCommands_creates_valid_batch_for_shared_table_deleted_entities( var currentDbContext = CreateContextServices(CreateSharedTableModel()).GetRequiredService(); var stateManager = currentDbContext.GetDependencies().StateManager; - var first = new FakeEntity - { - Id = 42, - Value = "Test" - }; + var first = new FakeEntity { Id = 42, Value = "Test" }; var firstEntry = stateManager.GetOrCreateEntry(first); firstEntry.SetEntityState(EntityState.Deleted); - var second = new RelatedFakeEntity - { - Id = 42 - }; + var second = new RelatedFakeEntity { Id = 42 }; var secondEntry = stateManager.GetOrCreateEntry(second); secondEntry.SetEntityState(EntityState.Deleted); @@ -826,17 +667,10 @@ public void BatchCommands_throws_on_conflicting_updates_for_shared_table_added_e var currentDbContext = CreateContextServices(CreateSharedTableModel()).GetRequiredService(); var stateManager = currentDbContext.GetDependencies().StateManager; - var first = new FakeEntity - { - Id = 42, - Value = "Test" - }; + var first = new FakeEntity { Id = 42, Value = "Test" }; var firstEntry = stateManager.GetOrCreateEntry(first); firstEntry.SetEntityState(EntityState.Added); - var second = new RelatedFakeEntity - { - Id = 42 - }; + var second = new RelatedFakeEntity { Id = 42 }; var secondEntry = stateManager.GetOrCreateEntry(second); secondEntry.SetEntityState(EntityState.Deleted); @@ -874,17 +708,10 @@ public void BatchCommands_throws_on_conflicting_values_for_shared_table_added_en var currentDbContext = CreateContextServices(CreateSharedTableModel()).GetRequiredService(); var stateManager = currentDbContext.GetDependencies().StateManager; - var first = new FakeEntity - { - Id = 42, - Value = "Test" - }; + var first = new FakeEntity { Id = 42, Value = "Test" }; var firstEntry = stateManager.GetOrCreateEntry(first); firstEntry.SetEntityState(EntityState.Modified); - var second = new RelatedFakeEntity - { - Id = 42 - }; + var second = new RelatedFakeEntity { Id = 42 }; var secondEntry = stateManager.GetOrCreateEntry(second); secondEntry.SetEntityState(EntityState.Modified); @@ -907,8 +734,8 @@ public void BatchCommands_throws_on_conflicting_values_for_shared_table_added_en { Assert.Equal( RelationalStrings.ConflictingRowValuesSensitive( - nameof(FakeEntity), nameof(RelatedFakeEntity), - "{Id: 42}", "{RelatedId: 1}", "{RelatedId: 2}", "{'RelatedId'}"), + nameof(FakeEntity), nameof(RelatedFakeEntity), + "{Id: 42}", "{RelatedId: 1}", "{RelatedId: 2}", "{'RelatedId'}"), Assert.Throws( () => CreateCommandBatchPreparer(updateAdapter: modelData, sensitiveLogging: true) .BatchCommands(new[] { firstEntry, secondEntry }, modelData).ToArray()).Message); @@ -940,7 +767,7 @@ public void BatchCommands_throws_on_conflicting_values_for_shared_table_added_en { Assert.Equal( RelationalStrings.ConflictingOriginalRowValues( - nameof(FakeEntity), nameof(RelatedFakeEntity), + nameof(FakeEntity), nameof(RelatedFakeEntity), "{'RelatedId'}", "{'RelatedId'}", "{'RelatedId'}"), Assert.Throws( () => CreateCommandBatchPreparer(updateAdapter: modelData, sensitiveLogging: false) @@ -959,17 +786,11 @@ public void BatchCommands_throws_on_incomplete_updates_for_shared_table_no_princ var currentDbContext = CreateContextServices(CreateSharedTableModel()).GetRequiredService(); var stateManager = currentDbContext.GetDependencies().StateManager; - var first = new DerivedRelatedFakeEntity - { - Id = 42 - }; + var first = new DerivedRelatedFakeEntity { Id = 42 }; var firstEntry = stateManager.GetOrCreateEntry(first); firstEntry.SetEntityState(state); - var second = new AnotherFakeEntity - { - Id = 42 - }; + var second = new AnotherFakeEntity { Id = 42 }; var secondEntry = stateManager.GetOrCreateEntry(second); secondEntry.SetEntityState(state); @@ -1003,24 +824,18 @@ public void BatchCommands_works_with_incomplete_updates_for_shared_table_no_leaf var currentDbContext = CreateContextServices(CreateSharedTableModel()).GetRequiredService(); var stateManager = currentDbContext.GetDependencies().StateManager; - var first = new FakeEntity - { - Id = 42 - }; + var first = new FakeEntity { Id = 42 }; var firstEntry = stateManager.GetOrCreateEntry(first); firstEntry.SetEntityState(state); - var second = new DerivedRelatedFakeEntity - { - Id = 42 - }; + var second = new DerivedRelatedFakeEntity { Id = 42 }; var secondEntry = stateManager.GetOrCreateEntry(second); secondEntry.SetEntityState(state); var modelData = new UpdateAdapter(stateManager); var batches = CreateCommandBatchPreparer(updateAdapter: modelData, sensitiveLogging: false) - .BatchCommands(new[] { firstEntry, secondEntry }, modelData).ToArray(); + .BatchCommands(new[] { firstEntry, secondEntry }, modelData).ToArray(); Assert.Equal(1, batches.Length); } @@ -1036,17 +851,11 @@ public void BatchCommands_throws_on_incomplete_updates_for_shared_table_no_middl var currentDbContext = CreateContextServices(CreateSharedTableModel()).GetRequiredService(); var stateManager = currentDbContext.GetDependencies().StateManager; - var first = new FakeEntity - { - Id = 42 - }; + var first = new FakeEntity { Id = 42 }; var firstEntry = stateManager.GetOrCreateEntry(first); firstEntry.SetEntityState(state); - var second = new AnotherFakeEntity - { - Id = 42 - }; + var second = new AnotherFakeEntity { Id = 42 }; var secondEntry = stateManager.GetOrCreateEntry(second); secondEntry.SetEntityState(state); diff --git a/test/EFCore.Relational.Tests/Update/ModificationCommandTest.cs b/test/EFCore.Relational.Tests/Update/ModificationCommandTest.cs index 3115beb6351..038aa6770c8 100644 --- a/test/EFCore.Relational.Tests/Update/ModificationCommandTest.cs +++ b/test/EFCore.Relational.Tests/Update/ModificationCommandTest.cs @@ -474,12 +474,7 @@ private static InternalEntityEntry CreateEntry( model, entityState, new - T1 - { - Id = 1, - Name1 = computeNonKeyValue ? null : "Test", - Name2 = computeNonKeyValue ? null : "Test" - }); + T1 { Id = 1, Name1 = computeNonKeyValue ? null : "Test", Name2 = computeNonKeyValue ? null : "Test" }); } } } diff --git a/test/EFCore.Relational.Tests/Update/ReaderModificationCommandBatchTest.cs b/test/EFCore.Relational.Tests/Update/ReaderModificationCommandBatchTest.cs index 17ccf714173..7c5a07b241c 100644 --- a/test/EFCore.Relational.Tests/Update/ReaderModificationCommandBatchTest.cs +++ b/test/EFCore.Relational.Tests/Update/ReaderModificationCommandBatchTest.cs @@ -181,10 +181,7 @@ public async Task ExecuteAsync_saves_store_generated_values() var connection = CreateConnection( CreateFakeDataReader( - new[] { "Col1" }, new List - { - new object[] { 42 } - })); + new[] { "Col1" }, new List { new object[] { 42 } })); var batch = new ModificationCommandBatchFake(); batch.AddCommand(command); @@ -207,10 +204,7 @@ public async Task ExecuteAsync_saves_store_generated_values_on_non_key_columns() var connection = CreateConnection( CreateFakeDataReader( - new[] { "Col1", "Col2" }, new List - { - new object[] { 42, "FortyTwo" } - })); + new[] { "Col1", "Col2" }, new List { new object[] { 42, "FortyTwo" } })); var batch = new ModificationCommandBatchFake(); batch.AddCommand(command); @@ -232,10 +226,7 @@ public async Task ExecuteAsync_saves_store_generated_values_when_updating() var connection = CreateConnection( CreateFakeDataReader( - new[] { "Col2" }, new List - { - new object[] { "FortyTwo" } - })); + new[] { "Col2" }, new List { new object[] { "FortyTwo" } })); var batch = new ModificationCommandBatchFake(); batch.AddCommand(command); @@ -258,11 +249,7 @@ public async Task Exception_not_thrown_for_more_than_one_row_returned_for_single var connection = CreateConnection( CreateFakeDataReader( new[] { "Col1" }, - new List - { - new object[] { 42 }, - new object[] { 43 } - })); + new List { new object[] { 42 }, new object[] { 43 } })); var batch = new ModificationCommandBatchFake(); batch.AddCommand(command); @@ -282,10 +269,7 @@ public async Task Exception_thrown_if_rows_returned_for_command_without_store_ge var connection = CreateConnection( CreateFakeDataReader( - new[] { "Col1" }, new List - { - new object[] { 42 } - })); + new[] { "Col1" }, new List { new object[] { 42 } })); var batch = new ModificationCommandBatchFake(); batch.AddCommand(command); @@ -538,19 +522,12 @@ private static InternalEntityEntry CreateEntry( var model = BuildModel(generateKeyValues, computeNonKeyValue); return RelationalTestHelpers.Instance.CreateInternalEntry( - model, entityState, new T1 - { - Id = 1, - Name = computeNonKeyValue ? null : "Test" - }); + model, entityState, new T1 { Id = 1, Name = computeNonKeyValue ? null : "Test" }); } private static FakeDbDataReader CreateFakeDataReader(string[] columnNames = null, IList results = null) { - results ??= new List - { - new object[] { 1 } - }; + results ??= new List { new object[] { 1 } }; columnNames ??= new[] { "RowsAffected" }; return new FakeDbDataReader(columnNames, results); diff --git a/test/EFCore.Relational.Tests/Update/UpdateSqlGeneratorTestBase.cs b/test/EFCore.Relational.Tests/Update/UpdateSqlGeneratorTestBase.cs index 4d23624e936..733755c96a1 100644 --- a/test/EFCore.Relational.Tests/Update/UpdateSqlGeneratorTestBase.cs +++ b/test/EFCore.Relational.Tests/Update/UpdateSqlGeneratorTestBase.cs @@ -35,7 +35,7 @@ public virtual void AppendDeleteOperation_creates_full_delete_command_text() public virtual void AppendDeleteOperation_creates_full_delete_command_text_with_concurrency_check() { var stringBuilder = new StringBuilder(); - var command = CreateDeleteCommand(concurrencyToken: true); + var command = CreateDeleteCommand(); CreateSqlGenerator().AppendDeleteOperation(stringBuilder, command, 0); @@ -51,7 +51,7 @@ public virtual void AppendDeleteOperation_creates_full_delete_command_text_with_ public virtual void AppendInsertOperation_appends_insert_and_select_and_where_if_store_generated_columns_exist() { var stringBuilder = new StringBuilder(); - var command = CreateInsertCommand(identityKey: true, isComputed: true); + var command = CreateInsertCommand(); CreateSqlGenerator().AppendInsertOperation(stringBuilder, command, 0); @@ -95,7 +95,7 @@ public virtual void public virtual void AppendInsertOperation_appends_insert_and_select_store_generated_columns_but_no_identity() { var stringBuilder = new StringBuilder(); - var command = CreateInsertCommand(false, isComputed: true); + var command = CreateInsertCommand(false); CreateSqlGenerator().AppendInsertOperation(stringBuilder, command, 0); @@ -196,7 +196,7 @@ protected virtual void AppendInsertOperation_appends_insert_and_select_for_only_ public virtual void AppendUpdateOperation_appends_update_and_select_if_store_generated_columns_exist() { var stringBuilder = new StringBuilder(); - var command = CreateUpdateCommand(isComputed: true, concurrencyToken: true); + var command = CreateUpdateCommand(); CreateSqlGenerator().AppendUpdateOperation(stringBuilder, command, 0); @@ -240,7 +240,7 @@ public virtual void AppendUpdateOperation_appends_update_and_select_rowcount_if_ public virtual void AppendUpdateOperation_appends_where_for_concurrency_token() { var stringBuilder = new StringBuilder(); - var command = CreateUpdateCommand(false, concurrencyToken: true); + var command = CreateUpdateCommand(false); CreateSqlGenerator().AppendUpdateOperation(stringBuilder, command, 0); @@ -375,7 +375,7 @@ protected ModificationCommand CreateUpdateCommand(bool isComputed = true, bool c entry, computedProperty, generator.GenerateNext, isComputed, false, false, false, false, true), new ColumnModification( - entry, concurrencyProperty, generator.GenerateNext, false, true, false, + entry, concurrencyProperty, generator.GenerateNext, false, true, false, concurrencyToken, concurrencyToken, true) }; diff --git a/test/EFCore.Specification.Tests/BuiltInDataTypesTestBase.cs b/test/EFCore.Specification.Tests/BuiltInDataTypesTestBase.cs index 96a636a72ea..8aee2d3e120 100644 --- a/test/EFCore.Specification.Tests/BuiltInDataTypesTestBase.cs +++ b/test/EFCore.Specification.Tests/BuiltInDataTypesTestBase.cs @@ -38,11 +38,7 @@ public virtual async Task Can_filter_projection_with_captured_enum_variable(bool var query = context .Set() .Select( - t => new EmailTemplateDto - { - Id = t.Id, - TemplateType = (EmailTemplateTypeDto)t.TemplateType - }) + t => new EmailTemplateDto { Id = t.Id, TemplateType = (EmailTemplateTypeDto)t.TemplateType }) .Where(t => t.TemplateType == templateType); var results = async @@ -64,11 +60,7 @@ public virtual async Task Can_filter_projection_with_inline_enum_variable(bool a var query = context .Set() .Select( - t => new EmailTemplateDto - { - Id = t.Id, - TemplateType = (EmailTemplateTypeDto)t.TemplateType - }) + t => new EmailTemplateDto { Id = t.Id, TemplateType = (EmailTemplateTypeDto)t.TemplateType }) .Where(t => t.TemplateType == EmailTemplateTypeDto.PasswordResetRequest); var results = async @@ -513,10 +505,7 @@ protected EntityEntry AddTestBuiltInDataTypes(DbSet s where TEntity : BuiltInDataTypesBase, new() { var entityEntry = set.Add( - new TEntity - { - Id = 11 - }); + new TEntity { Id = 11 }); entityEntry.CurrentValues.SetValues( new BuiltInDataTypes @@ -886,10 +875,7 @@ protected virtual EntityEntry AddTestBuiltInNullableDataTypes( where TEntity : BuiltInNullableDataTypesBase, new() { var entityEntry = set.Add( - new TEntity - { - Id = 11 - }); + new TEntity { Id = 11 }); entityEntry.CurrentValues.SetValues( new BuiltInNullableDataTypes @@ -995,8 +981,8 @@ public virtual void Can_query_using_any_nullable_data_type_as_literal() entity, context.Set().Where( e => e.Id == 12 - && -e.TestNullableDouble + -1.23456789 < 1E-5 - && -e.TestNullableDouble + -1.23456789 > -1E-5).ToList().Single()); + && -e.TestNullableDouble + -1.23456789 < 1E-5 + && -e.TestNullableDouble + -1.23456789 > -1E-5).ToList().Single()); } Assert.Same( @@ -1155,10 +1141,7 @@ public virtual void Can_query_with_null_parameters_using_any_nullable_data_type( using (var context = CreateContext()) { context.Set().Add( - new BuiltInNullableDataTypes - { - Id = 711 - }); + new BuiltInNullableDataTypes { Id = 711 }); Assert.Equal(1, context.SaveChanges()); } @@ -1442,38 +1425,14 @@ public virtual void Can_insert_and_read_back_with_binary_key() using (var context = CreateContext()) { context.Set().AddRange( - new BinaryKeyDataType - { - Id = new byte[] { 1, 2, 3 }, - Ex = "X1" - }, - new BinaryKeyDataType - { - Id = new byte[] { 1, 2, 3, 4 }, - Ex = "X3" - }, - new BinaryKeyDataType - { - Id = new byte[] { 1, 2, 3, 4, 5 }, - Ex = "X2" - }); + new BinaryKeyDataType { Id = new byte[] { 1, 2, 3 }, Ex = "X1" }, + new BinaryKeyDataType { Id = new byte[] { 1, 2, 3, 4 }, Ex = "X3" }, + new BinaryKeyDataType { Id = new byte[] { 1, 2, 3, 4, 5 }, Ex = "X2" }); context.Set().AddRange( - new BinaryForeignKeyDataType - { - Id = 77, - BinaryKeyDataTypeId = new byte[] { 1, 2, 3, 4 } - }, - new BinaryForeignKeyDataType - { - Id = 777, - BinaryKeyDataTypeId = new byte[] { 1, 2, 3 } - }, - new BinaryForeignKeyDataType - { - Id = 7777, - BinaryKeyDataTypeId = new byte[] { 1, 2, 3, 4, 5 } - }); + new BinaryForeignKeyDataType { Id = 77, BinaryKeyDataTypeId = new byte[] { 1, 2, 3, 4 } }, + new BinaryForeignKeyDataType { Id = 777, BinaryKeyDataTypeId = new byte[] { 1, 2, 3 } }, + new BinaryForeignKeyDataType { Id = 7777, BinaryKeyDataTypeId = new byte[] { 1, 2, 3, 4, 5 } }); Assert.Equal(6, context.SaveChanges()); } @@ -1505,15 +1464,9 @@ BinaryKeyDataType QueryByBinaryKey(DbContext context, byte[] bytes) entity2.Ex = "Xx3"; entity1.Ex = "Xx7"; - entity1.Dependents.Single().BinaryKeyDataTypeId = new byte[] - { - 1, 2, 3, 4, 5 - }; + entity1.Dependents.Single().BinaryKeyDataTypeId = new byte[] { 1, 2, 3, 4, 5 }; - entity2.Dependents.Single().BinaryKeyDataTypeId = new byte[] - { - 1, 2, 3, 4, 5 - }; + entity2.Dependents.Single().BinaryKeyDataTypeId = new byte[] { 1, 2, 3, 4, 5 }; context.SaveChanges(); } @@ -1540,10 +1493,7 @@ public virtual void Can_insert_and_read_back_with_null_binary_foreign_key() using (var context = CreateContext()) { context.Set().Add( - new BinaryForeignKeyDataType - { - Id = 78 - }); + new BinaryForeignKeyDataType { Id = 78 }); Assert.Equal(1, context.SaveChanges()); } @@ -1562,17 +1512,10 @@ public virtual void Can_insert_and_read_back_with_string_key() using (var context = CreateContext()) { var principal = context.Set().Add( - new StringKeyDataType - { - Id = "Gumball!" - }).Entity; + new StringKeyDataType { Id = "Gumball!" }).Entity; var dependent = context.Set().Add( - new StringForeignKeyDataType - { - Id = 77, - StringKeyDataTypeId = "Gumball!" - }).Entity; + new StringForeignKeyDataType { Id = 77, StringKeyDataTypeId = "Gumball!" }).Entity; Assert.Same(principal, dependent.Principal); @@ -1598,10 +1541,7 @@ public virtual void Can_insert_and_read_back_with_null_string_foreign_key() using (var context = CreateContext()) { context.Set().Add( - new StringForeignKeyDataType - { - Id = 78 - }); + new StringForeignKeyDataType { Id = 78 }); Assert.Equal(1, context.SaveChanges()); } @@ -1700,11 +1640,7 @@ public virtual void Can_insert_and_read_back_all_nullable_data_types_with_values using (var context = CreateContext()) { context.Set().Add( - new BuiltInNullableDataTypes - { - Id = 100, - PartitionId = 100 - }); + new BuiltInNullableDataTypes { Id = 100, PartitionId = 100 }); Assert.Equal(1, context.SaveChanges()); } @@ -1760,7 +1696,8 @@ public virtual void Can_insert_and_read_back_all_nullable_data_types_with_values TestNullableDouble = -1.23456789, TestNullableDecimal = -1234567890.01M, TestNullableDateTime = DateTime.Parse("01/01/2000 12:34:56"), - TestNullableDateTimeOffset = new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)), + TestNullableDateTimeOffset = + new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)), TestNullableTimeSpan = new TimeSpan(0, 10, 9, 8, 7), TestNullableSingle = -1.234F, TestNullableBoolean = false, @@ -1873,7 +1810,9 @@ public virtual void Can_insert_and_read_back_object_backed_data_types() AssertEqualIfMapped(entityType, -1.23456789, () => dt.Double); AssertEqualIfMapped(entityType, -1234567890.01M, () => dt.Decimal); AssertEqualIfMapped(entityType, DateTime.Parse("01/01/2000 12:34:56"), () => dt.DateTime); - AssertEqualIfMapped(entityType, new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)), () => dt.DateTimeOffset); + AssertEqualIfMapped( + entityType, new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)), + () => dt.DateTimeOffset); AssertEqualIfMapped(entityType, new TimeSpan(0, 10, 9, 8, 7), () => dt.TimeSpan); AssertEqualIfMapped(entityType, -1.234F, () => dt.Single); AssertEqualIfMapped(entityType, false, () => dt.Boolean); @@ -1944,7 +1883,9 @@ public virtual void Can_insert_and_read_back_nullable_backed_data_types() AssertEqualIfMapped(entityType, -1.23456789, () => dt.Double); AssertEqualIfMapped(entityType, -1234567890.01M, () => dt.Decimal); AssertEqualIfMapped(entityType, DateTime.Parse("01/01/2000 12:34:56"), () => dt.DateTime); - AssertEqualIfMapped(entityType, new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)), () => dt.DateTimeOffset); + AssertEqualIfMapped( + entityType, new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)), + () => dt.DateTimeOffset); AssertEqualIfMapped(entityType, new TimeSpan(0, 10, 9, 8, 7), () => dt.TimeSpan); AssertEqualIfMapped(entityType, -1.234F, () => dt.Single); AssertEqualIfMapped(entityType, false, () => dt.Boolean); @@ -2016,7 +1957,9 @@ public virtual void Can_insert_and_read_back_non_nullable_backed_data_types() AssertEqualIfMapped(entityType, -1.23456789, () => dt.Double); AssertEqualIfMapped(entityType, -1234567890.01M, () => dt.Decimal); AssertEqualIfMapped(entityType, DateTime.Parse("01/01/2000 12:34:56"), () => dt.DateTime); - AssertEqualIfMapped(entityType, new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)), () => dt.DateTimeOffset); + AssertEqualIfMapped( + entityType, new DateTimeOffset(DateTime.Parse("01/01/2000 12:34:56"), TimeSpan.FromHours(-8.0)), + () => dt.DateTimeOffset); AssertEqualIfMapped(entityType, new TimeSpan(0, 10, 9, 8, 7), () => dt.TimeSpan); AssertEqualIfMapped(entityType, -1.234F, () => dt.Single); AssertEqualIfMapped(entityType, false, () => dt.Boolean); @@ -2175,99 +2118,102 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con }); modelBuilder.Entity() - .HasData(new ObjectBackedDataTypes - { - Id = 13, - PartitionId = 1, - String = "string", - Bytes = new byte[] { 4, 20 }, - Int16 = -1234, - Int32 = -123456789, - Int64 = -1234567890123456789L, - Double = -1.23456789, - Decimal = -1234567890.01M, - DateTime = new DateTime(1973, 9,3), - DateTimeOffset = new DateTimeOffset(new DateTime(), TimeSpan.FromHours(-8.0)), - TimeSpan = new TimeSpan(0, 10, 9, 8, 7), - Single = -1.234F, - Boolean = true, - Byte = 255, - UnsignedInt16 = 1234, - UnsignedInt32 = 1234565789U, - UnsignedInt64 = 1234567890123456789UL, - Character = 'a', - SignedByte = -128, - Enum64 = Enum64.SomeValue, - Enum32 = Enum32.SomeValue, - Enum16 = Enum16.SomeValue, - Enum8 = Enum8.SomeValue, - EnumU64 = EnumU64.SomeValue, - EnumU32 = EnumU32.SomeValue, - EnumU16 = EnumU16.SomeValue, - EnumS8 = EnumS8.SomeValue - }); + .HasData( + new ObjectBackedDataTypes + { + Id = 13, + PartitionId = 1, + String = "string", + Bytes = new byte[] { 4, 20 }, + Int16 = -1234, + Int32 = -123456789, + Int64 = -1234567890123456789L, + Double = -1.23456789, + Decimal = -1234567890.01M, + DateTime = new DateTime(1973, 9, 3), + DateTimeOffset = new DateTimeOffset(new DateTime(), TimeSpan.FromHours(-8.0)), + TimeSpan = new TimeSpan(0, 10, 9, 8, 7), + Single = -1.234F, + Boolean = true, + Byte = 255, + UnsignedInt16 = 1234, + UnsignedInt32 = 1234565789U, + UnsignedInt64 = 1234567890123456789UL, + Character = 'a', + SignedByte = -128, + Enum64 = Enum64.SomeValue, + Enum32 = Enum32.SomeValue, + Enum16 = Enum16.SomeValue, + Enum8 = Enum8.SomeValue, + EnumU64 = EnumU64.SomeValue, + EnumU32 = EnumU32.SomeValue, + EnumU16 = EnumU16.SomeValue, + EnumS8 = EnumS8.SomeValue + }); modelBuilder.Entity() - .HasData(new NullableBackedDataTypes - { - Id = 13, - PartitionId = 1, - Int16 = -1234, - Int32 = -123456789, - Int64 = -1234567890123456789L, - Double = -1.23456789, - Decimal = -1234567890.01M, - DateTime = new DateTime(1973, 9,3), - DateTimeOffset = new DateTimeOffset(new DateTime(), TimeSpan.FromHours(-8.0)), - TimeSpan = new TimeSpan(0, 10, 9, 8, 7), - Single = -1.234F, - Boolean = true, - Byte = 255, - UnsignedInt16 = 1234, - UnsignedInt32 = 1234565789U, - UnsignedInt64 = 1234567890123456789UL, - Character = 'a', - SignedByte = -128, - Enum64 = Enum64.SomeValue, - Enum32 = Enum32.SomeValue, - Enum16 = Enum16.SomeValue, - Enum8 = Enum8.SomeValue, - EnumU64 = EnumU64.SomeValue, - EnumU32 = EnumU32.SomeValue, - EnumU16 = EnumU16.SomeValue, - EnumS8 = EnumS8.SomeValue - }); + .HasData( + new NullableBackedDataTypes + { + Id = 13, + PartitionId = 1, + Int16 = -1234, + Int32 = -123456789, + Int64 = -1234567890123456789L, + Double = -1.23456789, + Decimal = -1234567890.01M, + DateTime = new DateTime(1973, 9, 3), + DateTimeOffset = new DateTimeOffset(new DateTime(), TimeSpan.FromHours(-8.0)), + TimeSpan = new TimeSpan(0, 10, 9, 8, 7), + Single = -1.234F, + Boolean = true, + Byte = 255, + UnsignedInt16 = 1234, + UnsignedInt32 = 1234565789U, + UnsignedInt64 = 1234567890123456789UL, + Character = 'a', + SignedByte = -128, + Enum64 = Enum64.SomeValue, + Enum32 = Enum32.SomeValue, + Enum16 = Enum16.SomeValue, + Enum8 = Enum8.SomeValue, + EnumU64 = EnumU64.SomeValue, + EnumU32 = EnumU32.SomeValue, + EnumU16 = EnumU16.SomeValue, + EnumS8 = EnumS8.SomeValue + }); modelBuilder.Entity() - .HasData(new NonNullableBackedDataTypes - { - Id = 13, - PartitionId = 1, - Int16 = -1234, - Int32 = -123456789, - Int64 = -1234567890123456789L, - Double = -1.23456789, - Decimal = -1234567890.01M, - DateTime = new DateTime(1973, 9,3), - DateTimeOffset = new DateTimeOffset(new DateTime(), TimeSpan.FromHours(-8.0)), - TimeSpan = new TimeSpan(0, 10, 9, 8, 7), - Single = -1.234F, - Boolean = true, - Byte = 255, - UnsignedInt16 = 1234, - UnsignedInt32 = 1234565789U, - UnsignedInt64 = 1234567890123456789UL, - Character = 'a', - SignedByte = -128, - Enum64 = Enum64.SomeValue, - Enum32 = Enum32.SomeValue, - Enum16 = Enum16.SomeValue, - Enum8 = Enum8.SomeValue, - EnumU64 = EnumU64.SomeValue, - EnumU32 = EnumU32.SomeValue, - EnumU16 = EnumU16.SomeValue, - EnumS8 = EnumS8.SomeValue - }); + .HasData( + new NonNullableBackedDataTypes + { + Id = 13, + PartitionId = 1, + Int16 = -1234, + Int32 = -123456789, + Int64 = -1234567890123456789L, + Double = -1.23456789, + Decimal = -1234567890.01M, + DateTime = new DateTime(1973, 9, 3), + DateTimeOffset = new DateTimeOffset(new DateTime(), TimeSpan.FromHours(-8.0)), + TimeSpan = new TimeSpan(0, 10, 9, 8, 7), + Single = -1.234F, + Boolean = true, + Byte = 255, + UnsignedInt16 = 1234, + UnsignedInt32 = 1234565789U, + UnsignedInt64 = 1234567890123456789UL, + Character = 'a', + SignedByte = -128, + Enum64 = Enum64.SomeValue, + Enum32 = Enum32.SomeValue, + Enum16 = Enum16.SomeValue, + Enum8 = Enum8.SomeValue, + EnumU64 = EnumU64.SomeValue, + EnumU32 = EnumU32.SomeValue, + EnumU16 = EnumU16.SomeValue, + EnumS8 = EnumS8.SomeValue + }); } protected static void MakeRequired(ModelBuilder modelBuilder) @@ -2492,6 +2438,7 @@ protected enum EmailTemplateTypeDto PasswordResetRequest = 0, EmailConfirmation = 1 } + protected class ObjectBackedDataTypes { private object _string; @@ -2523,6 +2470,7 @@ protected class ObjectBackedDataTypes [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } + public int PartitionId { get; set; } public string String @@ -2711,6 +2659,7 @@ protected class NullableBackedDataTypes [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } + public int PartitionId { get; set; } public short Int16 @@ -2887,6 +2836,7 @@ protected class NonNullableBackedDataTypes [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } + public int PartitionId { get; set; } public short? Int16 diff --git a/test/EFCore.Specification.Tests/ComplianceTestBase.cs b/test/EFCore.Specification.Tests/ComplianceTestBase.cs index 86e35b21af3..eb2ab137b5e 100644 --- a/test/EFCore.Specification.Tests/ComplianceTestBase.cs +++ b/test/EFCore.Specification.Tests/ComplianceTestBase.cs @@ -18,9 +18,10 @@ public abstract class ComplianceTestBase [ConditionalFact] public virtual void All_test_bases_must_be_implemented() { - var concreteTests = TargetAssembly.GetTypes().Where(c => - c.BaseType != typeof(object) && !c.IsAbstract - && (c.IsPublic || c.IsNestedPublic)) + var concreteTests = TargetAssembly.GetTypes().Where( + c => + c.BaseType != typeof(object) && !c.IsAbstract + && (c.IsPublic || c.IsNestedPublic)) .ToList(); var nonImplementedBases = (from baseType in GetBaseTestClasses() diff --git a/test/EFCore.Specification.Tests/CompositeKeyEndToEndTestBase.cs b/test/EFCore.Specification.Tests/CompositeKeyEndToEndTestBase.cs index ef3141d4ba8..a82bc715ad0 100644 --- a/test/EFCore.Specification.Tests/CompositeKeyEndToEndTestBase.cs +++ b/test/EFCore.Specification.Tests/CompositeKeyEndToEndTestBase.cs @@ -26,12 +26,7 @@ public virtual async Task Can_use_two_non_generated_integers_as_composite_key_en using (var context = CreateContext()) { context.Add( - new Pegasus - { - Id1 = ticks, - Id2 = ticks + 1, - Name = "Rainbow Dash" - }); + new Pegasus { Id1 = ticks, Id2 = ticks + 1, Name = "Rainbow Dash" }); await context.SaveChangesAsync(); } @@ -73,11 +68,7 @@ public virtual async Task Can_use_generated_values_in_composite_key_end_to_end() context.Database.EnsureCreatedResiliently(); var added = context.Add( - new Unicorn - { - Id2 = id2, - Name = "Rarity" - }).Entity; + new Unicorn { Id2 = id2, Name = "Rarity" }).Entity; await context.SaveChangesAsync(); @@ -127,26 +118,11 @@ public virtual async Task Only_one_part_of_a_composite_key_needs_to_vary_for_uni using (var context = CreateContext()) { var pony1 = context.Add( - new EarthPony - { - Id1 = 1, - Id2 = 7, - Name = "Apple Jack 1" - }).Entity; + new EarthPony { Id1 = 1, Id2 = 7, Name = "Apple Jack 1" }).Entity; var pony2 = context.Add( - new EarthPony - { - Id1 = 2, - Id2 = 7, - Name = "Apple Jack 2" - }).Entity; + new EarthPony { Id1 = 2, Id2 = 7, Name = "Apple Jack 2" }).Entity; var pony3 = context.Add( - new EarthPony - { - Id1 = 3, - Id2 = 7, - Name = "Apple Jack 3" - }).Entity; + new EarthPony { Id1 = 3, Id2 = 7, Name = "Apple Jack 3" }).Entity; await context.SaveChangesAsync(); @@ -219,23 +195,14 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2, - e.Id3 - }); + e => new { e.Id1, e.Id2, e.Id3 }); b.Property(e => e.Id1).ValueGeneratedOnAdd(); b.Property(e => e.Id3).ValueGeneratedOnAdd(); }); @@ -244,11 +211,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); b.Property(e => e.Id1); }); } diff --git a/test/EFCore.Specification.Tests/ConcurrencyDetectorTestBase.cs b/test/EFCore.Specification.Tests/ConcurrencyDetectorTestBase.cs index e3923df3053..00600c660f4 100644 --- a/test/EFCore.Specification.Tests/ConcurrencyDetectorTestBase.cs +++ b/test/EFCore.Specification.Tests/ConcurrencyDetectorTestBase.cs @@ -3,11 +3,9 @@ using System; using System.Linq; -using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -165,10 +163,7 @@ protected virtual async Task ConcurrencyDetectorTest(Func(); IDisposable disposer = null; diff --git a/test/EFCore.Specification.Tests/ConferencePlannerTestBase.cs b/test/EFCore.Specification.Tests/ConferencePlannerTestBase.cs index 4c22f153016..45ba628b4f1 100644 --- a/test/EFCore.Specification.Tests/ConferencePlannerTestBase.cs +++ b/test/EFCore.Specification.Tests/ConferencePlannerTestBase.cs @@ -9,9 +9,13 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestModels.ConferencePlanner; +using Microsoft.EntityFrameworkCore.TestModels.ConferencePlanner.ConferenceDTO; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; -using ConferenceDTO = Microsoft.EntityFrameworkCore.TestModels.ConferencePlanner.ConferenceDTO; +using Attendee = Microsoft.EntityFrameworkCore.TestModels.ConferencePlanner.ConferenceDTO.Attendee; +using Session = Microsoft.EntityFrameworkCore.TestModels.ConferencePlanner.ConferenceDTO.Session; +using Speaker = Microsoft.EntityFrameworkCore.TestModels.ConferencePlanner.Speaker; +using Track = Microsoft.EntityFrameworkCore.TestModels.ConferencePlanner.Track; namespace Microsoft.EntityFrameworkCore { @@ -72,10 +76,7 @@ await ExecuteWithStrategyInTransactionAsync( var controller = new AttendeesController(context); var result = await controller.Post( - new ConferenceDTO.Attendee - { - EmailAddress = "discord@sample.com", FirstName = "", LastName = "Discord", UserName = "Discord!" - }); + new Attendee { EmailAddress = "discord@sample.com", FirstName = "", LastName = "Discord", UserName = "Discord!" }); Assert.NotEqual(default, result.Id); Assert.Equal("discord@sample.com", result.EmailAddress); @@ -95,10 +96,7 @@ await ExecuteWithStrategyInTransactionAsync( var controller = new AttendeesController(context); var result = await controller.Post( - new ConferenceDTO.Attendee - { - EmailAddress = "pinkie@sample.com", FirstName = "Pinkie", LastName = "Pie", UserName = "Pinks" - }); + new Attendee { EmailAddress = "pinkie@sample.com", FirstName = "Pinkie", LastName = "Pie", UserName = "Pinks" }); Assert.Null(result); }); @@ -123,10 +121,10 @@ await ExecuteWithStrategyInTransactionAsync( Assert.Equal(21, pinkySessions.Count); - var result = (ConferenceDTO.AttendeeResponse)await controller.AddSession("Pinks", session.Id); + var result = (AttendeeResponse)await controller.AddSession("Pinks", session.Id); Assert.Equal(22, result.Sessions.Count); - Assert.Contains(session.Id, result.Sessions.Select(s =>s .Id)); + Assert.Contains(session.Id, result.Sessions.Select(s => s.Id)); Assert.Equal(pinky.Id, result.Id); Assert.Equal(pinky.UserName, result.UserName); @@ -222,7 +220,7 @@ await ExecuteWithStrategyInTransactionAsync( { var controller = new AttendeesController(context); - var result = (string)await controller.RemoveSession("Pinks", -777); + var result = await controller.RemoveSession("Pinks", -777); Assert.Equal("No session", result); }); @@ -238,7 +236,7 @@ await ExecuteWithStrategyInTransactionAsync( var session = context.Sessions.AsNoTracking().Single(e => e.Title == "Hidden gems in .NET Core 3"); - var result = (string)await controller.RemoveSession("The Stig", session.Id); + var result = await controller.RemoveSession("The Stig", session.Id); Assert.Equal("No attendee", result); }); @@ -253,7 +251,7 @@ public AttendeesController(ApplicationDbContext db) _db = db; } - public async Task Get(string username) + public async Task Get(string username) { var attendee = await _db.Attendees .Include(a => a.SessionsAttendees) @@ -263,7 +261,7 @@ public AttendeesController(ApplicationDbContext db) return attendee?.MapAttendeeResponse(); } - public async Task> GetSessions(string username) + public async Task> GetSessions(string username) { return await _db.Sessions.AsNoTracking() .Include(s => s.Track) @@ -274,7 +272,7 @@ public AttendeesController(ApplicationDbContext db) .ToListAsync(); } - public async Task Post(ConferenceDTO.Attendee input) + public async Task Post(Attendee input) { var existingAttendee = await _db.Attendees .Where(a => a.UserName == input.UserName) @@ -285,7 +283,7 @@ public AttendeesController(ApplicationDbContext db) return null; } - var attendee = new Attendee + var attendee = new TestModels.ConferencePlanner.Attendee { FirstName = input.FirstName, LastName = input.LastName, UserName = input.UserName, EmailAddress = input.EmailAddress }; @@ -316,10 +314,7 @@ public async Task AddSession(string username, int sessionId) } attendee.SessionsAttendees.Add( - new SessionAttendee - { - AttendeeId = attendee.Id, SessionId = sessionId - }); + new SessionAttendee { AttendeeId = attendee.Id, SessionId = sessionId }); await _db.SaveChangesAsync(); @@ -366,15 +361,12 @@ await ExecuteWithStrategyInTransactionAsync( var controller = new SearchController(context); var results = await controller.Search( - new ConferenceDTO.SearchTerm - { - Query = searchTerm - }); + new SearchTerm { Query = searchTerm }); Assert.Equal(totalCount, results.Count); - var sessions = results.Where(r => r.Type == ConferenceDTO.SearchResultType.Session).Select(r => r.Session).ToList(); - var speakers = results.Where(r => r.Type == ConferenceDTO.SearchResultType.Speaker).Select(r => r.Speaker).ToList(); + var sessions = results.Where(r => r.Type == SearchResultType.Session).Select(r => r.Session).ToList(); + var speakers = results.Where(r => r.Type == SearchResultType.Speaker).Select(r => r.Speaker).ToList(); Assert.Equal(sessionCount, sessions.Count); Assert.Equal(totalCount - sessionCount, speakers.Count); @@ -397,7 +389,7 @@ public SearchController(ApplicationDbContext db) _db = db; } - public async Task> Search(ConferenceDTO.SearchTerm term) + public async Task> Search(SearchTerm term) { var query = term.Query; var sessionResults = await _db.Sessions @@ -423,16 +415,10 @@ public SearchController(ApplicationDbContext db) .ToListAsync(); var results = sessionResults.Select( - session => new ConferenceDTO.SearchResult - { - Type = ConferenceDTO.SearchResultType.Session, Session = session.MapSessionResponse() - }) + session => new SearchResult { Type = SearchResultType.Session, Session = session.MapSessionResponse() }) .Concat( speakerResults.Select( - speaker => new ConferenceDTO.SearchResult - { - Type = ConferenceDTO.SearchResultType.Speaker, Speaker = speaker.MapSpeakerResponse() - })); + speaker => new SearchResult { Type = SearchResultType.Speaker, Speaker = speaker.MapSpeakerResponse() })); return results.ToList(); } @@ -499,7 +485,7 @@ await ExecuteWithStrategyInTransactionAsync( var controller = new SessionsController(context); var result = await controller.Post( - new ConferenceDTO.Session + new Session { Abstract = "Pandas eat bamboo all dat.", Title = "Pandas!", @@ -529,7 +515,7 @@ await ExecuteWithStrategyInTransactionAsync( var result = await controller.Put( session.Id, - new ConferenceDTO.Session + new Session { Id = session.Id, Abstract = session.Abstract, @@ -556,7 +542,7 @@ await ExecuteWithStrategyInTransactionAsync( { var controller = new SessionsController(context); - var result = await controller.Put(-777, new ConferenceDTO.Session()); + var result = await controller.Put(-777, new Session()); Assert.Equal("Not found", result); }); @@ -605,7 +591,7 @@ public SessionsController(ApplicationDbContext db) _db = db; } - public async Task> Get() + public async Task> Get() { return await _db.Sessions.AsNoTracking() .Include(s => s.Track) @@ -615,7 +601,7 @@ public SessionsController(ApplicationDbContext db) .ToListAsync(); } - public async Task Get(int id) + public async Task Get(int id) { var session = await _db.Sessions.AsNoTracking() .Include(s => s.Track) @@ -626,9 +612,9 @@ public SessionsController(ApplicationDbContext db) return session?.MapSessionResponse(); } - public async Task Post(ConferenceDTO.Session input) + public async Task Post(Session input) { - var session = new Session + var session = new TestModels.ConferencePlanner.Session { Title = input.Title, StartTime = input.StartTime, @@ -643,7 +629,7 @@ public SessionsController(ApplicationDbContext db) return session.MapSessionResponse(); } - public async Task Put(int id, ConferenceDTO.Session input) + public async Task Put(int id, Session input) { var session = await _db.Sessions.FindAsync(id); @@ -664,7 +650,7 @@ public async Task Put(int id, ConferenceDTO.Session input) return "Success"; } - public async Task Delete(int id) + public async Task Delete(int id) { var session = await _db.Sessions.FindAsync(id); @@ -737,7 +723,7 @@ public SpeakersController(ApplicationDbContext db) _db = db; } - public async Task> GetSpeakers() + public async Task> GetSpeakers() { return await _db.Speakers.AsNoTracking() .Include(s => s.SessionSpeakers) @@ -746,7 +732,7 @@ public SpeakersController(ApplicationDbContext db) .ToListAsync(); } - public async Task GetSpeaker(int id) + public async Task GetSpeaker(int id) { var speaker = await _db.Speakers.AsNoTracking() .Include(s => s.SessionSpeakers) @@ -786,37 +772,40 @@ public abstract class ConferencePlannerFixtureBase : SharedStoreFixtureBase + var attendees1 = new List { - new Attendee + new TestModels.ConferencePlanner.Attendee { - EmailAddress = "sonicrainboom@sample.com", FirstName = "Rainbow", LastName = "Dash", UserName = "RainbowDash" + EmailAddress = "sonicrainboom@sample.com", + FirstName = "Rainbow", + LastName = "Dash", + UserName = "RainbowDash" }, - new Attendee + new TestModels.ConferencePlanner.Attendee { EmailAddress = "solovely@sample.com", FirstName = "Flutter", LastName = "Shy", UserName = "Fluttershy" } }; - var attendees2 = new List + var attendees2 = new List { - new Attendee + new TestModels.ConferencePlanner.Attendee { EmailAddress = "applesforever@sample.com", FirstName = "Apple", LastName = "Jack", UserName = "Applejack" }, - new Attendee + new TestModels.ConferencePlanner.Attendee { EmailAddress = "precious@sample.com", FirstName = "Rarity", LastName = "", UserName = "Rarity" } }; - var attendees3 = new List + var attendees3 = new List { - new Attendee + new TestModels.ConferencePlanner.Attendee { EmailAddress = "princess@sample.com", FirstName = "Twilight", LastName = "Sparkle", UserName = "Princess" }, - new Attendee + new TestModels.ConferencePlanner.Attendee { EmailAddress = "pinkie@sample.com", FirstName = "Pinkie", LastName = "Pie", UserName = "Pinks" } @@ -837,7 +826,8 @@ protected override void Seed(ApplicationDbContext context) { track = new Track { - Name = roomJson.GetProperty("name").GetString(), Sessions = new List() + Name = roomJson.GetProperty("name").GetString(), + Sessions = new List() }; tracks[roomId] = track; @@ -851,10 +841,7 @@ protected override void Seed(ApplicationDbContext context) var speakerId = speakerJson.GetProperty("id").GetGuid(); if (!speakers.TryGetValue(speakerId, out var speaker)) { - speaker = new Speaker - { - Name = speakerJson.GetProperty("name").GetString() - }; + speaker = new Speaker { Name = speakerJson.GetProperty("name").GetString() }; speakers[speakerId] = speaker; } @@ -862,19 +849,16 @@ protected override void Seed(ApplicationDbContext context) sessionSpeakers.Add(speaker); } - var session = new Session + var session = new TestModels.ConferencePlanner.Session { Title = sessionJson.GetProperty("title").GetString(), Abstract = sessionJson.GetProperty("description").GetString(), StartTime = sessionJson.GetProperty("startsAt").GetDateTime(), - EndTime = sessionJson.GetProperty("endsAt").GetDateTime(), + EndTime = sessionJson.GetProperty("endsAt").GetDateTime() }; session.SessionSpeakers = sessionSpeakers.Select( - s => new SessionSpeaker - { - Session = session, Speaker = s - }).ToList(); + s => new SessionSpeaker { Session = session, Speaker = s }).ToList(); var trackName = track.Name; var attendees = trackName.Contains("1") ? attendees1 @@ -883,10 +867,7 @@ protected override void Seed(ApplicationDbContext context) : attendees1.Concat(attendees2).Concat(attendees3).ToList(); session.SessionAttendees = attendees.Select( - a => new SessionAttendee - { - Session = session, Attendee = a - }).ToList(); + a => new SessionAttendee { Session = session, Attendee = a }).ToList(); track.Sessions.Add(session); } diff --git a/test/EFCore.Specification.Tests/ConferencePlannerTestBaseData.cs b/test/EFCore.Specification.Tests/ConferencePlannerTestBaseData.cs index 421b4988357..97093361604 100644 --- a/test/EFCore.Specification.Tests/ConferencePlannerTestBaseData.cs +++ b/test/EFCore.Specification.Tests/ConferencePlannerTestBaseData.cs @@ -1,5 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + namespace Microsoft.EntityFrameworkCore { public partial class ConferencePlannerTestBase diff --git a/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs b/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs index 1d03928082a..d9a5af8ed4d 100644 --- a/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs +++ b/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs @@ -25,34 +25,10 @@ public virtual void Can_query_and_update_with_nullable_converter_on_unique_index using (var context = CreateContext()) { context.AddRange( - new Person - { - Id = 1, - Name = "Lewis" - }, - new Person - { - Id = 2, - Name = "Seb", - SSN = new SocialSecurityNumber - { - Number = 111111111 - } - }, - new Person - { - Id = 3, - Name = "Kimi", - SSN = new SocialSecurityNumber - { - Number = 222222222 - } - }, - new Person - { - Id = 4, - Name = "Valtteri" - }); + new Person { Id = 1, Name = "Lewis" }, + new Person { Id = 2, Name = "Seb", SSN = new SocialSecurityNumber { Number = 111111111 } }, + new Person { Id = 3, Name = "Kimi", SSN = new SocialSecurityNumber { Number = 222222222 } }, + new Person { Id = 4, Name = "Valtteri" }); context.SaveChanges(); } @@ -78,15 +54,7 @@ public virtual void Can_query_and_update_with_nullable_converter_on_unique_index context.Remove(drivers[0]); context.Add( - new Person - { - Id = 5, - Name = "Charles", - SSN = new SocialSecurityNumber - { - Number = 222222222 - } - }); + new Person { Id = 5, Name = "Charles", SSN = new SocialSecurityNumber { Number = 222222222 } }); context.SaveChanges(); } @@ -134,14 +102,11 @@ public virtual void Can_query_and_update_with_nullable_converter_on_primary_key( using (var context = CreateContext()) { var principal = context.Add( - new NullablePrincipal - { - Id = 1, - Dependents = new List - { - new NonNullableDependent{Id = 1} - } - }).Entity; + new NullablePrincipal + { + Id = 1, Dependents = new List { new NonNullableDependent { Id = 1 } } + }) + .Entity; var pkEntry = context.Entry(principal).Property(e => e.Id); var fkEntry = context.Entry(principal.Dependents.Single()).Property(e => e.PrincipalId); @@ -273,17 +238,10 @@ public virtual void Can_insert_and_read_back_with_case_insensitive_string_key() using (var context = CreateContext()) { var principal = context.Set().Add( - new StringKeyDataType - { - Id = "Gumball!!" - }).Entity; + new StringKeyDataType { Id = "Gumball!!" }).Entity; var dependent = context.Set().Add( - new StringForeignKeyDataType - { - Id = 7767, - StringKeyDataTypeId = "gumball!!" - }).Entity; + new StringForeignKeyDataType { Id = 7767, StringKeyDataTypeId = "gumball!!" }).Entity; Assert.Same(principal, dependent.Principal); @@ -321,15 +279,7 @@ public virtual void Can_insert_and_read_back_with_string_list() using (var context = CreateContext()) { context.Set().Add( - new StringListDataType - { - Id = 1, - Strings = new List - { - "Gum", - "Taffy" - } - }); + new StringListDataType { Id = 1, Strings = new List { "Gum", "Taffy" } }); Assert.Equal(1, context.SaveChanges()); } @@ -357,24 +307,22 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con { base.OnModelCreating(modelBuilder, context); - modelBuilder.Entity(b => - { - b.Property(p => p.SSN) - .HasConversion( - ssn => ssn.HasValue - ? ssn.Value.Number - : new int?(), - i => i.HasValue - ? new SocialSecurityNumber - { - Number = i.Value - } - : new SocialSecurityNumber?()); - - b.Property(p => p.Id).ValueGeneratedNever(); - b.HasIndex(p => p.SSN) - .IsUnique(); - }); + modelBuilder.Entity( + b => + { + b.Property(p => p.SSN) + .HasConversion( + ssn => ssn.HasValue + ? ssn.Value.Number + : new int?(), + i => i.HasValue + ? new SocialSecurityNumber { Number = i.Value } + : new SocialSecurityNumber?()); + + b.Property(p => p.Id).ValueGeneratedNever(); + b.HasIndex(p => p.SSN) + .IsUnique(); + }); modelBuilder.Entity( b => diff --git a/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs b/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs index 605821d4363..149cd654955 100644 --- a/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs +++ b/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs @@ -754,11 +754,7 @@ public virtual ModelBuilder Key_specified_on_multiple_properties_can_be_overridd var modelBuilder = CreateModelBuilder(); modelBuilder.Entity().HasKey( - c => new - { - c.IdRow, - c.Name - }); + c => new { c.IdRow, c.Name }); Validate(modelBuilder); @@ -786,11 +782,7 @@ public virtual ModelBuilder DatabaseGeneratedOption_configures_the_property_corr var modelBuilder = CreateModelBuilder(); modelBuilder.Entity().HasAlternateKey( - e => new - { - e.Identity, - e.Version - }); + e => new { e.Identity, e.Version }); var entity = modelBuilder.Model.FindEntityType(typeof(GeneratedEntity)); @@ -827,12 +819,7 @@ public virtual ModelBuilder DatabaseGeneratedOption_Identity_does_not_throw_on_n var modelBuilder = CreateModelBuilder(); modelBuilder.Entity().HasAlternateKey( - e => new - { - e.String, - e.DateTime, - e.Guid - }); + e => new { e.String, e.DateTime, e.Guid }); var entity = modelBuilder.Model.FindEntityType(typeof(GeneratedEntityNonInteger)); @@ -1423,14 +1410,8 @@ public virtual void DatabaseGeneratedAttribute_autogenerates_values_when_set_to_ { RequiredColumn = "Third", RowVersion = new Guid("00000000-0000-0000-0000-000000000003"), - Details = new Details - { - Name = "Third Name" - }, - AdditionalDetails = new Details - { - Name = "Third Additional Name" - } + Details = new Details { Name = "Third Name" }, + AdditionalDetails = new Details { Name = "Third Additional Name" } }); context.SaveChanges(); @@ -1449,14 +1430,8 @@ public virtual void MaxLengthAttribute_throws_while_inserting_value_longer_than_ RequiredColumn = "ValidString", RowVersion = new Guid("00000000-0000-0000-0000-000000000001"), MaxLengthProperty = "Short", - Details = new Details - { - Name = "Third Name" - }, - AdditionalDetails = new Details - { - Name = "Third Additional Name" - } + Details = new Details { Name = "Third Name" }, + AdditionalDetails = new Details { Name = "Third Additional Name" } }); context.SaveChanges(); @@ -1471,14 +1446,8 @@ public virtual void MaxLengthAttribute_throws_while_inserting_value_longer_than_ RequiredColumn = "ValidString", RowVersion = new Guid("00000000-0000-0000-0000-000000000002"), MaxLengthProperty = "VeryVeryVeryVeryVeryVeryLongString", - Details = new Details - { - Name = "Third Name" - }, - AdditionalDetails = new Details - { - Name = "Third Additional Name" - } + Details = new Details { Name = "Third Name" }, + AdditionalDetails = new Details { Name = "Third Additional Name" } }); Assert.Equal( @@ -1946,8 +1915,9 @@ public virtual void var logEntry = Fixture.ListLoggerFactory.Log.Single(); Assert.Equal(LogLevel.Warning, logEntry.Level); Assert.Equal( - CoreResources.LogConflictingForeignKeyAttributesOnNavigationAndProperty(new TestLogger()).GenerateMessage( - nameof(Author), nameof(Author.AuthorDetails), nameof(AuthorDetails), nameof(AuthorDetails.AuthorId)), + CoreResources.LogConflictingForeignKeyAttributesOnNavigationAndProperty(new TestLogger()) + .GenerateMessage( + nameof(Author), nameof(Author.AuthorDetails), nameof(AuthorDetails), nameof(AuthorDetails.AuthorId)), logEntry.Message); } @@ -2088,10 +2058,7 @@ public virtual void RequiredAttribute_for_navigation_throws_while_inserting_null context => { context.Set().Add( - new BookDetails - { - AnotherBookId = 1 - }); + new BookDetails { AnotherBookId = 1 }); context.SaveChanges(); }); @@ -2130,14 +2097,8 @@ public virtual void RequiredAttribute_for_property_throws_while_inserting_null_v { RequiredColumn = "ValidString", RowVersion = new Guid("00000000-0000-0000-0000-000000000001"), - Details = new Details - { - Name = "One" - }, - AdditionalDetails = new Details - { - Name = "Two" - } + Details = new Details { Name = "One" }, + AdditionalDetails = new Details { Name = "Two" } }); context.SaveChanges(); @@ -2151,14 +2112,8 @@ public virtual void RequiredAttribute_for_property_throws_while_inserting_null_v { RequiredColumn = null, RowVersion = new Guid("00000000-0000-0000-0000-000000000002"), - Details = new Details - { - Name = "One" - }, - AdditionalDetails = new Details - { - Name = "Two" - } + Details = new Details { Name = "One" }, + AdditionalDetails = new Details { Name = "Two" } }); Assert.Equal( @@ -2174,10 +2129,7 @@ public virtual void StringLengthAttribute_throws_while_inserting_value_longer_th context => { context.Set().Add( - new Two - { - Data = "ValidString" - }); + new Two { Data = "ValidString" }); context.SaveChanges(); }); @@ -2186,10 +2138,7 @@ public virtual void StringLengthAttribute_throws_while_inserting_value_longer_th context => { context.Set().Add( - new Two - { - Data = "ValidButLongString" - }); + new Two { Data = "ValidButLongString" }); Assert.Equal( "An error occurred while updating the entries. See the inner exception for details.", @@ -2299,50 +2248,25 @@ protected override void Seed(PoolableDbContext context) { RequiredColumn = "First", RowVersion = new Guid("00000001-0000-0000-0000-000000000001"), - Details = new Details - { - Name = "First Name" - }, - AdditionalDetails = new Details - { - Name = "First Additional Name" - } + Details = new Details { Name = "First Name" }, + AdditionalDetails = new Details { Name = "First Additional Name" } }); context.Set().Add( new One { RequiredColumn = "Second", RowVersion = new Guid("00000001-0000-0000-0000-000000000001"), - Details = new Details - { - Name = "Second Name" - }, - AdditionalDetails = new Details - { - Name = "Second Additional Name" - } + Details = new Details { Name = "Second Name" }, + AdditionalDetails = new Details { Name = "Second Additional Name" } }); context.Set().Add( - new Two - { - Data = "First" - }); + new Two { Data = "First" }); context.Set().Add( - new Two - { - Data = "Second" - }); + new Two { Data = "Second" }); context.Set().Add( - new Book - { - Id = 1, - AdditionalDetails = new Details - { - Name = "Book Name" - } - }); + new Book { Id = 1, AdditionalDetails = new Details { Name = "Book Name" } }); context.SaveChanges(); } diff --git a/test/EFCore.Specification.Tests/DatabindingTestBase.cs b/test/EFCore.Specification.Tests/DatabindingTestBase.cs index 8d2e69b7466..e85674b6495 100644 --- a/test/EFCore.Specification.Tests/DatabindingTestBase.cs +++ b/test/EFCore.Specification.Tests/DatabindingTestBase.cs @@ -49,19 +49,9 @@ protected void SetupContext(F1Context context) } drivers.Add( - new Driver - { - Name = "Pedro de la Rosa", - TeamId = AddedTeam, - CarNumber = 13 - }); + new Driver { Name = "Pedro de la Rosa", TeamId = AddedTeam, CarNumber = 13 }); drivers.Add( - new Driver - { - Name = "Kamui Kobayashi", - TeamId = AddedTeam, - CarNumber = null - }); + new Driver { Name = "Kamui Kobayashi", TeamId = AddedTeam, CarNumber = null }); } [ConditionalTheory] @@ -102,12 +92,7 @@ public virtual void Adding_entity_to_context_is_reflected_in_local_view( Assert.Equal(0, local.Count); - var larry = new Driver - { - Name = "Larry David", - TeamId = Team.Ferrari, - CarNumber = 13 - }; + var larry = new Driver { Name = "Larry David", TeamId = Team.Ferrari, CarNumber = 13 }; context.Drivers.Add(larry); Assert.Equal(1, local.Count); @@ -130,12 +115,7 @@ public virtual void Attaching_entity_to_context_is_reflected_in_local_view( Assert.Equal(0, local.Count); - var larry = new Driver - { - Name = "Larry David", - TeamId = Team.Ferrari, - CarNumber = 13 - }; + var larry = new Driver { Name = "Larry David", TeamId = Team.Ferrari, CarNumber = 13 }; context.Drivers.Attach(larry); Assert.Equal(1, local.Count); @@ -341,13 +321,7 @@ public virtual void Entities_added_to_local_view_are_added_to_state_manager( Assert.Equal(0, local.Count); - var larry = new Driver - { - Id = -1, - Name = "Larry David", - TeamId = Team.Ferrari, - CarNumber = 13 - }; + var larry = new Driver { Id = -1, Name = "Larry David", TeamId = Team.Ferrari, CarNumber = 13 }; local.Add(larry); @@ -466,11 +440,7 @@ public virtual void Adding_entity_to_state_manager_of_different_type_than_local_ Assert.Equal(TotalCount, local.Count); context.Teams.Add( - new Team - { - Id = -1, - Name = "Wubbsy Racing" - }); + new Team { Id = -1, Name = "Wubbsy Racing" }); Assert.Equal(TotalCount, local.Count); } @@ -610,12 +580,7 @@ public virtual void Adding_entity_to_context_is_reflected_in_local_binding_list( Assert.Equal(0, bindingList.Count); - var larry = new Driver - { - Name = "Larry David", - TeamId = Team.Ferrari, - CarNumber = 13 - }; + var larry = new Driver { Name = "Larry David", TeamId = Team.Ferrari, CarNumber = 13 }; context.Drivers.Add(larry); Assert.True(bindingList.Contains(larry)); @@ -689,13 +654,7 @@ public virtual void Entities_added_to_local_binding_list_are_added_to_state_mana Assert.Equal(0, bindingList.Count); - var larry = new Driver - { - Id = -1, - Name = "Larry David", - TeamId = Team.Ferrari, - CarNumber = 13 - }; + var larry = new Driver { Id = -1, Name = "Larry David", TeamId = Team.Ferrari, CarNumber = 13 }; bindingList.Add(larry); @@ -781,11 +740,7 @@ public virtual void Adding_entity_to_state_manager_of_different_type_than_local_ var count = bindingList.Count; context.Teams.Add( - new Team - { - Id = -1, - Name = "Wubbsy Racing" - }); + new Team { Id = -1, Name = "Wubbsy Racing" }); Assert.Equal(count, bindingList.Count); } @@ -813,20 +768,11 @@ public virtual void Sets_of_subtypes_can_still_be_sorted() { var testDrivers = context.Set(); testDrivers.Attach( - new TestDriver - { - Id = 3 - }); + new TestDriver { Id = 3 }); testDrivers.Attach( - new TestDriver - { - Id = 1 - }); + new TestDriver { Id = 1 }); testDrivers.Attach( - new TestDriver - { - Id = 4 - }); + new TestDriver { Id = 4 }); var bindingList = testDrivers.Local.ToBindingList(); @@ -846,20 +792,11 @@ public virtual void Sets_containing_instances_of_subtypes_can_still_be_sorted() using (var context = CreateF1Context()) { context.Drivers.Attach( - new TestDriver - { - Id = 3 - }); + new TestDriver { Id = 3 }); context.Drivers.Attach( - new TestDriver - { - Id = 1 - }); + new TestDriver { Id = 1 }); context.Drivers.Attach( - new TestDriver - { - Id = 4 - }); + new TestDriver { Id = 4 }); var bindingList = context.Drivers.Local.ToBindingList(); @@ -892,12 +829,7 @@ public virtual void Entity_added_to_context_is_added_to_navigation_property_bind var ferrari = context.Teams.Single(t => t.Id == Team.Ferrari); var navBindingList = ((IListSource)ferrari.Drivers).GetList(); - var larry = new Driver - { - Name = "Larry David", - TeamId = Team.Ferrari, - CarNumber = 13 - }; + var larry = new Driver { Name = "Larry David", TeamId = Team.Ferrari, CarNumber = 13 }; context.Drivers.Add(larry); Assert.True(navBindingList.Contains(larry)); @@ -913,13 +845,7 @@ public virtual void Entity_added_to_navigation_property_binding_list_is_added_to var navBindingList = ((IListSource)ferrari.Drivers).GetList(); var localDrivers = context.Drivers.Local; - var larry = new Driver - { - Id = -1, - Name = "Larry David", - TeamId = Team.Ferrari, - CarNumber = 13 - }; + var larry = new Driver { Id = -1, Name = "Larry David", TeamId = Team.Ferrari, CarNumber = 13 }; navBindingList.Add(larry); Assert.False(localDrivers.Contains(larry)); diff --git a/test/EFCore.Specification.Tests/FieldMappingTestBase.cs b/test/EFCore.Specification.Tests/FieldMappingTestBase.cs index 395f7a79a1a..98e3d0d269b 100644 --- a/test/EFCore.Specification.Tests/FieldMappingTestBase.cs +++ b/test/EFCore.Specification.Tests/FieldMappingTestBase.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel.DataAnnotations.Schema; @@ -14,6 +13,8 @@ using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; +// ReSharper disable ConvertToAutoProperty +// ReSharper disable ConvertToAutoPropertyWithPrivateSetter // ReSharper disable PossibleMultipleEnumeration // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore @@ -809,11 +810,8 @@ protected virtual void Projection(string property1, string property2, boo using (var context = CreateContext()) { var posts = context.Set().Select( - p => new - { - Prop1 = EF.Property(p, property1), - Prop2 = EF.Property(p, property2) - }).AsTracking(tracking).ToList(); + p => new { Prop1 = EF.Property(p, property1), Prop2 = EF.Property(p, property2) }).AsTracking(tracking) + .ToList(); Assert.Equal(4, posts.Count); @@ -1004,7 +1002,6 @@ protected class BlogFull : IBlogAccessor private List _posts; #pragma warning restore 649 - // ReSharper disable once ConvertToAutoProperty [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { @@ -1012,14 +1009,12 @@ public int Id set => _id = value; } - // ReSharper disable once ConvertToAutoProperty public string Title { get => _title; set => _title = value; } - // ReSharper disable once ConvertToAutoProperty public IEnumerable Posts { get => _posts; @@ -1062,7 +1057,6 @@ protected class PostFull : IPostAccessor private BlogFull _blog; #pragma warning restore 649 - // ReSharper disable once ConvertToAutoProperty [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { @@ -1070,21 +1064,18 @@ public int Id set => _id = value; } - // ReSharper disable once ConvertToAutoProperty public string Title { get => _title; set => _title = value; } - // ReSharper disable once ConvertToAutoProperty public int BlogId { get => _blogId; set => _blogId = value; } - // ReSharper disable once ConvertToAutoProperty public BlogFull Blog { get => _blog; @@ -1138,7 +1129,6 @@ int IBlogAccessor.AccessId set => _id = value; } - // ReSharper disable once ConvertToAutoProperty string IBlogAccessor.AccessTitle { get => _title; @@ -1168,14 +1158,12 @@ int IPostAccessor.AccessId set => _id = value; } - // ReSharper disable once ConvertToAutoProperty string IPostAccessor.AccessTitle { get => _title; set => _title = value; } - // ReSharper disable once ConvertToAutoProperty int IPostAccessor.AccessBlogId { get => _blogId; @@ -1195,7 +1183,6 @@ protected class BlogFullExplicit : IBlogAccessor private string _mytitle; private IList _myposts; - // ReSharper disable once ConvertToAutoProperty [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { @@ -1203,14 +1190,12 @@ public int Id set => _myid = value; } - // ReSharper disable once ConvertToAutoProperty public string Title { get => _mytitle; set => _mytitle = value; } - // ReSharper disable once ConvertToAutoProperty public IEnumerable Posts { get => _myposts; @@ -1243,7 +1228,6 @@ protected class PostFullExplicit : IPostAccessor private int _myblogId; private BlogFullExplicit _myblog; - // ReSharper disable once ConvertToAutoProperty [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { @@ -1251,21 +1235,18 @@ public int Id set => _myid = value; } - // ReSharper disable once ConvertToAutoProperty public string Title { get => _mytitle; set => _mytitle = value; } - // ReSharper disable once ConvertToAutoProperty public int BlogId { get => _myblogId; set => _myblogId = value; } - // ReSharper disable once ConvertToAutoProperty public BlogFullExplicit Blog { get => _myblog; @@ -1303,14 +1284,11 @@ protected class BlogReadOnly : IBlogAccessor private string _title; private ObservableCollection _posts; - // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id => _id; - // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter public string Title => _title; - // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter public IEnumerable Posts => _posts; int IBlogAccessor.AccessId @@ -1339,17 +1317,13 @@ protected class PostReadOnly : IPostAccessor private int _blogId; private BlogReadOnly _blog; - // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id => _id; - // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter public string Title => _title; - // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter public int BlogId => _blogId; - // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter public BlogReadOnly Blog => _blog; int IPostAccessor.AccessId @@ -1383,14 +1357,11 @@ protected class BlogReadOnlyExplicit : IBlogAccessor private string _mytitle; private Collection _myposts; - // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id => _myid; - // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter public string Title => _mytitle; - // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter public IEnumerable Posts => _myposts; int IBlogAccessor.AccessId @@ -1419,17 +1390,13 @@ protected class PostReadOnlyExplicit : IPostAccessor private int _myblogId; private BlogReadOnlyExplicit _myblog; - // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id => _myid; - // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter public string Title => _mytitle; - // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter public int BlogId => _myblogId; - // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter public BlogReadOnlyExplicit Blog => _myblog; int IPostAccessor.AccessId @@ -1660,7 +1627,6 @@ int IBlogAccessor.AccessId set => _id = value; } - // ReSharper disable once ConvertToAutoProperty string IBlogAccessor.AccessTitle { get => _title; @@ -1690,14 +1656,12 @@ int IPostAccessor.AccessId set => _id = value; } - // ReSharper disable once ConvertToAutoProperty string IPostAccessor.AccessTitle { get => _title; set => _title = value; } - // ReSharper disable once ConvertToAutoProperty int IPostAccessor.AccessBlogId { get => _blogId; @@ -1732,49 +1696,24 @@ protected static TBlog CreateBlogAndPosts( where TPost : IPostAccessor, new() { posts.Add( - new TPost - { - AccessId = 10, AccessTitle = "Post10" - }); + new TPost { AccessId = 10, AccessTitle = "Post10" }); posts.Add( - new TPost - { - AccessId = 11, AccessTitle = "Post11" - }); + new TPost { AccessId = 11, AccessTitle = "Post11" }); - return new TBlog - { - AccessId = 10, - AccessTitle = "Blog10", - AccessPosts = (IEnumerable)posts - }; + return new TBlog { AccessId = 10, AccessTitle = "Blog10", AccessPosts = (IEnumerable)posts }; } protected static IList CreatePostsAndBlog() where TBlog : IBlogAccessor, new() where TPost : IPostAccessor, new() { - var blog = new TBlog - { - AccessId = 20, - AccessTitle = "Blog20" - }; + var blog = new TBlog { AccessId = 20, AccessTitle = "Blog20" }; return new List { - new TPost - { - AccessId = 20, - AccessTitle = "Post20", - AccessBlog = blog - }, - new TPost - { - AccessId = 21, - AccessTitle = "Post21", - AccessBlog = blog - } + new TPost { AccessId = 20, AccessTitle = "Post20", AccessBlog = blog }, + new TPost { AccessId = 21, AccessTitle = "Post21", AccessBlog = blog } }; } @@ -2079,14 +2018,7 @@ protected override void Seed(PoolableDbContext context) } context.Add( - new LoginSession - { - User = new User2(), - Users = new List - { - new User2() - } - }); + new LoginSession { User = new User2(), Users = new List { new User2() } }); context.SaveChanges(); } diff --git a/test/EFCore.Specification.Tests/FindTestBase.cs b/test/EFCore.Specification.Tests/FindTestBase.cs index 9f0f8959ecb..10166a1fbce 100644 --- a/test/EFCore.Specification.Tests/FindTestBase.cs +++ b/test/EFCore.Specification.Tests/FindTestBase.cs @@ -30,10 +30,7 @@ public virtual void Find_int_key_tracked() using (var context = CreateContext()) { var entity = context.Attach( - new IntKey - { - Id = 88 - }).Entity; + new IntKey { Id = 88 }).Entity; Assert.Same(entity, Find(context, 88)); } @@ -63,10 +60,7 @@ public virtual void Find_nullable_int_key_tracked() using (var context = CreateContext()) { var entity = context.Attach( - new NullableIntKey - { - Id = 88 - }).Entity; + new NullableIntKey { Id = 88 }).Entity; Assert.Same(entity, Find(context, 88)); } @@ -96,10 +90,7 @@ public virtual void Find_string_key_tracked() using (var context = CreateContext()) { var entity = context.Attach( - new StringKey - { - Id = "Rabbit" - }).Entity; + new StringKey { Id = "Rabbit" }).Entity; Assert.Same(entity, Find(context, "Rabbit")); } @@ -129,11 +120,7 @@ public virtual void Find_composite_key_tracked() using (var context = CreateContext()) { var entity = context.Attach( - new CompositeKey - { - Id1 = 88, - Id2 = "Rabbit" - }).Entity; + new CompositeKey { Id1 = 88, Id2 = "Rabbit" }).Entity; Assert.Same(entity, Find(context, 88, "Rabbit")); } @@ -163,10 +150,7 @@ public virtual void Find_base_type_tracked() using (var context = CreateContext()) { var entity = context.Attach( - new BaseType - { - Id = 88 - }).Entity; + new BaseType { Id = 88 }).Entity; Assert.Same(entity, Find(context, 88)); } @@ -196,10 +180,7 @@ public virtual void Find_derived_type_tracked() using (var context = CreateContext()) { var entity = context.Attach( - new DerivedType - { - Id = 88 - }).Entity; + new DerivedType { Id = 88 }).Entity; Assert.Same(entity, Find(context, 88)); } @@ -231,10 +212,7 @@ public virtual void Find_base_type_using_derived_set_tracked() using (var context = CreateContext()) { context.Attach( - new BaseType - { - Id = 88 - }); + new BaseType { Id = 88 }); Assert.Null(Find(context, 88)); } @@ -255,10 +233,7 @@ public virtual void Find_derived_type_using_base_set_tracked() using (var context = CreateContext()) { var entity = context.Attach( - new DerivedType - { - Id = 88 - }).Entity; + new DerivedType { Id = 88 }).Entity; Assert.Same(entity, Find(context, 88)); } @@ -403,10 +378,7 @@ public virtual async Task Find_int_key_tracked_async() using (var context = CreateContext()) { var entity = context.Attach( - new IntKey - { - Id = 88 - }).Entity; + new IntKey { Id = 88 }).Entity; var valueTask = FindAsync(context, 88); Assert.True(valueTask.IsCompleted); @@ -438,10 +410,7 @@ public virtual async Task Find_nullable_int_key_tracked_async() using (var context = CreateContext()) { var entity = context.Attach( - new NullableIntKey - { - Id = 88 - }).Entity; + new NullableIntKey { Id = 88 }).Entity; Assert.Same(entity, await FindAsync(context, 88)); } @@ -471,10 +440,7 @@ public virtual async Task Find_string_key_tracked_async() using (var context = CreateContext()) { var entity = context.Attach( - new StringKey - { - Id = "Rabbit" - }).Entity; + new StringKey { Id = "Rabbit" }).Entity; Assert.Same(entity, await FindAsync(context, "Rabbit")); } @@ -504,11 +470,7 @@ public virtual async Task Find_composite_key_tracked_async() using (var context = CreateContext()) { var entity = context.Attach( - new CompositeKey - { - Id1 = 88, - Id2 = "Rabbit" - }).Entity; + new CompositeKey { Id1 = 88, Id2 = "Rabbit" }).Entity; Assert.Same(entity, await FindAsync(context, 88, "Rabbit")); } @@ -538,10 +500,7 @@ public virtual async Task Find_base_type_tracked_async() using (var context = CreateContext()) { var entity = context.Attach( - new BaseType - { - Id = 88 - }).Entity; + new BaseType { Id = 88 }).Entity; Assert.Same(entity, await FindAsync(context, 88)); } @@ -571,10 +530,7 @@ public virtual async Task Find_derived_type_tracked_async() using (var context = CreateContext()) { var entity = context.Attach( - new DerivedType - { - Id = 88 - }).Entity; + new DerivedType { Id = 88 }).Entity; Assert.Same(entity, await FindAsync(context, 88)); } @@ -606,10 +562,7 @@ public virtual async Task Find_base_type_using_derived_set_tracked_async() using (var context = CreateContext()) { context.Attach( - new BaseType - { - Id = 88 - }); + new BaseType { Id = 88 }); Assert.Null(await FindAsync(context, 88)); } @@ -630,10 +583,7 @@ public virtual async Task Find_derived_type_using_base_set_tracked_async() using (var context = CreateContext()) { var entity = context.Attach( - new DerivedType - { - Id = 88 - }).Entity; + new DerivedType { Id = 88 }).Entity; Assert.Same(entity, await FindAsync(context, 88)); } @@ -823,11 +773,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con modelBuilder.Entity(); modelBuilder.Entity(); modelBuilder.Entity().HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); modelBuilder.Entity(); modelBuilder.Entity(); modelBuilder.Entity().Property(typeof(int), "Id").ValueGeneratedNever(); @@ -836,44 +782,15 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con protected override void Seed(PoolableDbContext context) { context.AddRange( - new IntKey - { - Id = 77, - Foo = "Smokey" - }, - new NullableIntKey - { - Id = 77, - Foo = "Smokey" - }, - new StringKey - { - Id = "Cat", - Foo = "Alice" - }, - new CompositeKey - { - Id1 = 77, - Id2 = "Dog", - Foo = "Olive" - }, - new BaseType - { - Id = 77, - Foo = "Baxter" - }, - new DerivedType - { - Id = 78, - Foo = "Strawberry", - Boo = "Cheesecake" - }); + new IntKey { Id = 77, Foo = "Smokey" }, + new NullableIntKey { Id = 77, Foo = "Smokey" }, + new StringKey { Id = "Cat", Foo = "Alice" }, + new CompositeKey { Id1 = 77, Id2 = "Dog", Foo = "Olive" }, + new BaseType { Id = 77, Foo = "Baxter" }, + new DerivedType { Id = 78, Foo = "Strawberry", Boo = "Cheesecake" }); var entry = context.Entry( - new ShadowKey - { - Foo = "Clippy" - }); + new ShadowKey { Foo = "Clippy" }); entry.Property("Id").CurrentValue = 77; entry.State = EntityState.Added; diff --git a/test/EFCore.Specification.Tests/GraphUpdatesFixtureBase.cs b/test/EFCore.Specification.Tests/GraphUpdatesFixtureBase.cs index b93a1dfcaf1..2501c856518 100644 --- a/test/EFCore.Specification.Tests/GraphUpdatesFixtureBase.cs +++ b/test/EFCore.Specification.Tests/GraphUpdatesFixtureBase.cs @@ -156,10 +156,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasMany(e => e.CompositeChildren) .WithOne(e => e.Parent2) .HasForeignKey( - e => new - { - e.Parent2Id - }); + e => new { e.Parent2Id }); }); modelBuilder.Entity(); @@ -203,17 +200,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasMany(e => e.CompositeChildren) .WithOne(e => e.Parent) .HasPrincipalKey( - e => new - { - e.Id, - e.AlternateId - }) + e => new { e.Id, e.AlternateId }) .HasForeignKey( - e => new - { - e.ParentId, - e.ParentAlternateId - }); + e => new { e.ParentId, e.ParentAlternateId }); }); modelBuilder.Entity(); @@ -234,17 +223,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasMany(e => e.CompositeChildren) .WithOne(e => e.Parent) .HasPrincipalKey( - e => new - { - e.Id, - e.AlternateId - }) + e => new { e.Id, e.AlternateId }) .HasForeignKey( - e => new - { - e.ParentId, - e.ParentAlternateId - }); + e => new { e.ParentId, e.ParentAlternateId }); }); modelBuilder.Entity(); @@ -264,17 +245,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasOne(e => e.SingleComposite) .WithOne(e => e.Back) .HasForeignKey( - e => new - { - e.BackId, - e.BackAlternateId - }) + e => new { e.BackId, e.BackAlternateId }) .HasPrincipalKey( - e => new - { - e.Id, - e.AlternateId - }); + e => new { e.Id, e.AlternateId }); }); modelBuilder.Entity( @@ -292,17 +265,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasOne(e => e.SingleComposite) .WithOne(e => e.Back) .HasForeignKey( - e => new - { - e.BackId, - e.ParentAlternateId - }) + e => new { e.BackId, e.ParentAlternateId }) .HasPrincipalKey( - e => new - { - e.Id, - e.AlternateId - }); + e => new { e.Id, e.AlternateId }); }); modelBuilder.Entity(); @@ -355,26 +320,14 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb.Property(e => e.Id).ValueGeneratedNever(); eb.HasKey( - e => new - { - e.Id, - e.ParentAlternateId - }); + e => new { e.Id, e.ParentAlternateId }); eb.HasMany(e => e.CompositeChildren) .WithOne(e => e.Parent) .HasPrincipalKey( - e => new - { - e.Id, - e.ParentAlternateId - }) + e => new { e.Id, e.ParentAlternateId }) .HasForeignKey( - e => new - { - e.ParentId, - e.ParentAlternateId - }); + e => new { e.ParentId, e.ParentAlternateId }); }); modelBuilder.Entity( @@ -383,11 +336,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb.Property(e => e.Id).ValueGeneratedNever(); eb.HasKey( - e => new - { - e.Id, - e.ParentAlternateId - }); + e => new { e.Id, e.ParentAlternateId }); eb.HasOne(e => e.Root) .WithMany() @@ -422,224 +371,166 @@ protected virtual object CreateFullGraph() => new Root { AlternateId = RootAK, - RequiredChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new Required1 - { - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new Required2(), - new Required2() - } - }, - new Required1 - { - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new Required2(), - new Required2() - } - } - }, - OptionalChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new Optional1 - { - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new Optional2(), - new Optional2() - }, - CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) - }, - new Optional1 + RequiredChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) { - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + new Required1 { - new Optional2(), - new Optional2() - }, - CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) - } - }, - RequiredSingle = new RequiredSingle1 - { - Single = new RequiredSingle2() - }, - OptionalSingle = new OptionalSingle1 - { - Single = new OptionalSingle2() - }, - OptionalSingleDerived = new OptionalSingle1Derived - { - Single = new OptionalSingle2Derived() - }, - OptionalSingleMoreDerived = new OptionalSingle1MoreDerived - { - Single = new OptionalSingle2MoreDerived() - }, - RequiredNonPkSingle = new RequiredNonPkSingle1 - { - Single = new RequiredNonPkSingle2() - }, - RequiredNonPkSingleDerived = new RequiredNonPkSingle1Derived - { - Single = new RequiredNonPkSingle2Derived(), - Root = new Root() - }, - RequiredNonPkSingleMoreDerived = new RequiredNonPkSingle1MoreDerived - { - Single = new RequiredNonPkSingle2MoreDerived(), - Root = new Root(), - DerivedRoot = new Root() - }, - RequiredChildrenAk = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new RequiredAk1 - { - AlternateId = Guid.NewGuid(), - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new RequiredAk2 + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) { - AlternateId = Guid.NewGuid() - }, - new RequiredAk2 - { - AlternateId = Guid.NewGuid() + new Required2(), new Required2() } }, - CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) + new Required1 { - new RequiredComposite2(), - new RequiredComposite2() + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new Required2(), new Required2() + } } }, - new RequiredAk1 + OptionalChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) { - AlternateId = Guid.NewGuid(), - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + new Optional1 { - new RequiredAk2 + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) { - AlternateId = Guid.NewGuid() + new Optional2(), new Optional2() }, - new RequiredAk2 - { - AlternateId = Guid.NewGuid() - } + CompositeChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) }, - CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) + new Optional1 { - new RequiredComposite2(), - new RequiredComposite2() + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new Optional2(), new Optional2() + }, + CompositeChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) } - } - }, - OptionalChildrenAk = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new OptionalAk1 + }, + RequiredSingle = new RequiredSingle1 { Single = new RequiredSingle2() }, + OptionalSingle = new OptionalSingle1 { Single = new OptionalSingle2() }, + OptionalSingleDerived = new OptionalSingle1Derived { Single = new OptionalSingle2Derived() }, + OptionalSingleMoreDerived = new OptionalSingle1MoreDerived { Single = new OptionalSingle2MoreDerived() }, + RequiredNonPkSingle = new RequiredNonPkSingle1 { Single = new RequiredNonPkSingle2() }, + RequiredNonPkSingleDerived = + new RequiredNonPkSingle1Derived { Single = new RequiredNonPkSingle2Derived(), Root = new Root() }, + RequiredNonPkSingleMoreDerived = + new RequiredNonPkSingle1MoreDerived { - AlternateId = Guid.NewGuid(), - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + Single = new RequiredNonPkSingle2MoreDerived(), Root = new Root(), DerivedRoot = new Root() + }, + RequiredChildrenAk = + new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new RequiredAk1 { - new OptionalAk2 + AlternateId = Guid.NewGuid(), + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) { - AlternateId = Guid.NewGuid() + new RequiredAk2 { AlternateId = Guid.NewGuid() }, + new RequiredAk2 { AlternateId = Guid.NewGuid() } }, - new OptionalAk2 - { - AlternateId = Guid.NewGuid() - } + CompositeChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new RequiredComposite2(), new RequiredComposite2() + } }, - CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) + new RequiredAk1 { - new OptionalComposite2(), - new OptionalComposite2() + AlternateId = Guid.NewGuid(), + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new RequiredAk2 { AlternateId = Guid.NewGuid() }, + new RequiredAk2 { AlternateId = Guid.NewGuid() } + }, + CompositeChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new RequiredComposite2(), new RequiredComposite2() + } } }, - new OptionalAk1 + OptionalChildrenAk = + new ObservableHashSet(ReferenceEqualityComparer.Instance) { - AlternateId = Guid.NewGuid(), - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + new OptionalAk1 { - new OptionalAk2 + AlternateId = Guid.NewGuid(), + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) { - AlternateId = Guid.NewGuid() + new OptionalAk2 { AlternateId = Guid.NewGuid() }, + new OptionalAk2 { AlternateId = Guid.NewGuid() } }, - new OptionalAk2 - { - AlternateId = Guid.NewGuid() - } + CompositeChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new OptionalComposite2(), new OptionalComposite2() + } }, - CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) + new OptionalAk1 { - new OptionalComposite2(), - new OptionalComposite2() + AlternateId = Guid.NewGuid(), + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new OptionalAk2 { AlternateId = Guid.NewGuid() }, + new OptionalAk2 { AlternateId = Guid.NewGuid() } + }, + CompositeChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new OptionalComposite2(), new OptionalComposite2() + } } - } - }, - RequiredSingleAk = new RequiredSingleAk1 - { - AlternateId = Guid.NewGuid(), - Single = new RequiredSingleAk2 + }, + RequiredSingleAk = + new RequiredSingleAk1 { - AlternateId = Guid.NewGuid() + AlternateId = Guid.NewGuid(), + Single = new RequiredSingleAk2 { AlternateId = Guid.NewGuid() }, + SingleComposite = new RequiredSingleComposite2() }, - SingleComposite = new RequiredSingleComposite2() - }, - OptionalSingleAk = new OptionalSingleAk1 - { - AlternateId = Guid.NewGuid(), - Single = new OptionalSingleAk2 + OptionalSingleAk = + new OptionalSingleAk1 { - AlternateId = Guid.NewGuid() + AlternateId = Guid.NewGuid(), + Single = new OptionalSingleAk2 { AlternateId = Guid.NewGuid() }, + SingleComposite = new OptionalSingleComposite2() }, - SingleComposite = new OptionalSingleComposite2() - }, - OptionalSingleAkDerived = new OptionalSingleAk1Derived - { - AlternateId = Guid.NewGuid(), - Single = new OptionalSingleAk2Derived + OptionalSingleAkDerived = + new OptionalSingleAk1Derived { - AlternateId = Guid.NewGuid() - } - }, - OptionalSingleAkMoreDerived = new OptionalSingleAk1MoreDerived - { - AlternateId = Guid.NewGuid(), - Single = new OptionalSingleAk2MoreDerived + AlternateId = Guid.NewGuid(), Single = new OptionalSingleAk2Derived { AlternateId = Guid.NewGuid() } + }, + OptionalSingleAkMoreDerived = + new OptionalSingleAk1MoreDerived { - AlternateId = Guid.NewGuid() - } - }, - RequiredNonPkSingleAk = new RequiredNonPkSingleAk1 - { - AlternateId = Guid.NewGuid(), - Single = new RequiredNonPkSingleAk2 + AlternateId = Guid.NewGuid(), Single = new OptionalSingleAk2MoreDerived { AlternateId = Guid.NewGuid() } + }, + RequiredNonPkSingleAk = + new RequiredNonPkSingleAk1 { - AlternateId = Guid.NewGuid() - } - }, - RequiredNonPkSingleAkDerived = new RequiredNonPkSingleAk1Derived - { - AlternateId = Guid.NewGuid(), - Single = new RequiredNonPkSingleAk2Derived + AlternateId = Guid.NewGuid(), Single = new RequiredNonPkSingleAk2 { AlternateId = Guid.NewGuid() } + }, + RequiredNonPkSingleAkDerived = + new RequiredNonPkSingleAk1Derived { - AlternateId = Guid.NewGuid() + AlternateId = Guid.NewGuid(), + Single = new RequiredNonPkSingleAk2Derived { AlternateId = Guid.NewGuid() }, + Root = new Root() }, - Root = new Root() - }, - RequiredNonPkSingleAkMoreDerived = new RequiredNonPkSingleAk1MoreDerived - { - AlternateId = Guid.NewGuid(), - Single = new RequiredNonPkSingleAk2MoreDerived + RequiredNonPkSingleAkMoreDerived = + new RequiredNonPkSingleAk1MoreDerived { - AlternateId = Guid.NewGuid() + AlternateId = Guid.NewGuid(), + Single = new RequiredNonPkSingleAk2MoreDerived { AlternateId = Guid.NewGuid() }, + Root = new Root(), + DerivedRoot = new Root() }, - Root = new Root(), - DerivedRoot = new Root() - }, RequiredCompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) { new RequiredComposite1 @@ -647,14 +538,7 @@ protected virtual object CreateFullGraph() Id = 1, CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) { - new OptionalOverlapping2 - { - Id = 1 - }, - new OptionalOverlapping2 - { - Id = 2 - } + new OptionalOverlapping2 { Id = 1 }, new OptionalOverlapping2 { Id = 2 } } }, new RequiredComposite1 @@ -662,14 +546,7 @@ protected virtual object CreateFullGraph() Id = 2, CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) { - new OptionalOverlapping2 - { - Id = 3 - }, - new OptionalOverlapping2 - { - Id = 4 - } + new OptionalOverlapping2 { Id = 3 }, new OptionalOverlapping2 { Id = 4 } } } } @@ -682,28 +559,16 @@ protected override void Seed(PoolableDbContext context) context.ChangeTracker.TrackGraph(CreateFullGraph(), e => tracker.TrackEntity(e.Entry)); context.Add( - new BadOrder - { - BadCustomer = new BadCustomer() - }); + new BadOrder { BadCustomer = new BadCustomer() }); context.Add( - new ParentAsAChild - { - ChildAsAParent = new ChildAsAParent() - }); + new ParentAsAChild { ChildAsAParent = new ChildAsAParent() }); var bloog = new Bloog { Id = 515 }; context.AddRange( - new Poost - { - Id = 516, Bloog = bloog - }, - new Poost - { - Id = 517, Bloog = bloog - }); + new Poost { Id = 516, Bloog = bloog }, + new Poost { Id = 517, Bloog = bloog }); context.SaveChanges(); } @@ -810,9 +675,9 @@ protected Root LoadOptionalOneToManyGraph(DbContext context) protected Root LoadRequiredCompositeGraph(DbContext context) { - return context.Set() - .Include(e => e.RequiredCompositeChildren).ThenInclude(e => e.CompositeChildren) - .Single(IsTheRoot); + return context.Set() + .Include(e => e.RequiredCompositeChildren).ThenInclude(e => e.CompositeChildren) + .Single(IsTheRoot); } private static void AssertEntries(IReadOnlyList expectedEntries, IReadOnlyList actualEntries) @@ -929,17 +794,9 @@ private static void AssertKeys(Root expected, Root actual) Assert.Equal( expected.RequiredCompositeChildren.OrderBy(e => e.Id).Select( - e => new - { - e.Id, - e.ParentAlternateId - }), + e => new { e.Id, e.ParentAlternateId }), actual.RequiredCompositeChildren.OrderBy(e => e.Id).Select( - e => new - { - e.Id, - e.ParentAlternateId - })); + e => new { e.Id, e.ParentAlternateId })); Assert.Equal( expected.RequiredCompositeChildren.OrderBy(e => e.Id).Select(e => e.CompositeChildren.Count), @@ -948,18 +805,10 @@ private static void AssertKeys(Root expected, Root actual) Assert.Equal( expected.RequiredCompositeChildren.OrderBy(e => e.Id).SelectMany(e => e.CompositeChildren).OrderBy(e => e.Id) .Select( - e => new - { - e.Id, - e.ParentAlternateId - }), + e => new { e.Id, e.ParentAlternateId }), actual.RequiredCompositeChildren.OrderBy(e => e.Id).SelectMany(e => e.CompositeChildren).OrderBy(e => e.Id) .Select( - e => new - { - e.Id, - e.ParentAlternateId - })); + e => new { e.Id, e.ParentAlternateId })); } private static void AssertNavigations(Root root) @@ -2891,7 +2740,6 @@ public int Id set => SetWithNotify(value, ref _id); } - public int? BloogId { get => _bloogId; diff --git a/test/EFCore.Specification.Tests/GraphUpdatesTestBase.cs b/test/EFCore.Specification.Tests/GraphUpdatesTestBase.cs index aa2c270389d..1af72e3102f 100644 --- a/test/EFCore.Specification.Tests/GraphUpdatesTestBase.cs +++ b/test/EFCore.Specification.Tests/GraphUpdatesTestBase.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable AccessToDisposedClosure @@ -465,34 +464,13 @@ public virtual void Save_required_many_to_one_dependents( CascadeTiming? deleteOrphansTiming) { var newRoot = new Root(); - var new1 = new Required1 - { - Parent = newRoot - }; - var new1d = new Required1Derived - { - Parent = newRoot - }; - var new1dd = new Required1MoreDerived - { - Parent = newRoot - }; - var new2a = new Required2 - { - Parent = new1 - }; - var new2b = new Required2 - { - Parent = new1 - }; - var new2d = new Required2Derived - { - Parent = new1 - }; - var new2dd = new Required2MoreDerived - { - Parent = new1 - }; + var new1 = new Required1 { Parent = newRoot }; + var new1d = new Required1Derived { Parent = newRoot }; + var new1dd = new Required1MoreDerived { Parent = newRoot }; + var new2a = new Required2 { Parent = new1 }; + var new2b = new Required2 { Parent = new1 }; + var new2d = new Required2Derived { Parent = new1 }; + var new2dd = new Required2MoreDerived { Parent = new1 }; Root root = null; IReadOnlyList entries = null; @@ -1061,28 +1039,34 @@ public virtual void Save_removed_required_many_to_one_dependents( if ((changeMechanism & ChangeMechanism.Fk) != 0 && deleteOrphansTiming == CascadeTiming.Immediate) { - testCode = () => context.Entry(removed2).GetInfrastructure()[context.Entry(removed2).Property(e => e.ParentId).Metadata] = null; + testCode = () => + context.Entry(removed2).GetInfrastructure()[context.Entry(removed2).Property(e => e.ParentId).Metadata] = + null; } else { if ((changeMechanism & ChangeMechanism.Fk) != 0) { - context.Entry(removed2).GetInfrastructure()[context.Entry(removed2).Property(e => e.ParentId).Metadata] = null; - context.Entry(removed1).GetInfrastructure()[context.Entry(removed1).Property(e => e.ParentId).Metadata] = null; + context.Entry(removed2).GetInfrastructure()[context.Entry(removed2).Property(e => e.ParentId).Metadata] = + null; + context.Entry(removed1).GetInfrastructure()[context.Entry(removed1).Property(e => e.ParentId).Metadata] = + null; } testCode = deleteOrphansTiming == CascadeTiming.Immediate - ? (Action)(() => context.ChangeTracker.DetectChanges()) + ? () => context.ChangeTracker.DetectChanges() : deleteOrphansTiming == null - ? (Action)(() => context.ChangeTracker.CascadeChanges()) + ? () => context.ChangeTracker.CascadeChanges() : (Action)(() => context.SaveChanges()); } var message = Assert.Throws(testCode).Message; Assert.True( - message == CoreStrings.RelationshipConceptualNullSensitive(nameof(Root), nameof(Required1), "{ParentId: " + removed1.ParentId + "}") - || message == CoreStrings.RelationshipConceptualNullSensitive(nameof(Required1), nameof(Required2), "{ParentId: " + removed2.ParentId + "}")); + message == CoreStrings.RelationshipConceptualNullSensitive( + nameof(Root), nameof(Required1), "{ParentId: " + removed1.ParentId + "}") + || message == CoreStrings.RelationshipConceptualNullSensitive( + nameof(Required1), nameof(Required2), "{ParentId: " + removed2.ParentId + "}")); } else { @@ -1189,18 +1173,9 @@ public virtual void Save_changed_optional_one_to_one( var new2 = new OptionalSingle2(); var new2d = new OptionalSingle2Derived(); var new2dd = new OptionalSingle2MoreDerived(); - var new1 = new OptionalSingle1 - { - Single = new2 - }; - var new1d = new OptionalSingle1Derived - { - Single = new2d - }; - var new1dd = new OptionalSingle1MoreDerived - { - Single = new2dd - }; + var new1 = new OptionalSingle1 { Single = new2 }; + var new1d = new OptionalSingle1Derived { Single = new2d }; + var new1dd = new OptionalSingle1MoreDerived { Single = new2dd }; Root root = null; IReadOnlyList entries = null; OptionalSingle1 old1 = null; @@ -1385,10 +1360,7 @@ public virtual void Save_required_one_to_one_changed_by_reference( }); var new2 = new RequiredSingle2(); - var new1 = new RequiredSingle1 - { - Single = new2 - }; + var new1 = new RequiredSingle1 { Single = new2 }; ExecuteWithStrategyInTransaction( context => @@ -1528,26 +1500,12 @@ public virtual void Save_required_non_PK_one_to_one_changed_by_reference( var new2 = new RequiredNonPkSingle2(); var new2d = new RequiredNonPkSingle2Derived(); var new2dd = new RequiredNonPkSingle2MoreDerived(); - var new1 = new RequiredNonPkSingle1 - { - Single = new2 - }; - var new1d = new RequiredNonPkSingle1Derived - { - Single = new2d, - Root = new Root() - }; - var new1dd = new RequiredNonPkSingle1MoreDerived - { - Single = new2dd, - Root = new Root(), - DerivedRoot = new Root() - }; + var new1 = new RequiredNonPkSingle1 { Single = new2 }; + var new1d = new RequiredNonPkSingle1Derived { Single = new2d, Root = new Root() }; + var new1dd = new RequiredNonPkSingle1MoreDerived { Single = new2dd, Root = new Root(), DerivedRoot = new Root() }; var newRoot = new Root { - RequiredNonPkSingle = new1, - RequiredNonPkSingleDerived = new1d, - RequiredNonPkSingleMoreDerived = new1dd + RequiredNonPkSingle = new1, RequiredNonPkSingleDerived = new1d, RequiredNonPkSingleMoreDerived = new1dd }; Root root = null; IReadOnlyList entries = null; @@ -1629,16 +1587,17 @@ public virtual void Save_required_non_PK_one_to_one_changed_by_reference( || deleteOrphansTiming == CascadeTiming.Never) { var testCode = deleteOrphansTiming == CascadeTiming.Immediate - ? (Action)(() => context.ChangeTracker.DetectChanges()) + ? () => context.ChangeTracker.DetectChanges() : deleteOrphansTiming == null - ? (Action)(() => context.ChangeTracker.CascadeChanges()) + ? () => context.ChangeTracker.CascadeChanges() : (Action)(() => context.SaveChanges()); var message = Assert.Throws(testCode).Message; Assert.Equal( message, - CoreStrings.RelationshipConceptualNullSensitive(nameof(Root), nameof(RequiredNonPkSingle1), "{RootId: " + old1.RootId + "}")); + CoreStrings.RelationshipConceptualNullSensitive( + nameof(Root), nameof(RequiredNonPkSingle1), "{RootId: " + old1.RootId + "}")); } else { @@ -1924,16 +1883,17 @@ public virtual void Sever_required_non_PK_one_to_one( || deleteOrphansTiming == CascadeTiming.Never) { var testCode = deleteOrphansTiming == CascadeTiming.Immediate - ? (Action)(() => context.ChangeTracker.DetectChanges()) + ? () => context.ChangeTracker.DetectChanges() : deleteOrphansTiming == null - ? (Action)(() => context.ChangeTracker.CascadeChanges()) + ? () => context.ChangeTracker.CascadeChanges() : (Action)(() => context.SaveChanges()); var message = Assert.Throws(testCode).Message; Assert.Equal( message, - CoreStrings.RelationshipConceptualNullSensitive(nameof(Root), nameof(RequiredNonPkSingle1), "{RootId: " + old1.RootId + "}")); + CoreStrings.RelationshipConceptualNullSensitive( + nameof(Root), nameof(RequiredNonPkSingle1), "{RootId: " + old1.RootId + "}")); } else { @@ -2608,14 +2568,7 @@ public virtual void Reparent_one_to_many_overlapping( Parent = context.Set().Single(IsTheRoot), CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) { - new OptionalOverlapping2 - { - Id = 5 - }, - new OptionalOverlapping2 - { - Id = 6 - } + new OptionalOverlapping2 { Id = 5 }, new OptionalOverlapping2 { Id = 6 } } }; @@ -2842,36 +2795,15 @@ public virtual void Save_optional_many_to_one_dependents_with_alternate_key( bool useExistingEntities, CascadeTiming? deleteOrphansTiming) { - var new1 = new OptionalAk1 - { - AlternateId = Guid.NewGuid() - }; - var new1d = new OptionalAk1Derived - { - AlternateId = Guid.NewGuid() - }; - var new1dd = new OptionalAk1MoreDerived - { - AlternateId = Guid.NewGuid() - }; - var new2a = new OptionalAk2 - { - AlternateId = Guid.NewGuid() - }; - var new2b = new OptionalAk2 - { - AlternateId = Guid.NewGuid() - }; + var new1 = new OptionalAk1 { AlternateId = Guid.NewGuid() }; + var new1d = new OptionalAk1Derived { AlternateId = Guid.NewGuid() }; + var new1dd = new OptionalAk1MoreDerived { AlternateId = Guid.NewGuid() }; + var new2a = new OptionalAk2 { AlternateId = Guid.NewGuid() }; + var new2b = new OptionalAk2 { AlternateId = Guid.NewGuid() }; var new2ca = new OptionalComposite2(); var new2cb = new OptionalComposite2(); - var new2d = new OptionalAk2Derived - { - AlternateId = Guid.NewGuid() - }; - var new2dd = new OptionalAk2MoreDerived - { - AlternateId = Guid.NewGuid() - }; + var new2d = new OptionalAk2Derived { AlternateId = Guid.NewGuid() }; + var new2dd = new OptionalAk2MoreDerived { AlternateId = Guid.NewGuid() }; Root root = null; IReadOnlyList entries = null; @@ -3061,53 +2993,16 @@ public virtual void Save_required_many_to_one_dependents_with_alternate_key( bool useExistingEntities, CascadeTiming? deleteOrphansTiming) { - var newRoot = new Root - { - AlternateId = Guid.NewGuid() - }; - var new1 = new RequiredAk1 - { - AlternateId = Guid.NewGuid(), - Parent = newRoot - }; - var new1d = new RequiredAk1Derived - { - AlternateId = Guid.NewGuid(), - Parent = newRoot - }; - var new1dd = new RequiredAk1MoreDerived - { - AlternateId = Guid.NewGuid(), - Parent = newRoot - }; - var new2a = new RequiredAk2 - { - AlternateId = Guid.NewGuid(), - Parent = new1 - }; - var new2b = new RequiredAk2 - { - AlternateId = Guid.NewGuid(), - Parent = new1 - }; - var new2ca = new RequiredComposite2 - { - Parent = new1 - }; - var new2cb = new RequiredComposite2 - { - Parent = new1 - }; - var new2d = new RequiredAk2Derived - { - AlternateId = Guid.NewGuid(), - Parent = new1 - }; - var new2dd = new RequiredAk2MoreDerived - { - AlternateId = Guid.NewGuid(), - Parent = new1 - }; + var newRoot = new Root { AlternateId = Guid.NewGuid() }; + var new1 = new RequiredAk1 { AlternateId = Guid.NewGuid(), Parent = newRoot }; + var new1d = new RequiredAk1Derived { AlternateId = Guid.NewGuid(), Parent = newRoot }; + var new1dd = new RequiredAk1MoreDerived { AlternateId = Guid.NewGuid(), Parent = newRoot }; + var new2a = new RequiredAk2 { AlternateId = Guid.NewGuid(), Parent = new1 }; + var new2b = new RequiredAk2 { AlternateId = Guid.NewGuid(), Parent = new1 }; + var new2ca = new RequiredComposite2 { Parent = new1 }; + var new2cb = new RequiredComposite2 { Parent = new1 }; + var new2d = new RequiredAk2Derived { AlternateId = Guid.NewGuid(), Parent = new1 }; + var new2dd = new RequiredAk2MoreDerived { AlternateId = Guid.NewGuid(), Parent = new1 }; Root root = null; IReadOnlyList entries = null; @@ -3400,16 +3295,18 @@ public virtual void Save_removed_required_many_to_one_dependents_with_alternate_ || deleteOrphansTiming == CascadeTiming.Never) { var testCode = deleteOrphansTiming == CascadeTiming.Immediate - ? (Action)(() => context.ChangeTracker.DetectChanges()) + ? () => context.ChangeTracker.DetectChanges() : deleteOrphansTiming == null - ? (Action)(() => context.ChangeTracker.CascadeChanges()) + ? () => context.ChangeTracker.CascadeChanges() : (Action)(() => context.SaveChanges()); var message = Assert.Throws(testCode).Message; Assert.True( - message == CoreStrings.RelationshipConceptualNullSensitive(nameof(Root), nameof(RequiredAk1), "{ParentId: " + removed1.ParentId + "}") - || message == CoreStrings.RelationshipConceptualNullSensitive(nameof(RequiredAk1), nameof(RequiredAk2), "{ParentId: " + removed2.ParentId + "}")); + message == CoreStrings.RelationshipConceptualNullSensitive( + nameof(Root), nameof(RequiredAk1), "{ParentId: " + removed1.ParentId + "}") + || message == CoreStrings.RelationshipConceptualNullSensitive( + nameof(RequiredAk1), nameof(RequiredAk2), "{ParentId: " + removed2.ParentId + "}")); } else { @@ -3517,35 +3414,13 @@ public virtual void Save_changed_optional_one_to_one_with_alternate_key( bool useExistingEntities, CascadeTiming? deleteOrphansTiming) { - var new2 = new OptionalSingleAk2 - { - AlternateId = Guid.NewGuid() - }; - var new2d = new OptionalSingleAk2Derived - { - AlternateId = Guid.NewGuid() - }; - var new2dd = new OptionalSingleAk2MoreDerived - { - AlternateId = Guid.NewGuid() - }; + var new2 = new OptionalSingleAk2 { AlternateId = Guid.NewGuid() }; + var new2d = new OptionalSingleAk2Derived { AlternateId = Guid.NewGuid() }; + var new2dd = new OptionalSingleAk2MoreDerived { AlternateId = Guid.NewGuid() }; var new2c = new OptionalSingleComposite2(); - var new1 = new OptionalSingleAk1 - { - AlternateId = Guid.NewGuid(), - Single = new2, - SingleComposite = new2c - }; - var new1d = new OptionalSingleAk1Derived - { - AlternateId = Guid.NewGuid(), - Single = new2d - }; - var new1dd = new OptionalSingleAk1MoreDerived - { - AlternateId = Guid.NewGuid(), - Single = new2dd - }; + var new1 = new OptionalSingleAk1 { AlternateId = Guid.NewGuid(), Single = new2, SingleComposite = new2c }; + var new1d = new OptionalSingleAk1Derived { AlternateId = Guid.NewGuid(), Single = new2d }; + var new1dd = new OptionalSingleAk1MoreDerived { AlternateId = Guid.NewGuid(), Single = new2dd }; Root root = null; IReadOnlyList entries = null; OptionalSingleAk1 old1 = null; @@ -3693,35 +3568,13 @@ public virtual void Save_changed_optional_one_to_one_with_alternate_key( [ConditionalFact] public virtual void Save_changed_optional_one_to_one_with_alternate_key_in_store() { - var new2 = new OptionalSingleAk2 - { - AlternateId = Guid.NewGuid() - }; - var new2d = new OptionalSingleAk2Derived - { - AlternateId = Guid.NewGuid() - }; - var new2dd = new OptionalSingleAk2MoreDerived - { - AlternateId = Guid.NewGuid() - }; + var new2 = new OptionalSingleAk2 { AlternateId = Guid.NewGuid() }; + var new2d = new OptionalSingleAk2Derived { AlternateId = Guid.NewGuid() }; + var new2dd = new OptionalSingleAk2MoreDerived { AlternateId = Guid.NewGuid() }; var new2c = new OptionalSingleComposite2(); - var new1 = new OptionalSingleAk1 - { - AlternateId = Guid.NewGuid(), - Single = new2, - SingleComposite = new2c - }; - var new1d = new OptionalSingleAk1Derived - { - AlternateId = Guid.NewGuid(), - Single = new2d - }; - var new1dd = new OptionalSingleAk1MoreDerived - { - AlternateId = Guid.NewGuid(), - Single = new2dd - }; + var new1 = new OptionalSingleAk1 { AlternateId = Guid.NewGuid(), Single = new2, SingleComposite = new2c }; + var new1d = new OptionalSingleAk1Derived { AlternateId = Guid.NewGuid(), Single = new2d }; + var new1dd = new OptionalSingleAk1MoreDerived { AlternateId = Guid.NewGuid(), Single = new2dd }; Root root = null; IReadOnlyList entries = null; OptionalSingleAk1 old1 = null; @@ -3899,22 +3752,10 @@ public virtual void Save_required_one_to_one_changed_by_reference_with_alternate bool useExistingEntities, CascadeTiming? deleteOrphansTiming) { - var new2 = new RequiredSingleAk2 - { - AlternateId = Guid.NewGuid() - }; + var new2 = new RequiredSingleAk2 { AlternateId = Guid.NewGuid() }; var new2c = new RequiredSingleComposite2(); - var new1 = new RequiredSingleAk1 - { - AlternateId = Guid.NewGuid(), - Single = new2, - SingleComposite = new2c - }; - var newRoot = new Root - { - AlternateId = Guid.NewGuid(), - RequiredSingleAk = new1 - }; + var new1 = new RequiredSingleAk1 { AlternateId = Guid.NewGuid(), Single = new2, SingleComposite = new2c }; + var newRoot = new Root { AlternateId = Guid.NewGuid(), RequiredSingleAk = new1 }; Root root = null; IReadOnlyList entries = null; RequiredSingleAk1 old1 = null; @@ -3970,16 +3811,17 @@ public virtual void Save_required_one_to_one_changed_by_reference_with_alternate || deleteOrphansTiming == CascadeTiming.Never) { var testCode = deleteOrphansTiming == CascadeTiming.Immediate - ? (Action)(() => context.ChangeTracker.DetectChanges()) + ? () => context.ChangeTracker.DetectChanges() : deleteOrphansTiming == null - ? (Action)(() => context.ChangeTracker.CascadeChanges()) + ? () => context.ChangeTracker.CascadeChanges() : (Action)(() => context.SaveChanges()); var message = Assert.Throws(testCode).Message; Assert.Equal( message, - CoreStrings.RelationshipConceptualNullSensitive(nameof(Root), nameof(RequiredSingleAk1), "{RootId: " + old1.RootId + "}")); + CoreStrings.RelationshipConceptualNullSensitive( + nameof(Root), nameof(RequiredSingleAk1), "{RootId: " + old1.RootId + "}")); } else { @@ -4092,35 +3934,14 @@ public virtual void Save_required_non_PK_one_to_one_changed_by_reference_with_al bool useExistingEntities, CascadeTiming? deleteOrphansTiming) { - var new2 = new RequiredNonPkSingleAk2 - { - AlternateId = Guid.NewGuid() - }; - var new2d = new RequiredNonPkSingleAk2Derived - { - AlternateId = Guid.NewGuid() - }; - var new2dd = new RequiredNonPkSingleAk2MoreDerived - { - AlternateId = Guid.NewGuid() - }; - var new1 = new RequiredNonPkSingleAk1 - { - AlternateId = Guid.NewGuid(), - Single = new2 - }; - var new1d = new RequiredNonPkSingleAk1Derived - { - AlternateId = Guid.NewGuid(), - Single = new2d, - Root = new Root() - }; + var new2 = new RequiredNonPkSingleAk2 { AlternateId = Guid.NewGuid() }; + var new2d = new RequiredNonPkSingleAk2Derived { AlternateId = Guid.NewGuid() }; + var new2dd = new RequiredNonPkSingleAk2MoreDerived { AlternateId = Guid.NewGuid() }; + var new1 = new RequiredNonPkSingleAk1 { AlternateId = Guid.NewGuid(), Single = new2 }; + var new1d = new RequiredNonPkSingleAk1Derived { AlternateId = Guid.NewGuid(), Single = new2d, Root = new Root() }; var new1dd = new RequiredNonPkSingleAk1MoreDerived { - AlternateId = Guid.NewGuid(), - Single = new2dd, - Root = new Root(), - DerivedRoot = new Root() + AlternateId = Guid.NewGuid(), Single = new2dd, Root = new Root(), DerivedRoot = new Root() }; var newRoot = new Root { @@ -4209,16 +4030,17 @@ public virtual void Save_required_non_PK_one_to_one_changed_by_reference_with_al || deleteOrphansTiming == CascadeTiming.Never) { var testCode = deleteOrphansTiming == CascadeTiming.Immediate - ? (Action)(() => context.ChangeTracker.DetectChanges()) + ? () => context.ChangeTracker.DetectChanges() : deleteOrphansTiming == null - ? (Action)(() => context.ChangeTracker.CascadeChanges()) + ? () => context.ChangeTracker.CascadeChanges() : (Action)(() => context.SaveChanges()); var message = Assert.Throws(testCode).Message; Assert.Equal( message, - CoreStrings.RelationshipConceptualNullSensitive(nameof(Root), nameof(RequiredNonPkSingleAk1), "{RootId: " + old1.RootId + "}")); + CoreStrings.RelationshipConceptualNullSensitive( + nameof(Root), nameof(RequiredNonPkSingleAk1), "{RootId: " + old1.RootId + "}")); } else { @@ -4435,16 +4257,17 @@ public virtual void Sever_required_one_to_one_with_alternate_key( || deleteOrphansTiming == CascadeTiming.Never) { var testCode = deleteOrphansTiming == CascadeTiming.Immediate - ? (Action)(() => context.ChangeTracker.DetectChanges()) + ? () => context.ChangeTracker.DetectChanges() : deleteOrphansTiming == null - ? (Action)(() => context.ChangeTracker.CascadeChanges()) + ? () => context.ChangeTracker.CascadeChanges() : (Action)(() => context.SaveChanges()); var message = Assert.Throws(testCode).Message; Assert.Equal( message, - CoreStrings.RelationshipConceptualNullSensitive(nameof(Root), nameof(RequiredSingleAk1), "{RootId: " + old1.RootId + "}")); + CoreStrings.RelationshipConceptualNullSensitive( + nameof(Root), nameof(RequiredSingleAk1), "{RootId: " + old1.RootId + "}")); } else { @@ -4536,16 +4359,17 @@ public virtual void Sever_required_non_PK_one_to_one_with_alternate_key( || deleteOrphansTiming == CascadeTiming.Never) { var testCode = deleteOrphansTiming == CascadeTiming.Immediate - ? (Action)(() => context.ChangeTracker.DetectChanges()) + ? () => context.ChangeTracker.DetectChanges() : deleteOrphansTiming == null - ? (Action)(() => context.ChangeTracker.CascadeChanges()) + ? () => context.ChangeTracker.CascadeChanges() : (Action)(() => context.SaveChanges()); var message = Assert.Throws(testCode).Message; Assert.Equal( message, - CoreStrings.RelationshipConceptualNullSensitive(nameof(Root), nameof(RequiredNonPkSingleAk1), "{RootId: " + old1.RootId + "}")); + CoreStrings.RelationshipConceptualNullSensitive( + nameof(Root), nameof(RequiredNonPkSingleAk1), "{RootId: " + old1.RootId + "}")); } else { @@ -4648,10 +4472,7 @@ public virtual void Reparent_optional_one_to_one_with_alternate_key( bool useExistingRoot, CascadeTiming? deleteOrphansTiming) { - var newRoot = new Root - { - AlternateId = Guid.NewGuid() - }; + var newRoot = new Root { AlternateId = Guid.NewGuid() }; Root root = null; OptionalSingleAk1 old1 = null; OptionalSingleAk2 old2 = null; @@ -4793,10 +4614,7 @@ public virtual void Reparent_required_one_to_one_with_alternate_key( bool useExistingRoot, CascadeTiming? deleteOrphansTiming) { - var newRoot = new Root - { - AlternateId = Guid.NewGuid() - }; + var newRoot = new Root { AlternateId = Guid.NewGuid() }; Root root = null; RequiredSingleAk1 old1 = null; RequiredSingleAk2 old2 = null; @@ -4938,10 +4756,7 @@ public virtual void Reparent_required_non_PK_one_to_one_with_alternate_key( bool useExistingRoot, CascadeTiming? deleteOrphansTiming) { - var newRoot = new Root - { - AlternateId = Guid.NewGuid() - }; + var newRoot = new Root { AlternateId = Guid.NewGuid() }; Root root = null; RequiredNonPkSingleAk1 old1 = null; RequiredNonPkSingleAk2 old2 = null; @@ -5058,7 +4873,10 @@ public virtual void Required_many_to_one_dependents_are_cascade_deleted( context.ChangeTracker.CascadeChanges(); - Assert.True(cascadeRemoved.All(e => context.Entry(e).State == (Fixture.ForceClientNoAction ? EntityState.Unchanged : EntityState.Deleted))); + Assert.True( + cascadeRemoved.All( + e => context.Entry(e).State + == (Fixture.ForceClientNoAction ? EntityState.Unchanged : EntityState.Deleted))); } if (Fixture.ForceClientNoAction) @@ -5214,7 +5032,10 @@ public virtual void Optional_many_to_one_dependents_are_orphaned( context.ChangeTracker.CascadeChanges(); - Assert.True(orphaned.All(e => context.Entry(e).State == (Fixture.ForceClientNoAction ? EntityState.Unchanged : EntityState.Modified))); + Assert.True( + orphaned.All( + e => context.Entry(e).State + == (Fixture.ForceClientNoAction ? EntityState.Unchanged : EntityState.Modified))); } if (Fixture.ForceClientNoAction) @@ -5361,7 +5182,8 @@ public virtual void Optional_one_to_one_are_orphaned( context.ChangeTracker.CascadeChanges(); - Assert.Equal(Fixture.ForceClientNoAction ? EntityState.Unchanged : EntityState.Modified, context.Entry(orphaned).State); + Assert.Equal( + Fixture.ForceClientNoAction ? EntityState.Unchanged : EntityState.Modified, context.Entry(orphaned).State); } if (Fixture.ForceClientNoAction) @@ -5501,7 +5323,8 @@ public virtual void Required_one_to_one_are_cascade_deleted( context.ChangeTracker.CascadeChanges(); - Assert.Equal(Fixture.ForceClientNoAction ? EntityState.Unchanged : EntityState.Deleted, context.Entry(orphaned).State); + Assert.Equal( + Fixture.ForceClientNoAction ? EntityState.Unchanged : EntityState.Deleted, context.Entry(orphaned).State); } if (Fixture.ForceClientNoAction) @@ -5646,7 +5469,8 @@ public virtual void Required_non_PK_one_to_one_are_cascade_deleted( context.ChangeTracker.CascadeChanges(); - Assert.Equal(Fixture.ForceClientNoAction ? EntityState.Unchanged : EntityState.Deleted, context.Entry(orphaned).State); + Assert.Equal( + Fixture.ForceClientNoAction ? EntityState.Unchanged : EntityState.Deleted, context.Entry(orphaned).State); } if (Fixture.ForceClientNoAction) @@ -5793,7 +5617,10 @@ public virtual void Optional_many_to_one_dependents_with_alternate_key_are_orpha context.ChangeTracker.CascadeChanges(); - Assert.True(orphaned.All(e => context.Entry(e).State == (Fixture.ForceClientNoAction ? EntityState.Unchanged : EntityState.Modified))); + Assert.True( + orphaned.All( + e => context.Entry(e).State + == (Fixture.ForceClientNoAction ? EntityState.Unchanged : EntityState.Modified))); } Assert.True(context.ChangeTracker.HasChanges()); @@ -5897,7 +5724,6 @@ public virtual void Required_many_to_one_dependents_with_alternate_key_are_casca Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Deleted)); Assert.True(cascadeRemovedC.All(e => context.Entry(e).State == EntityState.Deleted)); } - } if (Fixture.ForceClientNoAction) @@ -6186,7 +6012,8 @@ public virtual void Required_non_PK_one_to_one_with_alternate_key_are_cascade_de context.ChangeTracker.CascadeChanges(); - Assert.Equal(Fixture.ForceClientNoAction ? EntityState.Unchanged : EntityState.Deleted, context.Entry(orphaned).State); + Assert.Equal( + Fixture.ForceClientNoAction ? EntityState.Unchanged : EntityState.Deleted, context.Entry(orphaned).State); } if (Fixture.ForceClientNoAction) diff --git a/test/EFCore.Specification.Tests/InterceptionTestBase.cs b/test/EFCore.Specification.Tests/InterceptionTestBase.cs index 3a63e74c56a..f7cd6b2a6fe 100644 --- a/test/EFCore.Specification.Tests/InterceptionTestBase.cs +++ b/test/EFCore.Specification.Tests/InterceptionTestBase.cs @@ -50,26 +50,14 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder .Entity() .HasData( - new Singularity - { - Id = 77, Type = "Black Hole" - }, - new Singularity - { - Id = 88, Type = "Bing Bang" - }); + new Singularity { Id = 77, Type = "Black Hole" }, + new Singularity { Id = 88, Type = "Bing Bang" }); modelBuilder .Entity() .HasData( - new Brane - { - Id = 77, Type = "Black Hole?" - }, - new Brane - { - Id = 88, Type = "Bing Bang?" - }); + new Brane { Id = 77, Type = "Black Hole?" }, + new Brane { Id = 88, Type = "Bing Bang?" }); } } @@ -91,18 +79,12 @@ protected void AssertSql(string expected, string actual) public UniverseContext CreateContext(IInterceptor appInterceptor, string connectionString) => new UniverseContext( Fixture.CreateOptions( - new[] - { - appInterceptor - }, Enumerable.Empty())); + new[] { appInterceptor }, Enumerable.Empty())); public UniverseContext CreateContext(IInterceptor appInterceptor, params IInterceptor[] injectedInterceptors) => new UniverseContext( Fixture.CreateOptions( - new[] - { - appInterceptor - }, injectedInterceptors)); + new[] { appInterceptor }, injectedInterceptors)); public UniverseContext CreateContext( IEnumerable appInterceptors, @@ -114,7 +96,7 @@ public interface ITestDiagnosticListener : IDisposable void AssertEventsInOrder(params string[] eventNames); } - public class NullDiagnosticListener: ITestDiagnosticListener + public class NullDiagnosticListener : ITestDiagnosticListener { public void AssertEventsInOrder(params string[] eventNames) { @@ -125,7 +107,8 @@ public void Dispose() } } - public class TestDiagnosticListener : ITestDiagnosticListener, IObserver, IObserver> + public class TestDiagnosticListener : ITestDiagnosticListener, IObserver, + IObserver> { private readonly DbContextId _contextId; private readonly IDisposable _subscription; @@ -145,7 +128,6 @@ public void OnError(Exception error) { } - public void AssertEventsInOrder(params string[] eventNames) { Assert.True(_events.Count >= eventNames.Length); diff --git a/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs b/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs index 65dbd728969..301a89f175d 100644 --- a/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs +++ b/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs @@ -60,7 +60,8 @@ public virtual void Lazy_load_collection(EntityState state, bool useAttach, bool Assert.Equal( CoreStrings.WarningAsErrorTemplate( CoreEventId.LazyLoadOnDisposedContextWarning.ToString(), - CoreResources.LogLazyLoadOnDisposedContext(new TestLogger()).GenerateMessage("Children", "ParentProxy"), + CoreResources.LogLazyLoadOnDisposedContext(new TestLogger()) + .GenerateMessage("Children", "ParentProxy"), "CoreEventId.LazyLoadOnDisposedContextWarning"), Assert.Throws( () => parent.Children).Message); @@ -134,7 +135,8 @@ public virtual void Lazy_load_many_to_one_reference_to_principal(EntityState sta Assert.Equal( CoreStrings.WarningAsErrorTemplate( CoreEventId.LazyLoadOnDisposedContextWarning.ToString(), - CoreResources.LogLazyLoadOnDisposedContext(new TestLogger()).GenerateMessage("Parent", "ChildProxy"), + CoreResources.LogLazyLoadOnDisposedContext(new TestLogger()) + .GenerateMessage("Parent", "ChildProxy"), "CoreEventId.LazyLoadOnDisposedContextWarning"), Assert.Throws( () => child.Parent).Message); @@ -210,7 +212,8 @@ public virtual void Lazy_load_one_to_one_reference_to_principal(EntityState stat Assert.Equal( CoreStrings.WarningAsErrorTemplate( CoreEventId.LazyLoadOnDisposedContextWarning.ToString(), - CoreResources.LogLazyLoadOnDisposedContext(new TestLogger()).GenerateMessage("Parent", "SingleProxy"), + CoreResources.LogLazyLoadOnDisposedContext(new TestLogger()) + .GenerateMessage("Parent", "SingleProxy"), "CoreEventId.LazyLoadOnDisposedContextWarning"), Assert.Throws( () => single.Parent).Message); @@ -286,7 +289,8 @@ public virtual void Lazy_load_one_to_one_reference_to_dependent(EntityState stat Assert.Equal( CoreStrings.WarningAsErrorTemplate( CoreEventId.LazyLoadOnDisposedContextWarning.ToString(), - CoreResources.LogLazyLoadOnDisposedContext(new TestLogger()).GenerateMessage("Single", "ParentProxy"), + CoreResources.LogLazyLoadOnDisposedContext(new TestLogger()) + .GenerateMessage("Single", "ParentProxy"), "CoreEventId.LazyLoadOnDisposedContextWarning"), Assert.Throws( () => parent.Single).Message); @@ -553,10 +557,7 @@ public virtual void Lazy_load_many_to_one_reference_to_principal_changed_found_F child.ParentId = 797; child.Parent = parent; - parent.Children = new List - { - child - }; + parent.Children = new List { child }; context.Attach(child); context.Attach(parent); @@ -820,7 +821,8 @@ public virtual void Lazy_load_collection_already_loaded(EntityState state, Casca [InlineData(EntityState.Unchanged, CascadeTiming.Never)] [InlineData(EntityState.Modified, CascadeTiming.Never)] [InlineData(EntityState.Deleted, CascadeTiming.Never)] - public virtual void Lazy_load_many_to_one_reference_to_principal_already_loaded(EntityState state, CascadeTiming cascadeDeleteTiming) + public virtual void Lazy_load_many_to_one_reference_to_principal_already_loaded( + EntityState state, CascadeTiming cascadeDeleteTiming) { using (var context = CreateContext(lazyLoadingEnabled: true)) { @@ -1659,7 +1661,8 @@ public virtual void Lazy_load_collection_for_no_tracking_throws() Assert.Equal( CoreStrings.WarningAsErrorTemplate( CoreEventId.DetachedLazyLoadingWarning.ToString(), - CoreResources.LogDetachedLazyLoading(new TestLogger()).GenerateMessage(nameof(Parent.Children), "ParentProxy"), + CoreResources.LogDetachedLazyLoading(new TestLogger()) + .GenerateMessage(nameof(Parent.Children), "ParentProxy"), "CoreEventId.DetachedLazyLoadingWarning"), Assert.Throws( () => parent.Children).Message); @@ -1676,7 +1679,8 @@ public virtual void Lazy_load_reference_to_principal_for_no_tracking_throws() Assert.Equal( CoreStrings.WarningAsErrorTemplate( CoreEventId.DetachedLazyLoadingWarning.ToString(), - CoreResources.LogDetachedLazyLoading(new TestLogger()).GenerateMessage(nameof(Child.Parent), "ChildProxy"), + CoreResources.LogDetachedLazyLoading(new TestLogger()) + .GenerateMessage(nameof(Child.Parent), "ChildProxy"), "CoreEventId.DetachedLazyLoadingWarning"), Assert.Throws( () => child.Parent).Message); @@ -1693,7 +1697,8 @@ public virtual void Lazy_load_reference_to_dependent_for_no_tracking_throws() Assert.Equal( CoreStrings.WarningAsErrorTemplate( CoreEventId.DetachedLazyLoadingWarning.ToString(), - CoreResources.LogDetachedLazyLoading(new TestLogger()).GenerateMessage(nameof(Parent.Single), "ParentProxy"), + CoreResources.LogDetachedLazyLoading(new TestLogger()) + .GenerateMessage(nameof(Parent.Single), "ParentProxy"), "CoreEventId.DetachedLazyLoadingWarning"), Assert.Throws( () => parent.Single).Message); @@ -2257,32 +2262,16 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasMany(e => e.ChildrenCompositeKey) .WithOne(e => e.Parent) .HasPrincipalKey( - e => new - { - e.AlternateId, - e.Id - }) + e => new { e.AlternateId, e.Id }) .HasForeignKey( - e => new - { - e.ParentAlternateId, - e.ParentId - }); + e => new { e.ParentAlternateId, e.ParentId }); b.HasOne(e => e.SingleCompositeKey) .WithOne(e => e.Parent) .HasPrincipalKey( - e => new - { - e.AlternateId, - e.Id - }) + e => new { e.AlternateId, e.Id }) .HasForeignKey( - e => new - { - e.ParentAlternateId, - e.ParentId - }); + e => new { e.ParentAlternateId, e.ParentId }); }); modelBuilder.Entity( @@ -2371,174 +2360,58 @@ protected override void Seed(DbContext context) { Id = 707, AlternateId = "Root", - Children = new List - { - new Child - { - Id = 11 - }, - new Child - { - Id = 12 - } - }, - SinglePkToPk = new SinglePkToPk - { - Id = 707 - }, - Single = new Single - { - Id = 21 - }, - ChildrenAk = new List - { - new ChildAk - { - Id = 31 - }, - new ChildAk - { - Id = 32 - } - }, - SingleAk = new SingleAk - { - Id = 42 - }, - ChildrenShadowFk = new List - { - new ChildShadowFk - { - Id = 51 - }, - new ChildShadowFk - { - Id = 52 - } - }, - SingleShadowFk = new SingleShadowFk - { - Id = 62 - }, + Children = new List { new Child { Id = 11 }, new Child { Id = 12 } }, + SinglePkToPk = new SinglePkToPk { Id = 707 }, + Single = new Single { Id = 21 }, + ChildrenAk = new List { new ChildAk { Id = 31 }, new ChildAk { Id = 32 } }, + SingleAk = new SingleAk { Id = 42 }, + ChildrenShadowFk = new List { new ChildShadowFk { Id = 51 }, new ChildShadowFk { Id = 52 } }, + SingleShadowFk = new SingleShadowFk { Id = 62 }, ChildrenCompositeKey = new List { - new ChildCompositeKey - { - Id = 51 - }, - new ChildCompositeKey - { - Id = 52 - } + new ChildCompositeKey { Id = 51 }, new ChildCompositeKey { Id = 52 } }, - SingleCompositeKey = new SingleCompositeKey - { - Id = 62 - } + SingleCompositeKey = new SingleCompositeKey { Id = 62 } }); context.Add( new Blog { - Writer = new Person - { - FirstName = "firstNameWriter0", - LastName = "lastNameWriter0" - }, - Reader = new Person - { - FirstName = "firstNameReader0", - LastName = "lastNameReader0" - }, - Host = new Host - { - HostName = "127.0.0.1" - } + Writer = new Person { FirstName = "firstNameWriter0", LastName = "lastNameWriter0" }, + Reader = new Person { FirstName = "firstNameReader0", LastName = "lastNameReader0" }, + Host = new Host { HostName = "127.0.0.1" } }); context.Add( new Blog { - Writer = new Person - { - FirstName = "firstNameWriter1", - LastName = "lastNameWriter1" - }, - Reader = new Person - { - FirstName = "firstNameReader1", - LastName = "lastNameReader1" - }, - Host = new Host - { - HostName = "127.0.0.2" - } + Writer = new Person { FirstName = "firstNameWriter1", LastName = "lastNameWriter1" }, + Reader = new Person { FirstName = "firstNameReader1", LastName = "lastNameReader1" }, + Host = new Host { HostName = "127.0.0.2" } }); context.Add( new Blog { - Writer = new Person - { - FirstName = "firstNameWriter2", - LastName = "lastNameWriter2" - }, - Reader = new Person - { - FirstName = "firstNameReader2", - LastName = "lastNameReader2" - }, - Host = new Host - { - HostName = "127.0.0.3" - } + Writer = new Person { FirstName = "firstNameWriter2", LastName = "lastNameWriter2" }, + Reader = new Person { FirstName = "firstNameReader2", LastName = "lastNameReader2" }, + Host = new Host { HostName = "127.0.0.3" } }); - var nose1 = new Nose - { - Size = "Small" - }; + var nose1 = new Nose { Size = "Small" }; - var nose2 = new Nose - { - Size = "Medium" - }; + var nose2 = new Nose { Size = "Medium" }; - var nose3 = new Nose - { - Size = "Large" - }; + var nose3 = new Nose { Size = "Large" }; context.Add( - new Entity - { - BaseNoses = new List - { - nose1, - nose2, - nose3 - } - }); + new Entity { BaseNoses = new List { nose1, nose2, nose3 } }); context.Add( - new Parson - { - ParsonNoses = new List - { - nose2, - nose3 - } - }); + new Parson { ParsonNoses = new List { nose2, nose3 } }); context.Add( - new Company - { - CompanyNoses = new List - { - nose1, - nose3 - } - }); + new Company { CompanyNoses = new List { nose1, nose3 } }); context.Add( new Applicant( @@ -2547,11 +2420,7 @@ protected override void Seed(DbContext context) context.Add( new Pyrson(new FullName(FirstName.Create("Amila"), LastName.Create("Udayanga"))) { - Address = new Address - { - Line1 = "Line1", - Line2 = "Line2" - } + Address = new Address { Line1 = "Line1", Line2 = "Line2" } }); context.SaveChanges(); diff --git a/test/EFCore.Specification.Tests/LoadTestBase.cs b/test/EFCore.Specification.Tests/LoadTestBase.cs index db642b3fdba..c63c7124bed 100644 --- a/test/EFCore.Specification.Tests/LoadTestBase.cs +++ b/test/EFCore.Specification.Tests/LoadTestBase.cs @@ -275,11 +275,7 @@ public virtual void Lazy_load_many_to_one_reference_to_principal_null_FK(EntityS var changeDetector = (ChangeDetectorProxy)context.GetService(); var child = context.Attach( - new Child(context.GetService().Load) - { - Id = 767, - ParentId = null - }).Entity; + new Child(context.GetService().Load) { Id = 767, ParentId = null }).Entity; ClearLog(); @@ -316,11 +312,7 @@ public virtual void Lazy_load_one_to_one_reference_to_principal_null_FK(EntitySt var changeDetector = (ChangeDetectorProxy)context.GetService(); var single = context.Attach( - new Single(context.GetService().Load) - { - Id = 767, - ParentId = null - }).Entity; + new Single(context.GetService().Load) { Id = 767, ParentId = null }).Entity; ClearLog(); @@ -358,11 +350,7 @@ public virtual void Lazy_load_collection_not_found(EntityState state) var changeDetector = (ChangeDetectorProxy)context.GetService(); var parent = context.Attach( - new Parent(context.GetService().Load) - { - Id = 767, - AlternateId = "NewRoot" - }).Entity; + new Parent(context.GetService().Load) { Id = 767, AlternateId = "NewRoot" }).Entity; ClearLog(); @@ -399,11 +387,7 @@ public virtual void Lazy_load_many_to_one_reference_to_principal_not_found(Entit var changeDetector = (ChangeDetectorProxy)context.GetService(); var child = context.Attach( - new Child(context.GetService().Load) - { - Id = 767, - ParentId = 787 - }).Entity; + new Child(context.GetService().Load) { Id = 767, ParentId = 787 }).Entity; ClearLog(); @@ -440,11 +424,7 @@ public virtual void Lazy_load_one_to_one_reference_to_principal_not_found(Entity var changeDetector = (ChangeDetectorProxy)context.GetService(); var single = context.Attach( - new Single(context.GetService().Load) - { - Id = 767, - ParentId = 787 - }).Entity; + new Single(context.GetService().Load) { Id = 767, ParentId = 787 }).Entity; ClearLog(); @@ -482,11 +462,7 @@ public virtual void Lazy_load_one_to_one_reference_to_dependent_not_found(Entity var changeDetector = (ChangeDetectorProxy)context.GetService(); var parent = context.Attach( - new Parent(context.GetService().Load) - { - Id = 767, - AlternateId = "NewRoot" - }).Entity; + new Parent(context.GetService().Load) { Id = 767, AlternateId = "NewRoot" }).Entity; ClearLog(); @@ -890,11 +866,7 @@ public virtual void Lazy_load_many_to_one_reference_to_principal_null_FK_alterna using (var context = CreateContext(lazyLoadingEnabled: true)) { var child = context.Attach( - new ChildAk(context.GetService().Load) - { - Id = 767, - ParentId = null - }).Entity; + new ChildAk(context.GetService().Load) { Id = 767, ParentId = null }).Entity; ClearLog(); @@ -925,11 +897,7 @@ public virtual void Lazy_load_one_to_one_reference_to_principal_null_FK_alternat using (var context = CreateContext(lazyLoadingEnabled: true)) { var single = context.Attach( - new SingleAk(context.GetService().Load) - { - Id = 767, - ParentId = null - }).Entity; + new SingleAk(context.GetService().Load) { Id = 767, ParentId = null }).Entity; ClearLog(); @@ -1095,10 +1063,7 @@ public virtual void Lazy_load_many_to_one_reference_to_principal_null_FK_shadow_ using (var context = CreateContext(lazyLoadingEnabled: true)) { var child = context.Attach( - new ChildShadowFk(context.GetService().Load) - { - Id = 767 - }).Entity; + new ChildShadowFk(context.GetService().Load) { Id = 767 }).Entity; ClearLog(); @@ -1129,10 +1094,7 @@ public virtual void Lazy_load_one_to_one_reference_to_principal_null_FK_shadow_f using (var context = CreateContext(lazyLoadingEnabled: true)) { var single = context.Attach( - new SingleShadowFk(context.GetService().Load) - { - Id = 767 - }).Entity; + new SingleShadowFk(context.GetService().Load) { Id = 767 }).Entity; ClearLog(); @@ -1298,11 +1260,7 @@ public virtual void Lazy_load_many_to_one_reference_to_principal_null_FK_composi using (var context = CreateContext(lazyLoadingEnabled: true)) { var child = context.Attach( - new ChildCompositeKey(context.GetService().Load) - { - Id = 767, - ParentId = 567 - }).Entity; + new ChildCompositeKey(context.GetService().Load) { Id = 767, ParentId = 567 }).Entity; ClearLog(); @@ -1333,11 +1291,7 @@ public virtual void Lazy_load_one_to_one_reference_to_principal_null_FK_composit using (var context = CreateContext(lazyLoadingEnabled: true)) { var single = context.Attach( - new SingleCompositeKey(context.GetService().Load) - { - Id = 767, - ParentAlternateId = "Boot" - }).Entity; + new SingleCompositeKey(context.GetService().Load) { Id = 767, ParentAlternateId = "Boot" }).Entity; ClearLog(); @@ -1377,7 +1331,8 @@ public virtual void Lazy_load_collection_for_detached_throws(bool noTracking) Assert.Equal( CoreStrings.WarningAsErrorTemplate( CoreEventId.DetachedLazyLoadingWarning.ToString(), - CoreResources.LogDetachedLazyLoading(new TestLogger()).GenerateMessage(nameof(Parent.Children), "Parent"), + CoreResources.LogDetachedLazyLoading(new TestLogger()) + .GenerateMessage(nameof(Parent.Children), "Parent"), "CoreEventId.DetachedLazyLoadingWarning"), Assert.Throws( () => parent.Children).Message); @@ -1401,7 +1356,8 @@ public virtual void Lazy_load_reference_to_principal_for_detached_throws(bool no Assert.Equal( CoreStrings.WarningAsErrorTemplate( CoreEventId.DetachedLazyLoadingWarning.ToString(), - CoreResources.LogDetachedLazyLoading(new TestLogger()).GenerateMessage(nameof(Child.Parent), "Child"), + CoreResources.LogDetachedLazyLoading(new TestLogger()) + .GenerateMessage(nameof(Child.Parent), "Child"), "CoreEventId.DetachedLazyLoadingWarning"), Assert.Throws( () => child.Parent).Message); @@ -1425,7 +1381,8 @@ public virtual void Lazy_load_reference_to_dependent_for_detached_throws(bool no Assert.Equal( CoreStrings.WarningAsErrorTemplate( CoreEventId.DetachedLazyLoadingWarning.ToString(), - CoreResources.LogDetachedLazyLoading(new TestLogger()).GenerateMessage(nameof(Parent.Single), "Parent"), + CoreResources.LogDetachedLazyLoading(new TestLogger()) + .GenerateMessage(nameof(Parent.Single), "Parent"), "CoreEventId.DetachedLazyLoadingWarning"), Assert.Throws( () => parent.Single).Message); @@ -2026,11 +1983,7 @@ public virtual async Task Load_many_to_one_reference_to_principal_null_FK(Entity using (var context = CreateContext()) { var child = context.Attach( - new Child - { - Id = 767, - ParentId = null - }).Entity; + new Child { Id = 767, ParentId = null }).Entity; ClearLog(); @@ -2070,11 +2023,7 @@ public virtual async Task Load_one_to_one_reference_to_principal_null_FK(EntityS using (var context = CreateContext()) { var single = context.Attach( - new Single - { - Id = 767, - ParentId = null - }).Entity; + new Single { Id = 767, ParentId = null }).Entity; ClearLog(); @@ -2115,11 +2064,7 @@ public virtual async Task Load_many_to_one_reference_to_principal_using_Query_nu using (var context = CreateContext()) { var child = context.Attach( - new Child - { - Id = 767, - ParentId = null - }).Entity; + new Child { Id = 767, ParentId = null }).Entity; ClearLog(); @@ -2156,11 +2101,7 @@ public virtual async Task Load_one_to_one_reference_to_principal_using_Query_nul using (var context = CreateContext()) { var single = context.Attach( - new Single - { - Id = 767, - ParentId = null - }).Entity; + new Single { Id = 767, ParentId = null }).Entity; ClearLog(); @@ -2197,11 +2138,7 @@ public virtual async Task Load_collection_not_found(EntityState state, bool asyn using (var context = CreateContext()) { var parent = context.Attach( - new Parent - { - Id = 767, - AlternateId = "NewRoot" - }).Entity; + new Parent { Id = 767, AlternateId = "NewRoot" }).Entity; ClearLog(); @@ -2241,11 +2178,7 @@ public virtual async Task Load_many_to_one_reference_to_principal_not_found(Enti using (var context = CreateContext()) { var child = context.Attach( - new Child - { - Id = 767, - ParentId = 787 - }).Entity; + new Child { Id = 767, ParentId = 787 }).Entity; ClearLog(); @@ -2285,11 +2218,7 @@ public virtual async Task Load_one_to_one_reference_to_principal_not_found(Entit using (var context = CreateContext()) { var single = context.Attach( - new Single - { - Id = 767, - ParentId = 787 - }).Entity; + new Single { Id = 767, ParentId = 787 }).Entity; ClearLog(); @@ -2330,11 +2259,7 @@ public virtual async Task Load_one_to_one_reference_to_dependent_not_found(Entit using (var context = CreateContext()) { var parent = context.Attach( - new Parent - { - Id = 767, - AlternateId = "NewRoot" - }).Entity; + new Parent { Id = 767, AlternateId = "NewRoot" }).Entity; ClearLog(); @@ -2375,11 +2300,7 @@ public virtual async Task Load_collection_using_Query_not_found(EntityState stat using (var context = CreateContext()) { var parent = context.Attach( - new Parent - { - Id = 767, - AlternateId = "NewRoot" - }).Entity; + new Parent { Id = 767, AlternateId = "NewRoot" }).Entity; ClearLog(); @@ -2416,11 +2337,7 @@ public virtual async Task Load_many_to_one_reference_to_principal_using_Query_no using (var context = CreateContext()) { var child = context.Attach( - new Child - { - Id = 767, - ParentId = 787 - }).Entity; + new Child { Id = 767, ParentId = 787 }).Entity; ClearLog(); @@ -2457,11 +2374,7 @@ public virtual async Task Load_one_to_one_reference_to_principal_using_Query_not using (var context = CreateContext()) { var single = context.Attach( - new Single - { - Id = 767, - ParentId = 787 - }).Entity; + new Single { Id = 767, ParentId = 787 }).Entity; ClearLog(); @@ -2498,11 +2411,7 @@ public virtual async Task Load_one_to_one_reference_to_dependent_using_Query_not using (var context = CreateContext()) { var parent = context.Attach( - new Parent - { - Id = 767, - AlternateId = "NewRoot" - }).Entity; + new Parent { Id = 767, AlternateId = "NewRoot" }).Entity; ClearLog(); @@ -2641,7 +2550,8 @@ public virtual async Task Load_many_to_one_reference_to_principal_already_loaded [InlineData(EntityState.Modified, false, CascadeTiming.OnSaveChanges)] [InlineData(EntityState.Deleted, true, CascadeTiming.OnSaveChanges)] [InlineData(EntityState.Deleted, false, CascadeTiming.OnSaveChanges)] - public virtual async Task Load_one_to_one_reference_to_principal_already_loaded(EntityState state, bool async, CascadeTiming deleteOrphansTiming) + public virtual async Task Load_one_to_one_reference_to_principal_already_loaded( + EntityState state, bool async, CascadeTiming deleteOrphansTiming) { using (var context = CreateContext()) { @@ -2692,7 +2602,8 @@ public virtual async Task Load_one_to_one_reference_to_principal_already_loaded( [InlineData(EntityState.Modified, false, CascadeTiming.OnSaveChanges)] [InlineData(EntityState.Deleted, true, CascadeTiming.OnSaveChanges)] [InlineData(EntityState.Deleted, false, CascadeTiming.OnSaveChanges)] - public virtual async Task Load_one_to_one_reference_to_dependent_already_loaded(EntityState state, bool async, CascadeTiming deleteOrphansTiming) + public virtual async Task Load_one_to_one_reference_to_dependent_already_loaded( + EntityState state, bool async, CascadeTiming deleteOrphansTiming) { using (var context = CreateContext()) { @@ -2838,7 +2749,8 @@ public virtual async Task Load_one_to_one_PK_to_PK_reference_to_dependent_alread [InlineData(EntityState.Modified, false, CascadeTiming.OnSaveChanges)] [InlineData(EntityState.Deleted, true, CascadeTiming.OnSaveChanges)] [InlineData(EntityState.Deleted, false, CascadeTiming.OnSaveChanges)] - public virtual async Task Load_collection_using_Query_already_loaded(EntityState state, bool async, CascadeTiming deleteOrphansTiming) + public virtual async Task Load_collection_using_Query_already_loaded( + EntityState state, bool async, CascadeTiming deleteOrphansTiming) { using (var context = CreateContext()) { @@ -2958,7 +2870,8 @@ public virtual async Task Load_one_to_one_reference_to_principal_using_Query_alr [InlineData(EntityState.Modified, false, CascadeTiming.OnSaveChanges)] [InlineData(EntityState.Deleted, true, CascadeTiming.OnSaveChanges)] [InlineData(EntityState.Deleted, false, CascadeTiming.OnSaveChanges)] - public virtual async Task Load_one_to_one_reference_to_dependent_using_Query_already_loaded(EntityState state, bool async, CascadeTiming deleteOrphansTiming) + public virtual async Task Load_one_to_one_reference_to_dependent_using_Query_already_loaded( + EntityState state, bool async, CascadeTiming deleteOrphansTiming) { using (var context = CreateContext()) { @@ -3399,11 +3312,7 @@ public virtual async Task Load_collection_not_found_untyped(EntityState state, b using (var context = CreateContext()) { var parent = context.Attach( - new Parent - { - Id = 767, - AlternateId = "NewRoot" - }).Entity; + new Parent { Id = 767, AlternateId = "NewRoot" }).Entity; ClearLog(); @@ -3443,11 +3352,7 @@ public virtual async Task Load_many_to_one_reference_to_principal_not_found_unty using (var context = CreateContext()) { var child = context.Attach( - new Child - { - Id = 767, - ParentId = 787 - }).Entity; + new Child { Id = 767, ParentId = 787 }).Entity; ClearLog(); @@ -3487,11 +3392,7 @@ public virtual async Task Load_one_to_one_reference_to_principal_not_found_untyp using (var context = CreateContext()) { var single = context.Attach( - new Single - { - Id = 767, - ParentId = 787 - }).Entity; + new Single { Id = 767, ParentId = 787 }).Entity; ClearLog(); @@ -3532,11 +3433,7 @@ public virtual async Task Load_one_to_one_reference_to_dependent_not_found_untyp using (var context = CreateContext()) { var parent = context.Attach( - new Parent - { - Id = 767, - AlternateId = "NewRoot" - }).Entity; + new Parent { Id = 767, AlternateId = "NewRoot" }).Entity; ClearLog(); @@ -3577,11 +3474,7 @@ public virtual async Task Load_collection_using_Query_not_found_untyped(EntitySt using (var context = CreateContext()) { var parent = context.Attach( - new Parent - { - Id = 767, - AlternateId = "NewRoot" - }).Entity; + new Parent { Id = 767, AlternateId = "NewRoot" }).Entity; ClearLog(); @@ -3619,11 +3512,7 @@ public virtual async Task Load_many_to_one_reference_to_principal_using_Query_no using (var context = CreateContext()) { var child = context.Attach( - new Child - { - Id = 767, - ParentId = 787 - }).Entity; + new Child { Id = 767, ParentId = 787 }).Entity; ClearLog(); @@ -3661,11 +3550,7 @@ public virtual async Task Load_one_to_one_reference_to_principal_using_Query_not using (var context = CreateContext()) { var single = context.Attach( - new Single - { - Id = 767, - ParentId = 787 - }).Entity; + new Single { Id = 767, ParentId = 787 }).Entity; ClearLog(); @@ -3703,11 +3588,7 @@ public virtual async Task Load_one_to_one_reference_to_dependent_using_Query_not using (var context = CreateContext()) { var parent = context.Attach( - new Parent - { - Id = 767, - AlternateId = "NewRoot" - }).Entity; + new Parent { Id = 767, AlternateId = "NewRoot" }).Entity; ClearLog(); @@ -3890,7 +3771,8 @@ public virtual async Task Load_one_to_one_reference_to_principal_already_loaded_ [InlineData(EntityState.Modified, false, CascadeTiming.OnSaveChanges)] [InlineData(EntityState.Deleted, true, CascadeTiming.OnSaveChanges)] [InlineData(EntityState.Deleted, false, CascadeTiming.OnSaveChanges)] - public virtual async Task Load_one_to_one_reference_to_dependent_already_loaded_untyped(EntityState state, bool async, CascadeTiming deleteOrphansTiming) + public virtual async Task Load_one_to_one_reference_to_dependent_already_loaded_untyped( + EntityState state, bool async, CascadeTiming deleteOrphansTiming) { using (var context = CreateContext()) { @@ -3950,7 +3832,8 @@ public virtual async Task Load_one_to_one_reference_to_dependent_already_loaded_ [InlineData(EntityState.Modified, false, CascadeTiming.OnSaveChanges)] [InlineData(EntityState.Deleted, true, CascadeTiming.OnSaveChanges)] [InlineData(EntityState.Deleted, false, CascadeTiming.OnSaveChanges)] - public virtual async Task Load_collection_using_Query_already_loaded_untyped(EntityState state, bool async, CascadeTiming deleteOrphansTiming) + public virtual async Task Load_collection_using_Query_already_loaded_untyped( + EntityState state, bool async, CascadeTiming deleteOrphansTiming) { using (var context = CreateContext()) { @@ -4073,7 +3956,8 @@ public virtual async Task Load_one_to_one_reference_to_principal_using_Query_alr [InlineData(EntityState.Modified, false, CascadeTiming.OnSaveChanges)] [InlineData(EntityState.Deleted, true, CascadeTiming.OnSaveChanges)] [InlineData(EntityState.Deleted, false, CascadeTiming.OnSaveChanges)] - public virtual async Task Load_one_to_one_reference_to_dependent_using_Query_already_loaded_untyped(EntityState state, bool async, CascadeTiming deleteOrphansTiming) + public virtual async Task Load_one_to_one_reference_to_dependent_using_Query_already_loaded_untyped( + EntityState state, bool async, CascadeTiming deleteOrphansTiming) { using (var context = CreateContext()) { @@ -4439,11 +4323,7 @@ public virtual async Task Load_many_to_one_reference_to_principal_null_FK_altern using (var context = CreateContext()) { var child = context.Attach( - new ChildAk - { - Id = 767, - ParentId = null - }).Entity; + new ChildAk { Id = 767, ParentId = null }).Entity; ClearLog(); @@ -4483,11 +4363,7 @@ public virtual async Task Load_one_to_one_reference_to_principal_null_FK_alterna using (var context = CreateContext()) { var single = context.Attach( - new SingleAk - { - Id = 767, - ParentId = null - }).Entity; + new SingleAk { Id = 767, ParentId = null }).Entity; ClearLog(); @@ -4528,11 +4404,7 @@ public virtual async Task Load_many_to_one_reference_to_principal_using_Query_nu using (var context = CreateContext()) { var child = context.Attach( - new ChildAk - { - Id = 767, - ParentId = null - }).Entity; + new ChildAk { Id = 767, ParentId = null }).Entity; ClearLog(); @@ -4569,11 +4441,7 @@ public virtual async Task Load_one_to_one_reference_to_principal_using_Query_nul using (var context = CreateContext()) { var single = context.Attach( - new SingleAk - { - Id = 767, - ParentId = null - }).Entity; + new SingleAk { Id = 767, ParentId = null }).Entity; ClearLog(); @@ -4929,10 +4797,7 @@ public virtual async Task Load_many_to_one_reference_to_principal_null_FK_shadow using (var context = CreateContext()) { var child = context.Attach( - new ChildShadowFk - { - Id = 767 - }).Entity; + new ChildShadowFk { Id = 767 }).Entity; ClearLog(); @@ -4972,10 +4837,7 @@ public virtual async Task Load_one_to_one_reference_to_principal_null_FK_shadow_ using (var context = CreateContext()) { var single = context.Attach( - new SingleShadowFk - { - Id = 767 - }).Entity; + new SingleShadowFk { Id = 767 }).Entity; ClearLog(); @@ -5016,10 +4878,7 @@ public virtual async Task Load_many_to_one_reference_to_principal_using_Query_nu using (var context = CreateContext()) { var child = context.Attach( - new ChildShadowFk - { - Id = 767 - }).Entity; + new ChildShadowFk { Id = 767 }).Entity; ClearLog(); @@ -5056,10 +4915,7 @@ public virtual async Task Load_one_to_one_reference_to_principal_using_Query_nul using (var context = CreateContext()) { var single = context.Attach( - new SingleShadowFk - { - Id = 767 - }).Entity; + new SingleShadowFk { Id = 767 }).Entity; ClearLog(); @@ -5415,11 +5271,7 @@ public virtual async Task Load_many_to_one_reference_to_principal_null_FK_compos using (var context = CreateContext()) { var child = context.Attach( - new ChildCompositeKey - { - Id = 767, - ParentId = 567 - }).Entity; + new ChildCompositeKey { Id = 767, ParentId = 567 }).Entity; ClearLog(); @@ -5459,11 +5311,7 @@ public virtual async Task Load_one_to_one_reference_to_principal_null_FK_composi using (var context = CreateContext()) { var single = context.Attach( - new SingleCompositeKey - { - Id = 767, - ParentAlternateId = "Boot" - }).Entity; + new SingleCompositeKey { Id = 767, ParentAlternateId = "Boot" }).Entity; ClearLog(); @@ -5504,11 +5352,7 @@ public virtual async Task Load_many_to_one_reference_to_principal_using_Query_nu using (var context = CreateContext()) { var child = context.Attach( - new ChildCompositeKey - { - Id = 767, - ParentAlternateId = "Boot" - }).Entity; + new ChildCompositeKey { Id = 767, ParentAlternateId = "Boot" }).Entity; ClearLog(); @@ -5545,11 +5389,7 @@ public virtual async Task Load_one_to_one_reference_to_principal_using_Query_nul using (var context = CreateContext()) { var single = context.Attach( - new SingleCompositeKey - { - Id = 767, - ParentId = 567 - }).Entity; + new SingleCompositeKey { Id = 767, ParentId = 567 }).Entity; ClearLog(); @@ -6672,32 +6512,16 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasMany(e => e.ChildrenCompositeKey) .WithOne(e => e.Parent) .HasPrincipalKey( - e => new - { - e.AlternateId, - e.Id - }) + e => new { e.AlternateId, e.Id }) .HasForeignKey( - e => new - { - e.ParentAlternateId, - e.ParentId - }); + e => new { e.ParentAlternateId, e.ParentId }); b.HasOne(nameof(Parent.SingleCompositeKey)) .WithOne(e => e.Parent) .HasPrincipalKey( - e => new - { - e.AlternateId, - e.Id - }) + e => new { e.AlternateId, e.Id }) .HasForeignKey( - e => new - { - e.ParentAlternateId, - e.ParentId - }); + e => new { e.ParentAlternateId, e.ParentId }); }); modelBuilder.Entity(); @@ -6716,77 +6540,22 @@ protected override void Seed(PoolableDbContext context) { Id = 707, AlternateId = "Root", - Children = new List - { - new Child - { - Id = 11 - }, - new Child - { - Id = 12 - } - }, - SinglePkToPk = new SinglePkToPk - { - Id = 707 - }, - Single = new Single - { - Id = 21 - }, - ChildrenAk = new List - { - new ChildAk - { - Id = 31 - }, - new ChildAk - { - Id = 32 - } - }, - SingleAk = new SingleAk - { - Id = 42 - }, - ChildrenShadowFk = new List - { - new ChildShadowFk - { - Id = 51 - }, - new ChildShadowFk - { - Id = 52 - } - }, - SingleShadowFk = new SingleShadowFk - { - Id = 62 - }, + Children = new List { new Child { Id = 11 }, new Child { Id = 12 } }, + SinglePkToPk = new SinglePkToPk { Id = 707 }, + Single = new Single { Id = 21 }, + ChildrenAk = new List { new ChildAk { Id = 31 }, new ChildAk { Id = 32 } }, + SingleAk = new SingleAk { Id = 42 }, + ChildrenShadowFk = new List { new ChildShadowFk { Id = 51 }, new ChildShadowFk { Id = 52 } }, + SingleShadowFk = new SingleShadowFk { Id = 62 }, ChildrenCompositeKey = new List { - new ChildCompositeKey - { - Id = 51 - }, - new ChildCompositeKey - { - Id = 52 - } + new ChildCompositeKey { Id = 51 }, new ChildCompositeKey { Id = 52 } }, - SingleCompositeKey = new SingleCompositeKey - { - Id = 62 - } + SingleCompositeKey = new SingleCompositeKey { Id = 62 } }); context.Add( - new SimpleProduct - { - Deposit = new Deposit() - }); + new SimpleProduct { Deposit = new Deposit() }); context.SaveChanges(); } diff --git a/test/EFCore.Specification.Tests/LoggingTestBase.cs b/test/EFCore.Specification.Tests/LoggingTestBase.cs index ad571e91e98..4f61c3d2682 100644 --- a/test/EFCore.Specification.Tests/LoggingTestBase.cs +++ b/test/EFCore.Specification.Tests/LoggingTestBase.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Diagnostics.Internal; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; diff --git a/test/EFCore.Specification.Tests/MonsterFixupTestBase.cs b/test/EFCore.Specification.Tests/MonsterFixupTestBase.cs index 88d65a1b882..b8045fe10aa 100644 --- a/test/EFCore.Specification.Tests/MonsterFixupTestBase.cs +++ b/test/EFCore.Specification.Tests/MonsterFixupTestBase.cs @@ -1380,7 +1380,7 @@ protected void NavigationVerification() protected bool UseDetectChanges => Fixture.UseDetectChanges; protected void CreateAndSeedDatabase(Action seed) - => TestStore.Initialize(Fixture.ServiceProvider, CreateContext, c => seed((MonsterContext)c), null); + => TestStore.Initialize(Fixture.ServiceProvider, CreateContext, c => seed((MonsterContext)c)); protected MonsterContext CreateContext() => Fixture.CreateContext(Options); diff --git a/test/EFCore.Specification.Tests/MusicStoreTestBase.cs b/test/EFCore.Specification.Tests/MusicStoreTestBase.cs index 965325ad046..b17a0b8034e 100644 --- a/test/EFCore.Specification.Tests/MusicStoreTestBase.cs +++ b/test/EFCore.Specification.Tests/MusicStoreTestBase.cs @@ -85,10 +85,7 @@ public async Task Details_ReturnsAlbumDetail() private static Genre[] CreateTestGenres(int numberOfGenres, int numberOfAlbums, DbContext context) { - var artist = new Artist - { - Name = "Artist1" - }; + var artist = new Artist { Name = "Artist1" }; var genres = Enumerable.Range(1, numberOfGenres).Select( g => @@ -97,10 +94,7 @@ private static Genre[] CreateTestGenres(int numberOfGenres, int numberOfAlbums, Name = "Genre " + g, Albums = Enumerable.Range(1, numberOfAlbums).Select( n => - new Album - { - Artist = artist, Title = "Greatest Hits" - }).ToList() + new Album { Artist = artist, Title = "Greatest Hits" }).ToList() }).ToList(); context.AddRange(genres); @@ -140,24 +134,15 @@ public static Album[] GetAlbums() { var genres = Enumerable.Range(1, 10).Select( n => - new Genre - { - Name = "Genre Name " + n - }).ToArray(); + new Genre { Name = "Genre Name " + n }).ToArray(); var artists = Enumerable.Range(1, 10).Select( n => - new Artist - { - Name = "Artist Name " + n - }).ToArray(); + new Artist { Name = "Artist Name " + n }).ToArray(); var albums = Enumerable.Range(1, 10).Select( n => - new Album - { - Artist = artists[n - 1], Genre = genres[n - 1], Title = "Greatest Hits" - }).ToArray(); + new Album { Artist = artists[n - 1], Genre = genres[n - 1], Title = "Greatest Hits" }).ToArray(); return albums; } @@ -173,10 +158,7 @@ public async Task GenreMenuComponent_Returns_NineGenres() var genreMenuComponent = new GenreMenuComponent(context); var genres = Enumerable.Range(1, 10).Select( - n => new Genre - { - Name = $"G{n}" - }); + n => new Genre { Name = $"G{n}" }); context.AddRange(genres); context.SaveChanges(); @@ -195,15 +177,7 @@ public async Task AddressAndPayment_RedirectToCompleteWhenSuccessful() var order = CreateOrder(); - var formCollection = new Dictionary - { - { - "PromoCode", new[] - { - "FREE" - } - } - }; + var formCollection = new Dictionary { { "PromoCode", new[] { "FREE" } } }; using (var context = CreateContext()) { @@ -305,23 +279,12 @@ public async Task CartSummaryComponent_returns_items() { var album = new Album { - Title = albumTitle, - Artist = new Artist - { - Name = "Kung Fu Kenny" - }, - Genre = new Genre - { - Name = "Rap" - } + Title = albumTitle, Artist = new Artist { Name = "Kung Fu Kenny" }, Genre = new Genre { Name = "Rap" } }; var cartItems = Enumerable.Range(1, itemCount).Select( n => - new CartItem - { - Album = album, Count = 1, CartId = cartId - }).ToArray(); + new CartItem { Album = album, Count = 1, CartId = cartId }).ToArray(); context.AddRange(cartItems); context.SaveChanges(); @@ -343,13 +306,7 @@ public void Music_store_project_to_mapped_entity() { var albums = CreateTestAlbums( 10, - new Artist - { - Name = "Kung Fu Kenny" - }, new Genre - { - Name = "Rap" - }); + new Artist { Name = "Kung Fu Kenny" }, new Genre { Name = "Rap" }); context.Albums.AddRange(albums); context.SaveChanges(); @@ -365,14 +322,8 @@ join artist in context.Artists on album.ArtistId equals artist.ArtistId GenreId = album.GenreId, Price = album.Price, Title = album.Title, - Artist = new Artist - { - ArtistId = album.ArtistId, Name = artist.Name - }, - Genre = new Genre - { - GenreId = album.GenreId, Name = genre.Name - } + Artist = new Artist { ArtistId = album.ArtistId, Name = artist.Name }, + Genre = new Genre { GenreId = album.GenreId, Name = genre.Name } }; var foundAlbums = q.ToList(); @@ -469,13 +420,7 @@ public async Task Can_add_items_to_cart() { var albums = CreateTestAlbums( 10, - new Artist - { - Name = "Kung Fu Kenny" - }, new Genre - { - Name = "Rap" - }); + new Artist { Name = "Kung Fu Kenny" }, new Genre { Name = "Rap" }); context.AddRange(albums); context.SaveChanges(); @@ -495,19 +440,10 @@ private static CartItem[] CreateTestCartItems(string cartId, decimal itemPrice, { var albums = CreateTestAlbums( itemPrice, - new Artist - { - Name = "Kung Fu Kenny" - }, new Genre - { - Name = "Rap" - }); + new Artist { Name = "Kung Fu Kenny" }, new Genre { Name = "Rap" }); var cartItems = Enumerable.Range(1, numberOfItems).Select( - n => new CartItem - { - Count = 1, CartId = cartId, Album = albums[n % albums.Length] - }).ToArray(); + n => new CartItem { Count = 1, CartId = cartId, Album = albums[n % albums.Length] }).ToArray(); return cartItems; } @@ -516,10 +452,7 @@ private static Album[] CreateTestAlbums(decimal itemPrice, Artist artist, Genre { return Enumerable.Range(1, 10).Select( n => - new Album - { - Title = "Greatest Hits", Price = itemPrice, Artist = artist, Genre = genre - }).ToArray(); + new Album { Title = "Greatest Hits", Price = itemPrice, Artist = artist, Genre = genre }).ToArray(); } protected class CartSummaryComponent @@ -606,10 +539,7 @@ public virtual async Task Index() { var cart = ShoppingCart.GetCart(_context, _cartId); - var viewModel = new ShoppingCartViewModel - { - CartItems = await cart.GetCartItems(), CartTotal = await cart.GetTotal() - }; + var viewModel = new ShoppingCartViewModel { CartItems = await cart.GetCartItems(), CartTotal = await cart.GetTotal() }; return viewModel; } diff --git a/test/EFCore.Specification.Tests/NotificationEntitiesTestBase.cs b/test/EFCore.Specification.Tests/NotificationEntitiesTestBase.cs index 7ddf6bfe0b0..6361ece091e 100644 --- a/test/EFCore.Specification.Tests/NotificationEntitiesTestBase.cs +++ b/test/EFCore.Specification.Tests/NotificationEntitiesTestBase.cs @@ -125,21 +125,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con protected override void Seed(PoolableDbContext context) { context.Add( - new Blog - { - Id = 1, - Posts = new List - { - new Post - { - Id = 1 - }, - new Post - { - Id = 2 - } - } - }); + new Blog { Id = 1, Posts = new List { new Post { Id = 1 }, new Post { Id = 2 } } }); context.SaveChanges(); } diff --git a/test/EFCore.Specification.Tests/OptimisticConcurrencyTestBase.cs b/test/EFCore.Specification.Tests/OptimisticConcurrencyTestBase.cs index 5bf8d29bc82..d21647619dd 100644 --- a/test/EFCore.Specification.Tests/OptimisticConcurrencyTestBase.cs +++ b/test/EFCore.Specification.Tests/OptimisticConcurrencyTestBase.cs @@ -349,31 +349,13 @@ await c.Database.CreateExecutionStrategy().ExecuteAsync( using (var transaction = context.Database.BeginTransaction()) { context.Teams.Add( - new Team - { - Id = -1, - Name = "Wubbsy Racing", - Chassis = new Chassis - { - TeamId = -1, - Name = "Wubbsy" - } - }); + new Team { Id = -1, Name = "Wubbsy Racing", Chassis = new Chassis { TeamId = -1, Name = "Wubbsy" } }); using (var innerContext = CreateF1Context()) { UseTransaction(innerContext.Database, transaction); innerContext.Teams.Add( - new Team - { - Id = -1, - Name = "Wubbsy Racing", - Chassis = new Chassis - { - TeamId = -1, - Name = "Wubbsy" - } - }); + new Team { Id = -1, Name = "Wubbsy Racing", Chassis = new Chassis { TeamId = -1, Name = "Wubbsy" } }); await innerContext.SaveChangesAsync(); @@ -484,11 +466,7 @@ await c.Database.CreateExecutionStrategy().ExecuteAsync( using (context.Database.BeginTransaction()) { var entry = context.Drivers.Add( - new Driver - { - Name = "Larry David", - TeamId = Team.Ferrari - }); + new Driver { Name = "Larry David", TeamId = Team.Ferrari }); if (async) { @@ -539,12 +517,7 @@ await c.Database.CreateExecutionStrategy().ExecuteAsync( using (context.Database.BeginTransaction()) { var entry = context.Drivers.Add( - new Driver - { - Id = 676, - Name = "Larry David", - TeamId = Team.Ferrari - }); + new Driver { Id = 676, Name = "Larry David", TeamId = Team.Ferrari }); entry.State = state; diff --git a/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs b/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs index a2af8e593e3..87953299c03 100644 --- a/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs +++ b/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs @@ -1264,7 +1264,7 @@ public async Task Reload_when_entity_deleted_in_store_can_happen_for_any_state(E { using (var context = CreateContext()) { - var office = new Office { Number = "35"}; + var office = new Office { Number = "35" }; var mailRoom = new MailRoom { id = 36 }; var building = Building.Create(Guid.NewGuid(), "Bag End", 77); @@ -1428,10 +1428,7 @@ private void TestNonGenericDtoSetValues( var newBuilding = new BuildingDto { - BuildingId = new Guid(building.BuildingId.ToString()), - Name = "Values End", - Value = building.Value, - Shadow1 = 777 + BuildingId = new Guid(building.BuildingId.ToString()), Name = "Values End", Value = building.Value, Shadow1 = 777 }; buildingValues.SetValues(newBuilding); @@ -1468,12 +1465,7 @@ private void TestNonGenericDtoNoKeySetValues( var building = context.Set().Single(b => b.Name == "Building One"); var buildingValues = getPropertyValues(context.Entry(building)); - var newBuilding = new BuildingDtoNoKey - { - Name = "Values End", - Value = building.Value, - Shadow2 = "Cheese" - }; + var newBuilding = new BuildingDtoNoKey { Name = "Values End", Value = building.Value, Shadow2 = "Cheese" }; buildingValues.SetValues(newBuilding); @@ -2233,12 +2225,7 @@ private Building() } public static Building Create(Guid buildingId, string name, decimal value) - => new Building - { - BuildingId = buildingId, - Name = name, - Value = value - }; + => new Building { BuildingId = buildingId, Name = name, Value = value }; public Guid BuildingId { get; set; } public string Name { get; set; } @@ -2398,11 +2385,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con .HasForeignKey(m => m.BuildingId); modelBuilder.Entity().HasKey( - o => new - { - o.Number, - o.BuildingId - }); + o => new { o.Number, o.BuildingId }); modelBuilder.Ignore(); @@ -2443,26 +2426,10 @@ protected override void Seed(PoolableDbContext context) var offices = new List { - new Office - { - BuildingId = buildings[0].BuildingId, - Number = "1/1221" - }, - new Office - { - BuildingId = buildings[0].BuildingId, - Number = "1/1223" - }, - new Office - { - BuildingId = buildings[0].BuildingId, - Number = "2/1458" - }, - new Office - { - BuildingId = buildings[0].BuildingId, - Number = "2/1789" - } + new Office { BuildingId = buildings[0].BuildingId, Number = "1/1221" }, + new Office { BuildingId = buildings[0].BuildingId, Number = "1/1223" }, + new Office { BuildingId = buildings[0].BuildingId, Number = "2/1458" }, + new Office { BuildingId = buildings[0].BuildingId, Number = "2/1789" } }; foreach (var office in offices) @@ -2490,10 +2457,7 @@ protected override void Seed(PoolableDbContext context) }, new PastEmployee { - EmployeeId = 3, - FirstName = "John", - LastName = "Doe", - TerminationDate = new DateTime(2006, 1, 23) + EmployeeId = 3, FirstName = "John", LastName = "Doe", TerminationDate = new DateTime(2006, 1, 23) } }; @@ -2516,24 +2480,9 @@ protected override void Seed(PoolableDbContext context) var whiteboards = new List { - new Whiteboard - { - AssetTag = "WB1973", - iD = new byte[] { 1, 9, 7, 3 }, - Office = offices[0] - }, - new Whiteboard - { - AssetTag = "WB1977", - iD = new byte[] { 1, 9, 7, 7 }, - Office = offices[0] - }, - new Whiteboard - { - AssetTag = "WB1970", - iD = new byte[] { 1, 9, 7, 0 }, - Office = offices[2] - } + new Whiteboard { AssetTag = "WB1973", iD = new byte[] { 1, 9, 7, 3 }, Office = offices[0] }, + new Whiteboard { AssetTag = "WB1977", iD = new byte[] { 1, 9, 7, 7 }, Office = offices[0] }, + new Whiteboard { AssetTag = "WB1970", iD = new byte[] { 1, 9, 7, 0 }, Office = offices[2] } }; foreach (var whiteboard in whiteboards) diff --git a/test/EFCore.Specification.Tests/ProxyGraphUpdatesFixtureBase.cs b/test/EFCore.Specification.Tests/ProxyGraphUpdatesFixtureBase.cs index eb6b93ba7ae..e1e3108b315 100644 --- a/test/EFCore.Specification.Tests/ProxyGraphUpdatesFixtureBase.cs +++ b/test/EFCore.Specification.Tests/ProxyGraphUpdatesFixtureBase.cs @@ -150,10 +150,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasMany(e => e.CompositeChildren) .WithOne(e => e.Parent2) .HasForeignKey( - e => new - { - e.Parent2Id - }); + e => new { e.Parent2Id }); }); modelBuilder.Entity(); @@ -197,17 +194,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasMany(e => e.CompositeChildren) .WithOne(e => e.Parent) .HasPrincipalKey( - e => new - { - e.Id, - e.AlternateId - }) + e => new { e.Id, e.AlternateId }) .HasForeignKey( - e => new - { - e.ParentId, - e.ParentAlternateId - }); + e => new { e.ParentId, e.ParentAlternateId }); }); modelBuilder.Entity(); @@ -228,17 +217,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasMany(e => e.CompositeChildren) .WithOne(e => e.Parent) .HasPrincipalKey( - e => new - { - e.Id, - e.AlternateId - }) + e => new { e.Id, e.AlternateId }) .HasForeignKey( - e => new - { - e.ParentId, - e.ParentAlternateId - }); + e => new { e.ParentId, e.ParentAlternateId }); }); modelBuilder.Entity(); @@ -258,17 +239,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasOne(e => e.SingleComposite) .WithOne(e => e.Back) .HasForeignKey( - e => new - { - e.BackId, - e.BackAlternateId - }) + e => new { e.BackId, e.BackAlternateId }) .HasPrincipalKey( - e => new - { - e.Id, - e.AlternateId - }); + e => new { e.Id, e.AlternateId }); }); modelBuilder.Entity( @@ -286,17 +259,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasOne(e => e.SingleComposite) .WithOne(e => e.Back) .HasForeignKey( - e => new - { - e.BackId, - e.ParentAlternateId - }) + e => new { e.BackId, e.ParentAlternateId }) .HasPrincipalKey( - e => new - { - e.Id, - e.AlternateId - }); + e => new { e.Id, e.AlternateId }); }); modelBuilder.Entity(); @@ -349,26 +314,14 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb.Property(e => e.Id).ValueGeneratedNever(); eb.HasKey( - e => new - { - e.Id, - e.ParentAlternateId - }); + e => new { e.Id, e.ParentAlternateId }); eb.HasMany(e => e.CompositeChildren) .WithOne(e => e.Parent) .HasPrincipalKey( - e => new - { - e.Id, - e.ParentAlternateId - }) + e => new { e.Id, e.ParentAlternateId }) .HasForeignKey( - e => new - { - e.ParentId, - e.ParentAlternateId - }); + e => new { e.ParentId, e.ParentAlternateId }); }); modelBuilder.Entity( @@ -377,11 +330,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb.Property(e => e.Id).ValueGeneratedNever(); eb.HasKey( - e => new - { - e.Id, - e.ParentAlternateId - }); + e => new { e.Id, e.ParentAlternateId }); eb.HasOne(e => e.Root) .WithMany() @@ -397,224 +346,166 @@ protected virtual object CreateFullGraph() => new Root { AlternateId = RootAK, - RequiredChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new Required1 - { - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new Required2(), - new Required2() - } - }, - new Required1 + RequiredChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) { - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + new Required1 { - new Required2(), - new Required2() - } - } - }, - OptionalChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new Optional1 - { - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new Optional2(), - new Optional2() - }, - CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) - }, - new Optional1 - { - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new Optional2(), - new Optional2() - }, - CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) - } - }, - RequiredSingle = new RequiredSingle1 - { - Single = new RequiredSingle2() - }, - OptionalSingle = new OptionalSingle1 - { - Single = new OptionalSingle2() - }, - OptionalSingleDerived = new OptionalSingle1Derived - { - Single = new OptionalSingle2Derived() - }, - OptionalSingleMoreDerived = new OptionalSingle1MoreDerived - { - Single = new OptionalSingle2MoreDerived() - }, - RequiredNonPkSingle = new RequiredNonPkSingle1 - { - Single = new RequiredNonPkSingle2() - }, - RequiredNonPkSingleDerived = new RequiredNonPkSingle1Derived - { - Single = new RequiredNonPkSingle2Derived(), - Root = new Root() - }, - RequiredNonPkSingleMoreDerived = new RequiredNonPkSingle1MoreDerived - { - Single = new RequiredNonPkSingle2MoreDerived(), - Root = new Root(), - DerivedRoot = new Root() - }, - RequiredChildrenAk = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new RequiredAk1 - { - AlternateId = Guid.NewGuid(), - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new RequiredAk2 - { - AlternateId = Guid.NewGuid() - }, - new RequiredAk2 + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) { - AlternateId = Guid.NewGuid() + new Required2(), new Required2() } }, - CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) + new Required1 { - new RequiredComposite2(), - new RequiredComposite2() + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new Required2(), new Required2() + } } }, - new RequiredAk1 + OptionalChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) { - AlternateId = Guid.NewGuid(), - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + new Optional1 { - new RequiredAk2 + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) { - AlternateId = Guid.NewGuid() + new Optional2(), new Optional2() }, - new RequiredAk2 - { - AlternateId = Guid.NewGuid() - } + CompositeChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) }, - CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) + new Optional1 { - new RequiredComposite2(), - new RequiredComposite2() + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new Optional2(), new Optional2() + }, + CompositeChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) } - } - }, - OptionalChildrenAk = new ObservableHashSet(ReferenceEqualityComparer.Instance) - { - new OptionalAk1 + }, + RequiredSingle = new RequiredSingle1 { Single = new RequiredSingle2() }, + OptionalSingle = new OptionalSingle1 { Single = new OptionalSingle2() }, + OptionalSingleDerived = new OptionalSingle1Derived { Single = new OptionalSingle2Derived() }, + OptionalSingleMoreDerived = new OptionalSingle1MoreDerived { Single = new OptionalSingle2MoreDerived() }, + RequiredNonPkSingle = new RequiredNonPkSingle1 { Single = new RequiredNonPkSingle2() }, + RequiredNonPkSingleDerived = + new RequiredNonPkSingle1Derived { Single = new RequiredNonPkSingle2Derived(), Root = new Root() }, + RequiredNonPkSingleMoreDerived = + new RequiredNonPkSingle1MoreDerived { - AlternateId = Guid.NewGuid(), - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + Single = new RequiredNonPkSingle2MoreDerived(), Root = new Root(), DerivedRoot = new Root() + }, + RequiredChildrenAk = + new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new RequiredAk1 { - new OptionalAk2 + AlternateId = Guid.NewGuid(), + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) { - AlternateId = Guid.NewGuid() + new RequiredAk2 { AlternateId = Guid.NewGuid() }, + new RequiredAk2 { AlternateId = Guid.NewGuid() } }, - new OptionalAk2 - { - AlternateId = Guid.NewGuid() - } + CompositeChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new RequiredComposite2(), new RequiredComposite2() + } }, - CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) + new RequiredAk1 { - new OptionalComposite2(), - new OptionalComposite2() + AlternateId = Guid.NewGuid(), + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new RequiredAk2 { AlternateId = Guid.NewGuid() }, + new RequiredAk2 { AlternateId = Guid.NewGuid() } + }, + CompositeChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new RequiredComposite2(), new RequiredComposite2() + } } }, - new OptionalAk1 + OptionalChildrenAk = + new ObservableHashSet(ReferenceEqualityComparer.Instance) { - AlternateId = Guid.NewGuid(), - Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + new OptionalAk1 { - new OptionalAk2 + AlternateId = Guid.NewGuid(), + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) { - AlternateId = Guid.NewGuid() + new OptionalAk2 { AlternateId = Guid.NewGuid() }, + new OptionalAk2 { AlternateId = Guid.NewGuid() } }, - new OptionalAk2 - { - AlternateId = Guid.NewGuid() - } + CompositeChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new OptionalComposite2(), new OptionalComposite2() + } }, - CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) + new OptionalAk1 { - new OptionalComposite2(), - new OptionalComposite2() + AlternateId = Guid.NewGuid(), + Children = new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new OptionalAk2 { AlternateId = Guid.NewGuid() }, + new OptionalAk2 { AlternateId = Guid.NewGuid() } + }, + CompositeChildren = + new ObservableHashSet(ReferenceEqualityComparer.Instance) + { + new OptionalComposite2(), new OptionalComposite2() + } } - } - }, - RequiredSingleAk = new RequiredSingleAk1 - { - AlternateId = Guid.NewGuid(), - Single = new RequiredSingleAk2 + }, + RequiredSingleAk = + new RequiredSingleAk1 { - AlternateId = Guid.NewGuid() + AlternateId = Guid.NewGuid(), + Single = new RequiredSingleAk2 { AlternateId = Guid.NewGuid() }, + SingleComposite = new RequiredSingleComposite2() }, - SingleComposite = new RequiredSingleComposite2() - }, - OptionalSingleAk = new OptionalSingleAk1 - { - AlternateId = Guid.NewGuid(), - Single = new OptionalSingleAk2 + OptionalSingleAk = + new OptionalSingleAk1 { - AlternateId = Guid.NewGuid() + AlternateId = Guid.NewGuid(), + Single = new OptionalSingleAk2 { AlternateId = Guid.NewGuid() }, + SingleComposite = new OptionalSingleComposite2() }, - SingleComposite = new OptionalSingleComposite2() - }, - OptionalSingleAkDerived = new OptionalSingleAk1Derived - { - AlternateId = Guid.NewGuid(), - Single = new OptionalSingleAk2Derived + OptionalSingleAkDerived = + new OptionalSingleAk1Derived { - AlternateId = Guid.NewGuid() - } - }, - OptionalSingleAkMoreDerived = new OptionalSingleAk1MoreDerived - { - AlternateId = Guid.NewGuid(), - Single = new OptionalSingleAk2MoreDerived + AlternateId = Guid.NewGuid(), Single = new OptionalSingleAk2Derived { AlternateId = Guid.NewGuid() } + }, + OptionalSingleAkMoreDerived = + new OptionalSingleAk1MoreDerived { - AlternateId = Guid.NewGuid() - } - }, - RequiredNonPkSingleAk = new RequiredNonPkSingleAk1 - { - AlternateId = Guid.NewGuid(), - Single = new RequiredNonPkSingleAk2 + AlternateId = Guid.NewGuid(), Single = new OptionalSingleAk2MoreDerived { AlternateId = Guid.NewGuid() } + }, + RequiredNonPkSingleAk = + new RequiredNonPkSingleAk1 { - AlternateId = Guid.NewGuid() - } - }, - RequiredNonPkSingleAkDerived = new RequiredNonPkSingleAk1Derived - { - AlternateId = Guid.NewGuid(), - Single = new RequiredNonPkSingleAk2Derived + AlternateId = Guid.NewGuid(), Single = new RequiredNonPkSingleAk2 { AlternateId = Guid.NewGuid() } + }, + RequiredNonPkSingleAkDerived = + new RequiredNonPkSingleAk1Derived { - AlternateId = Guid.NewGuid() + AlternateId = Guid.NewGuid(), + Single = new RequiredNonPkSingleAk2Derived { AlternateId = Guid.NewGuid() }, + Root = new Root() }, - Root = new Root() - }, - RequiredNonPkSingleAkMoreDerived = new RequiredNonPkSingleAk1MoreDerived - { - AlternateId = Guid.NewGuid(), - Single = new RequiredNonPkSingleAk2MoreDerived + RequiredNonPkSingleAkMoreDerived = + new RequiredNonPkSingleAk1MoreDerived { - AlternateId = Guid.NewGuid() + AlternateId = Guid.NewGuid(), + Single = new RequiredNonPkSingleAk2MoreDerived { AlternateId = Guid.NewGuid() }, + Root = new Root(), + DerivedRoot = new Root() }, - Root = new Root(), - DerivedRoot = new Root() - }, RequiredCompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) { new RequiredComposite1 @@ -622,14 +513,7 @@ protected virtual object CreateFullGraph() Id = 1, CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) { - new OptionalOverlapping2 - { - Id = 1 - }, - new OptionalOverlapping2 - { - Id = 2 - } + new OptionalOverlapping2 { Id = 1 }, new OptionalOverlapping2 { Id = 2 } } }, new RequiredComposite1 @@ -637,14 +521,7 @@ protected virtual object CreateFullGraph() Id = 2, CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) { - new OptionalOverlapping2 - { - Id = 3 - }, - new OptionalOverlapping2 - { - Id = 4 - } + new OptionalOverlapping2 { Id = 3 }, new OptionalOverlapping2 { Id = 4 } } } } @@ -657,10 +534,7 @@ protected override void Seed(DbContext context) context.ChangeTracker.TrackGraph(CreateFullGraph(), e => tracker.TrackEntity(e.Entry)); context.Add( - new BadOrder - { - BadCustomer = new BadCustomer() - }); + new BadOrder { BadCustomer = new BadCustomer() }); context.SaveChanges(); } diff --git a/test/EFCore.Specification.Tests/ProxyGraphUpdatesTestBase.cs b/test/EFCore.Specification.Tests/ProxyGraphUpdatesTestBase.cs index 28f797f1947..8e0ecb8d943 100644 --- a/test/EFCore.Specification.Tests/ProxyGraphUpdatesTestBase.cs +++ b/test/EFCore.Specification.Tests/ProxyGraphUpdatesTestBase.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable InconsistentNaming @@ -713,7 +712,9 @@ public virtual void Save_required_non_PK_one_to_one_changed_by_reference(ChangeM var new1d = new RequiredNonPkSingle1Derived { Single = new2d, Root = new Root() }; var new1dd = new RequiredNonPkSingle1MoreDerived { Single = new2dd, Root = new Root(), DerivedRoot = new Root() }; var newRoot = new Root - { RequiredNonPkSingle = new1, RequiredNonPkSingleDerived = new1d, RequiredNonPkSingleMoreDerived = new1dd }; + { + RequiredNonPkSingle = new1, RequiredNonPkSingleDerived = new1d, RequiredNonPkSingleMoreDerived = new1dd + }; RequiredNonPkSingle1 old1 = null; RequiredNonPkSingle1Derived old1d = null; RequiredNonPkSingle1MoreDerived old1dd = null; @@ -1387,8 +1388,7 @@ public virtual void Reparent_one_to_many_overlapping(ChangeMechanism changeMecha Parent = context.Set().Single(IsTheRoot), CompositeChildren = new ObservableHashSet(ReferenceEqualityComparer.Instance) { - new OptionalOverlapping2 { Id = 5 }, - new OptionalOverlapping2 { Id = 6 } + new OptionalOverlapping2 { Id = 5 }, new OptionalOverlapping2 { Id = 6 } } }; @@ -2339,10 +2339,14 @@ public virtual void Save_required_non_PK_one_to_one_changed_by_reference_with_al var new1 = new RequiredNonPkSingleAk1 { AlternateId = Guid.NewGuid(), Single = new2 }; var new1d = new RequiredNonPkSingleAk1Derived { AlternateId = Guid.NewGuid(), Single = new2d, Root = new Root() }; var new1dd = new RequiredNonPkSingleAk1MoreDerived - { AlternateId = Guid.NewGuid(), Single = new2dd, Root = new Root(), DerivedRoot = new Root() }; + { + AlternateId = Guid.NewGuid(), Single = new2dd, Root = new Root(), DerivedRoot = new Root() + }; var newRoot = new Root { - AlternateId = Guid.NewGuid(), RequiredNonPkSingleAk = new1, RequiredNonPkSingleAkDerived = new1d, + AlternateId = Guid.NewGuid(), + RequiredNonPkSingleAk = new1, + RequiredNonPkSingleAkDerived = new1d, RequiredNonPkSingleAkMoreDerived = new1dd }; RequiredNonPkSingleAk1 old1 = null; @@ -2934,11 +2938,11 @@ public virtual void Required_many_to_one_dependents_are_cascade_deleted( ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); Assert.Equal(2, root.RequiredChildren.Count()); @@ -2954,42 +2958,42 @@ public virtual void Required_many_to_one_dependents_are_cascade_deleted( Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Detached)); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Detached)); - Assert.Equal(1, root.RequiredChildren.Count()); - Assert.DoesNotContain(removedId, root.RequiredChildren.Select(e => e.Id)); + Assert.Equal(1, root.RequiredChildren.Count()); + Assert.DoesNotContain(removedId, root.RequiredChildren.Select(e => e.Id)); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); - Assert.Same(root, removed.Parent); - Assert.Equal(2, removed.Children.Count()); - } - }, + Assert.Same(root, removed.Parent); + Assert.Equal(2, removed.Children.Count()); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Equal(1, root.RequiredChildren.Count()); - Assert.DoesNotContain(removedId, root.RequiredChildren.Select(e => e.Id)); + Assert.Equal(1, root.RequiredChildren.Count()); + Assert.DoesNotContain(removedId, root.RequiredChildren.Select(e => e.Id)); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); + } + }); } [ConditionalTheory] @@ -3011,11 +3015,11 @@ public virtual void Optional_many_to_one_dependents_are_orphaned( ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); Assert.Equal(2, root.OptionalChildren.Count()); @@ -3078,11 +3082,11 @@ public virtual void Optional_one_to_one_are_orphaned( ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); var removed = root.OptionalSingle; @@ -3139,11 +3143,11 @@ public virtual void Required_one_to_one_are_cascade_deleted( ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); var removed = root.RequiredSingle; @@ -3155,40 +3159,40 @@ public virtual void Required_one_to_one_are_cascade_deleted( Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); - Assert.Null(root.RequiredSingle); + Assert.Null(root.RequiredSingle); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Null(root.RequiredSingle); + Assert.Null(root.RequiredSingle); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + } + }); } [ConditionalTheory] @@ -3210,11 +3214,11 @@ public virtual void Required_non_PK_one_to_one_are_cascade_deleted( ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); var removed = root.RequiredNonPkSingle; @@ -3226,40 +3230,40 @@ public virtual void Required_non_PK_one_to_one_are_cascade_deleted( Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); - Assert.Null(root.RequiredNonPkSingle); + Assert.Null(root.RequiredNonPkSingle); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Null(root.RequiredNonPkSingle); + Assert.Null(root.RequiredNonPkSingle); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + } + }); } [ConditionalTheory] @@ -3281,11 +3285,11 @@ public virtual void Optional_many_to_one_dependents_with_alternate_key_are_orpha ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); Assert.Equal(2, root.OptionalChildrenAk.Count()); @@ -3350,11 +3354,11 @@ public virtual void Required_many_to_one_dependents_with_alternate_key_are_casca ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); Assert.Equal(2, root.RequiredChildrenAk.Count()); @@ -3373,44 +3377,44 @@ public virtual void Required_many_to_one_dependents_with_alternate_key_are_casca Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Detached)); - Assert.True(cascadeRemovedC.All(e => context.Entry(e).State == EntityState.Detached)); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Detached)); + Assert.True(cascadeRemovedC.All(e => context.Entry(e).State == EntityState.Detached)); - Assert.Equal(1, root.RequiredChildrenAk.Count()); - Assert.DoesNotContain(removedId, root.RequiredChildrenAk.Select(e => e.Id)); + Assert.Equal(1, root.RequiredChildrenAk.Count()); + Assert.DoesNotContain(removedId, root.RequiredChildrenAk.Select(e => e.Id)); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); - Assert.Same(root, removed.Parent); - Assert.Equal(2, removed.Children.Count()); - } - }, + Assert.Same(root, removed.Parent); + Assert.Equal(2, removed.Children.Count()); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Equal(1, root.RequiredChildrenAk.Count()); - Assert.DoesNotContain(removedId, root.RequiredChildrenAk.Select(e => e.Id)); + Assert.Equal(1, root.RequiredChildrenAk.Count()); + Assert.DoesNotContain(removedId, root.RequiredChildrenAk.Select(e => e.Id)); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); - Assert.Empty(context.Set().Where(e => orphanedIdCs.Contains(e.Id))); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); + Assert.Empty(context.Set().Where(e => orphanedIdCs.Contains(e.Id))); + } + }); } [ConditionalTheory] @@ -3433,11 +3437,11 @@ public virtual void Optional_one_to_one_with_alternate_key_are_orphaned( ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); var removed = root.OptionalSingleAk; @@ -3500,11 +3504,11 @@ public virtual void Required_one_to_one_with_alternate_key_are_cascade_deleted( ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); var removed = root.RequiredSingleAk; @@ -3518,43 +3522,43 @@ public virtual void Required_one_to_one_with_alternate_key_are_cascade_deleted( Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); - Assert.Equal(EntityState.Detached, context.Entry(orphanedC).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); + Assert.Equal(EntityState.Detached, context.Entry(orphanedC).State); - Assert.Null(root.RequiredSingleAk); + Assert.Null(root.RequiredSingleAk); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedIdC)); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedIdC)); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Null(root.RequiredSingleAk); + Assert.Null(root.RequiredSingleAk); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedIdC)); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedIdC)); + } + }); } [ConditionalTheory] @@ -3576,11 +3580,11 @@ public virtual void Required_non_PK_one_to_one_with_alternate_key_are_cascade_de ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); var removed = root.RequiredNonPkSingleAk; @@ -3592,40 +3596,40 @@ public virtual void Required_non_PK_one_to_one_with_alternate_key_are_cascade_de Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); - Assert.Null(root.RequiredNonPkSingleAk); + Assert.Null(root.RequiredNonPkSingleAk); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Null(root.RequiredNonPkSingleAk); + Assert.Null(root.RequiredNonPkSingleAk); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + } + }); } [ConditionalTheory] @@ -3656,11 +3660,11 @@ public virtual void Required_many_to_one_dependents_are_cascade_deleted_in_store Assert.Equal(2, orphanedIds.Count); }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = context.Set().Include(e => e.RequiredChildren).Single(IsTheRoot); + var root = context.Set().Include(e => e.RequiredChildren).Single(IsTheRoot); var removed = root.RequiredChildren.Single(e => e.Id == removedId); @@ -3723,11 +3727,11 @@ public virtual void Required_one_to_one_are_cascade_deleted_in_store( orphanedId = removed.Single.Id; }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = context.Set().Include(e => e.RequiredSingle).Single(IsTheRoot); + var root = context.Set().Include(e => e.RequiredSingle).Single(IsTheRoot); var removed = root.RequiredSingle; var orphaned = removed.Single; @@ -3736,39 +3740,39 @@ public virtual void Required_one_to_one_are_cascade_deleted_in_store( Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Null(root.RequiredSingle); + Assert.Null(root.RequiredSingle); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Null(root.RequiredSingle); + Assert.Null(root.RequiredSingle); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + } + }); } [ConditionalTheory] @@ -3797,11 +3801,11 @@ public virtual void Required_non_PK_one_to_one_are_cascade_deleted_in_store( orphanedId = removed.Single.Id; }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = context.Set().Include(e => e.RequiredNonPkSingle).Single(IsTheRoot); + var root = context.Set().Include(e => e.RequiredNonPkSingle).Single(IsTheRoot); var removed = root.RequiredNonPkSingle; var orphaned = removed.Single; @@ -3810,39 +3814,39 @@ public virtual void Required_non_PK_one_to_one_are_cascade_deleted_in_store( Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Null(root.RequiredNonPkSingle); + Assert.Null(root.RequiredNonPkSingle); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Null(root.RequiredNonPkSingle); + Assert.Null(root.RequiredNonPkSingle); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + } + }); } [ConditionalTheory] @@ -3876,11 +3880,11 @@ public virtual void Required_many_to_one_dependents_with_alternate_key_are_casca Assert.Equal(2, orphanedIdCs.Count); }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = context.Set().Include(e => e.RequiredChildrenAk).Single(IsTheRoot); + var root = context.Set().Include(e => e.RequiredChildrenAk).Single(IsTheRoot); var removed = root.RequiredChildrenAk.Single(e => e.Id == removedId); @@ -3945,11 +3949,11 @@ public virtual void Required_one_to_one_with_alternate_key_are_cascade_deleted_i orphanedIdC = removed.SingleComposite.Id; }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = context.Set().Include(e => e.RequiredSingleAk).Single(IsTheRoot); + var root = context.Set().Include(e => e.RequiredSingleAk).Single(IsTheRoot); var removed = root.RequiredSingleAk; var orphaned = removed.Single; @@ -3958,41 +3962,41 @@ public virtual void Required_one_to_one_with_alternate_key_are_cascade_deleted_i Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Null(root.RequiredSingleAk); + Assert.Null(root.RequiredSingleAk); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedIdC)); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedIdC)); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Null(root.RequiredSingleAk); + Assert.Null(root.RequiredSingleAk); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedIdC)); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedIdC)); + } + }); } [ConditionalTheory] @@ -4021,11 +4025,11 @@ public virtual void Required_non_PK_one_to_one_with_alternate_key_are_cascade_de orphanedId = removed.Single.Id; }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = context.Set().Include(e => e.RequiredNonPkSingleAk).Single(IsTheRoot); + var root = context.Set().Include(e => e.RequiredNonPkSingleAk).Single(IsTheRoot); var removed = root.RequiredNonPkSingleAk; var orphaned = removed.Single; @@ -4034,39 +4038,39 @@ public virtual void Required_non_PK_one_to_one_with_alternate_key_are_cascade_de Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Null(root.RequiredNonPkSingleAk); + Assert.Null(root.RequiredNonPkSingleAk); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Null(root.RequiredNonPkSingleAk); + Assert.Null(root.RequiredNonPkSingleAk); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + } + }); } [ConditionalTheory] @@ -4097,11 +4101,11 @@ public virtual void Optional_many_to_one_dependents_are_orphaned_in_store( Assert.Equal(2, orphanedIds.Count); }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = context.Set().Include(e => e.OptionalChildren).Single(IsTheRoot); + var root = context.Set().Include(e => e.OptionalChildren).Single(IsTheRoot); var removed = root.OptionalChildren.First(e => e.Id == removedId); @@ -4170,11 +4174,11 @@ public virtual void Optional_one_to_one_are_orphaned_in_store( orphanedId = removed.Single.Id; }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = context.Set().Include(e => e.OptionalSingle).Single(IsTheRoot); + var root = context.Set().Include(e => e.OptionalSingle).Single(IsTheRoot); var removed = root.OptionalSingle; var orphaned = removed.Single; @@ -4239,11 +4243,11 @@ public virtual void Optional_many_to_one_dependents_with_alternate_key_are_orpha Assert.Equal(2, orphanedIdCs.Count); }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = context.Set().Include(e => e.OptionalChildrenAk).Single(IsTheRoot); + var root = context.Set().Include(e => e.OptionalChildrenAk).Single(IsTheRoot); var removed = root.OptionalChildrenAk.First(e => e.Id == removedId); @@ -4325,11 +4329,11 @@ public virtual void Optional_one_to_one_with_alternate_key_are_orphaned_in_store orphanedIdC = removed.SingleComposite.Id; }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = context.Set().Include(e => e.OptionalSingleAk).Single(IsTheRoot); + var root = context.Set().Include(e => e.OptionalSingleAk).Single(IsTheRoot); var removed = root.OptionalSingleAk; var orphaned = removed.Single; @@ -4399,57 +4403,57 @@ public virtual void Required_many_to_one_dependents_are_cascade_deleted_starting Assert.Equal(2, root.RequiredChildren.Count()); }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - removedId = removed.Id; - orphanedIds = cascadeRemoved.Select(e => e.Id).ToList(); + removedId = removed.Id; + orphanedIds = cascadeRemoved.Select(e => e.Id).ToList(); Assert.Equal(2, orphanedIds.Count); context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate - ? EntityState.Deleted - : EntityState.Unchanged; + var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate + ? EntityState.Deleted + : EntityState.Unchanged; - Assert.True(cascadeRemoved.All(e => context.Entry(e).State == expectedState)); + Assert.True(cascadeRemoved.All(e => context.Entry(e).State == expectedState)); Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Detached)); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Detached)); - Assert.Same(root, removed.Parent); - Assert.Equal(2, removed.Children.Count()); - } - }, + Assert.Same(root, removed.Parent); + Assert.Equal(2, removed.Children.Count()); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - root = LoadRoot(context); + root = LoadRoot(context); - Assert.Equal(1, root.RequiredChildren.Count()); - Assert.DoesNotContain(removedId, root.RequiredChildren.Select(e => e.Id)); + Assert.Equal(1, root.RequiredChildren.Count()); + Assert.DoesNotContain(removedId, root.RequiredChildren.Select(e => e.Id)); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); + } + }); } [ConditionalTheory] @@ -4482,24 +4486,24 @@ public virtual void Optional_many_to_one_dependents_are_orphaned_starting_detach Assert.Equal(2, root.OptionalChildren.Count()); }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - removedId = removed.Id; - orphanedIds = orphaned.Select(e => e.Id).ToList(); + removedId = removed.Id; + orphanedIds = orphaned.Select(e => e.Id).ToList(); Assert.Equal(2, orphanedIds.Count); context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate - ? EntityState.Modified - : EntityState.Unchanged; + var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate + ? EntityState.Modified + : EntityState.Unchanged; - Assert.True(orphaned.All(e => context.Entry(e).State == expectedState)); + Assert.True(orphaned.All(e => context.Entry(e).State == expectedState)); Assert.True(context.ChangeTracker.HasChanges()); @@ -4553,22 +4557,22 @@ public virtual void Optional_one_to_one_are_orphaned_starting_detached( orphaned = removed.Single; }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - removedId = removed.Id; - orphanedId = orphaned.Id; + removedId = removed.Id; + orphanedId = orphaned.Id; context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate - ? EntityState.Modified - : EntityState.Unchanged; + var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate + ? EntityState.Modified + : EntityState.Unchanged; - Assert.Equal(expectedState, context.Entry(orphaned).State); + Assert.Equal(expectedState, context.Entry(orphaned).State); Assert.True(context.ChangeTracker.HasChanges()); @@ -4621,42 +4625,42 @@ public virtual void Required_one_to_one_are_cascade_deleted_starting_detached( orphaned = removed.Single; }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - removedId = removed.Id; - orphanedId = orphaned.Id; + removedId = removed.Id; + orphanedId = orphaned.Id; context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate - ? EntityState.Deleted - : EntityState.Unchanged; + var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate + ? EntityState.Deleted + : EntityState.Unchanged; - Assert.Equal(expectedState, context.Entry(orphaned).State); + Assert.Equal(expectedState, context.Entry(orphaned).State); Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => { if (cascadeDeleteTiming != CascadeTiming.Never) @@ -4698,54 +4702,54 @@ public virtual void Required_non_PK_one_to_one_are_cascade_deleted_starting_deta orphaned = removed.Single; }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - removedId = removed.Id; - orphanedId = orphaned.Id; + removedId = removed.Id; + orphanedId = orphaned.Id; context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate - ? EntityState.Deleted - : EntityState.Unchanged; + var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate + ? EntityState.Deleted + : EntityState.Unchanged; - Assert.Equal(expectedState, context.Entry(orphaned).State); + Assert.Equal(expectedState, context.Entry(orphaned).State); Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - root = LoadRoot(context); + root = LoadRoot(context); - Assert.Null(root.RequiredNonPkSingle); + Assert.Null(root.RequiredNonPkSingle); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + } + }); } [ConditionalTheory] @@ -4781,27 +4785,27 @@ public virtual void Optional_many_to_one_dependents_with_alternate_key_are_orpha Assert.Equal(2, root.OptionalChildrenAk.Count()); }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - removedId = removed.Id; - orphanedIds = orphaned.Select(e => e.Id).ToList(); - orphanedIdCs = orphanedC.Select(e => e.Id).ToList(); + removedId = removed.Id; + orphanedIds = orphaned.Select(e => e.Id).ToList(); + orphanedIdCs = orphanedC.Select(e => e.Id).ToList(); Assert.Equal(2, orphanedIds.Count); Assert.Equal(2, orphanedIdCs.Count); context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate - ? EntityState.Modified - : EntityState.Unchanged; + var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate + ? EntityState.Modified + : EntityState.Unchanged; - Assert.True(orphaned.All(e => context.Entry(e).State == expectedState)); - Assert.True(orphanedC.All(e => context.Entry(e).State == expectedState)); + Assert.True(orphaned.All(e => context.Entry(e).State == expectedState)); + Assert.True(orphanedC.All(e => context.Entry(e).State == expectedState)); Assert.True(context.ChangeTracker.HasChanges()); @@ -4862,61 +4866,61 @@ public virtual void Required_many_to_one_dependents_with_alternate_key_are_casca Assert.Equal(2, root.RequiredChildrenAk.Count()); }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - removedId = removed.Id; - orphanedIds = cascadeRemoved.Select(e => e.Id).ToList(); - orphanedIdCs = cascadeRemovedC.Select(e => e.Id).ToList(); + removedId = removed.Id; + orphanedIds = cascadeRemoved.Select(e => e.Id).ToList(); + orphanedIdCs = cascadeRemovedC.Select(e => e.Id).ToList(); Assert.Equal(2, orphanedIds.Count); context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate - ? EntityState.Deleted - : EntityState.Unchanged; + var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate + ? EntityState.Deleted + : EntityState.Unchanged; - Assert.True(cascadeRemoved.All(e => context.Entry(e).State == expectedState)); - Assert.True(cascadeRemovedC.All(e => context.Entry(e).State == expectedState)); + Assert.True(cascadeRemoved.All(e => context.Entry(e).State == expectedState)); + Assert.True(cascadeRemovedC.All(e => context.Entry(e).State == expectedState)); Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Detached)); - Assert.True(cascadeRemovedC.All(e => context.Entry(e).State == EntityState.Detached)); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Detached)); + Assert.True(cascadeRemovedC.All(e => context.Entry(e).State == EntityState.Detached)); - Assert.Same(root, removed.Parent); - Assert.Equal(2, removed.Children.Count()); - } - }, + Assert.Same(root, removed.Parent); + Assert.Equal(2, removed.Children.Count()); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - root = LoadRoot(context); + root = LoadRoot(context); - Assert.Equal(1, root.RequiredChildrenAk.Count()); - Assert.DoesNotContain(removedId, root.RequiredChildrenAk.Select(e => e.Id)); + Assert.Equal(1, root.RequiredChildrenAk.Count()); + Assert.DoesNotContain(removedId, root.RequiredChildrenAk.Select(e => e.Id)); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); - Assert.Empty(context.Set().Where(e => orphanedIdCs.Contains(e.Id))); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); + Assert.Empty(context.Set().Where(e => orphanedIdCs.Contains(e.Id))); + } + }); } [ConditionalTheory] @@ -4950,24 +4954,24 @@ public virtual void Optional_one_to_one_with_alternate_key_are_orphaned_starting orphanedC = removed.SingleComposite; }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - removedId = removed.Id; - orphanedId = orphaned.Id; - orphanedIdC = orphanedC.Id; + removedId = removed.Id; + orphanedId = orphaned.Id; + orphanedIdC = orphanedC.Id; context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate - ? EntityState.Modified - : EntityState.Unchanged; + var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate + ? EntityState.Modified + : EntityState.Unchanged; - Assert.Equal(expectedState, context.Entry(orphaned).State); - Assert.Equal(expectedState, context.Entry(orphanedC).State); + Assert.Equal(expectedState, context.Entry(orphaned).State); + Assert.Equal(expectedState, context.Entry(orphanedC).State); Assert.True(context.ChangeTracker.HasChanges()); @@ -5025,58 +5029,58 @@ public virtual void Required_one_to_one_with_alternate_key_are_cascade_deleted_s orphanedC = removed.SingleComposite; }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - removedId = removed.Id; - orphanedId = orphaned.Id; - orphanedIdC = orphanedC.Id; + removedId = removed.Id; + orphanedId = orphaned.Id; + orphanedIdC = orphanedC.Id; context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate - ? EntityState.Deleted - : EntityState.Unchanged; + var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate + ? EntityState.Deleted + : EntityState.Unchanged; - Assert.Equal(expectedState, context.Entry(orphaned).State); - Assert.Equal(expectedState, context.Entry(orphanedC).State); + Assert.Equal(expectedState, context.Entry(orphaned).State); + Assert.Equal(expectedState, context.Entry(orphanedC).State); Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); - Assert.Equal(EntityState.Detached, context.Entry(orphanedC).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); + Assert.Equal(EntityState.Detached, context.Entry(orphanedC).State); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - root = LoadRoot(context); + root = LoadRoot(context); - Assert.Null(root.RequiredSingleAk); + Assert.Null(root.RequiredSingleAk); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedIdC)); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedIdC)); + } + }); } [ConditionalTheory] @@ -5107,54 +5111,54 @@ public virtual void Required_non_PK_one_to_one_with_alternate_key_are_cascade_de orphaned = removed.Single; }, context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - removedId = removed.Id; - orphanedId = orphaned.Id; + removedId = removed.Id; + orphanedId = orphaned.Id; context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate - ? EntityState.Deleted - : EntityState.Unchanged; + var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate + ? EntityState.Deleted + : EntityState.Unchanged; - Assert.Equal(expectedState, context.Entry(orphaned).State); + Assert.Equal(expectedState, context.Entry(orphaned).State); Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - root = LoadRoot(context); + root = LoadRoot(context); - Assert.Null(root.RequiredNonPkSingleAk); + Assert.Null(root.RequiredNonPkSingleAk); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + } + }); } [ConditionalTheory] @@ -5176,11 +5180,11 @@ public virtual void Required_many_to_one_dependents_are_cascade_detached_when_Ad ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); Assert.Equal(2, root.RequiredChildren.Count()); @@ -5200,59 +5204,59 @@ public virtual void Required_many_to_one_dependents_are_cascade_detached_when_Ad context.ChangeTracker.DetectChanges(); } - Assert.Equal(EntityState.Unchanged, context.Entry(removed).State); + Assert.Equal(EntityState.Unchanged, context.Entry(removed).State); - Assert.Equal(EntityState.Added, context.Entry(added).State); - Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Unchanged)); + Assert.Equal(EntityState.Added, context.Entry(added).State); + Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Unchanged)); context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - if (cascadeDeleteTiming == CascadeTiming.Immediate) - { - Assert.Equal(EntityState.Detached, context.Entry(added).State); - Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Deleted)); - } - else - { - Assert.Equal(EntityState.Added, context.Entry(added).State); - Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Unchanged)); - } + if (cascadeDeleteTiming == CascadeTiming.Immediate) + { + Assert.Equal(EntityState.Detached, context.Entry(added).State); + Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Deleted)); + } + else + { + Assert.Equal(EntityState.Added, context.Entry(added).State); + Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Unchanged)); + } Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Equal(EntityState.Detached, context.Entry(added).State); - Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Detached)); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(added).State); + Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Detached)); - Assert.Same(root, removed.Parent); - Assert.Equal(3, removed.Children.Count()); - } - }, + Assert.Same(root, removed.Parent); + Assert.Equal(3, removed.Children.Count()); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Equal(1, root.RequiredChildren.Count()); - Assert.DoesNotContain(removedId, root.RequiredChildren.Select(e => e.Id)); + Assert.Equal(1, root.RequiredChildren.Count()); + Assert.DoesNotContain(removedId, root.RequiredChildren.Select(e => e.Id)); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); + } + }); } [ConditionalTheory] @@ -5274,11 +5278,11 @@ public virtual void Required_one_to_one_are_cascade_detached_when_Added( ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); var removed = root.RequiredSingle; @@ -5293,45 +5297,45 @@ public virtual void Required_one_to_one_are_cascade_detached_when_Added( context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate - ? EntityState.Detached - : EntityState.Added; + var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate + ? EntityState.Detached + : EntityState.Added; - Assert.Equal(expectedState, context.Entry(orphaned).State); + Assert.Equal(expectedState, context.Entry(orphaned).State); Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Null(root.RequiredSingle); + Assert.Null(root.RequiredSingle); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + } + }); } [ConditionalTheory] @@ -5353,11 +5357,11 @@ public virtual void Required_non_PK_one_to_one_are_cascade_detached_when_Added( ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); var removed = root.RequiredNonPkSingle; @@ -5372,45 +5376,45 @@ public virtual void Required_non_PK_one_to_one_are_cascade_detached_when_Added( context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate - ? EntityState.Detached - : EntityState.Added; + var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate + ? EntityState.Detached + : EntityState.Added; - Assert.Equal(expectedState, context.Entry(orphaned).State); + Assert.Equal(expectedState, context.Entry(orphaned).State); Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Null(root.RequiredNonPkSingle); + Assert.Null(root.RequiredNonPkSingle); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + } + }); } [ConditionalTheory] @@ -5433,11 +5437,11 @@ public virtual void Required_many_to_one_dependents_with_alternate_key_are_casca ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); Assert.Equal(2, root.RequiredChildrenAk.Count()); @@ -5470,59 +5474,59 @@ public virtual void Required_many_to_one_dependents_with_alternate_key_are_casca context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - if (cascadeDeleteTiming == CascadeTiming.Immediate) - { - Assert.Equal(EntityState.Detached, context.Entry(added).State); - Assert.Equal(EntityState.Detached, context.Entry(addedC).State); - Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Deleted)); - Assert.True(cascadeRemovedC.All(e => context.Entry(e).State == EntityState.Deleted)); - } - else - { - Assert.Equal(EntityState.Added, context.Entry(added).State); - Assert.Equal(EntityState.Added, context.Entry(addedC).State); - Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Unchanged)); - Assert.True(cascadeRemovedC.All(e => context.Entry(e).State == EntityState.Unchanged)); - } + if (cascadeDeleteTiming == CascadeTiming.Immediate) + { + Assert.Equal(EntityState.Detached, context.Entry(added).State); + Assert.Equal(EntityState.Detached, context.Entry(addedC).State); + Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Deleted)); + Assert.True(cascadeRemovedC.All(e => context.Entry(e).State == EntityState.Deleted)); + } + else + { + Assert.Equal(EntityState.Added, context.Entry(added).State); + Assert.Equal(EntityState.Added, context.Entry(addedC).State); + Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Unchanged)); + Assert.True(cascadeRemovedC.All(e => context.Entry(e).State == EntityState.Unchanged)); + } Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Equal(EntityState.Detached, context.Entry(added).State); - Assert.Equal(EntityState.Detached, context.Entry(addedC).State); - Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Detached)); - Assert.True(cascadeRemovedC.All(e => context.Entry(e).State == EntityState.Detached)); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(added).State); + Assert.Equal(EntityState.Detached, context.Entry(addedC).State); + Assert.True(cascadeRemoved.All(e => context.Entry(e).State == EntityState.Detached)); + Assert.True(cascadeRemovedC.All(e => context.Entry(e).State == EntityState.Detached)); - Assert.Same(root, removed.Parent); - Assert.Equal(3, removed.Children.Count()); - } - }, + Assert.Same(root, removed.Parent); + Assert.Equal(3, removed.Children.Count()); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Equal(1, root.RequiredChildrenAk.Count()); - Assert.DoesNotContain(removedId, root.RequiredChildrenAk.Select(e => e.Id)); + Assert.Equal(1, root.RequiredChildrenAk.Count()); + Assert.DoesNotContain(removedId, root.RequiredChildrenAk.Select(e => e.Id)); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); - Assert.Empty(context.Set().Where(e => orphanedIdCs.Contains(e.Id))); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => orphanedIds.Contains(e.Id))); + Assert.Empty(context.Set().Where(e => orphanedIdCs.Contains(e.Id))); + } + }); } [ConditionalTheory] @@ -5545,11 +5549,11 @@ public virtual void Required_one_to_one_with_alternate_key_are_cascade_detached_ ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); var removed = root.RequiredSingleAk; @@ -5568,48 +5572,48 @@ public virtual void Required_one_to_one_with_alternate_key_are_cascade_detached_ context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate - ? EntityState.Detached - : EntityState.Added; + var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate + ? EntityState.Detached + : EntityState.Added; - Assert.Equal(expectedState, context.Entry(orphaned).State); - Assert.Equal(expectedState, context.Entry(orphanedC).State); + Assert.Equal(expectedState, context.Entry(orphaned).State); + Assert.Equal(expectedState, context.Entry(orphanedC).State); Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); - Assert.Equal(EntityState.Detached, context.Entry(orphanedC).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); + Assert.Equal(EntityState.Detached, context.Entry(orphanedC).State); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Null(root.RequiredSingleAk); + Assert.Null(root.RequiredSingleAk); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedIdC)); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedIdC)); + } + }); } [ConditionalTheory] @@ -5631,11 +5635,11 @@ public virtual void Required_non_PK_one_to_one_with_alternate_key_are_cascade_de ExecuteWithStrategyInTransaction( context => - { - context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; - context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; + { + context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; + context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; - var root = LoadRoot(context); + var root = LoadRoot(context); var removed = root.RequiredNonPkSingleAk; @@ -5650,45 +5654,45 @@ public virtual void Required_non_PK_one_to_one_with_alternate_key_are_cascade_de context.Remove(removed); - Assert.Equal(EntityState.Deleted, context.Entry(removed).State); + Assert.Equal(EntityState.Deleted, context.Entry(removed).State); - var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate - ? EntityState.Detached - : EntityState.Added; + var expectedState = cascadeDeleteTiming == CascadeTiming.Immediate + ? EntityState.Detached + : EntityState.Added; - Assert.Equal(expectedState, context.Entry(orphaned).State); + Assert.Equal(expectedState, context.Entry(orphaned).State); Assert.True(context.ChangeTracker.HasChanges()); - if (cascadeDeleteTiming == CascadeTiming.Never) - { - Assert.Throws(() => context.SaveChanges()); - } - else - { - context.SaveChanges(); + if (cascadeDeleteTiming == CascadeTiming.Never) + { + Assert.Throws(() => context.SaveChanges()); + } + else + { + context.SaveChanges(); - Assert.False(context.ChangeTracker.HasChanges()); + Assert.False(context.ChangeTracker.HasChanges()); - Assert.Equal(EntityState.Detached, context.Entry(removed).State); - Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); + Assert.Equal(EntityState.Detached, context.Entry(removed).State); + Assert.Equal(EntityState.Detached, context.Entry(orphaned).State); - Assert.Same(root, removed.Root); - Assert.Same(orphaned, removed.Single); - } - }, + Assert.Same(root, removed.Root); + Assert.Same(orphaned, removed.Single); + } + }, context => + { + if (cascadeDeleteTiming != CascadeTiming.Never) { - if (cascadeDeleteTiming != CascadeTiming.Never) - { - var root = LoadRoot(context); + var root = LoadRoot(context); - Assert.Null(root.RequiredNonPkSingleAk); + Assert.Null(root.RequiredNonPkSingleAk); - Assert.Empty(context.Set().Where(e => e.Id == removedId)); - Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); - } - }); + Assert.Empty(context.Set().Where(e => e.Id == removedId)); + Assert.Empty(context.Set().Where(e => e.Id == orphanedId)); + } + }); } [ConditionalFact] diff --git a/test/EFCore.Specification.Tests/Query/AsNoTrackingTestBase.cs b/test/EFCore.Specification.Tests/Query/AsNoTrackingTestBase.cs index 82fe071f1d0..f83bff803d9 100644 --- a/test/EFCore.Specification.Tests/Query/AsNoTrackingTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/AsNoTrackingTestBase.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable InconsistentNaming @@ -62,11 +61,7 @@ var customers = (from c in context.Set().AsNoTracking() from o in context.Set().AsNoTracking() where c.CustomerID == o.CustomerID - select new - { - c, - o - }) + select new { c, o }) .ToList(); Assert.Equal(830, customers.Count); @@ -84,13 +79,7 @@ var customers join o in context.Set().AsNoTracking() on c.CustomerID equals o.CustomerID where c.CustomerID == "ALFKI" - select new - { - c.CustomerID, - c, - ocid = o.CustomerID, - o - }) + select new { c.CustomerID, c, ocid = o.CustomerID, o }) .ToList(); Assert.Equal(6, customers.Count); @@ -108,11 +97,7 @@ var customers join o in context.Set().AsNoTracking() on c.CustomerID equals o.CustomerID where c.CustomerID == "ALFKI" - select new - { - c, - o - }) + select new { c, o }) .AsNoTracking() .ToList(); @@ -214,11 +199,7 @@ public virtual void SelectMany_simple() var results = (from e in context.Set() from c in context.Set() - select new - { - c, - e - }) + select new { c, e }) .AsNoTracking() .ToList(); diff --git a/test/EFCore.Specification.Tests/Query/AsTrackingTestBase.cs b/test/EFCore.Specification.Tests/Query/AsTrackingTestBase.cs index eb207d036a4..f51fc3c2b3a 100644 --- a/test/EFCore.Specification.Tests/Query/AsTrackingTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/AsTrackingTestBase.cs @@ -59,11 +59,7 @@ var customers = (from c in context.Set().AsTracking() from o in context.Set().AsTracking() where c.CustomerID == o.CustomerID - select new - { - c, - o - }) + select new { c, o }) .ToList(); Assert.Equal(830, customers.Count); @@ -81,13 +77,7 @@ var customers join o in context.Set().AsTracking() on c.CustomerID equals o.CustomerID where c.CustomerID == "ALFKI" - select new - { - c.CustomerID, - c, - ocid = o.CustomerID, - o - }) + select new { c.CustomerID, c, ocid = o.CustomerID, o }) .ToList(); Assert.Equal(6, customers.Count); @@ -105,11 +95,7 @@ var customers join o in context.Set().AsTracking() on c.CustomerID equals o.CustomerID where c.CustomerID == "ALFKI" - select new - { - c, - o - }) + select new { c, o }) .AsTracking() .ToList(); diff --git a/test/EFCore.Specification.Tests/Query/AsyncGearsOfWarQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/AsyncGearsOfWarQueryTestBase.cs index 4bea8c7bf83..cd8df4bc7da 100644 --- a/test/EFCore.Specification.Tests/Query/AsyncGearsOfWarQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/AsyncGearsOfWarQueryTestBase.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable InconsistentNaming diff --git a/test/EFCore.Specification.Tests/Query/AsyncSimpleQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/AsyncSimpleQueryTestBase.cs index 6015f78e36c..1e7d33b1d5a 100644 --- a/test/EFCore.Specification.Tests/Query/AsyncSimpleQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/AsyncSimpleQueryTestBase.cs @@ -67,10 +67,7 @@ public virtual async Task ToList_context_subquery_deadlock_issue() c.CustomerID, Posts = context.Orders.Where(o => o.CustomerID == c.CustomerID) .Select( - m => new - { - m.CustomerID - }) + m => new { m.CustomerID }) .ToList() }) .ToListAsync(); @@ -84,10 +81,7 @@ public virtual async Task ToArray_on_nav_subquery_in_projection() { var results = await context.Customers.Select( - c => new - { - Orders = c.Orders.ToArray() - }) + c => new { Orders = c.Orders.ToArray() }) .ToListAsync(); Assert.Equal(830, results.SelectMany(a => a.Orders).ToList().Count); @@ -104,10 +98,7 @@ var results c => new { Orders = c.Orders.Select( - o => new - { - OrderDetails = o.OrderDetails.ToArray() - }) + o => new { OrderDetails = o.OrderDetails.ToArray() }) .ToArray() }) .ToListAsync(); @@ -123,10 +114,7 @@ public virtual async Task ToList_on_nav_subquery_in_projection() { var results = await context.Customers.Select( - c => new - { - Orders = c.Orders.ToList() - }) + c => new { Orders = c.Orders.ToList() }) .ToListAsync(); Assert.Equal(830, results.SelectMany(a => a.Orders).ToList().Count); @@ -140,10 +128,7 @@ public virtual async Task ToList_on_nav_subquery_with_predicate_in_projection() { var results = await context.Customers.Select( - c => new - { - Orders = c.Orders.Where(o => o.OrderID > 10).ToList() - }) + c => new { Orders = c.Orders.Where(o => o.OrderID > 10).ToList() }) .ToListAsync(); Assert.Equal(830, results.SelectMany(a => a.Orders).ToList().Count); @@ -157,10 +142,7 @@ public virtual async Task Average_on_nav_subquery_in_projection() { var results = await context.Customers.Select( - c => new - { - Ave = c.Orders.Average(o => o.Freight) - }) + c => new { Ave = c.Orders.Average(o => o.Freight) }) .ToListAsync(); Assert.Equal(91, results.ToList().Count); @@ -210,20 +192,14 @@ public virtual async Task Mixed_sync_async_query() var results = (await context.Customers .Select( - c => new - { - c.CustomerID, - Orders = context.Orders.Where(o => o.Customer.CustomerID == c.CustomerID) - }).ToListAsync()) + c => new { c.CustomerID, Orders = context.Orders.Where(o => o.Customer.CustomerID == c.CustomerID) }) + .ToListAsync()) .Select( x => new { Orders = x.Orders .GroupJoin( - new[] { "ALFKI" }, y => x.CustomerID, y => y, (h, id) => new - { - h.Customer - }) + new[] { "ALFKI" }, y => x.CustomerID, y => y, (h, id) => new { h.Customer }) }) .ToList(); @@ -469,11 +445,7 @@ public virtual async Task Select_bitwise_or() using (var context = CreateContext()) { var query = await context.Customers.OrderBy(c => c.CustomerID).Select( - c => new - { - c.CustomerID, - Value = c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" - }).ToListAsync(); + c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" }).ToListAsync(); Assert.All(query.Take(2), t => Assert.True(t.Value)); Assert.All(query.Skip(2), t => Assert.False(t.Value)); @@ -487,11 +459,8 @@ public virtual async Task Select_bitwise_or_multiple() { var query = await context.Customers.OrderBy(c => c.CustomerID) .Select( - c => new - { - c.CustomerID, - Value = c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" | c.CustomerID == "ANTON" - }).ToListAsync(); + c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" | c.CustomerID == "ANTON" }) + .ToListAsync(); Assert.All(query.Take(3), t => Assert.True(t.Value)); Assert.All(query.Skip(3), t => Assert.False(t.Value)); @@ -504,11 +473,7 @@ public virtual async Task Select_bitwise_and() using (var context = CreateContext()) { var query = await context.Customers.OrderBy(c => c.CustomerID).Select( - c => new - { - c.CustomerID, - Value = c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" - }).ToListAsync(); + c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" }).ToListAsync(); Assert.All(query, t => Assert.False(t.Value)); } @@ -521,11 +486,8 @@ public virtual async Task Select_bitwise_and_or() { var query = await context.Customers.OrderBy(c => c.CustomerID) .Select( - c => new - { - c.CustomerID, - Value = c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" | c.CustomerID == "ANTON" - }).ToListAsync(); + c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" | c.CustomerID == "ANTON" }) + .ToListAsync(); Assert.All(query.Where(c => c.CustomerID != "ANTON"), t => Assert.False(t.Value)); } @@ -537,11 +499,8 @@ public virtual async Task Select_bitwise_or_with_logical_or() using (var context = CreateContext()) { var query = await context.Customers.OrderBy(c => c.CustomerID).Select( - c => new - { - c.CustomerID, - Value = c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" || c.CustomerID == "ANTON" - }).ToListAsync(); + c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" || c.CustomerID == "ANTON" }) + .ToListAsync(); Assert.All(query.Take(3), t => Assert.True(t.Value)); Assert.All(query.Skip(3), t => Assert.False(t.Value)); @@ -554,11 +513,8 @@ public virtual async Task Select_bitwise_and_with_logical_and() using (var context = CreateContext()) { var query = await context.Customers.OrderBy(c => c.CustomerID).Select( - c => new - { - c.CustomerID, - Value = c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" && c.CustomerID == "ANTON" - }).ToListAsync(); + c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" && c.CustomerID == "ANTON" }) + .ToListAsync(); Assert.All(query, t => Assert.False(t.Value)); } diff --git a/test/EFCore.Specification.Tests/Query/CompiledQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/CompiledQueryTestBase.cs index 1dfbd83fd36..120482648f3 100644 --- a/test/EFCore.Specification.Tests/Query/CompiledQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/CompiledQueryTestBase.cs @@ -213,14 +213,16 @@ public virtual void Query_with_array_parameter() using (var context = CreateContext()) { - Assert.Equal("Unsupported Binary operator type specified.", + Assert.Equal( + "Unsupported Binary operator type specified.", Assert.Throws( () => query(context, new[] { "ALFKI" }).First().CustomerID).Message); } using (var context = CreateContext()) { - Assert.Equal("Unsupported Binary operator type specified.", + Assert.Equal( + "Unsupported Binary operator type specified.", Assert.Throws( () => query(context, new[] { "ANATR" }).First().CustomerID).Message); } @@ -477,14 +479,16 @@ public virtual async Task Query_with_array_parameter_async() using (var context = CreateContext()) { - Assert.Equal("Unsupported Binary operator type specified.", + Assert.Equal( + "Unsupported Binary operator type specified.", (await Assert.ThrowsAsync( () => query(context, new[] { "ALFKI" }).ToListAsync())).Message); } using (var context = CreateContext()) { - Assert.Equal("Unsupported Binary operator type specified.", + Assert.Equal( + "Unsupported Binary operator type specified.", (await Assert.ThrowsAsync( () => query(context, new[] { "ANATR" }).ToListAsync())).Message); } diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryFixtureBase.cs index a7fe5c3992f..2fd70f09762 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryFixtureBase.cs @@ -34,8 +34,7 @@ protected ComplexNavigationsQueryFixtureBase() var entityAsserters = new Dictionary> { { - typeof(Level1), - (e, a) => + typeof(Level1), (e, a) => { Assert.Equal(e == null, a == null); @@ -48,8 +47,7 @@ protected ComplexNavigationsQueryFixtureBase() } }, { - typeof(Level2), - (e, a) => + typeof(Level2), (e, a) => { Assert.Equal(e == null, a == null); @@ -64,8 +62,7 @@ protected ComplexNavigationsQueryFixtureBase() } }, { - typeof(Level3), - (e, a) => + typeof(Level3), (e, a) => { Assert.Equal(e == null, a == null); @@ -79,8 +76,7 @@ protected ComplexNavigationsQueryFixtureBase() } }, { - typeof(Level4), - (e, a) => + typeof(Level4), (e, a) => { Assert.Equal(e == null, a == null); @@ -94,8 +90,7 @@ protected ComplexNavigationsQueryFixtureBase() } }, { - typeof(InheritanceBase1), - (e, a) => + typeof(InheritanceBase1), (e, a) => { Assert.Equal(e == null, a == null); @@ -107,8 +102,7 @@ protected ComplexNavigationsQueryFixtureBase() } }, { - typeof(InheritanceBase2), - (e, a) => + typeof(InheritanceBase2), (e, a) => { Assert.Equal(e == null, a == null); @@ -120,8 +114,7 @@ protected ComplexNavigationsQueryFixtureBase() } }, { - typeof(InheritanceDerived1), - (e, a) => + typeof(InheritanceDerived1), (e, a) => { Assert.Equal(e == null, a == null); @@ -133,8 +126,7 @@ protected ComplexNavigationsQueryFixtureBase() } }, { - typeof(InheritanceDerived2), - (e, a) => + typeof(InheritanceDerived2), (e, a) => { Assert.Equal(e == null, a == null); @@ -146,8 +138,7 @@ protected ComplexNavigationsQueryFixtureBase() } }, { - typeof(InheritanceLeaf1), - (e, a) => + typeof(InheritanceLeaf1), (e, a) => { Assert.Equal(e == null, a == null); @@ -159,8 +150,7 @@ protected ComplexNavigationsQueryFixtureBase() } }, { - typeof(InheritanceLeaf2), - (e, a) => + typeof(InheritanceLeaf2), (e, a) => { Assert.Equal(e == null, a == null); diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs index 7433840c774..3241c17bcc0 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestModels.ComplexNavigationsModel; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; @@ -154,10 +153,7 @@ public virtual Task Key_equality_navigation_converted_to_FK(bool isAsync) return AssertQuery( isAsync, l2s => l2s.Where( - l => l.OneToOne_Required_FK_Inverse2 == new Level1 - { - Id = 1 - }), + l => l.OneToOne_Required_FK_Inverse2 == new Level1 { Id = 1 }), l2s => l2s.Where(l => l.OneToOne_Required_FK_Inverse2.Id == 1), e => e.Id, (e, a) => Assert.Equal(e.Id, a.Id)); @@ -170,14 +166,8 @@ public virtual Task Key_equality_two_conditions_on_same_navigation(bool isAsync) return AssertQuery( isAsync, l1s => l1s.Where( - l => l.OneToOne_Required_FK1 == new Level2 - { - Id = 1 - } - || l.OneToOne_Required_FK1 == new Level2 - { - Id = 2 - }), + l => l.OneToOne_Required_FK1 == new Level2 { Id = 1 } + || l.OneToOne_Required_FK1 == new Level2 { Id = 2 }), l1s => l1s.Where( l => MaybeScalar(l.OneToOne_Required_FK1, () => l.OneToOne_Required_FK1.Id) == 1 || MaybeScalar(l.OneToOne_Required_FK1, () => l.OneToOne_Required_FK1.Id) == 2), @@ -192,14 +182,8 @@ public virtual Task Key_equality_two_conditions_on_same_navigation2(bool isAsync return AssertQuery( isAsync, l2s => l2s.Where( - l => l.OneToOne_Required_FK_Inverse2 == new Level1 - { - Id = 1 - } - || l.OneToOne_Required_FK_Inverse2 == new Level1 - { - Id = 2 - }), + l => l.OneToOne_Required_FK_Inverse2 == new Level1 { Id = 1 } + || l.OneToOne_Required_FK_Inverse2 == new Level1 { Id = 2 }), l2s => l2s.Where( l => l.OneToOne_Required_FK_Inverse2.Id == 1 || l.OneToOne_Required_FK_Inverse2.Id == 2), @@ -226,7 +210,8 @@ public virtual Task Multi_level_include_one_to_many_optional_and_one_to_many_opt [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Multi_level_include_correct_PK_is_chosen_as_the_join_predicate_for_queries_that_join_same_table_multiple_times(bool isAsync) + public virtual Task Multi_level_include_correct_PK_is_chosen_as_the_join_predicate_for_queries_that_join_same_table_multiple_times( + bool isAsync) { var expectedIncludes = new List { @@ -304,21 +289,13 @@ public virtual Task Join_navigation_key_access_optional(bool isAsync) (l1s, l2s) => from e1 in l1s join e2 in l2s on e1.Id equals e2.OneToOne_Optional_FK_Inverse2.Id - select new - { - Id1 = e1.Id, - Id2 = e2.Id - }, + select new { Id1 = e1.Id, Id2 = e2.Id }, (l1s, l2s) => from e1 in l1s join e2 in l2s on e1.Id equals MaybeScalar( e2.OneToOne_Optional_FK_Inverse2, () => e2.OneToOne_Optional_FK_Inverse2.Id) - select new - { - Id1 = e1.Id, - Id2 = e2.Id - }, + select new { Id1 = e1.Id, Id2 = e2.Id }, e => e.Id1 + " " + e.Id2); } @@ -331,19 +308,11 @@ public virtual Task Join_navigation_key_access_required(bool isAsync) (l1s, l2s) => from e1 in l1s join e2 in l2s on e1.Id equals e2.OneToOne_Required_FK_Inverse2.Id - select new - { - Id1 = e1.Id, - Id2 = e2.Id - }, + select new { Id1 = e1.Id, Id2 = e2.Id }, (l1s, l2s) => from e1 in l1s join e2 in l2s on e1.Id equals e2.OneToOne_Required_FK_Inverse2.Id - select new - { - Id1 = e1.Id, - Id2 = e2.Id - }, + select new { Id1 = e1.Id, Id2 = e2.Id }, e => e.Id1 + " " + e.Id2); } @@ -416,10 +385,7 @@ public virtual Task Simple_level1_level2_GroupBy_Having_Count(bool isAsync) isAsync, l1s => l1s.GroupBy( l1 => l1.OneToOne_Required_PK1.OneToOne_Required_PK2.Name, - l1 => new - { - Id = ((int?)l1.OneToOne_Required_PK1.Id ?? 0) - }) + l1 => new { Id = ((int?)l1.OneToOne_Required_PK1.Id ?? 0) }) .Where(g => g.Min(l1 => l1.Id) > 0) .Select(g => g.Count()), l1s => l1s.GroupBy( @@ -428,10 +394,7 @@ public virtual Task Simple_level1_level2_GroupBy_Having_Count(bool isAsync) () => Maybe( l1.OneToOne_Required_PK1.OneToOne_Required_PK2, () => l1.OneToOne_Required_PK1.OneToOne_Required_PK2.Name)), - l1 => new - { - Id = (MaybeScalar(l1.OneToOne_Required_PK1, () => l1.OneToOne_Required_PK1.Id) ?? 0) - }) + l1 => new { Id = (MaybeScalar(l1.OneToOne_Required_PK1, () => l1.OneToOne_Required_PK1.Id) ?? 0) }) .Where(g => g.Min(l1 => l1.Id) > 0) .Select(g => g.Count())); } @@ -634,19 +597,11 @@ public virtual Task Join_navigation_in_outer_selector_translated_to_extra_join(b (l1s, l2s) => from e1 in l1s join e2 in l2s on e1.OneToOne_Optional_FK1.Id equals e2.Id - select new - { - Id1 = e1.Id, - Id2 = e2.Id - }, + select new { Id1 = e1.Id, Id2 = e2.Id }, (l1s, l2s) => from e1 in l1s join e2 in l2s on MaybeScalar(e1.OneToOne_Optional_FK1, () => e1.OneToOne_Optional_FK1.Id) equals e2.Id - select new - { - Id1 = e1.Id, - Id2 = e2.Id - }, + select new { Id1 = e1.Id, Id2 = e2.Id }, e => e.Id1 + " " + e.Id2); } @@ -659,11 +614,7 @@ public virtual Task Join_navigation_in_outer_selector_translated_to_extra_join_n (l1s, l3s) => from e1 in l1s join e3 in l3s on e1.OneToOne_Required_FK1.OneToOne_Optional_FK2.Id equals e3.Id - select new - { - Id1 = e1.Id, - Id3 = e3.Id - }, + select new { Id1 = e1.Id, Id3 = e3.Id }, (l1s, l3s) => from e1 in l1s join e3 in l3s on MaybeScalar( @@ -671,11 +622,7 @@ join e3 in l3s on MaybeScalar( () => MaybeScalar( e1.OneToOne_Required_FK1.OneToOne_Optional_FK2, () => e1.OneToOne_Required_FK1.OneToOne_Optional_FK2.Id)) equals e3.Id - select new - { - Id1 = e1.Id, - Id3 = e3.Id - }, + select new { Id1 = e1.Id, Id3 = e3.Id }, e => e.Id1 + " " + e.Id3); } @@ -688,21 +635,13 @@ public virtual Task Join_navigation_in_outer_selector_translated_to_extra_join_n (l1s, l3s) => from e3 in l3s join e1 in l1s on e3.OneToOne_Required_FK_Inverse3.OneToOne_Optional_FK_Inverse2.Id equals e1.Id - select new - { - Id3 = e3.Id, - Id1 = e1.Id - }, + select new { Id3 = e3.Id, Id1 = e1.Id }, (l1s, l3s) => from e3 in l3s join e1 in l1s on MaybeScalar( e3.OneToOne_Required_FK_Inverse3.OneToOne_Optional_FK_Inverse2, () => e3.OneToOne_Required_FK_Inverse3.OneToOne_Optional_FK_Inverse2.Id) equals e1.Id - select new - { - Id3 = e3.Id, - Id1 = e1.Id - }, + select new { Id3 = e3.Id, Id1 = e1.Id }, e => e.Id1 + " " + e.Id3); } @@ -715,19 +654,11 @@ public virtual Task Join_navigation_in_inner_selector(bool isAsync) (l1s, l2s) => from e2 in l2s join e1 in l1s on e2.Id equals e1.OneToOne_Optional_FK1.Id - select new - { - Id2 = e2.Id, - Id1 = e1.Id - }, + select new { Id2 = e2.Id, Id1 = e1.Id }, (l1s, l2s) => from e2 in l2s join e1 in l1s on e2.Id equals MaybeScalar(e1.OneToOne_Optional_FK1, () => e1.OneToOne_Optional_FK1.Id) - select new - { - Id2 = e2.Id, - Id1 = e1.Id - }, + select new { Id2 = e2.Id, Id1 = e1.Id }, e => e.Id2 + " " + e.Id1); } @@ -741,23 +672,13 @@ public virtual Task Join_navigations_in_inner_selector_translated_without_collis from e2 in l2s join e1 in l1s on e2.Id equals e1.OneToOne_Optional_FK1.Id join e3 in l3s on e2.Id equals e3.OneToOne_Optional_FK_Inverse3.Id - select new - { - Id2 = e2.Id, - Id1 = e1.Id, - Id3 = e3.Id - }, + select new { Id2 = e2.Id, Id1 = e1.Id, Id3 = e3.Id }, (l1s, l2s, l3s) => from e2 in l2s join e1 in l1s on e2.Id equals MaybeScalar(e1.OneToOne_Optional_FK1, () => e1.OneToOne_Optional_FK1.Id) join e3 in l3s on e2.Id equals MaybeScalar( e3.OneToOne_Optional_FK_Inverse3, () => e3.OneToOne_Optional_FK_Inverse3.Id) - select new - { - Id2 = e2.Id, - Id1 = e1.Id, - Id3 = e3.Id - }, + select new { Id2 = e2.Id, Id1 = e1.Id, Id3 = e3.Id }, e => e.Id2 + " " + e.Id1 + " " + e.Id3); } @@ -770,23 +691,11 @@ public virtual Task Join_navigation_non_key_join(bool isAsync) (l1s, l2s) => from e2 in l2s join e1 in l1s on e2.Name equals e1.OneToOne_Optional_FK1.Name - select new - { - Id2 = e2.Id, - Name2 = e2.Name, - Id1 = e1.Id, - Name1 = e1.Name - }, + select new { Id2 = e2.Id, Name2 = e2.Name, Id1 = e1.Id, Name1 = e1.Name }, (l1s, l2s) => from e2 in l2s join e1 in l1s on e2.Name equals Maybe(e1.OneToOne_Optional_FK1, () => e1.OneToOne_Optional_FK1.Name) - select new - { - Id2 = e2.Id, - Name2 = e2.Name, - Id1 = e1.Id, - Name1 = e1.Name - }, + select new { Id2 = e2.Id, Name2 = e2.Name, Id1 = e1.Id, Name1 = e1.Name }, e => e.Id2 + " " + e.Name2 + " " + e.Id1 + " " + e.Name1); } @@ -799,24 +708,12 @@ public virtual Task Join_with_orderby_on_inner_sequence_navigation_non_key_join( (l1s, l2s) => from e2 in l2s join e1 in l1s.OrderBy(l1 => l1.Id) on e2.Name equals e1.OneToOne_Optional_FK1.Name - select new - { - Id2 = e2.Id, - Name2 = e2.Name, - Id1 = e1.Id, - Name1 = e1.Name - }, + select new { Id2 = e2.Id, Name2 = e2.Name, Id1 = e1.Id, Name1 = e1.Name }, (l1s, l2s) => from e2 in l2s join e1 in l1s.OrderBy(l1 => l1.Id) on e2.Name equals Maybe( e1.OneToOne_Optional_FK1, () => e1.OneToOne_Optional_FK1.Name) - select new - { - Id2 = e2.Id, - Name2 = e2.Name, - Id1 = e1.Id, - Name1 = e1.Name - }, + select new { Id2 = e2.Id, Name2 = e2.Name, Id1 = e1.Id, Name1 = e1.Name }, e => e.Id2 + " " + e.Name2 + " " + e.Id1 + " " + e.Name1); } @@ -829,20 +726,12 @@ public virtual Task Join_navigation_self_ref(bool isAsync) l1s => from e1 in l1s join e2 in l1s on e1.Id equals e2.OneToMany_Optional_Self_Inverse1.Id - select new - { - Id1 = e1.Id, - Id2 = e2.Id - }, + select new { Id1 = e1.Id, Id2 = e2.Id }, l1s => from e1 in l1s join e2 in l1s on e1.Id equals MaybeScalar( e2.OneToMany_Optional_Self_Inverse1, () => e2.OneToMany_Optional_Self_Inverse1.Id) - select new - { - Id1 = e1.Id, - Id2 = e2.Id - }, + select new { Id1 = e1.Id, Id2 = e2.Id }, e => e.Id1 + " " + e.Id2); } @@ -855,11 +744,7 @@ public virtual Task Join_navigation_nested(bool isAsync) (l1s, l3s) => from e3 in l3s join e1 in l1s on e3.Id equals e1.OneToOne_Required_FK1.OneToOne_Optional_FK2.Id - select new - { - Id3 = e3.Id, - Id1 = e1.Id - }, + select new { Id3 = e3.Id, Id1 = e1.Id }, (l1s, l3s) => from e3 in l3s join e1 in l1s on e3.Id equals MaybeScalar( @@ -867,11 +752,7 @@ join e1 in l1s on e3.Id equals MaybeScalar( () => MaybeScalar( e1.OneToOne_Required_FK1.OneToOne_Optional_FK2, () => e1.OneToOne_Required_FK1.OneToOne_Optional_FK2.Id)) - select new - { - Id3 = e3.Id, - Id1 = e1.Id - }, + select new { Id3 = e3.Id, Id1 = e1.Id }, e => e.Id3 + " " + e.Id1); } @@ -885,11 +766,7 @@ public virtual Task Join_navigation_nested2(bool isAsync) (l1s, l3s) => from e3 in l3s join e1 in l1s.OrderBy(ll => ll.Id) on e3.Id equals e1.OneToOne_Required_FK1.OneToOne_Optional_FK2.Id - select new - { - Id3 = e3.Id, - Id1 = e1.Id - }, + select new { Id3 = e3.Id, Id1 = e1.Id }, (l1s, l3s) => from e3 in l3s join e1 in l1s.OrderBy(ll => ll.Id) on e3.Id equals MaybeScalar( @@ -897,11 +774,7 @@ join e1 in l1s.OrderBy(ll => ll.Id) on e3.Id equals MaybeScalar( () => MaybeScalar( e1.OneToOne_Required_FK1.OneToOne_Optional_FK2, () => e1.OneToOne_Required_FK1.OneToOne_Optional_FK2.Id)) - select new - { - Id3 = e3.Id, - Id1 = e1.Id - }, + select new { Id3 = e3.Id, Id1 = e1.Id }, e => e.Id3 + " " + e.Id1); } @@ -914,13 +787,7 @@ public virtual Task Join_navigation_deeply_nested_non_key_join(bool isAsync) (l1s, l4s) => from e4 in l4s join e1 in l1s on e4.Name equals e1.OneToOne_Required_FK1.OneToOne_Optional_FK2.OneToOne_Required_PK3.Name - select new - { - Id4 = e4.Id, - Name4 = e4.Name, - Id1 = e1.Id, - Name1 = e1.Name - }, + select new { Id4 = e4.Id, Name4 = e4.Name, Id1 = e1.Id, Name1 = e1.Name }, (l1s, l4s) => from e4 in l4s join e1 in l1s on e4.Name equals Maybe( @@ -930,13 +797,7 @@ join e1 in l1s on e4.Name equals Maybe( () => Maybe( e1.OneToOne_Required_FK1.OneToOne_Optional_FK2.OneToOne_Required_PK3, () => e1.OneToOne_Required_FK1.OneToOne_Optional_FK2.OneToOne_Required_PK3.Name))) - select new - { - Id4 = e4.Id, - Name4 = e4.Name, - Id1 = e1.Id, - Name1 = e1.Name - }, + select new { Id4 = e4.Id, Name4 = e4.Name, Id1 = e1.Id, Name1 = e1.Name }, e => e.Id4 + " " + e.Name4 + " " + e.Id1 + " " + e.Name1); } @@ -950,13 +811,7 @@ public virtual Task Join_navigation_deeply_nested_required(bool isAsync) from e1 in l1s join e4 in l4s on e1.Name equals e4.OneToOne_Required_FK_Inverse4.OneToOne_Required_FK_Inverse3 .OneToOne_Required_PK_Inverse2.Name - select new - { - Id4 = e4.Id, - Name4 = e4.Name, - Id1 = e1.Id, - Name1 = e1.Name - }, + select new { Id4 = e4.Id, Name4 = e4.Name, Id1 = e1.Id, Name1 = e1.Name }, e => e.Id4 + " " + e.Name4 + " " + e.Id1 + " " + e.Name1); } @@ -967,9 +822,11 @@ public virtual Task Multiple_complex_includes(bool isAsync) var expectedIncludes = new List { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), - new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToMany_Optional2", navigationPath: "OneToOne_Optional_FK1"), + new ExpectedInclude( + l2 => l2.OneToMany_Optional2, "OneToMany_Optional2", navigationPath: "OneToOne_Optional_FK1"), new ExpectedInclude(l1 => l1.OneToMany_Optional1, "OneToMany_Optional1"), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2", navigationPath: "OneToMany_Optional1") + new ExpectedInclude( + l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2", navigationPath: "OneToMany_Optional1") }; return AssertIncludeQuery( @@ -1015,9 +872,11 @@ public virtual Task Multiple_complex_include_select(bool isAsync) var expectedIncludes = new List { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), - new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToMany_Optional2", navigationPath: "OneToOne_Optional_FK1"), + new ExpectedInclude( + l2 => l2.OneToMany_Optional2, "OneToMany_Optional2", navigationPath: "OneToOne_Optional_FK1"), new ExpectedInclude(l1 => l1.OneToMany_Optional1, "OneToMany_Optional1"), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2", navigationPath: "OneToMany_Optional1") + new ExpectedInclude( + l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2", navigationPath: "OneToMany_Optional1") }; return AssertIncludeQuery( @@ -1420,20 +1279,12 @@ public virtual Task SelectMany_navigation_comparison1(bool isAsync) from l11 in l1s from l12 in l1s where l11 == l12 - select new - { - Id1 = l11.Id, - Id2 = l12.Id - }, + select new { Id1 = l11.Id, Id2 = l12.Id }, l1s => from l11 in l1s from l12 in l1s where l11.Id == l12.Id - select new - { - Id1 = l11.Id, - Id2 = l12.Id - }, + select new { Id1 = l11.Id, Id2 = l12.Id }, e => e.Id1 + " " + e.Id2); } @@ -1447,20 +1298,12 @@ public virtual Task SelectMany_navigation_comparison2(bool isAsync) from l1 in l1s from l2 in l2s where l1 == l2.OneToOne_Optional_FK_Inverse2 - select new - { - Id1 = l1.Id, - Id2 = l2.Id - }, + select new { Id1 = l1.Id, Id2 = l2.Id }, (l1s, l2s) => from l1 in l1s from l2 in l2s where l1.Id == MaybeScalar(l2.OneToOne_Optional_FK_Inverse2, () => l2.OneToOne_Optional_FK_Inverse2.Id) - select new - { - Id1 = l1.Id, - Id2 = l2.Id - }, + select new { Id1 = l1.Id, Id2 = l2.Id }, e => e.Id1 + " " + e.Id2); } @@ -1474,20 +1317,12 @@ public virtual Task SelectMany_navigation_comparison3(bool isAsync) from l1 in l1s from l2 in l2s where l1.OneToOne_Optional_FK1 == l2 - select new - { - Id1 = l1.Id, - Id2 = l2.Id - }, + select new { Id1 = l1.Id, Id2 = l2.Id }, (l1s, l2s) => from l1 in l1s from l2 in l2s where MaybeScalar(l1.OneToOne_Optional_FK1, () => l1.OneToOne_Optional_FK1.Id) == l2.Id - select new - { - Id1 = l1.Id, - Id2 = l2.Id - }, + select new { Id1 = l1.Id, Id2 = l2.Id }, e => e.Id1 + " " + e.Id2); } @@ -1501,21 +1336,13 @@ public virtual Task Where_complex_predicate_with_with_nav_prop_and_OrElse1(bool from l1 in l1s from l2 in l2s where l1.OneToOne_Optional_FK1.Name == "L2 01" || l2.OneToOne_Required_FK_Inverse2.Name != "Bar" - select new - { - Id1 = (int?)l1.Id, - Id2 = (int?)l2.Id - }, + select new { Id1 = (int?)l1.Id, Id2 = (int?)l2.Id }, (l1s, l2s) => from l1 in l1s from l2 in l2s where Maybe(l1.OneToOne_Optional_FK1, () => l1.OneToOne_Optional_FK1.Name) == "L2 01" || l2.OneToOne_Required_FK_Inverse2.Name != "Bar" - select new - { - Id1 = (int?)l1.Id, - Id2 = (int?)l2.Id - }, + select new { Id1 = (int?)l1.Id, Id2 = (int?)l2.Id }, e => e.Id1 + " " + e.Id2); } @@ -1598,11 +1425,7 @@ public virtual Task Complex_navigations_with_predicate_projected_into_anonymous_ e => e.OneToOne_Required_FK1.OneToOne_Required_FK2 == e.OneToOne_Required_FK1.OneToOne_Optional_FK2 && e.OneToOne_Required_FK1.OneToOne_Optional_FK2.Id != 7) .Select( - e => new - { - e.Name, - Id = (int?)e.OneToOne_Required_FK1.OneToOne_Optional_FK2.Id - }), + e => new { e.Name, Id = (int?)e.OneToOne_Required_FK1.OneToOne_Optional_FK2.Id }), l1s => l1s .Where( e => Maybe(e.OneToOne_Required_FK1, () => e.OneToOne_Required_FK1.OneToOne_Required_FK2) == Maybe( @@ -1640,11 +1463,7 @@ from e in l3s where e.OneToOne_Required_FK_Inverse3.OneToOne_Required_FK_Inverse2 == e.OneToOne_Required_FK_Inverse3.OneToOne_Optional_FK_Inverse2 && e.OneToOne_Required_FK_Inverse3.OneToOne_Optional_FK_Inverse2.Id != 7 - select new - { - e.Name, - Id = (int?)e.OneToOne_Required_FK_Inverse3.OneToOne_Optional_FK_Inverse2.Id - }, + select new { e.Name, Id = (int?)e.OneToOne_Required_FK_Inverse3.OneToOne_Optional_FK_Inverse2.Id }, l3s => from e in l3s where e.OneToOne_Required_FK_Inverse3.OneToOne_Required_FK_Inverse2 @@ -1673,11 +1492,7 @@ public virtual void Optional_navigation_projected_into_DTO() Id = e.Id, Name = e.Name, Inner = e.OneToOne_Optional_FK1 != null - ? new MyInnerDto - { - Id = (int?)e.OneToOne_Optional_FK1.Id, - Name = e.OneToOne_Optional_FK1.Name - } + ? new MyInnerDto { Id = (int?)e.OneToOne_Optional_FK1.Id, Name = e.OneToOne_Optional_FK1.Name } : null }).ToList().OrderBy(e => e.Id + " " + e.Name + " " + e.Inner).ToList(); @@ -1687,11 +1502,7 @@ public virtual void Optional_navigation_projected_into_DTO() Id = e.Id, Name = e.Name, Inner = e.OneToOne_Optional_FK1 != null - ? new MyInnerDto - { - Id = (int?)e.OneToOne_Optional_FK1.Id, - Name = e.OneToOne_Optional_FK1.Name - } + ? new MyInnerDto { Id = (int?)e.OneToOne_Optional_FK1.Id, Name = e.OneToOne_Optional_FK1.Name } : null }).ToList().OrderBy(e => e.Id + " " + e.Name + " " + e.Inner).ToList(); @@ -1855,10 +1666,7 @@ public virtual Task Include_with_optional_navigation(bool isAsync) l1s => from l1 in l1s.Include(e => e.OneToOne_Optional_FK1) where Maybe(l1.OneToOne_Optional_FK1, () => l1.OneToOne_Optional_FK1.Name) != "L2 05" select l1, - new List - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1") - }, + new List { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1") }, elementSorter: e => e.Id); } @@ -1911,11 +1719,7 @@ join l2 in l2s.Include(e => e.OneToOne_Required_PK2) #pragma warning restore IDE0031 // Use null propagation where l1.Name != "L1 03" orderby l1.Id - select new - { - l1, - grouping - }).Skip(1).Take(5), + select new { l1, grouping }).Skip(1).Take(5), expectedIncludes, clientProjections: new List> { @@ -1935,11 +1739,7 @@ join l1_Optional in l2s on (int?)l1.Id equals l1_Optional.Level1_Optional_Id int from l1_Optional in grouping.DefaultIfEmpty() from l2 in l2s join l2_Required_Reverse in l1s on l2.Level1_Required_Id equals l2_Required_Reverse.Id - select new - { - l1_Optional, - l2_Required_Reverse - }, + select new { l1_Optional, l2_Required_Reverse }, elementSorter: e => e.l1_Optional?.Id + " " + e.l2_Required_Reverse.Id); } @@ -2244,21 +2044,13 @@ public virtual Task Correlated_subquery_doesnt_project_unnecessary_columns_in_to from e1 in l1s join e2 in l2s on e1.Id equals e2.OneToOne_Optional_FK_Inverse2.Id where l2s.Any(l2 => l2.Level1_Required_Id == e1.Id) - select new - { - Name1 = e1.Name, - Id2 = e2.Id - }, + select new { Name1 = e1.Name, Id2 = e2.Id }, (l1s, l2s) => from e1 in l1s join e2 in l2s on e1.Id equals MaybeScalar( e2.OneToOne_Optional_FK_Inverse2, () => e2.OneToOne_Optional_FK_Inverse2.Id) where l2s.Any(l2 => l2.Level1_Required_Id == e1.Id) - select new - { - Name1 = e1.Name, - Id2 = e2.Id - }, + select new { Name1 = e1.Name, Id2 = e2.Id }, e => e.Name1 + " " + e.Id2); } @@ -2299,11 +2091,7 @@ public virtual Task GroupJoin_on_subquery_and_set_operation_on_grouping_but_noth l2s.Where(l2 => l2.Name != "L2 01"), l1 => l1.Id, l2 => l2.Level1_Optional_Id, - (l1, l2g) => new - { - l1, - l2g - }) + (l1, l2g) => new { l1, l2g }) .Where(r => r.l2g.Any()) .Select(r => r.l1), e => e.Id, @@ -2321,11 +2109,7 @@ public virtual Task GroupJoin_on_complex_subquery_and_set_operation_on_grouping_ l1s.Where(l1 => l1.Name != "L1 01").Select(l1 => l1.OneToOne_Required_FK1), l1 => l1.Id, l2 => l2 != null ? l2.Level1_Optional_Id : null, - (l1, l2s) => new - { - l1, - l2s - }) + (l1, l2s) => new { l1, l2s }) .Where(r => r.l2s.Any()) .Select(r => r.l1), e => e.Id, @@ -2343,11 +2127,7 @@ public virtual Task Null_protection_logic_work_for_inner_key_access_of_manually_ l1s.Select(l1 => l1.OneToOne_Required_FK1), l1 => l1.Id, l2 => MaybeScalar(l2, () => l2.Level1_Optional_Id), - (l1, l2s) => new - { - l1, - l2s - }) + (l1, l2s) => new { l1, l2s }) .Select(r => r.l1), e => e.Id, (e, a) => Assert.Equal(e.Id, a.Id)); @@ -2364,22 +2144,14 @@ public virtual Task Null_protection_logic_work_for_inner_key_access_of_manually_ l1s.Select(l1 => l1.OneToOne_Required_FK1), l1 => l1.Id, l2 => EF.Property(l2, "Level1_Optional_Id"), - (l1, l2s) => new - { - l1, - l2s - }) + (l1, l2s) => new { l1, l2s }) .Select(r => r.l1), l1s => l1s.GroupJoin( l1s.Select(l1 => l1.OneToOne_Required_FK1), l1 => l1.Id, l2 => MaybeScalar(l2, () => l2.Level1_Optional_Id), - (l1, l2s) => new - { - l1, - l2s - }) + (l1, l2s) => new { l1, l2s }) .Select(r => r.l1), e => e.Id, (e, a) => Assert.Equal(e.Id, a.Id)); @@ -2396,22 +2168,14 @@ public virtual Task Null_protection_logic_work_for_outer_key_access_of_manually_ l1s, l2 => l2.Level1_Optional_Id, l1 => l1.Id, - (l2, l1g) => new - { - l2, - l1g - }) + (l2, l1g) => new { l2, l1g }) .Select(r => r.l2), l1s => l1s.Select(l1 => l1.OneToOne_Required_FK1).GroupJoin( l1s, l2 => MaybeScalar(l2, () => l2.Level1_Optional_Id), l1 => l1.Id, - (l2, l1g) => new - { - l2, - l1g - }) + (l2, l1g) => new { l2, l1g }) .Select(r => r.l2), e => e?.Id, (e, a) => @@ -2510,11 +2274,7 @@ public virtual Task Order_by_key_of_anonymous_type_projected_navigation_doesnt_g isAsync, l3s => l3s .Select( - l3 => new - { - l3.OneToOne_Required_FK_Inverse3, - name = l3.Name - }) + l3 => new { l3.OneToOne_Required_FK_Inverse3, name = l3.Name }) .OrderBy(l3 => l3.OneToOne_Required_FK_Inverse3.Id) .Take(10) .Select(l2 => l2.OneToOne_Required_FK_Inverse3.Name), @@ -2564,11 +2324,7 @@ join l3 in l3s on l1.Id equals l3.Level2_Required_Id where l1.Name == "L1 03" where l3.Name == "L3 08" - select new - { - l2, - l1 - }) + select new { l2, l1 }) .OrderBy(l => l.l1.Id) .Take(3) .Select(l => l.l2.Name) @@ -3469,11 +3225,7 @@ public virtual Task Select_join_subquery_containing_filter_and_distinct(bool isA (l1s, l2s) => from l1 in l1s join l2 in l2s.Where(l => l.Id > 2).Distinct() on l1.Id equals l2.Level1_Optional_Id - select new - { - l1, - l2 - }, + select new { l1, l2 }, elementSorter: e => e.l1.Id + " " + e.l2.Id, elementAsserter: (e, a) => { @@ -3490,11 +3242,7 @@ public virtual Task Select_join_with_key_selector_being_a_subquery(bool isAsync) isAsync, (l1s, l2s) => from l1 in l1s join l2 in l2s on l1.Id equals l2s.Select(l => l.Id).OrderBy(l => l).FirstOrDefault() - select new - { - l1, - l2 - }, + select new { l1, l2 }, elementSorter: e => e.l1.Id + " " + e.l2.Id, elementAsserter: (e, a) => Assert.Equal(e.l1.Name + " " + e.l2.Name, a.l1.Name + " " + a.l2.Name)); } @@ -3520,19 +3268,19 @@ public virtual async Task Complex_query_with_optional_navigations_and_client_sid { var message = (await Assert.ThrowsAsync( () => AssertQuery( - isAsync, - l1s => l1s.Where( - l1 => l1.Id < 3 && !l1.OneToMany_Optional1.Select(l2 => l2.OneToOne_Optional_FK2.OneToOne_Optional_FK3.Id) - .All(l4 => ClientMethod(l4))), - l1s => l1s.Where( - l1 => l1.Id < 3 && !l1.OneToMany_Optional1.Select( - l2 => MaybeScalar( - l2.OneToOne_Optional_FK2, - () => MaybeScalar( - l2.OneToOne_Optional_FK2.OneToOne_Optional_FK3, - () => l2.OneToOne_Optional_FK2.OneToOne_Optional_FK3.Id))).All(a => true)), - elementSorter: e => e.Id, - elementAsserter: (e, a) => Assert.Equal(e.Id, a.Id)))).Message; + isAsync, + l1s => l1s.Where( + l1 => l1.Id < 3 && !l1.OneToMany_Optional1.Select(l2 => l2.OneToOne_Optional_FK2.OneToOne_Optional_FK3.Id) + .All(l4 => ClientMethod(l4))), + l1s => l1s.Where( + l1 => l1.Id < 3 && !l1.OneToMany_Optional1.Select( + l2 => MaybeScalar( + l2.OneToOne_Optional_FK2, + () => MaybeScalar( + l2.OneToOne_Optional_FK2.OneToOne_Optional_FK3, + () => l2.OneToOne_Optional_FK2.OneToOne_Optional_FK3.Id))).All(a => true)), + elementSorter: e => e.Id, + elementAsserter: (e, a) => Assert.Equal(e.Id, a.Id)))).Message; Assert.Contains("ClientMethod((Nullable)", message); } @@ -3562,11 +3310,7 @@ from l2o in l2s join l1i in l1s on l2i.Level1_Required_Id equals l1i.Id orderby l2i.Id - select new - { - Navigation = l2i.OneToOne_Required_FK_Inverse2, - Constant = 7 - }).First().Navigation.Name); + select new { Navigation = l2i.OneToOne_Required_FK_Inverse2, Constant = 7 }).First().Navigation.Name); } [ConditionalTheory(Skip = "Issue #15832")] @@ -3613,20 +3357,12 @@ public virtual Task Optional_navigation_propagates_nullability_to_manually_creat from l2_nav in l1s.Select(ll => ll.OneToOne_Optional_FK1) join l1 in l2s on l2_nav.Level1_Required_Id equals l1.Id into grouping from l1 in grouping.DefaultIfEmpty() - select new - { - Id1 = (int?)l2_nav.Id, - Id2 = (int?)l1.Id - }, + select new { Id1 = (int?)l2_nav.Id, Id2 = (int?)l1.Id }, (l1s, l2s) => from l2_nav in l1s.Select(ll => ll.OneToOne_Optional_FK1) join l1 in l2s on MaybeScalar(l2_nav, () => l2_nav.Level1_Required_Id) equals l1.Id into grouping from l1 in grouping.DefaultIfEmpty() - select new - { - Id1 = MaybeScalar(l2_nav, () => l2_nav.Id), - Id2 = MaybeScalar(l1, () => l1.Id) - }, + select new { Id1 = MaybeScalar(l2_nav, () => l2_nav.Id), Id2 = MaybeScalar(l1, () => l1.Id) }, elementSorter: e => e.Id1); } @@ -3640,21 +3376,13 @@ public virtual Task Optional_navigation_propagates_nullability_to_manually_creat from l3 in l3s join l2_nav in l1s.Select(ll => ll.OneToOne_Optional_FK1) on l3.Level2_Required_Id equals l2_nav.Id into grouping from l2_nav in grouping.DefaultIfEmpty() - select new - { - Name1 = l3.Name, - Name2 = l2_nav.Name - }, + select new { Name1 = l3.Name, Name2 = l2_nav.Name }, (l3s, l1s) => from l3 in l3s join l2_nav in l1s.Select(ll => ll.OneToOne_Optional_FK1) on l3.Level2_Required_Id equals MaybeScalar( l2_nav, () => l2_nav.Id) into grouping from l2_nav in grouping.DefaultIfEmpty() - select new - { - Name1 = l3.Name, - Name2 = Maybe(l2_nav, () => l2_nav.Name) - }, + select new { Name1 = l3.Name, Name2 = Maybe(l2_nav, () => l2_nav.Name) }, elementSorter: e => e.Name1 + e.Name2); } @@ -3701,11 +3429,7 @@ from l2_inner in grouping_inner.DefaultIfEmpty() select l2_inner) on l3.Level2_Required_Id equals l2_outer.Id into grouping_outer from l2_outer in grouping_outer.DefaultIfEmpty() - select new - { - entity = l2_outer, - property = l2_outer.Name - }, + select new { entity = l2_outer, property = l2_outer.Name }, (l1s, l2s, l3s) => from l3 in l3s join l2_outer in @@ -3715,11 +3439,7 @@ from l2_inner in grouping_inner.DefaultIfEmpty() select l2_inner) on l3.Level2_Required_Id equals MaybeScalar(l2_outer, () => l2_outer.Id) into grouping_outer from l2_outer in grouping_outer.DefaultIfEmpty() - select new - { - entity = l2_outer, - property = Maybe(l2_outer, () => l2_outer.Name) - }, + select new { entity = l2_outer, property = Maybe(l2_outer, () => l2_outer.Name) }, elementSorter: e => e.property, elementAsserter: (e, a) => { @@ -4022,20 +3742,12 @@ public virtual Task GroupJoin_on_left_side_being_a_subquery(bool isAsync) .ThenBy(l1 => l1.Id) .Take(2) .Select( - x => new - { - x.Id, - Brand = x.OneToOne_Optional_FK1.Name - }), + x => new { x.Id, Brand = x.OneToOne_Optional_FK1.Name }), l1s => l1s.OrderBy(l1 => Maybe(l1.OneToOne_Optional_FK1, () => l1.OneToOne_Optional_FK1.Name)) .ThenBy(l1 => l1.Id) .Take(2) .Select( - x => new - { - x.Id, - Brand = Maybe(x.OneToOne_Optional_FK1, () => x.OneToOne_Optional_FK1.Name) - }), + x => new { x.Id, Brand = Maybe(x.OneToOne_Optional_FK1, () => x.OneToOne_Optional_FK1.Name) }), e => e.Id); } @@ -4050,11 +3762,7 @@ from l2 in l2s join l1 in l1s.OrderBy(x => x.OneToOne_Optional_FK1.Name).Take(2) on l2.Level1_Optional_Id equals l1.Id into grouping from l1 in grouping.DefaultIfEmpty() #pragma warning disable IDE0031 // Use null propagation - select new - { - l2.Id, - Name = l1 != null ? l1.Name : null - }, + select new { l2.Id, Name = l1 != null ? l1.Name : null }, #pragma warning restore IDE0031 // Use null propagation (l1s, l2s) => from l2 in l2s @@ -4062,11 +3770,7 @@ join l1 in l1s.OrderBy(x => Maybe(x.OneToOne_Optional_FK1, () => x.OneToOne_Opti on l2.Level1_Optional_Id equals l1.Id into grouping from l1 in grouping.DefaultIfEmpty() #pragma warning disable IDE0031 // Use null propagation - select new - { - l2.Id, - Name = l1 != null ? l1.Name : null - }, + select new { l2.Id, Name = l1 != null ? l1.Name : null }, #pragma warning restore IDE0031 // Use null propagation e => e.Id); } @@ -4180,11 +3884,7 @@ public virtual Task GroupJoin_client_method_on_outer(bool isAsync) from l1 in l1s join l2 in l2s on l1.Id equals l2.Level1_Optional_Id into groupJoin from l2 in groupJoin.DefaultIfEmpty() - select new - { - l1.Id, - client = ClientMethodNullableInt(l1.Id) - }, + select new { l1.Id, client = ClientMethodNullableInt(l1.Id) }, elementSorter: e => e.Id, elementAsserter: (e, a) => Assert.Equal(e.Id + " " + e.client, a.Id + " " + a.client)); } @@ -4392,26 +4092,14 @@ public virtual Task Join_condition_optimizations_applied_correctly_when_anonymou (l1s, l2s) => from l1 in l1s join l2 in l2s - on new - { - A = EF.Property(l1, "OneToMany_Optional_Self_Inverse1Id") - } - equals new - { - A = EF.Property(l2, "Level1_Optional_Id") - } + on new { A = EF.Property(l1, "OneToMany_Optional_Self_Inverse1Id") } + equals new { A = EF.Property(l2, "Level1_Optional_Id") } select l1, (l1s, l2s) => from l1 in l1s join l2 in l2s - on new - { - A = MaybeScalar(l1.OneToMany_Optional_Self_Inverse1, () => l1.OneToMany_Optional_Self_Inverse1.Id) - } - equals new - { - A = l2.Level1_Optional_Id - } + on new { A = MaybeScalar(l1.OneToMany_Optional_Self_Inverse1, () => l1.OneToMany_Optional_Self_Inverse1.Id) } + equals new { A = l2.Level1_Optional_Id } select l1, elementSorter: e => e.Id, elementAsserter: (e, a) => Assert.Equal(e.Id, a.Id)); @@ -4796,11 +4484,7 @@ public virtual Task Project_collection_navigation_nested_anonymous(bool isAsync) return AssertQuery( isAsync, l1s => from l1 in l1s - select new - { - l1.Id, - l1.OneToOne_Optional_FK1.OneToMany_Optional2 - }, + select new { l1.Id, l1.OneToOne_Optional_FK1.OneToMany_Optional2 }, l1s => from l1 in l1s select new { @@ -4831,11 +4515,7 @@ public virtual Task Project_collection_navigation_count(bool isAsync) return AssertQuery( isAsync, l1s => from l1 in l1s - select new - { - l1.Id, - l1.OneToOne_Optional_FK1.OneToMany_Optional2.Count - }, + select new { l1.Id, l1.OneToOne_Optional_FK1.OneToMany_Optional2.Count }, l1s => from l1 in l1s select new { @@ -4857,11 +4537,7 @@ public virtual Task Project_collection_navigation_composed(bool isAsync) isAsync, l1s => from l1 in l1s where l1.Id < 3 - select new - { - l1.Id, - collection = l1.OneToMany_Optional1.Where(l2 => l2.Name != "Foo").ToList() - }, + select new { l1.Id, collection = l1.OneToMany_Optional1.Where(l2 => l2.Name != "Foo").ToList() }, elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -4884,11 +4560,7 @@ public virtual Task Project_collection_and_root_entity(bool isAsync) return AssertQuery( isAsync, l1s => from l1 in l1s - select new - { - l1, - l1.OneToMany_Optional1 - }, + select new { l1, l1.OneToMany_Optional1 }, elementSorter: e => e.l1.Id, elementAsserter: (e, a) => { @@ -4911,11 +4583,7 @@ public virtual Task Project_collection_and_include(bool isAsync) return AssertQuery( isAsync, l1s => from l1 in l1s.Include(l => l.OneToMany_Optional1) - select new - { - l1, - l1.OneToMany_Optional1 - }, + select new { l1, l1.OneToMany_Optional1 }, elementSorter: e => e.l1.Id, elementAsserter: (e, a) => { @@ -4938,11 +4606,7 @@ public virtual Task Project_navigation_and_collection(bool isAsync) return AssertQuery( isAsync, l1s => from l1 in l1s - select new - { - l1.OneToOne_Optional_FK1, - l1.OneToOne_Optional_FK1.OneToMany_Optional2 - }, + select new { l1.OneToOne_Optional_FK1, l1.OneToOne_Optional_FK1.OneToMany_Optional2 }, l1s => from l1 in l1s select new { @@ -4972,10 +4636,7 @@ public virtual void Include_inside_subquery() var query = ctx.LevelOne .Where(l1 => l1.Id < 3) .Select( - l1 => new - { - subquery = ctx.LevelTwo.Include(l => l.OneToMany_Optional2).Where(l => l.Id > 0) - }); + l1 => new { subquery = ctx.LevelTwo.Include(l => l.OneToMany_Optional2).Where(l => l.Id > 0) }); var result = query.ToList(); } @@ -5002,10 +4663,7 @@ public virtual Task Include_collection_with_multiple_orderbys_member(bool isAsyn .Include(l2 => l2.OneToMany_Optional2) .OrderBy(l2 => l2.Name) .ThenBy(l2 => l2.Level1_Required_Id), - new List - { - new ExpectedInclude(e => e.OneToMany_Optional2, "OneToMany_Optional2") - }, + new List { new ExpectedInclude(e => e.OneToMany_Optional2, "OneToMany_Optional2") }, assertOrder: true); } @@ -5022,10 +4680,7 @@ public virtual Task Include_collection_with_multiple_orderbys_property(bool isAs l2s => l2s .OrderBy(l2 => l2.Level1_Required_Id) .ThenBy(l2 => l2.Name), - new List - { - new ExpectedInclude(e => e.OneToMany_Optional2, "OneToMany_Optional2") - }, + new List { new ExpectedInclude(e => e.OneToMany_Optional2, "OneToMany_Optional2") }, assertOrder: true); } @@ -5039,10 +4694,7 @@ public virtual Task Include_collection_with_multiple_orderbys_methodcall(bool is .Include(l2 => l2.OneToMany_Optional2) .OrderBy(l2 => Math.Abs(l2.Level1_Required_Id)) .ThenBy(l2 => l2.Name), - new List - { - new ExpectedInclude(e => e.OneToMany_Optional2, "OneToMany_Optional2") - }, + new List { new ExpectedInclude(e => e.OneToMany_Optional2, "OneToMany_Optional2") }, assertOrder: true); } @@ -5056,10 +4708,7 @@ public virtual Task Include_collection_with_multiple_orderbys_complex(bool isAsy .Include(l2 => l2.OneToMany_Optional2) .OrderBy(l2 => Math.Abs(l2.Level1_Required_Id) + 7) .ThenBy(l2 => l2.Name), - new List - { - new ExpectedInclude(e => e.OneToMany_Optional2, "OneToMany_Optional2") - }, + new List { new ExpectedInclude(e => e.OneToMany_Optional2, "OneToMany_Optional2") }, assertOrder: true); } @@ -5073,10 +4722,7 @@ public virtual Task Include_collection_with_multiple_orderbys_complex_repeated(b .Include(l2 => l2.OneToMany_Optional2) .OrderBy(l2 => -l2.Level1_Required_Id) .ThenBy(l2 => -l2.Level1_Required_Id).ThenBy(l2 => l2.Name), - new List - { - new ExpectedInclude(e => e.OneToMany_Optional2, "OneToMany_Optional2") - }, + new List { new ExpectedInclude(e => e.OneToMany_Optional2, "OneToMany_Optional2") }, assertOrder: true); } @@ -5217,7 +4863,9 @@ public virtual Task String_include_multiple_derived_navigation_with_same_name_an [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task String_include_multiple_derived_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains(bool isAsync) + public virtual Task + String_include_multiple_derived_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains( + bool isAsync) { var expectedIncludes = new List { @@ -5266,7 +4914,9 @@ public virtual Task String_include_multiple_derived_collection_navigation_with_s [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task String_include_multiple_derived_collection_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains(bool isAsync) + public virtual Task + String_include_multiple_derived_collection_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains( + bool isAsync) { var expectedIncludes = new List { @@ -5290,7 +4940,6 @@ public virtual Task String_include_multiple_derived_navigations_complex(bool isA new ExpectedInclude(e => e.Reference, "Reference"), new ExpectedInclude(e => e.CollectionDifferentType, "CollectionDifferentType", "Reference"), new ExpectedInclude(e => e.CollectionDifferentType, "CollectionDifferentType", "Reference"), - new ExpectedInclude(e => e.Collection, "Collection"), new ExpectedInclude(e => e.ReferenceSameType, "ReferenceSameType", "Collection"), new ExpectedInclude(e => e.ReferenceSameType, "ReferenceSameType", "Collection") @@ -5352,10 +5001,7 @@ public virtual Task Include_after_SelectMany_and_reference_navigation(bool isAsy isAsync, l1s => l1s.SelectMany(l1 => l1.OneToMany_Required1).Select(l2 => l2.OneToOne_Optional_FK2) .Include(l3 => l3.OneToMany_Optional3), - new List - { - new ExpectedInclude(l3 => l3.OneToMany_Optional3, "OneToMany_Optional3") - }); + new List { new ExpectedInclude(l3 => l3.OneToMany_Optional3, "OneToMany_Optional3") }); } [ConditionalTheory(Skip = "Issue#16752")] @@ -5366,10 +5012,7 @@ public virtual Task Include_after_multiple_SelectMany_and_reference_navigation(b isAsync, l1s => l1s.SelectMany(l1 => l1.OneToMany_Required1).SelectMany(l2 => l2.OneToMany_Optional2) .Select(l3 => l3.OneToOne_Required_FK3).Include(l4 => l4.OneToMany_Required_Self4), - new List - { - new ExpectedInclude(l4 => l4.OneToMany_Required_Self4, "OneToMany_Required_Self4") - }); + new List { new ExpectedInclude(l4 => l4.OneToMany_Required_Self4, "OneToMany_Required_Self4") }); } [ConditionalTheory(Skip = "Issue#16752")] @@ -5382,10 +5025,7 @@ public virtual Task Include_after_SelectMany_and_multiple_reference_navigations( .Select(l3 => l3.OneToOne_Required_FK3).Include(l4 => l4.OneToMany_Optional_Self4), l1s => l1s.SelectMany(l1 => l1.OneToMany_Required1).Select(l2 => l2.OneToOne_Optional_FK2) .Select(l3 => Maybe(l3, () => l3.OneToOne_Required_FK3)), - new List - { - new ExpectedInclude(l4 => l4.OneToMany_Optional_Self4, "OneToMany_Optional_Self4") - }); + new List { new ExpectedInclude(l4 => l4.OneToMany_Optional_Self4, "OneToMany_Optional_Self4") }); } [ConditionalTheory(Skip = "Issue#16752")] @@ -5404,10 +5044,7 @@ from lInner in lOuter.OneToMany_Optional3.Distinct() from lInner in lOuter.OneToMany_Optional3.Distinct() where lInner != null select lOuter, - new List - { - new ExpectedInclude(l3 => l3.OneToMany_Optional3, "OneToMany_Optional") - }); + new List { new ExpectedInclude(l3 => l3.OneToMany_Optional3, "OneToMany_Optional") }); } [ConditionalTheory] @@ -5418,10 +5055,7 @@ await AssertQuery( isAsync, l1s => l1s.OrderBy(l1 => l1.Id).SelectMany( l1 => l1.OneToMany_Optional1.Select( - l2 => new - { - l2.Name - })).Take(1)); + l2 => new { l2.Name })).Take(1)); } [ConditionalTheory] @@ -5543,10 +5177,10 @@ public virtual Task Include1(bool isAsync) public virtual Task Include2(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1") - }; + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1") + }; return AssertIncludeQuery( isAsync, @@ -5559,10 +5193,10 @@ public virtual Task Include2(bool isAsync) public virtual Task Include3(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), - new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1, "OneToOne_Optional_PK1") - }; + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), + new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1, "OneToOne_Optional_PK1") + }; return AssertIncludeQuery( isAsync, @@ -5575,10 +5209,10 @@ public virtual Task Include3(bool isAsync) public virtual Task Include4(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), - new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_PK2", "OneToOne_Optional_FK1") - }; + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), + new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_PK2", "OneToOne_Optional_FK1") + }; return AssertIncludeQuery( isAsync, @@ -5586,16 +5220,15 @@ public virtual Task Include4(bool isAsync) expectedIncludes); } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Include5(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), - new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_PK2", "OneToOne_Optional_FK1") - }; + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), + new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_PK2", "OneToOne_Optional_FK1") + }; return AssertIncludeQuery( isAsync, @@ -5608,9 +5241,9 @@ public virtual Task Include5(bool isAsync) public virtual Task Include6(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_PK2") - }; + { + new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_PK2") + }; return AssertIncludeQuery( isAsync, @@ -5633,31 +5266,32 @@ public virtual Task Include7(bool isAsync) public virtual Task Include8(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK_Inverse2, "OneToOne_Optional_FK_Inverse2") - }; + { + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK_Inverse2, "OneToOne_Optional_FK_Inverse2") + }; return AssertIncludeQuery( isAsync, l2s => l2s.Where(l2 => l2.OneToOne_Optional_FK_Inverse2.Name != "Fubar").Include(l2 => l2.OneToOne_Optional_FK_Inverse2), - l2s => l2s.Where(l2 => Maybe(l2.OneToOne_Optional_FK_Inverse2, () => l2.OneToOne_Optional_FK_Inverse2.Name) != "Fubar").Include(l2 => l2.OneToOne_Optional_FK_Inverse2), + l2s => l2s.Where(l2 => Maybe(l2.OneToOne_Optional_FK_Inverse2, () => l2.OneToOne_Optional_FK_Inverse2.Name) != "Fubar") + .Include(l2 => l2.OneToOne_Optional_FK_Inverse2), expectedIncludes); } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Include9(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK_Inverse2, "OneToOne_Optional_FK_Inverse2") - }; + { + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK_Inverse2, "OneToOne_Optional_FK_Inverse2") + }; return AssertIncludeQuery( isAsync, l2s => l2s.Include(l2 => l2.OneToOne_Optional_FK_Inverse2).Where(l2 => l2.OneToOne_Optional_FK_Inverse2.Name != "Fubar"), - l2s => l2s.Include(l2 => l2.OneToOne_Optional_FK_Inverse2).Where(l2 => Maybe(l2.OneToOne_Optional_FK_Inverse2, () => l2.OneToOne_Optional_FK_Inverse2.Name) != "Fubar"), + l2s => l2s.Include(l2 => l2.OneToOne_Optional_FK_Inverse2).Where( + l2 => Maybe(l2.OneToOne_Optional_FK_Inverse2, () => l2.OneToOne_Optional_FK_Inverse2.Name) != "Fubar"), expectedIncludes); } @@ -5666,13 +5300,14 @@ public virtual Task Include9(bool isAsync) public virtual Task Include10(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), - new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_PK2", "OneToOne_Optional_FK1"), - new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1, "OneToOne_Optional_PK1"), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2", "OneToOne_Optional_PK1"), - new ExpectedInclude(l3 => l3.OneToOne_Optional_PK3, "OneToOne_Optional_PK3", "OneToOne_Optional_FK1.OneToOne_Optional_FK2") - }; + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), + new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_PK2", "OneToOne_Optional_FK1"), + new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1, "OneToOne_Optional_PK1"), + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2", "OneToOne_Optional_PK1"), + new ExpectedInclude( + l3 => l3.OneToOne_Optional_PK3, "OneToOne_Optional_PK3", "OneToOne_Optional_FK1.OneToOne_Optional_FK2") + }; return AssertIncludeQuery( isAsync, @@ -5687,18 +5322,20 @@ public virtual Task Include10(bool isAsync) public virtual Task Include11(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2", "OneToOne_Optional_FK1"), - new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_PK2", "OneToOne_Optional_FK1"), - new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1, "OneToOne_Optional_PK1"), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2", "OneToOne_Optional_PK1"), - new ExpectedInclude(l3 => l3.OneToOne_Optional_FK3, "OneToOne_Optional_FK3", "OneToOne_Optional_PK1.OneToOne_Optional_FK2"), - new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1, "OneToOne_Optional_PK1"), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2", "OneToOne_Optional_PK1"), - new ExpectedInclude(l3 => l3.OneToOne_Optional_PK3, "OneToOne_Optional_PK3", "OneToOne_Optional_PK1.OneToOne_Optional_FK2"), - new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_PK2", "OneToOne_Optional_PK1"), - }; + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2", "OneToOne_Optional_FK1"), + new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_PK2", "OneToOne_Optional_FK1"), + new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1, "OneToOne_Optional_PK1"), + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2", "OneToOne_Optional_PK1"), + new ExpectedInclude( + l3 => l3.OneToOne_Optional_FK3, "OneToOne_Optional_FK3", "OneToOne_Optional_PK1.OneToOne_Optional_FK2"), + new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1, "OneToOne_Optional_PK1"), + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2", "OneToOne_Optional_PK1"), + new ExpectedInclude( + l3 => l3.OneToOne_Optional_PK3, "OneToOne_Optional_PK3", "OneToOne_Optional_PK1.OneToOne_Optional_FK2"), + new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_PK2", "OneToOne_Optional_PK1") + }; return AssertIncludeQuery( isAsync, @@ -5716,9 +5353,9 @@ public virtual Task Include11(bool isAsync) public virtual Task Include12(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2") - }; + { + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2") + }; return AssertIncludeQuery( isAsync, @@ -5733,9 +5370,9 @@ public virtual Task Include12(bool isAsync) public virtual Task Include13(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1") - }; + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1") + }; return AssertIncludeQuery( isAsync, @@ -5743,11 +5380,7 @@ public virtual Task Include13(bool isAsync) .Include(l1 => l1.OneToOne_Optional_FK1) .Select(l1 => new { one = l1, two = l1 }), expectedIncludes, - clientProjections: new List> - { - x => x.one, - x => x.two - }, + clientProjections: new List> { x => x.one, x => x.two }, elementSorter: e => e.one.Id); } @@ -5756,10 +5389,10 @@ public virtual Task Include13(bool isAsync) public virtual Task Include14(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2", "OneToOne_Optional_FK1"), - }; + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1"), + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK2", "OneToOne_Optional_FK1") + }; return AssertIncludeQuery( isAsync, @@ -5769,7 +5402,7 @@ public virtual Task Include14(bool isAsync) expectedIncludes, clientProjections: new List> { - x => x.one, + x => x.one // issue #15368 //x => x.two, }, @@ -5781,7 +5414,8 @@ public virtual void Include15() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }).Include(x => x.foo.OneToOne_Optional_FK2).Include(x => x.bar.OneToMany_Optional2); + var query = ctx.LevelOne.Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }) + .Include(x => x.foo.OneToOne_Optional_FK2).Include(x => x.bar.OneToMany_Optional2); var result = query.ToList(); } @@ -5792,7 +5426,8 @@ public virtual void Include16() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }).Distinct().Include(x => x.foo.OneToOne_Optional_FK2).Include(x => x.bar.OneToMany_Optional2); + var query = ctx.LevelOne.Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }).Distinct() + .Include(x => x.foo.OneToOne_Optional_FK2).Include(x => x.bar.OneToMany_Optional2); var result = query.ToList(); } @@ -5803,7 +5438,8 @@ public virtual void Include17() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }).Include(x => x.foo.OneToOne_Optional_FK2).Distinct(); + var query = ctx.LevelOne.Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }) + .Include(x => x.foo.OneToOne_Optional_FK2).Distinct(); var result = query.ToList(); } @@ -5814,9 +5450,9 @@ public virtual void Include17() public virtual Task Include18_1(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1") - }; + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1") + }; return AssertIncludeQuery( isAsync, @@ -5829,14 +5465,15 @@ public virtual Task Include18_1(bool isAsync) public virtual Task Include18_1_1(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1") - }; + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1") + }; return AssertIncludeQuery( isAsync, l1s => l1s.OrderBy(x => x.OneToOne_Required_FK1.Name).Include(x => x.OneToOne_Optional_FK1).Take(10), - l1s => l1s.OrderBy(x => Maybe(x.OneToOne_Required_FK1, () => x.OneToOne_Required_FK1.Name)).Include(x => x.OneToOne_Optional_FK1).Take(10), + l1s => l1s.OrderBy(x => Maybe(x.OneToOne_Required_FK1, () => x.OneToOne_Required_FK1.Name)) + .Include(x => x.OneToOne_Optional_FK1).Take(10), expectedIncludes); } @@ -5845,9 +5482,9 @@ public virtual Task Include18_1_1(bool isAsync) public virtual Task Include18_2(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1") - }; + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1, "OneToOne_Optional_FK1") + }; return AssertIncludeQuery( isAsync, @@ -5861,7 +5498,8 @@ public virtual void Include18_3() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.OrderBy(x => x.OneToOne_Required_FK1.Name).Include(x => x.OneToOne_Optional_FK1).Select(l1 => new { foo = l1, bar = l1 }).Take(10); + var query = ctx.LevelOne.OrderBy(x => x.OneToOne_Required_FK1.Name).Include(x => x.OneToOne_Optional_FK1) + .Select(l1 => new { foo = l1, bar = l1 }).Take(10); var result = query.ToList(); } @@ -5872,7 +5510,8 @@ public virtual void Include18_3_1() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.OrderBy(x => x.OneToOne_Required_FK1.Name).Include(x => x.OneToOne_Optional_FK1).Select(l1 => new { foo = l1, bar = l1 }).Take(10).Select(x => new { x.foo, x.bar }); + var query = ctx.LevelOne.OrderBy(x => x.OneToOne_Required_FK1.Name).Include(x => x.OneToOne_Optional_FK1) + .Select(l1 => new { foo = l1, bar = l1 }).Take(10).Select(x => new { x.foo, x.bar }); var result = query.ToList(); } @@ -5883,7 +5522,8 @@ public virtual void Include18_3_2() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.OrderBy(x => x.OneToOne_Required_FK1.Name).Include(x => x.OneToOne_Optional_FK1).Select(l1 => new { outer_foo = new { inner_foo = l1, inner_bar = l1.Name }, outer_bar = l1 }).Take(10); + var query = ctx.LevelOne.OrderBy(x => x.OneToOne_Required_FK1.Name).Include(x => x.OneToOne_Optional_FK1) + .Select(l1 => new { outer_foo = new { inner_foo = l1, inner_bar = l1.Name }, outer_bar = l1 }).Take(10); var result = query.ToList(); } @@ -5894,9 +5534,9 @@ public virtual void Include18_3_2() public virtual Task Include18_3_3(bool isAsync) { var expectedIncludes = new List - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK2, "OneToOne_Optional_FK2") - }; + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK2, "OneToOne_Optional_FK2") + }; return AssertIncludeQuery( isAsync, @@ -5920,7 +5560,8 @@ public virtual void Include18() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.Include(x => x.OneToOne_Optional_FK1).Select(l1 => new { foo = l1, bar = l1.OneToOne_Optional_PK1 }).OrderBy(x => x.foo.Id).Take(10); + var query = ctx.LevelOne.Include(x => x.OneToOne_Optional_FK1) + .Select(l1 => new { foo = l1, bar = l1.OneToOne_Optional_PK1 }).OrderBy(x => x.foo.Id).Take(10); var result = query.ToList(); } @@ -5931,7 +5572,8 @@ public virtual void Include19() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.Include(x => x.OneToOne_Optional_FK1).Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }).Distinct(); + var query = ctx.LevelOne.Include(x => x.OneToOne_Optional_FK1) + .Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }).Distinct(); var result = query.ToList(); } @@ -5982,7 +5624,8 @@ public virtual void IncludeCollection5() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2).Select(l1 => l1.OneToMany_Optional1); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .Select(l1 => l1.OneToMany_Optional1); var result = query.ToList(); } } @@ -5992,7 +5635,8 @@ public virtual void IncludeCollection6() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2).ThenInclude(l3 => l3.OneToOne_Optional_FK3) + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .ThenInclude(l3 => l3.OneToOne_Optional_FK3) .Select(l1 => l1.OneToMany_Optional1); var result = query.ToList(); } @@ -6003,7 +5647,8 @@ public virtual void IncludeCollection6_1() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2).ThenInclude(l3 => l3.OneToOne_Optional_FK3); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .ThenInclude(l3 => l3.OneToOne_Optional_FK3); var result = query.ToList(); } } @@ -6013,8 +5658,10 @@ public virtual void IncludeCollection6_2() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2).ThenInclude(l3 => l3.OneToOne_Optional_FK3) - .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_FK2).ThenInclude(l3 => l3.OneToMany_Optional3) + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .ThenInclude(l3 => l3.OneToOne_Optional_FK3) + .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_FK2) + .ThenInclude(l3 => l3.OneToMany_Optional3) .Select(l1 => l1.OneToMany_Optional1); var result = query.ToList(); } @@ -6025,8 +5672,10 @@ public virtual void IncludeCollection6_3() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2).ThenInclude(l3 => l3.OneToOne_Optional_FK3) - .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_FK2).ThenInclude(l3 => l3.OneToMany_Optional3); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .ThenInclude(l3 => l3.OneToOne_Optional_FK3) + .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_FK2) + .ThenInclude(l3 => l3.OneToMany_Optional3); var result = query.ToList(); } @@ -6037,7 +5686,8 @@ public virtual void IncludeCollection6_4() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2).ThenInclude(l3 => l3.OneToOne_Optional_FK3) + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .ThenInclude(l3 => l3.OneToOne_Optional_FK3) .Select(l1 => l1.OneToMany_Optional1.Select(l2 => l2.OneToOne_Optional_PK2)); var result = query.ToList(); @@ -6049,7 +5699,8 @@ public virtual void IncludeCollection7() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2).Select(l1 => new { l1, l1.OneToMany_Optional1 }); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .Select(l1 => new { l1, l1.OneToMany_Optional1 }); var result = query.ToList(); } } @@ -6059,7 +5710,8 @@ public virtual void IncludeCollection8() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2).ThenInclude(l3 => l3.OneToOne_Optional_FK3) + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .ThenInclude(l3 => l3.OneToOne_Optional_FK3) .Where(l1 => l1.OneToMany_Optional1.Where(l2 => l2.OneToOne_Optional_PK2.Name != "Foo").Count() > 0); var result = query.ToList(); @@ -6071,7 +5723,8 @@ public virtual void Include_with_all_method_include_gets_ignored() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.Include(l1 => l1.OneToOne_Optional_FK1).Include(l1 => l1.OneToMany_Optional1).All(l1 => l1.Name != "Foo"); + var query = ctx.LevelOne.Include(l1 => l1.OneToOne_Optional_FK1).Include(l1 => l1.OneToMany_Optional1) + .All(l1 => l1.Name != "Foo"); } } @@ -6089,7 +5742,9 @@ public virtual void Join_with_navigations_in_the_result_selector2() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.Join(ctx.LevelTwo, l1 => l1.Id, l2 => l2.Level1_Required_Id, (o, i) => new { o.OneToOne_Optional_FK1, i.OneToMany_Optional2 }); + var query = ctx.LevelOne.Join( + ctx.LevelTwo, l1 => l1.Id, l2 => l2.Level1_Required_Id, + (o, i) => new { o.OneToOne_Optional_FK1, i.OneToMany_Optional2 }); var result = query.ToList(); } } @@ -6099,7 +5754,8 @@ public virtual void GroupJoin_with_navigations_in_the_result_selector() { using (var ctx = CreateContext()) { - var query = ctx.LevelOne.GroupJoin(ctx.LevelTwo, l1 => l1.Id, l2 => l2.Level1_Required_Id, (o, i) => new { o.OneToOne_Optional_FK1, i }); + var query = ctx.LevelOne.GroupJoin( + ctx.LevelTwo, l1 => l1.Id, l2 => l2.Level1_Required_Id, (o, i) => new { o.OneToOne_Optional_FK1, i }); var result = query.ToList(); } } @@ -6137,10 +5793,11 @@ orderby l1.Id select (from l2 in ctx.LevelTwo orderby l2.Id where l2.Level1_Required_Id == l1.Id - select l2.OneToMany_Optional2.Select(l3 => (from l4 in ctx.LevelFour - where l4.Level3_Required_Id == l3.Id - orderby l4.Id - select l4).FirstOrDefault()).FirstOrDefault()).FirstOrDefault().Name; + select l2.OneToMany_Optional2.Select( + l3 => (from l4 in ctx.LevelFour + where l4.Level3_Required_Id == l3.Id + orderby l4.Id + select l4).FirstOrDefault()).FirstOrDefault()).FirstOrDefault().Name; var result = query.ToList(); } @@ -6152,11 +5809,17 @@ public virtual Task Member_pushdown_with_multiple_collections(bool isAsync) { return AssertQuery( isAsync, - l1s => l1s.Select(l1 => l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).FirstOrDefault().OneToMany_Optional2.OrderBy(l3 => l3.Id).FirstOrDefault().Name), - l1s => l1s.Select(l1s => Maybe( - l1s.OneToMany_Optional1.OrderBy(l2 => l2.Id).FirstOrDefault(), - () => Maybe(l1s.OneToMany_Optional1.OrderBy(l2 => MaybeScalar(l2, () => l2.Id)).FirstOrDefault().OneToMany_Optional2.OrderBy(l3 => l3.Id).FirstOrDefault(), - () => l1s.OneToMany_Optional1.OrderBy(l2 => MaybeScalar(l2, () => l2.Id)).FirstOrDefault().OneToMany_Optional2.OrderBy(l3 => l3.Id).FirstOrDefault().Name)))); + l1s => l1s.Select( + l1 => l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).FirstOrDefault().OneToMany_Optional2.OrderBy(l3 => l3.Id) + .FirstOrDefault().Name), + l1s => l1s.Select( + l1s => Maybe( + l1s.OneToMany_Optional1.OrderBy(l2 => l2.Id).FirstOrDefault(), + () => Maybe( + l1s.OneToMany_Optional1.OrderBy(l2 => MaybeScalar(l2, () => l2.Id)).FirstOrDefault().OneToMany_Optional2 + .OrderBy(l3 => l3.Id).FirstOrDefault(), + () => l1s.OneToMany_Optional1.OrderBy(l2 => MaybeScalar(l2, () => l2.Id)).FirstOrDefault() + .OneToMany_Optional2.OrderBy(l3 => l3.Id).FirstOrDefault().Name)))); } [ConditionalTheory] @@ -6180,14 +5843,15 @@ public virtual Task Null_check_removal_applied_recursively(bool isAsync) { return AssertQuery( isAsync, - l1s => l1s.Where(l1 => - (((l1.OneToOne_Optional_FK1 == null - ? null - : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2) == null + l1s => l1s.Where( + l1 => + (((l1.OneToOne_Optional_FK1 == null + ? null + : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2) == null + ? null + : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3) == null ? null - : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3) == null - ? null - : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3.Name) == "L4 01")); + : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3.Name) == "L4 01")); } [ConditionalTheory] @@ -6196,14 +5860,15 @@ public virtual Task Null_check_different_structure_does_not_remove_null_checks(b { return AssertQuery( isAsync, - l1s => l1s.Where(l1 => - (l1.OneToOne_Optional_FK1 == null - ? null - : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2 == null + l1s => l1s.Where( + l1 => + (l1.OneToOne_Optional_FK1 == null ? null - : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3 == null + : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2 == null ? null - : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3.Name) == "L4 01")); + : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3 == null + ? null + : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3.Name) == "L4 01")); } } } diff --git a/test/EFCore.Specification.Tests/Query/DbFunctionsTestBase.cs b/test/EFCore.Specification.Tests/Query/DbFunctionsTestBase.cs index c78dad83f8e..4bdd62d0090 100644 --- a/test/EFCore.Specification.Tests/Query/DbFunctionsTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/DbFunctionsTestBase.cs @@ -4,7 +4,6 @@ using System.Linq; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable InconsistentNaming diff --git a/test/EFCore.Specification.Tests/Query/FiltersInheritanceTestBase.cs b/test/EFCore.Specification.Tests/Query/FiltersInheritanceTestBase.cs index 058de68dc43..0bd389c5619 100644 --- a/test/EFCore.Specification.Tests/Query/FiltersInheritanceTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/FiltersInheritanceTestBase.cs @@ -106,10 +106,7 @@ var animals = context.Set() .OfType() .Select( - b => new - { - b.EagleId - }) + b => new { b.EagleId }) .ToList(); Assert.Equal(1, animals.Count); diff --git a/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs index 83ed5071f3c..514722010c6 100644 --- a/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs @@ -3,7 +3,6 @@ using System.Linq; using Microsoft.EntityFrameworkCore.TestModels.FunkyDataModel; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable StringStartsWithIsCultureSpecific @@ -104,21 +103,13 @@ public virtual void String_contains_on_argument_with_wildcard_column() { var result = ctx.FunkyCustomers.Select(c => c.FirstName) .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new { fn, ln }) .Where(r => r.fn.Contains(r.ln)) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); var expected = ctx.FunkyCustomers.Select(c => c.FirstName).ToList() .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new { fn, ln }) .Where(r => r.ln?.Length == 0 || (r.fn != null && r.ln != null && r.fn.Contains(r.ln))) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); @@ -138,21 +129,13 @@ public virtual void String_contains_on_argument_with_wildcard_column_negated() { var result = ctx.FunkyCustomers.Select(c => c.FirstName) .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new { fn, ln }) .Where(r => !r.fn.Contains(r.ln)) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); var expected = ctx.FunkyCustomers.Select(c => c.FirstName).ToList() .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new { fn, ln }) .Where(r => r.ln?.Length != 0 && r.fn != null && r.ln != null && !r.fn.Contains(r.ln)) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); @@ -250,21 +233,13 @@ public virtual void String_starts_with_on_argument_with_wildcard_column() { var result = ctx.FunkyCustomers.Select(c => c.FirstName) .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new { fn, ln }) .Where(r => r.fn.StartsWith(r.ln)) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); var expected = ctx.FunkyCustomers.Select(c => c.FirstName).ToList() .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new { fn, ln }) .Where(r => r.ln?.Length == 0 || (r.fn != null && r.ln != null && r.fn.StartsWith(r.ln))) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); @@ -284,21 +259,13 @@ public virtual void String_starts_with_on_argument_with_wildcard_column_negated( { var result = ctx.FunkyCustomers.Select(c => c.FirstName) .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new { fn, ln }) .Where(r => !r.fn.StartsWith(r.ln)) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); var expected = ctx.FunkyCustomers.Select(c => c.FirstName).ToList() .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new { fn, ln }) .Where(r => r.ln?.Length != 0 && r.fn != null && r.ln != null && !r.fn.StartsWith(r.ln)) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); @@ -396,21 +363,13 @@ public virtual void String_ends_with_on_argument_with_wildcard_column() { var result = ctx.FunkyCustomers.Select(c => c.FirstName) .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new { fn, ln }) .Where(r => r.fn.EndsWith(r.ln)) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); var expected = ctx.FunkyCustomers.Select(c => c.FirstName).ToList() .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new { fn, ln }) .Where(r => r.ln?.Length == 0 || (r.fn != null && r.ln != null && r.fn.EndsWith(r.ln))) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); @@ -430,21 +389,13 @@ public virtual void String_ends_with_on_argument_with_wildcard_column_negated() { var result = ctx.FunkyCustomers.Select(c => c.FirstName) .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new { fn, ln }) .Where(r => !r.fn.EndsWith(r.ln)) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); var expected = ctx.FunkyCustomers.Select(c => c.FirstName).ToList() .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new { fn, ln }) .Where(r => r.ln?.Length != 0 && r.fn != null && r.ln != null && !r.fn.EndsWith(r.ln)) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); @@ -464,21 +415,13 @@ public virtual void String_ends_with_inside_conditional() { var result = ctx.FunkyCustomers.Select(c => c.FirstName) .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new { fn, ln }) .Where(r => r.fn.EndsWith(r.ln) ? true : false) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); var expected = ctx.FunkyCustomers.Select(c => c.FirstName).ToList() .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new { fn, ln }) .Where(r => r.ln?.Length == 0 || (r.fn != null && r.ln != null && r.fn.EndsWith(r.ln)) ? true : false) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); @@ -498,21 +441,13 @@ public virtual void String_ends_with_inside_conditional_negated() { var result = ctx.FunkyCustomers.Select(c => c.FirstName) .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName), (fn, ln) => new { fn, ln }) .Where(r => !r.fn.EndsWith(r.ln) ? true : false) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); var expected = ctx.FunkyCustomers.Select(c => c.FirstName).ToList() .SelectMany( - c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new - { - fn, - ln - }) + c => ctx.FunkyCustomers.Select(c2 => c2.LastName).ToList(), (fn, ln) => new { fn, ln }) .Where(r => r.ln?.Length != 0 && r.fn != null && r.ln != null && !r.fn.EndsWith(r.ln) ? true : false) .ToList().OrderBy(r => r.fn).ThenBy(r => r.ln).ToList(); @@ -532,40 +467,24 @@ public virtual void String_ends_with_equals_nullable_column() { var expected = ctx.FunkyCustomers.ToList() .SelectMany( - c => ctx.FunkyCustomers.ToList(), (c1, c2) => new - { - c1, - c2 - }) + c => ctx.FunkyCustomers.ToList(), (c1, c2) => new { c1, c2 }) .Where( r => (r.c2.LastName != null && r.c1.FirstName != null && r.c1.NullableBool.HasValue && r.c1.FirstName.EndsWith(r.c2.LastName) == r.c1.NullableBool.Value) || (r.c2.LastName == null && r.c1.NullableBool == false)) .ToList().Select( - r => new - { - r.c1.FirstName, - r.c2.LastName, - r.c1.NullableBool - }).OrderBy(r => r.FirstName).ThenBy(r => r.LastName).ToList(); + r => new { r.c1.FirstName, r.c2.LastName, r.c1.NullableBool }).OrderBy(r => r.FirstName).ThenBy(r => r.LastName) + .ToList(); ClearLog(); var result = ctx.FunkyCustomers .SelectMany( - c => ctx.FunkyCustomers, (c1, c2) => new - { - c1, - c2 - }) + c => ctx.FunkyCustomers, (c1, c2) => new { c1, c2 }) .Where(r => r.c1.FirstName.EndsWith(r.c2.LastName) == r.c1.NullableBool.Value) .ToList().Select( - r => new - { - r.c1.FirstName, - r.c2.LastName, - r.c1.NullableBool - }).OrderBy(r => r.FirstName).ThenBy(r => r.LastName).ToList(); + r => new { r.c1.FirstName, r.c2.LastName, r.c1.NullableBool }).OrderBy(r => r.FirstName).ThenBy(r => r.LastName) + .ToList(); Assert.Equal(result.Count, expected.Count); for (var i = 0; i < result.Count; i++) @@ -583,11 +502,7 @@ public virtual void String_ends_with_not_equals_nullable_column() { var expected = ctx.FunkyCustomers.ToList() .SelectMany( - c => ctx.FunkyCustomers.ToList(), (c1, c2) => new - { - c1, - c2 - }) + c => ctx.FunkyCustomers.ToList(), (c1, c2) => new { c1, c2 }) .Where( r => (r.c2.LastName != null && r.c1.FirstName != null && r.c1.NullableBool.HasValue @@ -595,30 +510,18 @@ public virtual void String_ends_with_not_equals_nullable_column() || r.c1.NullableBool == null || (r.c2.LastName == null && r.c1.NullableBool == true)) .ToList().Select( - r => new - { - r.c1.FirstName, - r.c2.LastName, - r.c1.NullableBool - }).OrderBy(r => r.FirstName).ThenBy(r => r.LastName).ToList(); + r => new { r.c1.FirstName, r.c2.LastName, r.c1.NullableBool }).OrderBy(r => r.FirstName).ThenBy(r => r.LastName) + .ToList(); ClearLog(); var result = ctx.FunkyCustomers .SelectMany( - c => ctx.FunkyCustomers, (c1, c2) => new - { - c1, - c2 - }) + c => ctx.FunkyCustomers, (c1, c2) => new { c1, c2 }) .Where(r => r.c1.FirstName.EndsWith(r.c2.LastName) != r.c1.NullableBool.Value) .ToList().Select( - r => new - { - r.c1.FirstName, - r.c2.LastName, - r.c1.NullableBool - }).OrderBy(r => r.FirstName).ThenBy(r => r.LastName).ToList(); + r => new { r.c1.FirstName, r.c2.LastName, r.c1.NullableBool }).OrderBy(r => r.FirstName).ThenBy(r => r.LastName) + .ToList(); Assert.Equal(result.Count, expected.Count); for (var i = 0; i < result.Count; i++) diff --git a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs index d58b21f9303..35323a0e580 100644 --- a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; @@ -36,8 +35,7 @@ protected GearsOfWarQueryFixtureBase() var entityAsserters = new Dictionary> { { - typeof(City), - (e, a) => + typeof(City), (e, a) => { Assert.Equal(e == null, a == null); @@ -50,8 +48,7 @@ protected GearsOfWarQueryFixtureBase() } }, { - typeof(CogTag), - (e, a) => + typeof(CogTag), (e, a) => { Assert.Equal(e == null, a == null); @@ -65,8 +62,7 @@ protected GearsOfWarQueryFixtureBase() } }, { - typeof(Faction), - (e, a) => + typeof(Faction), (e, a) => { Assert.Equal(e == null, a == null); @@ -79,8 +75,7 @@ protected GearsOfWarQueryFixtureBase() } }, { - typeof(Gear), - (e, a) => + typeof(Gear), (e, a) => { Assert.Equal(e == null, a == null); @@ -98,8 +93,7 @@ protected GearsOfWarQueryFixtureBase() } }, { - typeof(LocustCommander), - (e, a) => + typeof(LocustCommander), (e, a) => { Assert.Equal(e == null, a == null); @@ -113,8 +107,7 @@ protected GearsOfWarQueryFixtureBase() } }, { - typeof(LocustHorde), - (e, a) => + typeof(LocustHorde), (e, a) => { Assert.Equal(e == null, a == null); @@ -129,8 +122,7 @@ protected GearsOfWarQueryFixtureBase() } }, { - typeof(LocustLeader), - (e, a) => + typeof(LocustLeader), (e, a) => { Assert.Equal(e == null, a == null); @@ -142,8 +134,7 @@ protected GearsOfWarQueryFixtureBase() } }, { - typeof(Mission), - (e, a) => + typeof(Mission), (e, a) => { Assert.Equal(e == null, a == null); @@ -157,8 +148,7 @@ protected GearsOfWarQueryFixtureBase() } }, { - typeof(Officer), - (e, a) => + typeof(Officer), (e, a) => { Assert.Equal(e == null, a == null); @@ -176,8 +166,7 @@ protected GearsOfWarQueryFixtureBase() } }, { - typeof(Squad), - (e, a) => + typeof(Squad), (e, a) => { Assert.Equal(e == null, a == null); @@ -189,8 +178,7 @@ protected GearsOfWarQueryFixtureBase() } }, { - typeof(SquadMission), - (e, a) => + typeof(SquadMission), (e, a) => { Assert.Equal(e == null, a == null); @@ -202,8 +190,7 @@ protected GearsOfWarQueryFixtureBase() } }, { - typeof(Weapon), - (e, a) => + typeof(Weapon), (e, a) => { Assert.Equal(e == null, a == null); @@ -236,28 +223,16 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b => { b.HasKey( - g => new - { - g.Nickname, - g.SquadId - }); + g => new { g.Nickname, g.SquadId }); b.HasOne(g => g.CityOfBirth).WithMany(c => c.BornGears).HasForeignKey(g => g.CityOrBirthName).IsRequired(); b.HasOne(g => g.Tag).WithOne(t => t.Gear).HasForeignKey( - t => new - { - t.GearNickName, - t.GearSquadId - }); + t => new { t.GearNickName, t.GearSquadId }); b.HasOne(g => g.AssignedCity).WithMany(c => c.StationedGears).IsRequired(false); }); modelBuilder.Entity().HasMany(o => o.Reports).WithOne().HasForeignKey( - o => new - { - o.LeaderNickname, - o.LeaderSquadId - }); + o => new { o.LeaderNickname, o.LeaderSquadId }); modelBuilder.Entity( b => @@ -281,11 +256,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b => { b.HasKey( - sm => new - { - sm.SquadId, - sm.MissionId - }); + sm => new { sm.SquadId, sm.MissionId }); b.HasOne(sm => sm.Mission).WithMany(m => m.ParticipatingSquads).HasForeignKey(sm => sm.MissionId); b.HasOne(sm => sm.Squad).WithMany(s => s.Missions).HasForeignKey(sm => sm.SquadId); }); @@ -301,11 +272,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con modelBuilder.Entity().HasKey(l => l.Name); modelBuilder.Entity().HasBaseType(); modelBuilder.Entity().HasOne(c => c.DefeatedBy).WithOne().HasForeignKey( - c => new - { - c.DefeatedByNickname, - c.DefeatedBySquadId - }); + c => new { c.DefeatedByNickname, c.DefeatedBySquadId }); modelBuilder.Entity().HasKey(l => l.Id); modelBuilder.Entity().Property(l => l.Id).ValueGeneratedNever(); diff --git a/test/EFCore.Specification.Tests/Query/GroupByQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/GroupByQueryTestBase.cs index 3af81640936..2e208b8c081 100644 --- a/test/EFCore.Specification.Tests/Query/GroupByQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/GroupByQueryTestBase.cs @@ -120,11 +120,7 @@ public virtual Task GroupBy_Property_Select_Key_Average(bool isAsync) isAsync, os => os.GroupBy(o => o.CustomerID).Select( g => - new - { - g.Key, - Average = g.Average(o => o.OrderID) - }), + new { g.Key, Average = g.Average(o => o.OrderID) }), e => e.Key); } @@ -136,11 +132,7 @@ public virtual Task GroupBy_Property_Select_Key_Count(bool isAsync) isAsync, os => os.GroupBy(o => EF.Property(o, "CustomerID")).Select( g => - new - { - g.Key, - Count = g.Count() - }), + new { g.Key, Count = g.Count() }), e => e.Key); } @@ -152,11 +144,7 @@ public virtual Task GroupBy_Property_Select_Key_LongCount(bool isAsync) isAsync, os => os.GroupBy(o => o.CustomerID).Select( g => - new - { - g.Key, - LongCount = g.LongCount() - }), + new { g.Key, LongCount = g.LongCount() }), e => e.Key); } @@ -168,11 +156,7 @@ public virtual Task GroupBy_Property_Select_Key_Max(bool isAsync) isAsync, os => os.GroupBy(o => o.CustomerID).Select( g => - new - { - g.Key, - Max = g.Max(o => o.OrderID) - }), + new { g.Key, Max = g.Max(o => o.OrderID) }), e => e.Key); } @@ -184,11 +168,7 @@ public virtual Task GroupBy_Property_Select_Key_Min(bool isAsync) isAsync, os => os.GroupBy(o => o.CustomerID).Select( g => - new - { - g.Key, - Min = g.Min(o => o.OrderID) - }), + new { g.Key, Min = g.Min(o => o.OrderID) }), e => e.Key); } @@ -200,11 +180,7 @@ public virtual Task GroupBy_Property_Select_Key_Sum(bool isAsync) isAsync, os => os.GroupBy(o => o.CustomerID).Select( g => - new - { - g.Key, - Sum = g.Sum(o => o.OrderID) - }), + new { g.Key, Sum = g.Sum(o => o.OrderID) }), e => e.Key); } @@ -254,12 +230,7 @@ public virtual Task GroupBy_Property_Select_key_multiple_times_and_aggregate(boo isAsync, os => os.GroupBy(o => o.CustomerID).Select( g => - new - { - Key1 = g.Key, - Key2 = g.Key, - Sum = g.Sum(o => o.OrderID) - }), + new { Key1 = g.Key, Key2 = g.Key, Sum = g.Sum(o => o.OrderID) }), e => e.Key1); } @@ -271,11 +242,7 @@ public virtual Task GroupBy_Property_Select_Key_with_constant(bool isAsync) isAsync, os => os.GroupBy(o => new { Name = "CustomerID", Value = o.CustomerID }).Select( g => - new - { - g.Key, - Count = g.Count() - }), + new { g.Key, Count = g.Count() }), e => e.Key.Value); } @@ -287,11 +254,7 @@ public virtual Task GroupBy_aggregate_projecting_conditional_expression_based_on isAsync, os => os.GroupBy(o => o.OrderDate).Select( g => - new - { - Key = g.Key == null ? "is null" : "is not null", - Sum = g.Sum(o => o.OrderID) - }), + new { Key = g.Key == null ? "is null" : "is not null", Sum = g.Sum(o => o.OrderID) }), e => e.Sum); } @@ -306,10 +269,7 @@ public virtual Task GroupBy_anonymous_Select_Average(bool isAsync) return AssertQueryScalar( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID - }).Select(g => g.Average(o => o.OrderID))); + o => new { o.CustomerID }).Select(g => g.Average(o => o.OrderID))); } [ConditionalTheory] @@ -319,10 +279,7 @@ public virtual Task GroupBy_anonymous_Select_Count(bool isAsync) return AssertQueryScalar( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID - }).Select(g => g.Count())); + o => new { o.CustomerID }).Select(g => g.Count())); } [ConditionalTheory] @@ -332,10 +289,7 @@ public virtual Task GroupBy_anonymous_Select_LongCount(bool isAsync) return AssertQueryScalar( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID - }).Select(g => g.LongCount())); + o => new { o.CustomerID }).Select(g => g.LongCount())); } [ConditionalTheory] @@ -345,10 +299,7 @@ public virtual Task GroupBy_anonymous_Select_Max(bool isAsync) return AssertQueryScalar( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID - }).Select(g => g.Max(o => o.OrderID))); + o => new { o.CustomerID }).Select(g => g.Max(o => o.OrderID))); } [ConditionalTheory] @@ -358,10 +309,7 @@ public virtual Task GroupBy_anonymous_Select_Min(bool isAsync) return AssertQueryScalar( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID - }).Select(g => g.Min(o => o.OrderID))); + o => new { o.CustomerID }).Select(g => g.Min(o => o.OrderID))); } [ConditionalTheory] @@ -371,10 +319,7 @@ public virtual Task GroupBy_anonymous_Select_Sum(bool isAsync) return AssertQueryScalar( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID - }).Select(g => g.Sum(o => o.OrderID))); + o => new { o.CustomerID }).Select(g => g.Sum(o => o.OrderID))); } [ConditionalTheory] @@ -384,10 +329,7 @@ public virtual Task GroupBy_anonymous_Select_Sum_Min_Max_Avg(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID - }).Select( + o => new { o.CustomerID }).Select( g => new { @@ -406,16 +348,9 @@ public virtual Task GroupBy_anonymous_with_alias_Select_Key_Sum(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - Id = o.CustomerID - }).Select( + o => new { Id = o.CustomerID }).Select( g => - new - { - Key = g.Key.Id, - Sum = g.Sum(o => o.OrderID) - })); + new { Key = g.Key.Id, Sum = g.Sum(o => o.OrderID) })); } [ConditionalTheory] @@ -425,11 +360,7 @@ public virtual Task GroupBy_Composite_Select_Average(bool isAsync) return AssertQueryScalar( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select(g => g.Average(o => o.OrderID))); + o => new { o.CustomerID, o.EmployeeID }).Select(g => g.Average(o => o.OrderID))); } [ConditionalTheory] @@ -439,11 +370,7 @@ public virtual Task GroupBy_Composite_Select_Count(bool isAsync) return AssertQueryScalar( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select(g => g.Count())); + o => new { o.CustomerID, o.EmployeeID }).Select(g => g.Count())); } [ConditionalTheory] @@ -453,11 +380,7 @@ public virtual Task GroupBy_Composite_Select_LongCount(bool isAsync) return AssertQueryScalar( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select(g => g.LongCount())); + o => new { o.CustomerID, o.EmployeeID }).Select(g => g.LongCount())); } [ConditionalTheory] @@ -467,11 +390,7 @@ public virtual Task GroupBy_Composite_Select_Max(bool isAsync) return AssertQueryScalar( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select(g => g.Max(o => o.OrderID))); + o => new { o.CustomerID, o.EmployeeID }).Select(g => g.Max(o => o.OrderID))); } [ConditionalTheory] @@ -481,11 +400,7 @@ public virtual Task GroupBy_Composite_Select_Min(bool isAsync) return AssertQueryScalar( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select(g => g.Min(o => o.OrderID))); + o => new { o.CustomerID, o.EmployeeID }).Select(g => g.Min(o => o.OrderID))); } [ConditionalTheory] @@ -495,11 +410,7 @@ public virtual Task GroupBy_Composite_Select_Sum(bool isAsync) return AssertQueryScalar( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select(g => g.Sum(o => o.OrderID))); + o => new { o.CustomerID, o.EmployeeID }).Select(g => g.Sum(o => o.OrderID))); } [ConditionalTheory] @@ -509,11 +420,7 @@ public virtual Task GroupBy_Composite_Select_Sum_Min_Max_Avg(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select( + o => new { o.CustomerID, o.EmployeeID }).Select( g => new { @@ -532,17 +439,9 @@ public virtual Task GroupBy_Composite_Select_Key_Average(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select( + o => new { o.CustomerID, o.EmployeeID }).Select( g => - new - { - g.Key, - Average = g.Average(o => o.OrderID) - }), + new { g.Key, Average = g.Average(o => o.OrderID) }), e => e.Key.CustomerID + " " + e.Key.EmployeeID); } @@ -553,17 +452,9 @@ public virtual Task GroupBy_Composite_Select_Key_Count(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select( + o => new { o.CustomerID, o.EmployeeID }).Select( g => - new - { - g.Key, - Count = g.Count() - }), + new { g.Key, Count = g.Count() }), e => e.Key.CustomerID + " " + e.Key.EmployeeID); } @@ -574,17 +465,9 @@ public virtual Task GroupBy_Composite_Select_Key_LongCount(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select( + o => new { o.CustomerID, o.EmployeeID }).Select( g => - new - { - g.Key, - LongCount = g.LongCount() - }), + new { g.Key, LongCount = g.LongCount() }), e => e.Key.CustomerID + " " + e.Key.EmployeeID); } @@ -595,17 +478,9 @@ public virtual Task GroupBy_Composite_Select_Key_Max(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select( + o => new { o.CustomerID, o.EmployeeID }).Select( g => - new - { - g.Key, - Max = g.Max(o => o.OrderID) - }), + new { g.Key, Max = g.Max(o => o.OrderID) }), e => e.Key.CustomerID + " " + e.Key.EmployeeID); } @@ -616,17 +491,9 @@ public virtual Task GroupBy_Composite_Select_Key_Min(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select( + o => new { o.CustomerID, o.EmployeeID }).Select( g => - new - { - g.Key, - Min = g.Min(o => o.OrderID) - }), + new { g.Key, Min = g.Min(o => o.OrderID) }), e => e.Key.CustomerID + " " + e.Key.EmployeeID); } @@ -637,17 +504,9 @@ public virtual Task GroupBy_Composite_Select_Key_Sum(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select( + o => new { o.CustomerID, o.EmployeeID }).Select( g => - new - { - g.Key, - Sum = g.Sum(o => o.OrderID) - }), + new { g.Key, Sum = g.Sum(o => o.OrderID) }), e => e.Key.CustomerID + " " + e.Key.EmployeeID); } @@ -658,11 +517,7 @@ public virtual Task GroupBy_Composite_Select_Key_Sum_Min_Max_Avg(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select( + o => new { o.CustomerID, o.EmployeeID }).Select( g => new { @@ -682,11 +537,7 @@ public virtual Task GroupBy_Composite_Select_Sum_Min_Key_Max_Avg(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select( + o => new { o.CustomerID, o.EmployeeID }).Select( g => new { @@ -706,11 +557,7 @@ public virtual Task GroupBy_Composite_Select_Sum_Min_Key_flattened_Max_Avg(bool return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select( + o => new { o.CustomerID, o.EmployeeID }).Select( g => new { @@ -731,17 +578,9 @@ public virtual Task GroupBy_Dto_as_key_Select_Sum(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy( - o => new NominalType - { - CustomerID = o.CustomerID, - EmployeeID = o.EmployeeID - }).Select( + o => new NominalType { CustomerID = o.CustomerID, EmployeeID = o.EmployeeID }).Select( g => - new - { - Sum = g.Sum(o => o.OrderID), - g.Key - })); + new { Sum = g.Sum(o => o.OrderID), g.Key })); } [ConditionalTheory] @@ -752,18 +591,10 @@ public virtual Task GroupBy_Dto_as_element_selector_Select_Sum(bool isAsync) isAsync, os => os.GroupBy( o => o.CustomerID, - o => new NominalType - { - CustomerID = o.CustomerID, - EmployeeID = o.EmployeeID - }) + o => new NominalType { CustomerID = o.CustomerID, EmployeeID = o.EmployeeID }) .Select( g => - new - { - Sum = g.Sum(o => o.EmployeeID), - g.Key - })); + new { Sum = g.Sum(o => o.EmployeeID), g.Key })); } protected class NominalType @@ -792,11 +623,7 @@ public virtual Task GroupBy_Composite_Select_Dto_Sum_Min_Key_flattened_Max_Avg(b return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select( + o => new { o.CustomerID, o.EmployeeID }).Select( g => new CompositeDto { @@ -840,11 +667,7 @@ public virtual Task GroupBy_Composite_Select_Sum_Min_part_Key_flattened_Max_Avg( return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.EmployeeID - }).Select( + o => new { o.CustomerID, o.EmployeeID }).Select( g => new { @@ -884,10 +707,7 @@ public virtual Task GroupBy_Constant_with_element_selector_Select_Sum(bool isAsy isAsync, os => os.GroupBy(o => 2, o => new { o.OrderID, o.OrderDate }).Select( g => - new - { - Sum = g.Sum(o => o.OrderID) - }), + new { Sum = g.Sum(o => o.OrderID) }), e => e.Sum); } @@ -899,10 +719,7 @@ public virtual Task GroupBy_Constant_with_element_selector_Select_Sum2(bool isAs isAsync, os => os.GroupBy(o => 2, o => new { o.OrderID }).Select( g => - new - { - Sum = g.Sum(o => o.OrderID) - }), + new { Sum = g.Sum(o => o.OrderID) }), e => e.Sum); } @@ -914,10 +731,7 @@ public virtual Task GroupBy_Constant_with_element_selector_Select_Sum3(bool isAs isAsync, os => os.GroupBy(o => 2, o => new { o.OrderID, o.OrderDate, o.CustomerID }).Select( g => - new - { - Sum = g.Sum(o => o.OrderID) - }), + new { Sum = g.Sum(o => o.OrderID) }), e => e.Sum); } @@ -948,11 +762,7 @@ public virtual Task GroupBy_Constant_with_element_selector_Select_Sum_Min_Key_Ma isAsync, os => os.GroupBy(o => 2, o => o.OrderID).Select( g => - new - { - Sum = g.Sum(), - g.Key - }), + new { Sum = g.Sum(), g.Key }), e => e.Sum); } @@ -987,10 +797,7 @@ public virtual Task GroupBy_param_with_element_selector_Select_Sum(bool isAsync) isAsync, os => os.GroupBy(o => a, o => new { o.OrderID, o.OrderDate }).Select( g => - new - { - Sum = g.Sum(o => o.OrderID) - }), + new { Sum = g.Sum(o => o.OrderID) }), e => e.Sum); } @@ -1004,10 +811,7 @@ public virtual Task GroupBy_param_with_element_selector_Select_Sum2(bool isAsync isAsync, os => os.GroupBy(o => a, o => new { o.OrderID }).Select( g => - new - { - Sum = g.Sum(o => o.OrderID) - }), + new { Sum = g.Sum(o => o.OrderID) }), e => e.Sum); } @@ -1021,10 +825,7 @@ public virtual Task GroupBy_param_with_element_selector_Select_Sum3(bool isAsync isAsync, os => os.GroupBy(o => a, o => new { o.OrderID, o.OrderDate, o.CustomerID }).Select( g => - new - { - Sum = g.Sum(o => o.OrderID) - }), + new { Sum = g.Sum(o => o.OrderID) }), e => e.Sum); } @@ -1038,11 +839,7 @@ public virtual Task GroupBy_param_with_element_selector_Select_Sum_Min_Key_Max_A isAsync, os => os.GroupBy(o => a, o => o.OrderID).Select( g => - new - { - Sum = g.Sum(), - g.Key - }), + new { Sum = g.Sum(), g.Key }), e => e.Sum); } @@ -1054,11 +851,7 @@ public virtual Task GroupBy_anonymous_key_type_mismatch_with_aggregate(bool isAs isAsync, os => os.GroupBy(o => new { I0 = (int?)o.OrderDate.Value.Year }) .OrderBy(g => g.Key.I0) - .Select(g => new - { - I0 = g.Count(), - I1 = g.Key.I0 - }), + .Select(g => new { I0 = g.Count(), I1 = g.Key.I0 }), elementSorter: a => a.I1); } @@ -1128,13 +921,7 @@ public virtual Task GroupBy_Property_scalar_element_selector_Sum_Min_Max_Avg(boo isAsync, os => os.GroupBy(o => o.CustomerID, o => o.OrderID).Select( g => - new - { - Sum = g.Sum(), - Min = g.Min(), - Max = g.Max(), - Avg = g.Average() - }), + new { Sum = g.Sum(), Min = g.Min(), Max = g.Max(), Avg = g.Average() }), e => e.Min + " " + e.Max); } @@ -1145,11 +932,7 @@ public virtual Task GroupBy_Property_anonymous_element_selector_Average(bool isA return AssertQueryScalar( isAsync, os => os.GroupBy( - o => o.CustomerID, o => new - { - o.OrderID, - o.EmployeeID - }).Select(g => g.Average(o => o.OrderID))); + o => o.CustomerID, o => new { o.OrderID, o.EmployeeID }).Select(g => g.Average(o => o.OrderID))); } [ConditionalTheory] @@ -1159,11 +942,7 @@ public virtual Task GroupBy_Property_anonymous_element_selector_Count(bool isAsy return AssertQueryScalar( isAsync, os => os.GroupBy( - o => o.CustomerID, o => new - { - o.OrderID, - o.EmployeeID - }).Select(g => g.Count())); + o => o.CustomerID, o => new { o.OrderID, o.EmployeeID }).Select(g => g.Count())); } [ConditionalTheory] @@ -1173,11 +952,7 @@ public virtual Task GroupBy_Property_anonymous_element_selector_LongCount(bool i return AssertQueryScalar( isAsync, os => os.GroupBy( - o => o.CustomerID, o => new - { - o.OrderID, - o.EmployeeID - }).Select(g => g.LongCount())); + o => o.CustomerID, o => new { o.OrderID, o.EmployeeID }).Select(g => g.LongCount())); } [ConditionalTheory] @@ -1187,11 +962,7 @@ public virtual Task GroupBy_Property_anonymous_element_selector_Max(bool isAsync return AssertQueryScalar( isAsync, os => os.GroupBy( - o => o.CustomerID, o => new - { - o.OrderID, - o.EmployeeID - }).Select(g => g.Max(o => o.OrderID))); + o => o.CustomerID, o => new { o.OrderID, o.EmployeeID }).Select(g => g.Max(o => o.OrderID))); } [ConditionalTheory] @@ -1201,11 +972,7 @@ public virtual Task GroupBy_Property_anonymous_element_selector_Min(bool isAsync return AssertQueryScalar( isAsync, os => os.GroupBy( - o => o.CustomerID, o => new - { - o.OrderID, - o.EmployeeID - }).Select(g => g.Min(o => o.OrderID))); + o => o.CustomerID, o => new { o.OrderID, o.EmployeeID }).Select(g => g.Min(o => o.OrderID))); } [ConditionalTheory] @@ -1215,11 +982,7 @@ public virtual Task GroupBy_Property_anonymous_element_selector_Sum(bool isAsync return AssertQueryScalar( isAsync, os => os.GroupBy( - o => o.CustomerID, o => new - { - o.OrderID, - o.EmployeeID - }).Select(g => g.Sum(o => o.OrderID))); + o => o.CustomerID, o => new { o.OrderID, o.EmployeeID }).Select(g => g.Sum(o => o.OrderID))); } [ConditionalTheory] @@ -1229,11 +992,7 @@ public virtual Task GroupBy_Property_anonymous_element_selector_Sum_Min_Max_Avg( return AssertQuery( isAsync, os => os.GroupBy( - o => o.CustomerID, o => new - { - o.OrderID, - o.EmployeeID - }).Select( + o => o.CustomerID, o => new { o.OrderID, o.EmployeeID }).Select( g => new { @@ -1297,9 +1056,7 @@ public virtual Task GroupBy_empty_key_Aggregate(bool isAsync) isAsync, os => os.GroupBy( - o => new - { - }) + o => new { }) .Select(g => g.Sum(o => o.OrderID))); } @@ -1311,15 +1068,9 @@ public virtual Task GroupBy_empty_key_Aggregate_Key(bool isAsync) isAsync, os => os.GroupBy( - o => new - { - }) + o => new { }) .Select( - g => new - { - g.Key, - Sum = g.Sum(o => o.OrderID) - })); + g => new { g.Key, Sum = g.Sum(o => o.OrderID) })); } [ConditionalTheory] @@ -1384,11 +1135,7 @@ public virtual Task Distinct_GroupBy_Aggregate(bool isAsync) os.Distinct() .GroupBy(o => o.CustomerID) .Select( - g => new - { - g.Key, - c = g.Count() - }), + g => new { g.Key, c = g.Count() }), e => e.Key); } @@ -1400,19 +1147,11 @@ public virtual Task Anonymous_projection_Distinct_GroupBy_Aggregate(bool isAsync isAsync, os => os.Select( - o => new - { - o.OrderID, - o.EmployeeID - }) + o => new { o.OrderID, o.EmployeeID }) .Distinct() .GroupBy(o => o.EmployeeID) .Select( - g => new - { - g.Key, - c = g.Count() - }), + g => new { g.Key, c = g.Count() }), e => e.Key); } @@ -1426,11 +1165,7 @@ public virtual Task SelectMany_GroupBy_Aggregate(bool isAsync) cs.SelectMany(c => c.Orders) .GroupBy(o => o.EmployeeID) .Select( - g => new - { - g.Key, - c = g.Count() - }), + g => new { g.Key, c = g.Count() }), e => e.Key); } @@ -1446,11 +1181,7 @@ join c in cs on o.CustomerID equals c.CustomerID group o by c.CustomerID) .Select( - g => new - { - g.Key, - Count = g.Average(o => o.OrderID) - }), + g => new { g.Key, Count = g.Average(o => o.OrderID) }), e => e.Key); } @@ -1464,11 +1195,7 @@ public virtual Task GroupBy_required_navigation_member_Aggregate(bool isAsync) ods.GroupBy(od => od.Order.CustomerID) .Select( g => - new - { - CustomerId = g.Key, - Count = g.Count() - }), + new { CustomerId = g.Key, Count = g.Count() }), e => e.CustomerId); } @@ -1485,11 +1212,7 @@ join c in cs.Where(c => c.CustomerID != "DRACD" && c.CustomerID != "FOLKO") on o.CustomerID equals c.CustomerID group o by c.CustomerID) .Select( - g => new - { - g.Key, - Count = g.Average(o => o.OrderID) - }), + g => new { g.Key, Count = g.Average(o => o.OrderID) }), e => e.Key); } @@ -1508,11 +1231,7 @@ from o in grouping.DefaultIfEmpty() select o) .GroupBy(o => o.CustomerID) .Select( - g => new - { - g.Key, - Average = g.Average(o => o.OrderID) - }), + g => new { g.Key, Average = g.Average(o => o.OrderID) }), e => e.Key); } @@ -1530,11 +1249,7 @@ from o in grouping.DefaultIfEmpty() select c) .GroupBy(c => c.CustomerID) .Select( - g => new - { - g.Key, - Max = g.Max(c => c.City) - }), + g => new { g.Key, Max = g.Max(c => c.City) }), e => e.Key); } @@ -1552,11 +1267,7 @@ from c in grouping.DefaultIfEmpty() select o) .GroupBy(o => o.CustomerID) .Select( - g => new - { - g.Key, - Average = g.Average(o => o.OrderID) - }), + g => new { g.Key, Average = g.Average(o => o.OrderID) }), e => e.Key); } @@ -1574,11 +1285,7 @@ from o in grouping.DefaultIfEmpty() select c) .GroupBy(c => c.CustomerID) .Select( - g => new - { - Value = g.Key, - Max = g.Max(c => c.City) - }), + g => new { Value = g.Key, Max = g.Max(c => c.City) }), e => e.Value); } @@ -1596,11 +1303,7 @@ from c in grouping.DefaultIfEmpty() select o) .GroupBy(o => o.OrderID) .Select( - g => new - { - Value = g.Key, - Average = g.Average(o => o.OrderID) - }), + g => new { Value = g.Key, Average = g.Average(o => o.OrderID) }), e => e.Value); } @@ -1614,11 +1317,7 @@ public virtual Task GroupBy_optional_navigation_member_Aggregate(bool isAsync) os.GroupBy(o => o.Customer.Country) .Select( g => - new - { - Country = g.Key, - Count = g.Count() - }), + new { Country = g.Key, Count = g.Count() }), e => e.Country); } @@ -1638,11 +1337,7 @@ where o.OrderID > 10300 select o) .GroupBy(o => o.CustomerID) .Select( - g => new - { - g.Key, - Count = g.Average(o => o.OrderID) - }), + g => new { g.Key, Count = g.Average(o => o.OrderID) }), e => e.Key); } @@ -1658,11 +1353,7 @@ join o2 in os2 on o1.OrderID equals o2.OrderID group o2 by o1.CustomerID) .Select( - g => new - { - g.Key, - Count = g.Average(o => o.OrderID) - }), + g => new { g.Key, Count = g.Average(o => o.OrderID) }), e => e.Key); } @@ -1674,18 +1365,10 @@ public virtual Task GroupBy_multi_navigation_members_Aggregate(bool isAsync) isAsync, ods => ods.GroupBy( - od => new - { - od.Order.CustomerID, - od.Product.ProductName - }) + od => new { od.Order.CustomerID, od.Product.ProductName }) .Select( g => - new - { - CompositeKey = g.Key, - Count = g.Count() - }), + new { CompositeKey = g.Key, Count = g.Count() }), e => e.CompositeKey.CustomerID + " " + e.CompositeKey.ProductName); } @@ -1699,11 +1382,7 @@ public virtual Task Union_simple_groupby(bool isAsync) .Union(cs.Where(c => c.City == "México D.F.")) .GroupBy(c => c.City) .Select( - g => new - { - g.Key, - Total = g.Count() - })); + g => new { g.Key, Total = g.Count() })); } [ConditionalTheory] @@ -1714,21 +1393,10 @@ public virtual Task Select_anonymous_GroupBy_Aggregate(bool isAsync) isAsync, os => os.Where(o => o.OrderID < 10300) .Select( - o => new - { - A = o.CustomerID, - B = o.OrderDate, - C = o.OrderID - }) + o => new { A = o.CustomerID, B = o.OrderDate, C = o.OrderID }) .GroupBy(e => e.A) .Select( - g => new - { - Min = g.Min(o => o.B), - Max = g.Max(o => o.B), - Sum = g.Sum(o => o.C), - Avg = g.Average(o => o.C) - })); + g => new { Min = g.Min(o => o.B), Max = g.Max(o => o.B), Sum = g.Sum(o => o.C), Avg = g.Average(o => o.C) })); } [ConditionalTheory] @@ -1739,11 +1407,7 @@ public virtual Task GroupBy_principal_key_property_optimization(bool isAsync) isAsync, os => os.GroupBy(o => o.Customer.CustomerID) .Select( - g => new - { - g.Key, - Count = g.Count() - })); + g => new { g.Key, Count = g.Count() })); } #endregion @@ -1760,11 +1424,7 @@ public virtual Task GroupBy_OrderBy_key(bool isAsync) os.GroupBy(o => o.CustomerID) .OrderBy(o => o.Key) .Select( - g => new - { - g.Key, - c = g.Count() - }), + g => new { g.Key, c = g.Count() }), assertOrder: true); } @@ -1779,11 +1439,7 @@ public virtual Task GroupBy_OrderBy_count(bool isAsync) .OrderBy(o => o.Count()) .ThenBy(o => o.Key) .Select( - g => new - { - g.Key, - Count = g.Count() - }), + g => new { g.Key, Count = g.Count() }), assertOrder: true); } @@ -1798,11 +1454,7 @@ public virtual Task GroupBy_OrderBy_count_Select_sum(bool isAsync) .OrderBy(o => o.Count()) .ThenBy(o => o.Key) .Select( - g => new - { - g.Key, - Sum = g.Sum(o => o.OrderID) - }), + g => new { g.Key, Sum = g.Sum(o => o.OrderID) }), assertOrder: true); } @@ -1871,11 +1523,7 @@ public virtual Task GroupBy_Select_sum_over_unmapped_property(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy(o => o.CustomerID) - .Select(g => new - { - g.Key, - Sum = g.Sum(o => o.Freight) - })); + .Select(g => new { g.Key, Sum = g.Sum(o => o.Freight) })); } [ConditionalTheory] @@ -1888,11 +1536,7 @@ public virtual Task GroupBy_filter_key(bool isAsync) os.GroupBy(o => o.CustomerID) .Where(o => o.Key == "ALFKI") .Select( - g => new - { - g.Key, - c = g.Count() - })); + g => new { g.Key, c = g.Count() })); } [ConditionalTheory] @@ -1905,11 +1549,7 @@ public virtual Task GroupBy_filter_count(bool isAsync) os.GroupBy(o => o.CustomerID) .Where(o => o.Count() > 4) .Select( - g => new - { - g.Key, - Count = g.Count() - })); + g => new { g.Key, Count = g.Count() })); } [ConditionalTheory] @@ -1924,12 +1564,7 @@ public virtual Task GroupBy_filter_count_OrderBy_count_Select_sum(bool isAsync) .OrderBy(o => o.Count()) .ThenBy(o => o.Key) .Select( - g => new - { - g.Key, - Count = g.Count(), - Sum = g.Sum(o => o.OrderID) - })); + g => new { g.Key, Count = g.Count(), Sum = g.Sum(o => o.OrderID) })); } [ConditionalTheory] @@ -1942,18 +1577,10 @@ public virtual Task GroupBy_Aggregate_Join(bool isAsync) from a in os.GroupBy(o => o.CustomerID) .Where(g => g.Count() > 5) .Select( - g => new - { - CustomerID = g.Key, - LastOrderID = g.Max(o => o.OrderID) - }) + g => new { CustomerID = g.Key, LastOrderID = g.Max(o => o.OrderID) }) join c in cs on a.CustomerID equals c.CustomerID join o in os on a.LastOrderID equals o.OrderID - select new - { - c, - o - }, + select new { c, o }, entryCount: 126); } @@ -1968,18 +1595,10 @@ from c in cs join a in os.GroupBy(o => o.CustomerID) .Where(g => g.Count() > 5) .Select( - g => new - { - CustomerID = g.Key, - LastOrderID = g.Max(o => o.OrderID) - }) + g => new { CustomerID = g.Key, LastOrderID = g.Max(o => o.OrderID) }) on c.CustomerID equals a.CustomerID join o in os on a.LastOrderID equals o.OrderID - select new - { - c, - o - }, + select new { c, o }, entryCount: 126); } @@ -1994,17 +1613,9 @@ from c in cs join a in os.GroupBy(o => o.CustomerID) .Where(g => g.Count() > 5) .Select( - g => new - { - CustomerID = g.Key, - LastOrderID = g.Max(o => o.OrderID) - }) + g => new { CustomerID = g.Key, LastOrderID = g.Max(o => o.OrderID) }) on c.CustomerID equals a.CustomerID - select new - { - c, - a.LastOrderID - }, + select new { c, a.LastOrderID }, entryCount: 63); } @@ -2019,20 +1630,11 @@ from c in cs join a in os.GroupBy(o => o.CustomerID) .Where(g => g.Count() > 5) .Select( - g => new - { - CustomerID = g.Key, - LastOrderID = g.Max(o => o.OrderID) - }) + g => new { CustomerID = g.Key, LastOrderID = g.Max(o => o.OrderID) }) on c.CustomerID equals a.CustomerID join o in os on c.CustomerID equals o.CustomerID into grouping from g in grouping - select new - { - c, - a.LastOrderID, - g.OrderID - }, + select new { c, a.LastOrderID, g.OrderID }, entryCount: 63); } @@ -2048,24 +1650,11 @@ join i in (from c in cs join a in os.GroupBy(o => o.CustomerID) .Where(g => g.Count() > 5) .Select( - g => new - { - CustomerID = g.Key, - LastOrderID = g.Max(o => o.OrderID) - }) + g => new { CustomerID = g.Key, LastOrderID = g.Max(o => o.OrderID) }) on c.CustomerID equals a.CustomerID - select new - { - c, - a.LastOrderID - }) + select new { c, a.LastOrderID }) on o.CustomerID equals i.c.CustomerID - select new - { - o, - i.c, - i.c.CustomerID - }, + select new { o, i.c, i.c.CustomerID }, entryCount: 187); } @@ -2080,17 +1669,9 @@ public virtual Task Join_GroupBy_Aggregate_on_key(bool isAsync) join a in os.GroupBy(o => o.CustomerID) .Where(g => g.Count() > 5) .Select( - g => new - { - g.Key, - LastOrderID = g.Max(o => o.OrderID) - }) + g => new { g.Key, LastOrderID = g.Max(o => o.OrderID) }) on c.CustomerID equals a.Key - select new - { - c, - a.LastOrderID - }), + select new { c, a.LastOrderID }), e => e.c.CustomerID, entryCount: 63); } @@ -2146,11 +1727,7 @@ public virtual Task Distinct_GroupBy_OrderBy_key(bool isAsync) .GroupBy(o => o.CustomerID) .OrderBy(o => o.Key) .Select( - g => new - { - g.Key, - c = g.Count() - }), + g => new { g.Key, c = g.Count() }), assertOrder: true); } @@ -2173,12 +1750,8 @@ public virtual Task Select_GroupBy_All(bool isAsync) { return AssertAll>( isAsync, - os => os.Select(o => new ProjectedType - { - Order = o.OrderID, - Customer = o.CustomerID - }) - .GroupBy(a => a.Customer), + os => os.Select(o => new ProjectedType { Order = o.OrderID, Customer = o.CustomerID }) + .GroupBy(a => a.Customer), a => a.Key == "ALFKI"); } @@ -2208,10 +1781,7 @@ public virtual Task GroupBy_Where_in_aggregate(bool isAsync) return AssertQueryScalar( isAsync, os => from o in os - group o by new - { - o.CustomerID - } + group o by new { o.CustomerID } into g select g.Where(e => e.OrderID < 10300).Count()); } @@ -2223,18 +1793,9 @@ public virtual Task GroupBy_Key_as_part_of_element_selector(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy( - o => o.OrderID, o => new - { - o.OrderID, - o.OrderDate - }) + o => o.OrderID, o => new { o.OrderID, o.OrderDate }) .Select( - g => new - { - g.Key, - Avg = g.Average(e => e.OrderID), - Max = g.Max(o => o.OrderDate) - })); + g => new { g.Key, Avg = g.Average(e => e.OrderID), Max = g.Max(o => o.OrderDate) })); } [ConditionalTheory] @@ -2244,22 +1805,9 @@ public virtual Task GroupBy_composite_Key_as_part_of_element_selector(bool isAsy return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.OrderID, - o.CustomerID - }, o => new - { - o.OrderID, - o.OrderDate - }) + o => new { o.OrderID, o.CustomerID }, o => new { o.OrderID, o.OrderDate }) .Select( - g => new - { - g.Key, - Avg = g.Average(e => e.OrderID), - Max = g.Max(o => o.OrderDate) - })); + g => new { g.Key, Avg = g.Average(e => e.OrderID), Max = g.Max(o => o.OrderDate) })); } #endregion @@ -2273,11 +1821,7 @@ public virtual Task GroupBy_anonymous(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.City, - c.CustomerID - }).GroupBy(a => a.City), + c => new { c.City, c.CustomerID }).GroupBy(a => a.City), elementSorter: GroupingSorter(), elementAsserter: GroupingAsserter(d => d.CustomerID)); } @@ -2291,11 +1835,7 @@ public virtual Task GroupBy_anonymous_with_where(bool isAsync) isAsync, cs => cs.Where(c => countries.Contains(c.Country)) .Select( - c => new - { - c.City, - c.CustomerID - }) + c => new { c.City, c.CustomerID }) .GroupBy(a => a.City), elementSorter: GroupingSorter(), elementAsserter: GroupingAsserter(d => d.CustomerID)); @@ -2309,11 +1849,7 @@ public virtual Task GroupBy_anonymous_subquery(bool isAsync) isAsync, cs => cs.Select( - c => new - { - c.City, - c.CustomerID - }) + c => new { c.City, c.CustomerID }) .GroupBy(a => from c2 in cs select c2), assertOrder: true); } @@ -2326,11 +1862,7 @@ public virtual Task GroupBy_nested_order_by_enumerable(bool isAsync) isAsync, cs => cs.Select( - c => new - { - c.Country, - c.CustomerID - }) + c => new { c.Country, c.CustomerID }) .OrderBy(a => a.Country) .GroupBy(a => a.Country) .Select(g => g.OrderBy(a => a.CustomerID)), @@ -2347,15 +1879,9 @@ public virtual Task GroupBy_join_default_if_empty_anonymous(bool isAsync) (from order in os join orderDetail in ods on order.OrderID equals orderDetail.OrderID into orderJoin from orderDetail in orderJoin.DefaultIfEmpty() - group new - { - orderDetail.ProductID, - orderDetail.Quantity, - orderDetail.UnitPrice - } by new + group new { orderDetail.ProductID, orderDetail.Quantity, orderDetail.UnitPrice } by new { - order.OrderID, - order.OrderDate + order.OrderID, order.OrderDate }).Where(x => x.Key.OrderID == 10248), elementAsserter: GroupingAsserter(d => d.ProductID)); } @@ -2441,11 +1967,7 @@ public virtual Task GroupBy_with_element_selector3(bool isAsync) .OrderBy(g => g.Key) .Select( g => g.Select( - e => new - { - Title = EF.Property(e, "Title"), - e - }).ToList()), + e => new { Title = EF.Property(e, "Title"), e }).ToList()), assertOrder: true); } @@ -2506,11 +2028,7 @@ public virtual Task GroupBy_with_orderby_and_anonymous_projection(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy(o => o.CustomerID).OrderBy(g => g.Key).Select( - g => new - { - Foo = "Foo", - Group = g - }), + g => new { Foo = "Foo", Group = g }), e => GroupingSorter()(e.Group), elementAsserter: (e, a) => { @@ -2570,15 +2088,9 @@ public virtual Task GroupBy_join_anonymous(bool isAsync) (from order in os join orderDetail in ods on order.OrderID equals orderDetail.OrderID into orderJoin from orderDetail in orderJoin - group new + group new { orderDetail.ProductID, orderDetail.Quantity, orderDetail.UnitPrice } by new { - orderDetail.ProductID, - orderDetail.Quantity, - orderDetail.UnitPrice - } by new - { - order.OrderID, - order.OrderDate + order.OrderID, order.OrderDate }).Where(x => x.Key.OrderID == 10248), elementAsserter: GroupingAsserter(d => d.ProductID)); } @@ -2637,11 +2149,7 @@ public virtual Task Select_Distinct_GroupBy(bool isAsync) return AssertQuery( isAsync, os => os.Select( - o => new - { - o.CustomerID, - o.EmployeeID - }).OrderBy(a => a.EmployeeID).Distinct().GroupBy(o => o.CustomerID), + o => new { o.CustomerID, o.EmployeeID }).OrderBy(a => a.EmployeeID).Distinct().GroupBy(o => o.CustomerID), elementSorter: GroupingSorter(), elementAsserter: GroupingAsserter(d => d.EmployeeID)); } @@ -2653,10 +2161,7 @@ public virtual Task GroupBy_with_aggregate_through_navigation_property(bool isAs return AssertQuery( isAsync, os => os.GroupBy(c => c.EmployeeID).Select( - g => new - { - max = g.Max(i => i.Customer.Region) - }), + g => new { max = g.Max(i => i.Customer.Region) }), elementSorter: e => e.max); } @@ -2667,17 +2172,9 @@ public virtual Task GroupBy_anonymous_key_without_aggregate(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.CustomerID, - o.OrderDate - }) + o => new { o.CustomerID, o.OrderDate }) .Select( - g => new - { - g.Key, - g - }), + g => new { g.Key, g }), elementSorter: g => g.Key + " " + g.g.Count()); } @@ -2766,12 +2263,8 @@ public virtual Task Select_GroupBy(bool isAsync) return AssertQuery( isAsync, os => os.Select( - o => new ProjectedType - { - Order = o.OrderID, - Customer = o.CustomerID - }) - .GroupBy(p => p.Customer), + o => new ProjectedType { Order = o.OrderID, Customer = o.CustomerID }) + .GroupBy(p => p.Customer), elementSorter: g => g.Key + " " + g.Count()); } @@ -2782,13 +2275,9 @@ public virtual Task Select_GroupBy_SelectMany(bool isAsync) return AssertQuery( isAsync, os => os.Select( - o => new ProjectedType - { - Order = o.OrderID, - Customer = o.CustomerID - }) - .GroupBy(p => p.Customer) - .SelectMany(g => g), + o => new ProjectedType { Order = o.OrderID, Customer = o.CustomerID }) + .GroupBy(p => p.Customer) + .SelectMany(g => g), elementSorter: g => g.Order); } @@ -2801,12 +2290,9 @@ public virtual Task Join_GroupBy_entity_ToList(bool isAsync) (cs, os) => from c in cs.OrderBy(c => c.CustomerID).Take(5) join o in os.OrderBy(o => o.OrderID).Take(50) on c.CustomerID equals o.CustomerID - group o by c into grp - select new - { - C = grp.Key, - Os = grp.ToList() - }); + group o by c + into grp + select new { C = grp.Key, Os = grp.ToList() }); } #endregion @@ -2820,18 +2306,10 @@ public virtual Task Double_GroupBy_with_aggregate(bool isAsync) return AssertQuery( isAsync, os => os.GroupBy( - o => new - { - o.OrderID, - o.OrderDate - }) + o => new { o.OrderID, o.OrderDate }) .GroupBy(g => g.Key.OrderDate) .Select( - g => new - { - g.Key, - Lastest = g.OrderBy(e => e.Key.OrderID).FirstOrDefault() - })); + g => new { g.Key, Lastest = g.OrderBy(e => e.Key.OrderID).FirstOrDefault() })); } #endregion diff --git a/test/EFCore.Specification.Tests/Query/IncludeAsyncTestBase.cs b/test/EFCore.Specification.Tests/Query/IncludeAsyncTestBase.cs index 134662acf0c..a300dea62f7 100644 --- a/test/EFCore.Specification.Tests/Query/IncludeAsyncTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/IncludeAsyncTestBase.cs @@ -306,11 +306,7 @@ var customers = await (from c in context.Set().Include(c => c.Orders) join o in context.Set() on c.CustomerID equals o.CustomerID into g where c.CustomerID == "ALFKI" - select new - { - c, - g - }) + select new { c, g }) .ToListAsync(); Assert.Equal(1, customers.Count); @@ -330,11 +326,7 @@ var customers join o in context.Set().Include(o => o.OrderDetails) on c.CustomerID equals o.CustomerID into g where c.CustomerID == "ALFKI" - select new - { - c, - g - }) + select new { c, g }) .ToListAsync(); Assert.Equal(1, customers.Count); @@ -525,11 +517,7 @@ from c2 in context.Set() .OrderBy(c => c.CustomerID) .Skip(2) .Take(2) - select new - { - c1, - c2 - }) + select new { c1, c2 }) .ToListAsync(); Assert.Equal(4, customers.Count); @@ -556,11 +544,7 @@ from c2 in context.Set() .OrderBy(c => c.CustomerID) .Skip(2) .Take(2) - select new - { - c1, - c2 - }) + select new { c1, c2 }) .Take(1) .ToListAsync(); @@ -587,11 +571,7 @@ from c2 in context.Set() .OrderBy(c => c.CustomerID) .Skip(2) .Take(2) - select new - { - c1, - c2 - }) + select new { c1, c2 }) .Take(1) .ToListAsync(); @@ -620,11 +600,7 @@ from o2 in context.Set() .ThenBy(o => o.OrderID) .Skip(2) .Take(2) - select new - { - o1, - o2 - }) + select new { o1, o2 }) .ToListAsync(); Assert.Equal(4, orders.Count); @@ -650,11 +626,7 @@ from o2 in context.Set() .OrderBy(o => o.OrderID) .Skip(2) .Take(2) - select new - { - o1, - o2 - }) + select new { o1, o2 }) .ToListAsync(); Assert.Equal(4, orders.Count); @@ -679,11 +651,7 @@ from o2 in context.Set() .Include(o => o.Customer) .Skip(2) .Take(2) - select new - { - o1, - o2 - }) + select new { o1, o2 }) .ToListAsync(); Assert.Equal(4, orders.Count); diff --git a/test/EFCore.Specification.Tests/Query/IncludeOneToOneTestBase.cs b/test/EFCore.Specification.Tests/Query/IncludeOneToOneTestBase.cs index e558c233106..56fb7fb5e98 100644 --- a/test/EFCore.Specification.Tests/Query/IncludeOneToOneTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/IncludeOneToOneTestBase.cs @@ -179,80 +179,26 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con protected override void Seed(PoolableDbContext context) { - var address1 = new Address - { - Street = "3 Dragons Way", - City = "Meereen" - }; - var address2 = new Address - { - Street = "42 Castle Black", - City = "The Wall" - }; - var address3 = new Address - { - Street = "House of Black and White", - City = "Braavos" - }; + var address1 = new Address { Street = "3 Dragons Way", City = "Meereen" }; + var address2 = new Address { Street = "42 Castle Black", City = "The Wall" }; + var address3 = new Address { Street = "House of Black and White", City = "Braavos" }; context.Set().AddRange( - new Person - { - Name = "Daenerys Targaryen", - Address = address1 - }, - new Person - { - Name = "John Snow", - Address = address2 - }, - new Person - { - Name = "Arya Stark", - Address = address3 - }, - new Person - { - Name = "Harry Strickland" - }); + new Person { Name = "Daenerys Targaryen", Address = address1 }, + new Person { Name = "John Snow", Address = address2 }, + new Person { Name = "Arya Stark", Address = address3 }, + new Person { Name = "Harry Strickland" }); context.Set
().AddRange(address1, address2, address3); - var address21 = new Address2 - { - Id = "1", - Street = "3 Dragons Way", - City = "Meereen" - }; - var address22 = new Address2 - { - Id = "2", - Street = "42 Castle Black", - City = "The Wall" - }; - var address23 = new Address2 - { - Id = "3", - Street = "House of Black and White", - City = "Braavos" - }; + var address21 = new Address2 { Id = "1", Street = "3 Dragons Way", City = "Meereen" }; + var address22 = new Address2 { Id = "2", Street = "42 Castle Black", City = "The Wall" }; + var address23 = new Address2 { Id = "3", Street = "House of Black and White", City = "Braavos" }; context.Set().AddRange( - new Person2 - { - Name = "Daenerys Targaryen", - Address = address21 - }, - new Person2 - { - Name = "John Snow", - Address = address22 - }, - new Person2 - { - Name = "Arya Stark", - Address = address23 - }); + new Person2 { Name = "Daenerys Targaryen", Address = address21 }, + new Person2 { Name = "John Snow", Address = address22 }, + new Person2 { Name = "Arya Stark", Address = address23 }); context.Set().AddRange(address21, address22, address23); diff --git a/test/EFCore.Specification.Tests/Query/IncludeTestBase.cs b/test/EFCore.Specification.Tests/Query/IncludeTestBase.cs index 7baa77c21b7..93c0bc32126 100644 --- a/test/EFCore.Specification.Tests/Query/IncludeTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/IncludeTestBase.cs @@ -115,11 +115,7 @@ public virtual void Include_bad_navigation_property_simple() [ConditionalFact(Skip = "issue #15312")] public virtual void Include_property_expression_invalid() { - var anonymousType = new - { - Customer = default(Customer), - OrderDetails = default(ICollection) - }.GetType(); + var anonymousType = new { Customer = default(Customer), OrderDetails = default(ICollection) }.GetType(); var lambdaExpression = Expression.Lambda( Expression.New( anonymousType.GetTypeInfo().DeclaredConstructors.First(), @@ -146,11 +142,7 @@ public virtual void Include_property_expression_invalid() { context.Set() .Include( - o => new - { - o.Customer, - o.OrderDetails - }) + o => new { o.Customer, o.OrderDetails }) // ReSharper disable once ReturnValueOfPureMethodIsNotUsed .ToList(); } @@ -199,11 +191,7 @@ var customer [ConditionalFact(Skip = "issue#15312")] public virtual void Then_include_property_expression_invalid() { - var anonymousType = new - { - Customer = default(Customer), - OrderDetails = default(ICollection) - }.GetType(); + var anonymousType = new { Customer = default(Customer), OrderDetails = default(ICollection) }.GetType(); var lambdaExpression = Expression.Lambda( Expression.New( anonymousType.GetTypeInfo().DeclaredConstructors.First(), @@ -231,11 +219,7 @@ public virtual void Then_include_property_expression_invalid() context.Set() .Include(o => o.Orders) .ThenInclude( - o => new - { - o.Customer, - o.OrderDetails - }) + o => new { o.Customer, o.OrderDetails }) // ReSharper disable once ReturnValueOfPureMethodIsNotUsed .ToList(); } @@ -378,11 +362,13 @@ public virtual void Include_collection_with_last_no_orderby(bool useString) using (var context = CreateContext()) { Assert.Equal( - CoreStrings.TranslationFailed(@"Last(Select( source: DbSet, selector: (c) => IncludeExpression( c, MaterializeCollectionNavigation(Navigation: Customer.Orders (k__BackingField, List) Collection ToDependent Order Inverse: Customer PropertyAccessMode.Field, Where( source: DbSet, predicate: (o) => Property(c, ""CustomerID"") == Property(o, ""CustomerID""))), Orders)))"), - RemoveNewLines(Assert.Throws( - () => useString - ? context.Set().Include("Orders").Last() - : context.Set().Include(c => c.Orders).Last()).Message)); + CoreStrings.TranslationFailed( + @"Last(Select( source: DbSet, selector: (c) => IncludeExpression( c, MaterializeCollectionNavigation(Navigation: Customer.Orders (k__BackingField, List) Collection ToDependent Order Inverse: Customer PropertyAccessMode.Field, Where( source: DbSet, predicate: (o) => Property(c, ""CustomerID"") == Property(o, ""CustomerID""))), Orders)))"), + RemoveNewLines( + Assert.Throws( + () => useString + ? context.Set().Include("Orders").Last() + : context.Set().Include(c => c.Orders).Last()).Message)); } } @@ -875,10 +861,7 @@ var orders .Take(2) .Select( od => - new - { - od.Order.CustomerID - }) + new { od.Order.CustomerID }) .ToList() : context.OrderDetails.Include(od => od.Order) .Where(od => od.Quantity == 10) @@ -888,10 +871,7 @@ var orders .Take(2) .Select( od => - new - { - od.Order.CustomerID - }) + new { od.Order.CustomerID }) .ToList(); Assert.Equal(2, orders.Count); @@ -986,20 +966,12 @@ var customers ? (from c in context.Set().Include("Orders.Customer") join o in context.Set() on c.CustomerID equals o.CustomerID into g where c.CustomerID == "ALFKI" - select new - { - c, - g - }) + select new { c, g }) .ToList() : (from c in context.Set().Include(c => c.Orders).ThenInclude(o => o.Customer) join o in context.Set() on c.CustomerID equals o.CustomerID into g where c.CustomerID == "ALFKI" - select new - { - c, - g - }) + select new { c, g }) .ToList(); Assert.Equal(1, customers.Count); @@ -1032,21 +1004,13 @@ var customers join o in context.Set().Include("OrderDetails").Include("Customer") on c.CustomerID equals o.CustomerID into g where c.CustomerID == "ALFKI" - select new - { - c, - g - }) + select new { c, g }) .ToList() : (from c in context.Set() join o in context.Set().Include(o => o.OrderDetails).Include(o => o.Customer) on c.CustomerID equals o.CustomerID into g where c.CustomerID == "ALFKI" - select new - { - c, - g - }) + select new { c, g }) .ToList(); Assert.Equal(1, customers.Count); @@ -1581,11 +1545,7 @@ from c2 in context.Set() .OrderBy(c => c.CustomerID) .Skip(2) .Take(2) - select new - { - c1, - c2 - }) + select new { c1, c2 }) .ToList() : (from c1 in context.Set() .Include(c => c.Orders) @@ -1596,11 +1556,7 @@ from c2 in context.Set() .OrderBy(c => c.CustomerID) .Skip(2) .Take(2) - select new - { - c1, - c2 - }) + select new { c1, c2 }) .ToList(); Assert.Equal(4, customers.Count); @@ -1650,11 +1606,7 @@ from c2 in context.Set() .OrderBy(c => c.CustomerID) .Skip(2) .Take(2) - select new - { - c1, - c2 - }) + select new { c1, c2 }) .Take(1) .ToList() : (from c1 in context.Set() @@ -1666,11 +1618,7 @@ from c2 in context.Set() .OrderBy(c => c.CustomerID) .Skip(2) .Take(2) - select new - { - c1, - c2 - }) + select new { c1, c2 }) .Take(1) .ToList(); @@ -1720,11 +1668,7 @@ from c2 in context.Set() .OrderBy(c => c.CustomerID) .Skip(2) .Take(2) - select new - { - c1, - c2 - }) + select new { c1, c2 }) .Take(1) .ToList() : (from c1 in context.Set() @@ -1735,11 +1679,7 @@ from c2 in context.Set() .OrderBy(c => c.CustomerID) .Skip(2) .Take(2) - select new - { - c1, - c2 - }) + select new { c1, c2 }) .Take(1) .ToList(); @@ -1791,11 +1731,7 @@ from o2 in context.Set() .ThenBy(o => o.OrderID) .Skip(2) .Take(2) - select new - { - o1, - o2 - }) + select new { o1, o2 }) .ToList() : (from o1 in context.Set() .Include(o => o.Customer) @@ -1808,11 +1744,7 @@ from o2 in context.Set() .ThenBy(o => o.OrderID) .Skip(2) .Take(2) - select new - { - o1, - o2 - }) + select new { o1, o2 }) .ToList(); Assert.Equal(4, orders.Count); @@ -1863,11 +1795,7 @@ from o2 in context.Set() .OrderBy(o => o.OrderID) .Skip(2) .Take(2) - select new - { - o1, - o2 - }) + select new { o1, o2 }) .ToList() : (from o1 in context.Set() .Include(o => o.Customer) @@ -1877,11 +1805,7 @@ from o2 in context.Set() .OrderBy(o => o.OrderID) .Skip(2) .Take(2) - select new - { - o1, - o2 - }) + select new { o1, o2 }) .ToList(); Assert.Equal(4, orders.Count); @@ -1931,11 +1855,7 @@ from o2 in context.Set() .Include("Customer") .Skip(2) .Take(2) - select new - { - o1, - o2 - }) + select new { o1, o2 }) .ToList() : (from o1 in context.Set() .OrderBy(o => o.OrderID) @@ -1945,11 +1865,7 @@ from o2 in context.Set() .Include(o => o.Customer) .Skip(2) .Take(2) - select new - { - o1, - o2 - }) + select new { o1, o2 }) .ToList(); Assert.Equal(4, orders.Count); @@ -2500,20 +2416,12 @@ var orders ? context.Set() .Include("Customer") .Select( - o => new - { - o, - o.CustomerID - }) + o => new { o, o.CustomerID }) .ToList() : context.Set() .Include(o => o.Customer) .Select( - o => new - { - o, - o.CustomerID - }) + o => new { o, o.CustomerID }) .ToList(); Assert.Equal(830, orders.Count); @@ -3074,21 +2982,9 @@ public virtual void Include_with_complex_projection(bool useString) { var query = useString ? from o in context.Orders.Include("Customer") - select new - { - CustomerId = new - { - Id = o.Customer.CustomerID - } - } + select new { CustomerId = new { Id = o.Customer.CustomerID } } : from o in context.Orders.Include(o => o.Customer) - select new - { - CustomerId = new - { - Id = o.Customer.CustomerID - } - }; + select new { CustomerId = new { Id = o.Customer.CustomerID } }; var results = query.ToList(); @@ -3107,19 +3003,11 @@ public virtual void Include_with_complex_projection_does_not_change_ordering_of_ ? from c in context.Customers.Include(nameof(Customer.Orders)) .Where(c => c.ContactTitle == "Owner") .OrderBy(c => c.CustomerID) - select new - { - Id = c.CustomerID, - TotalOrders = c.Orders.Count - } + select new { Id = c.CustomerID, TotalOrders = c.Orders.Count } : from c in context.Customers.Include(c => c.Orders) .Where(c => c.ContactTitle == "Owner") .OrderBy(c => c.CustomerID) - select new - { - Id = c.CustomerID, - TotalOrders = c.Orders.Count - }; + select new { Id = c.CustomerID, TotalOrders = c.Orders.Count }; var result = q.Where(e => e.TotalOrders > 2).ToList(); @@ -3203,13 +3091,13 @@ var orders ? context.Orders .Include("OrderDetails") .OrderBy(o => o.OrderID > 0) - .ThenBy(o => o.Customer != null ? o.Customer.City : String.Empty) + .ThenBy(o => o.Customer != null ? o.Customer.City : string.Empty) .Take(5) .ToList() : context.Orders .Include(c => c.OrderDetails) .OrderBy(o => o.OrderID > 0) - .ThenBy(o => o.Customer != null ? o.Customer.City : String.Empty) + .ThenBy(o => o.Customer != null ? o.Customer.City : string.Empty) .Take(5) .ToList(); @@ -4023,10 +3911,7 @@ public virtual void Include_collection_OrderBy_list_contains(bool useString) { using (var context = CreateContext()) { - var list = new List - { - "ALFKI" - }; + var list = new List { "ALFKI" }; var customers = useString ? context.Customers @@ -4061,10 +3946,7 @@ public virtual void Include_collection_OrderBy_list_does_not_contains(bool useSt { using (var context = CreateContext()) { - var list = new List - { - "ALFKI" - }; + var list = new List { "ALFKI" }; var customers = useString ? context.Customers @@ -4146,11 +4028,7 @@ public virtual async Task Include_with_double_group_by(bool useString, bool asyn ? context.Orders.Include(nameof(Order.OrderDetails)) : context.Orders.Include(e => e.OrderDetails)) .GroupBy( - o => new - { - o.OrderID, - o.OrderDate - }) + o => new { o.OrderID, o.OrderDate }) .GroupBy(g => g.Key.OrderDate); var employee = async @@ -4173,11 +4051,7 @@ public virtual async Task Include_with_double_group_by_no_tracking(bool useStrin ? context.Orders.Include(nameof(Order.OrderDetails)).AsNoTracking() : context.Orders.Include(e => e.OrderDetails)).AsNoTracking() .GroupBy( - o => new - { - o.OrderID, - o.OrderDate - }) + o => new { o.OrderID, o.OrderDate }) .GroupBy(g => g.Key.OrderDate); var employee = async @@ -4200,18 +4074,10 @@ public virtual async Task Include_with_double_group_by_and_aggregate(bool useStr ? context.Orders.Include(nameof(Order.OrderDetails)) : context.Orders.Include(e => e.OrderDetails)) .GroupBy( - o => new - { - o.OrderID, - o.OrderDate - }) + o => new { o.OrderID, o.OrderDate }) .GroupBy(g => g.Key.OrderDate) .Select( - g => new - { - g.Key, - Lastest = g.OrderBy(e => e.Key.OrderID).FirstOrDefault() - }); + g => new { g.Key, Lastest = g.OrderBy(e => e.Key.OrderID).FirstOrDefault() }); var query = async ? await groups.ToListAsync() diff --git a/test/EFCore.Specification.Tests/Query/InheritanceTestBase.cs b/test/EFCore.Specification.Tests/Query/InheritanceTestBase.cs index eb984f26486..e143918ab46 100644 --- a/test/EFCore.Specification.Tests/Query/InheritanceTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/InheritanceTestBase.cs @@ -3,7 +3,6 @@ using System.Linq; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestModels.Inheritance; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -154,10 +153,7 @@ var animals = context.Set() .OfType() .Select( - b => new - { - b.EagleId - }) + b => new { b.EagleId }) .ToList(); Assert.Equal(2, animals.Count); @@ -381,11 +377,7 @@ public virtual void Discriminator_used_when_projection_over_derived_type2() var birds = context.Set() .Select( - b => new - { - b.IsFlightless, - Discriminator = EF.Property(b, "Discriminator") - }) + b => new { b.IsFlightless, Discriminator = EF.Property(b, "Discriminator") }) .ToArray(); Assert.Equal(2, birds.Length); @@ -401,10 +393,7 @@ var predators = context.Set() .Where(b => "Kiwi" == EF.Property(b, "Discriminator")) .Select( - k => new - { - Predator = EF.Property((Bird)k, "EagleId") - }) + k => new { Predator = EF.Property((Bird)k, "EagleId") }) .ToArray(); Assert.Equal(1, predators.Length); @@ -436,10 +425,7 @@ public virtual void Can_insert_update_delete() { var kiwi = new Kiwi { - Species = "Apteryx owenii", - Name = "Little spotted kiwi", - IsFlightless = true, - FoundOn = Island.North + Species = "Apteryx owenii", Name = "Little spotted kiwi", IsFlightless = true, FoundOn = Island.North }; var nz = context.Set().Single(c => c.Id == 1); @@ -505,8 +491,9 @@ public virtual void OfType_Union_subquery() { context.Set() .OfType() - .Union(context.Set() - .OfType()) + .Union( + context.Set() + .OfType()) .Where(o => o.FoundOn == Island.North) .ToList(); } @@ -532,7 +519,7 @@ public virtual void Subquery_OfType() { context.Set() .Take(5) - .Distinct() // Causes pushdown + .Distinct() // Causes pushdown .OfType() .ToList(); } @@ -559,10 +546,7 @@ public virtual void Setting_foreign_key_to_a_different_type_throws() var eagle = new Eagle { - Species = "Haliaeetus leucocephalus", - Name = "Bald eagle", - Group = EagleGroup.Booted, - EagleId = kiwi.Species + Species = "Haliaeetus leucocephalus", Name = "Bald eagle", Group = EagleGroup.Booted, EagleId = kiwi.Species }; context.Add(eagle); diff --git a/test/EFCore.Specification.Tests/Query/NullKeysTestBase.cs b/test/EFCore.Specification.Tests/Query/NullKeysTestBase.cs index 09342e38f4a..9b31211bbf5 100644 --- a/test/EFCore.Specification.Tests/Query/NullKeysTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NullKeysTestBase.cs @@ -269,190 +269,78 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con protected override void Seed(PoolableDbContext context) { context.Add( - new WithStringKey - { - Id = "Stereo" - }); + new WithStringKey { Id = "Stereo" }); context.Add( - new WithStringKey - { - Id = "Fire" - }); + new WithStringKey { Id = "Fire" }); context.Add( - new WithStringKey - { - Id = "Empire" - }); + new WithStringKey { Id = "Empire" }); context.Add( - new WithStringFk - { - Id = "Wendy", - Fk = "Stereo", - SelfFk = "Rodrigue" - }); + new WithStringFk { Id = "Wendy", Fk = "Stereo", SelfFk = "Rodrigue" }); context.Add( - new WithStringFk - { - Id = "And", - SelfFk = "By" - }); + new WithStringFk { Id = "And", SelfFk = "By" }); context.Add( - new WithStringFk - { - Id = "Me", - Fk = "Fire" - }); + new WithStringFk { Id = "Me", Fk = "Fire" }); context.Add( - new WithStringFk - { - Id = "By" - }); + new WithStringFk { Id = "By" }); context.Add( - new WithStringFk - { - Id = "George", - Fk = "Empire" - }); + new WithStringFk { Id = "George", Fk = "Empire" }); context.Add( - new WithStringFk - { - Id = "Rodrigue", - Fk = "Stereo" - }); + new WithStringFk { Id = "Rodrigue", Fk = "Stereo" }); context.Add( - new WithIntKey - { - Id = 1 - }); + new WithIntKey { Id = 1 }); context.Add( - new WithIntKey - { - Id = 2 - }); + new WithIntKey { Id = 2 }); context.Add( - new WithIntKey - { - Id = 3 - }); + new WithIntKey { Id = 3 }); context.Add( - new WithNullableIntFk - { - Id = 1 - }); + new WithNullableIntFk { Id = 1 }); context.Add( - new WithNullableIntFk - { - Id = 2, - Fk = 1 - }); + new WithNullableIntFk { Id = 2, Fk = 1 }); context.Add( - new WithNullableIntFk - { - Id = 3 - }); + new WithNullableIntFk { Id = 3 }); context.Add( - new WithNullableIntFk - { - Id = 4, - Fk = 2 - }); + new WithNullableIntFk { Id = 4, Fk = 2 }); context.Add( - new WithNullableIntFk - { - Id = 5 - }); + new WithNullableIntFk { Id = 5 }); context.Add( - new WithNullableIntFk - { - Id = 6 - }); + new WithNullableIntFk { Id = 6 }); context.Add( - new WithNullableIntKey - { - Id = 1 - }); + new WithNullableIntKey { Id = 1 }); context.Add( - new WithNullableIntKey - { - Id = 2 - }); + new WithNullableIntKey { Id = 2 }); context.Add( - new WithNullableIntKey - { - Id = 3 - }); + new WithNullableIntKey { Id = 3 }); context.Add( - new WithIntFk - { - Id = 1, - Fk = 1 - }); + new WithIntFk { Id = 1, Fk = 1 }); context.Add( - new WithIntFk - { - Id = 2, - Fk = 1 - }); + new WithIntFk { Id = 2, Fk = 1 }); context.Add( - new WithIntFk - { - Id = 3, - Fk = 3 - }); + new WithIntFk { Id = 3, Fk = 3 }); context.Add( - new WithAllNullableIntKey - { - Id = 1 - }); + new WithAllNullableIntKey { Id = 1 }); context.Add( - new WithAllNullableIntKey - { - Id = 2 - }); + new WithAllNullableIntKey { Id = 2 }); context.Add( - new WithAllNullableIntKey - { - Id = 3 - }); + new WithAllNullableIntKey { Id = 3 }); context.Add( - new WithAllNullableIntFk - { - Id = 1 - }); + new WithAllNullableIntFk { Id = 1 }); context.Add( - new WithAllNullableIntFk - { - Id = 2, - Fk = 1 - }); + new WithAllNullableIntFk { Id = 2, Fk = 1 }); context.Add( - new WithAllNullableIntFk - { - Id = 3 - }); + new WithAllNullableIntFk { Id = 3 }); context.Add( - new WithAllNullableIntFk - { - Id = 4, - Fk = 2 - }); + new WithAllNullableIntFk { Id = 4, Fk = 2 }); context.Add( - new WithAllNullableIntFk - { - Id = 5 - }); + new WithAllNullableIntFk { Id = 5 }); context.Add( - new WithAllNullableIntFk - { - Id = 6 - }); + new WithAllNullableIntFk { Id = 6 }); context.SaveChanges(); } diff --git a/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs index 5fec0864d03..be24da3a2e6 100644 --- a/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs @@ -151,10 +151,7 @@ var people .OrderBy(p => p.Id) .Take(5) .Select( - op => new - { - op - }) + op => new { op }) .ToList(); Assert.Equal(4, people.Count); @@ -247,7 +244,8 @@ public virtual void Set_throws_for_owned_type() { using (var ctx = CreateContext()) { - Assert.Equal(CoreStrings.InvalidSetTypeWeak(nameof(OwnedAddress)), + Assert.Equal( + CoreStrings.InvalidSetTypeWeak(nameof(OwnedAddress)), Assert.Throws(() => ctx.Set().ToList()).Message); } } @@ -293,7 +291,12 @@ public virtual void Project_multiple_owned_navigations_with_expansion_on_owned_c { using (var ctx = CreateContext()) { - var query = ctx.Set().Select(p => new { Count = p.Orders.Where(o => o.Client.PersonAddress.Country.Planet.Star.Id != 42).Count(), p.PersonAddress.Country.Planet }); + var query = ctx.Set().Select( + p => new + { + Count = p.Orders.Where(o => o.Client.PersonAddress.Country.Planet.Star.Id != 42).Count(), + p.PersonAddress.Country.Planet + }); var result = query.ToList(); Assert.Equal(4, result.Count); @@ -404,7 +407,8 @@ public virtual void Navigation_rewrite_on_owned_reference_followed_by_regular_en } [ConditionalFact] - public virtual void Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference_in_predicate_and_projection() + public virtual void + Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference_in_predicate_and_projection() { using (var ctx = CreateContext()) { @@ -433,7 +437,6 @@ public virtual void Query_with_OfType_eagerly_loads_correct_owned_navigations() } } - [ConditionalFact] public virtual void Query_loads_reference_nav_automatically_in_projection() { @@ -476,54 +479,23 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb => { eb.HasData( - new OwnedPerson - { - Id = 1 - }); + new OwnedPerson { Id = 1 }); eb.OwnsOne( p => p.PersonAddress, ab => { ab.HasData( - new - { - OwnedPersonId = 1 - }, new - { - OwnedPersonId = 2 - }, new - { - OwnedPersonId = 3 - }, new - { - OwnedPersonId = 4 - }); + new { OwnedPersonId = 1 }, new { OwnedPersonId = 2 }, new { OwnedPersonId = 3 }, + new { OwnedPersonId = 4 }); ab.OwnsOne( a => a.Country, cb => { cb.HasData( - new - { - OwnedAddressOwnedPersonId = 1, - PlanetId = 1, - Name = "USA" - }, new - { - OwnedAddressOwnedPersonId = 2, - PlanetId = 1, - Name = "USA" - }, new - { - OwnedAddressOwnedPersonId = 3, - PlanetId = 1, - Name = "USA" - }, new - { - OwnedAddressOwnedPersonId = 4, - PlanetId = 1, - Name = "USA" - }); + new { OwnedAddressOwnedPersonId = 1, PlanetId = 1, Name = "USA" }, + new { OwnedAddressOwnedPersonId = 2, PlanetId = 1, Name = "USA" }, + new { OwnedAddressOwnedPersonId = 3, PlanetId = 1, Name = "USA" }, + new { OwnedAddressOwnedPersonId = 4, PlanetId = 1, Name = "USA" }); cb.HasOne(cc => cc.Planet).WithMany().HasForeignKey(ee => ee.PlanetId) .OnDelete(DeleteBehavior.Restrict); @@ -534,31 +506,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con p => p.Orders, ob => { ob.HasData( - new - { - Id = -10, - ClientId = 1 - }, - new - { - Id = -11, - ClientId = 1 - }, - new - { - Id = -20, - ClientId = 2 - }, - new - { - Id = -30, - ClientId = 3 - }, - new - { - Id = -40, - ClientId = 4 - } + new { Id = -10, ClientId = 1 }, + new { Id = -11, ClientId = 1 }, + new { Id = -20, ClientId = 2 }, + new { Id = -30, ClientId = 3 }, + new { Id = -40, ClientId = 4 } ); }); }); @@ -567,38 +519,20 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb => { eb.HasData( - new Branch - { - Id = 2 - }); + new Branch { Id = 2 }); eb.OwnsOne( p => p.BranchAddress, ab => { ab.HasData( - new - { - BranchId = 2 - }, new - { - BranchId = 3 - }); + new { BranchId = 2 }, new { BranchId = 3 }); ab.OwnsOne( a => a.Country, cb => { cb.HasData( - new - { - OwnedAddressBranchId = 2, - PlanetId = 1, - Name = "Canada" - }, new - { - OwnedAddressBranchId = 3, - PlanetId = 1, - Name = "Canada" - }); + new { OwnedAddressBranchId = 2, PlanetId = 1, Name = "Canada" }, + new { OwnedAddressBranchId = 3, PlanetId = 1, Name = "Canada" }); }); }); }); @@ -607,19 +541,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb => { eb.HasData( - new LeafA - { - Id = 3 - }); + new LeafA { Id = 3 }); eb.OwnsOne( p => p.LeafAAddress, ab => { ab.HasData( - new - { - LeafAId = 3 - }); + new { LeafAId = 3 }); ab.OwnsOne( a => a.Country, cb => @@ -628,12 +556,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con .OnDelete(DeleteBehavior.Restrict); cb.HasData( - new - { - OwnedAddressLeafAId = 3, - PlanetId = 1, - Name = "Mexico" - }); + new { OwnedAddressLeafAId = 3, PlanetId = 1, Name = "Mexico" }); }); }); }); @@ -642,19 +565,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb => { eb.HasData( - new LeafB - { - Id = 4 - }); + new LeafB { Id = 4 }); eb.OwnsOne( p => p.LeafBAddress, ab => { ab.HasData( - new - { - LeafBId = 4 - }); + new { LeafBId = 4 }); ab.OwnsOne( a => a.Country, cb => @@ -663,12 +580,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con .OnDelete(DeleteBehavior.Restrict); cb.HasData( - new - { - OwnedAddressLeafBId = 4, - PlanetId = 1, - Name = "Panama" - }); + new { OwnedAddressLeafBId = 4, PlanetId = 1, Name = "Panama" }); }); }); }); @@ -696,26 +608,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con { b.OwnsOne( e => e.Throned, b => b.HasData( - new - { - BartonId = 1, - Property = "Property" - })); + new { BartonId = 1, Property = "Property" })); b.HasData( - new Barton - { - Id = 1, - Simple = "Simple" - }); - + new Barton { Id = 1, Simple = "Simple" }); }); modelBuilder.Entity().HasData( - new - { - Id = 1, - BartonId = 1 - }); + new { Id = 1, BartonId = 1 }); } public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) diff --git a/test/EFCore.Specification.Tests/Query/QueryFilterFuncletizationTestBase.cs b/test/EFCore.Specification.Tests/Query/QueryFilterFuncletizationTestBase.cs index 72414b0be72..bd94ce44a1f 100644 --- a/test/EFCore.Specification.Tests/Query/QueryFilterFuncletizationTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/QueryFilterFuncletizationTestBase.cs @@ -83,18 +83,11 @@ public virtual void DbContext_list_is_parameterized() var query = context.Set().ToList(); Assert.Empty(query); - context.TenantIds = new List - { - 1 - }; + context.TenantIds = new List { 1 }; query = context.Set().ToList(); Assert.Single(query); - context.TenantIds = new List - { - 2, - 3 - }; + context.TenantIds = new List { 2, 3 }; query = context.Set().ToList(); Assert.Equal(2, query.Count); } @@ -108,17 +101,11 @@ public virtual void DbContext_property_chain_is_parameterized() // This throws because IndirectionFlag is null Assert.Throws(() => context.Set().ToList()); - context.IndirectionFlag = new Indirection - { - Enabled = false - }; + context.IndirectionFlag = new Indirection { Enabled = false }; var entity = Assert.Single(context.Set().ToList()); Assert.False(entity.IsEnabled); - context.IndirectionFlag = new Indirection - { - Enabled = true - }; + context.IndirectionFlag = new Indirection { Enabled = true }; entity = Assert.Single(context.Set().ToList()); Assert.True(entity.IsEnabled); } @@ -231,17 +218,11 @@ public virtual void EntityTypeConfiguration_DbContext_property_chain_is_paramete // This throws because IndirectionFlag is null Assert.Throws(() => context.Set().ToList()); - context.IndirectionFlag = new Indirection - { - Enabled = false - }; + context.IndirectionFlag = new Indirection { Enabled = false }; var entity = Assert.Single(context.Set().ToList()); Assert.False(entity.IsEnabled); - context.IndirectionFlag = new Indirection - { - Enabled = true - }; + context.IndirectionFlag = new Indirection { Enabled = true }; entity = Assert.Single(context.Set().ToList()); Assert.True(entity.IsEnabled); } @@ -314,17 +295,11 @@ public virtual void Extension_method_DbContext_property_chain_is_parameterized() // This throws because IndirectionFlag is null Assert.Throws(() => context.Set().ToList()); - context.IndirectionFlag = new Indirection - { - Enabled = false - }; + context.IndirectionFlag = new Indirection { Enabled = false }; var entity = Assert.Single(context.Set().ToList()); Assert.False(entity.IsEnabled); - context.IndirectionFlag = new Indirection - { - Enabled = true - }; + context.IndirectionFlag = new Indirection { Enabled = true }; entity = Assert.Single(context.Set().ToList()); Assert.True(entity.IsEnabled); } diff --git a/test/EFCore.Specification.Tests/Query/QueryNavigationsTestBase.cs b/test/EFCore.Specification.Tests/Query/QueryNavigationsTestBase.cs index aa267139027..d1ed586b38b 100644 --- a/test/EFCore.Specification.Tests/Query/QueryNavigationsTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/QueryNavigationsTestBase.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable UnusedVariable @@ -114,14 +113,15 @@ public virtual async Task Join_with_nav_in_orderby_in_subquery_when_client_eval( { Assert.Equal( CoreStrings.TranslationFailed("(o) => ClientOrderBy( t: o.Outer, _: o.Inner)"), - RemoveNewLines((await Assert.ThrowsAsync( - () => AssertQuery( - isAsync, - (cs, os, ods) => (from c in cs - join o in os.OrderBy(o => ClientOrderBy(o, o.Customer)) on c.CustomerID equals o.CustomerID - join od in ods.OrderBy(od => ClientOrderBy(od, od.Product)) on o.OrderID equals od.OrderID - select c), - entryCount: 89))).Message)); + RemoveNewLines( + (await Assert.ThrowsAsync( + () => AssertQuery( + isAsync, + (cs, os, ods) => (from c in cs + join o in os.OrderBy(o => ClientOrderBy(o, o.Customer)) on c.CustomerID equals o.CustomerID + join od in ods.OrderBy(od => ClientOrderBy(od, od.Product)) on o.OrderID equals od.OrderID + select c), + entryCount: 89))).Message)); } private string RemoveNewLines(string message) @@ -194,10 +194,7 @@ public virtual Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar(bool os => from o1 in os.Where(o => o.OrderID < 10300) from o2 in os.Where(o => o.OrderID < 10400) where o1.Customer.City == o2.Customer.City - select new - { - o1, o2 - }, + select new { o1, o2 }, elementSorter: e => e.o1.OrderID + " " + e.o2.OrderID, elementAsserter: (e, a) => Assert.Equal(e.o1.OrderID, a.o1.OrderID), entryCount: 107); @@ -212,11 +209,7 @@ public virtual Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Proj os => from o1 in os.Where(o => o.OrderID < 10300) from o2 in os.Where(o => o.OrderID < 10400) where o1.Customer.City == o2.Customer.City - select new - { - o1.CustomerID, - C2 = o2.CustomerID - }, + select new { o1.CustomerID, C2 = o2.CustomerID }, elementSorter: e => e.CustomerID + " " + e.C2); } @@ -288,11 +281,7 @@ public virtual Task Select_collection_FirstOrDefault_project_anonymous_type(bool isAsync, cs => cs.OrderBy(c => c.CustomerID).Take(2).Select( c => c.Orders.OrderBy(o => o.OrderID).Select( - o => new - { - o.CustomerID, - o.OrderID - }).FirstOrDefault()), + o => new { o.CustomerID, o.OrderID }).FirstOrDefault()), assertOrder: true); } @@ -369,11 +358,7 @@ from o2 in os where o1.CustomerID.StartsWith("A") where o2.CustomerID.StartsWith("A") where o1.Customer == o2.Customer - select new - { - o1, - o2 - }, + select new { o1, o2 }, elementSorter: e => e.o1.OrderID + " " + e.o2.OrderID, entryCount: 30); } @@ -387,10 +372,7 @@ public virtual Task Select_Where_Navigation_Included(bool isAsync) os => from o in os.Include(o => o.Customer) where o.Customer.City == "Seattle" select o, - new List - { - new ExpectedInclude(o => o.Customer, "Customer") - }, + new List { new ExpectedInclude(o => o.Customer, "Customer") }, entryCount: 15); } @@ -420,10 +402,7 @@ public virtual Task Select_count_plus_sum(bool isAsync) return AssertQuery( isAsync, os => os.Select( - o => new - { - Total = o.OrderDetails.Sum(od => od.Quantity) + o.OrderDetails.Count() - }), + o => new { Total = o.OrderDetails.Sum(od => od.Quantity) + o.OrderDetails.Count() }), elementSorter: e => e.Total); } @@ -436,10 +415,7 @@ public virtual Task Singleton_Navigation_With_Member_Access(bool isAsync) os => from o in os where o.Customer.City == "Seattle" where o.Customer.Phone != "555 555 5555" - select new - { - B = o.Customer.City - }, + select new { B = o.Customer.City }, elementSorter: e => e.B); } @@ -452,11 +428,7 @@ public virtual Task Select_Singleton_Navigation_With_Member_Access(bool isAsync) os => from o in os where o.Customer.City == "Seattle" where o.Customer.Phone != "555 555 5555" - select new - { - A = o.Customer, - B = o.Customer.City - }, + select new { A = o.Customer, B = o.Customer.City }, elementSorter: e => e.A + " " + e.B, entryCount: 1); } @@ -470,11 +442,7 @@ var orders = await (from o in context.Set() where o.Customer.City == "Seattle" where o.Customer.Phone != "555 555 5555" - select new - { - A = o.Customer, - B = o.Customer.City - }).ToListAsync(); + select new { A = o.Customer, B = o.Customer.City }).ToListAsync(); Assert.Equal(14, orders.Count); Assert.True(orders.All(o => (o.A != null) && (o.B != null))); @@ -512,11 +480,7 @@ public virtual Task Select_Navigations(bool isAsync) return AssertQuery( isAsync, os => from o in os - select new - { - A = o.Customer, - B = o.Customer - }, + select new { A = o.Customer, B = o.Customer }, elementSorter: e => e.A.CustomerID, elementAsserter: (e, a) => { @@ -535,11 +499,7 @@ public virtual Task Select_Navigations_Where_Navigations(bool isAsync) os => from o in os where o.Customer.City == "Seattle" where o.Customer.Phone != "555 555 5555" - select new - { - A = o.Customer, - B = o.Customer - }, + select new { A = o.Customer, B = o.Customer }, elementSorter: e => e.A.CustomerID, elementAsserter: (e, a) => { @@ -558,11 +518,7 @@ public virtual Task Select_collection_navigation_simple(bool isAsync) cs => from c in cs where c.CustomerID.StartsWith("A") orderby c.CustomerID - select new - { - c.CustomerID, - c.Orders - }, + select new { c.CustomerID, c.Orders }, elementSorter: e => e.CustomerID, elementAsserter: (e, a) => { @@ -581,11 +537,7 @@ public virtual Task Select_collection_navigation_simple2(bool isAsync) cs => from c in cs where c.CustomerID.StartsWith("A") orderby c.CustomerID - select new - { - c.CustomerID, - c.Orders.Count - }, + select new { c.CustomerID, c.Orders.Count }, elementSorter: e => e.CustomerID, elementAsserter: (e, a) => { @@ -603,11 +555,7 @@ public virtual Task Select_collection_navigation_simple_followed_by_ordering_by_ cs => (from c in cs where c.CustomerID.StartsWith("A") orderby c.CustomerID - select new - { - c.CustomerID, - c.Orders - }).OrderBy(e => e.CustomerID), + select new { c.CustomerID, c.Orders }).OrderBy(e => e.CustomerID), elementAsserter: (e, a) => { Assert.Equal(e.CustomerID, a.CustomerID); @@ -625,11 +573,7 @@ public virtual Task Select_collection_navigation_multi_part(bool isAsync) isAsync, os => from o in os where o.CustomerID == "ALFKI" - select new - { - o.OrderID, - o.Customer.Orders - }, + select new { o.OrderID, o.Customer.Orders }, elementSorter: e => e.OrderID, elementAsserter: (e, a) => { @@ -649,10 +593,7 @@ public virtual Task Select_collection_navigation_multi_part2(bool isAsync) from od in ods orderby od.OrderID, od.ProductID where od.Order.CustomerID == "ALFKI" || od.Order.CustomerID == "ANTON" - select new - { - od.Order.Customer.Orders - }, + select new { od.Order.Customer.Orders }, assertOrder: true, elementAsserter: (e, a) => CollectionAsserter(ee => ee.OrderID, (ee, aa) => Assert.Equal(ee.OrderID, aa.OrderID)), entryCount: 13); @@ -665,15 +606,9 @@ public virtual Task Collection_select_nav_prop_any(bool isAsync) return AssertQuery( isAsync, cs => from c in cs - select new - { - Any = c.Orders.Any() - }, + select new { Any = c.Orders.Any() }, cs => from c in cs - select new - { - Any = (c.Orders ?? new List()).Any() - }, + select new { Any = (c.Orders ?? new List()).Any() }, elementSorter: e => e.Any); } @@ -724,15 +659,9 @@ public virtual Task Collection_select_nav_prop_all(bool isAsync) return AssertQuery( isAsync, cs => from c in cs - select new - { - All = c.Orders.All(o => o.CustomerID == "ALFKI") - }, + select new { All = c.Orders.All(o => o.CustomerID == "ALFKI") }, cs => from c in cs - select new - { - All = (c.Orders ?? new List()).All(o => o.CustomerID == "ALFKI") - }, + select new { All = (c.Orders ?? new List()).All(o => o.CustomerID == "ALFKI") }, elementSorter: e => e.All); } @@ -747,16 +676,10 @@ public virtual async Task Collection_select_nav_prop_all_client(bool isAsync) isAsync, cs => from c in cs orderby c.CustomerID - select new - { - All = c.Orders.All(o => o.ShipCity == "London") - }, + select new { All = c.Orders.All(o => o.ShipCity == "London") }, cs => from c in cs orderby c.CustomerID - select new - { - All = (c.Orders ?? new List()).All(o => false) - }, + select new { All = (c.Orders ?? new List()).All(o => false) }, assertOrder: true))).Message); } @@ -799,15 +722,9 @@ public virtual Task Collection_select_nav_prop_count(bool isAsync) return AssertQuery( isAsync, cs => from c in cs - select new - { - c.Orders.Count - }, + select new { c.Orders.Count }, cs => from c in cs - select new - { - (c.Orders ?? new List()).Count - }, + select new { (c.Orders ?? new List()).Count }, elementSorter: e => e.Count); } @@ -864,15 +781,9 @@ public virtual Task Collection_select_nav_prop_long_count(bool isAsync) return AssertQuery( isAsync, cs => from c in cs - select new - { - C = c.Orders.LongCount() - }, + select new { C = c.Orders.LongCount() }, cs => from c in cs - select new - { - C = (c.Orders ?? new List()).LongCount() - }, + select new { C = (c.Orders ?? new List()).LongCount() }, elementSorter: e => e.C); } @@ -904,15 +815,9 @@ public virtual Task Collection_select_nav_prop_sum(bool isAsync) return AssertQuery( isAsync, cs => from c in cs - select new - { - Sum = c.Orders.Sum(o => o.OrderID) - }, + select new { Sum = c.Orders.Sum(o => o.OrderID) }, cs => from c in cs - select new - { - Sum = (c.Orders ?? new List()).Sum(o => o.OrderID) - }, + select new { Sum = (c.Orders ?? new List()).Sum(o => o.OrderID) }, elementSorter: e => e.Sum); } @@ -924,15 +829,9 @@ public virtual Task Collection_select_nav_prop_sum_plus_one(bool isAsync) return AssertQuery( isAsync, cs => from c in cs - select new - { - Sum = c.Orders.Sum(o => o.OrderID) + 1 - }, + select new { Sum = c.Orders.Sum(o => o.OrderID) + 1 }, cs => from c in cs - select new - { - Sum = (c.Orders ?? new List()).Sum(o => o.OrderID) + 1 - }, + select new { Sum = (c.Orders ?? new List()).Sum(o => o.OrderID) + 1 }, elementSorter: e => e.Sum); } @@ -973,16 +872,10 @@ public virtual Task Collection_select_nav_prop_first_or_default(bool isAsync) isAsync, cs => from c in cs orderby c.CustomerID - select new - { - First = c.Orders.OrderBy(o => o.OrderID).FirstOrDefault() - }, + select new { First = c.Orders.OrderBy(o => o.OrderID).FirstOrDefault() }, cs => from c in cs orderby c.CustomerID - select new - { - First = (c.Orders ?? new List()).FirstOrDefault() - }, + select new { First = (c.Orders ?? new List()).FirstOrDefault() }, assertOrder: true, entryCount: 89); } @@ -997,10 +890,7 @@ public virtual Task Collection_select_nav_prop_first_or_default_then_nav_prop(bo isAsync, cs => from c in cs.Where(e => e.CustomerID.StartsWith("A")) orderby c.CustomerID - select new - { - c.Orders.Where(e => orderIds.Contains(e.OrderID)).FirstOrDefault().Customer - }, + select new { c.Orders.Where(e => orderIds.Contains(e.OrderID)).FirstOrDefault().Customer }, cs => from c in cs.Where(e => e.CustomerID.StartsWith("A")) orderby c.CustomerID select new @@ -1307,17 +1197,9 @@ public virtual Task Project_single_scalar_value_subquery_is_properly_inlined(boo return AssertQuery( isAsync, cs => from c in cs - select new - { - c.CustomerID, - OrderId = c.Orders.OrderBy(o => o.OrderID).Select(o => (int?)o.OrderID).FirstOrDefault() - }, + select new { c.CustomerID, OrderId = c.Orders.OrderBy(o => o.OrderID).Select(o => (int?)o.OrderID).FirstOrDefault() }, cs => from c in cs - select new - { - c.CustomerID, - OrderId = c.Orders.OrderBy(o => o.OrderID).Select(o => (int?)o.OrderID).FirstOrDefault() - }, + select new { c.CustomerID, OrderId = c.Orders.OrderBy(o => o.OrderID).Select(o => (int?)o.OrderID).FirstOrDefault() }, elementSorter: e => e.CustomerID); } @@ -1330,11 +1212,7 @@ public virtual Task Project_single_entity_value_subquery_works(bool isAsync) cs => from c in cs where c.CustomerID.StartsWith("A") orderby c.CustomerID - select new - { - c.CustomerID, - Order = c.Orders.OrderBy(o => o.OrderID).FirstOrDefault() - }, + select new { c.CustomerID, Order = c.Orders.OrderBy(o => o.OrderID).FirstOrDefault() }, elementSorter: e => e.CustomerID, entryCount: 4); } @@ -1431,11 +1309,7 @@ public virtual Task Navigation_projection_on_groupjoin_qsre(bool isAsync) (cs, os) => from c in cs join o in os on c.CustomerID equals o.CustomerID into grouping where c.CustomerID == "ALFKI" - select new - { - c, - G = grouping.Select(o => o.OrderDetails).ToList() - }, + select new { c, G = grouping.Select(o => o.OrderDetails).ToList() }, elementSorter: e => e.c.CustomerID, elementAsserter: (e, a) => { @@ -1483,11 +1357,7 @@ public virtual Task Navigation_projection_on_groupjoin_qsre_with_empty_grouping( (cs, os) => from c in cs join o in os.Where(oo => !anatrsOrders.Contains(oo.OrderID)) on c.CustomerID equals o.CustomerID into grouping where c.CustomerID.StartsWith("A") - select new - { - c, - G = grouping.Select(o => o.OrderDetails).ToList() - }, + select new { c, G = grouping.Select(o => o.OrderDetails).ToList() }, elementSorter: e => e.c.CustomerID, elementAsserter: (e, a) => { @@ -1553,10 +1423,7 @@ public virtual Task Group_join_doesnt_get_bound_directly_to_group_join_qsre(bool (cs, os) => from c in cs join o in os on c.CustomerID equals o.CustomerID into grouping where c.CustomerID.StartsWith("A") - select new - { - G = grouping.Count() - }, + select new { G = grouping.Count() }, elementSorter: e => e.G); } diff --git a/test/EFCore.Specification.Tests/Query/QueryTaggingTestBase.cs b/test/EFCore.Specification.Tests/Query/QueryTaggingTestBase.cs index 26e0354c38f..89c82791937 100644 --- a/test/EFCore.Specification.Tests/Query/QueryTaggingTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/QueryTaggingTestBase.cs @@ -4,7 +4,6 @@ using System.Linq; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable InconsistentNaming diff --git a/test/EFCore.Specification.Tests/Query/QueryTestBase.cs b/test/EFCore.Specification.Tests/Query/QueryTestBase.cs index bd06baa0601..9068e708efd 100644 --- a/test/EFCore.Specification.Tests/Query/QueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/QueryTestBase.cs @@ -19,11 +19,7 @@ public abstract class QueryTestBase : IClassFixture protected TFixture Fixture { get; } - public static IEnumerable IsAsyncData = new[] - { - new object[] { false }, - new object[] { true } - }; + public static IEnumerable IsAsyncData = new[] { new object[] { false }, new object[] { true } }; #region AssertAny @@ -1621,8 +1617,7 @@ protected static IEnumerable MaybeDefaultIfEmpty(IEnumerable - { default } + ? new List { default } : caller.DefaultIfEmpty(); } diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Functions.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Functions.cs index 94a5e09411e..b40ee2185f8 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Functions.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Functions.cs @@ -7,7 +7,6 @@ using System.Linq.Expressions; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable InconsistentNaming @@ -782,10 +781,7 @@ public virtual Task Select_math_round_int(bool isAsync) return AssertQuery( isAsync, os => os.Where(o => o.OrderID < 10250).Select( - o => new - { - A = Math.Round((double)o.OrderID) - }), + o => new { A = Math.Round((double)o.OrderID) }), e => e.A); } @@ -796,10 +792,7 @@ public virtual Task Select_math_truncate_int(bool isAsync) return AssertQuery( isAsync, os => os.Where(o => o.OrderID < 10250).Select( - o => new - { - A = Math.Truncate((double)o.OrderID) - }), + o => new { A = Math.Truncate((double)o.OrderID) }), e => e.A); } @@ -1280,11 +1273,7 @@ public virtual void IsNullOrEmpty_in_projection() { var query = context.Set() .Select( - c => new - { - Id = c.CustomerID, - Value = string.IsNullOrEmpty(c.Region) - }) + c => new { Id = c.CustomerID, Value = string.IsNullOrEmpty(c.Region) }) .ToList(); Assert.Equal(91, query.Count); @@ -1298,11 +1287,7 @@ public virtual void IsNullOrEmpty_negated_in_projection() { var query = context.Set() .Select( - c => new - { - Id = c.CustomerID, - Value = !string.IsNullOrEmpty(c.Region) - }) + c => new { Id = c.CustomerID, Value = !string.IsNullOrEmpty(c.Region) }) .ToList(); Assert.Equal(91, query.Count); diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.JoinGroupJoin.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.JoinGroupJoin.cs index 8701b6dcb78..b87482aace2 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.JoinGroupJoin.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.JoinGroupJoin.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable InconsistentNaming @@ -22,11 +21,7 @@ public virtual Task Join_customers_orders_projection(bool isAsync) (cs, os) => from c in cs join o in os on c.CustomerID equals o.CustomerID - select new - { - c.ContactName, - o.OrderID - }, + select new { c.ContactName, o.OrderID }, e => e.OrderID); } @@ -39,11 +34,7 @@ public virtual Task Join_customers_orders_entities(bool isAsync) (cs, os) => from c in cs join o in os on c.CustomerID equals o.CustomerID - select new - { - c, - o - }, + select new { c, o }, e => e.c.CustomerID + " " + e.o.OrderID, entryCount: 919); } @@ -57,11 +48,7 @@ public virtual Task Join_customers_orders_entities_same_entity_twice(bool isAsyn (cs, os) => from c in cs join o in os on c.CustomerID equals o.CustomerID - select new - { - A = c, - B = c - }, + select new { A = c, B = c }, e => e.A.CustomerID + " " + e.B.CustomerID, entryCount: 89); } @@ -76,12 +63,7 @@ public virtual Task Join_select_many(bool isAsync) from c in cs join o in os on c.CustomerID equals o.CustomerID from e in es - select new - { - c, - o, - e - }, + select new { c, o, e }, e => e.c.CustomerID + " " + e.o.OrderID + " " + e.e.EmployeeID, entryCount: 928); } @@ -96,12 +78,7 @@ public virtual Task Client_Join_select_many(bool isAsync) from e1 in es.OrderBy(e => e.EmployeeID).Take(2) join e2 in es.OrderBy(e => e.EmployeeID).Take(2) on e1.EmployeeID equals GetEmployeeID(e2) from e3 in es.OrderBy(e => e.EmployeeID).Skip(6).Take(2) - select new - { - e1, - e2, - e3 - }, + select new { e1, e2, e3 }, e => e.e1.EmployeeID + " " + e.e2.EmployeeID + " " + e.e3.EmployeeID, entryCount: 4); } @@ -120,11 +97,7 @@ public virtual Task Join_customers_orders_select(bool isAsync) (cs, os) => from c in cs join o in os on c.CustomerID equals o.CustomerID - select new - { - c.ContactName, - o.OrderID - } + select new { c.ContactName, o.OrderID } into p select p, e => e.OrderID); @@ -141,11 +114,7 @@ from c in cs join o1 in (from o2 in os orderby o2.OrderID select o2) on c.CustomerID equals o1.CustomerID where o1.CustomerID == "ALFKI" - select new - { - c.ContactName, - o1.OrderID - }, + select new { c.ContactName, o1.OrderID }, e => e.OrderID); } @@ -160,11 +129,7 @@ from c in cs join o1 in (from o2 in os orderby o2.OrderID select o2).Take(5) on c.CustomerID equals o1.CustomerID where o1.CustomerID == "ALFKI" - select new - { - c.ContactName, - o1.OrderID - }, + select new { c.ContactName, o1.OrderID }, e => e.OrderID); } @@ -179,17 +144,9 @@ from c in cs join o1 in (from o2 in os orderby o2.OrderID - select new - { - o2 - }) on c.CustomerID equals o1.o2.CustomerID + select new { o2 }) on c.CustomerID equals o1.o2.CustomerID where EF.Property(o1.o2, "CustomerID") == "ALFKI" - select new - { - o1, - o1.o2, - Shadow = EF.Property(o1.o2, "OrderDate") - }, + select new { o1, o1.o2, Shadow = EF.Property(o1.o2, "OrderDate") }, e => e.o1.o2.OrderID, entryCount: 6); } @@ -205,17 +162,9 @@ from c in cs join o1 in (from o2 in os orderby o2.OrderID - select new - { - o2 - }).Take(5) on c.CustomerID equals o1.o2.CustomerID + select new { o2 }).Take(5) on c.CustomerID equals o1.o2.CustomerID where EF.Property(o1.o2, "CustomerID") == "ALFKI" - select new - { - o1, - o1.o2, - Shadow = EF.Property(o1.o2, "OrderDate") - }, + select new { o1, o1.o2, Shadow = EF.Property(o1.o2, "OrderDate") }, e => e.o1.o2.OrderID); } @@ -230,11 +179,7 @@ from c in cs join o1 in (from o2 in os where o2.OrderID > 0 orderby o2.OrderID select o2) on c.CustomerID equals o1.CustomerID where o1.CustomerID == "ALFKI" - select new - { - c.ContactName, - o1.OrderID - }, + select new { c.ContactName, o1.OrderID }, e => e.OrderID); } @@ -249,11 +194,7 @@ from c in cs join o1 in (from o2 in os where o2.OrderID > 0 orderby o2.OrderID select o2).Take(5) on c.CustomerID equals o1.CustomerID where o1.CustomerID == "ALFKI" - select new - { - c.ContactName, - o1.OrderID - }, + select new { c.ContactName, o1.OrderID }, e => e.OrderID); } @@ -265,21 +206,9 @@ public virtual Task Join_composite_key(bool isAsync) isAsync, (cs, os) => from c in cs - join o in os on new - { - a = c.CustomerID, - b = c.CustomerID - } - equals new - { - a = o.CustomerID, - b = o.CustomerID - } - select new - { - c, - o - }, + join o in os on new { a = c.CustomerID, b = c.CustomerID } + equals new { a = o.CustomerID, b = o.CustomerID } + select new { c, o }, e => e.o.OrderID, entryCount: 919); } @@ -304,18 +233,8 @@ public virtual Task Join_client_new_expression(bool isAsync) isAsync, (cs, os) => from c in cs - join o in os on new Foo - { - Bar = c.CustomerID - } equals new Foo - { - Bar = o.CustomerID - } - select new - { - c, - o - }, + join o in os on new Foo { Bar = c.CustomerID } equals new Foo { Bar = o.CustomerID } + select new { c, o }, e => e.c.CustomerID); } @@ -396,11 +315,8 @@ public virtual Task Join_same_collection_multiple(bool isAsync) isAsync, (cs1, cs2, cs3) => cs1.Join( - cs2, o => o.CustomerID, i => i.CustomerID, (c1, c2) => new - { - c1, - c2 - }).Join(cs3, o => o.c1.CustomerID, i => i.CustomerID, (c12, c3) => c3), + cs2, o => o.CustomerID, i => i.CustomerID, (c1, c2) => new { c1, c2 }).Join( + cs3, o => o.c1.CustomerID, i => i.CustomerID, (c12, c3) => c3), entryCount: 91); } @@ -412,11 +328,7 @@ public virtual Task Join_same_collection_force_alias_uniquefication(bool isAsync isAsync, (os1, os2) => os1.Join( - os2, o => o.CustomerID, i => i.CustomerID, (_, o) => new - { - _, - o - }), + os2, o => o.CustomerID, i => i.CustomerID, (_, o) => new { _, o }), e => e._.OrderID + " " + e.o.OrderID, entryCount: 830); } @@ -430,11 +342,7 @@ public virtual Task GroupJoin_customers_orders(bool isAsync) (cs, os) => from c in cs join o in os.OrderBy(o => o.OrderID) on c.CustomerID equals o.CustomerID into orders - select new - { - customer = c, - orders = orders.ToList() - }, + select new { customer = c, orders = orders.ToList() }, e => e.customer.CustomerID, elementAsserter: (e, a) => { @@ -453,11 +361,7 @@ public virtual Task GroupJoin_customers_orders_count(bool isAsync) (cs, os) => from c in cs join o in os on c.CustomerID equals o.CustomerID into orders - select new - { - cust = c, - ords = orders.Count() - }, + select new { cust = c, ords = orders.Count() }, e => e.cust.CustomerID, entryCount: 91); } @@ -471,11 +375,7 @@ public virtual Task GroupJoin_customers_orders_count_preserves_ordering(bool isA (cs, os) => from c in cs.Where(c => c.CustomerID != "VAFFE" && c.CustomerID != "DRACD").OrderBy(c => c.City).Take(5) join o in os on c.CustomerID equals o.CustomerID into orders - select new - { - cust = c, - ords = orders.Count() - }, + select new { cust = c, ords = orders.Count() }, assertOrder: true, entryCount: 5); } @@ -493,11 +393,7 @@ join e in es on c.City equals e.City into employees .SelectMany(emps => emps) .Select( e => - new - { - Title = EF.Property(e, "Title"), - Id = e.EmployeeID - }), + new { Title = EF.Property(e, "Title"), Id = e.EmployeeID }), e => e.Id); } @@ -514,11 +410,7 @@ join e in es.OrderBy(e => e.City) on c.City equals e.City into employees .SelectMany(emps => emps) .Select( e => - new - { - Title = EF.Property(e, "Title"), - Id = e.EmployeeID - }), + new { Title = EF.Property(e, "Title"), Id = e.EmployeeID }), e => e.Id); } @@ -535,11 +427,7 @@ join e in es.OrderBy(e => e.City).Take(5) on c.City equals e.City into employees .SelectMany(emps => emps) .Select( e => - new - { - Title = EF.Property(e, "Title"), - Id = e.EmployeeID - }), + new { Title = EF.Property(e, "Title"), Id = e.EmployeeID }), e => e.Id); } @@ -581,10 +469,7 @@ public virtual Task GroupJoin_simple3(bool isAsync) from c in cs join o in os on c.CustomerID equals o.CustomerID into orders from o in orders - select new - { - o.OrderID - }, + select new { o.OrderID }, e => e.OrderID); } @@ -612,11 +497,7 @@ public virtual Task GroupJoin_tracking_groups2(bool isAsync) (cs, os) => from c in cs join o in os on c.CustomerID equals o.CustomerID into orders - select new - { - c, - orders - }, + select new { c, orders }, elementSorter: e => e.c.CustomerID, elementAsserter: (e, a) => { @@ -664,11 +545,7 @@ public virtual Task GroupJoin_projection(bool isAsync) from c in cs join o in os on c.CustomerID equals o.CustomerID into orders from o in orders - select new - { - c, - o - }, + select new { c, o }, e => e.c.CustomerID + " " + e.o.OrderID, entryCount: 919); } @@ -680,11 +557,7 @@ public virtual Task GroupJoin_outer_projection(bool isAsync) return AssertQuery( isAsync, (cs, os) => cs.GroupJoin( - os, c => c.CustomerID, o => o.CustomerID, (c, o) => new - { - c.City, - o - }), + os, c => c.CustomerID, o => o.CustomerID, (c, o) => new { c.City, o }), e => e.City + " " + CollectionSorter()(e.o), elementAsserter: (e, a) => { @@ -701,11 +574,7 @@ public virtual Task GroupJoin_outer_projection2(bool isAsync) return AssertQuery( isAsync, (cs, os) => cs.GroupJoin( - os, c => c.CustomerID, o => o.CustomerID, (c, g) => new - { - c.City, - g = g.Select(o => o.CustomerID) - }), + os, c => c.CustomerID, o => o.CustomerID, (c, g) => new { c.City, g = g.Select(o => o.CustomerID) }), e => e.City + " " + CollectionSorter()(e.g), elementAsserter: (e, a) => { @@ -721,10 +590,7 @@ public virtual Task GroupJoin_outer_projection3(bool isAsync) return AssertQuery( isAsync, (cs, os) => cs.GroupJoin( - os, c => c.CustomerID, o => o.CustomerID, (c, g) => new - { - g = g.Select(o => o.CustomerID) - }), + os, c => c.CustomerID, o => o.CustomerID, (c, g) => new { g = g.Select(o => o.CustomerID) }), e => CollectionSorter()(e.g), elementAsserter: (e, a) => CollectionAsserter(s => s)(e.g, a.g)); } @@ -747,11 +613,7 @@ public virtual Task GroupJoin_outer_projection_reverse(bool isAsync) return AssertQuery( isAsync, (cs, os) => os.GroupJoin( - cs, o => o.CustomerID, c => c.CustomerID, (o, c) => new - { - o.CustomerID, - c - }), + cs, o => o.CustomerID, c => c.CustomerID, (o, c) => new { o.CustomerID, c }), e => e.CustomerID, elementAsserter: (e, a) => { @@ -768,11 +630,7 @@ public virtual Task GroupJoin_outer_projection_reverse2(bool isAsync) return AssertQuery( isAsync, (cs, os) => os.GroupJoin( - cs, o => o.CustomerID, c => c.CustomerID, (o, g) => new - { - o.CustomerID, - g = g.Select(c => c.City) - }), + cs, o => o.CustomerID, c => c.CustomerID, (o, g) => new { o.CustomerID, g = g.Select(c => c.City) }), elementSorter: e => e.CustomerID, elementAsserter: (e, a) => { @@ -792,12 +650,7 @@ from c in cs from o0 in os.OrderBy(o => o.OrderID).Take(1) join o1 in os on c.CustomerID equals o1.CustomerID into orders from o2 in orders - select new - { - A = c.CustomerID, - B = o0.CustomerID, - C = o2.CustomerID - }, + select new { A = c.CustomerID, B = o0.CustomerID, C = o2.CustomerID }, e => e.A + " " + e.B + " " + e.C); } @@ -811,11 +664,7 @@ public virtual Task GroupJoin_DefaultIfEmpty(bool isAsync) from c in cs join o in os on c.CustomerID equals o.CustomerID into orders from o in orders.DefaultIfEmpty() - select new - { - c, - o - }, + select new { c, o }, e => e.c.CustomerID + " " + e.o?.OrderID, entryCount: 921); } @@ -832,12 +681,7 @@ join o1 in os on c.CustomerID equals o1.CustomerID into orders1 from o1 in orders1.DefaultIfEmpty() join o2 in os on c.CustomerID equals o2.CustomerID into orders2 from o2 in orders2.DefaultIfEmpty() - select new - { - c, - o1, - o2 - }, + select new { c, o1, o2 }, e => e.c.CustomerID + " " + e.o1?.OrderID + " " + e.o2?.OrderID, entryCount: 921); } @@ -852,11 +696,7 @@ public virtual Task GroupJoin_DefaultIfEmpty2(bool isAsync) from e in es join o in os on e.EmployeeID equals o.EmployeeID into orders from o in orders.DefaultIfEmpty() - select new - { - e, - o - }, + select new { e, o }, e => e.e.EmployeeID + " " + e.o?.OrderID, entryCount: 839); } @@ -965,11 +805,7 @@ public virtual Task GroupJoin_with_different_outer_elements_with_same_key(bool i cs, o => o.CustomerID, c => c.CustomerID, - (o, cg) => new - { - o.OrderID, - Name = cg.Select(c => c.ContactName).FirstOrDefault() - }), + (o, cg) => new { o.OrderID, Name = cg.Select(c => c.ContactName).FirstOrDefault() }), e => e.OrderID + " " + e.Name); } @@ -984,11 +820,7 @@ public virtual Task GroupJoin_with_different_outer_elements_with_same_key_with_p cs, o => o.CustomerID, c => c.CustomerID, - (o, cg) => new - { - o.OrderID, - Name = cg.Select(c => c.ContactName).FirstOrDefault() - }), + (o, cg) => new { o.OrderID, Name = cg.Select(c => c.ContactName).FirstOrDefault() }), e => e.OrderID + " " + e.Name); } @@ -1003,11 +835,7 @@ public virtual Task GroupJoin_with_different_outer_elements_with_same_key_projec cs, o => o.CustomerID, c => c.CustomerID, - (o, cg) => new - { - o.OrderID, - Name = cg.Select(c => c.ContactName).FirstOrDefault() - }), + (o, cg) => new { o.OrderID, Name = cg.Select(c => c.ContactName).FirstOrDefault() }), e => e.OrderID + " " + e.Name); } @@ -1021,11 +849,7 @@ public virtual Task GroupJoin_SelectMany_subquery_with_filter(bool isAsync) from c in cs join o in os on c.CustomerID equals o.CustomerID into lo from o in lo.Where(x => x.OrderID > 5) - select new - { - c.ContactName, - o.OrderID - }, + select new { c.ContactName, o.OrderID }, e => e.ContactName + " " + e.OrderID); } @@ -1039,11 +863,7 @@ public virtual Task GroupJoin_SelectMany_subquery_with_filter_orderby(bool isAsy from c in cs join o in os on c.CustomerID equals o.CustomerID into lo from o in lo.Where(x => x.OrderID > 5).OrderBy(x => x.OrderDate) - select new - { - c.ContactName, - o.OrderID - }, + select new { c.ContactName, o.OrderID }, e => e.ContactName + " " + e.OrderID); } @@ -1057,11 +877,7 @@ public virtual Task GroupJoin_SelectMany_subquery_with_filter_and_DefaultIfEmpty from c in cs join o in os on c.CustomerID equals o.CustomerID into lo from o in lo.Where(x => x.OrderID > 5).DefaultIfEmpty() - select new - { - c.ContactName, - o - }, + select new { c.ContactName, o }, e => e.ContactName + " " + e.o?.OrderID, entryCount: 830); } @@ -1076,11 +892,7 @@ public virtual Task GroupJoin_SelectMany_subquery_with_filter_orderby_and_Defaul from c in cs join o in os on c.CustomerID equals o.CustomerID into lo from o in lo.Where(x => x.OrderID > 5).OrderBy(x => x.OrderDate).DefaultIfEmpty() - select new - { - c.ContactName, - o - }, + select new { c.ContactName, o }, e => e.ContactName + " " + e.o?.OrderID, entryCount: 830); } diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.KeylessEntities.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.KeylessEntities.cs index 721d07dad13..9d4880fdc21 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.KeylessEntities.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.KeylessEntities.cs @@ -4,7 +4,6 @@ using System; using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Xunit; @@ -96,11 +95,7 @@ public virtual Task KeylessEntity_with_mixed_tracking(bool isAsync) (cs, ovs) => from c in cs from o in ovs.Where(ov => ov.CustomerID == c.CustomerID) - select new - { - c, - o - }, + select new { c, o }, e => e.c.CustomerID); } @@ -120,9 +115,10 @@ await Assert.ThrowsAsync( else { await Assert.ThrowsAsync( - () => Task.FromResult((from ov in ctx.Set().Include(ov => ov.Customer) - where ov.CustomerID == "ALFKI" - select ov).ToList())); + () => Task.FromResult( + (from ov in ctx.Set().Include(ov => ov.Customer) + where ov.CustomerID == "ALFKI" + select ov).ToList())); } } } @@ -143,9 +139,10 @@ await Assert.ThrowsAsync( else { await Assert.ThrowsAsync( - () => Task.FromResult((from ov in ctx.Set().Include(ov => ov.Customer.Orders) - where ov.CustomerID == "ALFKI" - select ov).ToList())); + () => Task.FromResult( + (from ov in ctx.Set().Include(ov => ov.Customer.Orders) + where ov.CustomerID == "ALFKI" + select ov).ToList())); } } } diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.ResultOperators.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.ResultOperators.cs index 340ba8c7c0b..3b6cf7e5eef 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.ResultOperators.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.ResultOperators.cs @@ -3,12 +3,10 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestModels.Northwind; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable PossibleMultipleEnumeration @@ -53,11 +51,7 @@ public virtual void Select_All() context .Set() .Select( - o => new ProjectedType - { - Order = o.OrderID, - Customer = o.CustomerID - }) + o => new ProjectedType { Order = o.OrderID, Customer = o.CustomerID }) .All(p => p.Customer == "ALFKI") ); } @@ -244,11 +238,7 @@ public virtual Task Sum_on_float_column_in_subquery(bool isAsync) return AssertQuery( isAsync, os => os.Where(o => o.OrderID < 10300).Select( - o => new - { - o.OrderID, - Sum = o.OrderDetails.Sum(od => od.Discount) - }), + o => new { o.OrderID, Sum = o.OrderDetails.Sum(od => od.Discount) }), e => e.OrderID); } @@ -370,11 +360,7 @@ public virtual Task Average_on_float_column_in_subquery(bool isAsync) return AssertQuery( isAsync, os => os.Where(o => o.OrderID < 10300).Select( - o => new - { - o.OrderID, - Sum = o.OrderDetails.Average(od => od.Discount) - }), + o => new { o.OrderID, Sum = o.OrderDetails.Average(od => od.Discount) }), e => e.OrderID); } @@ -386,11 +372,7 @@ public virtual Task Average_on_float_column_in_subquery_with_cast(bool isAsync) isAsync, os => os.Where(o => o.OrderID < 10300) .Select( - o => new - { - o.OrderID, - Sum = o.OrderDetails.Average(od => (float?)od.Discount) - }), + o => new { o.OrderID, Sum = o.OrderDetails.Average(od => (float?)od.Discount) }), e => e.OrderID); } @@ -496,7 +478,6 @@ public virtual void Average_no_data() } } - [ConditionalFact] public virtual void Average_no_data_nullable() { @@ -875,15 +856,9 @@ public virtual Task Distinct_OrderBy3(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.CustomerID - }).Distinct().OrderBy(a => a.CustomerID), + c => new { c.CustomerID }).Distinct().OrderBy(a => a.CustomerID), cs => cs.Select( - c => new - { - c.CustomerID - }).Distinct().OrderBy(a => a.CustomerID, StringComparer.Ordinal), + c => new { c.CustomerID }).Distinct().OrderBy(a => a.CustomerID, StringComparer.Ordinal), assertOrder: true); } @@ -1044,10 +1019,15 @@ public virtual Task Multiple_collection_navigation_with_FirstOrDefault_chained(b { return AssertQuery( isAsync, - cs => cs.OrderBy(c => c.CustomerID).Select(c => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault().OrderDetails.OrderBy(od => od.ProductID).FirstOrDefault()), - cs => cs.OrderBy(c => c.CustomerID).Select(c => Maybe( - Maybe(c.Orders.OrderBy(o => o.OrderID).FirstOrDefault(), () => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault().OrderDetails), - () => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault().OrderDetails.OrderBy(od => od.ProductID).FirstOrDefault()))); + cs => cs.OrderBy(c => c.CustomerID).Select( + c => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault().OrderDetails.OrderBy(od => od.ProductID).FirstOrDefault()), + cs => cs.OrderBy(c => c.CustomerID).Select( + c => Maybe( + Maybe( + c.Orders.OrderBy(o => o.OrderID).FirstOrDefault(), + () => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault().OrderDetails), + () => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault().OrderDetails.OrderBy(od => od.ProductID) + .FirstOrDefault()))); } [ConditionalTheory] @@ -1056,10 +1036,16 @@ public virtual Task Multiple_collection_navigation_with_FirstOrDefault_chained_p { return AssertQueryScalar( isAsync, - cs => cs.OrderBy(c => c.CustomerID).Select(c => (int?)c.Orders.OrderBy(o => o.OrderID).FirstOrDefault().OrderDetails.OrderBy(od => od.ProductID).FirstOrDefault().ProductID), - cs => cs.OrderBy(c => c.CustomerID).Select(c => MaybeScalar( - Maybe(c.Orders.OrderBy(o => o.OrderID).FirstOrDefault(), () => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault().OrderDetails), - () => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault().OrderDetails.OrderBy(od => od.ProductID).FirstOrDefault().ProductID))); + cs => cs.OrderBy(c => c.CustomerID).Select( + c => (int?)c.Orders.OrderBy(o => o.OrderID).FirstOrDefault().OrderDetails.OrderBy(od => od.ProductID).FirstOrDefault() + .ProductID), + cs => cs.OrderBy(c => c.CustomerID).Select( + c => MaybeScalar( + Maybe( + c.Orders.OrderBy(o => o.OrderID).FirstOrDefault(), + () => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault().OrderDetails), + () => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault().OrderDetails.OrderBy(od => od.ProductID).FirstOrDefault() + .ProductID))); } [ConditionalTheory] @@ -1087,13 +1073,14 @@ public virtual Task Last(bool isAsync) public virtual async Task Last_when_no_order_by(bool isAsync) { Assert.Equal( - CoreStrings.TranslationFailed(@"Last(Select( source: Where( source: DbSet, predicate: (c) => c.CustomerID == ""ALFKI""), selector: (c) => (object)c))"), + CoreStrings.TranslationFailed( + @"Last(Select( source: Where( source: DbSet, predicate: (c) => c.CustomerID == ""ALFKI""), selector: (c) => (object)c))"), RemoveNewLines( (await Assert.ThrowsAsync( () => AssertLast( - isAsync, - cs => cs.Where(c => c.CustomerID == "ALFKI"), - entryCount: 1))).Message)); + isAsync, + cs => cs.Where(c => c.CustomerID == "ALFKI"), + entryCount: 1))).Message)); } [ConditionalTheory] @@ -1246,11 +1233,7 @@ public virtual Task Contains_with_local_array_inline(bool isAsync) [MemberData(nameof(IsAsyncData))] public virtual Task Contains_with_local_list_closure(bool isAsync) { - var ids = new List - { - "ABCDE", - "ALFKI" - }; + var ids = new List { "ABCDE", "ALFKI" }; return AssertQuery( isAsync, cs => cs.Where(c => ids.Contains(c.CustomerID)), entryCount: 1); @@ -1260,11 +1243,7 @@ public virtual Task Contains_with_local_list_closure(bool isAsync) [MemberData(nameof(IsAsyncData))] public virtual Task Contains_with_local_list_closure_all_null(bool isAsync) { - var ids = new List - { - null, - null - }; + var ids = new List { null, null }; return AssertQuery( isAsync, cs => cs.Where(c => ids.Contains(c.CustomerID))); @@ -1278,11 +1257,7 @@ public virtual Task Contains_with_local_list_inline(bool isAsync) isAsync, cs => cs.Where( - c => new List - { - "ABCDE", - "ALFKI" - }.Contains(c.CustomerID)), entryCount: 1); + c => new List { "ABCDE", "ALFKI" }.Contains(c.CustomerID)), entryCount: 1); } [ConditionalTheory] @@ -1294,22 +1269,14 @@ public virtual async Task Contains_with_local_list_inline_closure_mix(bool isAsy await AssertQuery( isAsync, cs => cs.Where( - c => new List - { - "ABCDE", - id - }.Contains(c.CustomerID)), entryCount: 1); + c => new List { "ABCDE", id }.Contains(c.CustomerID)), entryCount: 1); id = "ANATR"; await AssertQuery( isAsync, cs => cs.Where( - c => new List - { - "ABCDE", - id - }.Contains(c.CustomerID)), entryCount: 1); + c => new List { "ABCDE", id }.Contains(c.CustomerID)), entryCount: 1); } [ConditionalTheory] @@ -1321,33 +1288,23 @@ public virtual async Task Contains_with_local_non_primitive_list_inline_closure_ await AssertQuery( isAsync, cs => cs.Where( - c => new List - { - new Customer { CustomerID = "ABCDE" }, - new Customer { CustomerID = id } - }.Select(i => i.CustomerID).Contains(c.CustomerID)), entryCount: 1); + c => new List { new Customer { CustomerID = "ABCDE" }, new Customer { CustomerID = id } } + .Select(i => i.CustomerID).Contains(c.CustomerID)), entryCount: 1); id = "ANATR"; await AssertQuery( isAsync, cs => cs.Where( - c => new List - { - new Customer { CustomerID = "ABCDE" }, - new Customer { CustomerID = id } - }.Select(i => i.CustomerID).Contains(c.CustomerID)), entryCount: 1); + c => new List { new Customer { CustomerID = "ABCDE" }, new Customer { CustomerID = id } } + .Select(i => i.CustomerID).Contains(c.CustomerID)), entryCount: 1); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Contains_with_local_non_primitive_list_closure_mix(bool isAsync) { - var ids = new List - { - new Customer { CustomerID = "ABCDE" }, - new Customer { CustomerID = "ALFKI" } - }; + var ids = new List { new Customer { CustomerID = "ABCDE" }, new Customer { CustomerID = "ALFKI" } }; await AssertQuery( isAsync, @@ -1471,19 +1428,7 @@ public virtual async Task Contains_with_local_tuple_array_closure(bool isAsync) [MemberData(nameof(IsAsyncData))] public virtual async Task Contains_with_local_anonymous_type_array_closure(bool isAsync) { - var ids = new[] - { - new - { - Id1 = 1, - Id2 = 2 - }, - new - { - Id1 = 10248, - Id2 = 11 - } - }; + var ids = new[] { new { Id1 = 1, Id2 = 2 }, new { Id1 = 10248, Id2 = 11 } }; Assert.Equal( CoreStrings.TranslationFailed( @@ -1494,11 +1439,7 @@ public virtual async Task Contains_with_local_anonymous_type_array_closure(bool isAsync, od => od.Where( o => ids.Contains( - new - { - Id1 = o.OrderID, - Id2 = o.ProductID - })), entryCount: 1))).Message)); + new { Id1 = o.OrderID, Id2 = o.ProductID })), entryCount: 1))).Message)); } private string RemoveNewLines(string message) @@ -1610,8 +1551,9 @@ public virtual Task List_Contains_over_entityType_should_rewrite_to_identity_equ { var someOrder = new Order { OrderID = 10248 }; - return AssertQuery(isAsync, cs => - cs.Where(c => c.Orders.Contains(someOrder)), + return AssertQuery( + isAsync, cs => + cs.Where(c => c.Orders.Contains(someOrder)), entryCount: 1); } @@ -1619,26 +1561,22 @@ public virtual Task List_Contains_over_entityType_should_rewrite_to_identity_equ [MemberData(nameof(IsAsyncData))] public virtual Task List_Contains_with_constant_list(bool isAsync) { - return AssertQuery(isAsync, cs => - cs.Where(c => new List - { - new Customer { CustomerID = "ALFKI" }, - new Customer { CustomerID = "ANATR" } - }.Contains(c)), - entryCount: 2); + return AssertQuery( + isAsync, cs => + cs.Where( + c => new List { new Customer { CustomerID = "ALFKI" }, new Customer { CustomerID = "ANATR" } } + .Contains(c)), + entryCount: 2); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task List_Contains_with_parameter_list(bool isAsync) { - var customers = new List - { - new Customer { CustomerID = "ALFKI" }, - new Customer { CustomerID = "ANATR" } - }; + var customers = new List { new Customer { CustomerID = "ALFKI" }, new Customer { CustomerID = "ANATR" } }; - return AssertQuery(isAsync, cs => cs.Where(c => customers.Contains(c)), + return AssertQuery( + isAsync, cs => cs.Where(c => customers.Contains(c)), entryCount: 2); } @@ -1646,13 +1584,10 @@ public virtual Task List_Contains_with_parameter_list(bool isAsync) [MemberData(nameof(IsAsyncData))] public virtual Task Contains_with_parameter_list_value_type_id(bool isAsync) { - var orders = new List - { - new Order { OrderID = 10248 }, - new Order { OrderID = 10249 } - }; + var orders = new List { new Order { OrderID = 10248 }, new Order { OrderID = 10249 } }; - return AssertQuery(isAsync, od => od.Where(o => orders.Contains(o)), + return AssertQuery( + isAsync, od => od.Where(o => orders.Contains(o)), entryCount: 2); } @@ -1660,11 +1595,8 @@ public virtual Task Contains_with_parameter_list_value_type_id(bool isAsync) [MemberData(nameof(IsAsyncData))] public virtual Task Contains_with_constant_list_value_type_id(bool isAsync) { - return AssertQuery(isAsync, od => od.Where(o => new List - { - new Order { OrderID = 10248 }, - new Order { OrderID = 10249 } - }.Contains(o)), + return AssertQuery( + isAsync, od => od.Where(o => new List { new Order { OrderID = 10248 }, new Order { OrderID = 10249 } }.Contains(o)), entryCount: 2); } @@ -1710,7 +1642,8 @@ public virtual void Paging_operation_on_string_doesnt_issue_warning() { Assert.Equal( CoreStrings.QueryFailed( - "AsQueryable(NavigationTreeExpression Value: EntityReferenceCustomer Expression: (Unhandled parameter: c).CustomerID)", "NavigationExpandingExpressionVisitor"), + "AsQueryable(NavigationTreeExpression Value: EntityReferenceCustomer Expression: (Unhandled parameter: c).CustomerID)", + "NavigationExpandingExpressionVisitor"), RemoveNewLines( Assert.Throws( () => context.Customers.Select(c => c.CustomerID.FirstOrDefault()).ToList()).Message)); @@ -1731,12 +1664,7 @@ public virtual Task Project_constant_Sum(bool isAsync) [MemberData(nameof(IsAsyncData))] public virtual Task Where_subquery_any_equals_operator(bool isAsync) { - var ids = new List - { - "ABCDE", - "ALFKI", - "ANATR" - }; + var ids = new List { "ABCDE", "ALFKI", "ANATR" }; return AssertQuery( isAsync, @@ -1756,12 +1684,7 @@ public virtual Task Where_subquery_any_equals(bool isAsync) [MemberData(nameof(IsAsyncData))] public virtual Task Where_subquery_any_equals_static(bool isAsync) { - var ids = new List - { - "ABCDE", - "ALFKI", - "ANATR" - }; + var ids = new List { "ABCDE", "ALFKI", "ANATR" }; return AssertQuery( isAsync, @@ -1773,12 +1696,7 @@ public virtual Task Where_subquery_any_equals_static(bool isAsync) [MemberData(nameof(IsAsyncData))] public virtual async Task Where_subquery_where_any(bool isAsync) { - var ids = new[] - { - "ABCDE", - "ALFKI", - "ANATR" - }; + var ids = new[] { "ABCDE", "ALFKI", "ANATR" }; await AssertQuery( isAsync, @@ -1795,12 +1713,7 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public virtual Task Where_subquery_all_not_equals_operator(bool isAsync) { - var ids = new List - { - "ABCDE", - "ALFKI", - "ANATR" - }; + var ids = new List { "ABCDE", "ALFKI", "ANATR" }; return AssertQuery( isAsync, @@ -1820,12 +1733,7 @@ public virtual Task Where_subquery_all_not_equals(bool isAsync) [MemberData(nameof(IsAsyncData))] public virtual Task Where_subquery_all_not_equals_static(bool isAsync) { - var ids = new List - { - "ABCDE", - "ALFKI", - "ANATR" - }; + var ids = new List { "ABCDE", "ALFKI", "ANATR" }; return AssertQuery( isAsync, @@ -1837,12 +1745,7 @@ public virtual Task Where_subquery_all_not_equals_static(bool isAsync) [MemberData(nameof(IsAsyncData))] public virtual async Task Where_subquery_where_all(bool isAsync) { - var ids = new List - { - "ABCDE", - "ALFKI", - "ANATR" - }; + var ids = new List { "ABCDE", "ALFKI", "ANATR" }; await AssertQuery( isAsync, diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Select.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Select.cs index 0d58a4cba08..af1a2dfae0d 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Select.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Select.cs @@ -39,11 +39,7 @@ public virtual Task Projection_when_arithmetic_expression_precedence(bool isAsyn return AssertQuery( isAsync, os => os.Select( - o => new - { - A = o.OrderID / (o.OrderID / 2), - B = o.OrderID / o.OrderID / 2 - }), + o => new { A = o.OrderID / (o.OrderID / 2), B = o.OrderID / o.OrderID / 2 }), e => e.A + " " + e.B); } @@ -111,10 +107,7 @@ public virtual async Task Select_bool_closure(bool isAsync) await AssertQuery( isAsync, cs => cs.Select( - c => new - { - f = boolean - }), + c => new { f = boolean }), e => e.f); boolean = true; @@ -122,10 +115,7 @@ await AssertQuery( await AssertQuery( isAsync, cs => cs.Select( - c => new - { - f = boolean - }), + c => new { f = boolean }), e => e.f); } @@ -142,10 +132,7 @@ public virtual async Task Select_bool_closure_with_order_by_property_with_cast_t () => AssertQuery( isAsync, cs => cs.Select( - c => new - { - f = boolean - }).OrderBy(e => (bool?)e.f), + c => new { f = boolean }).OrderBy(e => (bool?)e.f), assertOrder: true))).Message)); } @@ -177,10 +164,7 @@ public virtual Task Select_anonymous_one(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.City - }), + c => new { c.City }), e => e.City); } @@ -191,11 +175,7 @@ public virtual Task Select_anonymous_two(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.City, - c.Phone - }), + c => new { c.City, c.Phone }), e => e.Phone); } @@ -206,12 +186,7 @@ public virtual Task Select_anonymous_three(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.City, - c.Phone, - c.Country - }), + c => new { c.City, c.Phone, c.Country }), e => e.Phone); } @@ -222,11 +197,7 @@ public virtual Task Select_anonymous_bool_constant_true(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.CustomerID, - ConstantTrue = true - }), + c => new { c.CustomerID, ConstantTrue = true }), e => e.CustomerID); } @@ -237,11 +208,7 @@ public virtual Task Select_anonymous_constant_in_expression(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.CustomerID, - Expression = c.CustomerID.Length + 5 - }), + c => new { c.CustomerID, Expression = c.CustomerID.Length + 5 }), e => e.CustomerID); } @@ -252,11 +219,7 @@ public virtual Task Select_anonymous_conditional_expression(bool isAsync) return AssertQuery( isAsync, ps => ps.Select( - p => new - { - p.ProductID, - IsAvailable = p.UnitsInStock > 0 - }), + p => new { p.ProductID, IsAvailable = p.UnitsInStock > 0 }), e => e.ProductID); } @@ -287,11 +250,7 @@ public virtual Task Select_anonymous_with_object(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.City, - c - }), + c => new { c.City, c }), e => e.c.CustomerID, entryCount: 91); } @@ -303,14 +262,7 @@ public virtual Task Select_anonymous_nested(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.City, - Country = new - { - c.Country - } - }), + c => new { c.City, Country = new { c.Country } }), e => e.City); } @@ -321,9 +273,7 @@ public virtual Task Select_anonymous_empty(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - }), + c => new { }), e => 1); } @@ -334,10 +284,7 @@ public virtual Task Select_anonymous_literal(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - X = 10 - }), + c => new { X = 10 }), e => e.X); } @@ -447,10 +394,7 @@ public virtual void Select_nested_collection_multi_level() .Where(o => o.OrderID < 10500) .Take(3) .Select( - o => new - { - Date = o.OrderDate - }) + o => new { Date = o.OrderDate }) }) .ToList(); @@ -590,10 +534,7 @@ public virtual Task Select_nested_collection_count_using_anonymous_type(bool isA isAsync, cs => cs.Where(c => c.CustomerID.StartsWith("A")) .Select( - c => new - { - c.Orders.Count - }), + c => new { c.Orders.Count }), e => e.Count); } @@ -633,10 +574,7 @@ public virtual Task New_date_time_in_anonymous_type_works(bool isAsync) isAsync, cs => from c in cs where c.CustomerID.StartsWith("A") - select new - { - A = new DateTime() - }, + select new { A = new DateTime() }, e => e.A); } @@ -780,12 +718,7 @@ public virtual Task Select_non_matching_value_types_from_anonymous_type_introduc .Where(o => o.CustomerID == "ALFKI") .OrderBy(o => o.OrderID) .Select( - o => new - { - LongOrder = (long)o.OrderID, - ShortOrder = (short)o.OrderID, - Order = o.OrderID - }), + o => new { LongOrder = (long)o.OrderID, ShortOrder = (short)o.OrderID, Order = o.OrderID }), assertOrder: true); } @@ -861,7 +794,8 @@ public virtual Task Project_single_element_from_collection_with_OrderBy_Distinct cs => cs.Select( c => c.Orders.OrderBy(o => o.OrderID).Select(o => o.CustomerID).Distinct().FirstOrDefault()).Select(e => e.Length), cs => cs.Select( - c => c.Orders.OrderBy(o => o.OrderID).Select(o => o.CustomerID).Distinct().FirstOrDefault()).Select(e => e == null ? 0 : e.Length)); + c => c.Orders.OrderBy(o => o.OrderID).Select(o => o.CustomerID).Distinct().FirstOrDefault()) + .Select(e => e == null ? 0 : e.Length)); } [ConditionalTheory] @@ -1085,11 +1019,7 @@ public virtual Task Anonymous_projection_AsNoTracking_Selector(bool isAsync) return AssertQueryScalar( isAsync, os => os.Select( - o => new - { - A = o.CustomerID, - B = o.OrderDate - }) + o => new { A = o.CustomerID, B = o.OrderDate }) .AsNoTracking() // Just to cause a subquery .Select(e => e.B)); } @@ -1102,11 +1032,7 @@ public virtual Task Anonymous_projection_with_repeated_property_being_ordered(bo isAsync, cs => from c in cs orderby c.CustomerID - select new - { - A = c.CustomerID, - B = c.CustomerID - }); + select new { A = c.CustomerID, B = c.CustomerID }); } [ConditionalTheory] @@ -1117,11 +1043,7 @@ public virtual Task Anonymous_projection_with_repeated_property_being_ordered_2( isAsync, os => from o in os orderby o.CustomerID - select new - { - A = o.Customer.CustomerID, - B = o.CustomerID - }); + select new { A = o.Customer.CustomerID, B = o.CustomerID }); } [ConditionalTheory] @@ -1149,8 +1071,6 @@ from o in grouping.DefaultIfEmpty() select o != null ? o.OrderDate.Value : new DateTime(1753, 1, 1)); } - - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Cast_on_top_level_projection_brings_explicit_Cast(bool isAsync) @@ -1188,13 +1108,14 @@ public virtual Task Projecting_nullable_struct(bool isAsync) { return AssertQuery( isAsync, - os => os.Select(o => new - { - One = o.CustomerID, - Two = o.CustomerID == "ALFKI" - ? new MyStruct { X = o.OrderID, Y = o.CustomerID.Length } - : (MyStruct?)null - }), + os => os.Select( + o => new + { + One = o.CustomerID, + Two = o.CustomerID == "ALFKI" + ? new MyStruct { X = o.OrderID, Y = o.CustomerID.Length } + : (MyStruct?)null + }), elementSorter: e => e.One + " " + e.Two?.X); } @@ -1244,11 +1165,7 @@ public virtual Task SelectMany_correlated_with_outer_1(bool isAsync) isAsync, (cs, os) => from c in cs from o in os.Where(o => c.CustomerID == o.CustomerID).Select(o => c.City) - select new - { - c, - o - }, + select new { c, o }, entryCount: 89); } @@ -1261,11 +1178,7 @@ public virtual Task SelectMany_correlated_with_outer_2(bool isAsync) (cs, os) => from c in cs from o in os.Where(o => c.CustomerID == o.CustomerID) .OrderBy(o => c.City).ThenBy(o => o.OrderID).Take(2) - select new - { - c, - o - }, + select new { c, o }, entryCount: 266); } @@ -1277,11 +1190,7 @@ public virtual Task SelectMany_correlated_with_outer_3(bool isAsync) isAsync, (cs, os) => from c in cs from o in os.Where(o => c.CustomerID == o.CustomerID).Select(o => c.City).DefaultIfEmpty() - select new - { - c, - o - }, + select new { c, o }, entryCount: 91); } @@ -1294,11 +1203,7 @@ public virtual Task SelectMany_correlated_with_outer_4(bool isAsync) (cs, os) => from c in cs from o in os.Where(o => c.CustomerID == o.CustomerID) .OrderBy(o => c.City).ThenBy(o => o.OrderID).Take(2).DefaultIfEmpty() - select new - { - c, - o - }, + select new { c, o }, entryCount: 268); } } diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.SetOperations.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.SetOperations.cs index eaffe99abf0..a9dc0265307 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.SetOperations.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.SetOperations.cs @@ -17,7 +17,8 @@ public abstract partial class SimpleQueryTestBase [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Concat(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(c => c.City == "Berlin") .Concat(cs.Where(c => c.City == "London")), entryCount: 7); @@ -25,7 +26,8 @@ public virtual Task Concat(bool isAsync) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Concat_nested(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(c => c.City == "México D.F.") .Concat(cs.Where(s => s.City == "Berlin")) .Concat(cs.Where(e => e.City == "London")), @@ -34,17 +36,20 @@ public virtual Task Concat_nested(bool isAsync) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Concat_non_entity(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(c => c.City == "México D.F.") .Select(c => c.CustomerID) - .Concat(cs - .Where(s => s.ContactTitle == "Owner") - .Select(c => c.CustomerID))); + .Concat( + cs + .Where(s => s.ContactTitle == "Owner") + .Select(c => c.CustomerID))); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Except(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(c => c.City == "London") .Except(cs.Where(c => c.ContactName.Contains("Thomas"))), entryCount: 5); @@ -52,14 +57,16 @@ public virtual Task Except(bool isAsync) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Except_simple_followed_by_projecting_constant(bool isAsync) - => AssertQueryScalar(isAsync, cs => cs + => AssertQueryScalar( + isAsync, cs => cs .Except(cs) .Select(e => 1)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Except_nested(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(s => s.ContactTitle == "Owner") .Except(cs.Where(s => s.City == "México D.F.")) .Except(cs.Where(e => e.City == "Seattle")), @@ -68,7 +75,8 @@ public virtual Task Except_nested(bool isAsync) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Except_non_entity(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(s => s.ContactTitle == "Owner") .Select(c => c.CustomerID) .Except( @@ -79,7 +87,8 @@ public virtual Task Except_non_entity(bool isAsync) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Intersect(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(c => c.City == "London") .Intersect(cs.Where(c => c.ContactName.Contains("Thomas"))), entryCount: 1); @@ -87,7 +96,8 @@ public virtual Task Intersect(bool isAsync) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Intersect_nested(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(c => c.City == "México D.F.") .Intersect(cs.Where(s => s.ContactTitle == "Owner")) .Intersect(cs.Where(e => e.Fax != null)), @@ -96,17 +106,20 @@ public virtual Task Intersect_nested(bool isAsync) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Intersect_non_entity(bool isAsync) - => AssertQuery(isAsync, cs => cs - .Where(c => c.City == "México D.F.") - .Select(c => c.CustomerID) - .Intersect(cs - .Where(s => s.ContactTitle == "Owner") - .Select(c => c.CustomerID))); + => AssertQuery( + isAsync, cs => cs + .Where(c => c.City == "México D.F.") + .Select(c => c.CustomerID) + .Intersect( + cs + .Where(s => s.ContactTitle == "Owner") + .Select(c => c.CustomerID))); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Union(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(c => c.City == "Berlin") .Union(cs.Where(c => c.City == "London")), entryCount: 7); @@ -114,7 +127,8 @@ public virtual Task Union(bool isAsync) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Union_nested(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(s => s.ContactTitle == "Owner") .Union(cs.Where(s => s.City == "México D.F.")) .Union(cs.Where(e => e.City == "London")), @@ -123,18 +137,21 @@ public virtual Task Union_nested(bool isAsync) [ConditionalTheory(Skip = "Issue#16365")] [MemberData(nameof(IsAsyncData))] public virtual void Union_non_entity(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(s => s.ContactTitle == "Owner") .Select(c => c.CustomerID) - .Union(cs - .Where(c => c.City == "México D.F.") - .Select(c => c.CustomerID))); + .Union( + cs + .Where(c => c.City == "México D.F.") + .Select(c => c.CustomerID))); // OrderBy, Skip and Take are typically supported on the set operation itself (no need for query pushdown) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Union_OrderBy_Skip_Take(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(c => c.City == "Berlin") .Union(cs.Where(c => c.City == "London")) .OrderBy(c => c.ContactName) @@ -147,10 +164,11 @@ public virtual Task Union_OrderBy_Skip_Take(bool isAsync) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Union_Where(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(c => c.City == "Berlin") .Union(cs.Where(c => c.City == "London")) - .Where(c => c.ContactName.Contains("Thomas")), // pushdown + .Where(c => c.ContactName.Contains("Thomas")), // pushdown entryCount: 1); // Should cause pushdown into a subquery, keeping the ordering, offset and limit inside the subquery @@ -163,15 +181,16 @@ public virtual Task Union_Skip_Take_OrderBy_ThenBy_Where(bool isAsync) .Union(cs.Where(c => c.City == "London")) .OrderBy(c => c.Region) .ThenBy(c => c.City) - .Skip(0) // prevent pushdown from removing OrderBy - .Where(c => c.ContactName.Contains("Thomas")), // pushdown + .Skip(0) // prevent pushdown from removing OrderBy + .Where(c => c.ContactName.Contains("Thomas")), // pushdown entryCount: 1); // Nested set operation with same operation type - no parentheses are needed. [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Union_Union(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(c => c.City == "Berlin") .Union(cs.Where(c => c.City == "London")) .Union(cs.Where(c => c.City == "Mannheim")), @@ -182,7 +201,8 @@ public virtual Task Union_Union(bool isAsync) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Union_Intersect(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(c => c.City == "Berlin") .Union(cs.Where(c => c.City == "London")) .Intersect(cs.Where(c => c.ContactName.Contains("Thomas"))), @@ -191,7 +211,8 @@ public virtual Task Union_Intersect(bool isAsync) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Union_Take_Union_Take(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(c => c.City == "Berlin") .Union(cs.Where(c => c.City == "London")) .OrderBy(c => c.CustomerID) @@ -204,34 +225,39 @@ public virtual Task Union_Take_Union_Take(bool isAsync) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Select_Union(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(c => c.City == "Berlin") .Select(c => c.Address) - .Union(cs - .Where(c => c.City == "London") - .Select(c => c.Address))); + .Union( + cs + .Where(c => c.City == "London") + .Select(c => c.Address))); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Union_Select(bool isAsync) - => AssertQuery(isAsync, cs => cs - .Where(c => c.City == "Berlin") - .Union(cs.Where(c => c.City == "London")) - .Select(c => c.Address) - .Where(a => a.Contains("Hanover"))); + => AssertQuery( + isAsync, cs => cs + .Where(c => c.City == "Berlin") + .Union(cs.Where(c => c.City == "London")) + .Select(c => c.Address) + .Where(a => a.Contains("Hanover"))); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Union_with_anonymous_type_projection(bool isAsync) - => AssertQuery(isAsync, cs => cs - .Where(c => c.CompanyName.StartsWith("A")) - .Union(cs.Where(c => c.CompanyName.StartsWith("B"))) - .Select(c => new CustomerDeets { Id = c.CustomerID })); + => AssertQuery( + isAsync, cs => cs + .Where(c => c.CompanyName.StartsWith("A")) + .Union(cs.Where(c => c.CompanyName.StartsWith("B"))) + .Select(c => new CustomerDeets { Id = c.CustomerID })); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Select_Union_unrelated(bool isAsync) - => AssertQuery(isAsync, (cs, pd) => cs + => AssertQuery( + isAsync, (cs, pd) => cs .Select(c => c.ContactName) .Union(pd.Select(p => p.ProductName)) .Where(x => x.StartsWith("C")) @@ -241,46 +267,53 @@ public virtual Task Select_Union_unrelated(bool isAsync) [ConditionalTheory(Skip = "Very similar to #16298")] [MemberData(nameof(IsAsyncData))] public virtual Task Select_Union_different_fields_in_anonymous_with_subquery(bool isAsync) - => AssertQuery(isAsync, cs => cs - .Where(c => c.City == "Berlin") - .Select(c => new { Foo = c.City, Customer = c }) // Foo is City - .Union(cs - .Where(c => c.City == "London") - .Select(c => new { Foo = c.Region, Customer = c })) // Foo is Region - .OrderBy(x => x.Foo) - .Skip(1) - .Take(10) - .Where(x => x.Foo == "Berlin"), + => AssertQuery( + isAsync, cs => cs + .Where(c => c.City == "Berlin") + .Select(c => new { Foo = c.City, Customer = c }) // Foo is City + .Union( + cs + .Where(c => c.City == "London") + .Select(c => new { Foo = c.Region, Customer = c })) // Foo is Region + .OrderBy(x => x.Foo) + .Skip(1) + .Take(10) + .Where(x => x.Foo == "Berlin"), entryCount: 1); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Union_Include(bool isAsync) - => AssertQuery(isAsync, cs => cs - .Where(c => c.City == "Berlin") - .Union(cs.Where(c => c.City == "London")) - .Include(c => c.Orders), + => AssertQuery( + isAsync, cs => cs + .Where(c => c.City == "Berlin") + .Union(cs.Where(c => c.City == "London")) + .Include(c => c.Orders), entryCount: 59); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Include_Union(bool isAsync) - => AssertQuery(isAsync, cs => cs - .Where(c => c.City == "Berlin") - .Include(c => c.Orders) - .Union(cs - .Where(c => c.City == "London") - .Include(c => c.Orders)), + => AssertQuery( + isAsync, cs => cs + .Where(c => c.City == "Berlin") + .Include(c => c.Orders) + .Union( + cs + .Where(c => c.City == "London") + .Include(c => c.Orders)), entryCount: 59); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Select_Except_reference_projection(bool isAsync) - => AssertQuery(isAsync, od => od - .Select(o => o.Customer) - .Except(od - .Where(o => o.CustomerID == "ALFKI") - .Select(o => o.Customer)), + => AssertQuery( + isAsync, od => od + .Select(o => o.Customer) + .Except( + od + .Where(o => o.CustomerID == "ALFKI") + .Select(o => o.Customer)), entryCount: 88); [ConditionalFact] @@ -288,20 +321,23 @@ public virtual void Include_Union_only_on_one_side_throws() { using (var ctx = CreateContext()) { - Assert.Throws(() => - ctx.Customers - .Where(c => c.City == "Berlin") - .Include(c => c.Orders) - .Union(ctx.Customers.Where(c => c.City == "London")) - .ToList()); - - Assert.Throws(() => - ctx.Customers - .Where(c => c.City == "Berlin") - .Union(ctx.Customers - .Where(c => c.City == "London") - .Include(c => c.Orders)) - .ToList()); + Assert.Throws( + () => + ctx.Customers + .Where(c => c.City == "Berlin") + .Include(c => c.Orders) + .Union(ctx.Customers.Where(c => c.City == "London")) + .ToList()); + + Assert.Throws( + () => + ctx.Customers + .Where(c => c.City == "Berlin") + .Union( + ctx.Customers + .Where(c => c.City == "London") + .Include(c => c.Orders)) + .ToList()); } } @@ -310,48 +346,55 @@ public virtual void Include_Union_different_includes_throws() { using (var ctx = CreateContext()) { - Assert.Throws(() => - ctx.Customers - .Where(c => c.City == "Berlin") - .Include(c => c.Orders) - .Union(ctx.Customers - .Where(c => c.City == "London") + Assert.Throws( + () => + ctx.Customers + .Where(c => c.City == "Berlin") .Include(c => c.Orders) - .ThenInclude(o => o.OrderDetails)) - .ToList()); + .Union( + ctx.Customers + .Where(c => c.City == "London") + .Include(c => c.Orders) + .ThenInclude(o => o.OrderDetails)) + .ToList()); } } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task SubSelect_Union(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Select(c => new { Customer = c, Orders = c.Orders.Count }) - .Union(cs - .Select(c => new { Customer = c, Orders = c.Orders.Count }) + .Union( + cs + .Select(c => new { Customer = c, Orders = c.Orders.Count }) ), entryCount: 91); [ConditionalTheory(Skip = "#16243")] [MemberData(nameof(IsAsyncData))] public virtual Task Client_eval_Union_FirstOrDefault(bool isAsync) - => AssertFirstOrDefault(isAsync, cs => cs - .Select(c => ClientSideMethod(c)) - .Union(cs)); + => AssertFirstOrDefault( + isAsync, cs => cs + .Select(c => ClientSideMethod(c)) + .Union(cs)); private static Customer ClientSideMethod(Customer c) => c; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task GroupBy_Select_Union(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, cs => cs .Where(c => c.City == "Berlin") .GroupBy(c => c.CustomerID) .Select(g => new { CustomerID = g.Key, Count = g.Count() }) - .Union(cs - .Where(c => c.City == "London") - .GroupBy(c => c.CustomerID) - .Select(g => new { CustomerID = g.Key, Count = g.Count() }))); + .Union( + cs + .Where(c => c.City == "London") + .GroupBy(c => c.CustomerID) + .Select(g => new { CustomerID = g.Key, Count = g.Count() }))); [ConditionalTheory(Skip = "Issue#17339")] [MemberData(nameof(GetSetOperandTestCases))] diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Where.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Where.cs index 972c9602519..0e6a3a701d9 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Where.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Where.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestModels.Northwind; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable AccessToModifiedClosure @@ -68,10 +67,7 @@ public virtual Task Where_indexer_closure(bool isAsync) [MemberData(nameof(IsAsyncData))] public virtual Task Where_dictionary_key_access_closure(bool isAsync) { - var predicateMap = new Dictionary - { - ["City"] = "London" - }; + var predicateMap = new Dictionary { ["City"] = "London" }; return AssertQuery( isAsync, @@ -139,10 +135,7 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public virtual async Task Where_method_call_nullable_type_closure_via_query_cache(bool isAsync) { - var city = new City - { - Int = 2 - }; + var city = new City { Int = 2 }; await AssertQuery( isAsync, @@ -161,10 +154,7 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public virtual async Task Where_method_call_nullable_type_reverse_closure_via_query_cache(bool isAsync) { - var city = new City - { - NullableInt = 1 - }; + var city = new City { NullableInt = 1 }; await AssertQuery( isAsync, @@ -183,10 +173,7 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public virtual async Task Where_method_call_closure_via_query_cache(bool isAsync) { - var city = new City - { - InstanceFieldValue = "London" - }; + var city = new City { InstanceFieldValue = "London" }; await AssertQuery( isAsync, @@ -205,10 +192,7 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public virtual async Task Where_field_access_closure_via_query_cache(bool isAsync) { - var city = new City - { - InstanceFieldValue = "London" - }; + var city = new City { InstanceFieldValue = "London" }; await AssertQuery( isAsync, @@ -227,10 +211,7 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public virtual async Task Where_property_access_closure_via_query_cache(bool isAsync) { - var city = new City - { - InstancePropertyValue = "London" - }; + var city = new City { InstancePropertyValue = "London" }; await AssertQuery( isAsync, @@ -287,13 +268,7 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public virtual async Task Where_nested_field_access_closure_via_query_cache(bool isAsync) { - var city = new City - { - Nested = new City - { - InstanceFieldValue = "London" - } - }; + var city = new City { Nested = new City { InstanceFieldValue = "London" } }; await AssertQuery( isAsync, @@ -312,13 +287,7 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public virtual async Task Where_nested_property_access_closure_via_query_cache(bool isAsync) { - var city = new City - { - Nested = new City - { - InstancePropertyValue = "London" - } - }; + var city = new City { Nested = new City { InstancePropertyValue = "London" } }; await AssertQuery( isAsync, @@ -398,19 +367,13 @@ public virtual async Task Where_new_instance_field_access_query_cache(bool isAsy await AssertQuery( isAsync, cs => cs.Where( - c => c.City == new City - { - InstanceFieldValue = "London" - }.InstanceFieldValue), + c => c.City == new City { InstanceFieldValue = "London" }.InstanceFieldValue), entryCount: 6); await AssertQuery( isAsync, cs => cs.Where( - c => c.City == new City - { - InstanceFieldValue = "Seattle" - }.InstanceFieldValue), + c => c.City == new City { InstanceFieldValue = "Seattle" }.InstanceFieldValue), entryCount: 1); } @@ -422,20 +385,14 @@ public virtual async Task Where_new_instance_field_access_closure_via_query_cach await AssertQuery( isAsync, cs => cs.Where( - c => c.City == new City - { - InstanceFieldValue = city - }.InstanceFieldValue), + c => c.City == new City { InstanceFieldValue = city }.InstanceFieldValue), entryCount: 6); city = "Seattle"; await AssertQuery( isAsync, cs => cs.Where( - c => c.City == new City - { - InstanceFieldValue = city - }.InstanceFieldValue), + c => c.City == new City { InstanceFieldValue = city }.InstanceFieldValue), entryCount: 1); } @@ -598,11 +555,7 @@ public virtual Task Where_simple_shadow_projection_mixed(bool isAsync) isAsync, es => es.Where(e => EF.Property(e, "Title") == "Sales Representative") .Select( - e => new - { - e, - Title = EF.Property(e, "Title") - }), + e => new { e, Title = EF.Property(e, "Title") }), e => e.e.EmployeeID, entryCount: 6); } @@ -662,7 +615,8 @@ public virtual Task Where_subquery_correlated(bool isAsync) public virtual async Task Where_subquery_correlated_client_eval(bool isAsync) { Assert.Equal( - CoreStrings.TranslationFailed("(c0) => EntityShaperExpression: EntityType: Customer ValueBufferExpression: ProjectionBindingExpression: EmptyProjectionMember IsNullable: False.CustomerID == c0.CustomerID && c0.IsLondon"), + CoreStrings.TranslationFailed( + "(c0) => EntityShaperExpression: EntityType: Customer ValueBufferExpression: ProjectionBindingExpression: EmptyProjectionMember IsNullable: False.CustomerID == c0.CustomerID && c0.IsLondon"), RemoveNewLines( (await Assert.ThrowsAsync( () => AssertQuery( @@ -719,7 +673,8 @@ public virtual async Task Where_client_and_server_non_top_level(bool isAsync) public virtual async Task Where_client_deep_inside_predicate_and_server_top_level(bool isAsync) { Assert.Equal( - CoreStrings.TranslationFailed("(c) => c.CustomerID != \"ALFKI\" && c.CustomerID == \"MAUMAR\" || c.CustomerID != \"AROUT\" && c.IsLondon"), + CoreStrings.TranslationFailed( + "(c) => c.CustomerID != \"ALFKI\" && c.CustomerID == \"MAUMAR\" || c.CustomerID != \"AROUT\" && c.IsLondon"), RemoveNewLines( (await Assert.ThrowsAsync( () => AssertQuery( @@ -1159,11 +1114,7 @@ from e in es || c.City == "Berlin" || c.CustomerID == "ALFKI" || c.CustomerID == "ABCDE" - select new - { - c, - e - }, + select new { c, e }, e => e.c.CustomerID + " " + e.e.EmployeeID, entryCount: 16); } @@ -1179,11 +1130,7 @@ from c in cs from e in es where c.City != "London" && e.City != "London" - select new - { - c, - e - }, + select new { c, e }, e => e.c.CustomerID + " " + e.e.EmployeeID, entryCount: 90); } @@ -1199,11 +1146,7 @@ from c in cs from e in es where c.City != "London" && c.City != "Berlin" - select new - { - c, - e - }, + select new { c, e }, e => e.c.CustomerID + " " + e.e.EmployeeID, entryCount: 93); } @@ -1220,11 +1163,7 @@ from e in es where c.City != "London" && c.City != "Berlin" && c.City != "Seattle" - select new - { - c, - e - }, + select new { c, e }, e => e.c.CustomerID + " " + e.e.EmployeeID, entryCount: 92); } @@ -1242,11 +1181,7 @@ from e in es && c.City != "Berlin" && c.City != "Seattle" && c.City != "Lisboa" - select new - { - c, - e - }, + select new { c, e }, e => e.c.CustomerID + " " + e.e.EmployeeID, entryCount: 90); } @@ -1260,16 +1195,12 @@ public virtual Task Where_select_many_and(bool isAsync) (cs, es) => from c in cs from e in es - // ReSharper disable ArrangeRedundantParentheses + // ReSharper disable ArrangeRedundantParentheses #pragma warning disable RCS1032 // Remove redundant parentheses. where (c.City == "London" && c.Country == "UK") && (e.City == "London" && e.Country == "UK") #pragma warning restore RCS1032 // Remove redundant parentheses. - select new - { - c, - e - }, + select new { c, e }, e => e.c.CustomerID + " " + e.e.EmployeeID, entryCount: 10); } @@ -1300,10 +1231,7 @@ public virtual Task Where_primitive_tracked2(bool isAsync) return AssertQuery( isAsync, es => es.Take(9).Select( - e => new - { - e - }).Where(e => e.e.EmployeeID == 5), + e => new { e }).Where(e => e.e.EmployeeID == 5), e => e.e.EmployeeID, entryCount: 1); } @@ -1552,19 +1480,13 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public virtual async Task Where_poco_closure(bool isAsync) { - var customer = new Customer - { - CustomerID = "ALFKI" - }; + var customer = new Customer { CustomerID = "ALFKI" }; await AssertQuery( isAsync, cs => cs.Where(c => c.Equals(customer)).Select(c => c.CustomerID)); - customer = new Customer - { - CustomerID = "ANATR" - }; + customer = new Customer { CustomerID = "ANATR" }; await AssertQuery( isAsync, @@ -1788,49 +1710,31 @@ public virtual Task Where_compare_constructed_equal(bool isAsync) return AssertQuery( isAsync, cs => cs.Where( - c => new - { - x = c.City - } == new - { - x = "London" - })); + c => new { x = c.City } == new { x = "London" })); } - [ConditionalTheory(Skip = "Issue #14672. Cannot eval 'where (new <>f__AnonymousType410`2(x = [c].City, y = [c].Country) == { x = London, y = UK })'")] + [ConditionalTheory( + Skip = + "Issue #14672. Cannot eval 'where (new <>f__AnonymousType410`2(x = [c].City, y = [c].Country) == { x = London, y = UK })'")] [MemberData(nameof(IsAsyncData))] public virtual Task Where_compare_constructed_multi_value_equal(bool isAsync) { return AssertQuery( isAsync, cs => cs.Where( - c => new - { - x = c.City, - y = c.Country - } == new - { - x = "London", - y = "UK" - })); + c => new { x = c.City, y = c.Country } == new { x = "London", y = "UK" })); } - [ConditionalTheory(Skip = "Issue #14672. Cannot eval 'where (new <>f__AnonymousType410`2(x = [c].City, y = [c].Country) != { x = London, y = UK })'")] + [ConditionalTheory( + Skip = + "Issue #14672. Cannot eval 'where (new <>f__AnonymousType410`2(x = [c].City, y = [c].Country) != { x = London, y = UK })'")] [MemberData(nameof(IsAsyncData))] public virtual Task Where_compare_constructed_multi_value_not_equal(bool isAsync) { return AssertQuery( isAsync, cs => cs.Where( - c => new - { - x = c.City, - y = c.Country - } != new - { - x = "London", - y = "UK" - }), + c => new { x = c.City, y = c.Country } != new { x = "London", y = "UK" }), entryCount: 91); } @@ -2009,10 +1913,7 @@ public virtual Task Where_subquery_FirstOrDefault_compared_to_entity(bool isAsyn return AssertQuery( isAsync, cs => cs.Where( - c => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault() == new Order - { - OrderID = 10243 - })); + c => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault() == new Order { OrderID = 10243 })); } [ConditionalTheory] @@ -2049,7 +1950,7 @@ public virtual Task Decimal_cast_to_double_works(bool isAsync) entryCount: 2); } - [ConditionalTheory] // issue #16335 + [ConditionalTheory] // issue #16335 [MemberData(nameof(IsAsyncData))] public virtual Task Where_is_conditional(bool isAsync) { @@ -2060,7 +1961,7 @@ public virtual Task Where_is_conditional(bool isAsync) ps => ps.Where(p => p is Product ? false : true)); } - [ConditionalTheory] // issue #17172 + [ConditionalTheory] // issue #17172 [MemberData(nameof(IsAsyncData))] public virtual async Task Enclosing_class_settable_member_generates_parameter(bool isAsync) { @@ -2073,11 +1974,11 @@ await AssertQuery( SettableProperty = 10; await AssertQuery( - isAsync, - os => os.Where(o => o.OrderID == SettableProperty)); + isAsync, + os => os.Where(o => o.OrderID == SettableProperty)); } - [ConditionalTheory] // issue #17172 + [ConditionalTheory] // issue #17172 [MemberData(nameof(IsAsyncData))] public virtual Task Enclosing_class_readonly_member_generates_parameter(bool isAsync) { @@ -2086,7 +1987,7 @@ public virtual Task Enclosing_class_readonly_member_generates_parameter(bool isA os => os.Where(o => o.OrderID == ReadOnlyProperty)); } - [ConditionalTheory] // issue #17172 + [ConditionalTheory] // issue #17172 [MemberData(nameof(IsAsyncData))] public virtual Task Enclosing_class_const_member_does_not_generate_parameter(bool isAsync) { diff --git a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs index c40e717e2c0..998f21d1a8d 100644 --- a/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.cs @@ -6,15 +6,11 @@ using System.Globalization; using System.Linq; using System.Linq.Expressions; -using System.Reflection; using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Query.Internal; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.Extensions.Caching.Memory; using Xunit; // ReSharper disable ReplaceWithSingleCallToAny @@ -219,10 +215,7 @@ orderby c.CustomerID select c) .Take(2) from c2 in context.Customers - select new - { - CustomerID = EF.Property(c1, "CustomerID") - }) + select new { CustomerID = EF.Property(c1, "CustomerID") }) .Distinct() on EF.Property(c1_Orders, "CustomerID") equals _c1.CustomerID orderby _c1.CustomerID @@ -334,7 +327,7 @@ public virtual Task Entity_equality_self(bool isAsync) cs => from c in cs #pragma warning disable CS1718 // Comparison made to same variable - // ReSharper disable once EqualExpressionComparison + // ReSharper disable once EqualExpressionComparison where c == c #pragma warning restore CS1718 // Comparison made to same variable select c.CustomerID); @@ -344,10 +337,7 @@ from c in cs [MemberData(nameof(IsAsyncData))] public virtual Task Entity_equality_local(bool isAsync) { - var local = new Customer - { - CustomerID = "ANATR" - }; + var local = new Customer { CustomerID = "ANATR" }; return AssertQuery( isAsync, @@ -361,11 +351,7 @@ from c in cs [MemberData(nameof(IsAsyncData))] public virtual Task Entity_equality_local_composite_key(bool isAsync) { - var local = new OrderDetail - { - OrderID = 10248, - ProductID = 11 - }; + var local = new OrderDetail { OrderID = 10248, ProductID = 11 }; return AssertQuery( isAsync, @@ -380,10 +366,7 @@ where od.Equals(local) [MemberData(nameof(IsAsyncData))] public virtual Task Entity_equality_local_double_check(bool isAsync) { - var local = new Customer - { - CustomerID = "ANATR" - }; + var local = new Customer { CustomerID = "ANATR" }; return AssertQuery( isAsync, @@ -397,10 +380,7 @@ from c in cs [MemberData(nameof(IsAsyncData))] public virtual Task Join_with_entity_equality_local_on_both_sources(bool isAsync) { - var local = new Customer - { - CustomerID = "ANATR" - }; + var local = new Customer { CustomerID = "ANATR" }; return AssertQuery( isAsync, @@ -421,10 +401,7 @@ public virtual Task Entity_equality_local_inline(bool isAsync) isAsync, cs => from c in cs - where c == new Customer - { - CustomerID = "ANATR" - } + where c == new Customer { CustomerID = "ANATR" } select c.CustomerID); } @@ -435,11 +412,7 @@ public virtual Task Entity_equality_local_inline_composite_key(bool isAsync) isAsync, odt => from od in odt - where od.Equals(new OrderDetail - { - OrderID = 10248, - ProductID = 11 - }) + where od.Equals(new OrderDetail { OrderID = 10248, ProductID = 11 }) select od, entryCount: 1); @@ -494,13 +467,7 @@ public virtual Task Entity_equality_through_nested_anonymous_type_projection(boo => AssertQuery( isAsync, o => o - .Select(x => new - { - CustomerInfo = new - { - x.Customer - } - }) + .Select(x => new { CustomerInfo = new { x.Customer } }) .Where(x => x.CustomerInfo.Customer != null), entryCount: 89); @@ -534,14 +501,11 @@ where c.Orders.FirstOrDefault() != null [ConditionalFact] public virtual void Entity_equality_through_subquery_composite_key() { - Assert.Throws(() => - CreateContext().Orders - .Where(o => o.OrderDetails.FirstOrDefault() == new OrderDetail - { - OrderID = 10248, - ProductID = 11 - }) - .ToList()); + Assert.Throws( + () => + CreateContext().Orders + .Where(o => o.OrderDetails.FirstOrDefault() == new OrderDetail { OrderID = 10248, ProductID = 11 }) + .ToList()); } [ConditionalTheory] @@ -635,10 +599,7 @@ public virtual Task Queryable_simple_anonymous(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c - }), + c => new { c }), e => e.c.CustomerID, entryCount: 91); } @@ -650,10 +611,7 @@ public virtual Task Queryable_simple_anonymous_projection_subquery(bool isAsync) return AssertQuery( isAsync, cs => cs.Take(91).Select( - c => new - { - c - }).Select(a => a.c.City)); + c => new { c }).Select(a => a.c.City)); } [ConditionalTheory] @@ -663,10 +621,7 @@ public virtual Task Queryable_simple_anonymous_subquery(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c - }).Take(91).Select(a => a.c), + c => new { c }).Take(91).Select(a => a.c), entryCount: 91); } @@ -682,10 +637,7 @@ public virtual async Task Queryable_reprojection(bool isAsync) isAsync, cs => cs.Where(c => c.IsLondon) .Select( - c => new Customer - { - CustomerID = "Foo", City = c.City - })))).Message)); + c => new Customer { CustomerID = "Foo", City = c.City })))).Message)); } [ConditionalTheory] @@ -827,11 +779,7 @@ public virtual Task Join_Customers_Orders_Skip_Take(bool isAsync) (from c in cs join o in os on c.CustomerID equals o.CustomerID orderby o.OrderID - select new - { - c.ContactName, - o.OrderID - }).Skip(10).Take(5), + select new { c.ContactName, o.OrderID }).Skip(10).Take(5), e => e.ContactName); } @@ -846,11 +794,7 @@ public virtual Task Join_Customers_Orders_Skip_Take_followed_by_constant_project (from c in cs join o in os on c.CustomerID equals o.CustomerID orderby o.OrderID - select new - { - c.ContactName, - o.OrderID - }).Skip(10).Take(5).Select(e => "Foo"), + select new { c.ContactName, o.OrderID }).Skip(10).Take(5).Select(e => "Foo"), e => e.ContactName); } @@ -864,11 +808,7 @@ public virtual Task Join_Customers_Orders_Projection_With_String_Concat_Skip_Tak (from c in cs join o in os on c.CustomerID equals o.CustomerID orderby o.OrderID - select new - { - Contact = c.ContactName + " " + c.ContactTitle, - o.OrderID - }).Skip(10).Take(5), + select new { Contact = c.ContactName + " " + c.ContactTitle, o.OrderID }).Skip(10).Take(5), e => e.Contact); } @@ -1327,15 +1267,9 @@ public virtual async Task Projection_when_arithmetic_mixed_subqueries(bool isAsy isAsync, (os, es) => from o in os.OrderBy(o => o.OrderID).Take(3).Select( - o2 => new - { - o2, Mod = o2.OrderID % 2 - }) + o2 => new { o2, Mod = o2.OrderID % 2 }) from e in es.OrderBy(e => e.EmployeeID).Take(2).Select( - e2 => new - { - e2, Square = e2.EmployeeID ^ 2 - }) + e2 => new { e2, Square = e2.EmployeeID ^ 2 }) select new { Add = e.e2.EmployeeID + o.o2.OrderID, @@ -1369,11 +1303,7 @@ public virtual Task Take_with_single_select_many(bool isAsync) (from c in cs from o in os orderby c.CustomerID, o.OrderID - select new - { - c, - o - }) + select new { c, o }) .Take(1) .Cast(), entryCount: 2); @@ -1414,11 +1344,7 @@ from c in cs from e in es where c.City == "London" || e.City == "London" - select new - { - c, - e - }, + select new { c, e }, e => e.c.CustomerID + " " + e.e.EmployeeID, entryCount: 100); } @@ -1434,11 +1360,7 @@ from c in cs from e in es where c.City == "London" || c.City == "Berlin" - select new - { - c, - e - }, + select new { c, e }, e => e.c.CustomerID + " " + e.e.EmployeeID, entryCount: 16); } @@ -1455,11 +1377,7 @@ from e in es where c.City == "London" || c.City == "Berlin" || c.City == "Seattle" - select new - { - c, - e - }, + select new { c, e }, e => e.c.CustomerID + " " + e.e.EmployeeID, entryCount: 17); } @@ -1477,11 +1395,7 @@ from e in es || c.City == "Berlin" || c.City == "Seattle" || c.City == "Lisboa" - select new - { - c, - e - }, + select new { c, e }, e => e.c.CustomerID + " " + e.e.EmployeeID, entryCount: 19); } @@ -1502,11 +1416,7 @@ from e in es || c.City == "Berlin" || c.City == "Seattle" || c.City == lisboa - select new - { - c, - e - }, + select new { c, e }, e => e.c.CustomerID + " " + e.e.EmployeeID, entryCount: 19); } @@ -1519,21 +1429,11 @@ public virtual Task Where_subquery_anon(bool isAsync) isAsync, (es, os) => from e in es.OrderBy(ee => ee.EmployeeID).Take(3).Select( - e => new - { - e - }) + e => new { e }) from o in os.OrderBy(oo => oo.OrderID).Take(5).Select( - o => new - { - o - }) + o => new { o }) where e.e.EmployeeID == o.o.EmployeeID - select new - { - e, - o - }, + select new { e, o }, entryCount: 2); } @@ -1546,31 +1446,13 @@ public virtual Task Where_subquery_anon_nested(bool isAsync) (es, os, cs) => from t in ( from e in es.OrderBy(ee => ee.EmployeeID).Take(3).Select( - e => new - { - e - }).Where(e => e.e.City == "Seattle") + e => new { e }).Where(e => e.e.City == "Seattle") from o in os.OrderBy(oo => oo.OrderID).Take(5).Select( - o => new - { - o - }) - select new - { - e, - o - }) + o => new { o }) + select new { e, o }) from c in cs.Take(2).Select( - c => new - { - c - }) - select new - { - t.e, - t.o, - c - }, + c => new { c }) + select new { t.e, t.o, c }, entryCount: 8); } @@ -1684,21 +1566,13 @@ public virtual void Select_DTO_with_member_init_distinct_translated_to_server() var actual = context.Set() .Where(o => o.OrderID < 10300) .Select( - o => new OrderCountDTO - { - Id = o.CustomerID, - Count = o.OrderID - }) + o => new OrderCountDTO { Id = o.CustomerID, Count = o.OrderID }) .Distinct().ToList().OrderBy(e => e.Count).ToList(); var expected = Fixture.QueryAsserter.ExpectedData.Set() .Where(o => o.OrderID < 10300) .Select( - o => new OrderCountDTO - { - Id = o.CustomerID, - Count = o.OrderID - }) + o => new OrderCountDTO { Id = o.CustomerID, Count = o.OrderID }) .Distinct().ToList().OrderBy(e => e.Count).ToList(); Assert.Equal(expected.Count, actual.Count); @@ -1718,21 +1592,13 @@ public virtual void Select_nested_collection_count_using_DTO() var actual = context.Set() .Where(c => c.CustomerID.StartsWith("A")) .Select( - c => new OrderCountDTO - { - Id = c.CustomerID, - Count = c.Orders.Count - }) + c => new OrderCountDTO { Id = c.CustomerID, Count = c.Orders.Count }) .ToList().OrderBy(e => e.Id).ToList(); var expected = Fixture.QueryAsserter.ExpectedData.Set() .Where(c => c.CustomerID.StartsWith("A")) .Select( - c => new OrderCountDTO - { - Id = c.CustomerID, - Count = c.Orders.Count - }) + c => new OrderCountDTO { Id = c.CustomerID, Count = c.Orders.Count }) .ToList().OrderBy(e => e.Id).ToList(); Assert.Equal(expected.Count, actual.Count); @@ -1752,11 +1618,7 @@ public virtual Task Select_DTO_with_member_init_distinct_in_subquery_translated_ (cs, os) => from o in os.Where(o => o.OrderID < 10300) .Select( - o => new OrderCountDTO - { - Id = o.CustomerID, - Count = o.OrderID - }) + o => new OrderCountDTO { Id = o.CustomerID, Count = o.OrderID }) .Distinct() from c in cs.Where(c => c.CustomerID == o.Id) select c, @@ -1772,11 +1634,7 @@ public virtual Task Select_DTO_with_member_init_distinct_in_subquery_translated_ (cs, os) => from o in os.Where(o => o.OrderID < 10300) .Select( - o => new OrderCountDTO - { - Id = o.CustomerID, - Count = o.OrderID - }) + o => new OrderCountDTO { Id = o.CustomerID, Count = o.OrderID }) .Distinct() from c in cs.Where(c => o.Id == c.CustomerID) select c, @@ -1791,32 +1649,16 @@ public virtual void Select_DTO_with_member_init_distinct_in_subquery_used_in_pro var actual = (from c in context.Set().Where(c => c.CustomerID.StartsWith("A")) from o in context.Set().Where(o => o.OrderID < 10300) .Select( - o => new OrderCountDTO - { - Id = o.CustomerID, - Count = o.OrderID - }) + o => new OrderCountDTO { Id = o.CustomerID, Count = o.OrderID }) .Distinct() - select new - { - c, - o - }).ToList().OrderBy(e => e.c.CustomerID + " " + e.o.Count).ToList(); + select new { c, o }).ToList().OrderBy(e => e.c.CustomerID + " " + e.o.Count).ToList(); var expected = (from c in Fixture.QueryAsserter.ExpectedData.Set().Where(c => c.CustomerID.StartsWith("A")) from o in Fixture.QueryAsserter.ExpectedData.Set().Where(o => o.OrderID < 10300) .Select( - o => new OrderCountDTO - { - Id = o.CustomerID, - Count = o.OrderID - }) + o => new OrderCountDTO { Id = o.CustomerID, Count = o.OrderID }) .Distinct() - select new - { - c, - o - }).ToList().OrderBy(e => e.c.CustomerID + " " + e.o.Count).ToList(); + select new { c, o }).ToList().OrderBy(e => e.c.CustomerID + " " + e.o.Count).ToList(); Assert.Equal(expected.Count, actual.Count); for (var i = 0; i < expected.Count; i++) @@ -2218,10 +2060,7 @@ public virtual Task Where_query_composition2(bool isAsync) from e1 in es.Take(3) where e1.FirstName == (from e2 in es.OrderBy(e => e.EmployeeID) - select new - { - Foo = e2 - }) + select new { Foo = e2 }) .First().Foo.FirstName select e1, entryCount: 1); @@ -2253,10 +2092,7 @@ public virtual Task Where_query_composition2_FirstOrDefault_with_anonymous(bool from e1 in es.Take(3) where e1.FirstName == (from e2 in es.OrderBy(e => e.EmployeeID) - select new - { - Foo = e2 - }) + select new { Foo = e2 }) .FirstOrDefault().Foo.FirstName select e1, entryCount: 1); @@ -2293,10 +2129,7 @@ public virtual async Task Where_query_composition4(bool isAsync) from c1 in cs.OrderBy(c => c.CustomerID).Take(2) where c1.City == (from c2 in cs.OrderBy(c => c.CustomerID) from c3 in cs.OrderBy(c => c.IsLondon).ThenBy(c => c.CustomerID) - select new - { - c3 - }).First().c3.City + select new { c3 }).First().c3.City select c1, entryCount: 1))).Message)); } @@ -2324,7 +2157,8 @@ from c1 in cs public virtual async Task Where_query_composition6(bool isAsync) { Assert.Equal( - CoreStrings.TranslationFailed("(c) => c.IsLondon == First(Select( source: OrderBy( source: DbSet, keySelector: (c0) => c0.CustomerID), selector: (c0) => c0.IsLondon))"), + CoreStrings.TranslationFailed( + "(c) => c.IsLondon == First(Select( source: OrderBy( source: DbSet, keySelector: (c0) => c0.CustomerID), selector: (c0) => c0.IsLondon))"), RemoveNewLines( (await Assert.ThrowsAsync( () => AssertQuery( @@ -2334,10 +2168,7 @@ from c1 in cs where c1.IsLondon == cs.OrderBy(c => c.CustomerID) .Select( - c => new - { - Foo = c - }) + c => new { Foo = c }) .First().Foo.IsLondon select c1, entryCount: 85))).Message)); @@ -2384,15 +2215,9 @@ public virtual async Task SelectMany_mixed(bool isAsync) isAsync, (es, cs) => from e1 in es.OrderBy(e => e.EmployeeID).Take(2) - from s in new[] - { - "a", "b" - } + from s in new[] { "a", "b" } from c in cs.OrderBy(c => c.CustomerID).Take(2) - select new - { - e1, s, c - }, + select new { e1, s, c }, e => e.e1.EmployeeID + " " + e.c.CustomerID, entryCount: 4))).Message)); } @@ -2406,11 +2231,7 @@ public virtual Task SelectMany_simple1(bool isAsync) (es, cs) => from e in es from c in cs - select new - { - c, - e - }, + select new { c, e }, e => e.c.CustomerID + " " + e.e.EmployeeID, entryCount: 100); } @@ -2424,11 +2245,7 @@ public virtual Task SelectMany_simple_subquery(bool isAsync) (es, cs) => from e in es.Take(9) from c in cs - select new - { - c, - e - }, + select new { c, e }, e => e.c.CustomerID + " " + e.e.EmployeeID, entryCount: 100); } @@ -2443,12 +2260,7 @@ public virtual Task SelectMany_simple2(bool isAsync) from e1 in es from c in cs from e2 in es - select new - { - e1, - c, - e2.FirstName - }, + select new { e1, c, e2.FirstName }, e => e.e1.EmployeeID + " " + e.c.CustomerID + " " + e.FirstName, entryCount: 100); } @@ -2464,13 +2276,7 @@ from e1 in es from e2 in es from e3 in es from e4 in es - select new - { - e2, - e3, - e1, - e4 - }, + select new { e2, e3, e1, e4 }, e => e.e2.EmployeeID + " " + e.e3.EmployeeID + " " + e.e1.EmployeeID + e.e4.EmployeeID, entryCount: 9); } @@ -2484,11 +2290,7 @@ public virtual Task SelectMany_projection1(bool isAsync) es => from e1 in es from e2 in es - select new - { - e1.City, - e2.Country - }, + select new { e1.City, e2.Country }, e => e.City + " " + e.Country); } @@ -2502,12 +2304,7 @@ public virtual Task SelectMany_projection2(bool isAsync) from e1 in es from e2 in es from e3 in es - select new - { - e1.City, - e2.Country, - e3.FirstName - }, + select new { e1.City, e2.Country, e3.FirstName }, e => e.City + " " + e.Country + " " + e.FirstName); } @@ -2525,11 +2322,7 @@ orderby c1.CustomerID select c1, cs => cs.SelectMany( c => (from c2 in (from c3 in cs select c3) select c2), - (c, c1) => new - { - c, - c1 - }).OrderBy(t => t.c1.CustomerID, StringComparer.Ordinal) + (c, c1) => new { c, c1 }).OrderBy(t => t.c1.CustomerID, StringComparer.Ordinal) .Select(t => t.c1), assertOrder: true, entryCount: 91); @@ -2546,11 +2339,7 @@ from c in cs from e in es where c.City == e.City orderby c.CustomerID, e.EmployeeID - select new - { - c, - e - }, + select new { c, e }, assertOrder: true, entryCount: 15); } @@ -2565,11 +2354,7 @@ public virtual Task SelectMany_correlated_subquery_simple(bool isAsync) from c in cs from e in es.Where(e => e.City == c.City) orderby c.CustomerID, e.EmployeeID - select new - { - c, - e - }, + select new { c, e }, assertOrder: true, entryCount: 15); } @@ -2586,18 +2371,10 @@ from c1 in from e1 in (from e2 in es where c1 == e2.City - select new - { - e2.City, - c1 - }).Take(9) + select new { e2.City, c1 }).Take(9) from e2 in (from e3 in es where e1.City == e3.City select c1).Take(9) - select new - { - c1, - e1 - }, + select new { c1, e1 }, e => e.c1 + " " + e.e1.City + " " + e.e1.c1); } @@ -2612,11 +2389,7 @@ from c in cs from e in es where c.City == e.City orderby e.City, c.CustomerID descending - select new - { - c, - e.City - }, + select new { c, e.City }, assertOrder: true, entryCount: 8); } @@ -2711,18 +2484,9 @@ public virtual Task Multiple_joins_Where_Order_Any(bool isAsync) isAsync, (cs, os, ods) => cs.Join( - os, c => c.CustomerID, o => o.CustomerID, (cr, or) => new - { - cr, - or - }) + os, c => c.CustomerID, o => o.CustomerID, (cr, or) => new { cr, or }) .Join( - ods, e => e.or.OrderID, od => od.OrderID, (e, od) => new - { - e.cr, - e.or, - od - }) + ods, e => e.or.OrderID, od => od.OrderID, (e, od) => new { e.cr, e.or, od }) .Where(r => r.cr.City == "London").OrderBy(r => r.cr.CustomerID)); } @@ -2861,7 +2625,9 @@ from e in es.Where(c => c.EmployeeID == NonExistentID).DefaultIfEmpty() public virtual async Task Default_if_empty_top_level_arg(bool isAsync) { Assert.Equal( - CoreStrings.QueryFailed("DefaultIfEmpty( source: Where( source: DbSet, predicate: (c) => c.EmployeeID == 4294967295), defaultValue: (Unhandled parameter: __p_0))", "NavigationExpandingExpressionVisitor"), + CoreStrings.QueryFailed( + "DefaultIfEmpty( source: Where( source: DbSet, predicate: (c) => c.EmployeeID == 4294967295), defaultValue: (Unhandled parameter: __p_0))", + "NavigationExpandingExpressionVisitor"), RemoveNewLines( (await Assert.ThrowsAsync( () => AssertQuery( @@ -2877,7 +2643,9 @@ from e in es.Where(c => c.EmployeeID == NonExistentID).DefaultIfEmpty(new Employ public virtual async Task Default_if_empty_top_level_arg_followed_by_projecting_constant(bool isAsync) { Assert.Equal( - CoreStrings.QueryFailed("DefaultIfEmpty( source: Where( source: DbSet, predicate: (c) => c.EmployeeID == 4294967295), defaultValue: (Unhandled parameter: __p_0))", "NavigationExpandingExpressionVisitor"), + CoreStrings.QueryFailed( + "DefaultIfEmpty( source: Where( source: DbSet, predicate: (c) => c.EmployeeID == 4294967295), defaultValue: (Unhandled parameter: __p_0))", + "NavigationExpandingExpressionVisitor"), RemoveNewLines( (await Assert.ThrowsAsync( () => AssertQueryScalar( @@ -2920,11 +2688,7 @@ public virtual Task SelectMany_customer_orders(bool isAsync) from c in cs from o in os where c.CustomerID == o.CustomerID - select new - { - c.ContactName, - o.OrderID - }, + select new { c.ContactName, o.OrderID }, e => e.OrderID); } @@ -3044,15 +2808,9 @@ public virtual Task OrderBy_anon(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.CustomerID - }).OrderBy(a => a.CustomerID), + c => new { c.CustomerID }).OrderBy(a => a.CustomerID), cs => cs.Select( - c => new - { - c.CustomerID - }).OrderBy(a => a.CustomerID, StringComparer.Ordinal), + c => new { c.CustomerID }).OrderBy(a => a.CustomerID, StringComparer.Ordinal), assertOrder: true); } @@ -3063,15 +2821,9 @@ public virtual Task OrderBy_anon2(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c - }).OrderBy(a => a.c.CustomerID), + c => new { c }).OrderBy(a => a.c.CustomerID), cs => cs.Select( - c => new - { - c - }).OrderBy(a => a.c.CustomerID, StringComparer.Ordinal), + c => new { c }).OrderBy(a => a.c.CustomerID, StringComparer.Ordinal), assertOrder: true, entryCount: 91); } @@ -3096,25 +2848,17 @@ public virtual async Task OrderBy_client_mixed(bool isAsync) public virtual async Task OrderBy_multiple_queries(bool isAsync) { Assert.Equal( - CoreStrings.TranslationFailed("(c) => new Foo{ Bar = c.CustomerID }; (o) => new Foo{ Bar = o.CustomerID }; (c, o) => new TransparentIdentifier( Outer = c, Inner = o)"), + CoreStrings.TranslationFailed( + "(c) => new Foo{ Bar = c.CustomerID }; (o) => new Foo{ Bar = o.CustomerID }; (c, o) => new TransparentIdentifier( Outer = c, Inner = o)"), RemoveNewLines( (await Assert.ThrowsAsync( () => AssertQuery( isAsync, (cs, os) => from c in cs - join o in os on new Foo - { - Bar = c.CustomerID - } equals new Foo - { - Bar = o.CustomerID - } + join o in os on new Foo { Bar = c.CustomerID } equals new Foo { Bar = o.CustomerID } orderby c.IsLondon, o.OrderDate - select new - { - c, o - }))).Message)); + select new { c, o }))).Message)); } [ConditionalTheory] @@ -3271,12 +3015,7 @@ public virtual Task OrderBy_Join(bool isAsync) (cs, os) => from c in cs.OrderBy(c => c.CustomerID) join o in os.OrderBy(o => o.OrderID) on c.CustomerID equals o.CustomerID - select new - { - c.CustomerID, - o.OrderID - }, - assertOrder: false); + select new { c.CustomerID, o.OrderID }); } [ConditionalTheory] @@ -3289,26 +3028,14 @@ public virtual Task OrderBy_SelectMany(bool isAsync) from c in cs.OrderBy(c => c.CustomerID) from o in os.OrderBy(o => o.OrderID).Take(3) where c.CustomerID == o.CustomerID - select new - { - c.ContactName, - o.OrderID - }, + select new { c.ContactName, o.OrderID }, (cs, os) => cs.OrderBy(c => c.CustomerID, StringComparer.Ordinal) .SelectMany( _ => os.OrderBy(o => o.OrderID).Take(3), - (c, o) => new - { - c, - o - }).Where(t => t.c.CustomerID == t.o.CustomerID) + (c, o) => new { c, o }).Where(t => t.c.CustomerID == t.o.CustomerID) .Select( - t => new - { - t.c.ContactName, - t.o.OrderID - }), + t => new { t.c.ContactName, t.o.OrderID }), assertOrder: true); } @@ -3323,11 +3050,7 @@ from c in cs let hasOrders = os.Any(o => o.CustomerID == c.CustomerID) where c.CustomerID.StartsWith("A") orderby c.CustomerID - select new - { - c, - hasOrders - }, + select new { c, hasOrders }, assertOrder: true, entryCount: 4); } @@ -3384,11 +3107,7 @@ public virtual Task SelectMany_Joined(bool isAsync) (cs, os) => from c in cs from o in os.Where(o => o.CustomerID == c.CustomerID) - select new - { - c.ContactName, - o.OrderDate - }, + select new { c.ContactName, o.OrderDate }, e => e.ContactName + " " + e.OrderDate); } @@ -3401,11 +3120,7 @@ public virtual Task SelectMany_Joined_DefaultIfEmpty(bool isAsync) (cs, os) => from c in cs from o in os.Where(o => o.CustomerID == c.CustomerID).DefaultIfEmpty() - select new - { - c.ContactName, - o - }, + select new { c.ContactName, o }, e => e.ContactName + " " + e.o?.OrderID, entryCount: 830); } @@ -3419,11 +3134,7 @@ public virtual Task SelectMany_Joined_Take(bool isAsync) (cs, os) => from c in cs from o in os.Where(o => o.CustomerID == c.CustomerID).Take(4) - select new - { - c.ContactName, - o - }, + select new { c.ContactName, o }, e => e.o.OrderID, entryCount: 342); } @@ -3471,12 +3182,7 @@ public virtual Task Select_null_coalesce_operator(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.CustomerID, - c.CompanyName, - Region = c.Region ?? "ZZ" - }).OrderBy(o => o.Region).ThenBy(o => o.CustomerID), + c => new { c.CustomerID, c.CompanyName, Region = c.Region ?? "ZZ" }).OrderBy(o => o.Region).ThenBy(o => o.CustomerID), assertOrder: true); } @@ -3528,12 +3234,7 @@ public virtual Task Projection_null_coalesce_operator(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.CustomerID, - c.CompanyName, - Region = c.Region ?? "ZZ" - }), + c => new { c.CustomerID, c.CompanyName, Region = c.Region ?? "ZZ" }), e => e.CustomerID); } @@ -3565,12 +3266,7 @@ public virtual Task Select_take_null_coalesce_operator(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.CustomerID, - c.CompanyName, - Region = c.Region ?? "ZZ" - }).OrderBy(c => c.Region).Take(5), + c => new { c.CustomerID, c.CompanyName, Region = c.Region ?? "ZZ" }).OrderBy(c => c.Region).Take(5), e => e.CustomerID); } @@ -3581,12 +3277,7 @@ public virtual Task Select_take_skip_null_coalesce_operator(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.CustomerID, - c.CompanyName, - Region = c.Region ?? "ZZ" - }).OrderBy(c => c.Region).Take(10).Skip(5), + c => new { c.CustomerID, c.CompanyName, Region = c.Region ?? "ZZ" }).OrderBy(c => c.Region).Take(10).Skip(5), e => e.CustomerID); } @@ -3597,12 +3288,7 @@ public virtual Task Select_take_skip_null_coalesce_operator2(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.CustomerID, - c.CompanyName, - c.Region - }).OrderBy(c => c.Region ?? "ZZ").Take(10).Skip(5), + c => new { c.CustomerID, c.CompanyName, c.Region }).OrderBy(c => c.Region ?? "ZZ").Take(10).Skip(5), e => e.CustomerID); } @@ -3833,7 +3519,7 @@ public virtual void Select_Where_Subquery_Equality() { var orders = (from o in context.Orders.OrderBy(o => o.OrderID).Take(1) - // ReSharper disable once UseMethodAny.0 + // ReSharper disable once UseMethodAny.0 where (from od in context.OrderDetails.OrderBy(od => od.OrderID).Take(2) where (from c in context.Set() where c.CustomerID == o.CustomerID @@ -4128,11 +3814,7 @@ public virtual void Select_bitwise_or() using (var context = CreateContext()) { var query = context.Customers.OrderBy(c => c.CustomerID).Select( - c => new - { - c.CustomerID, - Value = c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" - }).ToList(); + c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" }).ToList(); Assert.All(query.Take(2), t => Assert.True(t.Value)); Assert.All(query.Skip(2), t => Assert.False(t.Value)); @@ -4146,11 +3828,8 @@ public virtual void Select_bitwise_or_multiple() { var query = context.Customers.OrderBy(c => c.CustomerID) .Select( - c => new - { - c.CustomerID, - Value = c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" | c.CustomerID == "ANTON" - }).ToList(); + c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" | c.CustomerID == "ANTON" }) + .ToList(); Assert.All(query.Take(3), t => Assert.True(t.Value)); Assert.All(query.Skip(3), t => Assert.False(t.Value)); @@ -4163,11 +3842,7 @@ public virtual void Select_bitwise_and() using (var context = CreateContext()) { var query = context.Customers.OrderBy(c => c.CustomerID).Select( - c => new - { - c.CustomerID, - Value = c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" - }).ToList(); + c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" }).ToList(); Assert.All(query, t => Assert.False(t.Value)); } @@ -4180,11 +3855,8 @@ public virtual void Select_bitwise_and_or() { var query = context.Customers.OrderBy(c => c.CustomerID) .Select( - c => new - { - c.CustomerID, - Value = c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" | c.CustomerID == "ANTON" - }).ToList(); + c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" | c.CustomerID == "ANTON" }) + .ToList(); Assert.All(query.Where(c => c.CustomerID != "ANTON"), t => Assert.False(t.Value)); } @@ -4239,11 +3911,8 @@ public virtual void Select_bitwise_or_with_logical_or() using (var context = CreateContext()) { var query = context.Customers.OrderBy(c => c.CustomerID).Select( - c => new - { - c.CustomerID, - Value = c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" || c.CustomerID == "ANTON" - }).ToList(); + c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" | c.CustomerID == "ANATR" || c.CustomerID == "ANTON" }) + .ToList(); Assert.All(query.Take(3), t => Assert.True(t.Value)); Assert.All(query.Skip(3), t => Assert.False(t.Value)); @@ -4256,11 +3925,8 @@ public virtual void Select_bitwise_and_with_logical_and() using (var context = CreateContext()) { var query = context.Customers.OrderBy(c => c.CustomerID).Select( - c => new - { - c.CustomerID, - Value = c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" && c.CustomerID == "ANTON" - }).ToList(); + c => new { c.CustomerID, Value = c.CustomerID == "ALFKI" & c.CustomerID == "ANATR" && c.CustomerID == "ANTON" }) + .ToList(); Assert.All(query, t => Assert.False(t.Value)); } @@ -4276,10 +3942,7 @@ public virtual Task Handle_materialization_properly_when_more_than_two_query_sou from c in cs.OrderBy(c => c.CustomerID) from o in os from e in es - select new - { - c - }, + select new { c }, entryCount: 1); } @@ -4414,11 +4077,7 @@ public virtual Task Subquery_member_pushdown_does_not_change_original_subquery_m os.OrderBy(o => o.OrderID) .Take(3) .Select( - o => new - { - OrderId = o.OrderID, - cs.SingleOrDefault(c => c.CustomerID == o.CustomerID).City - }) + o => new { OrderId = o.OrderID, cs.SingleOrDefault(c => c.CustomerID == o.CustomerID).City }) .OrderBy(o => o.City), assertOrder: true); } @@ -4450,10 +4109,7 @@ public virtual Task Query_expression_with_to_string_and_contains(bool isAsync) isAsync, os => os.Where(o => o.OrderDate != null && o.EmployeeID.Value.ToString().Contains("10")) .Select( - o => new Order - { - CustomerID = o.CustomerID - }), + o => new Order { CustomerID = o.CustomerID }), e => e.CustomerID); } @@ -4465,10 +4121,7 @@ public virtual Task Select_expression_other_to_string(bool isAsync) isAsync, os => os.Where(o => o.OrderDate != null) .Select( - o => new Order - { - ShipName = o.OrderDate.Value.ToString() - }), + o => new Order { ShipName = o.OrderDate.Value.ToString() }), e => e.ShipName); } @@ -4480,10 +4133,7 @@ public virtual Task Select_expression_long_to_string(bool isAsync) isAsync, os => os.Where(o => o.OrderDate != null) .Select( - o => new Order - { - ShipName = ((long)o.OrderID).ToString() - }), + o => new Order { ShipName = ((long)o.OrderID).ToString() }), e => e.ShipName); } @@ -4495,10 +4145,7 @@ public virtual Task Select_expression_int_to_string(bool isAsync) isAsync, os => os.Where(o => o.OrderDate != null) .Select( - o => new Order - { - ShipName = o.OrderID.ToString() - }), + o => new Order { ShipName = o.OrderID.ToString() }), e => e.ShipName); } @@ -4510,20 +4157,14 @@ await AssertQuery( isAsync, os => os.Where(o => o.OrderDate != null) .Select( - o => new Order - { - ShipName = o.OrderID.ToString("X") - }), + o => new Order { ShipName = o.OrderID.ToString("X") }), e => e.ShipName); await AssertQuery( isAsync, os => os.Where(o => o.OrderDate != null) .Select( - o => new Order - { - ShipName = o.OrderID.ToString(new CultureInfo("en-US")) - }), + o => new Order { ShipName = o.OrderID.ToString(new CultureInfo("en-US")) }), e => e.ShipName); } @@ -4535,10 +4176,7 @@ public virtual Task Select_expression_date_add_year(bool isAsync) isAsync, os => os.Where(o => o.OrderDate != null) .Select( - o => new Order - { - OrderDate = o.OrderDate.Value.AddYears(1) - }), + o => new Order { OrderDate = o.OrderDate.Value.AddYears(1) }), e => e.OrderDate); } @@ -4550,10 +4188,7 @@ public virtual Task Select_expression_datetime_add_month(bool isAsync) isAsync, os => os.Where(o => o.OrderDate != null) .Select( - o => new Order - { - OrderDate = o.OrderDate.Value.AddMonths(1) - }), + o => new Order { OrderDate = o.OrderDate.Value.AddMonths(1) }), e => e.OrderDate); } @@ -4565,10 +4200,7 @@ public virtual Task Select_expression_datetime_add_hour(bool isAsync) isAsync, os => os.Where(o => o.OrderDate != null) .Select( - o => new Order - { - OrderDate = o.OrderDate.Value.AddHours(1) - }), + o => new Order { OrderDate = o.OrderDate.Value.AddHours(1) }), e => e.OrderDate); } @@ -4580,10 +4212,7 @@ public virtual Task Select_expression_datetime_add_minute(bool isAsync) isAsync, os => os.Where(o => o.OrderDate != null) .Select( - o => new Order - { - OrderDate = o.OrderDate.Value.AddMinutes(1) - }), + o => new Order { OrderDate = o.OrderDate.Value.AddMinutes(1) }), e => e.OrderDate); } @@ -4595,10 +4224,7 @@ public virtual Task Select_expression_datetime_add_second(bool isAsync) isAsync, os => os.Where(o => o.OrderDate != null) .Select( - o => new Order - { - OrderDate = o.OrderDate.Value.AddSeconds(1) - }), + o => new Order { OrderDate = o.OrderDate.Value.AddSeconds(1) }), e => e.OrderDate); } @@ -4610,10 +4236,7 @@ public virtual Task Select_expression_datetime_add_ticks(bool isAsync) isAsync, os => os.Where(o => o.OrderDate != null) .Select( - o => new Order - { - OrderDate = o.OrderDate.Value.AddTicks(TimeSpan.TicksPerMillisecond) - }), + o => new Order { OrderDate = o.OrderDate.Value.AddTicks(TimeSpan.TicksPerMillisecond) }), e => e.OrderDate); } @@ -4625,10 +4248,7 @@ public virtual Task Select_expression_date_add_milliseconds_above_the_range(bool isAsync, os => os.Where(o => o.OrderDate != null) .Select( - o => new Order - { - OrderDate = o.OrderDate.Value.AddMilliseconds(1000000000000) - }), + o => new Order { OrderDate = o.OrderDate.Value.AddMilliseconds(1000000000000) }), e => e.OrderDate); } @@ -4640,10 +4260,7 @@ public virtual Task Select_expression_date_add_milliseconds_below_the_range(bool isAsync, os => os.Where(o => o.OrderDate != null) .Select( - o => new Order - { - OrderDate = o.OrderDate.Value.AddMilliseconds(-1000000000000) - })); + o => new Order { OrderDate = o.OrderDate.Value.AddMilliseconds(-1000000000000) })); } [ConditionalTheory] @@ -4704,11 +4321,7 @@ public virtual Task DefaultIfEmpty_in_subquery(bool isAsync) (from c in cs from o in os.Where(o => o.CustomerID == c.CustomerID).DefaultIfEmpty() where o != null - select new - { - c.CustomerID, - o.OrderID - }), + select new { c.CustomerID, o.OrderID }), e => e.CustomerID + " " + e.OrderID); } @@ -4721,11 +4334,7 @@ public virtual Task DefaultIfEmpty_in_subquery_not_correlated(bool isAsync) (cs, os) => (from c in cs from o in os.Where(o => o.OrderID > 15000).DefaultIfEmpty() - select new - { - c.CustomerID, - OrderID = o != null ? o.OrderID : (int?)null - }), + select new { c.CustomerID, OrderID = o != null ? o.OrderID : (int?)null }), e => e.CustomerID + " " + e.OrderID); } @@ -4741,12 +4350,7 @@ from o1 in os.Where(o => o.OrderID > 15000).DefaultIfEmpty() from o2 in os.Where(o => o.CustomerID == c.CustomerID).DefaultIfEmpty() where o1 != null && o2 != null orderby o1.OrderID, o2.OrderDate - select new - { - c.CustomerID, - o1.OrderID, - o2.OrderDate - }), + select new { c.CustomerID, o1.OrderID, o2.OrderDate }), e => e.CustomerID + " " + e.OrderID); } @@ -4915,11 +4519,7 @@ public virtual Task No_orderby_added_for_fully_translated_manually_constructed_L join e2 in es on e1.EmployeeID equals e2.ReportsTo into grouping from e2 in grouping.DefaultIfEmpty() #pragma warning disable IDE0031 // Use null propagation - select new - { - City1 = e1.City, - City2 = e2 != null ? e2.City : null - }, + select new { City1 = e1.City, City2 = e2 != null ? e2.City : null }, #pragma warning restore IDE0031 // Use null propagation e => e.City1 + " " + e.City2); } @@ -4935,11 +4535,7 @@ from o in os join c in cs on o.CustomerID equals c.CustomerID into grouping from c in ClientDefaultIfEmpty(grouping) #pragma warning disable IDE0031 // Use null propagation - select new - { - Id1 = o.CustomerID, - Id2 = c != null ? c.CustomerID : null - }, + select new { Id1 = o.CustomerID, Id2 = c != null ? c.CustomerID : null }, #pragma warning restore IDE0031 // Use null propagation e => e.Id1 + " " + e.Id2); } @@ -4953,22 +4549,10 @@ public virtual Task No_orderby_added_for_client_side_GroupJoin_dependent_to_prin isAsync, (cs, os) => from o in os - join c in cs on new - { - o.CustomerID, - o.OrderID - } equals new - { - c.CustomerID, - OrderID = 10000 - } into grouping + join c in cs on new { o.CustomerID, o.OrderID } equals new { c.CustomerID, OrderID = 10000 } into grouping from c in ClientDefaultIfEmpty(grouping) #pragma warning disable IDE0031 // Use null propagation - select new - { - Id1 = o.CustomerID, - Id2 = c != null ? c.CustomerID : null - }, + select new { Id1 = o.CustomerID, Id2 = c != null ? c.CustomerID : null }, #pragma warning restore IDE0031 // Use null propagation e => e.Id1 + " " + e.Id2); } @@ -4982,22 +4566,10 @@ public virtual Task No_orderby_added_for_client_side_GroupJoin_dependent_to_prin isAsync, (cs, os) => from o in os - join c in cs on new - { - o.OrderID, - o.CustomerID - } equals new - { - OrderID = 10000, - c.CustomerID - } into grouping + join c in cs on new { o.OrderID, o.CustomerID } equals new { OrderID = 10000, c.CustomerID } into grouping from c in ClientDefaultIfEmpty(grouping) #pragma warning disable IDE0031 // Use null propagation - select new - { - Id1 = o.CustomerID, - Id2 = c != null ? c.CustomerID : null - }, + select new { Id1 = o.CustomerID, Id2 = c != null ? c.CustomerID : null }, #pragma warning restore IDE0031 // Use null propagation e => e.Id1 + " " + e.Id2); } @@ -5012,11 +4584,7 @@ public virtual Task Orderby_added_for_client_side_GroupJoin_principal_to_depende join e2 in es on e1.EmployeeID equals e2.ReportsTo into grouping from e2 in ClientDefaultIfEmpty(grouping) #pragma warning disable IDE0031 // Use null propagation - select new - { - City1 = e1.City, - City2 = e2 != null ? e2.City : null - }, + select new { City1 = e1.City, City2 = e2 != null ? e2.City : null }, #pragma warning restore IDE0031 // Use null propagation e => e.City1 + " " + e.City2); } @@ -5060,10 +4628,7 @@ public virtual Task Anonymous_member_distinct_where(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.CustomerID - }).Distinct().Where(n => n.CustomerID == "ALFKI"), + c => new { c.CustomerID }).Distinct().Where(n => n.CustomerID == "ALFKI"), e => e.CustomerID); } @@ -5074,10 +4639,7 @@ public virtual Task Anonymous_member_distinct_orderby(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - c.CustomerID - }).Distinct().OrderBy(n => n.CustomerID), + c => new { c.CustomerID }).Distinct().OrderBy(n => n.CustomerID), assertOrder: true); } @@ -5088,15 +4650,9 @@ public virtual Task Anonymous_member_distinct_result(bool isAsync) return AssertSingleResult( isAsync, syncQuery: cs => cs.Select( - c => new - { - c.CustomerID - }).Distinct().Count(n => n.CustomerID.StartsWith("A")), + c => new { c.CustomerID }).Distinct().Count(n => n.CustomerID.StartsWith("A")), asyncQuery: cs => cs.Select( - c => new - { - c.CustomerID - }).Distinct().CountAsync(n => n.CustomerID.StartsWith("A"))); + c => new { c.CustomerID }).Distinct().CountAsync(n => n.CustomerID.StartsWith("A"))); } [ConditionalTheory] @@ -5106,10 +4662,7 @@ public virtual Task Anonymous_complex_distinct_where(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - A = c.CustomerID + c.City - }).Distinct().Where(n => n.A == "ALFKIBerlin"), + c => new { A = c.CustomerID + c.City }).Distinct().Where(n => n.A == "ALFKIBerlin"), e => e.A); } @@ -5120,10 +4673,7 @@ public virtual Task Anonymous_complex_distinct_orderby(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - A = c.CustomerID + c.City - }).Distinct().OrderBy(n => n.A), + c => new { A = c.CustomerID + c.City }).Distinct().OrderBy(n => n.A), assertOrder: true); } @@ -5134,15 +4684,9 @@ public virtual Task Anonymous_complex_distinct_result(bool isAsync) return AssertSingleResult( isAsync, syncQuery: cs => cs.Select( - c => new - { - A = c.CustomerID + c.City - }).Distinct().Count(n => n.A.StartsWith("A")), + c => new { A = c.CustomerID + c.City }).Distinct().Count(n => n.A.StartsWith("A")), asyncQuery: cs => cs.Select( - c => new - { - A = c.CustomerID + c.City - }).Distinct().CountAsync(n => n.A.StartsWith("A"))); + c => new { A = c.CustomerID + c.City }).Distinct().CountAsync(n => n.A.StartsWith("A"))); } [ConditionalTheory] @@ -5152,10 +4696,7 @@ public virtual Task Anonymous_complex_orderby(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new - { - A = c.CustomerID + c.City - }).OrderBy(n => n.A), + c => new { A = c.CustomerID + c.City }).OrderBy(n => n.A), assertOrder: true); } @@ -5166,10 +4707,7 @@ public virtual Task Anonymous_subquery_orderby(bool isAsync) return AssertQuery( isAsync, cs => cs.Where(c => c.Orders.Count > 1).Select( - c => new - { - A = c.Orders.OrderByDescending(o => o.OrderID).FirstOrDefault().OrderDate - }).OrderBy(n => n.A), + c => new { A = c.Orders.OrderByDescending(o => o.OrderID).FirstOrDefault().OrderDate }).OrderBy(n => n.A), assertOrder: true); } @@ -5205,10 +4743,7 @@ public virtual Task DTO_member_distinct_where(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new DTO - { - Property = c.CustomerID - }).Distinct().Where(n => n.Property == "ALFKI"), + c => new DTO { Property = c.CustomerID }).Distinct().Where(n => n.Property == "ALFKI"), e => e.Property, elementAsserter: (e, a) => Assert.Equal(e.Property, a.Property)); } @@ -5220,10 +4755,7 @@ public virtual Task DTO_member_distinct_orderby(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new DTO - { - Property = c.CustomerID - }).Distinct().OrderBy(n => n.Property), + c => new DTO { Property = c.CustomerID }).Distinct().OrderBy(n => n.Property), assertOrder: true, elementAsserter: (e, a) => Assert.Equal(e.Property, a.Property)); } @@ -5235,15 +4767,9 @@ public virtual Task DTO_member_distinct_result(bool isAsync) return AssertSingleResult( isAsync, syncQuery: cs => cs.Select( - c => new DTO - { - Property = c.CustomerID - }).Distinct().Count(n => n.Property.StartsWith("A")), + c => new DTO { Property = c.CustomerID }).Distinct().Count(n => n.Property.StartsWith("A")), asyncQuery: cs => cs.Select( - c => new DTO - { - Property = c.CustomerID - }).Distinct().CountAsync(n => n.Property.StartsWith("A"))); + c => new DTO { Property = c.CustomerID }).Distinct().CountAsync(n => n.Property.StartsWith("A"))); } [ConditionalTheory] @@ -5253,10 +4779,7 @@ public virtual Task DTO_complex_distinct_where(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new DTO - { - Property = c.CustomerID + c.City - }).Distinct().Where(n => n.Property == "ALFKIBerlin"), + c => new DTO { Property = c.CustomerID + c.City }).Distinct().Where(n => n.Property == "ALFKIBerlin"), e => e.Property, elementAsserter: (e, a) => Assert.Equal(e.Property, a.Property)); } @@ -5268,10 +4791,7 @@ public virtual Task DTO_complex_distinct_orderby(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new DTO - { - Property = c.CustomerID + c.City - }).Distinct().OrderBy(n => n.Property), + c => new DTO { Property = c.CustomerID + c.City }).Distinct().OrderBy(n => n.Property), assertOrder: true, elementAsserter: (e, a) => Assert.Equal(e.Property, a.Property)); } @@ -5283,15 +4803,9 @@ public virtual Task DTO_complex_distinct_result(bool isAsync) return AssertSingleResult( isAsync, syncQuery: cs => cs.Select( - c => new DTO - { - Property = c.CustomerID + c.City - }).Distinct().Count(n => n.Property.StartsWith("A")), + c => new DTO { Property = c.CustomerID + c.City }).Distinct().Count(n => n.Property.StartsWith("A")), asyncQuery: cs => cs.Select( - c => new DTO - { - Property = c.CustomerID + c.City - }).Distinct().CountAsync(n => n.Property.StartsWith("A"))); + c => new DTO { Property = c.CustomerID + c.City }).Distinct().CountAsync(n => n.Property.StartsWith("A"))); } [ConditionalTheory] @@ -5301,10 +4815,7 @@ public virtual Task DTO_complex_orderby(bool isAsync) return AssertQuery( isAsync, cs => cs.Select( - c => new DTO - { - Property = c.CustomerID + c.City - }).OrderBy(n => n.Property), + c => new DTO { Property = c.CustomerID + c.City }).OrderBy(n => n.Property), assertOrder: true, elementAsserter: (e, a) => Assert.Equal(e.Property, a.Property)); } @@ -5316,10 +4827,8 @@ public virtual Task DTO_subquery_orderby(bool isAsync) return AssertQuery( isAsync, cs => cs.Where(c => c.Orders.Count > 1).Select( - c => new DTO - { - Property = c.Orders.OrderByDescending(o => o.OrderID).FirstOrDefault().OrderDate - }).OrderBy(n => n.Property), + c => new DTO { Property = c.Orders.OrderByDescending(o => o.OrderID).FirstOrDefault().OrderDate }) + .OrderBy(n => n.Property), assertOrder: true, elementAsserter: (e, a) => Assert.Equal(e.Property, a.Property)); } @@ -5648,11 +5157,7 @@ from c2 in cs2 where c1.CustomerID.StartsWith("ALFKI") where c1.Equals(c2) orderby c1.CustomerID - select new - { - Id1 = c1.CustomerID, - Id2 = c2.CustomerID - }); + select new { Id1 = c1.CustomerID, Id2 = c2.CustomerID }); } [ConditionalTheory] @@ -5693,11 +5198,7 @@ from o2 in os2 where o1.CustomerID.StartsWith("A") where o1.Customer.Equals(o2.Customer) orderby o1.OrderID, o2.OrderID - select new - { - Id1 = o1.OrderID, - Id2 = o2.OrderID - }, + select new { Id1 = o1.OrderID, Id2 = o2.OrderID }, e => e.Id1 + " " + e.Id2); } @@ -5713,11 +5214,7 @@ from o2 in os2 where o1.CustomerID.StartsWith("A") where Equals(o1.Customer, o2.Customer) orderby o1.OrderID, o2.OrderID - select new - { - Id1 = o1.OrderID, - Id2 = o2.OrderID - }, + select new { Id1 = o1.OrderID, Id2 = o2.OrderID }, e => e.Id1 + " " + e.Id2); } @@ -5732,11 +5229,7 @@ from c in cs from o in os where c.CustomerID == "ALFKI" where Equals(c, o) - select new - { - Id1 = c.CustomerID, - Id2 = o.OrderID - }, + select new { Id1 = c.CustomerID, Id2 = o.OrderID }, e => e.Id1 + " " + e.Id2); } @@ -5751,11 +5244,7 @@ from c in cs from o in os where c.CustomerID == "ALFKI" where c.Orders.Equals(o.OrderDetails) - select new - { - Id1 = c.CustomerID, - Id2 = o.OrderID - }, + select new { Id1 = c.CustomerID, Id2 = o.OrderID }, e => e.Id1 + " " + e.Id2); } @@ -5780,11 +5269,7 @@ public virtual Task Comparing_collection_navigation_to_null_complex(bool isAsync .OrderBy(od => od.OrderID) .ThenBy(od => od.ProductID) .Select( - od => new - { - od.ProductID, - od.OrderID - }), + od => new { od.ProductID, od.OrderID }), e => e.ProductID + " " + e.OrderID); } @@ -5811,11 +5296,7 @@ from c1 in cs1 from c2 in cs2 where c1.CustomerID == "ALFKI" && c2.CustomerID == "ALFKI" where c1.Orders == c2.Orders - select new - { - Id1 = c1.CustomerID, - Id2 = c2.CustomerID - }, + select new { Id1 = c1.CustomerID, Id2 = c2.CustomerID }, e => e.Id1 + " " + e.Id2); } @@ -5830,11 +5311,7 @@ from c1 in cs1 from c2 in cs2 where c1.CustomerID == "ALFKI" && c2.CustomerID == "ALFKI" where Equals(c1.Orders, c2.Orders) - select new - { - Id1 = c1.CustomerID, - Id2 = c2.CustomerID - }, + select new { Id1 = c1.CustomerID, Id2 = c2.CustomerID }, e => e.Id1 + " " + e.Id2); } @@ -5850,11 +5327,7 @@ from c in cs from o in os where c.Orders == o.Customer.Orders orderby c.CustomerID, o.OrderID - select new - { - Id1 = c.CustomerID, - Id2 = o.OrderID - }, + select new { Id1 = c.CustomerID, Id2 = o.OrderID }, e => e.Id1 + " " + e.Id2); } @@ -5899,11 +5372,7 @@ public virtual Task Complex_nested_query_doesnt_try_binding_to_grandparent_when_ { c.CustomerID, OuterOrders = c.Orders.Select( - o => new - { - InnerOrder = c.Orders.Count(), - Id = c.CustomerID - }).ToList() + o => new { InnerOrder = c.Orders.Count(), Id = c.CustomerID }).ToList() }), elementAsserter: (e, a) => { @@ -5921,11 +5390,7 @@ public virtual Task Complex_nested_query_properly_binds_to_grandparent_when_pare cs => cs.Where(c => c.CustomerID == "ALFKI") .Select( - c => new - { - c.CustomerID, - OuterOrders = c.Orders.Count(o => c.Orders.Count() > 0) - })); + c => new { c.CustomerID, OuterOrders = c.Orders.Count(o => c.Orders.Count() > 0) })); } [ConditionalTheory] @@ -5936,10 +5401,7 @@ public virtual Task OrderBy_Dto_projection_skip_take(bool isAsync) isAsync, cs => cs.OrderBy(c => c.CustomerID) .Select( - c => new - { - Id = c.CustomerID - }) + c => new { Id = c.CustomerID }) .Skip(5) .Take(10), elementSorter: e => e.Id); @@ -5953,20 +5415,13 @@ public virtual void Streaming_chained_sync_query() var results = (context.Customers .Select( - c => new - { - c.CustomerID, - Orders = context.Orders.Where(o => o.Customer.CustomerID == c.CustomerID) - }).ToList()) + c => new { c.CustomerID, Orders = context.Orders.Where(o => o.Customer.CustomerID == c.CustomerID) }).ToList()) .Select( x => new { Orders = x.Orders .GroupJoin( - new[] { "ALFKI" }, y => x.CustomerID, y => y, (h, id) => new - { - h.Customer - }) + new[] { "ALFKI" }, y => x.CustomerID, y => y, (h, id) => new { h.Customer }) }) .ToList(); @@ -6052,10 +5507,7 @@ from od in o.OrderDetails where od.Quantity < 10 select od.Quantity where details.Any() - select new - { - Count = details.Count() - }); + select new { Count = details.Count() }); } [ConditionalTheory] @@ -6067,11 +5519,7 @@ public virtual Task Let_entity_equality_to_null(bool isAsync) cs => from c in cs.Where(c => c.CustomerID.StartsWith("A")) let o = c.Orders.OrderBy(e => e.OrderDate).FirstOrDefault() where o != null - select new - { - c.CustomerID, - o.OrderDate - }); + select new { c.CustomerID, o.OrderDate }); } [ConditionalTheory] @@ -6155,7 +5603,8 @@ select g.OrderByDescending(x => x.OrderID), [MemberData(nameof(IsAsyncData))] public virtual async Task Client_OrderBy_GroupBy_Group_ordering_works(bool isAsync) { - Assert.StartsWith("The LINQ expression ", + Assert.StartsWith( + "The LINQ expression ", RemoveNewLines( (await Assert.ThrowsAsync( () => AssertQuery( @@ -6171,7 +5620,6 @@ select g.OrderByDescending(x => x.OrderID), .Message)); } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Collection_navigation_equal_to_null_for_subquery(bool isAsync) diff --git a/test/EFCore.Specification.Tests/Query/SpatialQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/SpatialQueryTestBase.cs index a4a66a88018..e77dc097205 100644 --- a/test/EFCore.Specification.Tests/Query/SpatialQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/SpatialQueryTestBase.cs @@ -195,11 +195,7 @@ public virtual Task Contains(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Contains = e.Polygon == null ? (bool?)null : e.Polygon.Contains(point) - }), + e => new { e.Id, Contains = e.Polygon == null ? (bool?)null : e.Polygon.Contains(point) }), elementSorter: x => x.Id); } @@ -225,11 +221,7 @@ public virtual Task IGeometryCollection_Count(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Count = e.MultiLineString == null ? (int?)null : e.MultiLineString.Count - }), + e => new { e.Id, Count = e.MultiLineString == null ? (int?)null : e.MultiLineString.Count }), elementSorter: x => x.Id); } @@ -240,11 +232,7 @@ public virtual Task LineString_Count(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Count = e.LineString == null ? (int?)null : ((LineString)e.LineString).Count - }), + e => new { e.Id, Count = e.LineString == null ? (int?)null : e.LineString.Count }), elementSorter: x => x.Id); } @@ -255,22 +243,14 @@ public virtual Task CoveredBy(bool isAsync) var polygon = Fixture.GeometryFactory.CreatePolygon( new[] { - new Coordinate(-1, -1), - new Coordinate(2, -1), - new Coordinate(2, 2), - new Coordinate(-1, 2), - new Coordinate(-1, -1) + new Coordinate(-1, -1), new Coordinate(2, -1), new Coordinate(2, 2), new Coordinate(-1, 2), new Coordinate(-1, -1) }); return AssertQuery( isAsync, es => es .Select( - e => new - { - e.Id, - CoveredBy = e.Point == null ? (bool?)null : e.Point.CoveredBy(polygon) - }), + e => new { e.Id, CoveredBy = e.Point == null ? (bool?)null : e.Point.CoveredBy(polygon) }), elementSorter: x => x.Id); } @@ -291,20 +271,12 @@ public virtual Task Covers(bool isAsync) public virtual Task Crosses(bool isAsync) { var lineString = Fixture.GeometryFactory.CreateLineString( - new[] - { - new Coordinate(0.5, -0.5), - new Coordinate(0.5, 0.5) - }); + new[] { new Coordinate(0.5, -0.5), new Coordinate(0.5, 0.5) }); return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Crosses = e.LineString == null ? (bool?)null : e.LineString.Crosses(lineString) - }), + e => new { e.Id, Crosses = e.LineString == null ? (bool?)null : e.LineString.Crosses(lineString) }), elementSorter: x => x.Id); } @@ -313,22 +285,12 @@ public virtual Task Crosses(bool isAsync) public virtual Task Difference(bool isAsync) { var polygon = Fixture.GeometryFactory.CreatePolygon( - new[] - { - new Coordinate(0, 0), - new Coordinate(1, 0), - new Coordinate(1, 1), - new Coordinate(0, 0) - }); + new[] { new Coordinate(0, 0), new Coordinate(1, 0), new Coordinate(1, 1), new Coordinate(0, 0) }); return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Difference = e.Polygon == null ? null : e.Polygon.Difference(polygon) - }), + e => new { e.Id, Difference = e.Polygon == null ? null : e.Polygon.Difference(polygon) }), elementSorter: x => x.Id, elementAsserter: (e, a) => { @@ -356,11 +318,7 @@ public virtual Task Disjoint(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Disjoint = e.Polygon == null ? (bool?)null : e.Polygon.Disjoint(point) - }), + e => new { e.Id, Disjoint = e.Polygon == null ? (bool?)null : e.Polygon.Disjoint(point) }), elementSorter: x => x.Id); } @@ -373,11 +331,7 @@ public virtual Task Distance(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Distance = e.Point == null ? (double?)null : e.Point.Distance(point) - }), + e => new { e.Id, Distance = e.Point == null ? (double?)null : e.Point.Distance(point) }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -403,11 +357,7 @@ public virtual Task Distance_geometry(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Distance = e.Geometry == null ? (double?)null : e.Geometry.Distance(point) - }), + e => new { e.Id, Distance = e.Geometry == null ? (double?)null : e.Geometry.Distance(point) }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -431,11 +381,7 @@ public virtual Task Distance_constant(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Distance = e.Point == null ? (double?)null : e.Point.Distance(new Point(0, 1)) - }), + e => new { e.Id, Distance = e.Point == null ? (double?)null : e.Point.Distance(new Point(0, 1)) }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -459,11 +405,7 @@ public virtual Task Distance_constant_srid_4326(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Distance = e.Point == null ? (double?)null : e.Point.Distance(new Point(1, 1) { SRID = 4326 }) - }), + e => new { e.Id, Distance = e.Point == null ? (double?)null : e.Point.Distance(new Point(1, 1) { SRID = 4326 }) }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -487,11 +429,7 @@ public virtual Task Distance_constant_lhs(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Distance = e.Point == null ? (double?)null : new Point(0, 1).Distance(e.Point) - }), + e => new { e.Id, Distance = e.Point == null ? (double?)null : new Point(0, 1).Distance(e.Point) }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -517,11 +455,7 @@ public virtual Task Distance_on_converted_geometry_type(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Distance = e.Location.Distance(point) - }), + e => new { e.Id, Distance = e.Location.Distance(point) }), elementSorter: e => e.Id, elementAsserter: (e, a) => { Assert.Equal(e.Id, a.Id); }); } @@ -535,11 +469,7 @@ public virtual Task Distance_on_converted_geometry_type_lhs(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Distance = point.Distance(e.Location) - }), + e => new { e.Id, Distance = point.Distance(e.Location) }), elementSorter: e => e.Id, elementAsserter: (e, a) => { Assert.Equal(e.Id, a.Id); }); } @@ -551,11 +481,7 @@ public virtual Task Distance_on_converted_geometry_type_constant(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Distance = e.Location.Distance(new GeoPoint(1, 0)) - }), + e => new { e.Id, Distance = e.Location.Distance(new GeoPoint(1, 0)) }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -579,11 +505,7 @@ public virtual Task Distance_on_converted_geometry_type_constant_lhs(bool isAsyn return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Distance = new GeoPoint(1, 0).Distance(e.Location) - }), + e => new { e.Id, Distance = new GeoPoint(1, 0).Distance(e.Location) }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -635,11 +557,7 @@ public virtual Task EqualsTopologically(bool isAsync) isAsync, es => es .Select( - e => new - { - e.Id, - EqualsTopologically = e.Point == null ? (bool?)null : e.Point.EqualsTopologically(point) - }), + e => new { e.Id, EqualsTopologically = e.Point == null ? (bool?)null : e.Point.EqualsTopologically(point) }), elementSorter: x => x.Id); } @@ -671,11 +589,7 @@ public virtual Task GetGeometryN(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Geometry0 = e.MultiLineString == null ? null : e.MultiLineString.GetGeometryN(0) - }), + e => new { e.Id, Geometry0 = e.MultiLineString == null ? null : e.MultiLineString.GetGeometryN(0) }), elementSorter: x => x.Id); } @@ -713,12 +627,7 @@ public virtual Task InteriorPoint(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - InteriorPoint = e.Polygon == null ? null : e.Polygon.InteriorPoint, - e.Polygon - }), + e => new { e.Id, InteriorPoint = e.Polygon == null ? null : e.Polygon.InteriorPoint, e.Polygon }), elementSorter: x => x.Id, elementAsserter: (e, a) => { @@ -740,22 +649,12 @@ public virtual Task InteriorPoint(bool isAsync) public virtual Task Intersection(bool isAsync) { var polygon = Fixture.GeometryFactory.CreatePolygon( - new[] - { - new Coordinate(0, 0), - new Coordinate(1, 0), - new Coordinate(1, 1), - new Coordinate(0, 0) - }); + new[] { new Coordinate(0, 0), new Coordinate(1, 0), new Coordinate(1, 1), new Coordinate(0, 0) }); return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Intersection = e.Polygon == null ? null : e.Polygon.Intersection(polygon) - }), + e => new { e.Id, Intersection = e.Polygon == null ? null : e.Polygon.Intersection(polygon) }), elementSorter: x => x.Id, elementAsserter: (e, a) => { @@ -769,20 +668,12 @@ public virtual Task Intersection(bool isAsync) public virtual Task Intersects(bool isAsync) { var lineString = Fixture.GeometryFactory.CreateLineString( - new[] - { - new Coordinate(0.5, -0.5), - new Coordinate(0.5, 0.5) - }); + new[] { new Coordinate(0.5, -0.5), new Coordinate(0.5, 0.5) }); return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Intersects = e.LineString == null ? (bool?)null : e.LineString.Intersects(lineString) - }), + e => new { e.Id, Intersects = e.LineString == null ? (bool?)null : e.LineString.Intersects(lineString) }), elementSorter: x => x.Id); } @@ -793,11 +684,7 @@ public virtual Task ICurve_IsClosed(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - IsClosed = e.LineString == null ? (bool?)null : e.LineString.IsClosed - }), + e => new { e.Id, IsClosed = e.LineString == null ? (bool?)null : e.LineString.IsClosed }), elementSorter: x => x.Id); } @@ -808,11 +695,7 @@ public virtual Task IMultiCurve_IsClosed(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - IsClosed = e.MultiLineString == null ? (bool?)null : e.MultiLineString.IsClosed - }), + e => new { e.Id, IsClosed = e.MultiLineString == null ? (bool?)null : e.MultiLineString.IsClosed }), elementSorter: x => x.Id); } @@ -823,11 +706,7 @@ public virtual Task IsEmpty(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - IsEmpty = e.MultiLineString == null ? (bool?)null : e.MultiLineString.IsEmpty - }), + e => new { e.Id, IsEmpty = e.MultiLineString == null ? (bool?)null : e.MultiLineString.IsEmpty }), elementSorter: x => x.Id); } @@ -849,11 +728,7 @@ public virtual Task IsSimple(bool isAsync) isAsync, es => es.Select( e => - new - { - e.Id, - IsSimple = e.LineString == null ? (bool?)null : e.LineString.IsSimple - }), + new { e.Id, IsSimple = e.LineString == null ? (bool?)null : e.LineString.IsSimple }), elementSorter: x => x.Id); } @@ -877,11 +752,7 @@ public virtual Task IsWithinDistance(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - IsWithinDistance = e.Point == null ? (bool?)null : e.Point.IsWithinDistance(point, 1) - }), + e => new { e.Id, IsWithinDistance = e.Point == null ? (bool?)null : e.Point.IsWithinDistance(point, 1) }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -905,11 +776,7 @@ public virtual Task Item(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Item0 = e.MultiLineString == null ? null : e.MultiLineString[0] - }), + e => new { e.Id, Item0 = e.MultiLineString == null ? null : e.MultiLineString[0] }), elementSorter: x => x.Id); } @@ -966,11 +833,7 @@ public virtual Task NumGeometries(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - NumGeometries = e.MultiLineString == null ? (int?)null : e.MultiLineString.NumGeometries - }), + e => new { e.Id, NumGeometries = e.MultiLineString == null ? (int?)null : e.MultiLineString.NumGeometries }), elementSorter: x => x.Id); } @@ -981,11 +844,7 @@ public virtual Task NumInteriorRings(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - NumInteriorRings = e.Polygon == null ? (int?)null : e.Polygon.NumInteriorRings - }), + e => new { e.Id, NumInteriorRings = e.Polygon == null ? (int?)null : e.Polygon.NumInteriorRings }), elementSorter: x => x.Id); } @@ -996,11 +855,7 @@ public virtual Task NumPoints(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - NumPoints = e.LineString == null ? (int?)null : e.LineString.NumPoints - }), + e => new { e.Id, NumPoints = e.LineString == null ? (int?)null : e.LineString.NumPoints }), elementSorter: x => x.Id); } @@ -1011,11 +866,7 @@ public virtual Task OgcGeometryType(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - OgcGeometryType = e.Point == null ? (OgcGeometryType?)null : e.Point.OgcGeometryType - }), + e => new { e.Id, OgcGeometryType = e.Point == null ? (OgcGeometryType?)null : e.Point.OgcGeometryType }), elementSorter: x => x.Id); } @@ -1024,22 +875,12 @@ public virtual Task OgcGeometryType(bool isAsync) public virtual Task Overlaps(bool isAsync) { var polygon = Fixture.GeometryFactory.CreatePolygon( - new[] - { - new Coordinate(0, 0), - new Coordinate(1, 0), - new Coordinate(1, 1), - new Coordinate(0, 0) - }); + new[] { new Coordinate(0, 0), new Coordinate(1, 0), new Coordinate(1, 1), new Coordinate(0, 0) }); return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Overlaps = e.Polygon == null ? (bool?)null : e.Polygon.Overlaps(polygon) - }), + e => new { e.Id, Overlaps = e.Polygon == null ? (bool?)null : e.Polygon.Overlaps(polygon) }), elementSorter: x => x.Id); } @@ -1050,12 +891,7 @@ public virtual Task PointOnSurface(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - PointOnSurface = e.Polygon == null ? null : e.Polygon.PointOnSurface, - e.Polygon - }), + e => new { e.Id, PointOnSurface = e.Polygon == null ? null : e.Polygon.PointOnSurface, e.Polygon }), elementSorter: x => x.Id, elementAsserter: (e, a) => { @@ -1077,22 +913,12 @@ public virtual Task PointOnSurface(bool isAsync) public virtual Task Relate(bool isAsync) { var polygon = Fixture.GeometryFactory.CreatePolygon( - new[] - { - new Coordinate(0, 0), - new Coordinate(1, 0), - new Coordinate(1, 1), - new Coordinate(0, 0) - }); + new[] { new Coordinate(0, 0), new Coordinate(1, 0), new Coordinate(1, 1), new Coordinate(0, 0) }); return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Relate = e.Polygon == null ? (bool?)null : e.Polygon.Relate(polygon, "212111212") - }), + e => new { e.Id, Relate = e.Polygon == null ? (bool?)null : e.Polygon.Relate(polygon, "212111212") }), elementSorter: x => x.Id); } @@ -1113,11 +939,7 @@ public virtual Task SRID(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - SRID = e.Point == null ? (int?)null : e.Point.SRID - }), + e => new { e.Id, SRID = e.Point == null ? (int?)null : e.Point.SRID }), elementSorter: x => x.Id); } @@ -1128,11 +950,7 @@ public virtual Task SRID_geometry(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - SRID = e.Geometry == null ? (int?)null : e.Geometry.SRID - }), + e => new { e.Id, SRID = e.Geometry == null ? (int?)null : e.Geometry.SRID }), elementSorter: x => x.Id); } @@ -1151,22 +969,12 @@ public virtual Task StartPoint(bool isAsync) public virtual Task SymmetricDifference(bool isAsync) { var polygon = Fixture.GeometryFactory.CreatePolygon( - new[] - { - new Coordinate(0, 0), - new Coordinate(1, 0), - new Coordinate(1, 1), - new Coordinate(0, 0) - }); + new[] { new Coordinate(0, 0), new Coordinate(1, 0), new Coordinate(1, 1), new Coordinate(0, 0) }); return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - SymmetricDifference = e.Polygon == null ? null : e.Polygon.SymmetricDifference(polygon) - }), + e => new { e.Id, SymmetricDifference = e.Polygon == null ? null : e.Polygon.SymmetricDifference(polygon) }), elementSorter: x => x.Id, elementAsserter: (e, a) => { @@ -1184,7 +992,7 @@ public virtual Task ToBinary(bool isAsync) { return AssertQuery( isAsync, - es => es.Select(e => new { e.Id, Binary = e.Point == null ? null : ((Point)e.Point).ToBinary() }), + es => es.Select(e => new { e.Id, Binary = e.Point == null ? null : e.Point.ToBinary() }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -1199,7 +1007,7 @@ public virtual Task ToText(bool isAsync) { return AssertQuery( isAsync, - es => es.Select(e => new { e.Id, Text = e.Point == null ? null : ((Point)e.Point).ToText() }), + es => es.Select(e => new { e.Id, Text = e.Point == null ? null : e.Point.ToText() }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -1213,22 +1021,12 @@ public virtual Task ToText(bool isAsync) public virtual Task Touches(bool isAsync) { var polygon = Fixture.GeometryFactory.CreatePolygon( - new[] - { - new Coordinate(0, 1), - new Coordinate(1, 0), - new Coordinate(1, 1), - new Coordinate(0, 1) - }); + new[] { new Coordinate(0, 1), new Coordinate(1, 0), new Coordinate(1, 1), new Coordinate(0, 1) }); return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Touches = e.Polygon == null ? (bool?)null : e.Polygon.Touches(polygon) - }), + e => new { e.Id, Touches = e.Polygon == null ? (bool?)null : e.Polygon.Touches(polygon) }), elementSorter: x => x.Id); } @@ -1237,22 +1035,12 @@ public virtual Task Touches(bool isAsync) public virtual Task Union(bool isAsync) { var polygon = Fixture.GeometryFactory.CreatePolygon( - new[] - { - new Coordinate(0, 0), - new Coordinate(1, 0), - new Coordinate(1, 1), - new Coordinate(0, 0) - }); + new[] { new Coordinate(0, 0), new Coordinate(1, 0), new Coordinate(1, 1), new Coordinate(0, 0) }); return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Union = e.Polygon == null ? null : e.Polygon.Union(polygon) - }), + e => new { e.Id, Union = e.Polygon == null ? null : e.Polygon.Union(polygon) }), elementSorter: x => x.Id, elementAsserter: (e, a) => { @@ -1268,11 +1056,7 @@ public virtual Task Union_void(bool isAsync) return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Union = e.MultiLineString == null ? null : e.MultiLineString.Union() - }), + e => new { e.Id, Union = e.MultiLineString == null ? null : e.MultiLineString.Union() }), elementSorter: x => x.Id); } @@ -1283,21 +1067,13 @@ public virtual Task Within(bool isAsync) var polygon = Fixture.GeometryFactory.CreatePolygon( new[] { - new Coordinate(-1, -1), - new Coordinate(2, -1), - new Coordinate(2, 2), - new Coordinate(-1, 2), - new Coordinate(-1, -1) + new Coordinate(-1, -1), new Coordinate(2, -1), new Coordinate(2, 2), new Coordinate(-1, 2), new Coordinate(-1, -1) }); return AssertQuery( isAsync, es => es.Select( - e => new - { - e.Id, - Within = e.Point == null ? (bool?)null : e.Point.Within(polygon) - }), + e => new { e.Id, Within = e.Point == null ? (bool?)null : e.Point.Within(polygon) }), elementSorter: x => x.Id); } diff --git a/test/EFCore.Specification.Tests/SeedingTestBase.cs b/test/EFCore.Specification.Tests/SeedingTestBase.cs index e027f7a5b4d..a9c34e9074b 100644 --- a/test/EFCore.Specification.Tests/SeedingTestBase.cs +++ b/test/EFCore.Specification.Tests/SeedingTestBase.cs @@ -44,14 +44,8 @@ protected SeedingContext(string testId) protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.Entity().HasData( - new Seed - { - Id = 321, Species = "Apple" - }, - new Seed - { - Id = 322, Species = "Orange" - } + new Seed { Id = 321, Species = "Apple" }, + new Seed { Id = 322, Species = "Orange" } ); } @@ -59,6 +53,7 @@ protected class Seed { [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } + public string Species { get; set; } } } diff --git a/test/EFCore.Specification.Tests/SharedStoreFixtureBase.cs b/test/EFCore.Specification.Tests/SharedStoreFixtureBase.cs index ce2468fc00f..b4de14d6aec 100644 --- a/test/EFCore.Specification.Tests/SharedStoreFixtureBase.cs +++ b/test/EFCore.Specification.Tests/SharedStoreFixtureBase.cs @@ -127,7 +127,7 @@ protected virtual Task CleanAsync(DbContext context) // Called after DisposeAsync public virtual void Dispose() - { + { } public virtual Task DisposeAsync() => TestStore.DisposeAsync(); diff --git a/test/EFCore.Specification.Tests/SpatialFixtureBase.cs b/test/EFCore.Specification.Tests/SpatialFixtureBase.cs index 8c9e3dc0ac3..81895e801a4 100644 --- a/test/EFCore.Specification.Tests/SpatialFixtureBase.cs +++ b/test/EFCore.Specification.Tests/SpatialFixtureBase.cs @@ -1,9 +1,9 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using NetTopologySuite.Geometries; using Microsoft.EntityFrameworkCore.TestModels.SpatialModel; using NetTopologySuite; +using NetTopologySuite.Geometries; namespace Microsoft.EntityFrameworkCore { diff --git a/test/EFCore.Specification.Tests/SpatialTestBase.cs b/test/EFCore.Specification.Tests/SpatialTestBase.cs index cdde453595b..b2f4153750c 100644 --- a/test/EFCore.Specification.Tests/SpatialTestBase.cs +++ b/test/EFCore.Specification.Tests/SpatialTestBase.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestModels.SpatialModel; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using NetTopologySuite.Geometries; using Xunit; @@ -26,11 +25,7 @@ public virtual void Values_are_copied_into_change_tracker() { using (var db = Fixture.CreateContext()) { - var entity = new PointEntity - { - Id = Guid.NewGuid(), - Point = new Point(0, 0) - }; + var entity = new PointEntity { Id = Guid.NewGuid(), Point = new Point(0, 0) }; db.Attach(entity); entity.Point.X = 1; @@ -44,11 +39,7 @@ public virtual void Values_arent_compared_by_reference() { using (var db = Fixture.CreateContext()) { - var entity = new PointEntity - { - Id = Guid.NewGuid(), - Point = new Point(0, 0) - }; + var entity = new PointEntity { Id = Guid.NewGuid(), Point = new Point(0, 0) }; db.Attach(entity); entity.Point = new Point(0, 0); @@ -77,16 +68,8 @@ Polygon CreatePolygon(double y = 2.2) context => { context.AddRange( - new PointEntity - { - Id = id1, - Point = point - }, - new PolygonEntity - { - Id = id2, - Polygon = polygon - }); + new PointEntity { Id = id1, Point = point }, + new PolygonEntity { Id = id2, Polygon = polygon }); context.SaveChanges(); }, @@ -124,14 +107,14 @@ public virtual void Translators_handle_static_members() using (var db = Fixture.CreateContext()) { (from e in db.Set() - select new - { - e.Id, - e.Point, - Point.Empty, - DateTime.UtcNow, - Guid = Guid.NewGuid() - }).FirstOrDefault(); + select new + { + e.Id, + e.Point, + Point.Empty, + DateTime.UtcNow, + Guid = Guid.NewGuid() + }).FirstOrDefault(); } } diff --git a/test/EFCore.Specification.Tests/StoreGeneratedFixupTestBase.cs b/test/EFCore.Specification.Tests/StoreGeneratedFixupTestBase.cs index 17e81f0e67e..5889448764d 100644 --- a/test/EFCore.Specification.Tests/StoreGeneratedFixupTestBase.cs +++ b/test/EFCore.Specification.Tests/StoreGeneratedFixupTestBase.cs @@ -33,7 +33,13 @@ public virtual void Add_dependent_then_principal_one_to_many_FK_set_both_navs_se { var principal = new Category { Id1 = -77, Id2 = Guid77 }; var dependent = new Product - { Id1 = -78, Id2 = Guid78, Category = principal, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2 }; + { + Id1 = -78, + Id2 = Guid78, + Category = principal, + CategoryId1 = principal.Id1, + CategoryId2 = principal.Id2 + }; principal.Products.Add(dependent); MarkIdsTemporary(context, dependent, principal); @@ -109,7 +115,13 @@ public virtual void Add_dependent_then_principal_one_to_many_FK_set_dependent_na { var principal = new Category { Id1 = -77, Id2 = Guid77 }; var dependent = new Product - { Id1 = -78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2, Category = principal }; + { + Id1 = -78, + Id2 = Guid78, + CategoryId1 = principal.Id1, + CategoryId2 = principal.Id2, + Category = principal + }; MarkIdsTemporary(context, dependent, principal); @@ -165,7 +177,13 @@ public virtual void Add_principal_then_dependent_one_to_many_FK_set_both_navs_se { var principal = new Category { Id1 = -77, Id2 = Guid77 }; var dependent = new Product - { Id1 = -78, Id2 = Guid78, Category = principal, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2 }; + { + Id1 = -78, + Id2 = Guid78, + Category = principal, + CategoryId1 = principal.Id1, + CategoryId2 = principal.Id2 + }; principal.Products.Add(dependent); MarkIdsTemporary(context, dependent, principal); @@ -241,7 +259,13 @@ public virtual void Add_principal_then_dependent_one_to_many_FK_set_dependent_na { var principal = new Category { Id1 = -77, Id2 = Guid77 }; var dependent = new Product - { Id1 = -78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2, Category = principal }; + { + Id1 = -78, + Id2 = Guid78, + CategoryId1 = principal.Id1, + CategoryId2 = principal.Id2, + Category = principal + }; MarkIdsTemporary(context, dependent, principal); @@ -483,7 +507,13 @@ public virtual void Add_dependent_then_principal_one_to_many_dep_uni_FK_set_depe { var principal = new CategoryDN { Id1 = -77, Id2 = Guid77 }; var dependent = new ProductDN - { Id1 = -78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2, Category = principal }; + { + Id1 = -78, + Id2 = Guid78, + CategoryId1 = principal.Id1, + CategoryId2 = principal.Id2, + Category = principal + }; MarkIdsTemporary(context, dependent, principal); @@ -538,7 +568,13 @@ public virtual void Add_principal_then_dependent_one_to_many_dep_uni_FK_set_depe { var principal = new CategoryDN { Id1 = -77, Id2 = Guid77 }; var dependent = new ProductDN - { Id1 = -78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2, Category = principal }; + { + Id1 = -78, + Id2 = Guid78, + CategoryId1 = principal.Id1, + CategoryId2 = principal.Id2, + Category = principal + }; MarkIdsTemporary(context, dependent, principal); @@ -663,7 +699,13 @@ public virtual void Add_dependent_then_principal_one_to_one_FK_set_both_navs_set { var principal = new Parent { Id1 = -77, Id2 = Guid77 }; var dependent = new Child - { Id1 = -78, Id2 = Guid78, Parent = principal, ParentId1 = principal.Id1, ParentId2 = principal.Id2 }; + { + Id1 = -78, + Id2 = Guid78, + Parent = principal, + ParentId1 = principal.Id1, + ParentId2 = principal.Id2 + }; principal.Child = dependent; MarkIdsTemporary(context, dependent, principal); @@ -739,7 +781,13 @@ public virtual void Add_dependent_then_principal_one_to_one_FK_set_dependent_nav { var principal = new Parent { Id1 = -77, Id2 = Guid77 }; var dependent = new Child - { Id1 = -78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2, Parent = principal }; + { + Id1 = -78, + Id2 = Guid78, + ParentId1 = principal.Id1, + ParentId2 = principal.Id2, + Parent = principal + }; MarkIdsTemporary(context, dependent, principal); @@ -795,7 +843,13 @@ public virtual void Add_principal_then_dependent_one_to_one_FK_set_both_navs_set { var principal = new Parent { Id1 = -77, Id2 = Guid77 }; var dependent = new Child - { Id1 = -78, Id2 = Guid78, Parent = principal, ParentId1 = principal.Id1, ParentId2 = principal.Id2 }; + { + Id1 = -78, + Id2 = Guid78, + Parent = principal, + ParentId1 = principal.Id1, + ParentId2 = principal.Id2 + }; principal.Child = dependent; MarkIdsTemporary(context, dependent, principal); @@ -871,7 +925,13 @@ public virtual void Add_principal_then_dependent_one_to_one_FK_set_dependent_nav { var principal = new Parent { Id1 = -77, Id2 = Guid77 }; var dependent = new Child - { Id1 = -78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2, Parent = principal }; + { + Id1 = -78, + Id2 = Guid78, + ParentId1 = principal.Id1, + ParentId2 = principal.Id2, + Parent = principal + }; MarkIdsTemporary(context, dependent, principal); @@ -1113,7 +1173,13 @@ public virtual void Add_dependent_then_principal_one_to_one_dep_uni_FK_set_depen { var principal = new ParentDN { Id1 = -77, Id2 = Guid77 }; var dependent = new ChildDN - { Id1 = -78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2, Parent = principal }; + { + Id1 = -78, + Id2 = Guid78, + ParentId1 = principal.Id1, + ParentId2 = principal.Id2, + Parent = principal + }; MarkIdsTemporary(context, dependent, principal); @@ -1168,7 +1234,13 @@ public virtual void Add_principal_then_dependent_one_to_one_dep_uni_FK_set_depen { var principal = new ParentDN { Id1 = -77, Id2 = Guid77 }; var dependent = new ChildDN - { Id1 = -78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2, Parent = principal }; + { + Id1 = -78, + Id2 = Guid78, + ParentId1 = principal.Id1, + ParentId2 = principal.Id2, + Parent = principal + }; MarkIdsTemporary(context, dependent, principal); @@ -4095,11 +4167,11 @@ private static void AssertValidFks(DbContext context, FirstLevel firstLevel, boo Assert.All( secondLevels.Select(l => context.Entry(l).Property(e => e.Id).CurrentValue), - s => Assert.True(tempKeys ? s < 0 : s> 0)); + s => Assert.True(tempKeys ? s < 0 : s > 0)); Assert.All( thirdLevels.Select(l => context.Entry(l).Property(e => e.Id).CurrentValue), - s => Assert.True(tempKeys ? s < 0 : s> 0)); + s => Assert.True(tempKeys ? s < 0 : s > 0)); Assert.All( secondLevels.Select(l => context.Entry(l).Property(e => e.FirstLevelId).CurrentValue), @@ -4124,14 +4196,8 @@ private static void AddData(FirstLevel first) { first.SecondLevels = new List { - new SecondLevel - { - ThirdLevels = new List { new ThirdLevel(), new ThirdLevel() } - }, - new SecondLevel - { - ThirdLevels = new List { new ThirdLevel(), new ThirdLevel() } - } + new SecondLevel { ThirdLevels = new List { new ThirdLevel(), new ThirdLevel() } }, + new SecondLevel { ThirdLevels = new List { new ThirdLevel(), new ThirdLevel() } } }; } diff --git a/test/EFCore.Specification.Tests/StoreGeneratedTestBase.cs b/test/EFCore.Specification.Tests/StoreGeneratedTestBase.cs index cb69ba4db20..af3dc785b38 100644 --- a/test/EFCore.Specification.Tests/StoreGeneratedTestBase.cs +++ b/test/EFCore.Specification.Tests/StoreGeneratedTestBase.cs @@ -1068,7 +1068,7 @@ public virtual void Fields_used_correctly_for_store_generated_values() }); } - [ConditionalFact(Skip="Issue #15182")] + [ConditionalFact(Skip = "Issue #15182")] public virtual void Nullable_fields_get_defaults_when_not_set() { ExecuteWithStrategyInTransaction( @@ -1090,17 +1090,13 @@ public virtual void Nullable_fields_get_defaults_when_not_set() }); } - [ConditionalFact(Skip="Issue #15182")] + [ConditionalFact(Skip = "Issue #15182")] public virtual void Nullable_fields_store_non_defaults_when_set() { ExecuteWithStrategyInTransaction( context => { - var entity = context.Add(new WithNullableBackingFields - { - NullableBackedBool = false, - NullableBackedInt = 0 - }).Entity; + var entity = context.Add(new WithNullableBackingFields { NullableBackedBool = false, NullableBackedInt = 0 }).Entity; context.SaveChanges(); @@ -1116,17 +1112,13 @@ public virtual void Nullable_fields_store_non_defaults_when_set() }); } - [ConditionalFact(Skip="Issue #15182")] + [ConditionalFact(Skip = "Issue #15182")] public virtual void Nullable_fields_store_any_value_when_set() { ExecuteWithStrategyInTransaction( context => { - var entity = context.Add(new WithNullableBackingFields - { - NullableBackedBool = true, - NullableBackedInt = 3 - }).Entity; + var entity = context.Add(new WithNullableBackingFields { NullableBackedBool = true, NullableBackedInt = 3 }).Entity; context.SaveChanges(); @@ -1220,14 +1212,16 @@ protected class Anais protected class WithBackingFields { +#pragma warning disable RCS1085 // Use auto-implemented property. + // ReSharper disable ConvertToAutoProperty private int _id; -#pragma warning disable RCS1085 // Use auto-implemented property. public int Id { get => _id; set => _id = value; } + // ReSharper restore ConvertToAutoProperty #pragma warning restore RCS1085 // Use auto-implemented property. private int? _nullableAsNonNullable = 0; @@ -1258,6 +1252,7 @@ public int Id } private bool? _nullableBackedBool; + public bool NullableBackedBool { get => _nullableBackedBool ?? false; @@ -1265,6 +1260,7 @@ public bool NullableBackedBool } private int? _nullableBackedInt; + public int NullableBackedInt { get => _nullableBackedInt ?? 0; diff --git a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityDbContext``.cs b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityDbContext``.cs index 4658eea8931..068b8521a92 100644 --- a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityDbContext``.cs +++ b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityDbContext``.cs @@ -63,10 +63,7 @@ protected override void OnModelCreating(ModelBuilder builder) b => { b.HasKey( - r => new - { - r.UserId, r.RoleId - }); + r => new { r.UserId, r.RoleId }); }); } } diff --git a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityRoleClaim.cs b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityRoleClaim.cs index 22815661c89..da6ca0325bc 100644 --- a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityRoleClaim.cs +++ b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityRoleClaim.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.TestModels.AspNetIdentity { - public class IdentityRoleClaim where TKey : IEquatable + public class IdentityRoleClaim + where TKey : IEquatable { public virtual int Id { get; set; } public virtual TKey RoleId { get; set; } diff --git a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUserContext.cs b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUserContext.cs index 2b851ecc00a..4ad8f3188a5 100644 --- a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUserContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUserContext.cs @@ -3,7 +3,6 @@ using System; using System.Linq; -using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Microsoft.EntityFrameworkCore.TestModels.AspNetIdentity @@ -94,10 +93,7 @@ protected override void OnModelCreating(ModelBuilder builder) b => { b.HasKey( - l => new - { - l.LoginProvider, l.ProviderKey - }); + l => new { l.LoginProvider, l.ProviderKey }); if (maxKeyLength > 0) { @@ -110,10 +106,7 @@ protected override void OnModelCreating(ModelBuilder builder) b => { b.HasKey( - t => new - { - t.UserId, t.LoginProvider, t.Name - }); + t => new { t.UserId, t.LoginProvider, t.Name }); if (maxKeyLength > 0) { diff --git a/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/ComplexNavigationsData.cs b/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/ComplexNavigationsData.cs index 60e8ce88c18..007718848ad 100644 --- a/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/ComplexNavigationsData.cs +++ b/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/ComplexNavigationsData.cs @@ -66,66 +66,16 @@ public static IReadOnlyList CreateLevelOnes(bool tableSplitting) { var result = new List { - new Level1 - { - Id = 1, - Name = "L1 01", - Date = new DateTime(2001, 1, 1) - }, - new Level1 - { - Id = 2, - Name = "L1 02", - Date = new DateTime(2002, 2, 2) - }, - new Level1 - { - Id = 3, - Name = "L1 03", - Date = new DateTime(2003, 3, 3) - }, - new Level1 - { - Id = 4, - Name = "L1 04", - Date = new DateTime(2004, 4, 4) - }, - new Level1 - { - Id = 5, - Name = "L1 05", - Date = new DateTime(2005, 5, 5) - }, - new Level1 - { - Id = 6, - Name = "L1 06", - Date = new DateTime(2006, 6, 6) - }, - new Level1 - { - Id = 7, - Name = "L1 07", - Date = new DateTime(2007, 7, 7) - }, - new Level1 - { - Id = 8, - Name = "L1 08", - Date = new DateTime(2008, 8, 8) - }, - new Level1 - { - Id = 9, - Name = "L1 09", - Date = new DateTime(2009, 9, 9) - }, - new Level1 - { - Id = 10, - Name = "L1 10", - Date = new DateTime(2010, 10, 10) - } + new Level1 { Id = 1, Name = "L1 01", Date = new DateTime(2001, 1, 1) }, + new Level1 { Id = 2, Name = "L1 02", Date = new DateTime(2002, 2, 2) }, + new Level1 { Id = 3, Name = "L1 03", Date = new DateTime(2003, 3, 3) }, + new Level1 { Id = 4, Name = "L1 04", Date = new DateTime(2004, 4, 4) }, + new Level1 { Id = 5, Name = "L1 05", Date = new DateTime(2005, 5, 5) }, + new Level1 { Id = 6, Name = "L1 06", Date = new DateTime(2006, 6, 6) }, + new Level1 { Id = 7, Name = "L1 07", Date = new DateTime(2007, 7, 7) }, + new Level1 { Id = 8, Name = "L1 08", Date = new DateTime(2008, 8, 8) }, + new Level1 { Id = 9, Name = "L1 09", Date = new DateTime(2009, 9, 9) }, + new Level1 { Id = 10, Name = "L1 10", Date = new DateTime(2010, 10, 10) } }; if (!tableSplitting) @@ -133,24 +83,9 @@ public static IReadOnlyList CreateLevelOnes(bool tableSplitting) result.AddRange( new List { - new Level1 - { - Id = 11, - Name = "L1 11", - Date = new DateTime(2009, 11, 11) - }, - new Level1 - { - Id = 12, - Name = "L1 12", - Date = new DateTime(2008, 12, 12) - }, - new Level1 - { - Id = 13, - Name = "L1 13", - Date = new DateTime(2007, 1, 1) - } + new Level1 { Id = 11, Name = "L1 11", Date = new DateTime(2009, 11, 11) }, + new Level1 { Id = 12, Name = "L1 12", Date = new DateTime(2008, 12, 12) }, + new Level1 { Id = 13, Name = "L1 13", Date = new DateTime(2007, 1, 1) } }); } @@ -169,80 +104,22 @@ public static IReadOnlyList CreateLevelTwos(bool tableSplitting) { var result = new List { - new Level2 - { - Id = 1, - Name = "L2 01", - Date = new DateTime(2010, 10, 10) - }, - new Level2 - { - Id = 2, - Name = "L2 02", - Date = new DateTime(2002, 2, 2) - }, - new Level2 - { - Id = 3, - Name = "L2 03", - Date = new DateTime(2008, 8, 8) - }, - new Level2 - { - Id = 4, - Name = "L2 04", - Date = new DateTime(2004, 4, 4) - }, - new Level2 - { - Id = 5, - Name = "L2 05", - Date = new DateTime(2006, 6, 6) - }, - new Level2 - { - Id = 6, - Name = "L2 06", - Date = new DateTime(2005, 5, 5) - }, - new Level2 - { - Id = 7, - Name = "L2 07", - Date = new DateTime(2007, 7, 7) - }, - new Level2 - { - Id = 8, - Name = "L2 08", - Date = new DateTime(2003, 3, 3) - }, - new Level2 - { - Id = 9, - Name = "L2 09", - Date = new DateTime(2009, 9, 9) - }, - new Level2 - { - Id = 10, - Name = "L2 10", - Date = new DateTime(2001, 1, 1) - } + new Level2 { Id = 1, Name = "L2 01", Date = new DateTime(2010, 10, 10) }, + new Level2 { Id = 2, Name = "L2 02", Date = new DateTime(2002, 2, 2) }, + new Level2 { Id = 3, Name = "L2 03", Date = new DateTime(2008, 8, 8) }, + new Level2 { Id = 4, Name = "L2 04", Date = new DateTime(2004, 4, 4) }, + new Level2 { Id = 5, Name = "L2 05", Date = new DateTime(2006, 6, 6) }, + new Level2 { Id = 6, Name = "L2 06", Date = new DateTime(2005, 5, 5) }, + new Level2 { Id = 7, Name = "L2 07", Date = new DateTime(2007, 7, 7) }, + new Level2 { Id = 8, Name = "L2 08", Date = new DateTime(2003, 3, 3) }, + new Level2 { Id = 9, Name = "L2 09", Date = new DateTime(2009, 9, 9) }, + new Level2 { Id = 10, Name = "L2 10", Date = new DateTime(2001, 1, 1) } }; if (!tableSplitting) { result.AddRange( - new List - { - new Level2 - { - Id = 11, - Name = "L2 11", - Date = new DateTime(2000, 1, 1) - } - }); + new List { new Level2 { Id = 11, Name = "L2 11", Date = new DateTime(2000, 1, 1) } }); } foreach (var l2 in result) @@ -260,56 +137,16 @@ public static IReadOnlyList CreateLevelThrees(bool tableSplitting) { var result = new List { - new Level3 - { - Id = 1, - Name = "L3 01" - }, - new Level3 - { - Id = 2, - Name = "L3 02" - }, - new Level3 - { - Id = 3, - Name = "L3 03" - }, - new Level3 - { - Id = 4, - Name = "L3 04" - }, - new Level3 - { - Id = 5, - Name = "L3 05" - }, - new Level3 - { - Id = 6, - Name = "L3 06" - }, - new Level3 - { - Id = 7, - Name = "L3 07" - }, - new Level3 - { - Id = 8, - Name = "L3 08" - }, - new Level3 - { - Id = 9, - Name = "L3 09" - }, - new Level3 - { - Id = 10, - Name = "L3 10" - } + new Level3 { Id = 1, Name = "L3 01" }, + new Level3 { Id = 2, Name = "L3 02" }, + new Level3 { Id = 3, Name = "L3 03" }, + new Level3 { Id = 4, Name = "L3 04" }, + new Level3 { Id = 5, Name = "L3 05" }, + new Level3 { Id = 6, Name = "L3 06" }, + new Level3 { Id = 7, Name = "L3 07" }, + new Level3 { Id = 8, Name = "L3 08" }, + new Level3 { Id = 9, Name = "L3 09" }, + new Level3 { Id = 10, Name = "L3 10" } }; foreach (var l3 in result) @@ -327,56 +164,16 @@ public static IReadOnlyList CreateLevelFours(bool tableSplitting) { var result = new List { - new Level4 - { - Id = 1, - Name = "L4 01" - }, - new Level4 - { - Id = 2, - Name = "L4 02" - }, - new Level4 - { - Id = 3, - Name = "L4 03" - }, - new Level4 - { - Id = 4, - Name = "L4 04" - }, - new Level4 - { - Id = 5, - Name = "L4 05" - }, - new Level4 - { - Id = 6, - Name = "L4 06" - }, - new Level4 - { - Id = 7, - Name = "L4 07" - }, - new Level4 - { - Id = 8, - Name = "L4 08" - }, - new Level4 - { - Id = 9, - Name = "L4 09" - }, - new Level4 - { - Id = 10, - Name = "L4 10" - } + new Level4 { Id = 1, Name = "L4 01" }, + new Level4 { Id = 2, Name = "L4 02" }, + new Level4 { Id = 3, Name = "L4 03" }, + new Level4 { Id = 4, Name = "L4 04" }, + new Level4 { Id = 5, Name = "L4 05" }, + new Level4 { Id = 6, Name = "L4 06" }, + new Level4 { Id = 7, Name = "L4 07" }, + new Level4 { Id = 8, Name = "L4 08" }, + new Level4 { Id = 9, Name = "L4 09" }, + new Level4 { Id = 10, Name = "L4 10" } }; foreach (var l4 in result) @@ -392,21 +189,9 @@ public static IReadOnlyList CreateInheritanceBaseOnes() { var result = new List { - new InheritanceDerived1 - { - Id = 1, - Name = "ID1 01" - }, - new InheritanceDerived1 - { - Id = 2, - Name = "ID1 02" - }, - new InheritanceDerived2 - { - Id = 3, - Name = "ID2 01" - } + new InheritanceDerived1 { Id = 1, Name = "ID1 01" }, + new InheritanceDerived1 { Id = 2, Name = "ID1 02" }, + new InheritanceDerived2 { Id = 3, Name = "ID2 01" } }; return result; @@ -414,14 +199,7 @@ public static IReadOnlyList CreateInheritanceBaseOnes() public static IReadOnlyList CreateInheritanceBaseTwos() { - var result = new List - { - new InheritanceBase2 - { - Id = 1, - Name = "IB2 01" - } - }; + var result = new List { new InheritanceBase2 { Id = 1, Name = "IB2 01" } }; return result; } @@ -430,21 +208,9 @@ public static IReadOnlyList CreateInheritanceLeafOnes() { var result = new List { - new InheritanceLeaf1 - { - Id = 1, - Name = "IL1 01" - }, - new InheritanceLeaf1 - { - Id = 2, - Name = "IL1 02" - }, - new InheritanceLeaf1 - { - Id = 3, - Name = "IL1 03" - } + new InheritanceLeaf1 { Id = 1, Name = "IL1 01" }, + new InheritanceLeaf1 { Id = 2, Name = "IL1 02" }, + new InheritanceLeaf1 { Id = 3, Name = "IL1 03" } }; return result; @@ -452,14 +218,7 @@ public static IReadOnlyList CreateInheritanceLeafOnes() public static IReadOnlyList CreateInheritanceLeafTwos() { - var result = new List - { - new InheritanceLeaf2 - { - Id = 1, - Name = "IL2 01" - } - }; + var result = new List { new InheritanceLeaf2 { Id = 1, Name = "IL2 01" } }; return result; } @@ -471,11 +230,7 @@ public static void WireUpInheritancePart1( IReadOnlyList il2s) { ib2s[0].Reference = ib1s[0]; - ib2s[0].Collection = new List - { - ib1s[1], - ib1s[2] - }; + ib2s[0].Collection = new List { ib1s[1], ib1s[2] }; ((InheritanceDerived1)ib1s[0]).ReferenceSameType = il1s[0]; ((InheritanceDerived1)ib1s[1]).ReferenceSameType = il1s[1]; @@ -485,40 +240,20 @@ public static void WireUpInheritancePart1( ((InheritanceDerived1)ib1s[1]).ReferenceDifferentType = il1s[1]; ((InheritanceDerived2)ib1s[2]).ReferenceDifferentType = il2s[0]; - ((InheritanceDerived1)ib1s[0]).CollectionSameType = new List - { - il1s[0] - }; + ((InheritanceDerived1)ib1s[0]).CollectionSameType = new List { il1s[0] }; ((InheritanceDerived1)ib1s[1]).CollectionSameType = new List(); - ((InheritanceDerived2)ib1s[2]).CollectionSameType = new List - { - il1s[1], - il1s[2] - }; + ((InheritanceDerived2)ib1s[2]).CollectionSameType = new List { il1s[1], il1s[2] }; - ((InheritanceDerived1)ib1s[0]).CollectionDifferentType = new List - { - il1s[0] - }; - ((InheritanceDerived1)ib1s[1]).CollectionDifferentType = new List - { - il1s[1], - il1s[2] - }; - ((InheritanceDerived2)ib1s[2]).CollectionDifferentType = new List - { - il2s[0] - }; + ((InheritanceDerived1)ib1s[0]).CollectionDifferentType = new List { il1s[0] }; + ((InheritanceDerived1)ib1s[1]).CollectionDifferentType = new List { il1s[1], il1s[2] }; + ((InheritanceDerived2)ib1s[2]).CollectionDifferentType = new List { il2s[0] }; } public static void WireUpInheritancePart2( IReadOnlyList ib2s, IReadOnlyList il2s) { - il2s[0].BaseCollection = new List - { - ib2s[0] - }; + il2s[0].BaseCollection = new List { ib2s[0] }; } public static void WireUpPart1( @@ -587,60 +322,29 @@ public static void WireUpPart1( l1s[0].OneToMany_Required1.Add(l2s[10]); } - l1s[0].OneToMany_Required_Self1 = new List - { - l1s[0], - l1s[1] - }; + l1s[0].OneToMany_Required_Self1 = new List { l1s[0], l1s[1] }; if (!tableSplitting) { l1s[0].OneToMany_Required_Self1.Add(l1s[11]); } - l1s[1].OneToMany_Required_Self1 = new List - { - l1s[2] - }; + l1s[1].OneToMany_Required_Self1 = new List { l1s[2] }; if (!tableSplitting) { l1s[1].OneToMany_Required_Self1.Add(l1s[12]); } - l1s[2].OneToMany_Required_Self1 = new List - { - l1s[3] - }; - l1s[3].OneToMany_Required_Self1 = new List - { - l1s[4] - }; - l1s[4].OneToMany_Required_Self1 = new List - { - l1s[5] - }; - l1s[5].OneToMany_Required_Self1 = new List - { - l1s[6] - }; - l1s[6].OneToMany_Required_Self1 = new List - { - l1s[7] - }; - l1s[7].OneToMany_Required_Self1 = new List - { - l1s[8] - }; - l1s[8].OneToMany_Required_Self1 = new List - { - l1s[9] - }; + l1s[2].OneToMany_Required_Self1 = new List { l1s[3] }; + l1s[3].OneToMany_Required_Self1 = new List { l1s[4] }; + l1s[4].OneToMany_Required_Self1 = new List { l1s[5] }; + l1s[5].OneToMany_Required_Self1 = new List { l1s[6] }; + l1s[6].OneToMany_Required_Self1 = new List { l1s[7] }; + l1s[7].OneToMany_Required_Self1 = new List { l1s[8] }; + l1s[8].OneToMany_Required_Self1 = new List { l1s[9] }; l1s[9].OneToMany_Required_Self1 = new List(); if (!tableSplitting) { - l1s[10].OneToMany_Required_Self1 = new List - { - l1s[10] - }; + l1s[10].OneToMany_Required_Self1 = new List { l1s[10] }; l1s[11].OneToMany_Required_Self1 = new List(); l1s[12].OneToMany_Required_Self1 = new List(); } @@ -697,48 +401,20 @@ public static void WireUpPart1( l3s[9] }; - l2s[0].OneToMany_Required_Self2 = new List - { - l2s[0], - l2s[1] - }; + l2s[0].OneToMany_Required_Self2 = new List { l2s[0], l2s[1] }; if (!tableSplitting) { l2s[0].OneToMany_Required_Self2.Add(l2s[10]); } - l2s[1].OneToMany_Required_Self2 = new List - { - l2s[2] - }; - l2s[2].OneToMany_Required_Self2 = new List - { - l2s[3] - }; - l2s[3].OneToMany_Required_Self2 = new List - { - l2s[4] - }; - l2s[4].OneToMany_Required_Self2 = new List - { - l2s[5] - }; - l2s[5].OneToMany_Required_Self2 = new List - { - l2s[6] - }; - l2s[6].OneToMany_Required_Self2 = new List - { - l2s[7] - }; - l2s[7].OneToMany_Required_Self2 = new List - { - l2s[8] - }; - l2s[8].OneToMany_Required_Self2 = new List - { - l2s[9] - }; + l2s[1].OneToMany_Required_Self2 = new List { l2s[2] }; + l2s[2].OneToMany_Required_Self2 = new List { l2s[3] }; + l2s[3].OneToMany_Required_Self2 = new List { l2s[4] }; + l2s[4].OneToMany_Required_Self2 = new List { l2s[5] }; + l2s[5].OneToMany_Required_Self2 = new List { l2s[6] }; + l2s[6].OneToMany_Required_Self2 = new List { l2s[7] }; + l2s[7].OneToMany_Required_Self2 = new List { l2s[8] }; + l2s[8].OneToMany_Required_Self2 = new List { l2s[9] }; l2s[9].OneToMany_Required_Self2 = new List(); if (!tableSplitting) { @@ -797,82 +473,26 @@ public static void WireUpPart1( l4s[9] }; - l3s[0].OneToMany_Required_Self3 = new List - { - l3s[0], - l3s[1] - }; - l3s[1].OneToMany_Required_Self3 = new List - { - l3s[2] - }; - l3s[2].OneToMany_Required_Self3 = new List - { - l3s[3] - }; - l3s[3].OneToMany_Required_Self3 = new List - { - l3s[4] - }; - l3s[4].OneToMany_Required_Self3 = new List - { - l3s[5] - }; - l3s[5].OneToMany_Required_Self3 = new List - { - l3s[6] - }; - l3s[6].OneToMany_Required_Self3 = new List - { - l3s[7] - }; - l3s[7].OneToMany_Required_Self3 = new List - { - l3s[8] - }; - l3s[8].OneToMany_Required_Self3 = new List - { - l3s[9] - }; + l3s[0].OneToMany_Required_Self3 = new List { l3s[0], l3s[1] }; + l3s[1].OneToMany_Required_Self3 = new List { l3s[2] }; + l3s[2].OneToMany_Required_Self3 = new List { l3s[3] }; + l3s[3].OneToMany_Required_Self3 = new List { l3s[4] }; + l3s[4].OneToMany_Required_Self3 = new List { l3s[5] }; + l3s[5].OneToMany_Required_Self3 = new List { l3s[6] }; + l3s[6].OneToMany_Required_Self3 = new List { l3s[7] }; + l3s[7].OneToMany_Required_Self3 = new List { l3s[8] }; + l3s[8].OneToMany_Required_Self3 = new List { l3s[9] }; l3s[9].OneToMany_Required_Self3 = new List(); - l4s[0].OneToMany_Required_Self4 = new List - { - l4s[0], - l4s[1] - }; - l4s[1].OneToMany_Required_Self4 = new List - { - l4s[2] - }; - l4s[2].OneToMany_Required_Self4 = new List - { - l4s[3] - }; - l4s[3].OneToMany_Required_Self4 = new List - { - l4s[4] - }; - l4s[4].OneToMany_Required_Self4 = new List - { - l4s[5] - }; - l4s[5].OneToMany_Required_Self4 = new List - { - l4s[6] - }; - l4s[6].OneToMany_Required_Self4 = new List - { - l4s[7] - }; - l4s[7].OneToMany_Required_Self4 = new List - { - l4s[8] - }; - l4s[8].OneToMany_Required_Self4 = new List - { - l4s[9] - }; + l4s[0].OneToMany_Required_Self4 = new List { l4s[0], l4s[1] }; + l4s[1].OneToMany_Required_Self4 = new List { l4s[2] }; + l4s[2].OneToMany_Required_Self4 = new List { l4s[3] }; + l4s[3].OneToMany_Required_Self4 = new List { l4s[4] }; + l4s[4].OneToMany_Required_Self4 = new List { l4s[5] }; + l4s[5].OneToMany_Required_Self4 = new List { l4s[6] }; + l4s[6].OneToMany_Required_Self4 = new List { l4s[7] }; + l4s[7].OneToMany_Required_Self4 = new List { l4s[8] }; + l4s[8].OneToMany_Required_Self4 = new List { l4s[9] }; l4s[9].OneToMany_Required_Self4 = new List(); } @@ -1184,26 +804,11 @@ public static void WireUpPart2( l2s[9] }; - l1s[1].OneToMany_Optional_Self1 = new List - { - l1s[0] - }; - l1s[3].OneToMany_Optional_Self1 = new List - { - l1s[2] - }; - l1s[5].OneToMany_Optional_Self1 = new List - { - l1s[4] - }; - l1s[7].OneToMany_Optional_Self1 = new List - { - l1s[6] - }; - l1s[9].OneToMany_Optional_Self1 = new List - { - l1s[8] - }; + l1s[1].OneToMany_Optional_Self1 = new List { l1s[0] }; + l1s[3].OneToMany_Optional_Self1 = new List { l1s[2] }; + l1s[5].OneToMany_Optional_Self1 = new List { l1s[4] }; + l1s[7].OneToMany_Optional_Self1 = new List { l1s[6] }; + l1s[9].OneToMany_Optional_Self1 = new List { l1s[8] }; l1s[0].OneToOne_Optional_Self1 = l1s[9]; l1s[1].OneToOne_Optional_Self1 = l1s[8]; @@ -1223,38 +828,14 @@ public static void WireUpPart2( l2s[6].OneToOne_Optional_FK2 = l3s[2]; l2s[8].OneToOne_Optional_FK2 = l3s[0]; - l2s[0].OneToMany_Optional2 = new List - { - l3s[1], - l3s[5], - l3s[9] - }; - l2s[1].OneToMany_Optional2 = new List - { - l3s[3], - l3s[7] - }; + l2s[0].OneToMany_Optional2 = new List { l3s[1], l3s[5], l3s[9] }; + l2s[1].OneToMany_Optional2 = new List { l3s[3], l3s[7] }; - l2s[1].OneToMany_Optional_Self2 = new List - { - l2s[0] - }; - l2s[3].OneToMany_Optional_Self2 = new List - { - l2s[2] - }; - l2s[5].OneToMany_Optional_Self2 = new List - { - l2s[4] - }; - l2s[7].OneToMany_Optional_Self2 = new List - { - l2s[6] - }; - l2s[9].OneToMany_Optional_Self2 = new List - { - l2s[8] - }; + l2s[1].OneToMany_Optional_Self2 = new List { l2s[0] }; + l2s[3].OneToMany_Optional_Self2 = new List { l2s[2] }; + l2s[5].OneToMany_Optional_Self2 = new List { l2s[4] }; + l2s[7].OneToMany_Optional_Self2 = new List { l2s[6] }; + l2s[9].OneToMany_Optional_Self2 = new List { l2s[8] }; l2s[0].OneToOne_Optional_Self2 = l2s[9]; l2s[1].OneToOne_Optional_Self2 = l2s[8]; @@ -1283,26 +864,11 @@ public static void WireUpPart2( l4s[9] }; - l3s[1].OneToMany_Optional_Self3 = new List - { - l3s[0] - }; - l3s[3].OneToMany_Optional_Self3 = new List - { - l3s[2] - }; - l3s[5].OneToMany_Optional_Self3 = new List - { - l3s[4] - }; - l3s[7].OneToMany_Optional_Self3 = new List - { - l3s[6] - }; - l3s[9].OneToMany_Optional_Self3 = new List - { - l3s[8] - }; + l3s[1].OneToMany_Optional_Self3 = new List { l3s[0] }; + l3s[3].OneToMany_Optional_Self3 = new List { l3s[2] }; + l3s[5].OneToMany_Optional_Self3 = new List { l3s[4] }; + l3s[7].OneToMany_Optional_Self3 = new List { l3s[6] }; + l3s[9].OneToMany_Optional_Self3 = new List { l3s[8] }; l3s[0].OneToOne_Optional_Self3 = l3s[9]; l3s[1].OneToOne_Optional_Self3 = l3s[8]; @@ -1310,26 +876,11 @@ public static void WireUpPart2( l3s[3].OneToOne_Optional_Self3 = l3s[6]; l3s[4].OneToOne_Optional_Self3 = l3s[5]; - l4s[1].OneToMany_Optional_Self4 = new List - { - l4s[0] - }; - l4s[3].OneToMany_Optional_Self4 = new List - { - l4s[2] - }; - l4s[5].OneToMany_Optional_Self4 = new List - { - l4s[4] - }; - l4s[7].OneToMany_Optional_Self4 = new List - { - l4s[6] - }; - l4s[9].OneToMany_Optional_Self4 = new List - { - l4s[8] - }; + l4s[1].OneToMany_Optional_Self4 = new List { l4s[0] }; + l4s[3].OneToMany_Optional_Self4 = new List { l4s[2] }; + l4s[5].OneToMany_Optional_Self4 = new List { l4s[4] }; + l4s[7].OneToMany_Optional_Self4 = new List { l4s[6] }; + l4s[9].OneToMany_Optional_Self4 = new List { l4s[8] }; } public static void WireUpInversePart2( @@ -1451,16 +1002,8 @@ public static void Seed(ComplexNavigationsContext context, bool tableSplitting = var globalizations = new List(); for (var i = 0; i < 10; i++) { - var language = new ComplexNavigationLanguage - { - Name = "Language" + i, - CultureString = "Foo" + i - }; - var globalization = new ComplexNavigationGlobalization - { - Text = "Globalization" + i, - Language = language - }; + var language = new ComplexNavigationLanguage { Name = "Language" + i, CultureString = "Foo" + i }; + var globalization = new ComplexNavigationGlobalization { Text = "Globalization" + i, Language = language }; globalizations.Add(globalization); context.Languages.Add(language); @@ -1483,41 +1026,15 @@ public static void Seed(ComplexNavigationsContext context, bool tableSplitting = WireUpInheritancePart2(ib2s, il2s); context.SaveChanges(); - var mls1 = new ComplexNavigationString - { - DefaultText = "MLS1", - Globalizations = globalizations.Take(3).ToList() - }; - var mls2 = new ComplexNavigationString - { - DefaultText = "MLS2", - Globalizations = globalizations.Skip(3).Take(3).ToList() - }; - var mls3 = new ComplexNavigationString - { - DefaultText = "MLS3", - Globalizations = globalizations.Skip(6).Take(3).ToList() - }; - var mls4 = new ComplexNavigationString - { - DefaultText = "MLS4", - Globalizations = globalizations.Skip(9).ToList() - }; + var mls1 = new ComplexNavigationString { DefaultText = "MLS1", Globalizations = globalizations.Take(3).ToList() }; + var mls2 = new ComplexNavigationString { DefaultText = "MLS2", Globalizations = globalizations.Skip(3).Take(3).ToList() }; + var mls3 = new ComplexNavigationString { DefaultText = "MLS3", Globalizations = globalizations.Skip(6).Take(3).ToList() }; + var mls4 = new ComplexNavigationString { DefaultText = "MLS4", Globalizations = globalizations.Skip(9).ToList() }; context.MultilingualStrings.AddRange(mls1, mls2, mls3, mls4); - var field1 = new ComplexNavigationField - { - Name = "Field1", - Label = mls1, - Placeholder = null - }; - var field2 = new ComplexNavigationField - { - Name = "Field2", - Label = mls3, - Placeholder = mls4 - }; + var field1 = new ComplexNavigationField { Name = "Field1", Label = mls1, Placeholder = null }; + var field2 = new ComplexNavigationField { Name = "Field2", Label = mls3, Placeholder = mls4 }; context.Fields.AddRange(field1, field2); context.SaveChanges(); diff --git a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/F1Context.cs b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/F1Context.cs index cefac2a4c26..8612421857b 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/F1Context.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/F1Context.cs @@ -31,22 +31,10 @@ private static void AddEntities(F1Context context) { foreach (var engineSupplier in new List { - new EngineSupplier - { - Name = "Mercedes" - }, - new EngineSupplier - { - Name = "Renault" - }, - new EngineSupplier - { - Name = "Ferrari" - }, - new EngineSupplier - { - Name = "Cosworth" - } + new EngineSupplier { Name = "Mercedes" }, + new EngineSupplier { Name = "Renault" }, + new EngineSupplier { Name = "Ferrari" }, + new EngineSupplier { Name = "Cosworth" } }) { context.Add(engineSupplier); @@ -56,51 +44,29 @@ private static void AddEntities(F1Context context) var mercedesEngine = new Engine { Name = "FO 108X", - StorageLocation = new Location - { - Latitude = 47.64491, - Longitude = -122.128101 - }, + StorageLocation = new Location { Latitude = 47.64491, Longitude = -122.128101 }, EngineSupplier = engineSuppliers.Single(s => s.Name == "Mercedes") }; var renaultEngine = new Engine { Name = "RS27-2010", - StorageLocation = new Location - { - Latitude = 47.644199, - Longitude = -122.127049 - }, + StorageLocation = new Location { Latitude = 47.644199, Longitude = -122.127049 }, EngineSupplier = engineSuppliers.Single(s => s.Name == "Renault") }; var ferrariEngine = new Engine { Name = "056", - StorageLocation = new Location - { - Latitude = 47.64256, - Longitude = -122.130609 - }, + StorageLocation = new Location { Latitude = 47.64256, Longitude = -122.130609 }, EngineSupplier = engineSuppliers.Single(s => s.Name == "Ferrari") }; var cosworthEngine = new Engine { Name = "CA2010", - StorageLocation = new Location - { - Latitude = 47.644851, - Longitude = -122.129781 - }, + StorageLocation = new Location { Latitude = 47.644851, Longitude = -122.129781 }, EngineSupplier = engineSuppliers.Single(s => s.Name == "Cosworth") }; - foreach (var engine in new List - { - mercedesEngine, - renaultEngine, - ferrariEngine, - cosworthEngine - }) + foreach (var engine in new List { mercedesEngine, renaultEngine, ferrariEngine, cosworthEngine }) { context.Engines.Add(engine); } @@ -112,10 +78,7 @@ private static void AddEntities(F1Context context) Id = Team.McLaren, Name = "Vodafone McLaren Mercedes", Constructor = "McLaren", - Chassis = new Chassis - { - Name = "MP4-25" - }, + Chassis = new Chassis { Name = "MP4-25" }, Engine = mercedesEngine, Tire = "Bridgestone", Principal = "Martin Whitmarsh", @@ -131,10 +94,7 @@ private static void AddEntities(F1Context context) Id = Team.Mercedes, Name = "Mercedes GP Petronas F1 Team", Constructor = "Mercedes", - Chassis = new Chassis - { - Name = "MGP W01" - }, + Chassis = new Chassis { Name = "MGP W01" }, Engine = mercedesEngine, Tire = "Bridgestone", Principal = "Ross Brawn", @@ -150,10 +110,7 @@ private static void AddEntities(F1Context context) Id = Team.RedBull, Name = "Red Bull Racing", Constructor = "Red Bull", - Chassis = new Chassis - { - Name = "RB6" - }, + Chassis = new Chassis { Name = "RB6" }, Engine = renaultEngine, Tire = "Bridgestone", Principal = "Christian Horner", @@ -169,10 +126,7 @@ private static void AddEntities(F1Context context) Id = Team.Ferrari, Name = "Scuderia Ferrari Marlboro", Constructor = "Ferrari", - Chassis = new Chassis - { - Name = "F10" - }, + Chassis = new Chassis { Name = "F10" }, Engine = ferrariEngine, Tire = "Bridgestone", Principal = "Stefano Domenicali", @@ -188,10 +142,7 @@ private static void AddEntities(F1Context context) Id = Team.Williams, Name = "AT&T Williams", Constructor = "Williams", - Chassis = new Chassis - { - Name = "FW32" - }, + Chassis = new Chassis { Name = "FW32" }, Engine = cosworthEngine, Tire = "Bridgestone", Principal = "Frank Williams/Patrick Head", @@ -207,10 +158,7 @@ private static void AddEntities(F1Context context) Id = Team.Renault, Name = "Renault F1 Team", Constructor = "Renault", - Chassis = new Chassis - { - Name = "R30" - }, + Chassis = new Chassis { Name = "R30" }, Engine = renaultEngine, Tire = "Bridgestone", Principal = "Eric Boullier", @@ -226,10 +174,7 @@ private static void AddEntities(F1Context context) Id = Team.ForceIndia, Name = "Force India F1 Team", Constructor = "Force India", - Chassis = new Chassis - { - Name = "VJM03" - }, + Chassis = new Chassis { Name = "VJM03" }, Engine = mercedesEngine, Tire = "Bridgestone", Principal = "Vijay Mallya", @@ -245,10 +190,7 @@ private static void AddEntities(F1Context context) Id = Team.ToroRosso, Name = "Scuderia Toro Rosso", Constructor = "Toro Rosso", - Chassis = new Chassis - { - Name = "STR5" - }, + Chassis = new Chassis { Name = "STR5" }, Engine = ferrariEngine, Tire = "Bridgestone", Principal = "Franz Tost", @@ -264,10 +206,7 @@ private static void AddEntities(F1Context context) Id = Team.Lotus, Name = "Lotus Racing", Constructor = "Lotus", - Chassis = new Chassis - { - Name = "T127" - }, + Chassis = new Chassis { Name = "T127" }, Engine = cosworthEngine, Tire = "Bridgestone", Principal = "Tony Fernandes", @@ -283,10 +222,7 @@ private static void AddEntities(F1Context context) Id = Team.Hispania, Name = "Hispania Racing F1 Team (HRT)", Constructor = "HRT", - Chassis = new Chassis - { - Name = "F110" - }, + Chassis = new Chassis { Name = "F110" }, Engine = cosworthEngine, Tire = "Bridgestone", Principal = "Colin Kolles", @@ -302,10 +238,7 @@ private static void AddEntities(F1Context context) Id = Team.Sauber, Name = "BMW Sauber F1 Team", Constructor = "Sauber", - Chassis = new Chassis - { - Name = "C29" - }, + Chassis = new Chassis { Name = "C29" }, Engine = ferrariEngine, Tire = "Bridgestone", Principal = "Peter Sauber", @@ -321,10 +254,7 @@ private static void AddEntities(F1Context context) Id = Team.Vickers, Name = "Vickers Racing", Constructor = "Vickers", - Chassis = new Chassis - { - Name = "VR-01" - }, + Chassis = new Chassis { Name = "VR-01" }, Engine = cosworthEngine, Tire = "Bridgestone", Principal = "John Booth", @@ -851,35 +781,12 @@ private static void AddEntities(F1Context context) context.Drivers.Add(driver); } - var shell = new Sponsor - { - Name = "Shell" - }; - var vodafone = new TitleSponsor - { - Name = "Vodafone", - Details = new SponsorDetails - { - Days = 10, - Space = 50m - } - }; - var bridgestone = new Sponsor - { - Name = "Bridgestone" - }; - var fia = new Sponsor - { - Name = "FIA" - }; + var shell = new Sponsor { Name = "Shell" }; + var vodafone = new TitleSponsor { Name = "Vodafone", Details = new SponsorDetails { Days = 10, Space = 50m } }; + var bridgestone = new Sponsor { Name = "Bridgestone" }; + var fia = new Sponsor { Name = "FIA" }; - foreach (var sponsor in new List - { - shell, - vodafone, - bridgestone, - fia - }) + foreach (var sponsor in new List { shell, vodafone, bridgestone, fia }) { context.Sponsors.Add(sponsor); } diff --git a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ApplicationDbContext.cs b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ApplicationDbContext.cs index 03c11609d08..aef00448b57 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ApplicationDbContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ApplicationDbContext.cs @@ -34,4 +34,3 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) public DbSet Attendees { get; set; } } } - diff --git a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SearchResult.cs b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SearchResult.cs index 2ed4971b035..60f29698918 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SearchResult.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SearchResult.cs @@ -1,5 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + namespace Microsoft.EntityFrameworkCore.TestModels.ConferencePlanner.ConferenceDTO { public class SearchResult diff --git a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SearchResultType.cs b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SearchResultType.cs index fa6a2d12eac..61300bb135f 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SearchResultType.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SearchResultType.cs @@ -1,5 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + namespace Microsoft.EntityFrameworkCore.TestModels.ConferencePlanner.ConferenceDTO { public enum SearchResultType diff --git a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SearchTerm.cs b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SearchTerm.cs index 3a94062f312..d3b98d2de9e 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SearchTerm.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/SearchTerm.cs @@ -1,5 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + namespace Microsoft.EntityFrameworkCore.TestModels.ConferencePlanner.ConferenceDTO { public class SearchTerm diff --git a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/EntityExtensions.cs b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/EntityExtensions.cs index 37327f01315..c372ceca874 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/EntityExtensions.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/EntityExtensions.cs @@ -2,53 +2,43 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Linq; +using Microsoft.EntityFrameworkCore.TestModels.ConferencePlanner.ConferenceDTO; namespace Microsoft.EntityFrameworkCore.TestModels.ConferencePlanner { public static class EntityExtensions { - public static ConferenceDTO.SessionResponse MapSessionResponse(this Session session) => - new ConferenceDTO.SessionResponse + public static SessionResponse MapSessionResponse(this Session session) => + new SessionResponse { Id = session.Id, Title = session.Title, StartTime = session.StartTime, EndTime = session.EndTime, Speakers = session.SessionSpeakers? - .Select(ss => new ConferenceDTO.Speaker - { - Id = ss.SpeakerId, - Name = ss.Speaker.Name - }) + .Select(ss => new ConferenceDTO.Speaker { Id = ss.SpeakerId, Name = ss.Speaker.Name }) .ToList(), TrackId = session.TrackId, - Track = new ConferenceDTO.Track - { - Id = session?.TrackId ?? 0, - Name = session.Track?.Name - }, + Track = new ConferenceDTO.Track { Id = session?.TrackId ?? 0, Name = session.Track?.Name }, Abstract = session.Abstract }; - public static ConferenceDTO.SpeakerResponse MapSpeakerResponse(this Speaker speaker) => - new ConferenceDTO.SpeakerResponse + public static SpeakerResponse MapSpeakerResponse(this Speaker speaker) => + new SpeakerResponse { Id = speaker.Id, Name = speaker.Name, Bio = speaker.Bio, WebSite = speaker.WebSite, Sessions = speaker.SessionSpeakers? - .Select(ss => - new ConferenceDTO.Session - { - Id = ss.SessionId, - Title = ss.Session.Title - }) + .Select( + ss => + new ConferenceDTO.Session { Id = ss.SessionId, Title = ss.Session.Title }) .ToList() }; - public static ConferenceDTO.AttendeeResponse MapAttendeeResponse(this Attendee attendee) => - new ConferenceDTO.AttendeeResponse + public static AttendeeResponse MapAttendeeResponse(this Attendee attendee) => + new AttendeeResponse { Id = attendee.Id, FirstName = attendee.FirstName, @@ -56,15 +46,16 @@ public static ConferenceDTO.AttendeeResponse MapAttendeeResponse(this Attendee a UserName = attendee.UserName, EmailAddress = attendee.EmailAddress, Sessions = attendee.SessionsAttendees? - .Select(sa => - new ConferenceDTO.Session - { - Id = sa.SessionId, - Title = sa.Session.Title, - StartTime = sa.Session.StartTime, - EndTime = sa.Session.EndTime - }) - .ToList(), + .Select( + sa => + new ConferenceDTO.Session + { + Id = sa.SessionId, + Title = sa.Session.Title, + StartTime = sa.Session.StartTime, + EndTime = sa.Session.EndTime + }) + .ToList() }; } } diff --git a/test/EFCore.Specification.Tests/TestModels/FunkyDataModel/FunkyDataContext.cs b/test/EFCore.Specification.Tests/TestModels/FunkyDataModel/FunkyDataContext.cs index 6af34116544..75c4a9a29d5 100644 --- a/test/EFCore.Specification.Tests/TestModels/FunkyDataModel/FunkyDataContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/FunkyDataModel/FunkyDataContext.cs @@ -16,97 +16,23 @@ public FunkyDataContext(DbContextOptions options) public static void Seed(FunkyDataContext context) { - var c11 = new FunkyCustomer - { - FirstName = "%Bar", - LastName = "%B", - NullableBool = true - }; - var c12 = new FunkyCustomer - { - FirstName = "Ba%r", - LastName = "a%", - NullableBool = true - }; - var c13 = new FunkyCustomer - { - FirstName = "Bar%", - LastName = "%B%", - NullableBool = true - }; - var c14 = new FunkyCustomer - { - FirstName = "%Ba%r%", - LastName = null, - NullableBool = false - }; - var c15 = new FunkyCustomer - { - FirstName = "B%a%%r%", - LastName = "r%", - NullableBool = false - }; - var c16 = new FunkyCustomer - { - FirstName = null, - LastName = "%B%a%r" - }; - var c17 = new FunkyCustomer - { - FirstName = "%B%a%r", - LastName = "" - }; - var c18 = new FunkyCustomer - { - FirstName = "", - LastName = "%%r%" - }; + var c11 = new FunkyCustomer { FirstName = "%Bar", LastName = "%B", NullableBool = true }; + var c12 = new FunkyCustomer { FirstName = "Ba%r", LastName = "a%", NullableBool = true }; + var c13 = new FunkyCustomer { FirstName = "Bar%", LastName = "%B%", NullableBool = true }; + var c14 = new FunkyCustomer { FirstName = "%Ba%r%", LastName = null, NullableBool = false }; + var c15 = new FunkyCustomer { FirstName = "B%a%%r%", LastName = "r%", NullableBool = false }; + var c16 = new FunkyCustomer { FirstName = null, LastName = "%B%a%r" }; + var c17 = new FunkyCustomer { FirstName = "%B%a%r", LastName = "" }; + var c18 = new FunkyCustomer { FirstName = "", LastName = "%%r%" }; - var c21 = new FunkyCustomer - { - FirstName = "_Bar", - LastName = "_B", - NullableBool = false - }; - var c22 = new FunkyCustomer - { - FirstName = "Ba_r", - LastName = "a_", - NullableBool = false - }; - var c23 = new FunkyCustomer - { - FirstName = "Bar_", - LastName = "_B_", - NullableBool = false - }; - var c24 = new FunkyCustomer - { - FirstName = "_Ba_r_", - LastName = null, - NullableBool = true - }; - var c25 = new FunkyCustomer - { - FirstName = "B_a__r_", - LastName = "r_", - NullableBool = true - }; - var c26 = new FunkyCustomer - { - FirstName = null, - LastName = "_B_a_r" - }; - var c27 = new FunkyCustomer - { - FirstName = "_B_a_r", - LastName = "" - }; - var c28 = new FunkyCustomer - { - FirstName = "", - LastName = "__r_" - }; + var c21 = new FunkyCustomer { FirstName = "_Bar", LastName = "_B", NullableBool = false }; + var c22 = new FunkyCustomer { FirstName = "Ba_r", LastName = "a_", NullableBool = false }; + var c23 = new FunkyCustomer { FirstName = "Bar_", LastName = "_B_", NullableBool = false }; + var c24 = new FunkyCustomer { FirstName = "_Ba_r_", LastName = null, NullableBool = true }; + var c25 = new FunkyCustomer { FirstName = "B_a__r_", LastName = "r_", NullableBool = true }; + var c26 = new FunkyCustomer { FirstName = null, LastName = "_B_a_r" }; + var c27 = new FunkyCustomer { FirstName = "_B_a_r", LastName = "" }; + var c28 = new FunkyCustomer { FirstName = "", LastName = "__r_" }; context.FunkyCustomers.AddRange(c11, c12, c13, c14, c15, c16, c17, c18, c21, c22, c23, c24, c25, c26, c27, c28); diff --git a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs index a6e4802ac42..fa734846d88 100644 --- a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs +++ b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs @@ -95,19 +95,7 @@ public virtual IQueryable Set() } public static IReadOnlyList CreateSquads() - => new List - { - new Squad - { - Id = 1, - Name = "Delta" - }, - new Squad - { - Id = 2, - Name = "Kilo" - } - }; + => new List { new Squad { Id = 1, Name = "Delta" }, new Squad { Id = 2, Name = "Kilo" } }; public static IReadOnlyList CreateMissions() => new List @@ -136,153 +124,46 @@ public static IReadOnlyList CreateMissions() }; public static IReadOnlyList CreateSquadMissions() - => new List - { - new SquadMission(), - new SquadMission(), - new SquadMission() - }; + => new List { new SquadMission(), new SquadMission(), new SquadMission() }; public static IReadOnlyList CreateCities() { - var jacinto = new City - { - Location = "Jacinto's location", - Name = "Jacinto", - Nation = "Tyrus" - }; + var jacinto = new City { Location = "Jacinto's location", Name = "Jacinto", Nation = "Tyrus" }; - var ephyra = new City - { - Location = "Ephyra's location", - Name = "Ephyra", - Nation = "Tyrus" - }; + var ephyra = new City { Location = "Ephyra's location", Name = "Ephyra", Nation = "Tyrus" }; - var hanover = new City - { - Location = "Hanover's location", - Name = "Hanover" - }; + var hanover = new City { Location = "Hanover's location", Name = "Hanover" }; - var unknown = new City - { - Location = "Unknown", - Name = "Unknown" - }; + var unknown = new City { Location = "Unknown", Name = "Unknown" }; - var cities = new List - { jacinto, ephyra, hanover, unknown }; + var cities = new List { jacinto, ephyra, hanover, unknown }; return cities; } public static IReadOnlyList CreateWeapons() => new List { - new Weapon - { - Id = 1, - Name = "Marcus' Lancer", - AmmunitionType = AmmunitionType.Cartridge, - IsAutomatic = true - }, - new Weapon - { - Id = 2, - Name = "Marcus' Gnasher", - AmmunitionType = AmmunitionType.Shell, - IsAutomatic = false - }, - new Weapon - { - Id = 3, - Name = "Dom's Hammerburst", - AmmunitionType = AmmunitionType.Cartridge, - IsAutomatic = false - }, - new Weapon - { - Id = 4, - Name = "Dom's Gnasher", - AmmunitionType = AmmunitionType.Shell, - IsAutomatic = false - }, - new Weapon - { - Id = 5, - Name = "Cole's Gnasher", - AmmunitionType = AmmunitionType.Shell, - IsAutomatic = false - }, - new Weapon - { - Id = 6, - Name = "Cole's Mulcher", - AmmunitionType = AmmunitionType.Cartridge, - IsAutomatic = true - }, - new Weapon - { - Id = 7, - Name = "Baird's Lancer", - AmmunitionType = AmmunitionType.Cartridge, - IsAutomatic = true - }, - new Weapon - { - Id = 8, - Name = "Baird's Gnasher", - AmmunitionType = AmmunitionType.Shell, - IsAutomatic = false - }, - new Weapon - { - Id = 9, - Name = "Paduk's Markza", - AmmunitionType = AmmunitionType.Cartridge, - IsAutomatic = false - }, - new Weapon - { - Id = 10, - Name = "Mauler's Flail", - IsAutomatic = false - } + new Weapon { Id = 1, Name = "Marcus' Lancer", AmmunitionType = AmmunitionType.Cartridge, IsAutomatic = true }, + new Weapon { Id = 2, Name = "Marcus' Gnasher", AmmunitionType = AmmunitionType.Shell, IsAutomatic = false }, + new Weapon { Id = 3, Name = "Dom's Hammerburst", AmmunitionType = AmmunitionType.Cartridge, IsAutomatic = false }, + new Weapon { Id = 4, Name = "Dom's Gnasher", AmmunitionType = AmmunitionType.Shell, IsAutomatic = false }, + new Weapon { Id = 5, Name = "Cole's Gnasher", AmmunitionType = AmmunitionType.Shell, IsAutomatic = false }, + new Weapon { Id = 6, Name = "Cole's Mulcher", AmmunitionType = AmmunitionType.Cartridge, IsAutomatic = true }, + new Weapon { Id = 7, Name = "Baird's Lancer", AmmunitionType = AmmunitionType.Cartridge, IsAutomatic = true }, + new Weapon { Id = 8, Name = "Baird's Gnasher", AmmunitionType = AmmunitionType.Shell, IsAutomatic = false }, + new Weapon { Id = 9, Name = "Paduk's Markza", AmmunitionType = AmmunitionType.Cartridge, IsAutomatic = false }, + new Weapon { Id = 10, Name = "Mauler's Flail", IsAutomatic = false } }; public static IReadOnlyList CreateTags() => new List { - new CogTag - { - Id = Guid.Parse("DF36F493-463F-4123-83F9-6B135DEEB7BA"), - Note = "Dom's Tag" - }, - new CogTag - { - Id = Guid.Parse("A8AD98F9-E023-4E2A-9A70-C2728455BD34"), - Note = "Cole's Tag" - }, - new CogTag - { - Id = Guid.Parse("A7BE028A-0CF2-448F-AB55-CE8BC5D8CF69"), - Note = "Paduk's Tag" - }, - new CogTag - { - Id = Guid.Parse("70534E05-782C-4052-8720-C2C54481CE5F"), - Note = "Baird's Tag" - }, - new CogTag - { - Id = Guid.Parse("34C8D86E-A4AC-4BE5-827F-584DDA348A07"), - Note = "Marcus' Tag" - }, - new CogTag - { - Id = Guid.Parse("B39A6FBA-9026-4D69-828E-FD7068673E57"), - Note = "K.I.A." - } + new CogTag { Id = Guid.Parse("DF36F493-463F-4123-83F9-6B135DEEB7BA"), Note = "Dom's Tag" }, + new CogTag { Id = Guid.Parse("A8AD98F9-E023-4E2A-9A70-C2728455BD34"), Note = "Cole's Tag" }, + new CogTag { Id = Guid.Parse("A7BE028A-0CF2-448F-AB55-CE8BC5D8CF69"), Note = "Paduk's Tag" }, + new CogTag { Id = Guid.Parse("70534E05-782C-4052-8720-C2C54481CE5F"), Note = "Baird's Tag" }, + new CogTag { Id = Guid.Parse("34C8D86E-A4AC-4BE5-827F-584DDA348A07"), Note = "Marcus' Tag" }, + new CogTag { Id = Guid.Parse("B39A6FBA-9026-4D69-828E-FD7068673E57"), Note = "K.I.A." } }; public static IReadOnlyList CreateGears() @@ -346,67 +227,23 @@ public static IReadOnlyList CreateGears() public static IReadOnlyList CreateLocustLeaders() => new List { - new LocustLeader - { - Name = "General Karn", - ThreatLevel = 3 - }, - new LocustLeader - { - Name = "General RAAM", - ThreatLevel = 4 - }, - new LocustLeader - { - Name = "High Priest Skorge", - ThreatLevel = 1 - }, - new LocustCommander - { - Name = "Queen Myrrah", - ThreatLevel = 5 - }, - new LocustLeader - { - Name = "The Speaker", - ThreatLevel = 3 - }, - new LocustCommander - { - Name = "Unknown", - ThreatLevel = 0 - } + new LocustLeader { Name = "General Karn", ThreatLevel = 3 }, + new LocustLeader { Name = "General RAAM", ThreatLevel = 4 }, + new LocustLeader { Name = "High Priest Skorge", ThreatLevel = 1 }, + new LocustCommander { Name = "Queen Myrrah", ThreatLevel = 5 }, + new LocustLeader { Name = "The Speaker", ThreatLevel = 3 }, + new LocustCommander { Name = "Unknown", ThreatLevel = 0 } }; public static IReadOnlyList CreateFactions() => new List { - new LocustHorde - { - Id = 1, - Name = "Locust", - Eradicated = true, - CommanderName = "Queen Myrrah" - }, - new LocustHorde - { - Id = 2, - Name = "Swarm", - Eradicated = false, - CommanderName = "Unknown" - } + new LocustHorde { Id = 1, Name = "Locust", Eradicated = true, CommanderName = "Queen Myrrah" }, + new LocustHorde { Id = 2, Name = "Swarm", Eradicated = false, CommanderName = "Unknown" } }; public static IReadOnlyList CreateHighCommands() - => new List - { - new LocustHighCommand - { - Id = 1, - Name = "Locust Main Command", - IsOperational = true - } - }; + => new List { new LocustHighCommand { Id = 1, Name = "Locust Main Command", IsOperational = true } }; public static void WireUp( IReadOnlyList squads, @@ -433,39 +270,14 @@ public static void WireUp( squadMissions[2].Squad = squads[1]; squadMissions[2].SquadId = squads[1].Id; - missions[0].ParticipatingSquads = new List - { - squadMissions[0] - }; - missions[1].ParticipatingSquads = new List - { - squadMissions[1] - }; - missions[2].ParticipatingSquads = new List - { - squadMissions[2] - }; - squads[0].Missions = new List - { - squadMissions[0], - squadMissions[1] - }; - squads[1].Missions = new List - { - squadMissions[2] - }; + missions[0].ParticipatingSquads = new List { squadMissions[0] }; + missions[1].ParticipatingSquads = new List { squadMissions[1] }; + missions[2].ParticipatingSquads = new List { squadMissions[2] }; + squads[0].Missions = new List { squadMissions[0], squadMissions[1] }; + squads[1].Missions = new List { squadMissions[2] }; - squads[0].Members = new List - { - gears[0], - gears[1], - gears[3], - gears[4] - }; - squads[1].Members = new List - { - gears[2] - }; + squads[0].Members = new List { gears[0], gears[1], gears[3], gears[4] }; + squads[1].Members = new List { gears[2] }; weapons[1].SynergyWith = weapons[0]; weapons[1].SynergyWithId = weapons[0].Id; @@ -476,11 +288,7 @@ public static void WireUp( gears[0].CityOrBirthName = cities[1].Name; gears[0].Squad = squads[0]; gears[0].Tag = tags[0]; - gears[0].Weapons = new List - { - weapons[2], - weapons[3] - }; + gears[0].Weapons = new List { weapons[2], weapons[3] }; // cole gears[1].AssignedCity = cities[0]; @@ -488,11 +296,7 @@ public static void WireUp( gears[1].CityOrBirthName = cities[2].Name; gears[1].Squad = squads[0]; gears[1].Tag = tags[1]; - gears[1].Weapons = new List - { - weapons[4], - weapons[5] - }; + gears[1].Weapons = new List { weapons[4], weapons[5] }; // paduk gears[2].AssignedCity = cities[3]; @@ -500,10 +304,7 @@ public static void WireUp( gears[2].CityOrBirthName = cities[3].Name; gears[2].Squad = squads[1]; gears[2].Tag = tags[2]; - gears[2].Weapons = new List - { - weapons[8] - }; + gears[2].Weapons = new List { weapons[8] }; // baird gears[3].AssignedCity = cities[0]; @@ -511,64 +312,25 @@ public static void WireUp( gears[3].CityOrBirthName = cities[3].Name; gears[3].Squad = squads[0]; gears[3].Tag = tags[3]; - gears[3].Weapons = new List - { - weapons[6], - weapons[7] - }; - ((Officer)gears[3]).Reports = new List - { - gears[2] - }; + gears[3].Weapons = new List { weapons[6], weapons[7] }; + ((Officer)gears[3]).Reports = new List { gears[2] }; // marcus gears[4].CityOfBirth = cities[0]; gears[4].CityOrBirthName = cities[0].Name; gears[4].Squad = squads[0]; gears[4].Tag = tags[4]; - gears[4].Weapons = new List - { - weapons[0], - weapons[1] - }; - ((Officer)gears[4]).Reports = new List - { - gears[0], - gears[1], - gears[3] - }; - - cities[0].BornGears = new List - { - gears[4] - }; - cities[1].BornGears = new List - { - gears[0] - }; - cities[2].BornGears = new List - { - gears[1] - }; - cities[3].BornGears = new List - { - gears[2], - gears[3] - }; - cities[0].StationedGears = new List - { - gears[1], - gears[3] - }; - cities[1].StationedGears = new List - { - gears[0] - }; + gears[4].Weapons = new List { weapons[0], weapons[1] }; + ((Officer)gears[4]).Reports = new List { gears[0], gears[1], gears[3] }; + + cities[0].BornGears = new List { gears[4] }; + cities[1].BornGears = new List { gears[0] }; + cities[2].BornGears = new List { gears[1] }; + cities[3].BornGears = new List { gears[2], gears[3] }; + cities[0].StationedGears = new List { gears[1], gears[3] }; + cities[1].StationedGears = new List { gears[0] }; cities[2].StationedGears = new List(); - cities[3].StationedGears = new List - { - gears[2] - }; + cities[3].StationedGears = new List { gears[2] }; weapons[0].Owner = gears[4]; weapons[0].OwnerFullName = gears[4].FullName; @@ -617,8 +379,7 @@ public static void WireUp( locustHighCommands[0].Commanders = new List { - (LocustCommander)locustLeaders[3], - (LocustCommander)locustLeaders[5] + (LocustCommander)locustLeaders[3], (LocustCommander)locustLeaders[5] }; ((LocustCommander)locustLeaders[3]).HighCommand = locustHighCommands[0]; @@ -634,16 +395,9 @@ public static void WireUp2( { ((LocustHorde)factions[0]).Leaders = new List { - locustLeaders[0], - locustLeaders[1], - locustLeaders[2], - locustLeaders[3] - }; - ((LocustHorde)factions[1]).Leaders = new List - { - locustLeaders[4], - locustLeaders[5] + locustLeaders[0], locustLeaders[1], locustLeaders[2], locustLeaders[3] }; + ((LocustHorde)factions[1]).Leaders = new List { locustLeaders[4], locustLeaders[5] }; } } } diff --git a/test/EFCore.Specification.Tests/TestModels/Inheritance/InheritanceContext.cs b/test/EFCore.Specification.Tests/TestModels/Inheritance/InheritanceContext.cs index 4e87f18ccfe..40d0186ea0c 100644 --- a/test/EFCore.Specification.Tests/TestModels/Inheritance/InheritanceContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/Inheritance/InheritanceContext.cs @@ -14,49 +14,21 @@ public InheritanceContext(DbContextOptions options) public static void SeedData(InheritanceContext context) { - var kiwi = new Kiwi - { - Species = "Apteryx haastii", - Name = "Great spotted kiwi", - IsFlightless = true, - FoundOn = Island.South - }; + var kiwi = new Kiwi { Species = "Apteryx haastii", Name = "Great spotted kiwi", IsFlightless = true, FoundOn = Island.South }; - var eagle = new Eagle - { - Species = "Aquila chrysaetos canadensis", - Name = "American golden eagle", - Group = EagleGroup.Booted - }; + var eagle = new Eagle { Species = "Aquila chrysaetos canadensis", Name = "American golden eagle", Group = EagleGroup.Booted }; eagle.Prey.Add(kiwi); - var rose = new Rose - { - Species = "Rosa canina", - Name = "Dog-rose", - HasThorns = true - }; + var rose = new Rose { Species = "Rosa canina", Name = "Dog-rose", HasThorns = true }; - var daisy = new Daisy - { - Species = "Bellis perennis", - Name = "Common daisy" - }; + var daisy = new Daisy { Species = "Bellis perennis", Name = "Common daisy" }; - var nz = new Country - { - Id = 1, - Name = "New Zealand" - }; + var nz = new Country { Id = 1, Name = "New Zealand" }; nz.Animals.Add(kiwi); - var usa = new Country - { - Id = 2, - Name = "USA" - }; + var usa = new Country { Id = 2, Name = "USA" }; usa.Animals.Add(eagle); @@ -68,22 +40,9 @@ public static void SeedData(InheritanceContext context) context.Set().Add(daisy); context.AddRange( - new Tea - { - HasMilk = true, - CaffeineGrams = 1 - }, - new Lilt - { - SugarGrams = 4, - Carbonation = 7 - }, - new Coke - { - SugarGrams = 6, - CaffeineGrams = 4, - Carbonation = 5 - }); + new Tea { HasMilk = true, CaffeineGrams = 1 }, + new Lilt { SugarGrams = 4, Carbonation = 7 }, + new Coke { SugarGrams = 6, CaffeineGrams = 4, Carbonation = 5 }); context.SaveChanges(); } diff --git a/test/EFCore.Specification.Tests/TestModels/InheritanceRelationships/InheritanceRelationshipsContext.cs b/test/EFCore.Specification.Tests/TestModels/InheritanceRelationships/InheritanceRelationshipsContext.cs index 1ff2b5621e2..351c03cc55b 100644 --- a/test/EFCore.Specification.Tests/TestModels/InheritanceRelationships/InheritanceRelationshipsContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/InheritanceRelationships/InheritanceRelationshipsContext.cs @@ -35,226 +35,92 @@ public InheritanceRelationshipsContext(DbContextOptions options) public static void Seed(InheritanceRelationshipsContext context) { - var nrb1 = new NestedReferenceBase - { - Name = "NRB1" - }; - var nrb2 = new NestedReferenceBase - { - Name = "NRB2" - }; - var nrb3 = new NestedReferenceBase - { - Name = "NRB3" - }; - var nrb4 = new NestedReferenceBase - { - Name = "NRB4 (dangling)" - }; + var nrb1 = new NestedReferenceBase { Name = "NRB1" }; + var nrb2 = new NestedReferenceBase { Name = "NRB2" }; + var nrb3 = new NestedReferenceBase { Name = "NRB3" }; + var nrb4 = new NestedReferenceBase { Name = "NRB4 (dangling)" }; context.NestedReferences.AddRange(nrb1, nrb2, nrb3, nrb4); - var nrd1 = new NestedReferenceDerived - { - Name = "NRD1" - }; - var nrd2 = new NestedReferenceDerived - { - Name = "NRD2" - }; - var nrd3 = new NestedReferenceDerived - { - Name = "NRD3" - }; - var nrd4 = new NestedReferenceDerived - { - Name = "NRD4" - }; - var nrd5 = new NestedReferenceDerived - { - Name = "NRD4 (dangling)" - }; + var nrd1 = new NestedReferenceDerived { Name = "NRD1" }; + var nrd2 = new NestedReferenceDerived { Name = "NRD2" }; + var nrd3 = new NestedReferenceDerived { Name = "NRD3" }; + var nrd4 = new NestedReferenceDerived { Name = "NRD4" }; + var nrd5 = new NestedReferenceDerived { Name = "NRD4 (dangling)" }; context.NestedReferences.AddRange(nrd1, nrd2, nrd3, nrd5); - var ncb11 = new NestedCollectionBase - { - Name = "NCB11" - }; - var ncb21 = new NestedCollectionBase - { - Name = "NCB21" - }; - var ncb22 = new NestedCollectionBase - { - Name = "NCB22" - }; - var ncb31 = new NestedCollectionBase - { - Name = "NCB31" - }; - var ncb41 = new NestedCollectionBase - { - Name = "NCB41 (dangling)" - }; + var ncb11 = new NestedCollectionBase { Name = "NCB11" }; + var ncb21 = new NestedCollectionBase { Name = "NCB21" }; + var ncb22 = new NestedCollectionBase { Name = "NCB22" }; + var ncb31 = new NestedCollectionBase { Name = "NCB31" }; + var ncb41 = new NestedCollectionBase { Name = "NCB41 (dangling)" }; context.NestedCollections.AddRange(ncb11, ncb21, ncb22, ncb31, ncb41); - var ncd11 = new NestedCollectionDerived - { - Name = "NCD11" - }; - var ncd21 = new NestedCollectionDerived - { - Name = "NCD21" - }; - var ncd31 = new NestedCollectionDerived - { - Name = "NCD21" - }; - var ncd32 = new NestedCollectionDerived - { - Name = "NCD32" - }; - var ncd41 = new NestedCollectionDerived - { - Name = "NCD41" - }; - var ncd42 = new NestedCollectionDerived - { - Name = "NCD42" - }; - var ncd51 = new NestedCollectionDerived - { - Name = "NCD52 (dangling)" - }; - var ncd52 = new NestedCollectionDerived - { - Name = "NCD52 (dangling)" - }; + var ncd11 = new NestedCollectionDerived { Name = "NCD11" }; + var ncd21 = new NestedCollectionDerived { Name = "NCD21" }; + var ncd31 = new NestedCollectionDerived { Name = "NCD21" }; + var ncd32 = new NestedCollectionDerived { Name = "NCD32" }; + var ncd41 = new NestedCollectionDerived { Name = "NCD41" }; + var ncd42 = new NestedCollectionDerived { Name = "NCD42" }; + var ncd51 = new NestedCollectionDerived { Name = "NCD52 (dangling)" }; + var ncd52 = new NestedCollectionDerived { Name = "NCD52 (dangling)" }; context.NestedCollections.AddRange(ncd11, ncd21, ncd31, ncd32, ncd41, ncd42, ncd51, ncd52); var brob1 = new BaseReferenceOnBase { - Name = "BROB1", - NestedReference = nrb1, - NestedCollection = new List - { - ncb11 - } + Name = "BROB1", NestedReference = nrb1, NestedCollection = new List { ncb11 } }; var brob2 = new BaseReferenceOnBase { - Name = "BROB2", - NestedReference = nrd1, - NestedCollection = new List - { - ncd11 - } - }; - var brob3 = new BaseReferenceOnBase - { - Name = "BROB3 (dangling)" + Name = "BROB2", NestedReference = nrd1, NestedCollection = new List { ncd11 } }; + var brob3 = new BaseReferenceOnBase { Name = "BROB3 (dangling)" }; context.BaseReferencesOnBase.AddRange(brob1, brob2, brob3); var drob1 = new DerivedReferenceOnBase { - Name = "DROB1", - NestedReference = nrb2, - NestedCollection = new List - { - ncb21, - ncb22 - } + Name = "DROB1", NestedReference = nrb2, NestedCollection = new List { ncb21, ncb22 } }; var drob2 = new DerivedReferenceOnBase { - Name = "DROB2", - NestedReference = nrd2, - NestedCollection = new List - { - ncd21 - } - }; - var drob3 = new DerivedReferenceOnBase - { - Name = "DROB3" + Name = "DROB2", NestedReference = nrd2, NestedCollection = new List { ncd21 } }; + var drob3 = new DerivedReferenceOnBase { Name = "DROB3" }; var drob4 = new DerivedReferenceOnBase { Name = "DROB4 (half-dangling)", NestedReference = nrd3, - NestedCollection = new List - { - ncd31, - ncd32 - } - }; - var drob5 = new DerivedReferenceOnBase - { - Name = "DROB5 (dangling)" + NestedCollection = new List { ncd31, ncd32 } }; + var drob5 = new DerivedReferenceOnBase { Name = "DROB5 (dangling)" }; context.BaseReferencesOnBase.AddRange(drob1, drob2, drob3, drob4, drob5); - var rob1 = new ReferenceOnBase - { - Name = "ROB1" - }; - var rob2 = new ReferenceOnBase - { - Name = "ROB2" - }; - var rob3 = new ReferenceOnBase - { - Name = "ROB3" - }; - var rob4 = new ReferenceOnBase - { - Name = "ROB4" - }; + var rob1 = new ReferenceOnBase { Name = "ROB1" }; + var rob2 = new ReferenceOnBase { Name = "ROB2" }; + var rob3 = new ReferenceOnBase { Name = "ROB3" }; + var rob4 = new ReferenceOnBase { Name = "ROB4" }; context.ReferencesOnBase.AddRange(rob1, rob2, rob3, rob4); var bcob11 = new BaseCollectionOnBase { - Name = "BCOB11", - NestedReference = nrb1, - NestedCollection = new List - { - ncb11 - } + Name = "BCOB11", NestedReference = nrb1, NestedCollection = new List { ncb11 } }; var bcob12 = new BaseCollectionOnBase { - Name = "BCOB12", - NestedReference = nrd1, - NestedCollection = new List - { - ncd11 - } - }; - var bcob21 = new BaseCollectionOnBase - { - Name = "BCOB21" + Name = "BCOB12", NestedReference = nrd1, NestedCollection = new List { ncd11 } }; + var bcob21 = new BaseCollectionOnBase { Name = "BCOB21" }; var bcob31 = new BaseCollectionOnBase { - Name = "BCOB31 (dangling)", - NestedReference = nrb2, - NestedCollection = new List - { - ncb21, - ncb22 - } - }; - var bcob32 = new BaseCollectionOnBase - { - Name = "BCOB32 (dangling)" + Name = "BCOB31 (dangling)", NestedReference = nrb2, NestedCollection = new List { ncb21, ncb22 } }; + var bcob32 = new BaseCollectionOnBase { Name = "BCOB32 (dangling)" }; context.BaseCollectionsOnBase.AddRange(bcob11, bcob12, bcob21, bcob31, bcob32); @@ -262,201 +128,84 @@ public static void Seed(InheritanceRelationshipsContext context) { Name = "DCOB11", NestedReference = nrd2, - NestedCollection = new List - { - ncd21 - }, + NestedCollection = new List { ncd21 }, DerivedProperty = 1 }; var dcob12 = new DerivedCollectionOnBase { Name = "DCOB12", NestedReference = nrb3, - NestedCollection = new List - { - ncb31 - }, + NestedCollection = new List { ncb31 }, DerivedProperty = 2 }; - var dcob21 = new DerivedCollectionOnBase - { - Name = "DCOB21", - DerivedProperty = 3 - }; + var dcob21 = new DerivedCollectionOnBase { Name = "DCOB21", DerivedProperty = 3 }; var dcob31 = new DerivedCollectionOnBase { Name = "DCOB31", NestedReference = nrd3, - NestedCollection = new List - { - ncd31, - ncd32 - }, + NestedCollection = new List { ncd31, ncd32 }, DerivedProperty = 4 }; - var dcob32 = new DerivedCollectionOnBase - { - Name = "DCOB32", - DerivedProperty = 5 - }; - var dcob41 = new DerivedCollectionOnBase - { - Name = "DCOB41", - DerivedProperty = 6 - }; + var dcob32 = new DerivedCollectionOnBase { Name = "DCOB32", DerivedProperty = 5 }; + var dcob41 = new DerivedCollectionOnBase { Name = "DCOB41", DerivedProperty = 6 }; var dcob51 = new DerivedCollectionOnBase { Name = "DCOB51 (dangling)", NestedReference = nrd4, - NestedCollection = new List - { - ncd41, - ncd42 - }, + NestedCollection = new List { ncd41, ncd42 }, DerivedProperty = 7 }; - var dcob52 = new DerivedCollectionOnBase - { - Name = "DCOB52 (dangling)", - DerivedProperty = 8 - }; + var dcob52 = new DerivedCollectionOnBase { Name = "DCOB52 (dangling)", DerivedProperty = 8 }; context.BaseCollectionsOnBase.AddRange(dcob11, dcob12, dcob21, dcob31, dcob32, dcob41, dcob51, dcob52); - var cob11 = new CollectionOnBase - { - Name = "COB11" - }; - var cob12 = new CollectionOnBase - { - Name = "COB12" - }; - var cob21 = new CollectionOnBase - { - Name = "COB21" - }; - var cob31 = new CollectionOnBase - { - Name = "COB31" - }; - var cob32 = new CollectionOnBase - { - Name = "COB32" - }; - var cob33 = new CollectionOnBase - { - Name = "COB33" - }; - var cob41 = new CollectionOnBase - { - Name = "COB41" - }; - var cob51 = new CollectionOnBase - { - Name = "COB51 (dangling)" - }; - var cob52 = new CollectionOnBase - { - Name = "COB52 (dangling)" - }; + var cob11 = new CollectionOnBase { Name = "COB11" }; + var cob12 = new CollectionOnBase { Name = "COB12" }; + var cob21 = new CollectionOnBase { Name = "COB21" }; + var cob31 = new CollectionOnBase { Name = "COB31" }; + var cob32 = new CollectionOnBase { Name = "COB32" }; + var cob33 = new CollectionOnBase { Name = "COB33" }; + var cob41 = new CollectionOnBase { Name = "COB41" }; + var cob51 = new CollectionOnBase { Name = "COB51 (dangling)" }; + var cob52 = new CollectionOnBase { Name = "COB52 (dangling)" }; context.CollectionsOnBase.AddRange(cob11, cob12, cob21, cob31, cob32, cob33, cob41, cob51, cob52); - var brod1 = new BaseReferenceOnDerived - { - Name = "BROD1" - }; - var brod2 = new BaseReferenceOnDerived - { - Name = "BROD2 (dangling)" - }; - var brod3 = new BaseReferenceOnDerived - { - Name = "BROD3 (dangling)" - }; + var brod1 = new BaseReferenceOnDerived { Name = "BROD1" }; + var brod2 = new BaseReferenceOnDerived { Name = "BROD2 (dangling)" }; + var brod3 = new BaseReferenceOnDerived { Name = "BROD3 (dangling)" }; context.BaseReferencesOnDerived.AddRange(brod1, brod2, brod3); - var drod1 = new DerivedReferenceOnDerived - { - Name = "DROD1" - }; - var drod2 = new DerivedReferenceOnDerived - { - Name = "DROD2" - }; - var drod3 = new DerivedReferenceOnDerived - { - Name = "DROD3 (dangling)" - }; + var drod1 = new DerivedReferenceOnDerived { Name = "DROD1" }; + var drod2 = new DerivedReferenceOnDerived { Name = "DROD2" }; + var drod3 = new DerivedReferenceOnDerived { Name = "DROD3 (dangling)" }; context.BaseReferencesOnDerived.AddRange(drod1, drod2, drod3); - var rod1 = new ReferenceOnDerived - { - Name = "ROD1" - }; - var rod2 = new ReferenceOnDerived - { - Name = "ROD2" - }; - var rod3 = new ReferenceOnDerived - { - Name = "ROD3 (dangling)" - }; + var rod1 = new ReferenceOnDerived { Name = "ROD1" }; + var rod2 = new ReferenceOnDerived { Name = "ROD2" }; + var rod3 = new ReferenceOnDerived { Name = "ROD3 (dangling)" }; context.ReferencesOnDerived.AddRange(rod1, rod2, rod3); - var bcod11 = new BaseCollectionOnDerived - { - Name = "BCOD11" - }; - var bcod21 = new BaseCollectionOnDerived - { - Name = "BCOD21 (dangling)" - }; - var bcod22 = new BaseCollectionOnDerived - { - Name = "BCOD22 (dangling)" - }; + var bcod11 = new BaseCollectionOnDerived { Name = "BCOD11" }; + var bcod21 = new BaseCollectionOnDerived { Name = "BCOD21 (dangling)" }; + var bcod22 = new BaseCollectionOnDerived { Name = "BCOD22 (dangling)" }; context.BaseCollectionsOnDerived.AddRange(bcod11, bcod21, bcod22); - var dcod11 = new DerivedCollectionOnDerived - { - Name = "DCOD11" - }; - var dcod12 = new DerivedCollectionOnDerived - { - Name = "DCOD12" - }; - var dcod21 = new DerivedCollectionOnDerived - { - Name = "DCOD21" - }; - var dcod31 = new DerivedCollectionOnDerived - { - Name = "DCOD31 (dangling)" - }; + var dcod11 = new DerivedCollectionOnDerived { Name = "DCOD11" }; + var dcod12 = new DerivedCollectionOnDerived { Name = "DCOD12" }; + var dcod21 = new DerivedCollectionOnDerived { Name = "DCOD21" }; + var dcod31 = new DerivedCollectionOnDerived { Name = "DCOD31 (dangling)" }; context.BaseCollectionsOnDerived.AddRange(dcod11, dcod12, dcod21, dcod31); - var cod11 = new CollectionOnDerived - { - Name = "COD11" - }; - var cod21 = new CollectionOnDerived - { - Name = "COD21" - }; - var cod22 = new CollectionOnDerived - { - Name = "COD22" - }; - var cod31 = new CollectionOnDerived - { - Name = "COD31 (dangling)" - }; + var cod11 = new CollectionOnDerived { Name = "COD11" }; + var cod21 = new CollectionOnDerived { Name = "COD21" }; + var cod22 = new CollectionOnDerived { Name = "COD22" }; + var cod31 = new CollectionOnDerived { Name = "COD31 (dangling)" }; context.CollectionsOnDerived.AddRange(cod11, cod21, cod22, cod31); @@ -465,15 +214,8 @@ public static void Seed(InheritanceRelationshipsContext context) Name = "Base1", BaseReferenceOnBase = brob1, ReferenceOnBase = rob1, - BaseCollectionOnBase = new List - { - bcob11 - }, - CollectionOnBase = new List - { - cob11, - cob12 - } + BaseCollectionOnBase = new List { bcob11 }, + CollectionOnBase = new List { cob11, cob12 } }; var baseEntity2 = new BaseInheritanceRelationshipEntity @@ -481,19 +223,12 @@ public static void Seed(InheritanceRelationshipsContext context) Name = "Base2", BaseReferenceOnBase = drob2, ReferenceOnBase = rob2, - CollectionOnBase = new List - { - cob21 - } + CollectionOnBase = new List { cob21 } }; var baseEntity3 = new BaseInheritanceRelationshipEntity { - Name = "Base3", - BaseCollectionOnBase = new List - { - dcob21 - } + Name = "Base3", BaseCollectionOnBase = new List { dcob21 } }; context.BaseEntities.AddRange(baseEntity1, baseEntity2, baseEntity3); @@ -504,32 +239,14 @@ public static void Seed(InheritanceRelationshipsContext context) BaseSelfReferenceOnDerived = baseEntity1, BaseReferenceOnBase = drob1, ReferenceOnBase = rob3, - BaseCollectionOnBase = new List - { - dcob11, - dcob12 - }, - CollectionOnBase = new List - { - cob31, - cob32 - }, + BaseCollectionOnBase = new List { dcob11, dcob12 }, + CollectionOnBase = new List { cob31, cob32 }, BaseReferenceOnDerived = brod1, DerivedReferenceOnDerived = drod1, ReferenceOnDerived = rod1, - BaseCollectionOnDerived = new List - { - bcod11 - }, - DerivedCollectionOnDerived = new List - { - dcod11, - dcod12 - }, - CollectionOnDerived = new List - { - cod11 - } + BaseCollectionOnDerived = new List { bcod11 }, + DerivedCollectionOnDerived = new List { dcod11, dcod12 }, + CollectionOnDerived = new List { cod11 } }; var derivedEntity2 = new DerivedInheritanceRelationshipEntity @@ -538,37 +255,20 @@ public static void Seed(InheritanceRelationshipsContext context) BaseSelfReferenceOnDerived = baseEntity2, ReferenceOnBase = rob4, BaseReferenceOnBase = brob2, - CollectionOnBase = new List - { - cob41 - }, + CollectionOnBase = new List { cob41 }, BaseReferenceOnDerived = drod2, ReferenceOnDerived = rod2, - CollectionOnDerived = new List - { - cod21, - cod22 - } + CollectionOnDerived = new List { cod21, cod22 } }; var derivedEntity3 = new DerivedInheritanceRelationshipEntity { Name = "Derived3(6)", BaseSelfReferenceOnDerived = baseEntity3, - BaseCollectionOnBase = new List - { - bcob21 - }, + BaseCollectionOnBase = new List { bcob21 }, DerivedReferenceOnDerived = drod2, - BaseCollectionOnDerived = new List - { - dcod11, - dcod12 - }, - DerivedCollectionOnDerived = new List - { - dcod21 - } + BaseCollectionOnDerived = new List { dcod11, dcod12 }, + DerivedCollectionOnDerived = new List { dcod21 } }; context.BaseEntities.AddRange(derivedEntity1, derivedEntity2, derivedEntity3); @@ -577,33 +277,13 @@ public static void Seed(InheritanceRelationshipsContext context) baseEntity2.DerivedSefReferenceOnBase = derivedEntity2; baseEntity3.DerivedSefReferenceOnBase = derivedEntity3; - var principalEntity1 = new PrincipalEntity - { - Name = "PE1" - }; - var principalEntity2 = new PrincipalEntity - { - Name = "PE2" - }; + var principalEntity1 = new PrincipalEntity { Name = "PE1" }; + var principalEntity2 = new PrincipalEntity { Name = "PE2" }; context.PrincipalEntities.AddRange(principalEntity1, principalEntity2); - var referencedEntity1 = new ReferencedEntity - { - Name = "RE1", - Principals = new List - { - principalEntity1 - } - }; - var referencedEntity2 = new ReferencedEntity - { - Name = "RE2", - Principals = new List - { - principalEntity2 - } - }; + var referencedEntity1 = new ReferencedEntity { Name = "RE1", Principals = new List { principalEntity1 } }; + var referencedEntity2 = new ReferencedEntity { Name = "RE2", Principals = new List { principalEntity2 } }; context.ReferencedEntities.AddRange(referencedEntity1, referencedEntity2); diff --git a/test/EFCore.Specification.Tests/TestModels/MonsterContext`.cs b/test/EFCore.Specification.Tests/TestModels/MonsterContext`.cs index 94892ad8528..330bed3ba13 100644 --- a/test/EFCore.Specification.Tests/TestModels/MonsterContext`.cs +++ b/test/EFCore.Specification.Tests/TestModels/MonsterContext`.cs @@ -128,11 +128,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity(); modelBuilder.Entity().HasKey(e => e.Username); modelBuilder.Entity().HasKey( - e => new - { - e.MessageId, - e.FromUsername - }); + e => new { e.MessageId, e.FromUsername }); modelBuilder.Entity().HasKey(e => e.NoteId); @@ -190,11 +186,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) b => { b.HasKey( - e => new - { - e.OrderId, - e.ProductId - }); + e => new { e.OrderId, e.ProductId }); b.HasOne(e => (TProduct)e.Product).WithMany().HasForeignKey(e => e.ProductId); }); @@ -244,50 +236,26 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) b => { b.HasKey( - e => new - { - e.PhotoId, - e.ProductId - }); + e => new { e.PhotoId, e.ProductId }); b.HasMany(e => (IEnumerable)e.Features).WithOne(e => (TProductPhoto)e.Photo) .HasForeignKey( - e => new - { - e.PhotoId, - e.ProductId - }) + e => new { e.PhotoId, e.ProductId }) .HasPrincipalKey( - e => new - { - e.PhotoId, - e.ProductId - }); + e => new { e.PhotoId, e.ProductId }); }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.ReviewId, - e.ProductId - }); + e => new { e.ReviewId, e.ProductId }); b.HasMany(e => (IEnumerable)e.Features).WithOne(e => (TProductReview)e.Review) .HasForeignKey( - e => new - { - e.ReviewId, - e.ProductId - }) + e => new { e.ReviewId, e.ProductId }) .HasPrincipalKey( - e => new - { - e.ReviewId, - e.ProductId - }); + e => new { e.ReviewId, e.ProductId }); }); modelBuilder.Entity( @@ -316,11 +284,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) b => { b.HasKey( - e => new - { - e.ResetNo, - e.Username - }); + e => new { e.ResetNo, e.Username }); b.HasOne(e => (TLogin)e.Login).WithMany() .HasForeignKey(e => e.Username) @@ -402,65 +366,25 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) public override void SeedUsingFKs() { var customer0 = Add( - new TCustomer - { - Name = "Eeky Bear" - }).Entity; + new TCustomer { Name = "Eeky Bear" }).Entity; var customer1 = Add( - new TCustomer - { - Name = "Sheila Koalie" - }).Entity; + new TCustomer { Name = "Sheila Koalie" }).Entity; var customer3 = Add( - new TCustomer - { - Name = "Tarquin Tiger" - }).Entity; + new TCustomer { Name = "Tarquin Tiger" }).Entity; var customer2 = Add( - new TCustomer - { - Name = "Sue Pandy", - HusbandId = Entry(customer0).Property(e => e.CustomerId).CurrentValue - }).Entity; + new TCustomer { Name = "Sue Pandy", HusbandId = Entry(customer0).Property(e => e.CustomerId).CurrentValue }).Entity; var product1 = Add( - new TProduct - { - Description = "Mrs Koalie's Famous Waffles", - BaseConcurrency = "Pounds Sterling" - }).Entity; + new TProduct { Description = "Mrs Koalie's Famous Waffles", BaseConcurrency = "Pounds Sterling" }).Entity; var product2 = Add( - new TProduct - { - Description = "Chocolate Donuts", - BaseConcurrency = "US Dollars" - }).Entity; + new TProduct { Description = "Chocolate Donuts", BaseConcurrency = "US Dollars" }).Entity; var product3 = Add( - new TProduct - { - Description = "Assorted Dog Treats", - BaseConcurrency = "Stuffy Money" - }).Entity; + new TProduct { Description = "Assorted Dog Treats", BaseConcurrency = "Stuffy Money" }).Entity; - product1.Dimensions = new TDimensions - { - Depth = 3, - Width = 3, - Height = 0.5M - }; - product2.Dimensions = new TDimensions - { - Depth = 2, - Width = 2, - Height = 1 - }; - product3.Dimensions = new TDimensions - { - Depth = 3, - Width = 1, - Height = 4 - }; + product1.Dimensions = new TDimensions { Depth = 3, Width = 3, Height = 0.5M }; + product2.Dimensions = new TDimensions { Depth = 2, Width = 2, Height = 1 }; + product3.Dimensions = new TDimensions { Depth = 3, Width = 1, Height = 4 }; var barcode1 = Add( new TBarcode @@ -485,17 +409,9 @@ public override void SeedUsingFKs() }).Entity; var barcodeDetails1 = Add( - new TBarcodeDetail - { - Code = Entry(barcode1).Property(e => e.Code).CurrentValue, - RegisteredTo = "Eeky Bear" - }).Entity; + new TBarcodeDetail { Code = Entry(barcode1).Property(e => e.Code).CurrentValue, RegisteredTo = "Eeky Bear" }).Entity; var barcodeDetails2 = Add( - new TBarcodeDetail - { - Code = Entry(barcode2).Property(e => e.Code).CurrentValue, - RegisteredTo = "Trent" - }).Entity; + new TBarcodeDetail { Code = Entry(barcode2).Property(e => e.Code).CurrentValue, RegisteredTo = "Trent" }).Entity; var incorrectScan1 = Add( new TIncorrectScan @@ -565,36 +481,31 @@ public override void SeedUsingFKs() var suspiciousActivity1 = Add( new TSuspiciousActivity { - Activity = "Pig prints on keyboard", - Username = Entry(login3).Property(e => e.Username).CurrentValue + Activity = "Pig prints on keyboard", Username = Entry(login3).Property(e => e.Username).CurrentValue }).Entity; var suspiciousActivity2 = Add( new TSuspiciousActivity { - Activity = "Crumbs in the cupboard", - Username = Entry(login3).Property(e => e.Username).CurrentValue + Activity = "Crumbs in the cupboard", Username = Entry(login3).Property(e => e.Username).CurrentValue }).Entity; var suspiciousActivity3 = Add( new TSuspiciousActivity { - Activity = "Donuts gone missing", - Username = Entry(login3).Property(e => e.Username).CurrentValue + Activity = "Donuts gone missing", Username = Entry(login3).Property(e => e.Username).CurrentValue }).Entity; var rsaToken1 = Add( - new TRsaToken - { - Issued = DateTime.Now, - Serial = "1234", - Username = Entry(login1).Property(e => e.Username).CurrentValue - }).Entity; + new TRsaToken + { + Issued = DateTime.Now, Serial = "1234", Username = Entry(login1).Property(e => e.Username).CurrentValue + }) + .Entity; var rsaToken2 = Add( - new TRsaToken - { - Issued = DateTime.Now, - Serial = "2234", - Username = Entry(login2).Property(e => e.Username).CurrentValue - }).Entity; + new TRsaToken + { + Issued = DateTime.Now, Serial = "2234", Username = Entry(login2).Property(e => e.Username).CurrentValue + }) + .Entity; var smartCard1 = Add( new TSmartCard @@ -623,23 +534,17 @@ public override void SeedUsingFKs() var pageView1 = Add( new TPageView { - PageUrl = "somePage1", - Username = Entry(login1).Property(e => e.Username).CurrentValue, - Viewed = DateTime.Now + PageUrl = "somePage1", Username = Entry(login1).Property(e => e.Username).CurrentValue, Viewed = DateTime.Now }).Entity; var pageView2 = Add( new TPageView { - PageUrl = "somePage2", - Username = Entry(login1).Property(e => e.Username).CurrentValue, - Viewed = DateTime.Now + PageUrl = "somePage2", Username = Entry(login1).Property(e => e.Username).CurrentValue, Viewed = DateTime.Now }).Entity; var pageView3 = Add( new TPageView { - PageUrl = "somePage3", - Username = Entry(login1).Property(e => e.Username).CurrentValue, - Viewed = DateTime.Now + PageUrl = "somePage3", Username = Entry(login1).Property(e => e.Username).CurrentValue, Viewed = DateTime.Now }).Entity; var lastLogin1 = Add( @@ -713,23 +618,11 @@ public override void SeedUsingFKs() }).Entity; var orderNote1 = Add( - new TOrderNote - { - Note = "Must have tea!", - OrderId = Entry(order1).Property(e => e.AlternateId).CurrentValue - }).Entity; + new TOrderNote { Note = "Must have tea!", OrderId = Entry(order1).Property(e => e.AlternateId).CurrentValue }).Entity; var orderNote2 = Add( - new TOrderNote - { - Note = "And donuts!", - OrderId = Entry(order1).Property(e => e.AlternateId).CurrentValue - }).Entity; + new TOrderNote { Note = "And donuts!", OrderId = Entry(order1).Property(e => e.AlternateId).CurrentValue }).Entity; var orderNote3 = Add( - new TOrderNote - { - Note = "But no coffee. :-(", - OrderId = Entry(order1).Property(e => e.AlternateId).CurrentValue - }).Entity; + new TOrderNote { Note = "But no coffee. :-(", OrderId = Entry(order1).Property(e => e.AlternateId).CurrentValue }).Entity; var orderQualityCheck1 = Add( new TOrderQualityCheck @@ -799,53 +692,47 @@ public override void SeedUsingFKs() var productDetail1 = Add( new TProductDetail { - Details = "A Waffle Cart specialty!", - ProductId = Entry(product1).Property(e => e.ProductId).CurrentValue + Details = "A Waffle Cart specialty!", ProductId = Entry(product1).Property(e => e.ProductId).CurrentValue }).Entity; var productDetail2 = Add( new TProductDetail { - Details = "Eeky Bear's favorite!", - ProductId = Entry(product2).Property(e => e.ProductId).CurrentValue + Details = "Eeky Bear's favorite!", ProductId = Entry(product2).Property(e => e.ProductId).CurrentValue }).Entity; var productReview1 = Add( - new TProductReview - { - ProductId = Entry(product1).Property(e => e.ProductId).CurrentValue, - Review = "Better than Tarqies!" - }).Entity; + new TProductReview + { + ProductId = Entry(product1).Property(e => e.ProductId).CurrentValue, Review = "Better than Tarqies!" + }) + .Entity; var productReview2 = Add( new TProductReview { - ProductId = Entry(product1).Property(e => e.ProductId).CurrentValue, - Review = "Good with maple syrup." + ProductId = Entry(product1).Property(e => e.ProductId).CurrentValue, Review = "Good with maple syrup." }).Entity; var productReview3 = Add( - new TProductReview - { - ProductId = Entry(product2).Property(e => e.ProductId).CurrentValue, - Review = "Eeky says yes!" - }).Entity; + new TProductReview { ProductId = Entry(product2).Property(e => e.ProductId).CurrentValue, Review = "Eeky says yes!" }) + .Entity; var productPhoto1 = Add( - new TProductPhoto - { - ProductId = Entry(product1).Property(e => e.ProductId).CurrentValue, - Photo = new byte[] { 101, 102 } - }).Entity; + new TProductPhoto + { + ProductId = Entry(product1).Property(e => e.ProductId).CurrentValue, Photo = new byte[] { 101, 102 } + }) + .Entity; var productPhoto2 = Add( - new TProductPhoto - { - ProductId = Entry(product1).Property(e => e.ProductId).CurrentValue, - Photo = new byte[] { 103, 104 } - }).Entity; + new TProductPhoto + { + ProductId = Entry(product1).Property(e => e.ProductId).CurrentValue, Photo = new byte[] { 103, 104 } + }) + .Entity; var productPhoto3 = Add( - new TProductPhoto - { - ProductId = Entry(product3).Property(e => e.ProductId).CurrentValue, - Photo = new byte[] { 105, 106 } - }).Entity; + new TProductPhoto + { + ProductId = Entry(product3).Property(e => e.ProductId).CurrentValue, Photo = new byte[] { 105, 106 } + }) + .Entity; var productWebFeature1 = Add( new TProductWebFeature @@ -865,65 +752,48 @@ public override void SeedUsingFKs() }).Entity; var supplier1 = Add( - new TSupplier - { - Name = "Trading As Trent" - }).Entity; + new TSupplier { Name = "Trading As Trent" }).Entity; var supplier2 = Add( - new TSupplier - { - Name = "Ants By Boris" - }).Entity; + new TSupplier { Name = "Ants By Boris" }).Entity; var supplierLogo1 = Add( new TSupplierLogo { - SupplierId = Entry(supplier1).Property(e => e.SupplierId).CurrentValue, - Logo = new byte[] { 201, 202 } + SupplierId = Entry(supplier1).Property(e => e.SupplierId).CurrentValue, Logo = new byte[] { 201, 202 } }).Entity; var supplierInfo1 = Add( new TSupplierInfo { - SupplierId = Entry(supplier1).Property(e => e.SupplierId).CurrentValue, - Information = "Seems a bit dodgy." + SupplierId = Entry(supplier1).Property(e => e.SupplierId).CurrentValue, Information = "Seems a bit dodgy." }).Entity; var supplierInfo2 = Add( - new TSupplierInfo - { - SupplierId = Entry(supplier1).Property(e => e.SupplierId).CurrentValue, - Information = "Orange fur?" - }).Entity; + new TSupplierInfo + { + SupplierId = Entry(supplier1).Property(e => e.SupplierId).CurrentValue, Information = "Orange fur?" + }) + .Entity; var supplierInfo3 = Add( new TSupplierInfo { - SupplierId = Entry(supplier2).Property(e => e.SupplierId).CurrentValue, - Information = "Very expensive!" + SupplierId = Entry(supplier2).Property(e => e.SupplierId).CurrentValue, Information = "Very expensive!" }).Entity; var customerInfo1 = Add( new TCustomerInfo { - CustomerInfoId = Entry(customer1).Property(e => e.CustomerId).CurrentValue, - Information = "Really likes tea." + CustomerInfoId = Entry(customer1).Property(e => e.CustomerId).CurrentValue, Information = "Really likes tea." }).Entity; var customerInfo2 = Add( new TCustomerInfo { - CustomerInfoId = Entry(customer2).Property(e => e.CustomerId).CurrentValue, - Information = "Mrs Bossy Pants!" + CustomerInfoId = Entry(customer2).Property(e => e.CustomerId).CurrentValue, Information = "Mrs Bossy Pants!" }).Entity; var computer1 = Add( - new TComputer - { - Name = "markash420" - }).Entity; + new TComputer { Name = "markash420" }).Entity; var computer2 = Add( - new TComputer - { - Name = "unicorns420" - }).Entity; + new TComputer { Name = "unicorns420" }).Entity; var computerDetail1 = Add( new TComputerDetail @@ -948,17 +818,9 @@ public override void SeedUsingFKs() }).Entity; var driver1 = Add( - new TDriver - { - BirthDate = new DateTime(2006, 9, 19), - Name = "Eeky Bear" - }).Entity; + new TDriver { BirthDate = new DateTime(2006, 9, 19), Name = "Eeky Bear" }).Entity; var driver2 = Add( - new TDriver - { - BirthDate = new DateTime(2007, 9, 19), - Name = "Splash Bear" - }).Entity; + new TDriver { BirthDate = new DateTime(2007, 9, 19), Name = "Splash Bear" }).Entity; var license1 = Add( new TLicense @@ -988,91 +850,39 @@ public override void SeedUsingFKs() public override void SeedUsingNavigations(bool dependentNavs, bool principalNavs) { var customer0 = Add( - new TCustomer - { - Name = "Eeky Bear" - }).Entity; + new TCustomer { Name = "Eeky Bear" }).Entity; var customer1 = Add( - new TCustomer - { - Name = "Sheila Koalie" - }).Entity; + new TCustomer { Name = "Sheila Koalie" }).Entity; var customer3 = Add( - new TCustomer - { - Name = "Tarquin Tiger" - }).Entity; + new TCustomer { Name = "Tarquin Tiger" }).Entity; var customer2 = Add( - new TCustomer - { - Name = "Sue Pandy", - Husband = dependentNavs ? customer0 : null - }).Entity; + new TCustomer { Name = "Sue Pandy", Husband = dependentNavs ? customer0 : null }).Entity; if (principalNavs) { customer0.Wife = customer2; } var product1 = Add( - new TProduct - { - Description = "Mrs Koalie's Famous Waffles", - BaseConcurrency = "Pounds Sterling" - }).Entity; + new TProduct { Description = "Mrs Koalie's Famous Waffles", BaseConcurrency = "Pounds Sterling" }).Entity; var product2 = Add( - new TProduct - { - Description = "Chocolate Donuts", - BaseConcurrency = "US Dollars" - }).Entity; + new TProduct { Description = "Chocolate Donuts", BaseConcurrency = "US Dollars" }).Entity; var product3 = Add( - new TProduct - { - Description = "Assorted Dog Treats", - BaseConcurrency = "Stuffy Money" - }).Entity; + new TProduct { Description = "Assorted Dog Treats", BaseConcurrency = "Stuffy Money" }).Entity; - product1.Dimensions = new TDimensions - { - Depth = 3, - Width = 3, - Height = 0.5M - }; - product2.Dimensions = new TDimensions - { - Depth = 2, - Width = 2, - Height = 1 - }; - product3.Dimensions = new TDimensions - { - Depth = 3, - Width = 1, - Height = 4 - }; + product1.Dimensions = new TDimensions { Depth = 3, Width = 3, Height = 0.5M }; + product2.Dimensions = new TDimensions { Depth = 2, Width = 2, Height = 1 }; + product3.Dimensions = new TDimensions { Depth = 3, Width = 1, Height = 4 }; var barcode1 = Add( - new TBarcode - { - Code = new byte[] { 1, 2, 3, 4 }, - Product = dependentNavs ? product1 : null, - Text = "Barcode 1 2 3 4" - }).Entity; + new TBarcode { Code = new byte[] { 1, 2, 3, 4 }, Product = dependentNavs ? product1 : null, Text = "Barcode 1 2 3 4" }) + .Entity; var barcode2 = Add( - new TBarcode - { - Code = new byte[] { 2, 2, 3, 4 }, - Product = dependentNavs ? product2 : null, - Text = "Barcode 2 2 3 4" - }).Entity; + new TBarcode { Code = new byte[] { 2, 2, 3, 4 }, Product = dependentNavs ? product2 : null, Text = "Barcode 2 2 3 4" }) + .Entity; var barcode3 = Add( - new TBarcode - { - Code = new byte[] { 3, 2, 3, 4 }, - Product = dependentNavs ? product3 : null, - Text = "Barcode 3 2 3 4" - }).Entity; + new TBarcode { Code = new byte[] { 3, 2, 3, 4 }, Product = dependentNavs ? product3 : null, Text = "Barcode 3 2 3 4" }) + .Entity; if (principalNavs) { product1.InitializeCollections(); @@ -1084,17 +894,9 @@ public override void SeedUsingNavigations(bool dependentNavs, bool principalNavs } var barcodeDetails1 = Add( - new TBarcodeDetail - { - Code = barcode1.Code, - RegisteredTo = "Eeky Bear" - }).Entity; + new TBarcodeDetail { Code = barcode1.Code, RegisteredTo = "Eeky Bear" }).Entity; var barcodeDetails2 = Add( - new TBarcodeDetail - { - Code = barcode2.Code, - RegisteredTo = "Trent" - }).Entity; + new TBarcodeDetail { Code = barcode2.Code, RegisteredTo = "Trent" }).Entity; if (principalNavs) { barcode1.Detail = barcodeDetails1; @@ -1148,37 +950,23 @@ public override void SeedUsingNavigations(bool dependentNavs, bool principalNavs }).Entity; var resolution = Add( - new TResolution - { - Complaint = dependentNavs ? complaint2 : null, - Details = "Destroyed all coffee in Redmond area." - }).Entity; + new TResolution { Complaint = dependentNavs ? complaint2 : null, Details = "Destroyed all coffee in Redmond area." }) + .Entity; if (principalNavs) { complaint2.Resolution = resolution; } var login1 = Add( - new TLogin - { - Customer = dependentNavs ? customer1 : null, - Username = "MrsKoalie73", - AlternateUsername = "Sheila" - }).Entity; + new TLogin { Customer = dependentNavs ? customer1 : null, Username = "MrsKoalie73", AlternateUsername = "Sheila" }).Entity; var login2 = Add( - new TLogin - { - Customer = dependentNavs ? customer2 : null, - Username = "MrsBossyPants", - AlternateUsername = "Sue" - }).Entity; + new TLogin { Customer = dependentNavs ? customer2 : null, Username = "MrsBossyPants", AlternateUsername = "Sue" }).Entity; var login3 = Add( - new TLogin - { - Customer = dependentNavs ? customer3 : null, - Username = "TheStripedMenace", - AlternateUsername = "Tarquin" - }).Entity; + new TLogin + { + Customer = dependentNavs ? customer3 : null, Username = "TheStripedMenace", AlternateUsername = "Tarquin" + }) + .Entity; if (principalNavs) { customer1.InitializeCollections(); @@ -1192,36 +980,23 @@ public override void SeedUsingNavigations(bool dependentNavs, bool principalNavs var suspiciousActivity1 = Add( new TSuspiciousActivity { - Activity = "Pig prints on keyboard", - Username = Entry(login3).Property(e => e.Username).CurrentValue + Activity = "Pig prints on keyboard", Username = Entry(login3).Property(e => e.Username).CurrentValue }).Entity; var suspiciousActivity2 = Add( new TSuspiciousActivity { - Activity = "Crumbs in the cupboard", - Username = Entry(login3).Property(e => e.Username).CurrentValue + Activity = "Crumbs in the cupboard", Username = Entry(login3).Property(e => e.Username).CurrentValue }).Entity; var suspiciousActivity3 = Add( new TSuspiciousActivity { - Activity = "Donuts gone missing", - Username = Entry(login3).Property(e => e.Username).CurrentValue + Activity = "Donuts gone missing", Username = Entry(login3).Property(e => e.Username).CurrentValue }).Entity; var rsaToken1 = Add( - new TRsaToken - { - Issued = DateTime.Now, - Serial = "1234", - Login = login1 - }).Entity; + new TRsaToken { Issued = DateTime.Now, Serial = "1234", Login = login1 }).Entity; var rsaToken2 = Add( - new TRsaToken - { - Issued = DateTime.Now, - Serial = "2234", - Login = login2 - }).Entity; + new TRsaToken { Issued = DateTime.Now, Serial = "2234", Login = login2 }).Entity; var smartCard1 = Add( new TSmartCard @@ -1239,35 +1014,14 @@ public override void SeedUsingNavigations(bool dependentNavs, bool principalNavs }).Entity; var reset1 = Add( - new TPasswordReset - { - EmailedTo = "trent@example.com", - ResetNo = 1, - TempPassword = "Rent-A-Mole", - Login = login3 - }).Entity; + new TPasswordReset { EmailedTo = "trent@example.com", ResetNo = 1, TempPassword = "Rent-A-Mole", Login = login3 }).Entity; var pageView1 = Add( - new TPageView - { - PageUrl = "somePage1", - Login = login1, - Viewed = DateTime.Now - }).Entity; + new TPageView { PageUrl = "somePage1", Login = login1, Viewed = DateTime.Now }).Entity; var pageView2 = Add( - new TPageView - { - PageUrl = "somePage2", - Login = login1, - Viewed = DateTime.Now - }).Entity; + new TPageView { PageUrl = "somePage2", Login = login1, Viewed = DateTime.Now }).Entity; var pageView3 = Add( - new TPageView - { - PageUrl = "somePage3", - Login = login1, - Viewed = DateTime.Now - }).Entity; + new TPageView { PageUrl = "somePage3", Login = login1, Viewed = DateTime.Now }).Entity; var lastLogin1 = Add( new TLastLogin @@ -1348,26 +1102,14 @@ public override void SeedUsingNavigations(bool dependentNavs, bool principalNavs } var order1 = Add( - new TAnOrder - { - Customer = dependentNavs ? customer1 : null, - Login = dependentNavs ? login1 : null, - AlternateId = 77 - }).Entity; + new TAnOrder { Customer = dependentNavs ? customer1 : null, Login = dependentNavs ? login1 : null, AlternateId = 77 }) + .Entity; var order2 = Add( - new TAnOrder - { - Customer = dependentNavs ? customer2 : null, - Login = dependentNavs ? login2 : null, - AlternateId = 78 - }).Entity; + new TAnOrder { Customer = dependentNavs ? customer2 : null, Login = dependentNavs ? login2 : null, AlternateId = 78 }) + .Entity; var order3 = Add( - new TAnOrder - { - Customer = dependentNavs ? customer3 : null, - Login = dependentNavs ? login3 : null, - AlternateId = 79 - }).Entity; + new TAnOrder { Customer = dependentNavs ? customer3 : null, Login = dependentNavs ? login3 : null, AlternateId = 79 }) + .Entity; if (principalNavs) { customer1.Orders.Add(order1); @@ -1380,23 +1122,11 @@ public override void SeedUsingNavigations(bool dependentNavs, bool principalNavs } var orderNote1 = Add( - new TOrderNote - { - Note = "Must have tea!", - Order = dependentNavs ? order1 : null - }).Entity; + new TOrderNote { Note = "Must have tea!", Order = dependentNavs ? order1 : null }).Entity; var orderNote2 = Add( - new TOrderNote - { - Note = "And donuts!", - Order = dependentNavs ? order1 : null - }).Entity; + new TOrderNote { Note = "And donuts!", Order = dependentNavs ? order1 : null }).Entity; var orderNote3 = Add( - new TOrderNote - { - Note = "But no coffee. :-(", - Order = dependentNavs ? order1 : null - }).Entity; + new TOrderNote { Note = "But no coffee. :-(", Order = dependentNavs ? order1 : null }).Entity; if (principalNavs) { order1.InitializeCollections(); @@ -1406,69 +1136,24 @@ public override void SeedUsingNavigations(bool dependentNavs, bool principalNavs } var orderQualityCheck1 = Add( - new TOrderQualityCheck - { - Order = order1, - CheckedBy = "Eeky Bear", - CheckedDateTime = DateTime.Now - }).Entity; + new TOrderQualityCheck { Order = order1, CheckedBy = "Eeky Bear", CheckedDateTime = DateTime.Now }).Entity; var orderQualityCheck2 = Add( - new TOrderQualityCheck - { - Order = order2, - CheckedBy = "Eeky Bear", - CheckedDateTime = DateTime.Now - }).Entity; + new TOrderQualityCheck { Order = order2, CheckedBy = "Eeky Bear", CheckedDateTime = DateTime.Now }).Entity; var orderQualityCheck3 = Add( - new TOrderQualityCheck - { - Order = order3, - CheckedBy = "Eeky Bear", - CheckedDateTime = DateTime.Now - }).Entity; + new TOrderQualityCheck { Order = order3, CheckedBy = "Eeky Bear", CheckedDateTime = DateTime.Now }).Entity; var orderLine1 = Add( - new TOrderLine - { - Order = order1, - Product = product1, - Quantity = 7 - }).Entity; + new TOrderLine { Order = order1, Product = product1, Quantity = 7 }).Entity; var orderLine2 = Add( - new TOrderLine - { - Order = order1, - Product = product2, - Quantity = 1 - }).Entity; + new TOrderLine { Order = order1, Product = product2, Quantity = 1 }).Entity; var orderLine3 = Add( - new TOrderLine - { - Order = order2, - Product = product3, - Quantity = 2 - }).Entity; + new TOrderLine { Order = order2, Product = product3, Quantity = 2 }).Entity; var orderLine4 = Add( - new TOrderLine - { - Order = order2, - Product = product2, - Quantity = 3 - }).Entity; + new TOrderLine { Order = order2, Product = product2, Quantity = 3 }).Entity; var orderLine5 = Add( - new TOrderLine - { - Order = order2, - Product = product1, - Quantity = 4 - }).Entity; + new TOrderLine { Order = order2, Product = product1, Quantity = 4 }).Entity; var orderLine6 = Add( - new TOrderLine - { - Order = order3, - Product = product2, - Quantity = 5 - }).Entity; + new TOrderLine { Order = order3, Product = product2, Quantity = 5 }).Entity; if (principalNavs) { order1.OrderLines.Add(orderLine1); @@ -1482,17 +1167,9 @@ public override void SeedUsingNavigations(bool dependentNavs, bool principalNavs } var productDetail1 = Add( - new TProductDetail - { - Details = "A Waffle Cart specialty!", - Product = product1 - }).Entity; + new TProductDetail { Details = "A Waffle Cart specialty!", Product = product1 }).Entity; var productDetail2 = Add( - new TProductDetail - { - Details = "Eeky Bear's favorite!", - Product = product2 - }).Entity; + new TProductDetail { Details = "Eeky Bear's favorite!", Product = product2 }).Entity; if (principalNavs) { product1.Detail = productDetail1; @@ -1500,23 +1177,11 @@ public override void SeedUsingNavigations(bool dependentNavs, bool principalNavs } var productReview1 = Add( - new TProductReview - { - Product = dependentNavs ? product1 : null, - Review = "Better than Tarqies!" - }).Entity; + new TProductReview { Product = dependentNavs ? product1 : null, Review = "Better than Tarqies!" }).Entity; var productReview2 = Add( - new TProductReview - { - Product = dependentNavs ? product1 : null, - Review = "Good with maple syrup." - }).Entity; + new TProductReview { Product = dependentNavs ? product1 : null, Review = "Good with maple syrup." }).Entity; var productReview3 = Add( - new TProductReview - { - Product = dependentNavs ? product2 : null, - Review = "Eeky says yes!" - }).Entity; + new TProductReview { Product = dependentNavs ? product2 : null, Review = "Eeky says yes!" }).Entity; if (principalNavs) { product1.Reviews.Add(productReview1); @@ -1525,23 +1190,23 @@ public override void SeedUsingNavigations(bool dependentNavs, bool principalNavs } var productPhoto1 = Add( - new TProductPhoto - { - ProductId = Entry(product1).Property(e => e.ProductId).CurrentValue, - Photo = new byte[] { 101, 102 } - }).Entity; + new TProductPhoto + { + ProductId = Entry(product1).Property(e => e.ProductId).CurrentValue, Photo = new byte[] { 101, 102 } + }) + .Entity; var productPhoto2 = Add( - new TProductPhoto - { - ProductId = Entry(product1).Property(e => e.ProductId).CurrentValue, - Photo = new byte[] { 103, 104 } - }).Entity; + new TProductPhoto + { + ProductId = Entry(product1).Property(e => e.ProductId).CurrentValue, Photo = new byte[] { 103, 104 } + }) + .Entity; var productPhoto3 = Add( - new TProductPhoto - { - ProductId = Entry(product3).Property(e => e.ProductId).CurrentValue, - Photo = new byte[] { 105, 106 } - }).Entity; + new TProductPhoto + { + ProductId = Entry(product3).Property(e => e.ProductId).CurrentValue, Photo = new byte[] { 105, 106 } + }) + .Entity; if (principalNavs) { product1.Photos.Add(productPhoto1); @@ -1579,15 +1244,9 @@ public override void SeedUsingNavigations(bool dependentNavs, bool principalNavs } var supplier1 = Add( - new TSupplier - { - Name = "Trading As Trent" - }).Entity; + new TSupplier { Name = "Trading As Trent" }).Entity; var supplier2 = Add( - new TSupplier - { - Name = "Ants By Boris" - }).Entity; + new TSupplier { Name = "Ants By Boris" }).Entity; var supplierLogo1 = Add( new TSupplierLogo @@ -1601,35 +1260,21 @@ public override void SeedUsingNavigations(bool dependentNavs, bool principalNavs } var supplierInfo1 = Add( - new TSupplierInfo - { - Supplier = supplier1, - Information = "Seems a bit dodgy." - }).Entity; + new TSupplierInfo { Supplier = supplier1, Information = "Seems a bit dodgy." }).Entity; var supplierInfo2 = Add( - new TSupplierInfo - { - Supplier = supplier1, - Information = "Orange fur?" - }).Entity; + new TSupplierInfo { Supplier = supplier1, Information = "Orange fur?" }).Entity; var supplierInfo3 = Add( - new TSupplierInfo - { - Supplier = supplier2, - Information = "Very expensive!" - }).Entity; + new TSupplierInfo { Supplier = supplier2, Information = "Very expensive!" }).Entity; var customerInfo1 = Add( new TCustomerInfo { - CustomerInfoId = Entry(customer1).Property(e => e.CustomerId).CurrentValue, - Information = "Really likes tea." + CustomerInfoId = Entry(customer1).Property(e => e.CustomerId).CurrentValue, Information = "Really likes tea." }).Entity; var customerInfo2 = Add( new TCustomerInfo { - CustomerInfoId = Entry(customer2).Property(e => e.CustomerId).CurrentValue, - Information = "Mrs Bossy Pants!" + CustomerInfoId = Entry(customer2).Property(e => e.CustomerId).CurrentValue, Information = "Mrs Bossy Pants!" }).Entity; if (principalNavs) { @@ -1638,15 +1283,9 @@ public override void SeedUsingNavigations(bool dependentNavs, bool principalNavs } var computer1 = Add( - new TComputer - { - Name = "markash420" - }).Entity; + new TComputer { Name = "markash420" }).Entity; var computer2 = Add( - new TComputer - { - Name = "unicorns420" - }).Entity; + new TComputer { Name = "unicorns420" }).Entity; var computerDetail1 = Add( new TComputerDetail @@ -1679,17 +1318,9 @@ public override void SeedUsingNavigations(bool dependentNavs, bool principalNavs } var driver1 = Add( - new TDriver - { - BirthDate = new DateTime(2006, 9, 19), - Name = "Eeky Bear" - }).Entity; + new TDriver { BirthDate = new DateTime(2006, 9, 19), Name = "Eeky Bear" }).Entity; var driver2 = Add( - new TDriver - { - BirthDate = new DateTime(2007, 9, 19), - Name = "Splash Bear" - }).Entity; + new TDriver { BirthDate = new DateTime(2007, 9, 19), Name = "Splash Bear" }).Entity; var license1 = Add( new TLicense @@ -1734,83 +1365,31 @@ public override void SeedUsingNavigationsWithDeferredAdd() } var customer0 = toAdd[0].AddEx( - new TCustomer - { - Name = "Eeky Bear" - }); + new TCustomer { Name = "Eeky Bear" }); var customer1 = toAdd[0].AddEx( - new TCustomer - { - Name = "Sheila Koalie" - }); + new TCustomer { Name = "Sheila Koalie" }); var customer3 = toAdd[0].AddEx( - new TCustomer - { - Name = "Tarquin Tiger" - }); + new TCustomer { Name = "Tarquin Tiger" }); var customer2 = toAdd[0].AddEx( - new TCustomer - { - Name = "Sue Pandy", - Husband = customer0 - }); + new TCustomer { Name = "Sue Pandy", Husband = customer0 }); var product1 = toAdd[0].AddEx( - new TProduct - { - Description = "Mrs Koalie's Famous Waffles", - BaseConcurrency = "Pounds Sterling" - }); + new TProduct { Description = "Mrs Koalie's Famous Waffles", BaseConcurrency = "Pounds Sterling" }); var product2 = toAdd[0].AddEx( - new TProduct - { - Description = "Chocolate Donuts", - BaseConcurrency = "US Dollars" - }); + new TProduct { Description = "Chocolate Donuts", BaseConcurrency = "US Dollars" }); var product3 = toAdd[0].AddEx( - new TProduct - { - Description = "Assorted Dog Treats", - BaseConcurrency = "Stuffy Money" - }); + new TProduct { Description = "Assorted Dog Treats", BaseConcurrency = "Stuffy Money" }); - product1.Dimensions = new TDimensions - { - Depth = 3, - Width = 3, - Height = 0.5M - }; - product2.Dimensions = new TDimensions - { - Depth = 2, - Width = 2, - Height = 1 - }; - product3.Dimensions = new TDimensions - { - Depth = 3, - Width = 1, - Height = 4 - }; + product1.Dimensions = new TDimensions { Depth = 3, Width = 3, Height = 0.5M }; + product2.Dimensions = new TDimensions { Depth = 2, Width = 2, Height = 1 }; + product3.Dimensions = new TDimensions { Depth = 3, Width = 1, Height = 4 }; var barcode1 = toAdd[1].AddEx( - new TBarcode - { - Code = new byte[] { 1, 2, 3, 4 }, - Text = "Barcode 1 2 3 4" - }); + new TBarcode { Code = new byte[] { 1, 2, 3, 4 }, Text = "Barcode 1 2 3 4" }); var barcode2 = toAdd[1].AddEx( - new TBarcode - { - Code = new byte[] { 2, 2, 3, 4 }, - Text = "Barcode 2 2 3 4" - }); + new TBarcode { Code = new byte[] { 2, 2, 3, 4 }, Text = "Barcode 2 2 3 4" }); var barcode3 = toAdd[1].AddEx( - new TBarcode - { - Code = new byte[] { 3, 2, 3, 4 }, - Text = "Barcode 3 2 3 4" - }); + new TBarcode { Code = new byte[] { 3, 2, 3, 4 }, Text = "Barcode 3 2 3 4" }); product1.InitializeCollections(); product1.Barcodes.Add(barcode1); @@ -1820,15 +1399,9 @@ public override void SeedUsingNavigationsWithDeferredAdd() product3.Barcodes.Add(barcode3); var barcodeDetails1 = toAdd[1].AddEx( - new TBarcodeDetail - { - RegisteredTo = "Eeky Bear" - }); + new TBarcodeDetail { RegisteredTo = "Eeky Bear" }); var barcodeDetails2 = toAdd[1].AddEx( - new TBarcodeDetail - { - RegisteredTo = "Trent" - }); + new TBarcodeDetail { RegisteredTo = "Trent" }); barcode1.Detail = barcodeDetails1; barcode2.Detail = barcodeDetails2; @@ -1836,9 +1409,7 @@ public override void SeedUsingNavigationsWithDeferredAdd() var incorrectScan1 = toAdd[1].AddEx( new TIncorrectScan { - ScanDate = new DateTime(2014, 5, 28, 19, 9, 6), - Details = "Treats not Donuts", - ActualBarcode = barcode3 + ScanDate = new DateTime(2014, 5, 28, 19, 9, 6), Details = "Treats not Donuts", ActualBarcode = barcode3 }); barcode2.InitializeCollections(); barcode2.BadScans.Add(incorrectScan1); @@ -1846,9 +1417,7 @@ public override void SeedUsingNavigationsWithDeferredAdd() var incorrectScan2 = toAdd[1].AddEx( new TIncorrectScan { - ScanDate = new DateTime(2014, 5, 28, 19, 15, 31), - Details = "Wot no waffles?", - ActualBarcode = barcode2 + ScanDate = new DateTime(2014, 5, 28, 19, 15, 31), Details = "Wot no waffles?", ActualBarcode = barcode2 }); barcode1.InitializeCollections(); barcode1.BadScans.Add(incorrectScan2); @@ -1872,30 +1441,15 @@ public override void SeedUsingNavigationsWithDeferredAdd() }); var resolution = toAdd[2].AddEx( - new TResolution - { - Details = "Destroyed all coffee in Redmond area." - }); + new TResolution { Details = "Destroyed all coffee in Redmond area." }); complaint2.Resolution = resolution; var login1 = toAdd[1].AddEx( - new TLogin - { - Username = "MrsKoalie73", - AlternateUsername = "Sheila" - }); + new TLogin { Username = "MrsKoalie73", AlternateUsername = "Sheila" }); var login2 = toAdd[1].AddEx( - new TLogin - { - Username = "MrsBossyPants", - AlternateUsername = "Sue" - }); + new TLogin { Username = "MrsBossyPants", AlternateUsername = "Sue" }); var login3 = toAdd[1].AddEx( - new TLogin - { - Username = "TheStripedMenace", - AlternateUsername = "Tarquin" - }); + new TLogin { Username = "TheStripedMenace", AlternateUsername = "Tarquin" }); customer1.InitializeCollections(); customer1.Logins.Add(login1); @@ -1907,36 +1461,23 @@ public override void SeedUsingNavigationsWithDeferredAdd() var suspiciousActivity1 = toAdd[2].AddEx( new TSuspiciousActivity { - Activity = "Pig prints on keyboard", - Username = Entry(login3).Property(e => e.Username).CurrentValue + Activity = "Pig prints on keyboard", Username = Entry(login3).Property(e => e.Username).CurrentValue }); var suspiciousActivity2 = toAdd[2].AddEx( new TSuspiciousActivity { - Activity = "Crumbs in the cupboard", - Username = Entry(login3).Property(e => e.Username).CurrentValue + Activity = "Crumbs in the cupboard", Username = Entry(login3).Property(e => e.Username).CurrentValue }); var suspiciousActivity3 = toAdd[2].AddEx( new TSuspiciousActivity { - Activity = "Donuts gone missing", - Username = Entry(login3).Property(e => e.Username).CurrentValue + Activity = "Donuts gone missing", Username = Entry(login3).Property(e => e.Username).CurrentValue }); var rsaToken1 = toAdd[2].AddEx( - new TRsaToken - { - Issued = DateTime.Now, - Serial = "1234", - Login = login1 - }); + new TRsaToken { Issued = DateTime.Now, Serial = "1234", Login = login1 }); var rsaToken2 = toAdd[2].AddEx( - new TRsaToken - { - Issued = DateTime.Now, - Serial = "2234", - Login = login2 - }); + new TRsaToken { Issued = DateTime.Now, Serial = "2234", Login = login2 }); var smartCard1 = toAdd[2].AddEx( new TSmartCard @@ -1954,52 +1495,23 @@ public override void SeedUsingNavigationsWithDeferredAdd() }); var reset1 = toAdd[2].AddEx( - new TPasswordReset - { - EmailedTo = "trent@example.com", - ResetNo = 1, - TempPassword = "Rent-A-Mole", - Login = login3 - }); + new TPasswordReset { EmailedTo = "trent@example.com", ResetNo = 1, TempPassword = "Rent-A-Mole", Login = login3 }); var pageView1 = toAdd[1].AddEx( - new TPageView - { - PageUrl = "somePage1", - Login = login1, - Viewed = DateTime.Now - }); + new TPageView { PageUrl = "somePage1", Login = login1, Viewed = DateTime.Now }); var pageView2 = toAdd[1].AddEx( - new TPageView - { - PageUrl = "somePage2", - Login = login1, - Viewed = DateTime.Now - }); + new TPageView { PageUrl = "somePage2", Login = login1, Viewed = DateTime.Now }); var pageView3 = toAdd[1].AddEx( - new TPageView - { - PageUrl = "somePage3", - Login = login1, - Viewed = DateTime.Now - }); + new TPageView { PageUrl = "somePage3", Login = login1, Viewed = DateTime.Now }); var lastLogin1 = toAdd[2].AddEx( - new TLastLogin - { - LoggedIn = new DateTime(2014, 5, 27, 10, 22, 26), - LoggedOut = new DateTime(2014, 5, 27, 11, 22, 26) - }); + new TLastLogin { LoggedIn = new DateTime(2014, 5, 27, 10, 22, 26), LoggedOut = new DateTime(2014, 5, 27, 11, 22, 26) }); login1.LastLogin = lastLogin1; smartCard1.LastLogin = lastLogin1; var lastLogin2 = toAdd[2].AddEx( - new TLastLogin - { - LoggedIn = new DateTime(2014, 5, 27, 12, 22, 26), - LoggedOut = new DateTime(2014, 5, 27, 13, 22, 26) - }); + new TLastLogin { LoggedIn = new DateTime(2014, 5, 27, 12, 22, 26), LoggedOut = new DateTime(2014, 5, 27, 13, 22, 26) }); login2.LastLogin = lastLogin2; smartCard2.LastLogin = lastLogin2; @@ -2043,26 +1555,11 @@ public override void SeedUsingNavigationsWithDeferredAdd() login2.ReceivedMessages.Add(message3); var order1 = toAdd[2].AddEx( - new TAnOrder - { - Customer = customer1, - Login = login1, - AlternateId = 77 - }); + new TAnOrder { Customer = customer1, Login = login1, AlternateId = 77 }); var order2 = toAdd[2].AddEx( - new TAnOrder - { - Customer = customer2, - Login = login2, - AlternateId = 78 - }); + new TAnOrder { Customer = customer2, Login = login2, AlternateId = 78 }); var order3 = toAdd[2].AddEx( - new TAnOrder - { - Customer = customer3, - Login = login3, - AlternateId = 79 - }); + new TAnOrder { Customer = customer3, Login = login3, AlternateId = 79 }); customer1.Orders.Add(order1); customer2.Orders.Add(order2); @@ -2074,20 +1571,11 @@ public override void SeedUsingNavigationsWithDeferredAdd() login3.Orders.Add(order3); var orderNote1 = toAdd[2].AddEx( - new TOrderNote - { - Note = "Must have tea!" - }); + new TOrderNote { Note = "Must have tea!" }); var orderNote2 = toAdd[2].AddEx( - new TOrderNote - { - Note = "And donuts!" - }); + new TOrderNote { Note = "And donuts!" }); var orderNote3 = toAdd[2].AddEx( - new TOrderNote - { - Note = "But no coffee. :-(" - }); + new TOrderNote { Note = "But no coffee. :-(" }); order1.InitializeCollections(); order1.Notes.Add(orderNote1); @@ -2095,63 +1583,24 @@ public override void SeedUsingNavigationsWithDeferredAdd() order1.Notes.Add(orderNote3); var orderQualityCheck1 = toAdd[2].AddEx( - new TOrderQualityCheck - { - Order = order1, - CheckedBy = "Eeky Bear", - CheckedDateTime = DateTime.Now - }); + new TOrderQualityCheck { Order = order1, CheckedBy = "Eeky Bear", CheckedDateTime = DateTime.Now }); var orderQualityCheck2 = toAdd[2].AddEx( - new TOrderQualityCheck - { - Order = order2, - CheckedBy = "Eeky Bear", - CheckedDateTime = DateTime.Now - }); + new TOrderQualityCheck { Order = order2, CheckedBy = "Eeky Bear", CheckedDateTime = DateTime.Now }); var orderQualityCheck3 = toAdd[2].AddEx( - new TOrderQualityCheck - { - Order = order3, - CheckedBy = "Eeky Bear", - CheckedDateTime = DateTime.Now - }); + new TOrderQualityCheck { Order = order3, CheckedBy = "Eeky Bear", CheckedDateTime = DateTime.Now }); var orderLine1 = toAdd[3].AddEx( - new TOrderLine - { - Product = product1, - Quantity = 7 - }); + new TOrderLine { Product = product1, Quantity = 7 }); var orderLine2 = toAdd[3].AddEx( - new TOrderLine - { - Product = product2, - Quantity = 1 - }); + new TOrderLine { Product = product2, Quantity = 1 }); var orderLine3 = toAdd[3].AddEx( - new TOrderLine - { - Product = product3, - Quantity = 2 - }); + new TOrderLine { Product = product3, Quantity = 2 }); var orderLine4 = toAdd[3].AddEx( - new TOrderLine - { - Product = product2, - Quantity = 3 - }); + new TOrderLine { Product = product2, Quantity = 3 }); var orderLine5 = toAdd[3].AddEx( - new TOrderLine - { - Product = product1, - Quantity = 4 - }); + new TOrderLine { Product = product1, Quantity = 4 }); var orderLine6 = toAdd[3].AddEx( - new TOrderLine - { - Product = product2, - Quantity = 5 - }); + new TOrderLine { Product = product2, Quantity = 5 }); order1.OrderLines.Add(orderLine1); order1.OrderLines.Add(orderLine2); @@ -2163,64 +1612,37 @@ public override void SeedUsingNavigationsWithDeferredAdd() order3.OrderLines.Add(orderLine6); var productDetail1 = toAdd[0].AddEx( - new TProductDetail - { - Details = "A Waffle Cart specialty!" - }); + new TProductDetail { Details = "A Waffle Cart specialty!" }); var productDetail2 = toAdd[0].AddEx( - new TProductDetail - { - Details = "Eeky Bear's favorite!" - }); + new TProductDetail { Details = "Eeky Bear's favorite!" }); product1.Detail = productDetail1; product2.Detail = productDetail2; var productReview1 = toAdd[0].AddEx( - new TProductReview - { - Review = "Better than Tarqies!" - }); + new TProductReview { Review = "Better than Tarqies!" }); var productReview2 = toAdd[0].AddEx( - new TProductReview - { - Review = "Good with maple syrup." - }); + new TProductReview { Review = "Good with maple syrup." }); var productReview3 = toAdd[0].AddEx( - new TProductReview - { - Review = "Eeky says yes!" - }); + new TProductReview { Review = "Eeky says yes!" }); product1.Reviews.Add(productReview1); product1.Reviews.Add(productReview2); product2.Reviews.Add(productReview3); var productPhoto1 = toAdd[0].AddEx( - new TProductPhoto - { - Photo = new byte[] { 101, 102 } - }); + new TProductPhoto { Photo = new byte[] { 101, 102 } }); var productPhoto2 = toAdd[0].AddEx( - new TProductPhoto - { - Photo = new byte[] { 103, 104 } - }); + new TProductPhoto { Photo = new byte[] { 103, 104 } }); var productPhoto3 = toAdd[0].AddEx( - new TProductPhoto - { - Photo = new byte[] { 105, 106 } - }); + new TProductPhoto { Photo = new byte[] { 105, 106 } }); product1.Photos.Add(productPhoto1); product1.Photos.Add(productPhoto2); product3.Photos.Add(productPhoto3); var productWebFeature1 = toAdd[0].AddEx( - new TProductWebFeature - { - Heading = "Waffle Style" - }); + new TProductWebFeature { Heading = "Waffle Style" }); productPhoto1.InitializeCollections(); productPhoto1.Features.Add(productWebFeature1); @@ -2228,76 +1650,40 @@ public override void SeedUsingNavigationsWithDeferredAdd() productReview1.Features.Add(productWebFeature1); var productWebFeature2 = toAdd[0].AddEx( - new TProductWebFeature - { - Heading = "What does the waffle say?" - }); + new TProductWebFeature { Heading = "What does the waffle say?" }); productReview3.InitializeCollections(); productReview3.Features.Add(productWebFeature2); var supplier1 = toAdd[0].AddEx( - new TSupplier - { - Name = "Trading As Trent" - }); + new TSupplier { Name = "Trading As Trent" }); var supplier2 = toAdd[0].AddEx( - new TSupplier - { - Name = "Ants By Boris" - }); + new TSupplier { Name = "Ants By Boris" }); var supplierLogo1 = toAdd[0].AddEx( - new TSupplierLogo - { - Logo = new byte[] { 201, 202 } - }); + new TSupplierLogo { Logo = new byte[] { 201, 202 } }); supplier1.Logo = supplierLogo1; var supplierInfo1 = toAdd[0].AddEx( - new TSupplierInfo - { - Supplier = supplier1, - Information = "Seems a bit dodgy." - }); + new TSupplierInfo { Supplier = supplier1, Information = "Seems a bit dodgy." }); var supplierInfo2 = toAdd[0].AddEx( - new TSupplierInfo - { - Supplier = supplier1, - Information = "Orange fur?" - }); + new TSupplierInfo { Supplier = supplier1, Information = "Orange fur?" }); var supplierInfo3 = toAdd[0].AddEx( - new TSupplierInfo - { - Supplier = supplier2, - Information = "Very expensive!" - }); + new TSupplierInfo { Supplier = supplier2, Information = "Very expensive!" }); var customerInfo1 = toAdd[0].AddEx( - new TCustomerInfo - { - Information = "Really likes tea." - }); + new TCustomerInfo { Information = "Really likes tea." }); var customerInfo2 = toAdd[0].AddEx( - new TCustomerInfo - { - Information = "Mrs Bossy Pants!" - }); + new TCustomerInfo { Information = "Mrs Bossy Pants!" }); customer1.Info = customerInfo1; customer2.Info = customerInfo2; var computer1 = toAdd[0].AddEx( - new TComputer - { - Name = "markash420" - }); + new TComputer { Name = "markash420" }); var computer2 = toAdd[0].AddEx( - new TComputer - { - Name = "unicorns420" - }); + new TComputer { Name = "unicorns420" }); var computerDetail1 = toAdd[0].AddEx( new TComputerDetail @@ -2324,17 +1710,9 @@ public override void SeedUsingNavigationsWithDeferredAdd() computer2.ComputerDetail = computerDetail2; var driver1 = toAdd[0].AddEx( - new TDriver - { - BirthDate = new DateTime(2006, 9, 19), - Name = "Eeky Bear" - }); + new TDriver { BirthDate = new DateTime(2006, 9, 19), Name = "Eeky Bear" }); var driver2 = toAdd[0].AddEx( - new TDriver - { - BirthDate = new DateTime(2007, 9, 19), - Name = "Splash Bear" - }); + new TDriver { BirthDate = new DateTime(2007, 9, 19), Name = "Splash Bear" }); var license1 = toAdd[1].AddEx( new TLicense diff --git a/test/EFCore.Specification.Tests/TestModels/MusicStore/OrderDetail.cs b/test/EFCore.Specification.Tests/TestModels/MusicStore/OrderDetail.cs index da43c9a0993..cfa091a5c03 100644 --- a/test/EFCore.Specification.Tests/TestModels/MusicStore/OrderDetail.cs +++ b/test/EFCore.Specification.Tests/TestModels/MusicStore/OrderDetail.cs @@ -14,6 +14,7 @@ public class OrderDetail [Column(TypeName = "decimal(18,2)")] public decimal UnitPrice { get; set; } + public virtual Album Album { get; set; } public virtual Order Order { get; set; } } diff --git a/test/EFCore.Specification.Tests/TestModels/MusicStore/ShoppingCart.cs b/test/EFCore.Specification.Tests/TestModels/MusicStore/ShoppingCart.cs index 502ddc5b659..19e17e3941d 100644 --- a/test/EFCore.Specification.Tests/TestModels/MusicStore/ShoppingCart.cs +++ b/test/EFCore.Specification.Tests/TestModels/MusicStore/ShoppingCart.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.TestModels.Northwind; namespace Microsoft.EntityFrameworkCore.TestModels.MusicStore { @@ -28,18 +27,12 @@ public async Task AddToCart(Album album) // Get the matching cart and album instances var cartItem = await _dbContext.CartItems.SingleOrDefaultAsync( c => c.CartId == _shoppingCartId - && c.AlbumId == album.AlbumId); + && c.AlbumId == album.AlbumId); if (cartItem == null) { // Create a new cart item if no cart item exists - cartItem = new CartItem - { - AlbumId = album.AlbumId, - CartId = _shoppingCartId, - Count = 1, - DateCreated = DateTime.Now - }; + cartItem = new CartItem { AlbumId = album.AlbumId, CartId = _shoppingCartId, Count = 1, DateCreated = DateTime.Now }; _dbContext.CartItems.Add(cartItem); } @@ -55,7 +48,7 @@ public int RemoveFromCart(int id) // Get the cart var cartItem = _dbContext.CartItems.SingleOrDefault( cart => cart.CartId == _shoppingCartId - && cart.CartItemId == id); + && cart.CartItemId == id); int itemCount = 0; @@ -122,10 +115,10 @@ public async Task GetTotal() // No way to do decimal sum on server with SQLite, but client eval is fine here return (await _dbContext - .CartItems - .Where(c => c.CartId == _shoppingCartId) - .Select(c => c.Album.Price * c.Count) - .ToListAsync()) + .CartItems + .Where(c => c.CartId == _shoppingCartId) + .Select(c => c.Album.Price * c.Count) + .ToListAsync()) .Sum(); } @@ -141,13 +134,7 @@ public async Task CreateOrder(Order order) //var album = _db.Albums.Find(item.AlbumId); var album = await _dbContext.Albums.SingleAsync(a => a.AlbumId == item.AlbumId); - var orderDetail = new OrderDetail - { - AlbumId = item.AlbumId, - Order = order, - UnitPrice = album.Price, - Quantity = item.Count, - }; + var orderDetail = new OrderDetail { AlbumId = item.AlbumId, Order = order, UnitPrice = album.Price, Quantity = item.Count }; // Set the order total of the shopping cart orderTotal += (item.Count * album.Price); diff --git a/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindContext.cs b/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindContext.cs index 688b6b40149..f6a0d42dead 100644 --- a/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindContext.cs @@ -74,11 +74,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) e => { e.HasKey( - od => new - { - od.OrderID, - od.ProductID - }); + od => new { od.OrderID, od.ProductID }); }); #pragma warning disable CS0618 // Type or member is obsolete @@ -101,10 +97,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .ToQuery( () => Orders .Select( - o => new OrderQuery - { - CustomerID = o.CustomerID - })); + o => new OrderQuery { CustomerID = o.CustomerID })); modelBuilder .Query() @@ -112,12 +105,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) () => Products .Where(p => !p.Discontinued) .Select( - p => new ProductQuery - { - ProductID = p.ProductID, - ProductName = p.ProductName, - CategoryName = "Food" - })); + p => new ProductQuery { ProductID = p.ProductID, ProductName = p.ProductName, CategoryName = "Food" })); modelBuilder .Query() @@ -130,9 +118,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) c => new CustomerQuery { - CompanyName = c.CompanyName, - OrderCount = c.Orders.Count(), - SearchTerm = _searchTerm + CompanyName = c.CompanyName, OrderCount = c.Orders.Count(), SearchTerm = _searchTerm })); #pragma warning restore CS0618 // Type or member is obsolete } diff --git a/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindData.cs b/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindData.cs index 695b482ba59..d8cc34eb5b0 100644 --- a/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindData.cs +++ b/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindData.cs @@ -9,7 +9,6 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Query.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -68,11 +67,7 @@ public NorthwindData() customer.Orders.Add(order); orderQueries.Add( - new OrderQuery - { - CustomerID = order.CustomerID, - Customer = order.Customer - }); + new OrderQuery { CustomerID = order.CustomerID, Customer = order.Customer }); } _orderQueries = orderQueries.ToArray(); diff --git a/test/EFCore.Specification.Tests/TestModels/QueryFilterFuncletizationContext.cs b/test/EFCore.Specification.Tests/TestModels/QueryFilterFuncletizationContext.cs index ce70668dc24..f9bb43568ff 100644 --- a/test/EFCore.Specification.Tests/TestModels/QueryFilterFuncletizationContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/QueryFilterFuncletizationContext.cs @@ -163,240 +163,62 @@ public void Configure(EntityTypeBuilder - { - new DependentSetFilter(), - new DependentSetFilter() - } - }, + new FieldFilter { IsEnabled = true }, + new FieldFilter { IsEnabled = false }, + new PropertyFilter { IsEnabled = true }, + new PropertyFilter { IsEnabled = false }, + new MethodCallFilter { Tenant = 1 }, + new MethodCallFilter { Tenant = 2 }, + new ListFilter { Tenant = 1 }, + new ListFilter { Tenant = 2 }, + new ListFilter { Tenant = 3 }, + new ListFilter { Tenant = 4 }, + new PropertyChainFilter { IsEnabled = true }, + new PropertyChainFilter { IsEnabled = false }, + new PropertyMethodCallFilter { Tenant = 1 }, + new PropertyMethodCallFilter { Tenant = 2 }, + new MethodCallChainFilter { Tenant = 1 }, + new MethodCallChainFilter { Tenant = 2 }, + new ComplexFilter { IsEnabled = true }, + new ComplexFilter { IsEnabled = false }, + new ShortCircuitFilter { IsDeleted = false, IsModerated = false }, + new ShortCircuitFilter { IsDeleted = true, IsModerated = false }, + new ShortCircuitFilter { IsDeleted = false, IsModerated = true }, + new ShortCircuitFilter { IsDeleted = true, IsModerated = true }, + new DbContextStaticMemberFilter { UserId = 1 }, + new DbContextStaticMemberFilter { UserId = 2 }, + new DbContextStaticMemberFilter { UserId = 3 }, + new StaticMemberFilter { IsEnabled = true }, + new StaticMemberFilter { IsEnabled = false }, + new LocalVariableFilter { IsEnabled = true }, + new LocalVariableFilter { IsEnabled = false }, + new EntityTypeConfigurationFieldFilter { IsEnabled = true }, + new EntityTypeConfigurationFieldFilter { IsEnabled = false }, + new EntityTypeConfigurationPropertyFilter { IsEnabled = true }, + new EntityTypeConfigurationPropertyFilter { IsEnabled = false }, + new EntityTypeConfigurationMethodCallFilter { Tenant = 1 }, + new EntityTypeConfigurationMethodCallFilter { Tenant = 2 }, + new EntityTypeConfigurationPropertyChainFilter { IsEnabled = true }, + new EntityTypeConfigurationPropertyChainFilter { IsEnabled = false }, + new LocalMethodFilter { IsEnabled = true }, + new LocalMethodFilter { IsEnabled = false }, + new LocalMethodParamsFilter { IsEnabled = true }, + new LocalMethodParamsFilter { IsEnabled = false }, + new RemoteMethodParamsFilter { Tenant = 1 }, + new RemoteMethodParamsFilter { Tenant = 2 }, + new ExtensionBuilderFilter { IsEnabled = true }, + new ExtensionBuilderFilter { IsEnabled = false }, + new ExtensionContextFilter { IsEnabled = true }, + new ExtensionContextFilter { IsEnabled = false }, + new ParameterFilter { Tenant = 1 }, + new ParameterFilter { Tenant = 2 }, + new PrincipalSetFilter { Dependents = new List { new DependentSetFilter(), new DependentSetFilter() } }, new PrincipalSetFilter(), - new MultiContextFilter - { - BossId = 1, - IsEnabled = true - }, - new MultiContextFilter - { - BossId = 1, - IsEnabled = false - }, - new MultiContextFilter - { - BossId = 1, - IsEnabled = true - }, - new MultiContextFilter - { - BossId = 2, - IsEnabled = true - }, - new MultiContextFilter - { - BossId = 2, - IsEnabled = false - } + new MultiContextFilter { BossId = 1, IsEnabled = true }, + new MultiContextFilter { BossId = 1, IsEnabled = false }, + new MultiContextFilter { BossId = 1, IsEnabled = true }, + new MultiContextFilter { BossId = 2, IsEnabled = true }, + new MultiContextFilter { BossId = 2, IsEnabled = false } ); context.SaveChanges(); diff --git a/test/EFCore.Specification.Tests/TestModels/SpatialModel/SpatialData.cs b/test/EFCore.Specification.Tests/TestModels/SpatialModel/SpatialData.cs index 75fd95825f5..bb09cb11a2d 100644 --- a/test/EFCore.Specification.Tests/TestModels/SpatialModel/SpatialData.cs +++ b/test/EFCore.Specification.Tests/TestModels/SpatialModel/SpatialData.cs @@ -67,11 +67,7 @@ public static IReadOnlyList CreatePointEntities(GeometryFactory fac Point = factory.CreatePoint( new Coordinate(0, 0)) }, - new PointEntity - { - Id = Guid.Parse("67A54C9B-4C3B-4B27-8B4E-C0335E50E551"), - Point = null - } + new PointEntity { Id = Guid.Parse("67A54C9B-4C3B-4B27-8B4E-C0335E50E551"), Point = null } }; foreach (var entity in entities) @@ -87,13 +83,11 @@ public static IReadOnlyList CreateGeoPointEntities() { new GeoPointEntity { - Id = Guid.Parse("67A54C9B-4C3B-4B27-8B4E-C0335E50E552"), - Location = new GeoPoint(47.6233355, -122.34877) + Id = Guid.Parse("67A54C9B-4C3B-4B27-8B4E-C0335E50E552"), Location = new GeoPoint(47.6233355, -122.34877) }, new GeoPointEntity { - Id = Guid.Parse("67A54C9B-4C3B-4B27-8B4E-C0335E50E553"), - Location = new GeoPoint(47.5978429, -122.3308366) + Id = Guid.Parse("67A54C9B-4C3B-4B27-8B4E-C0335E50E553"), Location = new GeoPoint(47.5978429, -122.3308366) } }; @@ -104,17 +98,9 @@ public static IReadOnlyList CreateLineStringEntities(GeometryF { Id = 1, LineString = factory.CreateLineString( - new[] - { - new Coordinate(0, 0), - new Coordinate(1, 0) - }) + new[] { new Coordinate(0, 0), new Coordinate(1, 0) }) }, - new LineStringEntity - { - Id = 2, - LineString = null - } + new LineStringEntity { Id = 2, LineString = null } }; public static IReadOnlyList CreatePolygonEntities(GeometryFactory factory) @@ -124,19 +110,9 @@ public static IReadOnlyList CreatePolygonEntities(GeometryFactory { Id = Guid.Parse("2F39AADE-4D8D-42D2-88CE-775C84AB83B1"), Polygon = factory.CreatePolygon( - new[] - { - new Coordinate(0, 0), - new Coordinate(1, 0), - new Coordinate(0, 1), - new Coordinate(0, 0) - }) + new[] { new Coordinate(0, 0), new Coordinate(1, 0), new Coordinate(0, 1), new Coordinate(0, 0) }) }, - new PolygonEntity - { - Id = Guid.Parse("F1B00CB9-862B-417B-955A-F1F7688B2AB5"), - Polygon = null - } + new PolygonEntity { Id = Guid.Parse("F1B00CB9-862B-417B-955A-F1F7688B2AB5"), Polygon = null } }; public static IReadOnlyList CreateMultiLineStringEntities(GeometryFactory factory) @@ -149,24 +125,12 @@ public static IReadOnlyList CreateMultiLineStringEntities new[] { factory.CreateLineString( - new[] - { - new Coordinate(0, 0), - new Coordinate(0, 1) - }), + new[] { new Coordinate(0, 0), new Coordinate(0, 1) }), factory.CreateLineString( - new[] - { - new Coordinate(1, 0), - new Coordinate(1, 1) - }) + new[] { new Coordinate(1, 0), new Coordinate(1, 1) }) }) }, - new MultiLineStringEntity - { - Id = 2, - MultiLineString = null - } + new MultiLineStringEntity { Id = 2, MultiLineString = null } }; } } diff --git a/test/EFCore.Specification.Tests/TestModels/TransportationModel/LicensedOperator.cs b/test/EFCore.Specification.Tests/TestModels/TransportationModel/LicensedOperator.cs index 4acf69fa4a3..d6e0f3ba173 100644 --- a/test/EFCore.Specification.Tests/TestModels/TransportationModel/LicensedOperator.cs +++ b/test/EFCore.Specification.Tests/TestModels/TransportationModel/LicensedOperator.cs @@ -9,8 +9,8 @@ public class LicensedOperator : Operator public override bool Equals(object obj) => obj is LicensedOperator other - && base.Equals(other) - && LicenseType == other.LicenseType; + && base.Equals(other) + && LicenseType == other.LicenseType; public override int GetHashCode() => base.GetHashCode(); } diff --git a/test/EFCore.Specification.Tests/TestModels/TransportationModel/Operator.cs b/test/EFCore.Specification.Tests/TestModels/TransportationModel/Operator.cs index fd553a7e985..e226b85692b 100644 --- a/test/EFCore.Specification.Tests/TestModels/TransportationModel/Operator.cs +++ b/test/EFCore.Specification.Tests/TestModels/TransportationModel/Operator.cs @@ -10,7 +10,7 @@ public class Operator public string VehicleName { get; set; } public string Name { get; set; } public Vehicle Vehicle { get; set; } - public OperatorDetails Details { get; set; } + public OperatorDetails Details { get; set; } public override bool Equals(object obj) => obj is Operator other diff --git a/test/EFCore.Specification.Tests/TestModels/TransportationModel/TransportationContext.cs b/test/EFCore.Specification.Tests/TestModels/TransportationModel/TransportationContext.cs index 9d04aa54c3f..68999afaef0 100644 --- a/test/EFCore.Specification.Tests/TestModels/TransportationModel/TransportationContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/TransportationModel/TransportationContext.cs @@ -68,7 +68,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasForeignKey(e => e.VehicleName); }); - modelBuilder.Entity( eb => { @@ -102,11 +101,7 @@ protected IEnumerable CreateVehicles() { Name = "Trek Pro Fit Madone 6 Series", SeatingCapacity = 1, - Operator = new Operator - { - Name = "Lance Armstrong", - VehicleName = "Trek Pro Fit Madone 6 Series" - } + Operator = new Operator { Name = "Lance Armstrong", VehicleName = "Trek Pro Fit Madone 6 Series" } }, new PoweredVehicle { @@ -114,9 +109,7 @@ protected IEnumerable CreateVehicles() SeatingCapacity = 34, Operator = new LicensedOperator { - Name = "Albert Williams", - LicenseType = "Muni Transit", - VehicleName = "1984 California Car" + Name = "Albert Williams", LicenseType = "Muni Transit", VehicleName = "1984 California Car" } }, new PoweredVehicle @@ -130,9 +123,7 @@ protected IEnumerable CreateVehicles() }, Operator = new LicensedOperator { - Name = "Elon Musk", - LicenseType = "Driver", - VehicleName = "P85 2012 Tesla Model S Performance Edition" + Name = "Elon Musk", LicenseType = "Driver", VehicleName = "P85 2012 Tesla Model S Performance Edition" } }, new PoweredVehicle @@ -152,9 +143,7 @@ protected IEnumerable CreateVehicles() }, Operator = new LicensedOperator { - Name = "William J. Knight", - LicenseType = "Air Force Test Pilot", - VehicleName = "North American X-15A-2" + Name = "William J. Knight", LicenseType = "Air Force Test Pilot", VehicleName = "North American X-15A-2" } }, new PoweredVehicle @@ -174,11 +163,7 @@ protected IEnumerable CreateVehicles() }, Operator = new Operator { - Details = new OperatorDetails - { - Type = "Heat-seeking", - VehicleName = "AIM-9M Sidewinder" - }, + Details = new OperatorDetails { Type = "Heat-seeking", VehicleName = "AIM-9M Sidewinder" }, VehicleName = "AIM-9M Sidewinder" } } diff --git a/test/EFCore.Specification.Tests/TestModels/UpdatesModel/LoginDetails.cs b/test/EFCore.Specification.Tests/TestModels/UpdatesModel/LoginDetails.cs index 8ef9a8294aa..b83dc01ee62 100644 --- a/test/EFCore.Specification.Tests/TestModels/UpdatesModel/LoginDetails.cs +++ b/test/EFCore.Specification.Tests/TestModels/UpdatesModel/LoginDetails.cs @@ -23,9 +23,23 @@ public class public short? ProfileId12 { get; set; } public int? ProfileId13 { get; set; } public long? ProfileId14 { get; set; } - public int ExtraPropertyWithAnExtremelyLongAndOverlyConvolutedNameThatIsUsedToVerifyThatTheStoreIdentifierGenerationLengthLimitIsWorkingCorrectly { get; set; } - public string ExtraPropertyWithAnExtremelyLongAndOverlyConvolutedNameThatIsUsedToVerifyThatTheStoreIdentifierGenerationLengthLimitIsWorkingCorrectlyWhenTruncatedNamesCollide { get; set; } - public virtual LoginEntityTypeWithAnExtremelyLongAndOverlyConvolutedNameThatIsUsedToVerifyThatTheStoreIdentifierGenerationLengthLimitIsWorkingCorrectly Login { get; set; } + public int + ExtraPropertyWithAnExtremelyLongAndOverlyConvolutedNameThatIsUsedToVerifyThatTheStoreIdentifierGenerationLengthLimitIsWorkingCorrectly + { + get; + set; + } + + public string + ExtraPropertyWithAnExtremelyLongAndOverlyConvolutedNameThatIsUsedToVerifyThatTheStoreIdentifierGenerationLengthLimitIsWorkingCorrectlyWhenTruncatedNamesCollide + { + get; + set; + } + + public virtual + LoginEntityTypeWithAnExtremelyLongAndOverlyConvolutedNameThatIsUsedToVerifyThatTheStoreIdentifierGenerationLengthLimitIsWorkingCorrectly + Login { get; set; } } } diff --git a/test/EFCore.Specification.Tests/TestModels/UpdatesModel/UpdatesContext.cs b/test/EFCore.Specification.Tests/TestModels/UpdatesModel/UpdatesContext.cs index 6cd1759ffbd..c5d6aa0947c 100644 --- a/test/EFCore.Specification.Tests/TestModels/UpdatesModel/UpdatesContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/UpdatesModel/UpdatesContext.cs @@ -24,27 +24,11 @@ public static void Seed(UpdatesContext context) var productId2 = new Guid("0edc9136-7eed-463b-9b97-bdb9648ab877"); context.Add( - new Category - { - Id = 78, - PrincipalId = 778 - }); + new Category { Id = 78, PrincipalId = 778 }); context.Add( - new Product - { - Id = productId1, - Name = "Apple Cider", - Price = 1.49M, - DependentId = 778 - }); + new Product { Id = productId1, Name = "Apple Cider", Price = 1.49M, DependentId = 778 }); context.Add( - new Product - { - Id = productId2, - Name = "Apple Cobler", - Price = 2.49M, - DependentId = 778 - }); + new Product { Id = productId2, Name = "Apple Cobler", Price = 2.49M, DependentId = 778 }); context.SaveChanges(); } diff --git a/test/EFCore.Specification.Tests/TestUtilities/AnnotationComparer.cs b/test/EFCore.Specification.Tests/TestUtilities/AnnotationComparer.cs index 1f4e2536e6d..00ee6540880 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/AnnotationComparer.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/AnnotationComparer.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; // ReSharper disable PossibleNullReferenceException diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs index 5712ed20ee2..3063b0e83b0 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs @@ -315,7 +315,8 @@ private void OrderingSettingsVerifier(bool assertOrder, Type type, Func) || type.GetGenericTypeDefinition() == typeof(IOrderedQueryable<>))) { - throw new InvalidOperationException("Query result is OrderedQueryable - you need to set AssertQuery option: 'assertOrder' to 'true'. If the resulting order is non-deterministic by design, add identity projection to the top of the query to disable this check."); + throw new InvalidOperationException( + "Query result is OrderedQueryable - you need to set AssertQuery option: 'assertOrder' to 'true'. If the resulting order is non-deterministic by design, add identity projection to the top of the query to disable this check."); } if (assertOrder && elementSorter != null) @@ -717,8 +718,8 @@ public virtual Task AssertQueryScalar( // NB: Using Nullable<> instead of ? to work around dotnet/roslyn#31676 public override async Task AssertQueryScalar( - Func, IQueryable>> actualQuery, - Func, IQueryable>> expectedQuery, + Func, IQueryable> actualQuery, + Func, IQueryable> expectedQuery, bool assertOrder, bool isAsync, string testMethodName) @@ -772,8 +773,8 @@ public virtual Task AssertQueryScalar( // NB: Using Nullable<> instead of ? to work around dotnet/roslyn#31676 public override async Task AssertQueryScalar( - Func, IQueryable, IQueryable>> actualQuery, - Func, IQueryable, IQueryable>> expectedQuery, + Func, IQueryable, IQueryable> actualQuery, + Func, IQueryable, IQueryable> expectedQuery, bool assertOrder, bool isAsync, string testMethodName) diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryAsserterBase.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryAsserterBase.cs index 691c0154ccd..791c73a269a 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryAsserterBase.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryAsserterBase.cs @@ -159,8 +159,8 @@ public abstract Task AssertQueryScalar( // NB: Using Nullable<> instead of ? to work around dotnet/roslyn#31676 public abstract Task AssertQueryScalar( - Func, IQueryable>> actualQuery, - Func, IQueryable>> expectedQuery, + Func, IQueryable> actualQuery, + Func, IQueryable> expectedQuery, bool assertOrder, bool isAsync, string testMethodName) @@ -169,8 +169,8 @@ public abstract Task AssertQueryScalar( // NB: Using Nullable<> instead of ? to work around dotnet/roslyn#31676 public abstract Task AssertQueryScalar( - Func, IQueryable, IQueryable>> actualQuery, - Func, IQueryable, IQueryable>> expectedQuery, + Func, IQueryable, IQueryable> actualQuery, + Func, IQueryable, IQueryable> expectedQuery, bool assertOrder, bool isAsync, string testMethodName) diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectWhereExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectWhereExpressionMutator.cs index f1f8f95aef5..ef643eb772b 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectWhereExpressionMutator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/InjectWhereExpressionMutator.cs @@ -33,10 +33,7 @@ public override Expression Apply(Expression expression, Random random) var typeArgument = expressionToInject.Type.GetGenericArguments()[0]; var prm = Expression.Parameter(typeArgument, "prm"); - var candidateExpressions = new List - { - Expression.Constant(random.Choose(new List { true, false })) - }; + var candidateExpressions = new List { Expression.Constant(random.Choose(new List { true, false })) }; if (typeArgument == typeof(bool)) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/ProceduralQueryExpressionGenerator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/ProceduralQueryExpressionGenerator.cs index 1724d4f07d8..2f28aca0d6c 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/ProceduralQueryExpressionGenerator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/ProceduralQueryExpressionGenerator.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Query; namespace Microsoft.EntityFrameworkCore.TestUtilities.QueryTestGeneration { diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestLogger`.cs b/test/EFCore.Specification.Tests/TestUtilities/TestLogger`.cs index cfa717af60f..b5499345566 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestLogger`.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestLogger`.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Diagnostics.Internal; namespace Microsoft.EntityFrameworkCore.TestUtilities { diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestServiceFactory.cs b/test/EFCore.Specification.Tests/TestUtilities/TestServiceFactory.cs index ed6e689fda8..e0118c88437 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestServiceFactory.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestServiceFactory.cs @@ -32,7 +32,8 @@ private readonly ConcurrentDictionary _factories (typeof(IRegisteredServices), new RegisteredServices(Enumerable.Empty())), (typeof(ServiceParameterBindingFactory), new ServiceParameterBindingFactory(typeof(IStateManager))), (typeof(IDiagnosticsLogger), new TestLogger()), - (typeof(IDiagnosticsLogger), new TestLogger()), + (typeof(IDiagnosticsLogger), + new TestLogger()), (typeof(IDiagnosticsLogger), new TestLogger()) }; diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs b/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs index fb7e3448986..88c2d8d6f20 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs @@ -46,7 +46,8 @@ public virtual TestStore Initialize( } public TestStore Initialize( - IServiceProvider serviceProvider, Func createContext, Action seed = null, Action clean = null) + IServiceProvider serviceProvider, Func createContext, Action seed = null, + Action clean = null) => Initialize(serviceProvider, () => createContext(this), seed, clean); protected virtual void Initialize(Func createContext, Action seed, Action clean) diff --git a/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalFactAttribute.cs b/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalFactAttribute.cs index b9d3f3e90eb..0e7ce451539 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalFactAttribute.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalFactAttribute.cs @@ -2,9 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Diagnostics; -using System.IO; -using Xunit; using Xunit.Sdk; // ReSharper disable once CheckNamespace diff --git a/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalFactDiscoverer.cs b/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalFactDiscoverer.cs index 85816328986..91a9636cb2c 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalFactDiscoverer.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalFactDiscoverer.cs @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities.Xunit { /// - /// Used dynamically from . + /// Used dynamically from . /// Make sure to update that class if you move this type. /// public class ConditionalFactDiscoverer : FactDiscoverer diff --git a/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalFactTestCase.cs b/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalFactTestCase.cs index 548a3989979..46c61df8caa 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalFactTestCase.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalFactTestCase.cs @@ -33,10 +33,7 @@ public override async Task RunAsync( ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) => await XunitTestCaseExtensions.TrySkipAsync(this, messageBus) - ? new RunSummary - { - Total = 1, Skipped = 1 - } + ? new RunSummary { Total = 1, Skipped = 1 } : await base.RunAsync( diagnosticMessageSink, messageBus, diff --git a/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalTheoryAttribute.cs b/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalTheoryAttribute.cs index 7dc2813e1de..aebe227ee92 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalTheoryAttribute.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalTheoryAttribute.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Xunit; using Xunit.Sdk; // ReSharper disable once CheckNamespace diff --git a/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalTheoryDiscoverer.cs b/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalTheoryDiscoverer.cs index 00c1cd1f4ca..a83dd502154 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalTheoryDiscoverer.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalTheoryDiscoverer.cs @@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities.Xunit { /// - /// Used dynamically from . + /// Used dynamically from . /// Make sure to update that class if you move this type. /// public class ConditionalTheoryDiscoverer : TheoryDiscoverer @@ -29,7 +29,6 @@ protected override IEnumerable CreateTestCasesForTheory( discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod); - } protected override IEnumerable CreateTestCasesForDataRow( diff --git a/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalTheoryTestCase.cs b/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalTheoryTestCase.cs index 32720f73a51..27ba5157e33 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalTheoryTestCase.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/Xunit/ConditionalTheoryTestCase.cs @@ -32,10 +32,7 @@ public override async Task RunAsync( ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) => await XunitTestCaseExtensions.TrySkipAsync(this, messageBus) - ? new RunSummary - { - Total = 1, Skipped = 1 - } + ? new RunSummary { Total = 1, Skipped = 1 } : await base.RunAsync( diagnosticMessageSink, messageBus, diff --git a/test/EFCore.Specification.Tests/TestUtilities/Xunit/XunitTestCaseExtensions.cs b/test/EFCore.Specification.Tests/TestUtilities/Xunit/XunitTestCaseExtensions.cs index f985f897ea2..80ea34accaf 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/Xunit/XunitTestCaseExtensions.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/Xunit/XunitTestCaseExtensions.cs @@ -28,15 +28,15 @@ public static async ValueTask TrySkipAsync(XunitTestCase testCase, IMessag var skipReasons = new List(); var attributes = _assemblyAttributes.GetOrAdd( - assembly.Name, - a => assembly.GetCustomAttributes(typeof(ITestCondition)).ToList()) - .Concat( - _typeAttributes.GetOrAdd( - type.Name, - t => type.GetCustomAttributes(typeof(ITestCondition)).ToList())) - .Concat(method.GetCustomAttributes(typeof(ITestCondition))) - .OfType() - .Select(attributeInfo => (ITestCondition)attributeInfo.Attribute); + assembly.Name, + a => assembly.GetCustomAttributes(typeof(ITestCondition)).ToList()) + .Concat( + _typeAttributes.GetOrAdd( + type.Name, + t => type.GetCustomAttributes(typeof(ITestCondition)).ToList())) + .Concat(method.GetCustomAttributes(typeof(ITestCondition))) + .OfType() + .Select(attributeInfo => (ITestCondition)attributeInfo.Attribute); foreach (var attribute in attributes) { @@ -48,7 +48,8 @@ public static async ValueTask TrySkipAsync(XunitTestCase testCase, IMessag if (skipReasons.Count > 0) { - messageBus.QueueMessage(new TestSkipped(new XunitTest(testCase, testCase.DisplayName), string.Join(Environment.NewLine, skipReasons))); + messageBus.QueueMessage( + new TestSkipped(new XunitTest(testCase, testCase.DisplayName), string.Join(Environment.NewLine, skipReasons))); return true; } diff --git a/test/EFCore.Specification.Tests/UpdatesFixtureBase.cs b/test/EFCore.Specification.Tests/UpdatesFixtureBase.cs index 50fda2cdb9d..1442a3f31ed 100644 --- a/test/EFCore.Specification.Tests/UpdatesFixtureBase.cs +++ b/test/EFCore.Specification.Tests/UpdatesFixtureBase.cs @@ -83,29 +83,28 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb => { eb.HasKey( - l => new - { - l.ProfileId - }); + l => new { l.ProfileId }); eb.HasOne(d => d.Login).WithOne() - .HasForeignKey( - l => new - { - l.ProfileId, - l.ProfileId1, - l.ProfileId3, - l.ProfileId4, - l.ProfileId5, - l.ProfileId6, - l.ProfileId7, - l.ProfileId8, - l.ProfileId9, - l.ProfileId10, - l.ProfileId11, - l.ProfileId12, - l.ProfileId13, - l.ProfileId14 - }); + .HasForeignKey< + LoginEntityTypeWithAnExtremelyLongAndOverlyConvolutedNameThatIsUsedToVerifyThatTheStoreIdentifierGenerationLengthLimitIsWorkingCorrectlyDetails + >( + l => new + { + l.ProfileId, + l.ProfileId1, + l.ProfileId3, + l.ProfileId4, + l.ProfileId5, + l.ProfileId6, + l.ProfileId7, + l.ProfileId8, + l.ProfileId9, + l.ProfileId10, + l.ProfileId11, + l.ProfileId12, + l.ProfileId13, + l.ProfileId14 + }); }); modelBuilder.Entity( diff --git a/test/EFCore.Specification.Tests/UpdatesTestBase.cs b/test/EFCore.Specification.Tests/UpdatesTestBase.cs index 5555326d033..3e35ff2250b 100644 --- a/test/EFCore.Specification.Tests/UpdatesTestBase.cs +++ b/test/EFCore.Specification.Tests/UpdatesTestBase.cs @@ -32,16 +32,8 @@ public virtual void Mutation_of_tracked_values_does_not_mutate_values_in_store() context => { context.AFewBytes.AddRange( - new AFewBytes - { - Id = id1, - Bytes = bytes - }, - new AFewBytes - { - Id = id2, - Bytes = bytes - }); + new AFewBytes { Id = id1, Bytes = bytes }, + new AFewBytes { Id = id2, Bytes = bytes }); context.SaveChanges(); }, @@ -81,11 +73,7 @@ public virtual void Save_partial_update() context => { var entry = context.Products.Attach( - new Product - { - Id = productId, - Price = 1.49M - }); + new Product { Id = productId, Price = 1.49M }); entry.Property(c => c.Price).CurrentValue = 1.99M; entry.Property(p => p.Price).IsModified = true; @@ -111,11 +99,7 @@ public virtual void Save_partial_update_on_missing_record_throws() context => { var entry = context.Products.Attach( - new Product - { - Id = new Guid("3d1302c5-4cf8-4043-9758-de9398f6fe10"), - Name = "Apple Fritter" - }); + new Product { Id = new Guid("3d1302c5-4cf8-4043-9758-de9398f6fe10"), Name = "Apple Fritter" }); entry.Property(c => c.Name).IsModified = true; @@ -137,9 +121,7 @@ public virtual void Save_partial_update_on_concurrency_token_original_value_mism var entry = context.Products.Attach( new Product { - Id = productId, - Name = "Apple Fritter", - Price = 3.49M // Not the same as the value stored in the database + Id = productId, Name = "Apple Fritter", Price = 3.49M // Not the same as the value stored in the database }); entry.Property(c => c.Name).IsModified = true; @@ -160,24 +142,14 @@ public virtual void Update_on_bytes_concurrency_token_original_value_mismatch_th context => { context.Add( - new ProductWithBytes - { - Id = productId, - Name = "MegaChips", - Bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 } - }); + new ProductWithBytes { Id = productId, Name = "MegaChips", Bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 } }); context.SaveChanges(); }, context => { var entry = context.ProductWithBytes.Attach( - new ProductWithBytes - { - Id = productId, - Name = "MegaChips", - Bytes = new byte[] { 8, 7, 6, 5, 4, 3, 2, 1 } - }); + new ProductWithBytes { Id = productId, Name = "MegaChips", Bytes = new byte[] { 8, 7, 6, 5, 4, 3, 2, 1 } }); entry.Entity.Name = "GigaChips"; @@ -196,24 +168,14 @@ public virtual void Update_on_bytes_concurrency_token_original_value_matches_doe context => { context.Add( - new ProductWithBytes - { - Id = productId, - Name = "MegaChips", - Bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 } - }); + new ProductWithBytes { Id = productId, Name = "MegaChips", Bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 } }); context.SaveChanges(); }, context => { var entry = context.ProductWithBytes.Attach( - new ProductWithBytes - { - Id = productId, - Name = "MegaChips", - Bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 } - }); + new ProductWithBytes { Id = productId, Name = "MegaChips", Bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 } }); entry.Entity.Name = "GigaChips"; @@ -231,24 +193,14 @@ public virtual void Remove_on_bytes_concurrency_token_original_value_mismatch_th context => { context.Add( - new ProductWithBytes - { - Id = productId, - Name = "MegaChips", - Bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 } - }); + new ProductWithBytes { Id = productId, Name = "MegaChips", Bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 } }); context.SaveChanges(); }, context => { var entry = context.ProductWithBytes.Attach( - new ProductWithBytes - { - Id = productId, - Name = "MegaChips", - Bytes = new byte[] { 8, 7, 6, 5, 4, 3, 2, 1 } - }); + new ProductWithBytes { Id = productId, Name = "MegaChips", Bytes = new byte[] { 8, 7, 6, 5, 4, 3, 2, 1 } }); entry.State = EntityState.Deleted; @@ -267,24 +219,14 @@ public virtual void Remove_on_bytes_concurrency_token_original_value_matches_doe context => { context.Add( - new ProductWithBytes - { - Id = productId, - Name = "MegaChips", - Bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 } - }); + new ProductWithBytes { Id = productId, Name = "MegaChips", Bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 } }); context.SaveChanges(); }, context => { var entry = context.ProductWithBytes.Attach( - new ProductWithBytes - { - Id = productId, - Name = "MegaChips", - Bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 } - }); + new ProductWithBytes { Id = productId, Name = "MegaChips", Bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 } }); entry.State = EntityState.Deleted; @@ -302,11 +244,7 @@ public virtual void Can_remove_partial() context => { context.Products.Remove( - new Product - { - Id = productId, - Price = 1.49M - }); + new Product { Id = productId, Price = 1.49M }); context.SaveChanges(); }, @@ -325,10 +263,7 @@ public virtual void Remove_partial_on_missing_record_throws() context => { context.Products.Remove( - new Product - { - Id = new Guid("3d1302c5-4cf8-4043-9758-de9398f6fe10") - }); + new Product { Id = new Guid("3d1302c5-4cf8-4043-9758-de9398f6fe10") }); Assert.Equal( UpdateConcurrencyMessage, @@ -348,8 +283,7 @@ public virtual void Remove_partial_on_concurrency_token_original_value_mismatch_ context.Products.Remove( new Product { - Id = productId, - Price = 3.49M // Not the same as the value stored in the database + Id = productId, Price = 3.49M // Not the same as the value stored in the database }); Assert.Equal( @@ -370,12 +304,7 @@ public virtual void Save_replaced_principal() Assert.Equal(2, products.Count); - var newCategory = new Category - { - Id = category.Id, - PrincipalId = category.PrincipalId, - Name = "New Category" - }; + var newCategory = new Category { Id = category.Id, PrincipalId = category.PrincipalId, Name = "New Category" }; context.Remove(category); context.Add(newCategory); @@ -403,28 +332,13 @@ public virtual void SaveChanges_processes_all_tracked_entities() var productId2 = new Guid("0edc9136-7eed-463b-9b97-bdb9648ab877"); var entry1 = stateManager.GetOrCreateEntry( - new Category - { - Id = 77, - PrincipalId = 777 - }); + new Category { Id = 77, PrincipalId = 777 }); var entry2 = stateManager.GetOrCreateEntry( - new Category - { - Id = 78, - PrincipalId = 778 - }); + new Category { Id = 78, PrincipalId = 778 }); var entry3 = stateManager.GetOrCreateEntry( - new Product - { - Id = productId1 - }); + new Product { Id = productId1 }); var entry4 = stateManager.GetOrCreateEntry( - new Product - { - Id = productId2, - Price = 2.49M - }); + new Product { Id = productId2, Price = 2.49M }); entry1.SetEntityState(EntityState.Added); entry2.SetEntityState(EntityState.Modified); @@ -457,28 +371,13 @@ public virtual void SaveChanges_false_processes_all_tracked_entities_without_cal var productId2 = new Guid("0edc9136-7eed-463b-9b97-bdb9648ab877"); var entry1 = stateManager.GetOrCreateEntry( - new Category - { - Id = 77, - PrincipalId = 777 - }); + new Category { Id = 77, PrincipalId = 777 }); var entry2 = stateManager.GetOrCreateEntry( - new Category - { - Id = 78, - PrincipalId = 778 - }); + new Category { Id = 78, PrincipalId = 778 }); var entry3 = stateManager.GetOrCreateEntry( - new Product - { - Id = productId1 - }); + new Product { Id = productId1 }); var entry4 = stateManager.GetOrCreateEntry( - new Product - { - Id = productId2, - Price = 2.49M - }); + new Product { Id = productId2, Price = 2.49M }); entry1.SetEntityState(EntityState.Added); entry2.SetEntityState(EntityState.Modified); @@ -513,28 +412,13 @@ public Task SaveChangesAsync_processes_all_tracked_entities() var productId2 = new Guid("0edc9136-7eed-463b-9b97-bdb9648ab877"); var entry1 = stateManager.GetOrCreateEntry( - new Category - { - Id = 77, - PrincipalId = 777 - }); + new Category { Id = 77, PrincipalId = 777 }); var entry2 = stateManager.GetOrCreateEntry( - new Category - { - Id = 78, - PrincipalId = 778 - }); + new Category { Id = 78, PrincipalId = 778 }); var entry3 = stateManager.GetOrCreateEntry( - new Product - { - Id = productId1 - }); + new Product { Id = productId1 }); var entry4 = stateManager.GetOrCreateEntry( - new Product - { - Id = productId2, - Price = 2.49M - }); + new Product { Id = productId2, Price = 2.49M }); entry1.SetEntityState(EntityState.Added); entry2.SetEntityState(EntityState.Modified); @@ -567,28 +451,13 @@ public Task SaveChangesAsync_false_processes_all_tracked_entities_without_callin var productId2 = new Guid("0edc9136-7eed-463b-9b97-bdb9648ab877"); var entry1 = stateManager.GetOrCreateEntry( - new Category - { - Id = 77, - PrincipalId = 777 - }); + new Category { Id = 77, PrincipalId = 777 }); var entry2 = stateManager.GetOrCreateEntry( - new Category - { - Id = 78, - PrincipalId = 778 - }); + new Category { Id = 78, PrincipalId = 778 }); var entry3 = stateManager.GetOrCreateEntry( - new Product - { - Id = productId1 - }); + new Product { Id = productId1 }); var entry4 = stateManager.GetOrCreateEntry( - new Product - { - Id = productId2, - Price = 2.49M - }); + new Product { Id = productId2, Price = 2.49M }); entry1.SetEntityState(EntityState.Added); entry2.SetEntityState(EntityState.Modified); diff --git a/test/EFCore.Specification.Tests/WithConstructorsTestBase.cs b/test/EFCore.Specification.Tests/WithConstructorsTestBase.cs index b708d2838b9..6143c54006a 100644 --- a/test/EFCore.Specification.Tests/WithConstructorsTestBase.cs +++ b/test/EFCore.Specification.Tests/WithConstructorsTestBase.cs @@ -11,7 +11,6 @@ using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; @@ -208,18 +207,9 @@ public virtual void Attaching_entity_sets_context() using (var context = CreateContext()) { - var entityWithBase = new HasContextProperty - { - Id = id1 - }; - var entityWithDerived = new HasContextProperty - { - Id = id2 - }; - var entityWithOther = new HasContextProperty - { - Id = id3 - }; + var entityWithBase = new HasContextProperty { Id = id1 }; + var entityWithDerived = new HasContextProperty { Id = id2 }; + var entityWithOther = new HasContextProperty { Id = id3 }; context.Attach(entityWithBase); context.Attach(entityWithDerived); @@ -290,10 +280,7 @@ public virtual void Attaching_entity_sets_EntityType() using (var context = CreateContext()) { - var entity = new HasEntityTypeProperty - { - Id = id - }; + var entity = new HasEntityTypeProperty { Id = id }; context.Attach(entity); @@ -360,10 +347,7 @@ public virtual void Attaching_entity_sets_StateManager() using (var context = CreateContext()) { - var entity = new HasStateManagerProperty - { - Id = id - }; + var entity = new HasStateManagerProperty { Id = id }; context.Attach(entity); @@ -521,11 +505,7 @@ public virtual void Attaching_entity_sets_lazy_loader() using (var context = CreateContext()) { - var post = new LazyPropertyPost - { - Id = id, - LazyPropertyBlogId = fk - }; + var post = new LazyPropertyPost { Id = id, LazyPropertyBlogId = fk }; Assert.Null(post.GetLoader()); context.Attach(post); @@ -603,11 +583,7 @@ public virtual void Attaching_entity_sets_lazy_loader_field() using (var context = CreateContext()) { - var post = new LazyFieldPost - { - Id = id, - LazyFieldBlogId = fk - }; + var post = new LazyFieldPost { Id = id, LazyFieldBlogId = fk }; Assert.Null(post.GetLoader()); context.Attach(post); @@ -660,11 +636,7 @@ public virtual void Attaching_entity_sets_lazy_loader_delegate() using (var context = CreateContext()) { - var post = new LazyPcsPost - { - Id = id, - LazyPcsBlogId = fk - }; + var post = new LazyPcsPost { Id = id, LazyPcsBlogId = fk }; Assert.Null(post.GetLoader()); context.Attach(post); @@ -929,7 +901,6 @@ protected class HasContextPc where TContext : DbContext { private TContext _context; - // ReSharper disable once ConvertToAutoProperty private bool _setterCalled; public HasContextPc() @@ -958,7 +929,7 @@ private TContext Context } } - // ReSharper disable once ConvertToAutoProperty + // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter public bool SetterCalled => _setterCalled; public TContext GetContext() => Context; @@ -1059,8 +1030,8 @@ protected class HasStateManagerProperty protected class HasStateManagerPc { private IStateManager _stateManager; - // ReSharper disable once ConvertToAutoProperty private bool _setterCalled; + // ReSharper disable once ConvertToAutoProperty public HasStateManagerPc() { @@ -1085,7 +1056,7 @@ private IStateManager StateManager } } - // ReSharper disable once ConvertToAutoProperty + // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter public bool SetterCalled => _setterCalled; public IStateManager GetStateManager() => StateManager; @@ -1627,11 +1598,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.Property(e => e.Title); }); - modelBuilder.Entity(b => - { - b.HasNoKey(); - b.Property(e => e.Title); - }); + modelBuilder.Entity( + b => + { + b.HasNoKey(); + b.Property(e => e.Title); + }); modelBuilder.Entity( b => diff --git a/test/EFCore.SqlServer.FunctionalTests/BatchingTest.cs b/test/EFCore.SqlServer.FunctionalTests/BatchingTest.cs index c6cb6610d7f..1728b3cf904 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BatchingTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BatchingTest.cs @@ -84,12 +84,7 @@ public void Inserts_and_updates_are_batched_correctly() context.Owners.Add(owner1); context.Owners.Add(owner2); - var blog1 = new Blog - { - Id = Guid.NewGuid(), - Owner = owner1, - Order = 1 - }; + var blog1 = new Blog { Id = Guid.NewGuid(), Owner = owner1, Order = 1 }; context.Set().Add(blog1); expectedBlogs.Add(blog1); @@ -99,22 +94,12 @@ public void Inserts_and_updates_are_batched_correctly() owner2.Name = "2"; blog1.Order = 0; - var blog2 = new Blog - { - Id = Guid.NewGuid(), - Owner = owner1, - Order = 1 - }; + var blog2 = new Blog { Id = Guid.NewGuid(), Owner = owner1, Order = 1 }; context.Set().Add(blog2); expectedBlogs.Add(blog2); - var blog3 = new Blog - { - Id = Guid.NewGuid(), - Owner = owner2, - Order = 2 - }; + var blog3 = new Blog { Id = Guid.NewGuid(), Owner = owner2, Order = 2 }; context.Set().Add(blog3); expectedBlogs.Add(blog3); @@ -156,11 +141,7 @@ public void Inserts_are_batched_only_when_necessary(int minBatchSize) for (var i = 1; i < 4; i++) { - var blog = new Blog - { - Id = Guid.NewGuid(), - Owner = owner - }; + var blog = new Blog { Id = Guid.NewGuid(), Owner = owner }; context.Set().Add(blog); expectedBlogs.Add(blog); @@ -172,8 +153,10 @@ public void Inserts_are_batched_only_when_necessary(int minBatchSize) Assert.Contains( minBatchSize == 3 - ? RelationalResources.LogBatchReadyForExecution(new TestLogger()).GenerateMessage(3) - : RelationalResources.LogBatchSmallerThanMinBatchSize(new TestLogger()).GenerateMessage(3, 4), + ? RelationalResources.LogBatchReadyForExecution(new TestLogger()) + .GenerateMessage(3) + : RelationalResources.LogBatchSmallerThanMinBatchSize(new TestLogger()) + .GenerateMessage(3, 4), Fixture.TestSqlLoggerFactory.Log.Select(l => l.Message)); Assert.Equal(minBatchSize <= 3 ? 2 : 4, Fixture.TestSqlLoggerFactory.SqlStatements.Count); diff --git a/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs index 48cb95e2b03..acb27010c4b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs @@ -463,10 +463,7 @@ public virtual void Can_query_using_any_mapped_data_types_with_nulls() using (var context = CreateContext()) { context.Set().Add( - new MappedNullableDataTypes - { - Int = 911 - }); + new MappedNullableDataTypes { Int = 911 }); Assert.Equal(1, context.SaveChanges()); } @@ -1422,10 +1419,7 @@ private static void AssertMappedPrecisionAndScaledDataTypes(MappedPrecisionAndSc private static MappedPrecisionAndScaledDataTypes CreateMappedPrecisionAndScaledDataTypes(int id) => new MappedPrecisionAndScaledDataTypes { - Id = id, - DecimalAsDecimal52 = 101.1m, - DecimalAsDec52 = 102.2m, - DecimalAsNumeric52 = 103.3m + Id = id, DecimalAsDecimal52 = 101.1m, DecimalAsDec52 = 102.2m, DecimalAsNumeric52 = 103.3m }; [ConditionalFact] @@ -2185,10 +2179,7 @@ private static void AssertMappedPrecisionAndScaledDataTypesWithIdentity( private static MappedPrecisionAndScaledDataTypesWithIdentity CreateMappedPrecisionAndScaledDataTypesWithIdentity(int id) => new MappedPrecisionAndScaledDataTypesWithIdentity { - Int = id, - DecimalAsDecimal52 = 101.1m, - DecimalAsDec52 = 102.2m, - DecimalAsNumeric52 = 103.3m + Int = id, DecimalAsDecimal52 = 101.1m, DecimalAsDec52 = 102.2m, DecimalAsNumeric52 = 103.3m }; [ConditionalFact] diff --git a/test/EFCore.SqlServer.FunctionalTests/CommandConfigurationTest.cs b/test/EFCore.SqlServer.FunctionalTests/CommandConfigurationTest.cs index 31fb8373470..d45ed5d1230 100644 --- a/test/EFCore.SqlServer.FunctionalTests/CommandConfigurationTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/CommandConfigurationTest.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable UnusedAutoPropertyAccessor.Local diff --git a/test/EFCore.SqlServer.FunctionalTests/CommandInterceptionSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/CommandInterceptionSqlServerTest.cs index 80ded93c1c3..c84c66240d0 100644 --- a/test/EFCore.SqlServer.FunctionalTests/CommandInterceptionSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/CommandInterceptionSqlServerTest.cs @@ -70,7 +70,8 @@ public class InterceptionSqlServerFixture : InterceptionSqlServerFixtureBase } public class CommandInterceptionWithDiagnosticsSqlServerTest - : CommandInterceptionSqlServerTestBase, IClassFixture + : CommandInterceptionSqlServerTestBase, + IClassFixture { public CommandInterceptionWithDiagnosticsSqlServerTest(InterceptionSqlServerFixture fixture) : base(fixture) diff --git a/test/EFCore.SqlServer.FunctionalTests/ConferencePlannerSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ConferencePlannerSqlServerTest.cs index 3c604401270..8280d88b38c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ConferencePlannerSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ConferencePlannerSqlServerTest.cs @@ -7,7 +7,8 @@ namespace Microsoft.EntityFrameworkCore { - public class ConferencePlannerSqlServerTest : ConferencePlannerTestBase + public class ConferencePlannerSqlServerTest : ConferencePlannerTestBase { public ConferencePlannerSqlServerTest(ConferencePlannerSqlServerFixture fixture) : base(fixture) diff --git a/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs index a4edebf2f80..c6cf5271bea 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs @@ -43,7 +43,7 @@ public class FakeDbConnection : DbConnection public override void ChangeDatabase(string databaseName) => throw new NotImplementedException(); public override void Close() => throw new NotImplementedException(); public override void Open() => throw new NotImplementedException(); - protected override DbTransaction BeginDbTransaction(System.Data.IsolationLevel isolationLevel) => throw new NotImplementedException(); + protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) => throw new NotImplementedException(); protected override DbCommand CreateDbCommand() => throw new NotImplementedException(); } @@ -62,7 +62,8 @@ public class InterceptionSqlServerFixture : InterceptionSqlServerFixtureBase } public class ConnectionInterceptionWithDiagnosticsSqlServerTest - : ConnectionInterceptionSqlServerTestBase, IClassFixture + : ConnectionInterceptionSqlServerTestBase, + IClassFixture { public ConnectionInterceptionWithDiagnosticsSqlServerTest(InterceptionSqlServerFixture fixture) : base(fixture) diff --git a/test/EFCore.SqlServer.FunctionalTests/ConnectionSpecificationTest.cs b/test/EFCore.SqlServer.FunctionalTests/ConnectionSpecificationTest.cs index 19522af1cca..4bbc4f192e4 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ConnectionSpecificationTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ConnectionSpecificationTest.cs @@ -270,10 +270,7 @@ public void Can_use_AddDbContext_and_get_connection_string_from_config(string ke { var configBuilder = new ConfigurationBuilder() .AddInMemoryCollection( - new Dictionary - { - { key, SqlServerNorthwindTestStoreFactory.NorthwindConnectionString } - }); + new Dictionary { { key, SqlServerNorthwindTestStoreFactory.NorthwindConnectionString } }); var serviceProvider = new ServiceCollection() diff --git a/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs index a842ddb493c..3f6755759d1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs @@ -2,14 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Linq; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Diagnostics.Internal; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.SqlServer.Diagnostics.Internal; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; namespace Microsoft.EntityFrameworkCore diff --git a/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs index 07051ae6e1d..f4c7b0a2b55 100644 --- a/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs @@ -4,7 +4,6 @@ using System; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable InconsistentNaming diff --git a/test/EFCore.SqlServer.FunctionalTests/DataAnnotationSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/DataAnnotationSqlServerTest.cs index 42ea791787a..0aa83fb8cfc 100644 --- a/test/EFCore.SqlServer.FunctionalTests/DataAnnotationSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/DataAnnotationSqlServerTest.cs @@ -39,7 +39,8 @@ public virtual ModelBuilder Default_for_key_string_column_throws() Assert.Equal( CoreStrings.WarningAsErrorTemplate( RelationalEventId.ModelValidationKeyDefaultValueWarning, - RelationalResources.LogKeyHasDefaultValue(new TestLogger()).GenerateMessage(nameof(Login1.UserName), nameof(Login1)), + RelationalResources.LogKeyHasDefaultValue(new TestLogger()) + .GenerateMessage(nameof(Login1.UserName), nameof(Login1)), "RelationalEventId.ModelValidationKeyDefaultValueWarning"), Assert.Throws(() => Validate(modelBuilder)).Message); @@ -342,6 +343,7 @@ public override void TimestampAttribute_throws_if_value_in_database_changed() } private static readonly string _eol = Environment.NewLine; + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs b/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs index 07f1383d8ad..a5084a60c06 100644 --- a/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs @@ -84,7 +84,7 @@ public PooledContext(DbContextOptions options) ChangeTracker.LazyLoadingEnabled = false; Database.AutoTransactionsEnabled = false; ChangeTracker.CascadeDeleteTiming = CascadeTiming.Never; - ChangeTracker.DeleteOrphansTiming= CascadeTiming.Never; + ChangeTracker.DeleteOrphansTiming = CascadeTiming.Never; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) @@ -388,7 +388,7 @@ public void Context_configuration_is_reset(bool useInterface) context1.ChangeTracker.LazyLoadingEnabled = true; context1.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; context1.ChangeTracker.CascadeDeleteTiming = CascadeTiming.Immediate; - context1.ChangeTracker.DeleteOrphansTiming= CascadeTiming.Immediate; + context1.ChangeTracker.DeleteOrphansTiming = CascadeTiming.Immediate; context1.Database.AutoTransactionsEnabled = true; serviceScope.Dispose(); @@ -425,7 +425,7 @@ public void Default_Context_configuration__is_reset() context1.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; context1.Database.AutoTransactionsEnabled = false; context1.ChangeTracker.CascadeDeleteTiming = CascadeTiming.Immediate; - context1.ChangeTracker.DeleteOrphansTiming= CascadeTiming.Immediate; + context1.ChangeTracker.DeleteOrphansTiming = CascadeTiming.Immediate; serviceScope.Dispose(); diff --git a/test/EFCore.SqlServer.FunctionalTests/DefaultValuesTest.cs b/test/EFCore.SqlServer.FunctionalTests/DefaultValuesTest.cs index e97d4d5d708..551e7be7042 100644 --- a/test/EFCore.SqlServer.FunctionalTests/DefaultValuesTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/DefaultValuesTest.cs @@ -23,24 +23,14 @@ public void Can_use_SQL_Server_default_values() context.Database.EnsureCreatedResiliently(); context.Chippers.Add( - new Chipper - { - Id = "Default" - }); + new Chipper { Id = "Default" }); context.SaveChanges(); var honeyDijon = context.Add( - new KettleChips - { - Name = "Honey Dijon" - }).Entity; + new KettleChips { Name = "Honey Dijon" }).Entity; var buffaloBleu = context.Add( - new KettleChips - { - Name = "Buffalo Bleu", - BestBuyDate = new DateTime(2111, 1, 11) - }).Entity; + new KettleChips { Name = "Buffalo Bleu", BestBuyDate = new DateTime(2111, 1, 11) }).Entity; context.SaveChanges(); diff --git a/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs index e625a1f376c..58fd51b70ec 100644 --- a/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Microsoft.Extensions.DependencyInjection; using Xunit; diff --git a/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs index 5b87a9dbd18..b11ca07dc32 100644 --- a/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Microsoft.Extensions.DependencyInjection; using Xunit; diff --git a/test/EFCore.SqlServer.FunctionalTests/F1SqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/F1SqlServerFixture.cs index 5eb9fbbf99e..380ca0eb2e3 100644 --- a/test/EFCore.SqlServer.FunctionalTests/F1SqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/F1SqlServerFixture.cs @@ -25,18 +25,21 @@ protected override void BuildModelExternal(ModelBuilder modelBuilder) .ValueGeneratedOnAddOrUpdate() .IsConcurrencyToken(); - modelBuilder.Entity(eb => - { - eb.Property("Version").IsRowVersion().HasColumnName("Version"); - eb.Property(Sponsor.ClientTokenPropertyName).HasColumnName(Sponsor.ClientTokenPropertyName); - }); - modelBuilder.Entity() - .OwnsOne(s => s.Details, eb => + modelBuilder.Entity( + eb => { - eb.Property(d => d.Space).HasColumnType("decimal(18,2)"); eb.Property("Version").IsRowVersion().HasColumnName("Version"); - eb.Property(Sponsor.ClientTokenPropertyName).IsConcurrencyToken().HasColumnName(Sponsor.ClientTokenPropertyName); + eb.Property(Sponsor.ClientTokenPropertyName).HasColumnName(Sponsor.ClientTokenPropertyName); }); + modelBuilder.Entity() + .OwnsOne( + s => s.Details, eb => + { + eb.Property(d => d.Space).HasColumnType("decimal(18,2)"); + eb.Property("Version").IsRowVersion().HasColumnName("Version"); + eb.Property(Sponsor.ClientTokenPropertyName).IsConcurrencyToken() + .HasColumnName(Sponsor.ClientTokenPropertyName); + }); } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientCascade.cs b/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientCascade.cs index f34df02e550..f50bc66b135 100644 --- a/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientCascade.cs +++ b/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientCascade.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore { - public class GraphUpdatesSqlServerTestClientCascade : GraphUpdatesSqlServerTestBase + public class GraphUpdatesSqlServerTestClientCascade : GraphUpdatesSqlServerTestBase< + GraphUpdatesSqlServerTestClientCascade.GraphUpdatesWithClientCascadeSqlServerFixture> { public GraphUpdatesSqlServerTestClientCascade(GraphUpdatesWithClientCascadeSqlServerFixture fixture) : base(fixture) diff --git a/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientNoAction.cs b/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientNoAction.cs index a8ecbc9d25a..87b85852a89 100644 --- a/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientNoAction.cs +++ b/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestClientNoAction.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore { - public class GraphUpdatesSqlServerTestClientNoAction : GraphUpdatesSqlServerTestBase + public class GraphUpdatesSqlServerTestClientNoAction : GraphUpdatesSqlServerTestBase< + GraphUpdatesSqlServerTestClientNoAction.GraphUpdatesWithClientNoActionSqlServerFixture> { public GraphUpdatesSqlServerTestClientNoAction(GraphUpdatesWithClientNoActionSqlServerFixture fixture) : base(fixture) diff --git a/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestIdentity.cs b/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestIdentity.cs index d1fa571428e..ca3233ccb6d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestIdentity.cs +++ b/test/EFCore.SqlServer.FunctionalTests/GraphUpdatesSqlServerTestIdentity.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore { - public class GraphUpdatesSqlServerTestIdentity : GraphUpdatesSqlServerTestBase + public class GraphUpdatesSqlServerTestIdentity : GraphUpdatesSqlServerTestBase< + GraphUpdatesSqlServerTestIdentity.GraphUpdatesWithIdentitySqlServerFixture> { public GraphUpdatesSqlServerTestIdentity(GraphUpdatesWithIdentitySqlServerFixture fixture) : base(fixture) diff --git a/test/EFCore.SqlServer.FunctionalTests/MemoryOptimizedTablesTest.cs b/test/EFCore.SqlServer.FunctionalTests/MemoryOptimizedTablesTest.cs index 624832011d8..e40be84cc86 100644 --- a/test/EFCore.SqlServer.FunctionalTests/MemoryOptimizedTablesTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/MemoryOptimizedTablesTest.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Linq; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable UnusedAutoPropertyAccessor.Local @@ -26,19 +25,7 @@ public void Can_create_memoryOptimized_table() using (CreateTestStore()) { var bigUn = new BigUn(); - var fastUns = new[] - { - new FastUn - { - Name = "First 'un", - BigUn = bigUn - }, - new FastUn - { - Name = "Second 'un", - BigUn = bigUn - } - }; + var fastUns = new[] { new FastUn { Name = "First 'un", BigUn = bigUn }, new FastUn { Name = "Second 'un", BigUn = bigUn } }; using (var context = CreateContext()) { context.Database.EnsureCreatedResiliently(); diff --git a/test/EFCore.SqlServer.FunctionalTests/MigrationsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/MigrationsSqlServerTest.cs index 971a4f20fcb..3aed77c0ecc 100644 --- a/test/EFCore.SqlServer.FunctionalTests/MigrationsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/MigrationsSqlServerTest.cs @@ -530,11 +530,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Blogs"); b.HasData( - new - { - Id = 1, - Name = "HalfADonkey" - }); + new { Id = 1, Name = "HalfADonkey" }); }); modelBuilder.Entity( @@ -1069,261 +1065,273 @@ public class AspNetIdentity30ModelSnapshot : ModelSnapshot protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "3.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + modelBuilder + .HasAnnotation("ProductVersion", "3.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); - b.Property("Name") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); + b.Property("Name") + .HasColumnType("nvarchar(256)") + .HasMaxLength(256); - b.Property("NormalizedName") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); + b.Property("NormalizedName") + .HasColumnType("nvarchar(256)") + .HasMaxLength(256); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("NormalizedName") - .IsUnique() - .HasName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); + b.HasIndex("NormalizedName") + .IsUnique() + .HasName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); - b.ToTable("AspNetRoles"); - }); + b.ToTable("AspNetRoles"); + }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); - b.Property("RoleId") - .IsRequired() - .HasColumnType("nvarchar(450)"); + b.Property("RoleId") + .IsRequired() + .HasColumnType("nvarchar(450)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("RoleId"); + b.HasIndex("RoleId"); - b.ToTable("AspNetRoleClaims"); - }); + b.ToTable("AspNetRoleClaims"); + }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); - b.Property("AccessFailedCount") - .HasColumnType("int"); + b.Property("AccessFailedCount") + .HasColumnType("int"); - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); - b.Property("Email") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); + b.Property("Email") + .HasColumnType("nvarchar(256)") + .HasMaxLength(256); - b.Property("EmailConfirmed") - .HasColumnType("bit"); + b.Property("EmailConfirmed") + .HasColumnType("bit"); - b.Property("LockoutEnabled") - .HasColumnType("bit"); + b.Property("LockoutEnabled") + .HasColumnType("bit"); - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); - b.Property("NormalizedEmail") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); + b.Property("NormalizedEmail") + .HasColumnType("nvarchar(256)") + .HasMaxLength(256); - b.Property("NormalizedUserName") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); + b.Property("NormalizedUserName") + .HasColumnType("nvarchar(256)") + .HasMaxLength(256); - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); - b.Property("UserName") - .HasColumnType("nvarchar(256)") - .HasMaxLength(256); + b.Property("UserName") + .HasColumnType("nvarchar(256)") + .HasMaxLength(256); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("NormalizedEmail") - .HasName("EmailIndex"); + b.HasIndex("NormalizedEmail") + .HasName("EmailIndex"); - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); - b.ToTable("AspNetUsers"); - }); + b.ToTable("AspNetUsers"); + }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("UserId"); + b.HasIndex("UserId"); - b.ToTable("AspNetUserClaims"); - }); + b.ToTable("AspNetUserClaims"); + }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(128)") - .HasMaxLength(128); + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(128)") + .HasMaxLength(128); - b.Property("ProviderKey") - .HasColumnType("nvarchar(128)") - .HasMaxLength(128); + b.Property("ProviderKey") + .HasColumnType("nvarchar(128)") + .HasMaxLength(128); - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); - b.HasKey("LoginProvider", "ProviderKey"); + b.HasKey("LoginProvider", "ProviderKey"); - b.HasIndex("UserId"); + b.HasIndex("UserId"); - b.ToTable("AspNetUserLogins"); - }); + b.ToTable("AspNetUserLogins"); + }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); - b.HasKey("UserId", "RoleId"); + b.HasKey("UserId", "RoleId"); - b.HasIndex("RoleId"); + b.HasIndex("RoleId"); - b.ToTable("AspNetUserRoles"); - }); + b.ToTable("AspNetUserRoles"); + }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); - b.Property("LoginProvider") - .HasColumnType("nvarchar(128)") - .HasMaxLength(128); + b.Property("LoginProvider") + .HasColumnType("nvarchar(128)") + .HasMaxLength(128); - b.Property("Name") - .HasColumnType("nvarchar(128)") - .HasMaxLength(128); + b.Property("Name") + .HasColumnType("nvarchar(128)") + .HasMaxLength(128); - b.Property("Value") - .HasColumnType("nvarchar(max)"); + b.Property("Value") + .HasColumnType("nvarchar(max)"); - b.HasKey("UserId", "LoginProvider", "Name"); + b.HasKey("UserId", "LoginProvider", "Name"); - b.ToTable("AspNetUserTokens"); - }); + b.ToTable("AspNetUserTokens"); + }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); #pragma warning restore 612, 618 } } @@ -1360,10 +1368,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity().HasData( - new Blog - { - Id = 1, Name = "HalfADonkey" - }); + new Blog { Id = 1, Name = "HalfADonkey" }); } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/OptimisticConcurrencySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/OptimisticConcurrencySqlServerTest.cs index f3cfee98734..6555919ddaf 100644 --- a/test/EFCore.SqlServer.FunctionalTests/OptimisticConcurrencySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/OptimisticConcurrencySqlServerTest.cs @@ -146,11 +146,7 @@ await c.Database.CreateExecutionStrategy().ExecuteAsync( Assert.Null(sponsorEntry.Property(Sponsor.ClientTokenPropertyName).CurrentValue); sponsorEntry.Property(Sponsor.ClientTokenPropertyName).CurrentValue = 1; - sponsor.Details = new SponsorDetails - { - Days = 11, - Space = 51m - }; + sponsor.Details = new SponsorDetails { Days = 11, Space = 51m }; context.ChangeTracker.DetectChanges(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/CompiledQueryCacheKeyGeneratorTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/CompiledQueryCacheKeyGeneratorTest.cs index 46a40c640e8..b0aec28991f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/CompiledQueryCacheKeyGeneratorTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/CompiledQueryCacheKeyGeneratorTest.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable InconsistentNaming diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/CompiledQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/CompiledQuerySqlServerTest.cs index 1ed5a655697..810b87ac675 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/CompiledQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/CompiledQuerySqlServerTest.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Runtime.CompilerServices; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs index 99e1c1f1fda..887d7a9ea7f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs @@ -2396,9 +2396,13 @@ FROM [LevelFour] AS [l4] ) AS [t] ON [l1.OneToOne_Required_FK1.OneToOne_Optional_FK2.OneToMany_Required3].[Id] = [t].[Id]"); } - public override async Task SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_followed_by_Select_required_navigation_using_same_navs(bool isAsync) + public override async Task + SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_followed_by_Select_required_navigation_using_same_navs( + bool isAsync) { - await base.SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_followed_by_Select_required_navigation_using_same_navs(isAsync); + await base + .SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_followed_by_Select_required_navigation_using_same_navs( + isAsync); AssertSql( @"SELECT [OneToOne_Required_FK_Inverse3.OneToMany_Required2.OneToOne_Required_FK_Inverse3.OneToOne_Required_PK_Inverse2].[Id], [OneToOne_Required_FK_Inverse3.OneToMany_Required2.OneToOne_Required_FK_Inverse3.OneToOne_Required_PK_Inverse2].[Date], [OneToOne_Required_FK_Inverse3.OneToMany_Required2.OneToOne_Required_FK_Inverse3.OneToOne_Required_PK_Inverse2].[Name], [OneToOne_Required_FK_Inverse3.OneToMany_Required2.OneToOne_Required_FK_Inverse3.OneToOne_Required_PK_Inverse2].[OneToMany_Optional_Self_Inverse1Id], [OneToOne_Required_FK_Inverse3.OneToMany_Required2.OneToOne_Required_FK_Inverse3.OneToOne_Required_PK_Inverse2].[OneToMany_Required_Self_Inverse1Id], [OneToOne_Required_FK_Inverse3.OneToMany_Required2.OneToOne_Required_FK_Inverse3.OneToOne_Required_PK_Inverse2].[OneToOne_Optional_Self1Id] @@ -2410,9 +2414,13 @@ FROM [LevelFour] AS [l4] LEFT JOIN [LevelOne] AS [OneToOne_Required_FK_Inverse3.OneToMany_Required2.OneToOne_Required_FK_Inverse3.OneToOne_Required_PK_Inverse2] ON [l4.OneToOne_Required_FK_Inverse4.OneToOne_Required_FK_Inverse3.OneToMany_Required2.OneToOne_Required_FK_Inverse3].[Id] = [OneToOne_Required_FK_Inverse3.OneToMany_Required2.OneToOne_Required_FK_Inverse3.OneToOne_Required_PK_Inverse2].[Id]"); } - public override async Task SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_followed_by_Select_required_navigation_using_different_navs(bool isAsync) + public override async Task + SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_followed_by_Select_required_navigation_using_different_navs( + bool isAsync) { - await base.SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_followed_by_Select_required_navigation_using_different_navs(isAsync); + await base + .SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_followed_by_Select_required_navigation_using_different_navs( + isAsync); AssertSql( @"SELECT [l1.OneToOne_Optional_FK1.OneToMany_Optional2.OneToOne_Required_FK_Inverse3.OneToOne_Required_PK_Inverse2].[Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2.OneToOne_Required_FK_Inverse3.OneToOne_Required_PK_Inverse2].[Date], [l1.OneToOne_Optional_FK1.OneToMany_Optional2.OneToOne_Required_FK_Inverse3.OneToOne_Required_PK_Inverse2].[Name], [l1.OneToOne_Optional_FK1.OneToMany_Optional2.OneToOne_Required_FK_Inverse3.OneToOne_Required_PK_Inverse2].[OneToMany_Optional_Self_Inverse1Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2.OneToOne_Required_FK_Inverse3.OneToOne_Required_PK_Inverse2].[OneToMany_Required_Self_Inverse1Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2.OneToOne_Required_FK_Inverse3.OneToOne_Required_PK_Inverse2].[OneToOne_Optional_Self1Id] @@ -3749,9 +3757,13 @@ WHERE [i1].[Discriminator] IN (N'InheritanceDerived2', N'InheritanceDerived1', N ORDER BY [t0].[Id]"); } - public override async Task String_include_multiple_derived_collection_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains(bool isAsync) + public override async Task + String_include_multiple_derived_collection_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains( + bool isAsync) { - await base.String_include_multiple_derived_collection_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains(isAsync); + await base + .String_include_multiple_derived_collection_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains( + isAsync); AssertSql( @"SELECT [i].[Id], [i].[Discriminator], [i].[InheritanceBase2Id], [i].[InheritanceBase2Id1], [i].[Name] @@ -4504,7 +4516,6 @@ public override void IncludeCollection6_2() @""); } - public override void IncludeCollection6_3() { base.IncludeCollection6_3(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerTest.cs index 895c96e5e0e..e4ea1ff1642 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerTest.cs @@ -21,7 +21,7 @@ public override async Task Simple_level1_include(bool isAsync) await base.Simple_level1_include(isAsync); AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [t].[Id], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id] + @"SELECT [l].[Id], [l].[Date], [l].[Name], [t].[Id], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id] FROM [Level1] AS [l] LEFT JOIN ( SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l1].[Id] AS [Id0] @@ -257,7 +257,6 @@ WHERE [l].[OneToMany_Required_Inverse2Id] IS NOT NULL AND ([l].[Level1_Required_ ) AS [t] ON [t1].[Id] = [t].[Id]"); } - public override async Task SelectMany_with_Include1(bool isAsync) { await base.SelectMany_with_Include1(isAsync); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/DbFunctionsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/DbFunctionsSqlServerTest.cs index d056cfc996f..6cbcf52db1f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/DbFunctionsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/DbFunctionsSqlServerTest.cs @@ -597,7 +597,6 @@ public virtual void IsDate_valid() @"SELECT TOP(1) CAST(ISDATE(CONVERT(VARCHAR(100), [o].[OrderDate])) AS bit) FROM [Orders] AS [o] WHERE CAST(ISDATE(CONVERT(VARCHAR(100), [o].[OrderDate])) AS bit) = CAST(1 AS bit)"); - } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs index 9fc606567fe..58448032930 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs @@ -381,14 +381,14 @@ public override void FromSqlRaw_queryable_simple_projection_composed() base.FromSqlRaw_queryable_simple_projection_composed(); // issue #16079 -// AssertSql( -// @"SELECT [p].[ProductName] -//FROM ( -// SELECT * -// FROM ""Products"" -// WHERE ""Discontinued"" <> CAST(1 AS bit) -// AND ((""UnitsInStock"" + ""UnitsOnOrder"") < ""ReorderLevel"") -//) AS [p]"); + // AssertSql( + // @"SELECT [p].[ProductName] + //FROM ( + // SELECT * + // FROM ""Products"" + // WHERE ""Discontinued"" <> CAST(1 AS bit) + // AND ((""UnitsInStock"" + ""UnitsOnOrder"") < ""ReorderLevel"") + //) AS [p]"); } public override void FromSqlRaw_queryable_simple_include() @@ -538,7 +538,7 @@ public override void FromSqlInterpolated_with_inlined_db_parameter_without_name_ base.FromSqlInterpolated_with_inlined_db_parameter_without_name_prefix(); AssertSql( - @"somename='ALFKI' (Nullable = false) (Size = 5) + @"somename='ALFKI' (Nullable = false) (Size = 5) SELECT * FROM ""Customers"" WHERE ""CustomerID"" = @somename"); } @@ -586,10 +586,7 @@ public virtual void FromSqlRaw_in_subquery_with_positional_dbParameter_without_n .FromSqlRaw( @"SELECT * FROM ""Customers"" WHERE ""City"" = {0}", // ReSharper disable once FormatStringProblem - new SqlParameter - { - Value = "London" - }) + new SqlParameter { Value = "London" }) .Select(c => c.CustomerID) .Contains(o.CustomerID)) .ToArray(); @@ -750,11 +747,7 @@ public override void FromSqlRaw_does_not_parameterize_interpolated_string() } protected override DbParameter CreateDbParameter(string name, object value) - => new SqlParameter - { - ParameterName = name, - Value = value - }; + => new SqlParameter { ParameterName = name, Value = value }; private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs index 5b7b0f0aa58..8741d742d0f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.TestModels.FunkyDataModel; using Microsoft.EntityFrameworkCore.TestUtilities; -using Xunit; using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index e2c242e7a5a..b7206f7e951 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Xunit; using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query @@ -109,7 +108,6 @@ WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND ([g].[Nickname] = N'Marcu ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id]"); } - public override async Task Include_navigation_on_derived_type(bool isAsync) { await base.Include_navigation_on_derived_type(isAsync); @@ -2550,8 +2548,6 @@ public override async Task Join_predicate_value_equals_condition(bool isAsync) FROM [Gears] AS [g] INNER JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL WHERE [g].[Discriminator] IN (N'Gear', N'Officer')"); - - } public override async Task Join_predicate_value(bool isAsync) @@ -4409,7 +4405,8 @@ WHERE [g2].[Discriminator] IN (N'Gear', N'Officer') AND ((([g].[Nickname] = [g2] ORDER BY [g].[HasSoulPatch] DESC, [t1].[Note], [g].[Nickname], [g].[SquadId], [t0].[IsAutomatic], [t0].[Nickname] DESC, [t0].[Id]"); } - public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings(bool isAsync) + public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings( + bool isAsync) { await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings(isAsync); @@ -4438,7 +4435,8 @@ WHERE [g2].[Discriminator] IN (N'Gear', N'Officer') AND ((([g].[Nickname] = [g2] ORDER BY [g].[HasSoulPatch] DESC, [t1].[Note], [g].[Nickname], [g].[SquadId], [t0].[IsAutomatic], [t0].[Nickname] DESC, [t0].[Id]"); } - public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings(bool isAsync) + public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings( + bool isAsync) { await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings(isAsync); @@ -6580,7 +6578,8 @@ FROM [Weapons] AS [w] ORDER BY [w].[Id]) IS NOT NULL)"); } - public override async Task Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let(bool isAsync) + public override async Task Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let( + bool isAsync) { await base.Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let(isAsync); @@ -6606,7 +6605,8 @@ public override async Task public override async Task Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool isAsync) { - await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(isAsync); + await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex( + isAsync); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[Note] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeOneToOneSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/IncludeOneToOneSqlServerTest.cs index fe8f89ceb6d..4043a35fc79 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeOneToOneSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/IncludeOneToOneSqlServerTest.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Linq; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit.Abstractions; diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeSqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/IncludeSqlServerFixture.cs index 5a3c22b5808..09f07d53391 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeSqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/IncludeSqlServerFixture.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestUtilities; namespace Microsoft.EntityFrameworkCore.Query diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/IncludeSqlServerTest.cs index 2efb50cf796..7a8835e71a7 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/IncludeSqlServerTest.cs @@ -43,7 +43,6 @@ FROM [Orders] AS [o] LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID]"); } - public override void Include_when_result_operator(bool useString) { base.Include_when_result_operator(useString); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/MappingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/MappingQuerySqlServerTest.cs index ba1ddcd20e8..eb9e10e4d6b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/MappingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/MappingQuerySqlServerTest.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.EntityFrameworkCore.TestUtilities; -using Xunit; namespace Microsoft.EntityFrameworkCore.Query { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NavigationTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NavigationTest.cs index 44c8afc3b85..6214b1b6d18 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NavigationTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NavigationTest.cs @@ -105,9 +105,7 @@ public NavigationTestFixture() var connStrBuilder = new SqlConnectionStringBuilder(TestEnvironment.DefaultConnection) { - InitialCatalog = "StateManagerBug", - MultipleActiveResultSets = true, - ["Trusted_Connection"] = true + InitialCatalog = "StateManagerBug", MultipleActiveResultSets = true, ["Trusted_Connection"] = true }; _options = new DbContextOptionsBuilder() diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs index feb6f444f53..9c2bdcfbbf6 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs @@ -824,7 +824,7 @@ public override void Navigation_rewrite_on_owned_reference_followed_by_regular_e base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity(); AssertSql( - @"SELECT [p].[Id], [p].[StarId] + @"SELECT [p].[Id], [p].[StarId] FROM [OwnedPerson] AS [o] LEFT JOIN ( SELECT [o0].[Id], [t].[Id] AS [Id0] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs index 8e94b18111a..bf0231ed94f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs @@ -68,7 +68,8 @@ public async Task Where_equals_DateTime_Now(bool async) Assert.Equal(0, results.Count); - AssertSql(@"SELECT [d].[Id], [d].[DateTime], [d].[DateTime2], [d].[DateTime2_0], [d].[DateTime2_1], [d].[DateTime2_2], [d].[DateTime2_3], [d].[DateTime2_4], [d].[DateTime2_5], [d].[DateTime2_6], [d].[DateTime2_7], [d].[SmallDateTime] + AssertSql( + @"SELECT [d].[Id], [d].[DateTime], [d].[DateTime2], [d].[DateTime2_0], [d].[DateTime2_1], [d].[DateTime2_2], [d].[DateTime2_3], [d].[DateTime2_4], [d].[DateTime2_5], [d].[DateTime2_6], [d].[DateTime2_7], [d].[SmallDateTime] FROM [Dates] AS [d] WHERE ((([d].[DateTime2_2] = GETDATE()) OR ([d].[DateTime2_7] = GETDATE())) OR ([d].[DateTime] = GETDATE())) OR ([d].[SmallDateTime] = GETDATE())"); } @@ -98,7 +99,8 @@ public async Task Where_not_equals_DateTime_Now(bool async) Assert.Equal(1, results.Count); - AssertSql(@"SELECT [d].[Id], [d].[DateTime], [d].[DateTime2], [d].[DateTime2_0], [d].[DateTime2_1], [d].[DateTime2_2], [d].[DateTime2_3], [d].[DateTime2_4], [d].[DateTime2_5], [d].[DateTime2_6], [d].[DateTime2_7], [d].[SmallDateTime] + AssertSql( + @"SELECT [d].[Id], [d].[DateTime], [d].[DateTime2], [d].[DateTime2_0], [d].[DateTime2_1], [d].[DateTime2_2], [d].[DateTime2_3], [d].[DateTime2_4], [d].[DateTime2_5], [d].[DateTime2_6], [d].[DateTime2_7], [d].[SmallDateTime] FROM [Dates] AS [d] WHERE ((([d].[DateTime2_2] <> GETDATE()) AND ([d].[DateTime2_7] <> GETDATE())) AND ([d].[DateTime] <> GETDATE())) AND ([d].[SmallDateTime] <> GETDATE())"); } @@ -135,7 +137,8 @@ public async Task Where_equals_new_DateTime(bool async) Assert.Equal(1, results.Count); - AssertSql(@"SELECT [d].[Id], [d].[DateTime], [d].[DateTime2], [d].[DateTime2_0], [d].[DateTime2_1], [d].[DateTime2_2], [d].[DateTime2_3], [d].[DateTime2_4], [d].[DateTime2_5], [d].[DateTime2_6], [d].[DateTime2_7], [d].[SmallDateTime] + AssertSql( + @"SELECT [d].[Id], [d].[DateTime], [d].[DateTime2], [d].[DateTime2_0], [d].[DateTime2_1], [d].[DateTime2_2], [d].[DateTime2_3], [d].[DateTime2_4], [d].[DateTime2_5], [d].[DateTime2_6], [d].[DateTime2_7], [d].[SmallDateTime] FROM [Dates] AS [d] WHERE (((((((((([d].[SmallDateTime] = '1970-09-03T12:00:00') AND ([d].[DateTime] = '1971-09-03T12:00:10.220')) AND ([d].[DateTime2] = '1972-09-03T12:00:10.3330000')) AND ([d].[DateTime2_0] = '1973-09-03T12:00:10')) AND ([d].[DateTime2_1] = '1974-09-03T12:00:10.5')) AND ([d].[DateTime2_2] = '1975-09-03T12:00:10.66')) AND ([d].[DateTime2_3] = '1976-09-03T12:00:10.777')) AND ([d].[DateTime2_4] = '1977-09-03T12:00:10.8880')) AND ([d].[DateTime2_5] = '1978-09-03T12:00:10.99900')) AND ([d].[DateTime2_6] = '1979-09-03T12:00:10.111000')) AND ([d].[DateTime2_7] = '1980-09-03T12:00:10.2220000')"); } @@ -187,7 +190,8 @@ public async Task Where_contains_DateTime_literals(bool async) Assert.Equal(1, results.Count); - AssertSql(@"SELECT [d].[Id], [d].[DateTime], [d].[DateTime2], [d].[DateTime2_0], [d].[DateTime2_1], [d].[DateTime2_2], [d].[DateTime2_3], [d].[DateTime2_4], [d].[DateTime2_5], [d].[DateTime2_6], [d].[DateTime2_7], [d].[SmallDateTime] + AssertSql( + @"SELECT [d].[Id], [d].[DateTime], [d].[DateTime2], [d].[DateTime2_0], [d].[DateTime2_1], [d].[DateTime2_2], [d].[DateTime2_3], [d].[DateTime2_4], [d].[DateTime2_5], [d].[DateTime2_6], [d].[DateTime2_7], [d].[SmallDateTime] FROM [Dates] AS [d] WHERE ((((((((([d].[SmallDateTime] IN ('1970-09-03T12:00:00', '1971-09-03T12:00:10', '1972-09-03T12:00:10', '1973-09-03T12:00:10', '1974-09-03T12:00:10', '1975-09-03T12:00:10', '1976-09-03T12:00:10', '1977-09-03T12:00:10', '1978-09-03T12:00:10', '1979-09-03T12:00:10', '1980-09-03T12:00:10') AND [d].[DateTime] IN ('1970-09-03T12:00:00.000', '1971-09-03T12:00:10.220', '1972-09-03T12:00:10.333', '1973-09-03T12:00:10.000', '1974-09-03T12:00:10.500', '1975-09-03T12:00:10.660', '1976-09-03T12:00:10.777', '1977-09-03T12:00:10.888', '1978-09-03T12:00:10.999', '1979-09-03T12:00:10.111', '1980-09-03T12:00:10.222')) AND [d].[DateTime2] IN ('1970-09-03T12:00:00.0000000', '1971-09-03T12:00:10.2200000', '1972-09-03T12:00:10.3330000', '1973-09-03T12:00:10.0000000', '1974-09-03T12:00:10.5000000', '1975-09-03T12:00:10.6600000', '1976-09-03T12:00:10.7770000', '1977-09-03T12:00:10.8880000', '1978-09-03T12:00:10.9990000', '1979-09-03T12:00:10.1110000', '1980-09-03T12:00:10.2220000')) AND [d].[DateTime2_0] IN ('1970-09-03T12:00:00', '1971-09-03T12:00:10', '1972-09-03T12:00:10', '1973-09-03T12:00:10', '1974-09-03T12:00:10', '1975-09-03T12:00:10', '1976-09-03T12:00:10', '1977-09-03T12:00:10', '1978-09-03T12:00:10', '1979-09-03T12:00:10', '1980-09-03T12:00:10')) AND [d].[DateTime2_1] IN ('1970-09-03T12:00:00.0', '1971-09-03T12:00:10.2', '1972-09-03T12:00:10.3', '1973-09-03T12:00:10.0', '1974-09-03T12:00:10.5', '1975-09-03T12:00:10.6', '1976-09-03T12:00:10.7', '1977-09-03T12:00:10.8', '1978-09-03T12:00:10.9', '1979-09-03T12:00:10.1', '1980-09-03T12:00:10.2')) AND [d].[DateTime2_2] IN ('1970-09-03T12:00:00.00', '1971-09-03T12:00:10.22', '1972-09-03T12:00:10.33', '1973-09-03T12:00:10.00', '1974-09-03T12:00:10.50', '1975-09-03T12:00:10.66', '1976-09-03T12:00:10.77', '1977-09-03T12:00:10.88', '1978-09-03T12:00:10.99', '1979-09-03T12:00:10.11', '1980-09-03T12:00:10.22')) AND [d].[DateTime2_3] IN ('1970-09-03T12:00:00.000', '1971-09-03T12:00:10.220', '1972-09-03T12:00:10.333', '1973-09-03T12:00:10.000', '1974-09-03T12:00:10.500', '1975-09-03T12:00:10.660', '1976-09-03T12:00:10.777', '1977-09-03T12:00:10.888', '1978-09-03T12:00:10.999', '1979-09-03T12:00:10.111', '1980-09-03T12:00:10.222')) AND [d].[DateTime2_4] IN ('1970-09-03T12:00:00.0000', '1971-09-03T12:00:10.2200', '1972-09-03T12:00:10.3330', '1973-09-03T12:00:10.0000', '1974-09-03T12:00:10.5000', '1975-09-03T12:00:10.6600', '1976-09-03T12:00:10.7770', '1977-09-03T12:00:10.8880', '1978-09-03T12:00:10.9990', '1979-09-03T12:00:10.1110', '1980-09-03T12:00:10.2220')) AND [d].[DateTime2_5] IN ('1970-09-03T12:00:00.00000', '1971-09-03T12:00:10.22000', '1972-09-03T12:00:10.33300', '1973-09-03T12:00:10.00000', '1974-09-03T12:00:10.50000', '1975-09-03T12:00:10.66000', '1976-09-03T12:00:10.77700', '1977-09-03T12:00:10.88800', '1978-09-03T12:00:10.99900', '1979-09-03T12:00:10.11100', '1980-09-03T12:00:10.22200')) AND [d].[DateTime2_6] IN ('1970-09-03T12:00:00.000000', '1971-09-03T12:00:10.220000', '1972-09-03T12:00:10.333000', '1973-09-03T12:00:10.000000', '1974-09-03T12:00:10.500000', '1975-09-03T12:00:10.660000', '1976-09-03T12:00:10.777000', '1977-09-03T12:00:10.888000', '1978-09-03T12:00:10.999000', '1979-09-03T12:00:10.111000', '1980-09-03T12:00:10.222000')) AND [d].[DateTime2_7] IN ('1970-09-03T12:00:00.0000000', '1971-09-03T12:00:10.2200000', '1972-09-03T12:00:10.3330000', '1973-09-03T12:00:10.0000000', '1974-09-03T12:00:10.5000000', '1975-09-03T12:00:10.6600000', '1976-09-03T12:00:10.7770000', '1977-09-03T12:00:10.8880000', '1978-09-03T12:00:10.9990000', '1979-09-03T12:00:10.1110000', '1980-09-03T12:00:10.2220000')"); } @@ -260,7 +264,7 @@ private SqlServerTestStore CreateDateTimeStore() DateTime2_4 = new DateTime(1977, 9, 3, 12, 0, 10, 888), DateTime2_5 = new DateTime(1978, 9, 3, 12, 0, 10, 999), DateTime2_6 = new DateTime(1979, 9, 3, 12, 0, 10, 111), - DateTime2_7 = new DateTime(1980, 9, 3, 12, 0, 10, 222), + DateTime2_7 = new DateTime(1980, 9, 3, 12, 0, 10, 222) }); c.SaveChanges(); @@ -410,14 +414,8 @@ public void EnsureSeeded() if (!Persons.Any()) { AddRange( - new Person - { - Name = "John Doe" - }, - new Person - { - Name = "Joe Bloggs" - }); + new Person { Name = "John Doe" }, + new Person { Name = "Joe Bloggs" }); SaveChanges(); } @@ -507,10 +505,7 @@ public async Task First_FirstOrDefault_ix_async_bug_603() using (var context = new MyContext603(_options)) { context.Products.Add( - new Product - { - Name = "Product 1" - }); + new Product { Name = "Product 1" }); context.SaveChanges(); } @@ -529,10 +524,7 @@ public async Task First_FirstOrDefault_ix_async_bug_603() using (var context = new MyContext603(_options)) { context.Products.Add( - new Product - { - Name = "Product 1" - }); + new Product { Name = "Product 1" }); context.SaveChanges(); } @@ -632,47 +624,19 @@ private SqlServerTestStore CreateDatabase925() () => new MyContext925(_options), context => { - var order11 = new Order - { - Name = "Order11" - }; - var order12 = new Order - { - Name = "Order12" - }; - var order21 = new Order - { - Name = "Order21" - }; - var order22 = new Order - { - Name = "Order22" - }; - var order23 = new Order - { - Name = "Order23" - }; + var order11 = new Order { Name = "Order11" }; + var order12 = new Order { Name = "Order12" }; + var order21 = new Order { Name = "Order21" }; + var order22 = new Order { Name = "Order22" }; + var order23 = new Order { Name = "Order23" }; var customer1 = new Customer { - FirstName = "Customer", - LastName = "One", - Orders = new List - { - order11, - order12 - } + FirstName = "Customer", LastName = "One", Orders = new List { order11, order12 } }; var customer2 = new Customer { - FirstName = "Customer", - LastName = "Two", - Orders = new List - { - order21, - order22, - order23 - } + FirstName = "Customer", LastName = "Two", Orders = new List { order21, order22, order23 } }; context.Customers.AddRange(customer1, customer2); @@ -714,11 +678,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { m.ToTable("Customer"); m.HasKey( - c => new - { - c.FirstName, - c.LastName - }); + c => new { c.FirstName, c.LastName }); m.HasMany(c => c.Orders).WithOne(o => o.Customer); }); @@ -744,10 +704,7 @@ public void GroupJoin_expansion_when_optional_nav_in_projection() { Permissions = from u in p.ProjectUsers - select new PermissionView - { - UserName = u.User.Name - } + select new PermissionView { UserName = u.User.Name } }; var target = context.ProjectUsers.OrderBy(u => u.Id).First(); @@ -820,49 +777,19 @@ private SqlServerTestStore CreateDatabase7293() { var projects = new[] { - new Project - { - Name = "Projects 1" - }, - new Project - { - Name = "Projects 2" - }, - new Project - { - Name = "Projects 3" - } + new Project { Name = "Projects 1" }, new Project { Name = "Projects 2" }, new Project { Name = "Projects 3" } }; context.Projects.AddRange(projects); - var users = new[] - { - new User - { - Name = "Users 1" - }, - new User - { - Name = "Users 2" - }, - new User - { - Name = "Users 3" - } - }; + var users = new[] { new User { Name = "Users 1" }, new User { Name = "Users 2" }, new User { Name = "Users 3" } }; context.Users.AddRange(users); var permissions = (from project in projects from user in users - select new ProjectUser - { - ProjectId = project.Id, - Project = project, - UserId = user.Id, - User = user - }).ToList(); + select new ProjectUser { ProjectId = project.Id, Project = project, UserId = user.Id, User = user }) + .ToList(); context.ProjectUsers.AddRange(permissions); context.SaveChanges(); @@ -941,27 +868,12 @@ private SqlServerTestStore CreateDatabase963() () => new MyContext963(_options), context => { - var drogon = new Dragon - { - Name = "Drogon" - }; - var rhaegal = new Dragon - { - Name = "Rhaegal" - }; - var viserion = new Dragon - { - Name = "Viserion" - }; - var balerion = new Dragon - { - Name = "Balerion" - }; + var drogon = new Dragon { Name = "Drogon" }; + var rhaegal = new Dragon { Name = "Rhaegal" }; + var viserion = new Dragon { Name = "Viserion" }; + var balerion = new Dragon { Name = "Balerion" }; - var aerys = new Targaryen - { - Name = "Aerys II" - }; + var aerys = new Targaryen { Name = "Aerys II" }; var details = new Details { FullName = @"Daenerys Stormborn of the House Targaryen, the First of Her Name, the Unburnt, Queen of Meereen, @@ -970,14 +882,7 @@ private SqlServerTestStore CreateDatabase963() var daenerys = new Targaryen { - Name = "Daenerys", - Details = details, - Dragons = new List - { - drogon, - rhaegal, - viserion - } + Name = "Daenerys", Details = details, Dragons = new List { drogon, rhaegal, viserion } }; context.Targaryens.AddRange(daenerys, aerys); context.Dragons.AddRange(drogon, rhaegal, viserion, balerion); @@ -1050,11 +955,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) public void Compiler_generated_local_closure_produces_valid_parameter_name_1742() { Execute1742( - new CustomerDetails_1742 - { - FirstName = "Foo", - LastName = "Bar" - }); + new CustomerDetails_1742 { FirstName = "Foo", LastName = "Bar" }); } public void Execute1742(CustomerDetails_1742 details) @@ -1196,72 +1097,26 @@ private SqlServerTestStore CreateDatabase3758() () => new MyContext3758(_options), context => { - var o111 = new Order3758 - { - Name = "O111" - }; - var o112 = new Order3758 - { - Name = "O112" - }; - var o121 = new Order3758 - { - Name = "O121" - }; - var o122 = new Order3758 - { - Name = "O122" - }; - var o131 = new Order3758 - { - Name = "O131" - }; - var o132 = new Order3758 - { - Name = "O132" - }; - var o141 = new Order3758 - { - Name = "O141" - }; - - var o211 = new Order3758 - { - Name = "O211" - }; - var o212 = new Order3758 - { - Name = "O212" - }; - var o221 = new Order3758 - { - Name = "O221" - }; - var o222 = new Order3758 - { - Name = "O222" - }; - var o231 = new Order3758 - { - Name = "O231" - }; - var o232 = new Order3758 - { - Name = "O232" - }; - var o241 = new Order3758 - { - Name = "O241" - }; + var o111 = new Order3758 { Name = "O111" }; + var o112 = new Order3758 { Name = "O112" }; + var o121 = new Order3758 { Name = "O121" }; + var o122 = new Order3758 { Name = "O122" }; + var o131 = new Order3758 { Name = "O131" }; + var o132 = new Order3758 { Name = "O132" }; + var o141 = new Order3758 { Name = "O141" }; + + var o211 = new Order3758 { Name = "O211" }; + var o212 = new Order3758 { Name = "O212" }; + var o221 = new Order3758 { Name = "O221" }; + var o222 = new Order3758 { Name = "O222" }; + var o231 = new Order3758 { Name = "O231" }; + var o232 = new Order3758 { Name = "O232" }; + var o241 = new Order3758 { Name = "O241" }; var c1 = new Customer3758 { Name = "C1", - Orders1 = new List - { - o111, - o112 - }, + Orders1 = new List { o111, o112 }, Orders2 = new MyGenericCollection3758(), Orders3 = new MyNonGenericCollection3758(), Orders4 = new MyInvalidCollection3758(42) @@ -1274,11 +1129,7 @@ private SqlServerTestStore CreateDatabase3758() var c2 = new Customer3758 { Name = "C2", - Orders1 = new List - { - o211, - o212 - }, + Orders1 = new List { o211, o212 }, Orders2 = new MyGenericCollection3758(), Orders3 = new MyNonGenericCollection3758(), Orders4 = new MyInvalidCollection3758(42) @@ -1324,11 +1175,7 @@ public void ThenInclude_with_interface_navigations_3409() { var results = context.Children .Select( - c => new - { - c.SelfReferenceBackNavigation, - c.SelfReferenceBackNavigation.ParentBackNavigation - }) + c => new { c.SelfReferenceBackNavigation, c.SelfReferenceBackNavigation.ParentBackNavigation }) .ToList(); Assert.Equal(3, results.Count); @@ -1442,15 +1289,8 @@ private SqlServerTestStore CreateDatabase3409() var child2 = new Child3409(); var child3 = new Child3409(); - parent1.ChildCollection = new List - { - child1 - }; - child1.SelfReferenceCollection = new List - { - child2, - child3 - }; + parent1.ChildCollection = new List { child1 }; + child1.SelfReferenceCollection = new List { child2, child3 }; context.Parents.AddRange(parent1); context.Children.AddRange(child1, child2, child3); @@ -1535,11 +1375,7 @@ join eRoot in ctx.Entities on eVersion.RootEntityId equals eRoot.Id into RootEntities from eRootJoined in RootEntities.DefaultIfEmpty() - select new - { - One = 1, - Coalesce = eRootJoined ?? eVersion - }; + select new { One = 1, Coalesce = eRootJoined ?? eVersion }; var result = query.ToList(); Assert.True(result.All(e => e.Coalesce.Children.Count > 0)); @@ -1559,11 +1395,7 @@ join eRoot in ctx.Entities.Include(e => e.Children) on eVersion.RootEntityId equals eRoot.Id into RootEntities from eRootJoined in RootEntities.DefaultIfEmpty() - select new - { - Root = eRootJoined, - Coalesce = eRootJoined ?? eVersion - }; + select new { Root = eRootJoined, Coalesce = eRootJoined ?? eVersion }; var result = query.ToList(); Assert.Equal(2, result.Count(e => e.Coalesce.Children.Count > 0)); @@ -1583,12 +1415,8 @@ join eRoot in ctx.Entities.Include(e => e.Children) on eVersion.RootEntityId equals eRoot.Id into RootEntities from eRootJoined in RootEntities.DefaultIfEmpty() - // ReSharper disable once ConstantNullCoalescingCondition - select new - { - One = 1, - Coalesce = eRootJoined ?? (eVersion ?? eRootJoined) - }; + // ReSharper disable once ConstantNullCoalescingCondition + select new { One = 1, Coalesce = eRootJoined ?? (eVersion ?? eRootJoined) }; var result = query.ToList(); Assert.Equal(2, result.Count(e => e.Coalesce.Children.Count > 0)); @@ -1608,13 +1436,8 @@ join eRoot in ctx.Entities on eVersion.RootEntityId equals eRoot.Id into RootEntities from eRootJoined in RootEntities.DefaultIfEmpty() - // ReSharper disable once ConstantNullCoalescingCondition - select new - { - One = eRootJoined, - Two = 2, - Coalesce = eRootJoined ?? (eVersion ?? eRootJoined) - }; + // ReSharper disable once ConstantNullCoalescingCondition + select new { One = eRootJoined, Two = 2, Coalesce = eRootJoined ?? (eVersion ?? eRootJoined) }; var result = query.ToList(); Assert.True(result.All(e => e.Coalesce.Children.Count > 0)); @@ -1634,7 +1457,7 @@ join eRoot in ctx.Entities on eVersion.RootEntityId equals eRoot.Id into RootEntities from eRootJoined in RootEntities.DefaultIfEmpty() - // ReSharper disable once MergeConditionalExpression + // ReSharper disable once MergeConditionalExpression #pragma warning disable IDE0029 // Use coalesce expression select eRootJoined != null ? eRootJoined : eVersion; #pragma warning restore IDE0029 // Use coalesce expression @@ -1657,12 +1480,7 @@ join eRoot in ctx.Entities on eVersion.RootEntityId equals eRoot.Id into RootEntities from eRootJoined in RootEntities.DefaultIfEmpty() - select new - { - eRootJoined, - eVersion, - foo = eRootJoined ?? eVersion - }; + select new { eRootJoined, eVersion, foo = eRootJoined ?? eVersion }; query.ToList(); @@ -1677,52 +1495,19 @@ private SqlServerTestStore CreateDatabase3101() () => new MyContext3101(_options), context => { - var c11 = new Child3101 - { - Name = "c11" - }; - var c12 = new Child3101 - { - Name = "c12" - }; - var c13 = new Child3101 - { - Name = "c13" - }; - var c21 = new Child3101 - { - Name = "c21" - }; - var c22 = new Child3101 - { - Name = "c22" - }; - var c31 = new Child3101 - { - Name = "c31" - }; - var c32 = new Child3101 - { - Name = "c32" - }; + var c11 = new Child3101 { Name = "c11" }; + var c12 = new Child3101 { Name = "c12" }; + var c13 = new Child3101 { Name = "c13" }; + var c21 = new Child3101 { Name = "c21" }; + var c22 = new Child3101 { Name = "c22" }; + var c31 = new Child3101 { Name = "c31" }; + var c32 = new Child3101 { Name = "c32" }; context.Children.AddRange(c11, c12, c13, c21, c22, c31, c32); - var e1 = new Entity3101 - { - Id = 1, - Children = new[] { c11, c12, c13 } - }; - var e2 = new Entity3101 - { - Id = 2, - Children = new[] { c21, c22 } - }; - var e3 = new Entity3101 - { - Id = 3, - Children = new[] { c31, c32 } - }; + var e1 = new Entity3101 { Id = 1, Children = new[] { c11, c12, c13 } }; + var e2 = new Entity3101 { Id = 2, Children = new[] { c21, c22 } }; + var e3 = new Entity3101 { Id = 3, Children = new[] { c31, c32 } }; e2.RootEntity = e1; @@ -1812,11 +1597,7 @@ public virtual void Repro6986_can_project_shadow_property_using_ef_property() using (var context = new ReproContext6986(_options)) { var query = context.Contacts.OfType().Select( - c => new - { - c, - Prop = EF.Property(c, "ServiceOperator6986Id") - }).ToList(); + c => new { c, Prop = EF.Property(c, "ServiceOperator6986Id") }).ToList(); Assert.Equal(1, query.Count); Assert.Equal(1, query[0].Prop); @@ -1832,14 +1613,8 @@ private SqlServerTestStore CreateDatabase6986() { context.ServiceOperators.Add(new ServiceOperator6986()); context.Employers.AddRange( - new Employer6986 - { - Name = "UWE" - }, - new Employer6986 - { - Name = "Hewlett Packard" - }); + new Employer6986 { Name = "UWE" }, + new Employer6986 { Name = "Hewlett Packard" }); context.SaveChanges(); @@ -1859,10 +1634,7 @@ private SqlServerTestStore CreateDatabase6986() UserName = "hp@esoterix.co.uk", Employer6986 = context.Employers.OrderBy(e => e.Id).First(e => e.Name == "Hewlett Packard") }, - new Contact6986 - { - UserName = "noroles@esoterix.co.uk" - }); + new Contact6986 { UserName = "noroles@esoterix.co.uk" }); context.SaveChanges(); }); } @@ -2046,14 +1818,7 @@ private SqlServerTestStore CreateDatabase5456() { Posts = new List { - new Post5456 - { - Comments = new List - { - new Comment5456(), - new Comment5456() - } - }, + new Post5456 { Comments = new List { new Comment5456(), new Comment5456() } }, new Post5456() }, Author = new Author5456() @@ -2165,15 +1930,9 @@ private SqlServerTestStore CreateDatabase7359() context => { context.Add( - new Product - { - Name = "Product1" - }); + new Product { Name = "Product1" }); context.Add( - new SpecialProduct - { - Name = "SpecialProduct" - }); + new SpecialProduct { Name = "SpecialProduct" }); context.SaveChanges(); }); } @@ -2238,15 +1997,8 @@ private SqlServerTestStore CreateDatabase7312() { context.AddRange( new Proposal7312(), - new ProposalCustom7312 - { - Name = "CustomProposal" - }, - new ProposalLeave7312 - { - LeaveStart = DateTime.Now, - LeaveType = new ProposalLeaveType7312() - } + new ProposalCustom7312 { Name = "CustomProposal" }, + new ProposalLeave7312 { LeaveStart = DateTime.Now, LeaveType = new ProposalLeaveType7312() } ); context.SaveChanges(); }); @@ -2445,9 +2197,7 @@ private SqlServerTestStore CreateDatabase8538() context.AddRange( new Entity8538 { - Permission = Permission.NONE, - PermissionByte = PermissionByte.NONE, - PermissionShort = PermissionShort.NONE + Permission = Permission.NONE, PermissionByte = PermissionByte.NONE, PermissionShort = PermissionShort.NONE }, new Entity8538 { @@ -2644,7 +2394,7 @@ public void Include_collection_for_entity_with_owned_type_works() Assert.True(result[0].Cast.All(a => a.Details != null)); AssertSql( - @"SELECT [m].[Id], [m].[Title], [t].[Id], [t].[Details_Info], [t1].[Id], [t1].[Movie9202Id], [t1].[Name], [t1].[Id0], [t1].[Details_Info] + @"SELECT [m].[Id], [m].[Title], [t].[Id], [t].[Details_Info], [t1].[Id], [t1].[Movie9202Id], [t1].[Name], [t1].[Id0], [t1].[Details_Info] FROM [Movies] AS [m] LEFT JOIN ( SELECT [m0].[Id], [m0].[Details_Info], [m1].[Id] AS [Id0] @@ -2683,7 +2433,7 @@ public void Include_collection_for_entity_with_owned_type_works_string() Assert.True(result[0].Cast.All(a => a.Details != null)); AssertSql( - @"SELECT [m].[Id], [m].[Title], [t].[Id], [t].[Details_Info], [t1].[Id], [t1].[Movie9202Id], [t1].[Name], [t1].[Id0], [t1].[Details_Info] + @"SELECT [m].[Id], [m].[Title], [t].[Id], [t].[Details_Info], [t1].[Id], [t1].[Movie9202Id], [t1].[Name], [t1].[Id0], [t1].[Details_Info] FROM [Movies] AS [m] LEFT JOIN ( SELECT [m0].[Id], [m0].[Details_Info], [m1].[Id] AS [Id0] @@ -2712,43 +2462,14 @@ private SqlServerTestStore CreateDatabase9202() () => new MyContext9202(_options), context => { - var av = new Actor9202 - { - Name = "Alicia Vikander", - Details = new Details9202 - { - Info = "Best actor ever made" - } - }; - var oi = new Actor9202 - { - Name = "Oscar Isaac", - Details = new Details9202 - { - Info = "Best actor ever made" - } - }; - var dg = new Actor9202 - { - Name = "Domhnall Gleeson", - Details = new Details9202 - { - Info = "Best actor ever made" - } - }; + var av = new Actor9202 { Name = "Alicia Vikander", Details = new Details9202 { Info = "Best actor ever made" } }; + var oi = new Actor9202 { Name = "Oscar Isaac", Details = new Details9202 { Info = "Best actor ever made" } }; + var dg = new Actor9202 { Name = "Domhnall Gleeson", Details = new Details9202 { Info = "Best actor ever made" } }; var em = new Movie9202 { Title = "Ex Machina", - Cast = new List - { - av, - oi, - dg - }, - Details = new Details9202 - { - Info = "Best movie ever made" - } + Cast = new List { av, oi, dg }, + Details = new Details9202 { Info = "Best movie ever made" } }; context.Actors.AddRange(av, oi, dg); context.Movies.Add(em); @@ -2846,18 +2567,9 @@ private SqlServerTestStore CreateDatabase9214() () => new MyContext9214(_options), context => { - var w1 = new Widget9214 - { - Val = 1 - }; - var w2 = new Widget9214 - { - Val = 2 - }; - var w3 = new Widget9214 - { - Val = 3 - }; + var w1 = new Widget9214 { Val = 1 }; + var w2 = new Widget9214 { Val = 2 }; + var w3 = new Widget9214 { Val = 3 }; context.Widgets.AddRange(w1, w2, w3); context.SaveChanges(); @@ -2935,21 +2647,14 @@ public virtual void From_sql_gets_value_of_out_parameter_in_stored_procedure() { var valueParam = new SqlParameter { - ParameterName = "Value", - Value = 0, - Direction = ParameterDirection.Output, - SqlDbType = SqlDbType.Int + ParameterName = "Value", Value = 0, Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int }; Assert.Equal(0, valueParam.Value); var blogs = context.Blogs.FromSqlRaw( "[dbo].[GetPersonAndVoteCount] @id, @Value out", - new SqlParameter - { - ParameterName = "id", - Value = 1 - }, + new SqlParameter { ParameterName = "id", Value = 1 }, valueParam) .ToList(); @@ -2982,18 +2687,9 @@ FROM dbo.Blogs END"); context.AddRange( - new Blog9277 - { - SomeValue = 1 - }, - new Blog9277 - { - SomeValue = 2 - }, - new Blog9277 - { - SomeValue = 3 - } + new Blog9277 { SomeValue = 1 }, + new Blog9277 { SomeValue = 2 }, + new Blog9277 { SomeValue = 3 } ); context.SaveChanges(); @@ -3134,42 +2830,17 @@ private SqlServerTestStore CreateDatabase9038() { var famalies = new List { - new PersonFamily9038 - { - LastName = "Garrison" - }, - new PersonFamily9038 - { - LastName = "Cartman" - } + new PersonFamily9038 { LastName = "Garrison" }, new PersonFamily9038 { LastName = "Cartman" } }; var teachers = new List { - new PersonTeacher9038 - { - Name = "Ms. Frizzle" - }, - new PersonTeacher9038 - { - Name = "Mr. Garrison", - Family = famalies[0] - } + new PersonTeacher9038 { Name = "Ms. Frizzle" }, + new PersonTeacher9038 { Name = "Mr. Garrison", Family = famalies[0] } }; var students = new List { - new PersonKid9038 - { - Name = "Arnold", - Grade = 2, - Teacher = teachers[0] - }, - new PersonKid9038 - { - Name = "Eric", - Grade = 4, - Teacher = teachers[1], - Family = famalies[1] - } + new PersonKid9038 { Name = "Arnold", Grade = 2, Teacher = teachers[0] }, + new PersonKid9038 { Name = "Eric", Grade = 4, Teacher = teachers[1], Family = famalies[1] } }; context.People.AddRange(teachers); @@ -3277,15 +2948,8 @@ private SqlServerTestStore CreateDatabase9735() context => { context.AddRange( - new Address9735 - { - Name = "An A" - }, - new Customer9735 - { - Name = "A B", - AddressId = 1 - } + new Address9735 { Name = "An A" }, + new Customer9735 { Name = "A B", AddressId = 1 } ); context.SaveChanges(); @@ -3308,18 +2972,9 @@ public virtual void GroupJoin_to_parent_with_no_child_works_9892() from p in context.Parents join c in ( from x in context.Children - select new - { - x.ParentId, - OtherParent = x.OtherParent.Name - }) + select new { x.ParentId, OtherParent = x.OtherParent.Name }) on p.Id equals c.ParentId into child - select new - { - ParentId = p.Id, - ParentName = p.Name, - Children = child.Select(c => c.OtherParent) - }).ToList(); + select new { ParentId = p.Id, ParentName = p.Name, Children = child.Select(c => c.OtherParent) }).ToList(); Assert.Equal(3, results.Count); Assert.Single(results.Where(t => !t.Children.Any())); @@ -3334,58 +2989,27 @@ private SqlServerTestStore CreateDatabase9892() context => { context.Parents.Add( - new Parent9892 - { - Name = "Parent1" - }); + new Parent9892 { Name = "Parent1" }); context.Parents.Add( - new Parent9892 - { - Name = "Parent2" - }); + new Parent9892 { Name = "Parent2" }); context.Parents.Add( - new Parent9892 - { - Name = "Parent3" - }); + new Parent9892 { Name = "Parent3" }); context.OtherParents.Add( - new OtherParent9892 - { - Name = "OtherParent1" - }); + new OtherParent9892 { Name = "OtherParent1" }); context.OtherParents.Add( - new OtherParent9892 - { - Name = "OtherParent2" - }); + new OtherParent9892 { Name = "OtherParent2" }); context.SaveChanges(); context.Children.Add( - new Child9892 - { - ParentId = 1, - OtherParentId = 1 - }); + new Child9892 { ParentId = 1, OtherParentId = 1 }); context.Children.Add( - new Child9892 - { - ParentId = 1, - OtherParentId = 2 - }); + new Child9892 { ParentId = 1, OtherParentId = 2 }); context.Children.Add( - new Child9892 - { - ParentId = 2, - OtherParentId = 1 - }); + new Child9892 { ParentId = 2, OtherParentId = 1 }); context.Children.Add( - new Child9892 - { - ParentId = 2, - OtherParentId = 2 - }); + new Child9892 { ParentId = 2, OtherParentId = 2 }); context.SaveChanges(); @@ -3439,10 +3063,7 @@ public virtual void Conditional_expression_with_conditions_does_not_collapse_if_ using (var context = new MyContext9468(_options)) { var query = context.Carts.Select( - t => new - { - Processing = t.Configuration != null ? !t.Configuration.Processed : (bool?)null - }).ToList(); + t => new { Processing = t.Configuration != null ? !t.Configuration.Processed : (bool?)null }).ToList(); Assert.Single(query.Where(t => t.Processing == null)); Assert.Single(query.Where(t => t.Processing == true)); @@ -3470,17 +3091,8 @@ private SqlServerTestStore CreateDatabase9468() { context.AddRange( new Cart9468(), - new Cart9468 - { - Configuration = new Configuration9468 - { - Processed = true - } - }, - new Cart9468 - { - Configuration = new Configuration9468() - } + new Cart9468 { Configuration = new Configuration9468 { Processed = true } }, + new Cart9468 { Configuration = new Configuration9468() } ); context.SaveChanges(); @@ -3558,33 +3170,13 @@ private SqlServerTestStore CreateDatabase10635() () => new MyContext10635(_options), context => { - var c11 = new Child10635 - { - Name = "Child111" - }; - var c12 = new Child10635 - { - Name = "Child112" - }; - var c13 = new Child10635 - { - Name = "Child113" - }; - var c21 = new Child10635 - { - Name = "Child121" - }; + var c11 = new Child10635 { Name = "Child111" }; + var c12 = new Child10635 { Name = "Child112" }; + var c13 = new Child10635 { Name = "Child113" }; + var c21 = new Child10635 { Name = "Child121" }; - var p1 = new Parent10635 - { - Name = "Parent1", - Children = new[] { c11, c12, c13 } - }; - var p2 = new Parent10635 - { - Name = "Parent2", - Children = new[] { c21 } - }; + var p1 = new Parent10635 { Name = "Parent1", Children = new[] { c11, c12, c13 } }; + var p2 = new Parent10635 { Name = "Parent2", Children = new[] { c21 } }; context.Parents.AddRange(p1, p2); context.Children.AddRange(c11, c12, c13, c21); context.SaveChanges(); @@ -3634,15 +3226,7 @@ public void Row_number_paging_with_owned_type() { context.Database.EnsureClean(); context.Add( - new Note - { - Text = "Foo Bar", - User = new User10168 - { - Fullname = "Full1", - Email = "abc@def.com" - } - }); + new Note { Text = "Foo Bar", User = new User10168 { Fullname = "Full1", Email = "abc@def.com" } }); context.SaveChanges(); ClearLog(); @@ -3660,7 +3244,7 @@ public void Row_number_paging_with_owned_type() Assert.Equal("Full1", result.User.Fullname); AssertSql( - @"@__p_0='?' (DbType = Int32) + @"@__p_0='?' (DbType = Int32) @__p_1='?' (DbType = Int32) SELECT [t0].[Id], [t0].[Text], [t0].[Id0], [t0].[User_Email], [t0].[User_Fullname] @@ -3769,18 +3353,9 @@ private SqlServerTestStore CreateDatabase10301() context => { context.AddRange( - new Blog10301 - { - SomeValue = 1 - }, - new Blog10301 - { - SomeValue = 2 - }, - new Blog10301 - { - SomeValue = 2 - } + new Blog10301 { SomeValue = 1 }, + new Blog10301 { SomeValue = 2 }, + new Blog10301 { SomeValue = 2 } ); context.SaveChanges(); @@ -3851,10 +3426,7 @@ private SqlServerTestStore CreateDatabase11104() context => { context.AddRange( - new Derived1 - { - IsTwo = false - } + new Derived1 { IsTwo = false } ); context.SaveChanges(); @@ -3916,22 +3488,14 @@ public virtual void GroupJoin_Anonymous_projection_GroupBy_Aggregate_join_elimin join a in context.Set() on e.Id equals a.Id into grouping from a in grouping.DefaultIfEmpty() - select new - { - ename = e.Name, - aname = a.Name - }) + select new { ename = e.Name, aname = a.Name }) .GroupBy(g => g.aname) .Select( - g => new - { - g.Key, - cnt = g.Count() + 5 - }) + g => new { g.Key, cnt = g.Count() + 5 }) .ToList(); AssertSql( - @"SELECT [t1].[Name] AS [Key], COUNT(*) + 5 AS [cnt] + @"SELECT [t1].[Name] AS [Key], COUNT(*) + 5 AS [cnt] FROM [Table] AS [t2] LEFT JOIN ( SELECT [t].[Id], [t].[Name], [t0].[Id] AS [Id0] @@ -3958,27 +3522,15 @@ from a in grouping.DefaultIfEmpty() join m in context.Set() on e.Id equals m.Id into grouping2 from m in grouping2.DefaultIfEmpty() - select new - { - aname = a.Name, - mname = m.Name - }) + select new { aname = a.Name, mname = m.Name }) .GroupBy( - g => new - { - g.aname, - g.mname - }) + g => new { g.aname, g.mname }) .Select( - g => new - { - MyKey = g.Key.aname, - cnt = g.Count() + 5 - }) + g => new { MyKey = g.Key.aname, cnt = g.Count() + 5 }) .ToList(); AssertSql( - @"SELECT [t1].[Name] AS [MyKey], COUNT(*) + 5 AS [cnt] + @"SELECT [t1].[Name] AS [MyKey], COUNT(*) + 5 AS [cnt] FROM [Table] AS [t2] LEFT JOIN ( SELECT [t].[Id], [t].[Name], [t0].[Id] AS [Id0] @@ -4011,24 +3563,12 @@ from a in grouping.DefaultIfEmpty() join m in context.Set() on e.Id equals m.Id into grouping2 from m in grouping2.DefaultIfEmpty() - select new - { - aname = a.Name, - mname = m.Name - }) + select new { aname = a.Name, mname = m.Name }) .OrderBy(g => g.aname) .GroupBy( - g => new - { - g.aname, - g.mname - }).FirstOrDefault() + g => new { g.aname, g.mname }).FirstOrDefault() .Select( - g => new - { - MyKey = g.aname, - cnt = g.mname - }) + g => new { MyKey = g.aname, cnt = g.mname }) .ToList(); AssertSql( @@ -4143,47 +3683,16 @@ private SqlServerTestStore CreateDatabase11803() () => new MyContext11803(_options), context => { - var f1 = new Faction - { - Name = "Skeliege" - }; - var f2 = new Faction - { - Name = "Monsters" - }; - var f3 = new Faction - { - Name = "Nilfgaard" - }; - var f4 = new Faction - { - Name = "Northern Realms" - }; - var f5 = new Faction - { - Name = "Scioia'tael" - }; + var f1 = new Faction { Name = "Skeliege" }; + var f2 = new Faction { Name = "Monsters" }; + var f3 = new Faction { Name = "Nilfgaard" }; + var f4 = new Faction { Name = "Northern Realms" }; + var f5 = new Faction { Name = "Scioia'tael" }; - var l11 = new Leader - { - Faction = f1, - Name = "Bran Tuirseach" - }; - var l12 = new Leader - { - Faction = f1, - Name = "Crach an Craite" - }; - var l13 = new Leader - { - Faction = f1, - Name = "Eist Tuirseach" - }; - var l14 = new Leader - { - Faction = f1, - Name = "Harald the Cripple" - }; + var l11 = new Leader { Faction = f1, Name = "Bran Tuirseach" }; + var l12 = new Leader { Faction = f1, Name = "Crach an Craite" }; + var l13 = new Leader { Faction = f1, Name = "Eist Tuirseach" }; + var l14 = new Leader { Faction = f1, Name = "Harald the Cripple" }; context.Factions.AddRange(f1, f2, f3, f4, f5); context.Leaders.AddRange(l11, l12, l13, l14); @@ -4217,10 +3726,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) () => Set() .Where(lq => lq.Name != "Foo") .Select( - lq => new FactionQuery - { - Name = lq.Name - })); + lq => new FactionQuery { Name = lq.Name })); modelBuilder .Entity() @@ -4229,10 +3735,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) () => Set() .Where(fq => fq.Name != "Bar") .Select( - fq => new LeaderQuery - { - Name = "Not Bar" - })); + fq => new LeaderQuery { Name = "Not Bar" })); } } @@ -4276,12 +3779,7 @@ public virtual void Collection_without_setter_materialized_correctly() { var query1 = context.Blogs .Select( - b => new - { - Collection1 = b.Posts1, - Collection2 = b.Posts2, - Collection3 = b.Posts3 - }).ToList(); + b => new { Collection1 = b.Posts1, Collection2 = b.Posts2, Collection3 = b.Posts3 }).ToList(); var query2 = context.Blogs .Select( @@ -4304,12 +3802,7 @@ public virtual void Collection_without_setter_materialized_correctly() var query4 = context.Blogs .Where(b => ClientMethod11923(b.Id)) .Select( - b => new - { - Collection1 = b.Posts1, - Collection2 = b.Posts2, - Collection3 = b.Posts3 - }).ToList(); + b => new { Collection1 = b.Posts1, Collection2 = b.Posts2, Collection3 = b.Posts3 }).ToList(); var query5 = context.Blogs .Where(b => ClientMethod11923(b.Id)) @@ -4340,64 +3833,22 @@ private SqlServerTestStore CreateDatabase11923() () => new MyContext11923(_options), context => { - var p111 = new Post11923 - { - Name = "P111" - }; - var p112 = new Post11923 - { - Name = "P112" - }; - var p121 = new Post11923 - { - Name = "P121" - }; - var p122 = new Post11923 - { - Name = "P122" - }; - var p123 = new Post11923 - { - Name = "P123" - }; - var p131 = new Post11923 - { - Name = "P131" - }; + var p111 = new Post11923 { Name = "P111" }; + var p112 = new Post11923 { Name = "P112" }; + var p121 = new Post11923 { Name = "P121" }; + var p122 = new Post11923 { Name = "P122" }; + var p123 = new Post11923 { Name = "P123" }; + var p131 = new Post11923 { Name = "P131" }; - var p211 = new Post11923 - { - Name = "P211" - }; - var p212 = new Post11923 - { - Name = "P212" - }; - var p221 = new Post11923 - { - Name = "P221" - }; - var p222 = new Post11923 - { - Name = "P222" - }; - var p223 = new Post11923 - { - Name = "P223" - }; - var p231 = new Post11923 - { - Name = "P231" - }; + var p211 = new Post11923 { Name = "P211" }; + var p212 = new Post11923 { Name = "P212" }; + var p221 = new Post11923 { Name = "P221" }; + var p222 = new Post11923 { Name = "P222" }; + var p223 = new Post11923 { Name = "P223" }; + var p231 = new Post11923 { Name = "P231" }; - var b1 = new Blog11923 - { - Name = "B1" - }; - var b2 = new Blog11923 - { - Name = "B2" - }; + var b1 = new Blog11923 { Name = "B1" }; + var b2 = new Blog11923 { Name = "B2" }; b1.Posts1.AddRange(new[] { p111, p112 }); b1.Posts2.AddRange(new[] { p121, p122, p123 }); @@ -4740,10 +4191,7 @@ public virtual void Correlated_collection_correctly_associates_entities_with_byt { blog.Name, Comments = blog.Comments.Select( - u => new - { - u.Id - }).ToArray() + u => new { u.Id }).ToArray() }; var result = query.ToList(); Assert.Equal(1, result[0].Comments.Count()); @@ -4809,11 +4257,7 @@ public virtual void Find_underlying_property_after_GroupJoin_DefaultIfEmpty() join d in context.EmployeeDevices on e.Id equals d.EmployeeId into grouping from j in grouping.DefaultIfEmpty() - select new Holder13025 - { - Name = e.Name, - DeviceId = j.DeviceId - }).ToList(); + select new Holder13025 { Name = e.Name, DeviceId = j.DeviceId }).ToList(); } } } @@ -4834,14 +4278,7 @@ private SqlServerTestStore CreateDatabase13025() new Employee13025 { Name = "Test1", - Devices = new List - { - new EmployeeDevice13025 - { - DeviceId = 1, - Device = "Battery" - } - } + Devices = new List { new EmployeeDevice13025 { DeviceId = 1, Device = "Battery" } } }); context.SaveChanges(); @@ -5061,8 +4498,7 @@ public virtual void DateTime_Contains_with_smalldatetime_generates_correct_liter { using (var context = new MyContext13118(_options)) { - var testDateList = new List - { new DateTime(2018, 10, 07) }; + var testDateList = new List { new DateTime(2018, 10, 07) }; var findRecordsWithDateInList = context.ReproEntity .Where(a => testDateList.Contains(a.MyTime)) .ToList(); @@ -5084,14 +4520,8 @@ private SqlServerTestStore CreateDatabase13118() context => { context.AddRange( - new ReproEntity13118 - { - MyTime = new DateTime(2018, 10, 07) - }, - new ReproEntity13118 - { - MyTime = new DateTime(2018, 10, 08) - }); + new ReproEntity13118 { MyTime = new DateTime(2018, 10, 07) }, + new ReproEntity13118 { MyTime = new DateTime(2018, 10, 08) }); context.SaveChanges(); ClearLog(); @@ -5160,10 +4590,7 @@ private SqlServerTestStore CreateDatabase12732() context => { context.Add( - new Todo - { - Type = TodoType.foo0 - }); + new Todo { Type = TodoType.foo0 }); context.SaveChanges(); ClearLog(); }); @@ -5210,10 +4637,7 @@ public virtual void Correlated_subquery_with_owned_navigation_being_compared_to_ { Turnovers = y.Turnovers == null ? null - : new - { - y.Turnovers.AmountIn - } + : new { y.Turnovers.AmountIn } }).ToList() }).ToList(); @@ -5223,7 +4647,7 @@ public virtual void Correlated_subquery_with_owned_navigation_being_compared_to_ Assert.Equal(10, partners[0].Addresses[0].Turnovers.AmountIn); AssertSql( - @"SELECT [p].[Id], [t0].[c], [t0].[Turnovers_AmountIn], [t0].[Id] + @"SELECT [p].[Id], [t0].[c], [t0].[Turnovers_AmountIn], [t0].[Id] FROM [Partners] AS [p] LEFT JOIN ( SELECT CASE @@ -5254,13 +4678,7 @@ private SqlServerTestStore CreateDatabase13157() { Addresses = new List { - new Address13157 - { - Turnovers = new AddressTurnovers13157 - { - AmountIn = 10 - } - } + new Address13157 { Turnovers = new AddressTurnovers13157 { AmountIn = 10 } } } } ); @@ -5469,10 +4887,7 @@ private SqlServerTestStore CreateDatabase13587() context => { context.InventoryPools.Add( - new InventoryPool13587 - { - Quantity = 2 - }); + new InventoryPool13587 { Quantity = 2 }); context.SaveChanges(); @@ -5530,7 +4945,6 @@ private SqlServerTestStore CreateDatabase12518() }); } - public class MyContext12518 : DbContext { public virtual DbSet Parents { get; set; } @@ -5545,13 +4959,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { var child = modelBuilder.Entity(); child.HasOne(_ => _.Parent) - .WithOne(_ => _.Child) - .HasForeignKey(_ => _.ChildId); + .WithOne(_ => _.Child) + .HasForeignKey(_ => _.ChildId); child.Property(x => x.ULongRowVersion) - .HasConversion(new NumberToBytesConverter()) - .IsRowVersion() - .IsRequired() - .HasColumnType("RowVersion"); + .HasConversion(new NumberToBytesConverter()) + .IsRowVersion() + .IsRequired() + .HasColumnType("RowVersion"); modelBuilder.Entity(); } @@ -5563,6 +4977,7 @@ public class Parent12518 public Guid? ChildId { get; set; } public Child12518 Child { get; set; } } + public class Child12518 { public Guid Id { get; set; } = Guid.NewGuid(); @@ -5610,7 +5025,7 @@ public class MyContext12549 : DbContext public DbSet Table2 { get; set; } public MyContext12549(DbContextOptions options) - : base(options) + : base(options) { } } @@ -5685,10 +5100,7 @@ private SqlServerTestStore CreateDatabase16233() { context.AddRange( new BaseType16233(), - new DerivedType16233 - { - Reference = new Reference16233() - }, + new DerivedType16233 { Reference = new Reference16233() }, new DerivedType16233()); context.SaveChanges(); @@ -5697,7 +5109,6 @@ private SqlServerTestStore CreateDatabase16233() }); } - public class MyContext16233 : DbContext { public virtual DbSet Bases { get; set; } @@ -5749,7 +5160,8 @@ from c in grouping.DefaultIfEmpty() }; var result = query.ToList(); Assert.Equal(2, result.Count); - AssertSql(@"SELECT [p].[Id], [p].[Name], CASE + AssertSql( + @"SELECT [p].[Id], [p].[Name], CASE WHEN [c].[Id] IS NULL THEN N'Other' ELSE [c].[Name] END AS [CategoryName], CASE @@ -5767,21 +5179,13 @@ private SqlServerTestStore CreateDatabase15684() () => new MyContext15684(_options), context => { - context.Products.Add(new Product15684 - { - Name = "Apple", - Category = new Category15684 + context.Products.Add( + new Product15684 { - Name = "Fruit", - Status = CategoryStatus15684.Active - } - }); - + Name = "Apple", Category = new Category15684 { Name = "Fruit", Status = CategoryStatus15684.Active } + }); - context.Products.Add(new Product15684 - { - Name = "Bike" - }); + context.Products.Add(new Product15684 { Name = "Bike" }); context.SaveChanges(); @@ -5793,7 +5197,10 @@ public class MyContext15684 : DbContext public DbSet Categories { get; set; } public DbSet Products { get; set; } - public MyContext15684(DbContextOptions options) : base(options) { } + public MyContext15684(DbContextOptions options) + : base(options) + { + } protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -5839,7 +5246,7 @@ public class ProductDto15684 public enum CategoryStatus15684 { Active = 0, - Removed = 1, + Removed = 1 } #endregion @@ -5878,7 +5285,6 @@ public virtual void Null_check_removal_applied_recursively() Expression.Constant("Leeds", typeof(string))), userParam); - using (var context = new MyContext15204(_options)) { var query = context.BuildingSet @@ -5909,28 +5315,38 @@ private SqlServerTestStore CreateDatabase15204() var london = new TCity15204 { Name = "London" }; var sam = new TBuilder15204 { Name = "Sam", City = london }; - context.MandatorSet.Add(new TMandator15204 - { - Identity = Guid.NewGuid(), - Name = "One", - Buildings = new List + context.MandatorSet.Add( + new TMandator15204 { - new TBuilding15204 { Identity = Guid.NewGuid(), LongName = "One L1", Builder = sam }, - new TBuilding15204 { Identity = Guid.NewGuid(), LongName = "One L2", Builder = sam } - } - }); - context.MandatorSet.Add(new TMandator15204 - { - Identity = Guid.NewGuid(), - Name = "Two", - Buildings = new List - { - new TBuilding15204 { Identity = Guid.NewGuid(), LongName = "Two L1", - Builder = new TBuilder15204 { Name = "John", City = london }}, - new TBuilding15204 { Identity = Guid.NewGuid(), LongName = "Two L2", - Builder = new TBuilder15204 { Name = "Mark", City = new TCity15204 { Name = "Leeds" }}} - } - }); + Identity = Guid.NewGuid(), + Name = "One", + Buildings = new List + { + new TBuilding15204 { Identity = Guid.NewGuid(), LongName = "One L1", Builder = sam }, + new TBuilding15204 { Identity = Guid.NewGuid(), LongName = "One L2", Builder = sam } + } + }); + context.MandatorSet.Add( + new TMandator15204 + { + Identity = Guid.NewGuid(), + Name = "Two", + Buildings = new List + { + new TBuilding15204 + { + Identity = Guid.NewGuid(), + LongName = "Two L1", + Builder = new TBuilder15204 { Name = "John", City = london } + }, + new TBuilding15204 + { + Identity = Guid.NewGuid(), + LongName = "Two L2", + Builder = new TBuilder15204 { Name = "Mark", City = new TCity15204 { Name = "Leeds" } } + } + } + }); context.SaveChanges(); @@ -5944,7 +5360,8 @@ public class MyContext15204 : DbContext public DbSet Builder { get; set; } public DbSet City { get; set; } - public MyContext15204(DbContextOptions options) : base(options) + public MyContext15204(DbContextOptions options) + : base(options) { ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; ChangeTracker.AutoDetectChangesEnabled = false; @@ -6050,7 +5467,8 @@ public class MyContext15518 : DbContext { public DbSet Repos { get; set; } - public MyContext15518(DbContextOptions options) : base(options) + public MyContext15518(DbContextOptions options) + : base(options) { } } @@ -6073,11 +5491,7 @@ public virtual void Select_nested_projection() using (var context = new MyContext8864(_options)) { var customers = context.Customers - .Select(c => new - { - Customer = c, - CustomerAgain = Get(context, c.Id) - }) + .Select(c => new { Customer = c, CustomerAgain = Get(context, c.Id) }) .ToList(); Assert.Equal(2, customers.Count); @@ -6091,7 +5505,7 @@ public virtual void Select_nested_projection() } private static Customer8864 Get(MyContext8864 context, int id) - => context.Customers.Single(c => c.Id == id); + => context.Customers.Single(c => c.Id == id); private SqlServerTestStore CreateDatabase8864() => CreateTestStore( @@ -6111,7 +5525,8 @@ public class MyContext8864 : DbContext { public DbSet Customers { get; set; } - public MyContext8864(DbContextOptions options) : base(options) + public MyContext8864(DbContextOptions options) + : base(options) { } } @@ -6150,13 +5565,16 @@ private SqlServerTestStore CreateDatabase7983() () => new MyContext7983(_options), context => { - context.Add(new Blog7983 - { - Posts = new List { - new Post7983 { Title = "First" }, - new Post7983 { Title = "Second" }, - new Post7983 { Title = "Third" } } - }); + context.Add( + new Blog7983 + { + Posts = new List + { + new Post7983 { Title = "First" }, + new Post7983 { Title = "Second" }, + new Post7983 { Title = "Third" } + } + }); context.SaveChanges(); @@ -6168,7 +5586,8 @@ public class MyContext7983 : DbContext public DbSet Blogs { get; set; } public DbSet Posts { get; set; } - public MyContext7983(DbContextOptions options) : base(options) + public MyContext7983(DbContextOptions options) + : base(options) { } } @@ -6193,6 +5612,7 @@ public class Post7983 public class PostDTO7983 { public string Title { get; set; } + public PostDTO7983 From(Post7983 post) { Title = post.Title; @@ -6250,20 +5670,27 @@ SELECT 1 public class MyContext17253 : DbContext { public DbSet EntitiesWithQueryFilterSelfReference { get; set; } - public DbSet EntitiesReferencingEntityWithQueryFilterSelfReference { get; set; } + + public DbSet EntitiesReferencingEntityWithQueryFilterSelfReference + { + get; + set; + } public DbSet EntitiesWithQueryFilterCycle1 { get; set; } public DbSet EntitiesWithQueryFilterCycle2 { get; set; } public DbSet EntitiesWithQueryFilterCycle3 { get; set; } - public MyContext17253(DbContextOptions options) : base(options) + public MyContext17253(DbContextOptions options) + : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity().HasQueryFilter(e => EntitiesWithQueryFilterSelfReference.Any()); - modelBuilder.Entity().HasQueryFilter(e => Set().Any()); + modelBuilder.Entity() + .HasQueryFilter(e => Set().Any()); modelBuilder.Entity().HasQueryFilter(e => EntitiesWithQueryFilterCycle2.Any()); modelBuilder.Entity().HasQueryFilter(e => Set().Any()); @@ -6276,8 +5703,13 @@ private SqlServerTestStore CreateDatabase17253() () => new MyContext17253(_options), context => { - context.EntitiesWithQueryFilterSelfReference.Add(new EntityWithQueryFilterSelfReference { Name = "EntityWithQueryFilterSelfReference" }); - context.EntitiesReferencingEntityWithQueryFilterSelfReference.Add(new EntityReferencingEntityWithQueryFilterSelfReference { Name = "EntityReferencingEntityWithQueryFilterSelfReference" }); + context.EntitiesWithQueryFilterSelfReference.Add( + new EntityWithQueryFilterSelfReference { Name = "EntityWithQueryFilterSelfReference" }); + context.EntitiesReferencingEntityWithQueryFilterSelfReference.Add( + new EntityReferencingEntityWithQueryFilterSelfReference + { + Name = "EntityReferencingEntityWithQueryFilterSelfReference" + }); context.EntitiesWithQueryFilterCycle1.Add(new EntityWithQueryFilterCycle1 { Name = "EntityWithQueryFilterCycle1_1" }); context.EntitiesWithQueryFilterCycle2.Add(new EntityWithQueryFilterCycle2 { Name = "EntityWithQueryFilterCycle2_1" }); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/QueryLoggingSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/QueryLoggingSqlServerTest.cs index ba5545bffbd..1c8ac55de95 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/QueryLoggingSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/QueryLoggingSqlServerTest.cs @@ -61,7 +61,8 @@ var customers Assert.NotNull(customers); Assert.Contains( - CoreResources.LogSensitiveDataLoggingEnabled(new TestLogger()).GenerateMessage(), Fixture.TestSqlLoggerFactory.Log.Select(l => l.Message)); + CoreResources.LogSensitiveDataLoggingEnabled(new TestLogger()).GenerateMessage(), + Fixture.TestSqlLoggerFactory.Log.Select(l => l.Message)); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Select.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Select.cs index 2401728d331..6987b3c21a1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Select.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.Select.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; -using Xunit; namespace Microsoft.EntityFrameworkCore.Query { @@ -600,9 +599,11 @@ FROM [Orders] AS [o] FROM [Customers] AS [c]"); } - public override async Task Project_single_element_from_collection_with_OrderBy_Distinct_and_FirstOrDefault_followed_by_projecting_length(bool isAsync) + public override async Task + Project_single_element_from_collection_with_OrderBy_Distinct_and_FirstOrDefault_followed_by_projecting_length(bool isAsync) { - await base.Project_single_element_from_collection_with_OrderBy_Distinct_and_FirstOrDefault_followed_by_projecting_length(isAsync); + await base.Project_single_element_from_collection_with_OrderBy_Distinct_and_FirstOrDefault_followed_by_projecting_length( + isAsync); AssertSql( @"SELECT ( diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.SetOperations.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.SetOperations.cs index 7dc8f9b9b9a..7d341da99d1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.SetOperations.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SimpleQuerySqlServerTest.SetOperations.cs @@ -62,7 +62,8 @@ FROM [Customers] AS [c] EXCEPT SELECT [c0].[CustomerID], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region] FROM [Customers] AS [c0] -WHERE CHARINDEX(N'Thomas', [c0].[ContactName]) > 0"); } +WHERE CHARINDEX(N'Thomas', [c0].[ContactName]) > 0"); + } public override async Task Union_OrderBy_Skip_Take(bool isAsync) { @@ -203,7 +204,8 @@ public override async Task Select_Union(bool isAsync) { await base.Select_Union(isAsync); - AssertSql(@"SELECT [c].[Address] + AssertSql( + @"SELECT [c].[Address] FROM [Customers] AS [c] WHERE ([c].[City] = N'Berlin') AND [c].[City] IS NOT NULL UNION @@ -216,7 +218,8 @@ public override async Task Union_Select(bool isAsync) { await base.Union_Select(isAsync); - AssertSql(@"SELECT [t].[Address] + AssertSql( + @"SELECT [t].[Address] FROM ( 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/SpatialQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerFixture.cs index 5a11c98316e..a7d4ee9fca5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerFixture.cs @@ -37,7 +37,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con e => SqlFunctionExpression.Create( e.First(), "STDistance", - e.Skip(1), + e.Skip(1), typeof(double), null))); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs index 5d41a49aa05..3aa289f0174 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs @@ -52,9 +52,9 @@ public override async Task AsBinary(bool isAsync) await base.AsBinary(isAsync); // issue #15994 -// AssertSql( -// @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] -//FROM [PointEntity] AS [e]"); + // AssertSql( + // @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] + //FROM [PointEntity] AS [e]"); } public override async Task AsText(bool isAsync) @@ -62,9 +62,9 @@ public override async Task AsText(bool isAsync) await base.AsText(isAsync); // issue #15994 -// AssertSql( -// @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] -//FROM [PointEntity] AS [e]"); + // AssertSql( + // @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] + //FROM [PointEntity] AS [e]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -78,9 +78,9 @@ public override async Task Buffer(bool isAsync) await base.Buffer(isAsync); // issue #15994 -// AssertSql( -// @"SELECT [e].[Id], [e].[Polygon].STBuffer(1.0E0) AS [Buffer] -//FROM [PolygonEntity] AS [e]"); + // AssertSql( + // @"SELECT [e].[Id], [e].[Polygon].STBuffer(1.0E0) AS [Buffer] + //FROM [PolygonEntity] AS [e]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -100,11 +100,11 @@ public override async Task Contains(bool isAsync) await base.Contains(isAsync); // issue #15994 -// AssertSql( -// @"@__point_0='0xE6100000010C000000000000D03F000000000000D03F' (Size = 22) (DbType = Binary) + // AssertSql( + // @"@__point_0='0xE6100000010C000000000000D03F000000000000D03F' (Size = 22) (DbType = Binary) -//SELECT [e].[Id], [e].[Polygon].STContains(@__point_0) AS [Contains] -//FROM [PolygonEntity] AS [e]"); + //SELECT [e].[Id], [e].[Polygon].STContains(@__point_0) AS [Contains] + //FROM [PolygonEntity] AS [e]"); } public override async Task ConvexHull(bool isAsync) @@ -112,9 +112,9 @@ public override async Task ConvexHull(bool isAsync) await base.ConvexHull(isAsync); // issue #15994 -// AssertSql( -// @"SELECT [e].[Id], [e].[Polygon].STConvexHull() AS [ConvexHull] -//FROM [PolygonEntity] AS [e]"); + // AssertSql( + // @"SELECT [e].[Id], [e].[Polygon].STConvexHull() AS [ConvexHull] + //FROM [PolygonEntity] AS [e]"); } public override async Task IGeometryCollection_Count(bool isAsync) @@ -158,11 +158,11 @@ public override async Task Difference(bool isAsync) await base.Difference(isAsync); // issue #15994 -// AssertSql( -// @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) + // AssertSql( + // @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Binary) -//SELECT [e].[Id], [e].[Polygon].STDifference(@__polygon_0) AS [Difference] -//FROM [PolygonEntity] AS [e]"); + //SELECT [e].[Id], [e].[Polygon].STDifference(@__polygon_0) AS [Difference] + //FROM [PolygonEntity] AS [e]"); } public override async Task Dimension(bool isAsync) @@ -179,11 +179,11 @@ public override async Task Disjoint(bool isAsync) await base.Disjoint(isAsync); // issue #15994 -// AssertSql( -// @"@__point_0='0xE6100000010C000000000000F03F000000000000F03F' (Size = 22) (DbType = Binary) + // AssertSql( + // @"@__point_0='0xE6100000010C000000000000F03F000000000000F03F' (Size = 22) (DbType = Binary) -//SELECT [e].[Id], [e].[Polygon].STDisjoint(@__point_0) AS [Disjoint] -//FROM [PolygonEntity] AS [e]"); + //SELECT [e].[Id], [e].[Polygon].STDisjoint(@__point_0) AS [Disjoint] + //FROM [PolygonEntity] AS [e]"); } public override async Task Distance(bool isAsync) @@ -191,11 +191,11 @@ public override async Task Distance(bool isAsync) await base.Distance(isAsync); // issue #15994 -// AssertSql( -// @"@__point_0='0xE6100000010C000000000000F03F0000000000000000' (Size = 22) (DbType = Binary) + // AssertSql( + // @"@__point_0='0xE6100000010C000000000000F03F0000000000000000' (Size = 22) (DbType = Binary) -//SELECT [e].[Id], [e].[Point].STDistance(@__point_0) AS [Distance] -//FROM [PointEntity] AS [e]"); + //SELECT [e].[Id], [e].[Point].STDistance(@__point_0) AS [Distance] + //FROM [PointEntity] AS [e]"); } public override async Task Distance_geometry(bool isAsync) @@ -203,11 +203,11 @@ public override async Task Distance_geometry(bool isAsync) await base.Distance_geometry(isAsync); // issue #15994 -// AssertSql( -// @"@__point_0='0xE6100000010C000000000000F03F0000000000000000' (Size = 22) (DbType = Binary) + // AssertSql( + // @"@__point_0='0xE6100000010C000000000000F03F0000000000000000' (Size = 22) (DbType = Binary) -//SELECT [e].[Id], [e].[Geometry].STDistance(@__point_0) AS [Distance] -//FROM [PointEntity] AS [e]"); + //SELECT [e].[Id], [e].[Geometry].STDistance(@__point_0) AS [Distance] + //FROM [PointEntity] AS [e]"); } [ConditionalTheory(Skip = "Mixing SRIDs not supported")] @@ -221,9 +221,9 @@ public override async Task Distance_constant_srid_4326(bool isAsync) await base.Distance_constant_srid_4326(isAsync); // issue #15994 -// AssertSql( -// @"SELECT [e].[Id], [e].[Point].STDistance('POINT (1 1)') AS [Distance] -//FROM [PointEntity] AS [e]"); + // AssertSql( + // @"SELECT [e].[Id], [e].[Point].STDistance('POINT (1 1)') AS [Distance] + //FROM [PointEntity] AS [e]"); } [ConditionalTheory(Skip = "Mixing SRIDs not supported")] @@ -286,11 +286,11 @@ public override async Task EqualsTopologically(bool isAsync) await base.EqualsTopologically(isAsync); // issue #15994 -// AssertSql( -// @"@__point_0='0xE6100000010C00000000000000000000000000000000' (Size = 22) (DbType = Object) + // AssertSql( + // @"@__point_0='0xE6100000010C00000000000000000000000000000000' (Size = 22) (DbType = Object) -//SELECT [e].[Id], [e].[Point].STEquals(@__point_0) AS [EqualsTopologically] -//FROM [PointEntity] AS [e]"); + //SELECT [e].[Id], [e].[Point].STEquals(@__point_0) AS [EqualsTopologically] + //FROM [PointEntity] AS [e]"); } public override async Task ExteriorRing(bool isAsync) @@ -316,9 +316,9 @@ public override async Task GetGeometryN(bool isAsync) await base.GetGeometryN(isAsync); // issue #15994 -// AssertSql( -// @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Geometry0] -//FROM [MultiLineStringEntity] AS [e]"); + // AssertSql( + // @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Geometry0] + //FROM [MultiLineStringEntity] AS [e]"); } public override async Task GetInteriorRingN(bool isAsync) @@ -338,9 +338,9 @@ public override async Task GetPointN(bool isAsync) await base.GetPointN(isAsync); // issue #15994 -// AssertSql( -// @"SELECT [e].[Id], [e].[LineString].STPointN(0 + 1) AS [Point0] -//FROM [LineStringEntity] AS [e]"); + // AssertSql( + // @"SELECT [e].[Id], [e].[LineString].STPointN(0 + 1) AS [Point0] + //FROM [LineStringEntity] AS [e]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -354,11 +354,11 @@ public override async Task Intersection(bool isAsync) await base.Intersection(isAsync); // issue #15994 -// AssertSql( -// @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) + // AssertSql( + // @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) -//SELECT [e].[Id], [e].[Polygon].STIntersection(@__polygon_0) AS [Intersection] -//FROM [PolygonEntity] AS [e]"); + //SELECT [e].[Id], [e].[Polygon].STIntersection(@__polygon_0) AS [Intersection] + //FROM [PolygonEntity] AS [e]"); } public override async Task Intersects(bool isAsync) @@ -366,11 +366,11 @@ public override async Task Intersects(bool isAsync) await base.Intersects(isAsync); // issue #15994 -// AssertSql( -// @"@__lineString_0='0xE61000000114000000000000E0BF000000000000E03F000000000000E03F0000...' (Size = 38) (DbType = Object) + // AssertSql( + // @"@__lineString_0='0xE61000000114000000000000E0BF000000000000E03F000000000000E03F0000...' (Size = 38) (DbType = Object) -//SELECT [e].[Id], [e].[LineString].STIntersects(@__lineString_0) AS [Intersects] -//FROM [LineStringEntity] AS [e]"); + //SELECT [e].[Id], [e].[LineString].STIntersects(@__lineString_0) AS [Intersects] + //FROM [LineStringEntity] AS [e]"); } public override async Task ICurve_IsClosed(bool isAsync) @@ -443,9 +443,9 @@ public override async Task Item(bool isAsync) await base.Item(isAsync); // issue #15994 -// AssertSql( -// @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Item0] -//FROM [MultiLineStringEntity] AS [e]"); + // AssertSql( + // @"SELECT [e].[Id], [e].[MultiLineString].STGeometryN(0 + 1) AS [Item0] + //FROM [MultiLineStringEntity] AS [e]"); } public override async Task Length(bool isAsync) @@ -519,11 +519,11 @@ public override async Task Overlaps(bool isAsync) await base.Overlaps(isAsync); // issue #15994 -// AssertSql( -// @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) + // AssertSql( + // @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) -//SELECT [e].[Id], [e].[Polygon].STOverlaps(@__polygon_0) AS [Overlaps] -//FROM [PolygonEntity] AS [e]"); + //SELECT [e].[Id], [e].[Polygon].STOverlaps(@__polygon_0) AS [Overlaps] + //FROM [PolygonEntity] AS [e]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -576,11 +576,11 @@ public override async Task SymmetricDifference(bool isAsync) await base.SymmetricDifference(isAsync); // issue #15994 -// AssertSql( -// @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) + // AssertSql( + // @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) -//SELECT [e].[Id], [e].[Polygon].STSymDifference(@__polygon_0) AS [SymmetricDifference] -//FROM [PolygonEntity] AS [e]"); + //SELECT [e].[Id], [e].[Polygon].STSymDifference(@__polygon_0) AS [SymmetricDifference] + //FROM [PolygonEntity] AS [e]"); } public override async Task ToBinary(bool isAsync) @@ -588,9 +588,9 @@ public override async Task ToBinary(bool isAsync) await base.ToBinary(isAsync); // issue #15994 -// AssertSql( -// @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] -//FROM [PointEntity] AS [e]"); + // AssertSql( + // @"SELECT [e].[Id], [e].[Point].STAsBinary() AS [Binary] + //FROM [PointEntity] AS [e]"); } public override async Task ToText(bool isAsync) @@ -598,9 +598,9 @@ public override async Task ToText(bool isAsync) await base.ToText(isAsync); // issue #15994 -// AssertSql( -// @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] -//FROM [PointEntity] AS [e]"); + // AssertSql( + // @"SELECT [e].[Id], [e].[Point].AsTextZM() AS [Text] + //FROM [PointEntity] AS [e]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -614,11 +614,11 @@ public override async Task Union(bool isAsync) await base.Union(isAsync); // issue #15994 -// AssertSql( -// @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) + // AssertSql( + // @"@__polygon_0='0xE610000001040400000000000000000000000000000000000000000000000000...' (Size = 96) (DbType = Object) -//SELECT [e].[Id], [e].[Polygon].STUnion(@__polygon_0) AS [Union] -//FROM [PolygonEntity] AS [e]"); + //SELECT [e].[Id], [e].[Polygon].STUnion(@__polygon_0) AS [Union] + //FROM [PolygonEntity] AS [e]"); } [ConditionalTheory(Skip = "No Server Translation.")] @@ -632,11 +632,11 @@ public override async Task Within(bool isAsync) await base.Within(isAsync); // issue #15994 -// AssertSql( -// @"@__polygon_0='0xE6100000010405000000000000000000F0BF000000000000F0BF000000000000...' (Size = 112) (DbType = Object) + // AssertSql( + // @"@__polygon_0='0xE6100000010405000000000000000000F0BF000000000000F0BF000000000000...' (Size = 112) (DbType = Object) -//SELECT [e].[Id], [e].[Point].STWithin(@__polygon_0) AS [Within] -//FROM [PointEntity] AS [e]"); + //SELECT [e].[Id], [e].[Point].STWithin(@__polygon_0) AS [Within] + //FROM [PointEntity] AS [e]"); } public override async Task X(bool isAsync) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs index d1ce3913416..e328938fb05 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.SpatialModel; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using NetTopologySuite.Geometries; using Xunit; using Xunit.Abstractions; diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SqlExecutorSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SqlExecutorSqlServerTest.cs index 5865d3e767e..6d979150fdc 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SqlExecutorSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SqlExecutorSqlServerTest.cs @@ -137,11 +137,7 @@ public override async Task Query_with_parameters_interpolated_async() } protected override DbParameter CreateDbParameter(string name, object value) - => new SqlParameter - { - ParameterName = name, - Value = value - }; + => new SqlParameter { ParameterName = name, Value = value }; protected override string TenMostExpensiveProductsSproc => "[dbo].[Ten Most Expensive Products]"; protected override string CustomerOrderHistorySproc => "[dbo].[CustOrderHist] @CustomerID"; diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs b/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs index 9c4d605076e..4c84a56ff23 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.EntityFrameworkCore.TestUtilities; -using Xunit; using Xunit.Abstractions; // ReSharper disable InconsistentNaming @@ -44,7 +43,6 @@ FROM [Customers] AS [c] WHERE ([c].[Id] = @__customerId_0) AND @__customerId_0 IS NOT NULL"); } - public override void Scalar_Function_Constant_Parameter_Static() { base.Scalar_Function_Constant_Parameter_Static(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Scaffolding/SqlServerDatabaseModelFactoryTest.cs b/test/EFCore.SqlServer.FunctionalTests/Scaffolding/SqlServerDatabaseModelFactoryTest.cs index 6b471722a79..c6f782e7d95 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Scaffolding/SqlServerDatabaseModelFactoryTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Scaffolding/SqlServerDatabaseModelFactoryTest.cs @@ -658,7 +658,8 @@ Name nvarchar(100) NOT NULL, { Assert.Equal("dbo", c.Table.Schema); Assert.Equal("Blogs", c.Table.Name); - Assert.Equal(@"Blog table comment. + Assert.Equal( + @"Blog table comment. On multiple lines.", c.Table.Comment); }); @@ -720,10 +721,7 @@ Id int PRIMARY KEY Assert.StartsWith("PK__PrimaryK", pk.Name); Assert.Null(pk[SqlServerAnnotationNames.Clustered]); Assert.Equal( - new List - { - "Id" - }, pk.Columns.Select(ic => ic.Name).ToList()); + new List { "Id" }, pk.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE PrimaryKeyTable;"); } @@ -752,10 +750,7 @@ CREATE TABLE UniqueConstraint ( Assert.StartsWith("UQ__UniqueCo", uniqueConstraint.Name); Assert.Null(uniqueConstraint[SqlServerAnnotationNames.Clustered]); Assert.Equal( - new List - { - "Name" - }, uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); + new List { "Name" }, uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE UniqueConstraint;"); } @@ -824,15 +819,9 @@ FOREIGN KEY (Id) REFERENCES PrincipalTable(Id) ON DELETE NO ACTION, Assert.Equal("dbo", firstFk.PrincipalTable.Schema); Assert.Equal("PrincipalTable", firstFk.PrincipalTable.Name); Assert.Equal( - new List - { - "ForeignKeyId" - }, firstFk.Columns.Select(ic => ic.Name).ToList()); + new List { "ForeignKeyId" }, firstFk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id" - }, firstFk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id" }, firstFk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, firstFk.OnDelete); var secondFk = Assert.Single(dbModel.Tables.Single(t => t.Name == "SecondDependent").ForeignKeys); @@ -843,15 +832,9 @@ FOREIGN KEY (Id) REFERENCES PrincipalTable(Id) ON DELETE NO ACTION, Assert.Equal("dbo", secondFk.PrincipalTable.Schema); Assert.Equal("PrincipalTable", secondFk.PrincipalTable.Name); Assert.Equal( - new List - { - "Id" - }, secondFk.Columns.Select(ic => ic.Name).ToList()); + new List { "Id" }, secondFk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id" - }, secondFk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id" }, secondFk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.NoAction, secondFk.OnDelete); }, @" @@ -1573,11 +1556,7 @@ PRIMARY KEY (Id2, Id1) Assert.Equal("CompositePrimaryKeyTable", pk.Table.Name); Assert.StartsWith("PK__Composit", pk.Name); Assert.Equal( - new List - { - "Id2", - "Id1" - }, pk.Columns.Select(ic => ic.Name).ToList()); + new List { "Id2", "Id1" }, pk.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE CompositePrimaryKeyTable;"); } @@ -1602,10 +1581,7 @@ CREATE TABLE NonClusteredPrimaryKeyTable ( Assert.StartsWith("PK__NonClust", pk.Name); Assert.False((bool)pk[SqlServerAnnotationNames.Clustered]); Assert.Equal( - new List - { - "Id1" - }, pk.Columns.Select(ic => ic.Name).ToList()); + new List { "Id1" }, pk.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE NonClusteredPrimaryKeyTable;"); } @@ -1632,10 +1608,7 @@ CREATE TABLE NonClusteredPrimaryKeyTableWithClusteredIndex ( Assert.StartsWith("PK__NonClust", pk.Name); Assert.False((bool)pk[SqlServerAnnotationNames.Clustered]); Assert.Equal( - new List - { - "Id1" - }, pk.Columns.Select(ic => ic.Name).ToList()); + new List { "Id1" }, pk.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE NonClusteredPrimaryKeyTableWithClusteredIndex;"); } @@ -1661,10 +1634,7 @@ CONSTRAINT UK_Clustered UNIQUE CLUSTERED ( Id2 ), Assert.StartsWith("PK__NonClust", pk.Name); Assert.False((bool)pk[SqlServerAnnotationNames.Clustered]); Assert.Equal( - new List - { - "Id1" - }, pk.Columns.Select(ic => ic.Name).ToList()); + new List { "Id1" }, pk.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE NonClusteredPrimaryKeyTableWithClusteredConstraint;"); } @@ -1690,10 +1660,7 @@ CONSTRAINT MyPK PRIMARY KEY ( Id2 ), Assert.StartsWith("MyPK", pk.Name); Assert.Null(pk[SqlServerAnnotationNames.Clustered]); Assert.Equal( - new List - { - "Id2" - }, pk.Columns.Select(ic => ic.Name).ToList()); + new List { "Id2" }, pk.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE PrimaryKeyName;"); } @@ -1723,11 +1690,7 @@ CONSTRAINT UX UNIQUE (Id2, Id1) Assert.Equal("CompositeUniqueConstraintTable", uniqueConstraint.Table.Name); Assert.Equal("UX", uniqueConstraint.Name); Assert.Equal( - new List - { - "Id2", - "Id1" - }, uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); + new List { "Id2", "Id1" }, uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE CompositeUniqueConstraintTable;"); } @@ -1753,10 +1716,7 @@ CREATE TABLE ClusteredUniqueConstraintTable ( Assert.StartsWith("UQ__Clustere", uniqueConstraint.Name); Assert.True((bool)uniqueConstraint[SqlServerAnnotationNames.Clustered]); Assert.Equal( - new List - { - "Id2" - }, uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); + new List { "Id2" }, uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE ClusteredUniqueConstraintTable;"); } @@ -1782,10 +1742,7 @@ CONSTRAINT MyUC UNIQUE ( Id2 ), Assert.Equal("UniqueConstraintName", uniqueConstraint.Table.Name); Assert.Equal("MyUC", uniqueConstraint.Name); Assert.Equal( - new List - { - "Id2" - }, uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); + new List { "Id2" }, uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE UniqueConstraintName;"); } @@ -1816,11 +1773,7 @@ CREATE TABLE CompositeIndexTable ( Assert.Equal("CompositeIndexTable", index.Table.Name); Assert.Equal("IX_COMPOSITE", index.Name); Assert.Equal( - new List - { - "Id2", - "Id1" - }, index.Columns.Select(ic => ic.Name).ToList()); + new List { "Id2", "Id1" }, index.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE CompositeIndexTable;"); } @@ -1848,10 +1801,7 @@ CREATE TABLE ClusteredIndexTable ( Assert.Equal("IX_CLUSTERED", index.Name); Assert.True((bool)index[SqlServerAnnotationNames.Clustered]); Assert.Equal( - new List - { - "Id2" - }, index.Columns.Select(ic => ic.Name).ToList()); + new List { "Id2" }, index.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE ClusteredIndexTable;"); } @@ -1880,10 +1830,7 @@ CREATE TABLE UniqueIndexTable ( Assert.True(index.IsUnique); Assert.Null(index.Filter); Assert.Equal( - new List - { - "Id2" - }, index.Columns.Select(ic => ic.Name).ToList()); + new List { "Id2" }, index.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE UniqueIndexTable;"); } @@ -1911,10 +1858,7 @@ CREATE TABLE FilteredIndexTable ( Assert.Equal("IX_UNIQUE", index.Name); Assert.Equal("([Id2]>(10))", index.Filter); Assert.Equal( - new List - { - "Id2" - }, index.Columns.Select(ic => ic.Name).ToList()); + new List { "Id2" }, index.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE FilteredIndexTable;"); } @@ -1952,17 +1896,9 @@ FOREIGN KEY (ForeignKeyId1, ForeignKeyId2) REFERENCES PrincipalTable(Id1, Id2) O Assert.Equal("dbo", fk.PrincipalTable.Schema); Assert.Equal("PrincipalTable", fk.PrincipalTable.Name); Assert.Equal( - new List - { - "ForeignKeyId1", - "ForeignKeyId2" - }, fk.Columns.Select(ic => ic.Name).ToList()); + new List { "ForeignKeyId1", "ForeignKeyId2" }, fk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id1", - "Id2" - }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id1", "Id2" }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, fk.OnDelete); }, @" @@ -2006,15 +1942,9 @@ FOREIGN KEY (ForeignKeyId2) REFERENCES AnotherPrincipalTable(Id) ON DELETE CASCA Assert.Equal("dbo", principalFk.PrincipalTable.Schema); Assert.Equal("PrincipalTable", principalFk.PrincipalTable.Name); Assert.Equal( - new List - { - "ForeignKeyId1" - }, principalFk.Columns.Select(ic => ic.Name).ToList()); + new List { "ForeignKeyId1" }, principalFk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id" - }, principalFk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id" }, principalFk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, principalFk.OnDelete); var anotherPrincipalFk = Assert.Single(foreignKeys.Where(f => f.PrincipalTable.Name == "AnotherPrincipalTable")); @@ -2025,15 +1955,9 @@ FOREIGN KEY (ForeignKeyId2) REFERENCES AnotherPrincipalTable(Id) ON DELETE CASCA Assert.Equal("dbo", anotherPrincipalFk.PrincipalTable.Schema); Assert.Equal("AnotherPrincipalTable", anotherPrincipalFk.PrincipalTable.Name); Assert.Equal( - new List - { - "ForeignKeyId2" - }, anotherPrincipalFk.Columns.Select(ic => ic.Name).ToList()); + new List { "ForeignKeyId2" }, anotherPrincipalFk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id" - }, anotherPrincipalFk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id" }, anotherPrincipalFk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, anotherPrincipalFk.OnDelete); }, @" @@ -2069,15 +1993,9 @@ FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id2) ON DELETE CASCADE, Assert.Equal("dbo", fk.PrincipalTable.Schema); Assert.Equal("PrincipalTable", fk.PrincipalTable.Name); Assert.Equal( - new List - { - "ForeignKeyId" - }, fk.Columns.Select(ic => ic.Name).ToList()); + new List { "ForeignKeyId" }, fk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id2" - }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id2" }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, fk.OnDelete); }, @" @@ -2111,15 +2029,9 @@ CONSTRAINT MYFK FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id) ON DELE Assert.Equal("dbo", fk.PrincipalTable.Schema); Assert.Equal("PrincipalTable", fk.PrincipalTable.Name); Assert.Equal( - new List - { - "ForeignKeyId" - }, fk.Columns.Select(ic => ic.Name).ToList()); + new List { "ForeignKeyId" }, fk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id" - }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id" }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, fk.OnDelete); Assert.Equal("MYFK", fk.Name); }, @@ -2154,15 +2066,9 @@ FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id) ON DELETE SET NULL, Assert.Equal("dbo", fk.PrincipalTable.Schema); Assert.Equal("PrincipalTable", fk.PrincipalTable.Name); Assert.Equal( - new List - { - "ForeignKeyId" - }, fk.Columns.Select(ic => ic.Name).ToList()); + new List { "ForeignKeyId" }, fk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id" - }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id" }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.SetNull, fk.OnDelete); }, @" @@ -2191,7 +2097,9 @@ CREATE TABLE Blank ( var (_, Id, Message, _, _) = Assert.Single(Fixture.ListLoggerFactory.Log.Where(t => t.Level == LogLevel.Warning)); Assert.Equal(SqlServerResources.LogMissingSchema(new TestLogger()).EventId, Id); - Assert.Equal(SqlServerResources.LogMissingSchema(new TestLogger()).GenerateMessage("MySchema"), Message); + Assert.Equal( + SqlServerResources.LogMissingSchema(new TestLogger()).GenerateMessage("MySchema"), + Message); }, "DROP TABLE Blank;"); } @@ -2213,7 +2121,9 @@ CREATE TABLE Blank ( var (_, Id, Message, _, _) = Assert.Single(Fixture.ListLoggerFactory.Log.Where(t => t.Level == LogLevel.Warning)); Assert.Equal(SqlServerResources.LogMissingTable(new TestLogger()).EventId, Id); - Assert.Equal(SqlServerResources.LogMissingTable(new TestLogger()).GenerateMessage("MyTable"), Message); + Assert.Equal( + SqlServerResources.LogMissingTable(new TestLogger()).GenerateMessage("MyTable"), + Message); }, "DROP TABLE Blank;"); } @@ -2238,10 +2148,12 @@ CONSTRAINT MYFK FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id) ON DELE { var (_, Id, Message, _, _) = Assert.Single(Fixture.ListLoggerFactory.Log.Where(t => t.Level == LogLevel.Warning)); - Assert.Equal(SqlServerResources.LogPrincipalTableNotInSelectionSet(new TestLogger()).EventId, Id); Assert.Equal( - SqlServerResources.LogPrincipalTableNotInSelectionSet(new TestLogger()).GenerateMessage( - "MYFK", "dbo.DependentTable", "dbo.PrincipalTable"), Message); + SqlServerResources.LogPrincipalTableNotInSelectionSet(new TestLogger()).EventId, Id); + Assert.Equal( + SqlServerResources.LogPrincipalTableNotInSelectionSet(new TestLogger()) + .GenerateMessage( + "MYFK", "dbo.DependentTable", "dbo.PrincipalTable"), Message); }, @" DROP TABLE DependentTable; @@ -2264,7 +2176,9 @@ CONSTRAINT MYFK FOREIGN KEY (Id) REFERENCES PrincipalTable(Id) var (level, _, message, _, _) = Assert.Single( Fixture.ListLoggerFactory.Log, t => t.Id == SqlServerEventId.ReflexiveConstraintIgnored); Assert.Equal(LogLevel.Debug, level); - Assert.Equal(SqlServerResources.LogReflexiveConstraintIgnored(new TestLogger()).GenerateMessage("MYFK", "dbo.PrincipalTable"), message); + Assert.Equal( + SqlServerResources.LogReflexiveConstraintIgnored(new TestLogger()) + .GenerateMessage("MYFK", "dbo.PrincipalTable"), message); var table = Assert.Single(dbModel.Tables); Assert.Empty(table.ForeignKeys); diff --git a/test/EFCore.SqlServer.FunctionalTests/SequenceEndToEndTest.cs b/test/EFCore.SqlServer.FunctionalTests/SequenceEndToEndTest.cs index 1f126df4877..ca4084c2840 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SequenceEndToEndTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SequenceEndToEndTest.cs @@ -59,15 +59,9 @@ private static void AddEntities(IServiceProvider serviceProvider, string name) for (var i = 0; i < 10; i++) { context.Add( - new Pegasus - { - Name = "Rainbow Dash " + i - }); + new Pegasus { Name = "Rainbow Dash " + i }); context.Add( - new Pegasus - { - Name = "Fluttershy " + i - }); + new Pegasus { Name = "Fluttershy " + i }); } context.SaveChanges(); @@ -135,22 +129,13 @@ private static void AddEntitiesToMultipleContexts( for (var i = 0; i < 29; i++) { context1.Add( - new Pegasus - { - Name = "Rainbow Dash " + i - }); + new Pegasus { Name = "Rainbow Dash " + i }); context2.Add( - new Pegasus - { - Name = "Fluttershy " + i - }); + new Pegasus { Name = "Fluttershy " + i }); context1.Add( - new Pegasus - { - Name = "Fluttershy " + i - }); + new Pegasus { Name = "Fluttershy " + i }); } context1.SaveChanges(); @@ -201,15 +186,9 @@ private static async Task AddEntitiesAsync(IServiceProvider serviceProvider, str for (var i = 0; i < 10; i++) { await context.AddAsync( - new Pegasus - { - Name = "Rainbow Dash " + i - }); + new Pegasus { Name = "Rainbow Dash " + i }); await context.AddAsync( - new Pegasus - { - Name = "Fluttershy " + i - }); + new Pegasus { Name = "Fluttershy " + i }); } await context.SaveChangesAsync(); @@ -304,17 +283,9 @@ private static void AddEntitiesWithIds(IServiceProvider serviceProvider, int idO for (var i = 1; i < 11; i++) { context.Add( - new Pegasus - { - Name = "Rainbow Dash " + i, - Identifier = i * 100 + idOffset - }); + new Pegasus { Name = "Rainbow Dash " + i, Identifier = i * 100 + idOffset }); context.Add( - new Pegasus - { - Name = "Fluttershy " + i, - Identifier = i * 100 + idOffset + 1 - }); + new Pegasus { Name = "Fluttershy " + i, Identifier = i * 100 + idOffset + 1 }); } context.SaveChanges(); @@ -419,15 +390,9 @@ private static void AddEntitiesNullable(IServiceProvider serviceProvider, string for (var i = 0; i < 10; i++) { context.Add( - new Unicon - { - Name = "Twilight Sparkle " + i - }); + new Unicon { Name = "Twilight Sparkle " + i }); context.Add( - new Unicon - { - Name = "Rarity " + i - }); + new Unicon { Name = "Rarity " + i }); } context.SaveChanges(); diff --git a/test/EFCore.SqlServer.FunctionalTests/SequentialGuidEndToEndTest.cs b/test/EFCore.SqlServer.FunctionalTests/SequentialGuidEndToEndTest.cs index d2a21cbafbe..cfc7dad1b8f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SequentialGuidEndToEndTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SequentialGuidEndToEndTest.cs @@ -28,10 +28,7 @@ public async Task Can_use_sequential_GUID_end_to_end_async() for (var i = 0; i < 50; i++) { context.Add( - new Pegasus - { - Name = "Rainbow Dash " + i - }); + new Pegasus { Name = "Rainbow Dash " + i }); } await context.SaveChangesAsync(); @@ -65,12 +62,7 @@ public async Task Can_use_explicit_values() { guids.Add( context.Add( - new Pegasus - { - Name = "Rainbow Dash " + i, - Index = i, - Id = Guid.NewGuid() - }).Entity.Id); + new Pegasus { Name = "Rainbow Dash " + i, Index = i, Id = Guid.NewGuid() }).Entity.Id); } await context.SaveChangesAsync(); diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/AdventureWorksContext.cs b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/AdventureWorksContext.cs index c899d19aeb7..c7a36d72783 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/AdventureWorksContext.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/AdventureWorksContext.cs @@ -66,11 +66,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) entity => { entity.HasKey( - e => new - { - e.CustomerID, - e.AddressID - }) + e => new { e.CustomerID, e.AddressID }) .HasName("PK_CustomerAddress_CustomerID_AddressID"); entity.HasIndex(e => e.rowguid) @@ -174,12 +170,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) entity => { entity.HasKey( - e => new - { - e.ProductModelID, - e.ProductDescriptionID, - e.Culture - }) + e => new { e.ProductModelID, e.ProductDescriptionID, e.Culture }) .HasName("PK_ProductModelProductDescription_ProductModelID_ProductDescriptionID_Culture"); entity.HasIndex(e => e.rowguid) @@ -199,11 +190,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) entity => { entity.HasKey( - e => new - { - e.SalesOrderID, - e.SalesOrderDetailID - }) + e => new { e.SalesOrderID, e.SalesOrderDetailID }) .HasName("PK_SalesOrderDetail_SalesOrderID_SalesOrderDetailID"); entity.HasIndex(e => e.ProductID) diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureBatchingTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureBatchingTest.cs index d4d154854d8..dcceca8b957 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureBatchingTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureBatchingTest.cs @@ -4,7 +4,6 @@ using System; using Microsoft.EntityFrameworkCore.SqlAzure.Model; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; using Xunit.Abstractions; @@ -40,10 +39,7 @@ public void AddWithBatchSize(int batchSize) contextScoped.Products.Add( new Product { - Name = uuid, - ProductNumber = uuid.Substring(0, 25), - Weight = 1000, - SellStartDate = DateTime.Now + Name = uuid, ProductNumber = uuid.Substring(0, 25), Weight = 1000, SellStartDate = DateTime.Now }); } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureConnectionTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureConnectionTest.cs index 20b7c2e3cc7..5cc9018cae1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureConnectionTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureConnectionTest.cs @@ -5,7 +5,6 @@ using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore.SqlAzure.Model; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable InconsistentNaming @@ -23,10 +22,8 @@ public SqlAzureConnectionTest(SqlAzureFixture fixture) [InlineData(false)] public void Connect_with_encryption(bool encryptionEnabled) { - var connectionStringBuilder = new SqlConnectionStringBuilder(SqlServerTestStore.CreateConnectionString("adventureworks")) - { - Encrypt = encryptionEnabled - }; + var connectionStringBuilder = + new SqlConnectionStringBuilder(SqlServerTestStore.CreateConnectionString("adventureworks")) { Encrypt = encryptionEnabled }; var options = new DbContextOptionsBuilder(); options.UseSqlServer(connectionStringBuilder.ConnectionString, b => b.ApplyConfiguration()); diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureFundamentalsTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureFundamentalsTest.cs index 826957a42b3..f4b1b72ed87 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureFundamentalsTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureFundamentalsTest.cs @@ -5,7 +5,6 @@ using System.Linq; using Microsoft.EntityFrameworkCore.SqlAzure.Model; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable InconsistentNaming @@ -39,10 +38,7 @@ public void CanAdd() contextScoped.Add( new Product { - Name = "Blue Cloud", - ProductNumber = "xxxxxxxxxxx", - Weight = 0.01m, - SellStartDate = DateTime.Now + Name = "Blue Cloud", ProductNumber = "xxxxxxxxxxx", Weight = 0.01m, SellStartDate = DateTime.Now }); Assert.Equal(1, contextScoped.SaveChanges()); } @@ -60,10 +56,7 @@ public void CanUpdate() { using (contextScoped.Database.BeginTransaction()) { - var product = new Product - { - ProductID = 999 - }; + var product = new Product { ProductID = 999 }; contextScoped.Products.Attach(product); Assert.Equal(0, contextScoped.SaveChanges()); diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerDatabaseCreatorTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerDatabaseCreatorTest.cs index dac17aa6d86..02c1936c498 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerDatabaseCreatorTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerDatabaseCreatorTest.cs @@ -13,7 +13,6 @@ using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -290,7 +289,7 @@ private static async Task Creates_physical_database_and_schema_test( { if (createDatabase) { - testDatabase.Initialize(null, (Func)null, null, null); + testDatabase.Initialize(null, (Func)null); } else { @@ -765,11 +764,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) b => { b.HasKey( - e => new - { - e.Key1, - e.Key2 - }); + e => new { e.Key1, e.Key2 }); b.Property(e => e.AndRow).IsConcurrencyToken().ValueGeneratedOnAddOrUpdate(); }); } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerEndToEndTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerEndToEndTest.cs index eb77ddabc26..79caaeba352 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerEndToEndTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerEndToEndTest.cs @@ -36,81 +36,29 @@ public void Can_use_decimal_and_byte_as_identity_columns() { using (var testDatabase = SqlServerTestStore.CreateInitialized(DatabaseName)) { - var nownNum1 = new NownNum - { - Id = 77.0m, - TheWalrus = "Crying" - }; - var nownNum2 = new NownNum - { - Id = 78.0m, - TheWalrus = "Walrus" - }; + var nownNum1 = new NownNum { Id = 77.0m, TheWalrus = "Crying" }; + var nownNum2 = new NownNum { Id = 78.0m, TheWalrus = "Walrus" }; - var numNum1 = new NumNum - { - TheWalrus = "I" - }; - var numNum2 = new NumNum - { - TheWalrus = "Am" - }; + var numNum1 = new NumNum { TheWalrus = "I" }; + var numNum2 = new NumNum { TheWalrus = "Am" }; - var anNum1 = new AnNum - { - TheWalrus = "Goo goo" - }; - var anNum2 = new AnNum - { - TheWalrus = "g'joob" - }; + var anNum1 = new AnNum { TheWalrus = "Goo goo" }; + var anNum2 = new AnNum { TheWalrus = "g'joob" }; - var adNum1 = new AdNum - { - TheWalrus = "Eggman" - }; - var adNum2 = new AdNum - { - TheWalrus = "Eggmen" - }; + var adNum1 = new AdNum { TheWalrus = "Eggman" }; + var adNum2 = new AdNum { TheWalrus = "Eggmen" }; - var byteNownNum1 = new ByteNownNum - { - Id = 77, - Lucy = "Tangerine" - }; - var byteNownNum2 = new ByteNownNum - { - Id = 78, - Lucy = "Trees" - }; + var byteNownNum1 = new ByteNownNum { Id = 77, Lucy = "Tangerine" }; + var byteNownNum2 = new ByteNownNum { Id = 78, Lucy = "Trees" }; - var byteNum1 = new ByteNum - { - Lucy = "Marmalade" - }; - var byteNum2 = new ByteNum - { - Lucy = "Skies" - }; + var byteNum1 = new ByteNum { Lucy = "Marmalade" }; + var byteNum2 = new ByteNum { Lucy = "Skies" }; - var byteAnNum1 = new ByteAnNum - { - Lucy = "Cellophane" - }; - var byteAnNum2 = new ByteAnNum - { - Lucy = "Flowers" - }; + var byteAnNum1 = new ByteAnNum { Lucy = "Cellophane" }; + var byteAnNum2 = new ByteAnNum { Lucy = "Flowers" }; - var byteAdNum1 = new ByteAdNum - { - Lucy = "Kaleidoscope" - }; - var byteAdNum2 = new ByteAdNum - { - Lucy = "Eyes" - }; + var byteAdNum1 = new ByteAdNum { Lucy = "Kaleidoscope" }; + var byteAdNum2 = new ByteAdNum { Lucy = "Eyes" }; decimal[] preSaveValues; byte[] preSaveByteValues; @@ -124,11 +72,9 @@ public void Can_use_decimal_and_byte_as_identity_columns() nownNum1, nownNum2, numNum1, numNum2, adNum1, adNum2, anNum1, anNum2, byteNownNum1, byteNownNum2, byteNum1, byteNum2, byteAdNum1, byteAdNum2, byteAnNum1, byteAnNum2); - preSaveValues = new[] - { numNum1.Id, numNum2.Id, adNum1.Id, adNum2.Id, anNum1.Id, anNum2.Id }; + preSaveValues = new[] { numNum1.Id, numNum2.Id, adNum1.Id, adNum2.Id, anNum1.Id, anNum2.Id }; - preSaveByteValues = new[] - { byteNum1.Id, byteNum2.Id, byteAdNum1.Id, byteAdNum2.Id, byteAnNum1.Id, byteAnNum2.Id }; + preSaveByteValues = new[] { byteNum1.Id, byteNum2.Id, byteAdNum1.Id, byteAdNum2.Id, byteAnNum1.Id, byteAnNum2.Id }; context.SaveChanges(); } @@ -284,34 +230,14 @@ public void Can_use_string_enum_or_byte_array_as_key() { using (var testDatabase = SqlServerTestStore.CreateInitialized(DatabaseName)) { - var sNum1 = new SNum - { - TheWalrus = "I" - }; - var sNum2 = new SNum - { - TheWalrus = "Am" - }; + var sNum1 = new SNum { TheWalrus = "I" }; + var sNum2 = new SNum { TheWalrus = "Am" }; - var enNum1 = new EnNum - { - TheWalrus = "Goo goo", - Id = ENum.BNum - }; - var enNum2 = new EnNum - { - TheWalrus = "g'joob", - Id = ENum.CNum - }; + var enNum1 = new EnNum { TheWalrus = "Goo goo", Id = ENum.BNum }; + var enNum2 = new EnNum { TheWalrus = "g'joob", Id = ENum.CNum }; - var bNum1 = new BNum - { - TheWalrus = "Eggman" - }; - var bNum2 = new BNum - { - TheWalrus = "Eggmen" - }; + var bNum1 = new BNum { TheWalrus = "Eggman" }; + var bNum2 = new BNum { TheWalrus = "Eggmen" }; var options = Fixture.CreateOptions(testDatabase); using (var context = new ENumContext(options)) @@ -342,14 +268,8 @@ public void Can_remove_multiple_byte_array_as_key() { using (var testDatabase = SqlServerTestStore.CreateInitialized(DatabaseName)) { - var bNum1 = new BNum - { - TheWalrus = "Eggman" - }; - var bNum2 = new BNum - { - TheWalrus = "Eggmen" - }; + var bNum1 = new BNum { TheWalrus = "Eggman" }; + var bNum2 = new BNum { TheWalrus = "Eggmen" }; var options = Fixture.CreateOptions(testDatabase); using (var context = new ENumContext(options)) @@ -389,6 +309,7 @@ private class SNum { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public string Id { get; set; } + public string TheWalrus { get; set; } } @@ -411,6 +332,7 @@ private class BNum { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public byte[] Id { get; set; } + public string TheWalrus { get; set; } } @@ -632,10 +554,7 @@ public void Can_track_an_entity_with_more_than_10_properties() context.Characters.Add( new PlayerCharacter( - new Level - { - Game = new Game() - })); + new Level { Game = new Game() })); context.SaveChanges(); } @@ -666,16 +585,9 @@ public void Adding_an_item_to_a_collection_marks_it_as_modified() context.Database.EnsureCreatedResiliently(); var player = new PlayerCharacter( - new Level - { - Game = new Game() - }); + new Level { Game = new Game() }); - var weapon = new Item - { - Id = 1, - Game = player.Game - }; + var weapon = new Item { Id = 1, Game = player.Game }; context.Characters.Add(player); @@ -702,16 +614,9 @@ public void Can_set_reference_twice() context.Database.EnsureCreatedResiliently(); var player = new PlayerCharacter( - new Level - { - Game = new Game() - }); + new Level { Game = new Game() }); - var weapon = new Item - { - Id = 1, - Game = player.Game - }; + var weapon = new Item { Id = 1, Game = player.Game }; player.Items.Add(weapon); context.Characters.Add(player); @@ -751,25 +656,14 @@ public void Can_include_on_loaded_entity() context.Database.EnsureCreatedResiliently(); var player = new PlayerCharacter( - new Level - { - Game = new Game() - }); + new Level { Game = new Game() }); - var weapon = new Item - { - Id = 1, - Game = player.Game - }; + var weapon = new Item { Id = 1, Game = player.Game }; player.Items.Add(weapon); player.Items.Add( - new Item - { - Id = 2, - Game = player.Game - }); + new Item { Id = 2, Game = player.Game }); context.Characters.Add(player); @@ -924,11 +818,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .ValueGeneratedNever(); eb.HasKey( - l => new - { - l.GameId, - l.Id - }); + l => new { l.GameId, l.Id }); }); modelBuilder.Entity( @@ -938,11 +828,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .ValueGeneratedNever(); eb.HasKey( - a => new - { - a.GameId, - a.Id - }); + a => new { a.GameId, a.Id }); eb.HasOne(a => a.Level) .WithMany(l => l.Actors) @@ -969,11 +855,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .ValueGeneratedNever(); eb.HasKey( - l => new - { - l.GameId, - l.Id - }); + l => new { l.GameId, l.Id }); }); modelBuilder.Entity(); @@ -1026,15 +908,9 @@ public async Task Can_save_and_query_with_schema() using (var context = new SchemaContext(options)) { context.Add( - new Jack - { - MyKey = 1 - }); + new Jack { MyKey = 1 }); context.Add( - new Black - { - MyKey = 2 - }); + new Black { MyKey = 2 }); context.SaveChanges(); } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerMigrationSqlGeneratorTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerMigrationSqlGeneratorTest.cs index 60b30dcd813..fa2e3cb8e81 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerMigrationSqlGeneratorTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerMigrationSqlGeneratorTest.cs @@ -60,7 +60,7 @@ public void CreateTableOperation_default_schema_with_comments() ClrType = typeof(string), IsNullable = false, Comment = "Name comment" - }, + } }, Comment = "Table comment" }); @@ -102,7 +102,7 @@ public void CreateTableOperation_default_schema_with_column_comments() ClrType = typeof(string), IsNullable = false, Comment = "Name comment" - }, + } } }); @@ -133,7 +133,8 @@ public override void CreateIndexOperation_with_filter_where_clause() { base.CreateIndexOperation_with_filter_where_clause(); - AssertSql(@"CREATE INDEX [IX_People_Name] ON [People] ([Name]) WHERE [Name] IS NOT NULL; + AssertSql( + @"CREATE INDEX [IX_People_Name] ON [People] ([Name]) WHERE [Name] IS NOT NULL; "); } @@ -141,7 +142,8 @@ public override void CreateIndexOperation_with_filter_where_clause_and_is_unique { base.CreateIndexOperation_with_filter_where_clause_and_is_unique(); - AssertSql(@"CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]) WHERE [Name] IS NOT NULL AND <> ''; + AssertSql( + @"CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]) WHERE [Name] IS NOT NULL AND <> ''; "); } @@ -149,12 +151,7 @@ public override void CreateIndexOperation_with_filter_where_clause_and_is_unique public void AlterTableOperation_with_new_comment() { Generate( - new AlterTableOperation - { - Name = "People", - Schema = "dbo", - Comment = "My Comment" - }); + new AlterTableOperation { Name = "People", Schema = "dbo", Comment = "My Comment" }); AssertSql( @"EXEC sp_addextendedproperty 'MS_Description', N'My Comment', 'SCHEMA', N'dbo', 'TABLE', N'People'; @@ -174,13 +171,7 @@ public void AlterTableOperation_with_different_comment_to_existing() }), new AlterTableOperation { - Schema = "dbo", - Name = "People", - Comment = "My Comment 2", - OldTable = new TableOperation - { - Comment = "My Comment" - } + Schema = "dbo", Name = "People", Comment = "My Comment 2", OldTable = new TableOperation { Comment = "My Comment" } }); AssertSql( @@ -200,15 +191,7 @@ public void AlterTableOperation_removing_comment() { x.HasComment("My Comment"); }), - new AlterTableOperation - { - Schema = "dbo", - Name = "People", - OldTable = new TableOperation - { - Comment = "My Comment" - } - }); + new AlterTableOperation { Schema = "dbo", Name = "People", OldTable = new TableOperation { Comment = "My Comment" } }); AssertSql( @"EXEC sp_dropextendedproperty 'MS_Description', 'SCHEMA', N'dbo', 'TABLE', N'People'; @@ -221,13 +204,11 @@ public virtual void AddColumnOperation_with_computedSql() Generate( new AddColumnOperation { - Table = "People", - Name = "FullName", - ClrType = typeof(string), - ComputedColumnSql = "FirstName + ' ' + LastName" + Table = "People", Name = "FullName", ClrType = typeof(string), ComputedColumnSql = "FirstName + ' ' + LastName" }); - AssertSql(@"ALTER TABLE [People] ADD [FullName] AS FirstName + ' ' + LastName; + AssertSql( + @"ALTER TABLE [People] ADD [FullName] AS FirstName + ' ' + LastName; "); } @@ -245,7 +226,8 @@ public void AddColumnOperation_with_computed_column_SQL() ComputedColumnSql = "CURRENT_TIMESTAMP" }); - AssertSql(@"ALTER TABLE [People] ADD [Birthday] AS CURRENT_TIMESTAMP; + AssertSql( + @"ALTER TABLE [People] ADD [Birthday] AS CURRENT_TIMESTAMP; "); } @@ -264,7 +246,8 @@ public virtual void AddColumnOperation_identity() [SqlServerAnnotationNames.Identity] = "1, 1" }); - AssertSql(@"ALTER TABLE [People] ADD [Id] int NOT NULL IDENTITY; + AssertSql( + @"ALTER TABLE [People] ADD [Id] int NOT NULL IDENTITY; "); } @@ -284,9 +267,11 @@ public virtual void AddColumnOperation_identity_legacy() SqlServerValueGenerationStrategy.IdentityColumn }); - AssertSql(@"ALTER TABLE [People] ADD [Id] int NOT NULL IDENTITY; + AssertSql( + @"ALTER TABLE [People] ADD [Id] int NOT NULL IDENTITY; "); } + [ConditionalFact] public virtual void AddColumnOperation_identity_seed_increment() { @@ -302,7 +287,8 @@ public virtual void AddColumnOperation_identity_seed_increment() [SqlServerAnnotationNames.Identity] = "100,5" }); - AssertSql(@"ALTER TABLE [People] ADD [Id] int NOT NULL IDENTITY(100,5); + AssertSql( + @"ALTER TABLE [People] ADD [Id] int NOT NULL IDENTITY(100,5); "); } @@ -310,7 +296,8 @@ public override void AddColumnOperation_without_column_type() { base.AddColumnOperation_without_column_type(); - AssertSql(@"ALTER TABLE [People] ADD [Alias] nvarchar(max) NOT NULL; + AssertSql( + @"ALTER TABLE [People] ADD [Alias] nvarchar(max) NOT NULL; "); } @@ -318,7 +305,8 @@ public override void AddColumnOperation_with_unicode_no_model() { base.AddColumnOperation_with_unicode_no_model(); - AssertSql(@"ALTER TABLE [Person] ADD [Name] varchar(max) NULL; + AssertSql( + @"ALTER TABLE [Person] ADD [Name] varchar(max) NULL; "); } @@ -326,7 +314,8 @@ public override void AddColumnOperation_with_maxLength() { base.AddColumnOperation_with_maxLength(); - AssertSql(@"ALTER TABLE [Person] ADD [Name] nvarchar(30) NULL; + AssertSql( + @"ALTER TABLE [Person] ADD [Name] nvarchar(30) NULL; "); } @@ -345,7 +334,8 @@ public virtual void AddColumnOperation_datetime_with_defaultValue() DefaultValue = new DateTime(2019, 1, 1) }); - AssertSql(@"ALTER TABLE [dbo].[People] ADD [Birthday] datetime NOT NULL DEFAULT '2019-01-01T00:00:00.000'; + AssertSql( + @"ALTER TABLE [dbo].[People] ADD [Birthday] datetime NOT NULL DEFAULT '2019-01-01T00:00:00.000'; "); } @@ -364,7 +354,8 @@ public virtual void AddColumnOperation_smalldatetime_with_defaultValue() DefaultValue = new DateTime(2019, 1, 1) }); - AssertSql(@"ALTER TABLE [dbo].[People] ADD [Birthday] smalldatetime NOT NULL DEFAULT '2019-01-01T00:00:00'; + AssertSql( + @"ALTER TABLE [dbo].[People] ADD [Birthday] smalldatetime NOT NULL DEFAULT '2019-01-01T00:00:00'; "); } @@ -372,7 +363,8 @@ public override void AddColumnOperation_with_maxLength_overridden() { base.AddColumnOperation_with_maxLength_overridden(); - AssertSql(@"ALTER TABLE [Person] ADD [Name] nvarchar(32) NULL; + AssertSql( + @"ALTER TABLE [Person] ADD [Name] nvarchar(32) NULL; "); } @@ -380,7 +372,8 @@ public override void AddColumnOperation_with_maxLength_on_derived() { base.AddColumnOperation_with_maxLength_on_derived(); - AssertSql(@"ALTER TABLE [Person] ADD [Name] nvarchar(30) NULL; + AssertSql( + @"ALTER TABLE [Person] ADD [Name] nvarchar(30) NULL; "); } @@ -388,7 +381,8 @@ public override void AddColumnOperation_with_ansi() { base.AddColumnOperation_with_ansi(); - AssertSql(@"ALTER TABLE [Person] ADD [Name] varchar(max) NULL; + AssertSql( + @"ALTER TABLE [Person] ADD [Name] varchar(max) NULL; "); } @@ -396,7 +390,8 @@ public override void AddColumnOperation_with_unicode_overridden() { base.AddColumnOperation_with_unicode_overridden(); - AssertSql(@"ALTER TABLE [Person] ADD [Name] nvarchar(max) NULL; + AssertSql( + @"ALTER TABLE [Person] ADD [Name] nvarchar(max) NULL; "); } @@ -404,7 +399,8 @@ public override void AddColumnOperation_with_shared_column() { base.AddColumnOperation_with_shared_column(); - AssertSql(@"ALTER TABLE [Base] ADD [Foo] nvarchar(max) NULL; + AssertSql( + @"ALTER TABLE [Base] ADD [Foo] nvarchar(max) NULL; "); } @@ -422,7 +418,8 @@ public virtual void AddColumnOperation_with_rowversion_overridden() IsNullable = true }); - AssertSql(@"ALTER TABLE [Person] ADD [RowVersion] rowversion NULL; + AssertSql( + @"ALTER TABLE [Person] ADD [RowVersion] rowversion NULL; "); } @@ -439,7 +436,8 @@ public virtual void AddColumnOperation_with_rowversion_no_model() IsNullable = true }); - AssertSql(@"ALTER TABLE [Person] ADD [RowVersion] rowversion NULL; + AssertSql( + @"ALTER TABLE [Person] ADD [RowVersion] rowversion NULL; "); } @@ -447,13 +445,7 @@ public virtual void AddColumnOperation_with_rowversion_no_model() public virtual void AddColumnOperation_with_comment() { Generate( - new AddColumnOperation - { - Table = "People", - Name = "FullName", - ClrType = typeof(string), - Comment = "My comment" - }); + new AddColumnOperation { Table = "People", Name = "FullName", ClrType = typeof(string), Comment = "My comment" }); AssertSql( @"ALTER TABLE [People] ADD [FullName] nvarchar(max) NOT NULL; @@ -486,14 +478,10 @@ public virtual void AddColumnOperation_with_comment_non_default_schema() public virtual void AddPrimaryKeyOperation_nonclustered() { Generate( - new AddPrimaryKeyOperation - { - Table = "People", - Columns = new[] { "Id" }, - [SqlServerAnnotationNames.Clustered] = false - }); + new AddPrimaryKeyOperation { Table = "People", Columns = new[] { "Id" }, [SqlServerAnnotationNames.Clustered] = false }); - AssertSql(@"ALTER TABLE [People] ADD PRIMARY KEY NONCLUSTERED ([Id]); + AssertSql( + @"ALTER TABLE [People] ADD PRIMARY KEY NONCLUSTERED ([Id]); "); } @@ -534,10 +522,7 @@ public virtual void AlterColumnOperation_with_identity() Generate( new AlterColumnOperation { - Table = "People", - Name = "Id", - ClrType = typeof(int), - [SqlServerAnnotationNames.Identity] = "1, 1" + Table = "People", Name = "Id", ClrType = typeof(int), [SqlServerAnnotationNames.Identity] = "1, 1" }); AssertSql( @@ -581,10 +566,7 @@ public void AlterColumnOperation_computed() Generate( new AlterColumnOperation { - Table = "People", - Name = "FullName", - ClrType = typeof(string), - ComputedColumnSql = "[FirstName] + ' ' + [LastName]" + Table = "People", Name = "FullName", ClrType = typeof(string), ComputedColumnSql = "[FirstName] + ' ' + [LastName]" }); AssertSql( @@ -618,11 +600,7 @@ public virtual void AlterColumnOperation_computed_with_index() Name = "FullName", ClrType = typeof(string), ComputedColumnSql = "[FirstName] + ' ' + [LastName]", - OldColumn = new ColumnOperation - { - ClrType = typeof(string), - ComputedColumnSql = "[LastName] + ', ' + [FirstName]" - } + OldColumn = new ColumnOperation { ClrType = typeof(string), ComputedColumnSql = "[LastName] + ', ' + [FirstName]" } }); AssertSql( @@ -660,6 +638,7 @@ public virtual void AlterColumnOperation_memoryOptimized_with_index(bool obsolet { x.IsMemoryOptimized(); } + x.Property("Name"); x.HasKey("Name"); x.HasIndex("Name"); @@ -670,10 +649,7 @@ public virtual void AlterColumnOperation_memoryOptimized_with_index(bool obsolet Name = "Name", ClrType = typeof(string), MaxLength = 30, - OldColumn = new ColumnOperation - { - ClrType = typeof(string) - } + OldColumn = new ColumnOperation { ClrType = typeof(string) } }); AssertSql( @@ -708,11 +684,7 @@ public virtual void AlterColumnOperation_with_index_no_narrowing() Name = "Name", ClrType = typeof(string), IsNullable = true, - OldColumn = new ColumnOperation - { - ClrType = typeof(string), - IsNullable = false - } + OldColumn = new ColumnOperation { ClrType = typeof(string), IsNullable = false } }); AssertSql( @@ -746,11 +718,7 @@ public virtual void AlterColumnOperation_with_index() ClrType = typeof(string), MaxLength = 30, IsNullable = true, - OldColumn = new ColumnOperation - { - ClrType = typeof(string), - IsNullable = true - } + OldColumn = new ColumnOperation { ClrType = typeof(string), IsNullable = true } }); AssertSql( @@ -800,11 +768,7 @@ public virtual void AlterColumnOperation_with_index_included_column(bool obsolet ClrType = typeof(string), MaxLength = 30, IsNullable = true, - OldColumn = new ColumnOperation - { - ClrType = typeof(string), - IsNullable = true - } + OldColumn = new ColumnOperation { ClrType = typeof(string), IsNullable = true } }); AssertSql( @@ -841,11 +805,7 @@ public virtual void AlterColumnOperation_with_index_no_included() ClrType = typeof(string), MaxLength = 30, IsNullable = true, - OldColumn = new ColumnOperation - { - ClrType = typeof(string), - IsNullable = true - } + OldColumn = new ColumnOperation { ClrType = typeof(string), IsNullable = true } }); AssertSql( @@ -912,11 +872,7 @@ public virtual void AlterColumnOperation_with_composite_index() Name = "FirstName", ClrType = typeof(string), IsNullable = false, - OldColumn = new ColumnOperation - { - ClrType = typeof(string), - IsNullable = true - } + OldColumn = new ColumnOperation { ClrType = typeof(string), IsNullable = true } }); AssertSql( @@ -951,18 +907,9 @@ public virtual void AlterColumnOperation_with_added_index() ClrType = typeof(string), MaxLength = 30, IsNullable = true, - OldColumn = new ColumnOperation - { - ClrType = typeof(string), - IsNullable = true - } + OldColumn = new ColumnOperation { ClrType = typeof(string), IsNullable = true } }, - new CreateIndexOperation - { - Name = "IX_Person_Name", - Table = "Person", - Columns = new[] { "Name" } - }); + new CreateIndexOperation { Name = "IX_Person_Name", Table = "Person", Columns = new[] { "Name" } }); AssertSql( @"DECLARE @var0 sysname; @@ -1009,11 +956,7 @@ public virtual void AlterColumnOperation_with_added_online_index(bool obsolete) ClrType = typeof(string), MaxLength = 30, IsNullable = true, - OldColumn = new ColumnOperation - { - ClrType = typeof(string), - IsNullable = true - } + OldColumn = new ColumnOperation { ClrType = typeof(string), IsNullable = true } }, new CreateIndexOperation { @@ -1048,11 +991,7 @@ public virtual void AlterColumnOperation_identity() Name = "Id", ClrType = typeof(long), [SqlServerAnnotationNames.Identity] = "1, 1", - OldColumn = new ColumnOperation - { - ClrType = typeof(int), - [SqlServerAnnotationNames.Identity] = "1, 1" - } + OldColumn = new ColumnOperation { ClrType = typeof(int), [SqlServerAnnotationNames.Identity] = "1, 1" } }); AssertSql( @@ -1107,10 +1046,7 @@ public virtual void AlterColumnOperation_add_identity() Name = "Id", ClrType = typeof(int), [SqlServerAnnotationNames.Identity] = "1, 1", - OldColumn = new ColumnOperation - { - ClrType = typeof(int) - } + OldColumn = new ColumnOperation { ClrType = typeof(int) } })); Assert.Equal(SqlServerStrings.AlterIdentityColumn, ex.Message); @@ -1128,10 +1064,7 @@ public virtual void AlterColumnOperation_add_identity_legacy() Name = "Id", ClrType = typeof(int), [SqlServerAnnotationNames.ValueGenerationStrategy] = SqlServerValueGenerationStrategy.IdentityColumn, - OldColumn = new ColumnOperation - { - ClrType = typeof(int) - } + OldColumn = new ColumnOperation { ClrType = typeof(int) } })); Assert.Equal(SqlServerStrings.AlterIdentityColumn, ex.Message); @@ -1148,11 +1081,7 @@ public virtual void AlterColumnOperation_remove_identity() Table = "Person", Name = "Id", ClrType = typeof(int), - OldColumn = new ColumnOperation - { - ClrType = typeof(int), - [SqlServerAnnotationNames.Identity] = "1, 1" - } + OldColumn = new ColumnOperation { ClrType = typeof(int), [SqlServerAnnotationNames.Identity] = "1, 1" } })); Assert.Equal(SqlServerStrings.AlterIdentityColumn, ex.Message); @@ -1225,12 +1154,7 @@ public void AlterColumnOperation_with_different_comment_to_existing() ClrType = typeof(string), IsNullable = false, Comment = "My Comment 2", - OldColumn = new ColumnOperation - { - ClrType = typeof(string), - IsNullable = true, - Comment = "My Comment" - } + OldColumn = new ColumnOperation { ClrType = typeof(string), IsNullable = true, Comment = "My Comment" } }); AssertSql( @@ -1264,12 +1188,7 @@ public void AlterColumnOperation_removing_comment() Name = "Name", ClrType = typeof(string), IsNullable = false, - OldColumn = new ColumnOperation - { - ClrType = typeof(string), - IsNullable = true, - Comment = "My Comment" - } + OldColumn = new ColumnOperation { ClrType = typeof(string), IsNullable = true, Comment = "My Comment" } }); AssertSql( @@ -1288,10 +1207,7 @@ FROM [sys].[default_constraints] [d] public virtual void CreateDatabaseOperation() { Generate( - new SqlServerCreateDatabaseOperation - { - Name = "Northwind" - }); + new SqlServerCreateDatabaseOperation { Name = "Northwind" }); AssertSql( @"CREATE DATABASE [Northwind]; @@ -1308,11 +1224,7 @@ IF SERVERPROPERTY('EngineEdition') <> 5 public virtual void CreateDatabaseOperation_with_filename() { Generate( - new SqlServerCreateDatabaseOperation - { - Name = "Northwind", - FileName = "Narf.mdf" - }); + new SqlServerCreateDatabaseOperation { Name = "Northwind", FileName = "Narf.mdf" }); var expectedFile = Path.GetFullPath("Narf.mdf"); var expectedLog = Path.GetFullPath("Narf_log.ldf"); @@ -1336,11 +1248,7 @@ public virtual void CreateDatabaseOperation_with_filename_and_datadirectory() var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; Generate( - new SqlServerCreateDatabaseOperation - { - Name = "Northwind", - FileName = "|DataDirectory|Narf.mdf" - }); + new SqlServerCreateDatabaseOperation { Name = "Northwind", FileName = "|DataDirectory|Narf.mdf" }); var expectedFile = Path.Combine(baseDirectory, "Narf.mdf"); var expectedLog = Path.Combine(baseDirectory, "Narf_log.ldf"); @@ -1366,11 +1274,7 @@ public virtual void CreateDatabaseOperation_with_filename_and_custom_datadirecto AppDomain.CurrentDomain.SetData("DataDirectory", dataDirectory); Generate( - new SqlServerCreateDatabaseOperation - { - Name = "Northwind", - FileName = "|DataDirectory|Narf.mdf" - }); + new SqlServerCreateDatabaseOperation { Name = "Northwind", FileName = "|DataDirectory|Narf.mdf" }); AppDomain.CurrentDomain.SetData("DataDirectory", null); @@ -1394,10 +1298,7 @@ IF SERVERPROPERTY('EngineEdition') <> 5 public virtual void AlterDatabaseOperationOperation() { Generate( - new AlterDatabaseOperation - { - [SqlServerAnnotationNames.MemoryOptimized] = true - }); + new AlterDatabaseOperation { [SqlServerAnnotationNames.MemoryOptimized] = true }); Assert.Contains( "CONTAINS MEMORY_OPTIMIZED_DATA;", @@ -1408,7 +1309,8 @@ public override void CreateIndexOperation_nonunique() { base.CreateIndexOperation_nonunique(); - AssertSql(@"CREATE INDEX [IX_People_Name] ON [People] ([Name]); + AssertSql( + @"CREATE INDEX [IX_People_Name] ON [People] ([Name]); "); } @@ -1416,7 +1318,8 @@ public override void CreateIndexOperation_unique() { base.CreateIndexOperation_unique(); - AssertSql(@"CREATE UNIQUE INDEX [IX_People_Name] ON [dbo].[People] ([FirstName], [LastName]) WHERE [FirstName] IS NOT NULL AND [LastName] IS NOT NULL; + AssertSql( + @"CREATE UNIQUE INDEX [IX_People_Name] ON [dbo].[People] ([FirstName], [LastName]) WHERE [FirstName] IS NOT NULL AND [LastName] IS NOT NULL; "); } @@ -1434,7 +1337,8 @@ public virtual void CreateIndexOperation_unique_non_legacy() IsUnique = true }); - AssertSql(@"CREATE UNIQUE INDEX [IX_People_Name] ON [dbo].[People] ([FirstName], [LastName]); + AssertSql( + @"CREATE UNIQUE INDEX [IX_People_Name] ON [dbo].[People] ([FirstName], [LastName]); "); } @@ -1444,13 +1348,11 @@ public virtual void CreateIndexOperation_clustered() Generate( new CreateIndexOperation { - Name = "IX_People_Name", - Table = "People", - Columns = new[] { "Name" }, - [SqlServerAnnotationNames.Clustered] = true + Name = "IX_People_Name", Table = "People", Columns = new[] { "Name" }, [SqlServerAnnotationNames.Clustered] = true }); - AssertSql(@"CREATE CLUSTERED INDEX [IX_People_Name] ON [People] ([Name]); + AssertSql( + @"CREATE CLUSTERED INDEX [IX_People_Name] ON [People] ([Name]); "); } @@ -1467,7 +1369,8 @@ public virtual void CreateIndexOperation_unique_clustered() [SqlServerAnnotationNames.Clustered] = true }); - AssertSql(@"CREATE UNIQUE CLUSTERED INDEX [IX_People_Name] ON [People] ([Name]); + AssertSql( + @"CREATE UNIQUE CLUSTERED INDEX [IX_People_Name] ON [People] ([Name]); "); } @@ -1483,7 +1386,8 @@ public virtual void CreateIndexOperation_with_include() [SqlServerAnnotationNames.Include] = new[] { "FirstName", "LastName" } }); - AssertSql(@"CREATE INDEX [IX_People_Name] ON [People] ([Name]) INCLUDE ([FirstName], [LastName]); + AssertSql( + @"CREATE INDEX [IX_People_Name] ON [People] ([Name]) INCLUDE ([FirstName], [LastName]); "); } @@ -1500,7 +1404,8 @@ public virtual void CreateIndexOperation_with_include_and_filter() [SqlServerAnnotationNames.Include] = new[] { "FirstName", "LastName" } }); - AssertSql(@"CREATE INDEX [IX_People_Name] ON [People] ([Name]) INCLUDE ([FirstName], [LastName]) WHERE [Name] IS NOT NULL AND <> ''; + AssertSql( + @"CREATE INDEX [IX_People_Name] ON [People] ([Name]) INCLUDE ([FirstName], [LastName]) WHERE [Name] IS NOT NULL AND <> ''; "); } @@ -1517,7 +1422,8 @@ public virtual void CreateIndexOperation_unique_with_include() [SqlServerAnnotationNames.Include] = new[] { "FirstName", "LastName" } }); - AssertSql(@"CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]) INCLUDE ([FirstName], [LastName]) WHERE [Name] IS NOT NULL; + AssertSql( + @"CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]) INCLUDE ([FirstName], [LastName]) WHERE [Name] IS NOT NULL; "); } @@ -1535,7 +1441,8 @@ public virtual void CreateIndexOperation_unique_with_include_and_filter() [SqlServerAnnotationNames.Include] = new[] { "FirstName", "LastName" } }); - AssertSql(@"CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]) INCLUDE ([FirstName], [LastName]) WHERE [Name] IS NOT NULL AND <> ''; + AssertSql( + @"CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]) INCLUDE ([FirstName], [LastName]) WHERE [Name] IS NOT NULL AND <> ''; "); } @@ -1554,7 +1461,8 @@ public virtual void CreateIndexOperation_unique_with_include_and_filter_online() [SqlServerAnnotationNames.CreatedOnline] = true }); - AssertSql(@"CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]) INCLUDE ([FirstName], [LastName]) WHERE [Name] IS NOT NULL AND <> '' WITH (ONLINE = ON); + AssertSql( + @"CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]) INCLUDE ([FirstName], [LastName]) WHERE [Name] IS NOT NULL AND <> '' WITH (ONLINE = ON); "); } @@ -1572,7 +1480,8 @@ public virtual void CreateIndexOperation_unique_with_include_non_legacy() [SqlServerAnnotationNames.Include] = new[] { "FirstName", "LastName" } }); - AssertSql(@"CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]) INCLUDE ([FirstName], [LastName]); + AssertSql( + @"CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]) INCLUDE ([FirstName], [LastName]); "); } @@ -1581,15 +1490,10 @@ public virtual void CreateIndexOperation_unique_bound_null() { Generate( modelBuilder => modelBuilder.Entity("People").Property("Name"), - new CreateIndexOperation - { - Name = "IX_People_Name", - Table = "People", - Columns = new[] { "Name" }, - IsUnique = true - }); + new CreateIndexOperation { Name = "IX_People_Name", Table = "People", Columns = new[] { "Name" }, IsUnique = true }); - AssertSql(@"CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]) WHERE [Name] IS NOT NULL; + AssertSql( + @"CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]) WHERE [Name] IS NOT NULL; "); } @@ -1597,20 +1501,16 @@ public virtual void CreateIndexOperation_unique_bound_null() public virtual void CreateIndexOperation_unique_bound_not_null() { Generate( - modelBuilder => modelBuilder.Entity("People", x => - { - x.Property("Name").IsRequired(); - x.HasKey("Name"); - }), - new CreateIndexOperation - { - Name = "IX_People_Name", - Table = "People", - Columns = new[] { "Name" }, - IsUnique = true - }); + modelBuilder => modelBuilder.Entity( + "People", x => + { + x.Property("Name").IsRequired(); + x.HasKey("Name"); + }), + new CreateIndexOperation { Name = "IX_People_Name", Table = "People", Columns = new[] { "Name" }, IsUnique = true }); - AssertSql(@"CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]); + AssertSql( + @"CREATE UNIQUE INDEX [IX_People_Name] ON [People] ([Name]); "); } @@ -1620,21 +1520,23 @@ public virtual void CreateIndexOperation_unique_bound_not_null() public virtual void CreateIndexOperation_memoryOptimized_unique_nullable(bool obsolete) { Generate( - modelBuilder => modelBuilder.Entity("People", x => - { - if (obsolete) + modelBuilder => modelBuilder.Entity( + "People", x => { + if (obsolete) + { #pragma warning disable 618 - x.ToTable("People", "dbo").ForSqlServerIsMemoryOptimized().Property("Name"); + x.ToTable("People", "dbo").ForSqlServerIsMemoryOptimized().Property("Name"); #pragma warning restore 618 - } - else - { - x.ToTable("People", "dbo").IsMemoryOptimized().Property("Name"); - } - x.Property("Id"); - x.HasKey("Id"); - }), + } + else + { + x.ToTable("People", "dbo").IsMemoryOptimized().Property("Name"); + } + + x.Property("Id"); + x.HasKey("Id"); + }), new CreateIndexOperation { Name = "IX_People_Name", @@ -1644,7 +1546,8 @@ public virtual void CreateIndexOperation_memoryOptimized_unique_nullable(bool ob IsUnique = true }); - AssertSql(@"ALTER TABLE [dbo].[People] ADD INDEX [IX_People_Name] ([Name]); + AssertSql( + @"ALTER TABLE [dbo].[People] ADD INDEX [IX_People_Name] ([Name]); "); } @@ -1654,21 +1557,23 @@ public virtual void CreateIndexOperation_memoryOptimized_unique_nullable(bool ob public virtual void CreateIndexOperation_memoryOptimized_unique_nullable_with_filter(bool obsolete) { Generate( - modelBuilder => modelBuilder.Entity("People", x => - { - if (obsolete) + modelBuilder => modelBuilder.Entity( + "People", x => { + if (obsolete) + { #pragma warning disable 618 - x.ForSqlServerIsMemoryOptimized().Property("Name"); + x.ForSqlServerIsMemoryOptimized().Property("Name"); #pragma warning restore 618 - } - else - { - x.IsMemoryOptimized().Property("Name"); - } - x.Property("Id"); - x.HasKey("Id"); - }), + } + else + { + x.IsMemoryOptimized().Property("Name"); + } + + x.Property("Id"); + x.HasKey("Id"); + }), new CreateIndexOperation { Name = "IX_People_Name", @@ -1678,7 +1583,8 @@ public virtual void CreateIndexOperation_memoryOptimized_unique_nullable_with_fi Filter = "[Name] IS NOT NULL AND <> ''" }); - AssertSql(@"ALTER TABLE [People] ADD INDEX [IX_People_Name] ([Name]); + AssertSql( + @"ALTER TABLE [People] ADD INDEX [IX_People_Name] ([Name]); "); } @@ -1688,20 +1594,22 @@ public virtual void CreateIndexOperation_memoryOptimized_unique_nullable_with_fi public virtual void CreateIndexOperation_memoryOptimized_unique_nonclustered_not_nullable(bool obsolete) { Generate( - modelBuilder => modelBuilder.Entity("People", x => - { - if (obsolete) + modelBuilder => modelBuilder.Entity( + "People", x => { + if (obsolete) + { #pragma warning disable 618 - x.ForSqlServerIsMemoryOptimized().Property("Name").IsRequired(); + x.ForSqlServerIsMemoryOptimized().Property("Name").IsRequired(); #pragma warning restore 618 - } - else - { - x.IsMemoryOptimized().Property("Name").IsRequired(); - } - x.HasKey("Name"); - }), + } + else + { + x.IsMemoryOptimized().Property("Name").IsRequired(); + } + + x.HasKey("Name"); + }), new CreateIndexOperation { Name = "IX_People_Name", @@ -1711,7 +1619,8 @@ public virtual void CreateIndexOperation_memoryOptimized_unique_nonclustered_not [SqlServerAnnotationNames.Clustered] = false }); - AssertSql(@"ALTER TABLE [People] ADD INDEX [IX_People_Name] UNIQUE NONCLUSTERED ([Name]); + AssertSql( + @"ALTER TABLE [People] ADD INDEX [IX_People_Name] UNIQUE NONCLUSTERED ([Name]); "); } @@ -1719,12 +1628,10 @@ public virtual void CreateIndexOperation_memoryOptimized_unique_nonclustered_not public virtual void CreateSchemaOperation() { Generate( - new EnsureSchemaOperation - { - Name = "my" - }); + new EnsureSchemaOperation { Name = "my" }); - AssertSql(@"IF SCHEMA_ID(N'my') IS NULL EXEC(N'CREATE SCHEMA [my];'); + AssertSql( + @"IF SCHEMA_ID(N'my') IS NULL EXEC(N'CREATE SCHEMA [my];'); "); } @@ -1732,10 +1639,7 @@ public virtual void CreateSchemaOperation() public virtual void CreateSchemaOperation_dbo() { Generate( - new EnsureSchemaOperation - { - Name = "dbo" - }); + new EnsureSchemaOperation { Name = "dbo" }); AssertSql(""); } @@ -1759,10 +1663,7 @@ FROM [sys].[default_constraints] [d] public virtual void DropDatabaseOperation() { Generate( - new SqlServerDropDatabaseOperation - { - Name = "Northwind" - }); + new SqlServerDropDatabaseOperation { Name = "Northwind" }); AssertSql( @"IF SERVERPROPERTY('EngineEdition') <> 5 @@ -1779,7 +1680,8 @@ public override void DropIndexOperation() { base.DropIndexOperation(); - AssertSql(@"DROP INDEX [IX_People_Name] ON [dbo].[People]; + AssertSql( + @"DROP INDEX [IX_People_Name] ON [dbo].[People]; "); } @@ -1789,28 +1691,27 @@ public override void DropIndexOperation() public virtual void DropIndexOperation_memoryOptimized(bool obsolete) { Generate( - modelBuilder => modelBuilder.Entity("People", x => - { - if (obsolete) + modelBuilder => modelBuilder.Entity( + "People", x => { + if (obsolete) + { #pragma warning disable 618 - x.ForSqlServerIsMemoryOptimized(); + x.ForSqlServerIsMemoryOptimized(); #pragma warning restore 618 - } - else - { - x.IsMemoryOptimized(); - } - x.Property("Id"); - x.HasKey("Id"); - }), - new DropIndexOperation - { - Name = "IX_People_Name", - Table = "People" - }); + } + else + { + x.IsMemoryOptimized(); + } + + x.Property("Id"); + x.HasKey("Id"); + }), + new DropIndexOperation { Name = "IX_People_Name", Table = "People" }); - AssertSql(@"ALTER TABLE [People] DROP INDEX [IX_People_Name]; + AssertSql( + @"ALTER TABLE [People] DROP INDEX [IX_People_Name]; "); } @@ -1818,14 +1719,10 @@ public virtual void DropIndexOperation_memoryOptimized(bool obsolete) public virtual void MoveSequenceOperation_legacy() { Generate( - new RenameSequenceOperation - { - Name = "EntityFrameworkHiLoSequence", - Schema = "dbo", - NewSchema = "my" - }); + new RenameSequenceOperation { Name = "EntityFrameworkHiLoSequence", Schema = "dbo", NewSchema = "my" }); - AssertSql(@"ALTER SCHEMA [my] TRANSFER [dbo].[EntityFrameworkHiLoSequence]; + AssertSql( + @"ALTER SCHEMA [my] TRANSFER [dbo].[EntityFrameworkHiLoSequence]; "); } @@ -1836,13 +1733,11 @@ public virtual void MoveSequenceOperation() modelBuilder => modelBuilder.HasAnnotation(CoreAnnotationNames.ProductVersion, "2.1.0"), new RenameSequenceOperation { - Name = "EntityFrameworkHiLoSequence", - Schema = "dbo", - NewName = "EntityFrameworkHiLoSequence", - NewSchema = "my" + Name = "EntityFrameworkHiLoSequence", Schema = "dbo", NewName = "EntityFrameworkHiLoSequence", NewSchema = "my" }); - AssertSql(@"ALTER SCHEMA [my] TRANSFER [dbo].[EntityFrameworkHiLoSequence]; + AssertSql( + @"ALTER SCHEMA [my] TRANSFER [dbo].[EntityFrameworkHiLoSequence]; "); } @@ -1853,9 +1748,7 @@ public virtual void MoveSequenceOperation_into_default() modelBuilder => modelBuilder.HasAnnotation(CoreAnnotationNames.ProductVersion, "2.1.0"), new RenameSequenceOperation { - Name = "EntityFrameworkHiLoSequence", - Schema = "dbo", - NewName = "EntityFrameworkHiLoSequence" + Name = "EntityFrameworkHiLoSequence", Schema = "dbo", NewName = "EntityFrameworkHiLoSequence" }); AssertSql( @@ -1868,14 +1761,10 @@ public virtual void MoveSequenceOperation_into_default() public virtual void MoveTableOperation_legacy() { Generate( - new RenameTableOperation - { - Name = "People", - Schema = "dbo", - NewSchema = "hr" - }); + new RenameTableOperation { Name = "People", Schema = "dbo", NewSchema = "hr" }); - AssertSql(@"ALTER SCHEMA [hr] TRANSFER [dbo].[People]; + AssertSql( + @"ALTER SCHEMA [hr] TRANSFER [dbo].[People]; "); } @@ -1884,15 +1773,10 @@ public virtual void MoveTableOperation() { Generate( modelBuilder => modelBuilder.HasAnnotation(CoreAnnotationNames.ProductVersion, "2.1.0"), - new RenameTableOperation - { - Name = "People", - Schema = "dbo", - NewName = "People", - NewSchema = "hr" - }); + new RenameTableOperation { Name = "People", Schema = "dbo", NewName = "People", NewSchema = "hr" }); - AssertSql(@"ALTER SCHEMA [hr] TRANSFER [dbo].[People]; + AssertSql( + @"ALTER SCHEMA [hr] TRANSFER [dbo].[People]; "); } @@ -1901,12 +1785,7 @@ public virtual void MoveTableOperation_into_default() { Generate( modelBuilder => modelBuilder.HasAnnotation(CoreAnnotationNames.ProductVersion, "2.1.0"), - new RenameTableOperation - { - Name = "People", - Schema = "dbo", - NewName = "People" - }); + new RenameTableOperation { Name = "People", Schema = "dbo", NewName = "People" }); AssertSql( @"DECLARE @defaultSchema sysname = SCHEMA_NAME(); @@ -1918,15 +1797,10 @@ public virtual void MoveTableOperation_into_default() public virtual void RenameColumnOperation() { Generate( - new RenameColumnOperation - { - Table = "People", - Schema = "dbo", - Name = "Name", - NewName = "FullName" - }); + new RenameColumnOperation { Table = "People", Schema = "dbo", Name = "Name", NewName = "FullName" }); - AssertSql(@"EXEC sp_rename N'[dbo].[People].[Name]', N'FullName', N'COLUMN'; + AssertSql( + @"EXEC sp_rename N'[dbo].[People].[Name]', N'FullName', N'COLUMN'; "); } @@ -1934,15 +1808,10 @@ public virtual void RenameColumnOperation() public virtual void RenameIndexOperation() { Generate( - new RenameIndexOperation - { - Table = "People", - Schema = "dbo", - Name = "IX_People_Name", - NewName = "IX_People_FullName" - }); + new RenameIndexOperation { Table = "People", Schema = "dbo", Name = "IX_People_Name", NewName = "IX_People_FullName" }); - AssertSql(@"EXEC sp_rename N'[dbo].[People].[IX_People_Name]', N'IX_People_FullName', N'INDEX'; + AssertSql( + @"EXEC sp_rename N'[dbo].[People].[IX_People_Name]', N'IX_People_FullName', N'INDEX'; "); } @@ -1965,14 +1834,10 @@ public virtual void RenameIndexOperations_throws_when_no_table() public virtual void RenameSequenceOperation_legacy() { Generate( - new RenameSequenceOperation - { - Name = "EntityFrameworkHiLoSequence", - Schema = "dbo", - NewName = "MySequence" - }); + new RenameSequenceOperation { Name = "EntityFrameworkHiLoSequence", Schema = "dbo", NewName = "MySequence" }); - AssertSql(@"EXEC sp_rename N'[dbo].[EntityFrameworkHiLoSequence]', N'MySequence'; + AssertSql( + @"EXEC sp_rename N'[dbo].[EntityFrameworkHiLoSequence]', N'MySequence'; "); } @@ -1983,13 +1848,11 @@ public virtual void RenameSequenceOperation() modelBuilder => modelBuilder.HasAnnotation(CoreAnnotationNames.ProductVersion, "2.1.0"), new RenameSequenceOperation { - Name = "EntityFrameworkHiLoSequence", - Schema = "dbo", - NewName = "MySequence", - NewSchema = "dbo" + Name = "EntityFrameworkHiLoSequence", Schema = "dbo", NewName = "MySequence", NewSchema = "dbo" }); - AssertSql(@"EXEC sp_rename N'[dbo].[EntityFrameworkHiLoSequence]', N'MySequence'; + AssertSql( + @"EXEC sp_rename N'[dbo].[EntityFrameworkHiLoSequence]', N'MySequence'; "); } @@ -1998,7 +1861,8 @@ public override void RenameTableOperation_legacy() { base.RenameTableOperation_legacy(); - AssertSql(@"EXEC sp_rename N'[dbo].[People]', N'Person'; + AssertSql( + @"EXEC sp_rename N'[dbo].[People]', N'Person'; "); } @@ -2007,7 +1871,8 @@ public override void RenameTableOperation() { base.RenameTableOperation(); - AssertSql(@"EXEC sp_rename N'[dbo].[People]', N'Person'; + AssertSql( + @"EXEC sp_rename N'[dbo].[People]', N'Person'; "); } @@ -2021,7 +1886,8 @@ public virtual void SqlOperation_handles_backslash() "comment" }); - AssertSql(@"-- Multiline comment + AssertSql( + @"-- Multiline comment "); } @@ -2036,7 +1902,8 @@ public virtual void SqlOperation_ignores_sequential_gos() "GO" }); - AssertSql(@"-- Ready set + AssertSql( + @"-- Ready set "); } @@ -2081,12 +1948,10 @@ public virtual void SqlOperation_handles_go_with_count() public virtual void SqlOperation_ignores_non_go() { Generate( - new SqlOperation - { - Sql = "-- I GO 2" - }); + new SqlOperation { Sql = "-- I GO 2" }); - AssertSql(@"-- I GO 2 + AssertSql( + @"-- I GO 2 "); } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerQueryTriggersTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerQueryTriggersTest.cs index 82c6a6850ec..89c2311dcdc 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerQueryTriggersTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerQueryTriggersTest.cs @@ -20,10 +20,7 @@ public void Triggers_with_subqueries_run_on_insert_update_and_delete() { using (var context = CreateContext()) { - var product = new Product - { - Name = "blah" - }; + var product = new Product { Name = "blah" }; context.Products.Add(product); context.SaveChanges(); @@ -46,38 +43,20 @@ public void Triggers_with_subqueries_work_with_batch_operations() { using (var context = CreateContext()) { - var productToBeUpdated1 = new Product - { - Name = "u1" - }; - var productToBeUpdated2 = new Product - { - Name = "u2" - }; + var productToBeUpdated1 = new Product { Name = "u1" }; + var productToBeUpdated2 = new Product { Name = "u2" }; context.Products.Add(productToBeUpdated1); context.Products.Add(productToBeUpdated2); - var productToBeDeleted1 = new Product - { - Name = "d1" - }; - var productToBeDeleted2 = new Product - { - Name = "d2" - }; + var productToBeDeleted1 = new Product { Name = "d1" }; + var productToBeDeleted2 = new Product { Name = "d2" }; context.Products.Add(productToBeDeleted1); context.Products.Add(productToBeDeleted2); context.SaveChanges(); - var productToBeAdded1 = new Product - { - Name = "a1" - }; - var productToBeAdded2 = new Product - { - Name = "a2" - }; + var productToBeAdded1 = new Product { Name = "a1" }; + var productToBeAdded2 = new Product { Name = "a2" }; context.Products.Add(productToBeAdded1); context.Products.Add(productToBeAdded2); diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerTriggersTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerTriggersTest.cs index f3794c766ee..755b734cab8 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerTriggersTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerTriggersTest.cs @@ -21,10 +21,7 @@ public void Triggers_run_on_insert_update_and_delete() { using (var context = CreateContext()) { - var product = new Product - { - Name = "blah" - }; + var product = new Product { Name = "blah" }; context.Products.Add(product); context.SaveChanges(); @@ -52,38 +49,20 @@ public void Triggers_work_with_batch_operations() { using (var context = CreateContext()) { - var productToBeUpdated1 = new Product - { - Name = "u1" - }; - var productToBeUpdated2 = new Product - { - Name = "u2" - }; + var productToBeUpdated1 = new Product { Name = "u1" }; + var productToBeUpdated2 = new Product { Name = "u2" }; context.Products.Add(productToBeUpdated1); context.Products.Add(productToBeUpdated2); - var productToBeDeleted1 = new Product - { - Name = "d1" - }; - var productToBeDeleted2 = new Product - { - Name = "d2" - }; + var productToBeDeleted1 = new Product { Name = "d1" }; + var productToBeDeleted2 = new Product { Name = "d2" }; context.Products.Add(productToBeDeleted1); context.Products.Add(productToBeDeleted2); context.SaveChanges(); - var productToBeAdded1 = new Product - { - Name = "a1" - }; - var productToBeAdded2 = new Product - { - Name = "a2" - }; + var productToBeAdded1 = new Product { Name = "a1" }; + var productToBeAdded2 = new Product { Name = "a2" }; context.Products.Add(productToBeAdded1); context.Products.Add(productToBeAdded2); diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationScenariosTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationScenariosTest.cs index 97c22d58b81..eb6d669d58c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationScenariosTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationScenariosTest.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; // ReSharper disable InconsistentNaming @@ -31,13 +30,7 @@ public void Insert_with_Identity_column() context.Database.EnsureCreatedResiliently(); context.AddRange( - new Blog - { - Name = "One Unicorn" - }, new Blog - { - Name = "Two Unicorns" - }); + new Blog { Name = "One Unicorn" }, new Blog { Name = "Two Unicorns" }); context.SaveChanges(); } @@ -71,13 +64,7 @@ public void Insert_with_sequence_HiLo() context.Database.EnsureCreatedResiliently(); context.AddRange( - new Blog - { - Name = "One Unicorn" - }, new Blog - { - Name = "Two Unicorns" - }); + new Blog { Name = "One Unicorn" }, new Blog { Name = "Two Unicorns" }); context.SaveChanges(); } @@ -109,10 +96,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) eb => { eb.HasAlternateKey( - b => new - { - b.OtherId - }); + b => new { b.OtherId }); eb.Property(b => b.OtherId).ValueGeneratedOnAdd(); }); } @@ -129,13 +113,7 @@ public void Insert_with_default_value_from_sequence() context.Database.EnsureCreatedResiliently(); context.AddRange( - new Blog - { - Name = "One Unicorn" - }, new Blog - { - Name = "Two Unicorns" - }); + new Blog { Name = "One Unicorn" }, new Blog { Name = "Two Unicorns" }); context.SaveChanges(); } @@ -151,13 +129,7 @@ public void Insert_with_default_value_from_sequence() using (var context = new BlogContextDefaultValueNoMigrations(testStore.Name)) { context.AddRange( - new Blog - { - Name = "One Unicorn" - }, new Blog - { - Name = "Two Unicorns" - }); + new Blog { Name = "One Unicorn" }, new Blog { Name = "Two Unicorns" }); context.SaveChanges(); } @@ -221,13 +193,7 @@ public void Insert_with_default_string_value_from_sequence() context.Database.EnsureCreatedResiliently(); context.AddRange( - new BlogWithStringKey - { - Name = "One Unicorn" - }, new BlogWithStringKey - { - Name = "Two Unicorns" - }); + new BlogWithStringKey { Name = "One Unicorn" }, new BlogWithStringKey { Name = "Two Unicorns" }); context.SaveChanges(); } @@ -283,13 +249,7 @@ public void Insert_with_key_default_value_from_sequence() context.Database.EnsureCreatedResiliently(); context.AddRange( - new Blog - { - Name = "One Unicorn" - }, new Blog - { - Name = "Two Unicorns" - }); + new Blog { Name = "One Unicorn" }, new Blog { Name = "Two Unicorns" }); context.SaveChanges(); } @@ -335,15 +295,7 @@ public void Insert_with_explicit_non_default_keys() context.Database.EnsureCreatedResiliently(); context.AddRange( - new Blog - { - Id = 66, - Name = "One Unicorn" - }, new Blog - { - Id = 67, - Name = "Two Unicorns" - }); + new Blog { Id = 66, Name = "One Unicorn" }, new Blog { Id = 67, Name = "Two Unicorns" }); context.SaveChanges(); } @@ -384,16 +336,8 @@ public void Insert_with_explicit_with_default_keys() context.Database.EnsureCreatedResiliently(); context.AddRange( - new NullableKeyBlog - { - Id = 0, - Name = "One Unicorn" - }, - new NullableKeyBlog - { - Id = 1, - Name = "Two Unicorns" - }); + new NullableKeyBlog { Id = 0, Name = "One Unicorn" }, + new NullableKeyBlog { Id = 1, Name = "Two Unicorns" }); context.SaveChanges(); } @@ -435,15 +379,8 @@ public void Insert_with_non_key_default_value() var blogs = new List { - new Blog - { - Name = "One Unicorn" - }, - new Blog - { - Name = "Two Unicorns", - CreatedOn = new DateTime(1969, 8, 3, 0, 10, 0) - } + new Blog { Name = "One Unicorn" }, + new Blog { Name = "Two Unicorns", CreatedOn = new DateTime(1969, 8, 3, 0, 10, 0) } }; context.AddRange(blogs); @@ -495,7 +432,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasDefaultValueSql("getdate()"); b.Property(e => e.OtherId) - .HasDefaultValue(value: null); + .HasDefaultValue(); }); } } @@ -510,14 +447,8 @@ public void Insert_with_non_key_default_value_readonly() context.Database.EnsureCreatedResiliently(); context.AddRange( - new Blog - { - Name = "One Unicorn" - }, - new Blog - { - Name = "Two Unicorns" - }); + new Blog { Name = "One Unicorn" }, + new Blog { Name = "Two Unicorns" }); context.SaveChanges(); @@ -577,11 +508,7 @@ public void Insert_and_update_with_computed_column() context.Database.EnsureCreatedResiliently(); var blog = context.Add( - new FullNameBlog - { - FirstName = "One", - LastName = "Unicorn" - }).Entity; + new FullNameBlog { FirstName = "One", LastName = "Unicorn" }).Entity; context.SaveChanges(); @@ -642,11 +569,7 @@ public void Insert_and_update_with_computed_column_with_function() using (var context = new BlogContextComputedColumnWithFunction(testStore.Name)) { var blog = context.Add( - new FullNameBlog - { - FirstName = "One", - LastName = "Unicorn" - }).Entity; + new FullNameBlog { FirstName = "One", LastName = "Unicorn" }).Entity; context.SaveChanges(); @@ -713,11 +636,7 @@ RETURN @FullName using (var context = new BlogContextComputedColumn(testStore.Name)) { var blog = context.Add( - new FullNameBlog - { - FirstName = "One", - LastName = "Unicorn" - }).Entity; + new FullNameBlog { FirstName = "One", LastName = "Unicorn" }).Entity; context.SaveChanges(); @@ -740,17 +659,9 @@ RETURN @FullName using (var context = new BlogContextComputedColumn(testStore.Name)) { var blog1 = context.Add( - new FullNameBlog - { - FirstName = "Hank", - LastName = "Unicorn" - }).Entity; + new FullNameBlog { FirstName = "Hank", LastName = "Unicorn" }).Entity; var blog2 = context.Add( - new FullNameBlog - { - FirstName = "Jeff", - LastName = "Unicorn" - }).Entity; + new FullNameBlog { FirstName = "Jeff", LastName = "Unicorn" }).Entity; context.SaveChanges(); @@ -780,10 +691,7 @@ public void Insert_with_client_generated_GUID_key() context.Database.EnsureCreatedResiliently(); var blog = context.Add( - new GuidBlog - { - Name = "One Unicorn" - }).Entity; + new GuidBlog { Name = "One Unicorn" }).Entity; var beforeSave = blog.Id; var beforeSaveNotId = blog.NotId; @@ -834,10 +742,7 @@ public void Insert_with_ValueGeneratedOnAdd_GUID_nonkey_property_throws() context.Database.EnsureCreatedResiliently(); var blog = context.Add( - new GuidBlog - { - Name = "One Unicorn" - }).Entity; + new GuidBlog { Name = "One Unicorn" }).Entity; Assert.Equal(default, blog.NotId); @@ -869,10 +774,7 @@ public void Insert_with_server_generated_GUID_key() context.Database.EnsureCreatedResiliently(); var blog = context.Add( - new GuidBlog - { - Name = "One Unicorn" - }).Entity; + new GuidBlog { Name = "One Unicorn" }).Entity; var beforeSave = blog.Id; var beforeSaveNotId = blog.NotId; @@ -930,15 +832,7 @@ public void Insert_with_explicit_non_default_keys_by_default() context.Database.EnsureCreatedResiliently(); context.AddRange( - new Blog - { - Id = 1, - Name = "One Unicorn" - }, new Blog - { - Id = 2, - Name = "Two Unicorns" - }); + new Blog { Id = 1, Name = "One Unicorn" }, new Blog { Id = 2, Name = "Two Unicorns" }); // DbUpdateException : An error occurred while updating the entries. See the // inner exception for details. @@ -961,15 +855,7 @@ public void Insert_with_explicit_default_keys() context.Database.EnsureCreatedResiliently(); context.AddRange( - new Blog - { - Id = 0, - Name = "One Unicorn" - }, new Blog - { - Id = 1, - Name = "Two Unicorns" - }); + new Blog { Id = 0, Name = "One Unicorn" }, new Blog { Id = 1, Name = "Two Unicorns" }); // DbUpdateException : An error occurred while updating the entries. See the // inner exception for details. @@ -998,15 +884,7 @@ public void Insert_with_implicit_default_keys() context.Database.EnsureCreatedResiliently(); context.AddRange( - new Blog - { - Id = 0, - Name = "One Unicorn" - }, new Blog - { - Id = 1, - Name = "Two Unicorns" - }); + new Blog { Id = 0, Name = "One Unicorn" }, new Blog { Id = 1, Name = "Two Unicorns" }); context.SaveChanges(); } @@ -1048,14 +926,7 @@ public void Insert_explicit_value_throws_when_readonly_sequence_before_save() context.Database.EnsureCreatedResiliently(); context.AddRange( - new Blog - { - Id = 1, - Name = "One Unicorn" - }, new Blog - { - Name = "Two Unicorns" - }); + new Blog { Id = 1, Name = "One Unicorn" }, new Blog { Name = "Two Unicorns" }); // The property 'Id' on entity type 'Blog' is defined to be read-only before it is // saved, but its value has been set to something other than a temporary or default value. @@ -1095,15 +966,8 @@ public void Insert_explicit_value_throws_when_readonly_before_save() context.Database.EnsureCreatedResiliently(); context.AddRange( - new Blog - { - Name = "One Unicorn" - }, - new Blog - { - Name = "Two Unicorns", - CreatedOn = new DateTime(1969, 8, 3, 0, 10, 0) - }); + new Blog { Name = "One Unicorn" }, + new Blog { Name = "Two Unicorns", CreatedOn = new DateTime(1969, 8, 3, 0, 10, 0) }); // The property 'CreatedOn' on entity type 'Blog' is defined to be read-only before it is // saved, but its value has been set to something other than a temporary or default value. @@ -1124,12 +988,7 @@ public void Insert_explicit_value_into_computed_column() context.Database.EnsureCreatedResiliently(); context.Add( - new FullNameBlog - { - FirstName = "One", - LastName = "Unicorn", - FullName = "Gerald" - }); + new FullNameBlog { FirstName = "One", LastName = "Unicorn", FullName = "Gerald" }); // The property 'FullName' on entity type 'FullNameBlog' is defined to be read-only before it is // saved, but its value has been set to something other than a temporary or default value. @@ -1150,11 +1009,7 @@ public void Update_explicit_value_in_computed_column() context.Database.EnsureCreatedResiliently(); context.Add( - new FullNameBlog - { - FirstName = "One", - LastName = "Unicorn" - }); + new FullNameBlog { FirstName = "One", LastName = "Unicorn" }); context.SaveChanges(); } @@ -1185,10 +1040,7 @@ public void Resolve_concurrency() context.Database.EnsureCreatedResiliently(); var blog = context.Add( - new ConcurrentBlog - { - Name = "One Unicorn" - }).Entity; + new ConcurrentBlog { Name = "One Unicorn" }).Entity; context.SaveChanges(); diff --git a/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSqlServerTest.cs index f071d61db40..6436dc4027c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSqlServerTest.cs @@ -33,10 +33,7 @@ public virtual void Exception_in_SaveChanges_causes_store_values_to_be_reverted( } entities.Add( - new Darwin - { - Id = 1777 - }); + new Darwin { Id = 1777 }); for (var i = 0; i < 2; i++) { diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConfiguredConditionAttribute.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConfiguredConditionAttribute.cs index a439006704c..1f3dd5bc9e7 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConfiguredConditionAttribute.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConfiguredConditionAttribute.cs @@ -12,7 +12,8 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities public sealed class SqlServerConfiguredConditionAttribute : Attribute, ITestCondition { public ValueTask IsMetAsync() - => new ValueTask(TestEnvironment.IsConfigured && (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || !TestEnvironment.IsLocalDb)); + => new ValueTask( + TestEnvironment.IsConfigured && (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || !TestEnvironment.IsLocalDb)); public string SkipReason => TestEnvironment.IsLocalDb ? "LocalDb is not accessible on this platform. An external SQL Server must be configured." diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestHelpers.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestHelpers.cs index fc242e7756c..8d64bfc5b24 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestHelpers.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestHelpers.cs @@ -3,13 +3,7 @@ using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.SqlServer.Diagnostics.Internal; -using Microsoft.EntityFrameworkCore.SqlServer.Internal; -using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal; -using Microsoft.EntityFrameworkCore.Storage; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.TestUtilities diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs index e983f56c05c..73817769610 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs @@ -25,7 +25,7 @@ public class SqlServerTestStore : RelationalTestStore public static SqlServerTestStore GetNorthwindStore() => (SqlServerTestStore)SqlServerNorthwindTestStoreFactory.Instance - .GetOrCreate(SqlServerNorthwindTestStoreFactory.Name).Initialize(null, (Func)null, null, null); + .GetOrCreate(SqlServerNorthwindTestStoreFactory.Name).Initialize(null, (Func)null); public static SqlServerTestStore GetOrCreate(string name) => new SqlServerTestStore(name); @@ -70,7 +70,7 @@ private SqlServerTestStore( public SqlServerTestStore InitializeSqlServer( IServiceProvider serviceProvider, Func createContext, Action seed) - => (SqlServerTestStore)Initialize(serviceProvider, createContext, seed, null); + => (SqlServerTestStore)Initialize(serviceProvider, createContext, seed); public SqlServerTestStore InitializeSqlServer( IServiceProvider serviceProvider, Func createContext, Action seed) @@ -328,15 +328,15 @@ private static T Execute( DbConnection connection, Func execute, string sql, bool useTransaction = false, object[] parameters = null) => new TestSqlServerRetryingExecutionStrategy().Execute( - new - { - connection, - execute, - sql, - useTransaction, - parameters - }, - state => ExecuteCommand(state.connection, state.execute, state.sql, state.useTransaction, state.parameters)); + new + { + connection, + execute, + sql, + useTransaction, + parameters + }, + state => ExecuteCommand(state.connection, state.execute, state.sql, state.useTransaction, state.parameters)); private static T ExecuteCommand( DbConnection connection, Func execute, string sql, bool useTransaction, object[] parameters) @@ -459,8 +459,7 @@ public static string CreateConnectionString(string name, string fileName = null, { var builder = new SqlConnectionStringBuilder(TestEnvironment.DefaultConnection) { - MultipleActiveResultSets = multipleActiveResultSets ?? new Random().Next(0, 2) == 1, - InitialCatalog = name + MultipleActiveResultSets = multipleActiveResultSets ?? new Random().Next(0, 2) == 1, InitialCatalog = name }; if (fileName != null) { diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestEnvironment.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestEnvironment.cs index 884195a2b07..032bb70a156 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestEnvironment.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestEnvironment.cs @@ -19,7 +19,7 @@ public static class TestEnvironment .GetSection("Test:SqlServer"); public static string DefaultConnection { get; } = Config["DefaultConnection"] - ?? "Data Source=(localdb)\\MSSQLLocalDB;Database=master;Integrated Security=True;Connect Timeout=30;ConnectRetryCount=0"; + ?? "Data Source=(localdb)\\MSSQLLocalDB;Database=master;Integrated Security=True;Connect Timeout=30;ConnectRetryCount=0"; private static readonly string _dataSource = new SqlConnectionStringBuilder(DefaultConnection).DataSource; @@ -30,7 +30,7 @@ public static class TestEnvironment public static bool IsSqlAzure { get; } = _dataSource.Contains("database.windows.net"); public static bool IsCI { get; } = Environment.GetEnvironmentVariable("PIPELINE_WORKSPACE") != null - || Environment.GetEnvironmentVariable("TEAMCITY_VERSION") != null; + || Environment.GetEnvironmentVariable("TEAMCITY_VERSION") != null; private static bool? _fullTextInstalled; diff --git a/test/EFCore.SqlServer.FunctionalTests/TransactionInterceptionSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/TransactionInterceptionSqlServerTest.cs index a61c10021ba..de15b2cfacc 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TransactionInterceptionSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TransactionInterceptionSqlServerTest.cs @@ -42,7 +42,8 @@ public class InterceptionSqlServerFixture : InterceptionSqlServerFixtureBase } public class TransactionInterceptionWithDiagnosticsSqlServerTest - : TransactionInterceptionSqlServerTestBase, IClassFixture + : TransactionInterceptionSqlServerTestBase, + IClassFixture { public TransactionInterceptionWithDiagnosticsSqlServerTest(InterceptionSqlServerFixture fixture) : base(fixture) diff --git a/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs b/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs index 223956d95d9..a3505dc3b08 100644 --- a/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs +++ b/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs @@ -108,6 +108,7 @@ public virtual void Detects_duplicate_column_names_within_hierarchy_with_differe { cb.Property(c => c.Identity).UseIdentityColumn(); } + cb.Property(c => c.Identity).HasColumnName(nameof(Cat.Identity)); }); modelBuilder.Entity( @@ -172,6 +173,7 @@ public virtual void Detects_incompatible_memory_optimized_shared_table(bool obso { modelBuilder.Entity().ToTable("Table").IsMemoryOptimized(); } + modelBuilder.Entity().ToTable("Table"); VerifyError( @@ -216,7 +218,9 @@ public virtual void Detects_default_decimal_mapping() var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.Entity().Property("Price"); - VerifyWarning(SqlServerResources.LogDefaultDecimalTypeColumn(new TestLogger()).GenerateMessage("Price", nameof(Animal)), modelBuilder.Model); + VerifyWarning( + SqlServerResources.LogDefaultDecimalTypeColumn(new TestLogger()) + .GenerateMessage("Price", nameof(Animal)), modelBuilder.Model); } [ConditionalFact] @@ -225,7 +229,9 @@ public virtual void Detects_default_nullable_decimal_mapping() var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.Entity().Property("Price"); - VerifyWarning(SqlServerResources.LogDefaultDecimalTypeColumn(new TestLogger()).GenerateMessage("Price", nameof(Animal)), modelBuilder.Model); + VerifyWarning( + SqlServerResources.LogDefaultDecimalTypeColumn(new TestLogger()) + .GenerateMessage("Price", nameof(Animal)), modelBuilder.Model); } [ConditionalTheory] @@ -247,7 +253,9 @@ public void Detects_byte_identity_column(bool obsolete) modelBuilder.Entity().Property("Bite").UseIdentityColumn(); } - VerifyWarning(SqlServerResources.LogByteIdentityColumn(new TestLogger()).GenerateMessage("Bite", nameof(Dog)), modelBuilder.Model); + VerifyWarning( + SqlServerResources.LogByteIdentityColumn(new TestLogger()) + .GenerateMessage("Bite", nameof(Dog)), modelBuilder.Model); } [ConditionalTheory] @@ -269,7 +277,9 @@ public void Detects_nullable_byte_identity_column(bool obsolete) modelBuilder.Entity().Property("Bite").UseIdentityColumn(); } - VerifyWarning(SqlServerResources.LogByteIdentityColumn(new TestLogger()).GenerateMessage("Bite", nameof(Dog)), modelBuilder.Model); + VerifyWarning( + SqlServerResources.LogByteIdentityColumn(new TestLogger()) + .GenerateMessage("Bite", nameof(Dog)), modelBuilder.Model); } [ConditionalTheory] @@ -380,6 +390,7 @@ public void Passes_for_non_key_SequenceHiLo_on_model(bool obsolete) { modelBuilder.UseHiLo(); } + modelBuilder.Entity().Property(c => c.Type).ValueGeneratedOnAdd(); Validate(modelBuilder.Model); @@ -401,7 +412,9 @@ public void Metadata_throws_when_setting_conflicting_serverGenerated_values(stri ConfigureProperty(propertyBuilder.Metadata, firstConfiguration, "1"); ConfigureProperty(propertyBuilder.Metadata, secondConfiguration, "2"); - VerifyError(RelationalStrings.ConflictingColumnServerGeneration(firstConfiguration, "NullableInt", secondConfiguration), modelBuilder.Model); + VerifyError( + RelationalStrings.ConflictingColumnServerGeneration(firstConfiguration, "NullableInt", secondConfiguration), + modelBuilder.Model); } protected virtual void ConfigureProperty(IMutableProperty property, string configuration, string value) diff --git a/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerMemoryOptimizedTablesConventionTest.cs b/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerMemoryOptimizedTablesConventionTest.cs index a5bff9465c8..27d524389c2 100644 --- a/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerMemoryOptimizedTablesConventionTest.cs +++ b/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerMemoryOptimizedTablesConventionTest.cs @@ -33,11 +33,7 @@ public void Keys_and_indexes_are_nonclustered_for_memory_optimized_tables(bool o } modelBuilder.Entity().HasKey( - o => new - { - o.Id, - o.CustomerId - }); + o => new { o.Id, o.CustomerId }); modelBuilder.Entity().HasIndex(o => o.CustomerId); Assert.True(modelBuilder.Model.FindEntityType(typeof(Order)).GetKeys().All(k => k.IsClustered() == false)); diff --git a/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataBuilderExtensionsTest.cs b/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataBuilderExtensionsTest.cs index 45cde596910..fe63e4089e7 100644 --- a/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataBuilderExtensionsTest.cs +++ b/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataBuilderExtensionsTest.cs @@ -22,17 +22,20 @@ public void Can_access_model() { var builder = CreateBuilder(); - Assert.NotNull(builder - .HasValueGenerationStrategy(SqlServerValueGenerationStrategy.SequenceHiLo)); + Assert.NotNull( + builder + .HasValueGenerationStrategy(SqlServerValueGenerationStrategy.SequenceHiLo)); Assert.Equal(SqlServerValueGenerationStrategy.SequenceHiLo, builder.Metadata.GetValueGenerationStrategy()); - Assert.NotNull(builder + Assert.NotNull( + builder .HasValueGenerationStrategy(SqlServerValueGenerationStrategy.IdentityColumn, fromDataAnnotation: true)); Assert.Equal( SqlServerValueGenerationStrategy.IdentityColumn, builder.Metadata.GetValueGenerationStrategy()); - Assert.Null(builder - .HasValueGenerationStrategy(SqlServerValueGenerationStrategy.SequenceHiLo)); + Assert.Null( + builder + .HasValueGenerationStrategy(SqlServerValueGenerationStrategy.SequenceHiLo)); Assert.Equal(SqlServerValueGenerationStrategy.IdentityColumn, builder.Metadata.GetValueGenerationStrategy()); Assert.Equal( @@ -158,6 +161,7 @@ public void Can_access_index(bool obsolete) { Assert.NotNull(indexBuilder.IsClustered(true)); } + Assert.True(indexBuilder.Metadata.IsClustered()); if (obsolete) @@ -170,8 +174,8 @@ public void Can_access_index(bool obsolete) { Assert.NotNull(indexBuilder.IsClustered(false, fromDataAnnotation: true)); } - Assert.False(indexBuilder.Metadata.IsClustered()); + Assert.False(indexBuilder.Metadata.IsClustered()); if (obsolete) { @@ -183,6 +187,7 @@ public void Can_access_index(bool obsolete) { Assert.Null(indexBuilder.IsClustered(true)); } + Assert.False(indexBuilder.Metadata.IsClustered()); Assert.Equal( diff --git a/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataExtensionsTest.cs b/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataExtensionsTest.cs index 3eca4950dc9..a229b3ee1d5 100644 --- a/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataExtensionsTest.cs +++ b/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataExtensionsTest.cs @@ -40,7 +40,6 @@ public void Can_get_and_set_column_name() Assert.Equal("Name", property.GetColumnName()); } - [ConditionalFact] public void Can_get_and_set_column_key_name() { @@ -386,7 +385,7 @@ public void Can_get_and_set_sequence_name_on_property() .Metadata; Assert.Null(property.GetHiLoSequenceName()); - Assert.Null(((IProperty)property).GetHiLoSequenceName()); + Assert.Null(property.GetHiLoSequenceName()); property.SetHiLoSequenceName("Snook"); diff --git a/test/EFCore.SqlServer.Tests/Migrations/SqlServerMigrationsAnnotationProviderTest.cs b/test/EFCore.SqlServer.Tests/Migrations/SqlServerMigrationsAnnotationProviderTest.cs index 36ee2fd9f51..86639a0c2cf 100644 --- a/test/EFCore.SqlServer.Tests/Migrations/SqlServerMigrationsAnnotationProviderTest.cs +++ b/test/EFCore.SqlServer.Tests/Migrations/SqlServerMigrationsAnnotationProviderTest.cs @@ -16,7 +16,7 @@ public class SqlServerMigrationsAnnotationProviderTest public SqlServerMigrationsAnnotationProviderTest() { - _modelBuilder = SqlServerTestHelpers.Instance.CreateConventionBuilder(/*skipValidation: true*/); + _modelBuilder = SqlServerTestHelpers.Instance.CreateConventionBuilder( /*skipValidation: true*/); _annotations = new SqlServerMigrationsAnnotationProvider(new MigrationsAnnotationProviderDependencies()); } @@ -40,7 +40,8 @@ public void Resolves_column_names_for_Index_with_included_properties() var index = _modelBuilder.Entity().HasIndex(e => e.IndexedProp).IncludeProperties(e => e.IncludedProp).Metadata; _modelBuilder.FinalizeModel(); - Assert.Contains(_annotations.For(index), a => a.Name == SqlServerAnnotationNames.Include && ((string[])a.Value).Contains("IncludedColumn")); + Assert.Contains( + _annotations.For(index), a => a.Name == SqlServerAnnotationNames.Include && ((string[])a.Value).Contains("IncludedColumn")); } private class Entity diff --git a/test/EFCore.SqlServer.Tests/Migrations/SqlServerModelDifferTest.cs b/test/EFCore.SqlServer.Tests/Migrations/SqlServerModelDifferTest.cs index ed40ddc0c1a..ab4cd74b786 100644 --- a/test/EFCore.SqlServer.Tests/Migrations/SqlServerModelDifferTest.cs +++ b/test/EFCore.SqlServer.Tests/Migrations/SqlServerModelDifferTest.cs @@ -353,10 +353,7 @@ public void Add_SequenceHiLo_with_seed_data() x.Property("Id"); x.Property("SequenceId"); x.HasData( - new - { - Id = 42 - }); + new { Id = 42 }); }), _ => { }, target => target.Entity( @@ -366,10 +363,7 @@ public void Add_SequenceHiLo_with_seed_data() x.ToTable("Firefly", "dbo"); x.Property("SequenceId").UseHiLo(schema: "dbo"); x.HasData( - new - { - Id = 43 - }); + new { Id = 43 }); }), upOps => Assert.Collection( upOps, @@ -503,31 +497,10 @@ public void SeedData_all_operations() x.Property("Value1"); x.Property("Value2"); x.HasData( - new - { - Id = 99999, - Value1 = 0, - Value2 = "" - }, // deleted - new - { - Id = 42, - Value1 = 32, - Value2 = "equal", - InvalidProperty = "is ignored" - }, // modified - new - { - Id = 8, - Value1 = 100, - Value2 = "equal" - }, // unchanged - new - { - Id = 24, - Value1 = 72, - Value2 = "not equal1" - }); // modified + new { Id = 99999, Value1 = 0, Value2 = "" }, // deleted + new { Id = 42, Value1 = 32, Value2 = "equal", InvalidProperty = "is ignored" }, // modified + new { Id = 8, Value1 = 100, Value2 = "equal" }, // unchanged + new { Id = 24, Value1 = 72, Value2 = "not equal1" }); // modified }), target => target.Entity( "EntityWithTwoProperties", @@ -537,37 +510,11 @@ public void SeedData_all_operations() x.Property("Value1"); x.Property("Value2"); x.HasData( - new - { - Id = 11111, - Value1 = 0, - Value2 = "" - }, // added - new - { - Id = 11112, - Value1 = 1, - Value2 = "new" - }, // added - new - { - Id = 42, - Value1 = 27, - Value2 = "equal", - InvalidProperty = "is ignored here too" - }, // modified - new - { - Id = 8, - Value1 = 100, - Value2 = "equal" - }, // unchanged - new - { - Id = 24, - Value1 = 99, - Value2 = "not equal2" - }); // modified + new { Id = 11111, Value1 = 0, Value2 = "" }, // added + new { Id = 11112, Value1 = 1, Value2 = "new" }, // added + new { Id = 42, Value1 = 27, Value2 = "equal", InvalidProperty = "is ignored here too" }, // modified + new { Id = 8, Value1 = 100, Value2 = "equal" }, // unchanged + new { Id = 24, Value1 = 99, Value2 = "not equal2" }); // modified }), upOps => Assert.Collection( upOps, diff --git a/test/EFCore.SqlServer.Tests/ModelBuilding/SqlServerModelBuilderGenericTest.cs b/test/EFCore.SqlServer.Tests/ModelBuilding/SqlServerModelBuilderGenericTest.cs index 2bea6e3dc40..d5b1ec12490 100644 --- a/test/EFCore.SqlServer.Tests/ModelBuilding/SqlServerModelBuilderGenericTest.cs +++ b/test/EFCore.SqlServer.Tests/ModelBuilding/SqlServerModelBuilderGenericTest.cs @@ -296,7 +296,7 @@ public virtual void Owned_types_can_be_mapped_to_different_tables() { tb.Ignore(l => l.Book); tb.WithOwner() - .HasConstraintName("AlternateLabelFK"); + .HasConstraintName("AlternateLabelFK"); tb.ToTable("TT", "TS"); tb.IsMemoryOptimized(); tb.OwnsOne( @@ -480,7 +480,7 @@ public override void Can_configure_owned_type() entityBuilder.Property(d => d.CustomerId); entityBuilder.HasIndex(d => d.CustomerId); entityBuilder.WithOwner(d => d.Customer) - .HasPrincipalKey(c => c.AlternateKey); + .HasPrincipalKey(c => c.AlternateKey); modelBuilder.FinalizeModel(); diff --git a/test/EFCore.SqlServer.Tests/SqlServerEventIdTest.cs b/test/EFCore.SqlServer.Tests/SqlServerEventIdTest.cs index dfe2355a3e0..378f235f803 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerEventIdTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerEventIdTest.cs @@ -27,13 +27,7 @@ public void Every_eventId_has_a_logger_method_and_logs_when_level_enabled() var fakeFactories = new Dictionary> { - { - typeof(IList), () => new List - { - "Fake1", - "Fake2" - } - }, + { typeof(IList), () => new List { "Fake1", "Fake2" } }, { typeof(IProperty), () => property }, { typeof(string), () => "Fake" } }; diff --git a/test/EFCore.SqlServer.Tests/SqlServerMigrationBuilderTest.cs b/test/EFCore.SqlServer.Tests/SqlServerMigrationBuilderTest.cs index 4960f789380..0d65d2ad514 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerMigrationBuilderTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerMigrationBuilderTest.cs @@ -1,8 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Migrations; using Xunit; @@ -23,6 +21,5 @@ public void Not_IsSqlServer_when_using_different_provider() var migrationBuilder = new MigrationBuilder("Microsoft.EntityFrameworkCore.InMemory"); Assert.False(migrationBuilder.IsSqlServer()); } - } } diff --git a/test/EFCore.SqlServer.Tests/SqlServerOptionsExtensionTest.cs b/test/EFCore.SqlServer.Tests/SqlServerOptionsExtensionTest.cs index 494077f6693..60fbaa1a74a 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerOptionsExtensionTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerOptionsExtensionTest.cs @@ -5,7 +5,6 @@ using System.Linq; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.SqlServer.Infrastructure.Internal; using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal; using Microsoft.Extensions.DependencyInjection; diff --git a/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs b/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs index 6a51eeedb1b..4b0d24c1477 100644 --- a/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs +++ b/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs @@ -34,11 +34,7 @@ public void Row_version_is_marked_as_modified_only_if_it_really_changed(string m var newToken = changeValue ? new byte[] { 1, 2, 3, 4, 0, 6, 7, 8 } : token; var entity = context.Attach( - new WithRowVersion - { - Id = 789, - Version = token.ToArray() - }).Entity; + new WithRowVersion { Id = 789, Version = token.ToArray() }).Entity; var propertyEntry = context.Entry(entity).Property(e => e.Version); diff --git a/test/EFCore.SqlServer.Tests/Update/SqlServerUpdateSqlGeneratorTest.cs b/test/EFCore.SqlServer.Tests/Update/SqlServerUpdateSqlGeneratorTest.cs index e6c78f90e4f..951b149bf89 100644 --- a/test/EFCore.SqlServer.Tests/Update/SqlServerUpdateSqlGeneratorTest.cs +++ b/test/EFCore.SqlServer.Tests/Update/SqlServerUpdateSqlGeneratorTest.cs @@ -104,7 +104,7 @@ FROM [dbo].[Ducks] public void AppendBulkInsertOperation_appends_insert_if_store_generated_columns_exist() { var stringBuilder = new StringBuilder(); - var command = CreateInsertCommand(identityKey: true, isComputed: true); + var command = CreateInsertCommand(); var sqlGenerator = (ISqlServerUpdateSqlGenerator)CreateSqlGenerator(); var grouping = sqlGenerator.AppendBulkInsertOperation(stringBuilder, new[] { command, command }, 0); diff --git a/test/EFCore.Sqlite.FunctionalTests/AutoincrementTest.cs b/test/EFCore.Sqlite.FunctionalTests/AutoincrementTest.cs index c06830ac66c..916be2d9976 100644 --- a/test/EFCore.Sqlite.FunctionalTests/AutoincrementTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/AutoincrementTest.cs @@ -21,10 +21,7 @@ public void Autoincrement_prevents_reusing_rowid() using (var context = CreateContext()) { context.People.Add( - new PersonA - { - Name = "Bruce" - }); + new PersonA { Name = "Bruce" }); context.SaveChanges(); var hero = context.People.First(p => p.Id == 1); @@ -32,10 +29,7 @@ public void Autoincrement_prevents_reusing_rowid() context.People.Remove(hero); context.SaveChanges(); context.People.Add( - new PersonA - { - Name = "Batman" - }); + new PersonA { Name = "Batman" }); context.SaveChanges(); var gone = context.People.FirstOrDefault(p => p.Id == 1); var begins = context.People.FirstOrDefault(p => p.Id == 2); diff --git a/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs index 8490a172e1a..9f22e57e563 100644 --- a/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Sqlite.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -50,11 +49,7 @@ public virtual void Can_insert_and_query_decimal() using (var context = CreateContext()) { context.Set().Add( - new BuiltInNullableDataTypes - { - Id = 14, - TestNullableDecimal = 3m - }); + new BuiltInNullableDataTypes { Id = 14, TestNullableDecimal = 3m }); Assert.Equal(1, context.SaveChanges()); } @@ -149,10 +144,7 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_set_to_null() using (var context = CreateContext()) { context.Set().Add( - new MappedNullableDataTypes - { - Id = 78 - }); + new MappedNullableDataTypes { Id = 78 }); Assert.Equal(1, context.SaveChanges()); } @@ -200,12 +192,7 @@ private static void AssertMappedSizedDataTypes(MappedSizedDataTypes entity, int } private static MappedSizedDataTypes CreateMappedSizedDataTypes(int id) - => new MappedSizedDataTypes - { - Id = id, - Nvarchar = "Into", - Binary = new byte[] { 10, 11, 12, 13 } - }; + => new MappedSizedDataTypes { Id = id, Nvarchar = "Into", Binary = new byte[] { 10, 11, 12, 13 } }; [ConditionalFact] public virtual void Can_insert_and_read_back_nulls_for_all_mapped_sized_data_types() @@ -213,10 +200,7 @@ public virtual void Can_insert_and_read_back_nulls_for_all_mapped_sized_data_typ using (var context = CreateContext()) { context.Set().Add( - new MappedSizedDataTypes - { - Id = 78 - }); + new MappedSizedDataTypes { Id = 78 }); Assert.Equal(1, context.SaveChanges()); } @@ -279,11 +263,7 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_with_precisio using (var context = CreateContext()) { context.Set().Add( - new MappedPrecisionAndScaledDataTypes - { - Id = 77, - Decimal = 101.1m - }); + new MappedPrecisionAndScaledDataTypes { Id = 77, Decimal = 101.1m }); Assert.Equal(1, context.SaveChanges()); } @@ -379,10 +359,7 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_set_to_null_w using (var context = CreateContext()) { context.Set().Add( - new MappedNullableDataTypesWithIdentity - { - AltId = 78 - }); + new MappedNullableDataTypesWithIdentity { AltId = 78 }); Assert.Equal(1, context.SaveChanges()); } @@ -431,12 +408,7 @@ private static void AssertMappedSizedDataTypesWithIdentity(MappedSizedDataTypesW } private static MappedSizedDataTypesWithIdentity CreateMappedSizedDataTypesWithIdentity(int id) - => new MappedSizedDataTypesWithIdentity - { - AltId = id, - Nvarchar = "Into", - Binary = new byte[] { 10, 11, 12, 13 } - }; + => new MappedSizedDataTypesWithIdentity { AltId = id, Nvarchar = "Into", Binary = new byte[] { 10, 11, 12, 13 } }; [ConditionalFact] public virtual void Can_insert_and_read_back_nulls_for_all_mapped_sized_data_types_with_Identity() @@ -444,10 +416,7 @@ public virtual void Can_insert_and_read_back_nulls_for_all_mapped_sized_data_typ using (var context = CreateContext()) { context.Set().Add( - new MappedSizedDataTypesWithIdentity - { - AltId = 78 - }); + new MappedSizedDataTypesWithIdentity { AltId = 78 }); Assert.Equal(1, context.SaveChanges()); } @@ -510,11 +479,7 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_with_precisio using (var context = CreateContext()) { context.Set().Add( - new MappedPrecisionAndScaledDataTypesWithIdentity - { - AltId = 77, - Decimal = 101.1m - }); + new MappedPrecisionAndScaledDataTypesWithIdentity { AltId = 77, Decimal = 101.1m }); Assert.Equal(1, context.SaveChanges()); } @@ -573,20 +538,11 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_set_to_null_i using (var context = CreateContext()) { context.Set().Add( - new MappedNullableDataTypes - { - Id = 278 - }); + new MappedNullableDataTypes { Id = 278 }); context.Set().Add( - new MappedNullableDataTypes - { - Id = 279 - }); + new MappedNullableDataTypes { Id = 279 }); context.Set().Add( - new MappedNullableDataTypes - { - Id = 280 - }); + new MappedNullableDataTypes { Id = 280 }); Assert.Equal(3, context.SaveChanges()); } @@ -627,20 +583,11 @@ public virtual void Can_insert_and_read_back_nulls_for_all_mapped_sized_data_typ using (var context = CreateContext()) { context.Set().Add( - new MappedSizedDataTypes - { - Id = 278 - }); + new MappedSizedDataTypes { Id = 278 }); context.Set().Add( - new MappedSizedDataTypes - { - Id = 279 - }); + new MappedSizedDataTypes { Id = 279 }); context.Set().Add( - new MappedSizedDataTypes - { - Id = 280 - }); + new MappedSizedDataTypes { Id = 280 }); Assert.Equal(3, context.SaveChanges()); } @@ -683,23 +630,11 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_with_precisio using (var context = CreateContext()) { context.Set().Add( - new MappedPrecisionAndScaledDataTypes - { - Id = 177, - Decimal = 101.1m - }); + new MappedPrecisionAndScaledDataTypes { Id = 177, Decimal = 101.1m }); context.Set().Add( - new MappedPrecisionAndScaledDataTypes - { - Id = 178, - Decimal = 101.1m - }); + new MappedPrecisionAndScaledDataTypes { Id = 178, Decimal = 101.1m }); context.Set().Add( - new MappedPrecisionAndScaledDataTypes - { - Id = 179, - Decimal = 101.1m - }); + new MappedPrecisionAndScaledDataTypes { Id = 179, Decimal = 101.1m }); Assert.Equal(3, context.SaveChanges()); } @@ -769,20 +704,11 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_set_to_null_w using (var context = CreateContext()) { context.Set().Add( - new MappedNullableDataTypesWithIdentity - { - AltId = 278 - }); + new MappedNullableDataTypesWithIdentity { AltId = 278 }); context.Set().Add( - new MappedNullableDataTypesWithIdentity - { - AltId = 279 - }); + new MappedNullableDataTypesWithIdentity { AltId = 279 }); context.Set().Add( - new MappedNullableDataTypesWithIdentity - { - AltId = 280 - }); + new MappedNullableDataTypesWithIdentity { AltId = 280 }); Assert.Equal(3, context.SaveChanges()); } @@ -826,20 +752,11 @@ public virtual void Can_insert_and_read_back_nulls_for_all_mapped_sized_data_typ using (var context = CreateContext()) { context.Set().Add( - new MappedSizedDataTypesWithIdentity - { - AltId = 278 - }); + new MappedSizedDataTypesWithIdentity { AltId = 278 }); context.Set().Add( - new MappedSizedDataTypesWithIdentity - { - AltId = 279 - }); + new MappedSizedDataTypesWithIdentity { AltId = 279 }); context.Set().Add( - new MappedSizedDataTypesWithIdentity - { - AltId = 280 - }); + new MappedSizedDataTypesWithIdentity { AltId = 280 }); Assert.Equal(3, context.SaveChanges()); } @@ -885,23 +802,11 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_with_precisio using (var context = CreateContext()) { context.Set().Add( - new MappedPrecisionAndScaledDataTypesWithIdentity - { - AltId = 177, - Decimal = 101.1m - }); + new MappedPrecisionAndScaledDataTypesWithIdentity { AltId = 177, Decimal = 101.1m }); context.Set().Add( - new MappedPrecisionAndScaledDataTypesWithIdentity - { - AltId = 178, - Decimal = 101.1m - }); + new MappedPrecisionAndScaledDataTypesWithIdentity { AltId = 178, Decimal = 101.1m }); context.Set().Add( - new MappedPrecisionAndScaledDataTypesWithIdentity - { - AltId = 179, - Decimal = 101.1m - }); + new MappedPrecisionAndScaledDataTypesWithIdentity { AltId = 179, Decimal = 101.1m }); Assert.Equal(3, context.SaveChanges()); } @@ -961,7 +866,6 @@ public virtual void Cant_query_Min_of_converted_types() { Id = 202, PartitionId = 200, - TestNullableDecimal = 10.000000000000001m, TestNullableDateTimeOffset = new DateTimeOffset(2018, 1, 1, 11, 0, 0, TimeSpan.FromHours(-2)), TestNullableTimeSpan = TimeSpan.FromDays(10), @@ -1106,20 +1010,10 @@ public virtual void Cant_query_Average_of_converted_types() using (var context = CreateContext()) { context.Add( - new BuiltInNullableDataTypes - { - Id = 205, - PartitionId = 202, - TestNullableDecimal = 1.000000000000003m - }); + new BuiltInNullableDataTypes { Id = 205, PartitionId = 202, TestNullableDecimal = 1.000000000000003m }); context.Add( - new BuiltInNullableDataTypes - { - Id = 206, - PartitionId = 202, - TestNullableDecimal = 1.000000000000001m - }); + new BuiltInNullableDataTypes { Id = 206, PartitionId = 202, TestNullableDecimal = 1.000000000000001m }); context.SaveChanges(); @@ -1140,20 +1034,10 @@ public virtual void Cant_query_Sum_of_converted_types() using (var context = CreateContext()) { context.Add( - new BuiltInDataTypes - { - Id = 205, - PartitionId = 203, - TestDecimal = 1.000000000000001m - }); + new BuiltInDataTypes { Id = 205, PartitionId = 203, TestDecimal = 1.000000000000001m }); context.Add( - new BuiltInDataTypes - { - Id = 206, - PartitionId = 203, - TestDecimal = 1.000000000000001m - }); + new BuiltInDataTypes { Id = 206, PartitionId = 203, TestDecimal = 1.000000000000001m }); context.SaveChanges(); @@ -1162,7 +1046,8 @@ public virtual void Cant_query_Sum_of_converted_types() .Where(e => e.PartitionId == 203) .Sum(e => e.TestDecimal)); Assert.Equal( - CoreStrings.TranslationFailed("Projection Mapping: EmptyProjectionMember -> [EntityProjectionExpression]SELECT 1FROM BuiltInDataTypes AS bWHERE b.PartitionId == 203"), + CoreStrings.TranslationFailed( + "Projection Mapping: EmptyProjectionMember -> [EntityProjectionExpression]SELECT 1FROM BuiltInDataTypes AS bWHERE b.PartitionId == 203"), RemoveNewLines(ex.Message)); } } @@ -1178,22 +1063,14 @@ public virtual void Can_query_negation_of_converted_types() context.Add( new BuiltInDataTypes { - Id = 207, - PartitionId = 204, - TestDecimal = 1.000000000000001m, - TestTimeSpan = TimeSpan.FromMinutes(1) + Id = 207, PartitionId = 204, TestDecimal = 1.000000000000001m, TestTimeSpan = TimeSpan.FromMinutes(1) }); context.SaveChanges(); var result = context.Set() .Select( - e => new BuiltInDataTypes - { - Id = e.Id, - TestDecimal = -e.TestDecimal, - TestTimeSpan = -e.TestTimeSpan - }) + e => new BuiltInDataTypes { Id = e.Id, TestDecimal = -e.TestDecimal, TestTimeSpan = -e.TestTimeSpan }) .First(e => e.Id == 207); Assert.Equal(-1.000000000000001m, result.TestDecimal); @@ -1312,7 +1189,8 @@ public virtual void Can_query_less_than_of_converted_types() e.Id, TestDecimal = e.TestDecimal < 10m, TestDateTime = e.TestDateTime < new DateTime(2018, 10, 10, 0, 0, 0), - TestDateTimeOffset = e.TestDateTimeOffset < new DateTimeOffset(2018, 1, 1, 11, 0, 0, TimeSpan.FromHours(-2)), + TestDateTimeOffset = + e.TestDateTimeOffset < new DateTimeOffset(2018, 1, 1, 11, 0, 0, TimeSpan.FromHours(-2)), TestTimeSpan = e.TestTimeSpan < new TimeSpan(10, 0, 0, 0), TestUnsignedInt64 = e.TestUnsignedInt64 < ulong.MaxValue, TestCharacter = e.TestCharacter < 'B' @@ -1355,7 +1233,8 @@ public virtual void Can_query_less_than_or_equal_of_converted_types() e.Id, TestDecimal = e.TestDecimal <= 10m, TestDateTime = e.TestDateTime <= new DateTime(2018, 10, 10, 0, 0, 0), - TestDateTimeOffset = e.TestDateTimeOffset <= new DateTimeOffset(2018, 1, 1, 11, 0, 0, TimeSpan.FromHours(-2)), + TestDateTimeOffset = + e.TestDateTimeOffset <= new DateTimeOffset(2018, 1, 1, 11, 0, 0, TimeSpan.FromHours(-2)), TestTimeSpan = e.TestTimeSpan <= new TimeSpan(10, 0, 0, 0), TestUnsignedInt64 = e.TestUnsignedInt64 <= ulong.MaxValue, TestCharacter = e.TestCharacter <= 'B' @@ -1398,7 +1277,8 @@ public virtual void Can_query_greater_than_of_converted_types() e.Id, TestDecimal = e.TestDecimal > 10m, TestDateTime = e.TestDateTime > new DateTime(2018, 10, 10, 0, 0, 0), - TestDateTimeOffset = e.TestDateTimeOffset > new DateTimeOffset(2018, 1, 1, 11, 0, 0, TimeSpan.FromHours(-2)), + TestDateTimeOffset = + e.TestDateTimeOffset > new DateTimeOffset(2018, 1, 1, 11, 0, 0, TimeSpan.FromHours(-2)), TestTimeSpan = e.TestTimeSpan > new TimeSpan(10, 0, 0, 0), TestUnsignedInt64 = e.TestUnsignedInt64 > ulong.MaxValue, TestCharacter = e.TestCharacter > 'B' @@ -1441,7 +1321,8 @@ public virtual void Can_query_greater_than_or_equal_of_converted_types() e.Id, TestDecimal = e.TestDecimal >= 10m, TestDateTime = e.TestDateTime >= new DateTime(2018, 10, 10, 0, 0, 0), - TestDateTimeOffset = e.TestDateTimeOffset >= new DateTimeOffset(2018, 1, 1, 11, 0, 0, TimeSpan.FromHours(-2)), + TestDateTimeOffset = + e.TestDateTimeOffset >= new DateTimeOffset(2018, 1, 1, 11, 0, 0, TimeSpan.FromHours(-2)), TestTimeSpan = e.TestTimeSpan >= new TimeSpan(10, 0, 0, 0), TestUnsignedInt64 = e.TestUnsignedInt64 >= ulong.MaxValue, TestCharacter = e.TestCharacter >= 'B' @@ -1537,10 +1418,7 @@ public virtual void Can_query_modulo_of_converted_types() context.Add( new BuiltInDataTypes { - Id = 216, - PartitionId = 204, - TestDecimal = 3.000000000000003m, - TestUnsignedInt64 = 10000000000000000001 + Id = 216, PartitionId = 204, TestDecimal = 3.000000000000003m, TestUnsignedInt64 = 10000000000000000001 }); context.SaveChanges(); @@ -1580,7 +1458,6 @@ public virtual void Cant_query_OrderBy_of_converted_types() { Id = 218, PartitionId = 205, - TestNullableDecimal = 10.000000000000001m, TestNullableDateTimeOffset = new DateTimeOffset(2018, 1, 1, 11, 0, 0, TimeSpan.FromHours(-2)), TestNullableTimeSpan = TimeSpan.FromDays(10), diff --git a/test/EFCore.Sqlite.FunctionalTests/ConvertToProviderTypesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/ConvertToProviderTypesSqliteTest.cs index 481ce49988e..fca895cd00a 100644 --- a/test/EFCore.Sqlite.FunctionalTests/ConvertToProviderTypesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/ConvertToProviderTypesSqliteTest.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit.Abstractions; diff --git a/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs index b784675f54b..57ee02bd859 100644 --- a/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestUtilities; namespace Microsoft.EntityFrameworkCore diff --git a/test/EFCore.Sqlite.FunctionalTests/DataAnnotationSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/DataAnnotationSqliteTest.cs index 10f2ccd3705..f987fbc0e99 100644 --- a/test/EFCore.Sqlite.FunctionalTests/DataAnnotationSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/DataAnnotationSqliteTest.cs @@ -148,7 +148,6 @@ LEFT JOIN ( UPDATE ""Sample"" SET ""Name"" = @p0, ""RowVersion"" = @p1 WHERE ""UniqueNo"" = @p2 AND ""RowVersion"" = @p3; SELECT changes();"); - } public override void DatabaseGeneratedAttribute_autogenerates_values_when_set_to_identity() diff --git a/test/EFCore.Sqlite.FunctionalTests/DefaultValuesTest.cs b/test/EFCore.Sqlite.FunctionalTests/DefaultValuesTest.cs index 529ab3d7ee2..f8395e01d34 100644 --- a/test/EFCore.Sqlite.FunctionalTests/DefaultValuesTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/DefaultValuesTest.cs @@ -17,16 +17,9 @@ public void Can_use_SQLite_default_values() using (var context = CreateChipsContext()) { var honeyDijon = context.Add( - new KettleChips - { - Name = "Honey Dijon" - }).Entity; + new KettleChips { Name = "Honey Dijon" }).Entity; var buffaloBleu = context.Add( - new KettleChips - { - Name = "Buffalo Bleu", - BestBuyDate = new DateTime(2111, 1, 11) - }).Entity; + new KettleChips { Name = "Buffalo Bleu", BestBuyDate = new DateTime(2111, 1, 11) }).Entity; context.SaveChanges(); diff --git a/test/EFCore.Sqlite.FunctionalTests/MigrationsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/MigrationsSqliteTest.cs index df9e98993cb..64adb671c21 100644 --- a/test/EFCore.Sqlite.FunctionalTests/MigrationsSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/MigrationsSqliteTest.cs @@ -11,6 +11,7 @@ using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations.Operations; using Microsoft.EntityFrameworkCore.TestModels.AspNetIdentity; +using ModelSnapshot22; using Xunit; namespace Microsoft.EntityFrameworkCore @@ -305,7 +306,7 @@ FROM sqlite_master public override void Can_diff_against_2_2_model() { - using (var context = new ModelSnapshot22.BloggingContext()) + using (var context = new BloggingContext()) { DiffSnapshot(new BloggingContextModelSnapshot22(), context); } @@ -372,7 +373,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder .HasAnnotation("ProductVersion", "2.1.0"); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityRole", b => { b.Property("Id") .ValueGeneratedOnAdd(); @@ -395,7 +397,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetRoles"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { b.Property("Id") .ValueGeneratedOnAdd(); @@ -414,7 +417,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetRoleClaims"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUser", b => { b.Property("Id") .ValueGeneratedOnAdd(); @@ -464,7 +468,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUsers"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { b.Property("Id") .ValueGeneratedOnAdd(); @@ -483,7 +488,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUserClaims"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.Property("LoginProvider") .HasMaxLength(128); @@ -503,7 +509,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUserLogins"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserRole", b => { b.Property("UserId"); @@ -516,7 +523,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUserRoles"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserToken", b => { b.Property("UserId"); @@ -533,7 +541,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUserTokens"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") .WithMany() @@ -541,7 +550,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser") .WithMany() @@ -549,7 +559,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser") .WithMany() @@ -557,7 +568,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserRole", b => { b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") .WithMany() @@ -570,7 +582,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserToken", b => { b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser") .WithMany() @@ -597,7 +610,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder .HasAnnotation("ProductVersion", "2.2.0-preview1"); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityRole", b => { b.Property("Id") .ValueGeneratedOnAdd(); @@ -620,7 +634,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetRoles"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { b.Property("Id") .ValueGeneratedOnAdd(); @@ -639,7 +654,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetRoleClaims"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUser", b => { b.Property("Id") .ValueGeneratedOnAdd(); @@ -689,7 +705,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUsers"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { b.Property("Id") .ValueGeneratedOnAdd(); @@ -708,7 +725,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUserClaims"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.Property("LoginProvider") .HasMaxLength(128); @@ -728,7 +746,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUserLogins"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserRole", b => { b.Property("UserId"); @@ -741,7 +760,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUserRoles"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserToken", b => { b.Property("UserId"); @@ -758,7 +778,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUserTokens"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") .WithMany() @@ -766,7 +787,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser") .WithMany() @@ -774,7 +796,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser") .WithMany() @@ -782,7 +805,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserRole", b => { b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") .WithMany() @@ -795,7 +819,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserToken", b => { b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser") .WithMany() @@ -822,7 +847,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder .HasAnnotation("ProductVersion", "3.0.0"); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityRole", b => { b.Property("Id") .HasColumnType("TEXT"); @@ -848,7 +874,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetRoles"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -871,7 +898,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetRoleClaims"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUser", b => { b.Property("Id") .HasColumnType("TEXT"); @@ -935,7 +963,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUsers"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -958,7 +987,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUserClaims"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.Property("LoginProvider") .HasColumnType("TEXT") @@ -982,7 +1012,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUserLogins"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserRole", b => { b.Property("UserId") .HasColumnType("TEXT"); @@ -997,7 +1028,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUserRoles"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserToken", b => { b.Property("UserId") .HasColumnType("TEXT"); @@ -1018,7 +1050,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AspNetUserTokens"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) .WithMany() @@ -1027,7 +1060,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) .WithMany() @@ -1036,7 +1070,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) .WithMany() @@ -1045,7 +1080,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserRole", b => { b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) .WithMany() @@ -1060,7 +1096,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + modelBuilder.Entity( + "Microsoft.AspNetCore.Identity.IdentityUserToken", b => { b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) .WithMany() diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/BadDataSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/BadDataSqliteTest.cs index 964d7cd4f28..c4bbc12549c 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/BadDataSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/BadDataSqliteTest.cs @@ -4,11 +4,11 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Data; using System.Data.Common; using System.Linq; using System.Threading; using System.Threading.Tasks; -using System.Transactions; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; @@ -385,13 +385,13 @@ public Task OpenAsync(CancellationToken cancellationToken, bool errorsExpe public bool Close() => true; - public Task CloseAsync() => Task.FromResult(true); + public Task CloseAsync() => Task.FromResult(true); public bool IsMultipleActiveResultSetsEnabled { get; } - public IDbContextTransaction BeginTransaction(System.Data.IsolationLevel isolationLevel) => throw new NotImplementedException(); + public IDbContextTransaction BeginTransaction(IsolationLevel isolationLevel) => throw new NotImplementedException(); public Task BeginTransactionAsync( - System.Data.IsolationLevel isolationLevel, CancellationToken cancellationToken = default) => throw new NotImplementedException(); + IsolationLevel isolationLevel, CancellationToken cancellationToken = default) => throw new NotImplementedException(); public IDbContextTransaction UseTransaction(DbTransaction transaction) => throw new NotImplementedException(); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs index 451ab3a792e..31b64c2b4d1 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs @@ -37,10 +37,6 @@ public override void Bad_data_error_handling_invalid_cast_no_tracking() } protected override DbParameter CreateDbParameter(string name, object value) - => new SqliteParameter - { - ParameterName = name, - Value = value - }; + => new SqliteParameter { ParameterName = name, Value = value }; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/IncludeSqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/IncludeSqliteFixture.cs index 897fd1e302a..992f67d8f37 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/IncludeSqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/IncludeSqliteFixture.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestUtilities; namespace Microsoft.EntityFrameworkCore.Query diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/QueryFilterFuncletizationSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/QueryFilterFuncletizationSqliteTest.cs index f7b1a25ab71..4d8483a7044 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/QueryFilterFuncletizationSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/QueryFilterFuncletizationSqliteTest.cs @@ -6,7 +6,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class QueryFilterFuncletizationSqliteTest : QueryFilterFuncletizationTestBase + public class QueryFilterFuncletizationSqliteTest : QueryFilterFuncletizationTestBase< + QueryFilterFuncletizationSqliteTest.QueryFilterFuncletizationSqliteFixture> { public QueryFilterFuncletizationSqliteTest( QueryFilterFuncletizationSqliteFixture fixture, ITestOutputHelper testOutputHelper) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/SimpleQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/SimpleQuerySqliteTest.cs index deda260df1b..5d93bfe7e3d 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/SimpleQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/SimpleQuerySqliteTest.cs @@ -1317,7 +1317,6 @@ public override void Select_nested_collection_multi_level() public override Task SelectMany_correlated_with_outer_4(bool isAsync) => null; - [ConditionalTheory(Skip = "Issue#17324")] public override Task Project_single_element_from_collection_with_OrderBy_over_navigation_Take_and_FirstOrDefault_2(bool isAsync) { diff --git a/test/EFCore.Sqlite.FunctionalTests/Scaffolding/SqliteDatabaseModelFactoryTest.cs b/test/EFCore.Sqlite.FunctionalTests/Scaffolding/SqliteDatabaseModelFactoryTest.cs index 53abc7bc039..d808dd07fc7 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Scaffolding/SqliteDatabaseModelFactoryTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Scaffolding/SqliteDatabaseModelFactoryTest.cs @@ -204,10 +204,7 @@ public void Create_primary_key() Assert.Equal("Place", pk.Table.Name); Assert.Equal( - new List - { - "Id" - }, pk.Columns.Select(ic => ic.Name).ToList()); + new List { "Id" }, pk.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE Place;"); } @@ -233,10 +230,7 @@ Location int // ReSharper disable once PossibleNullReferenceException Assert.Equal("Place", uniqueConstraint.Table.Name); Assert.Equal( - new List - { - "Name" - }, uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); + new List { "Name" }, uniqueConstraint.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE Place;"); } @@ -299,15 +293,9 @@ FOREIGN KEY (Id) REFERENCES PrincipalTable(Id) ON DELETE NO ACTION Assert.Equal("FirstDependent", firstFk.Table.Name); Assert.Equal("PrincipalTable", firstFk.PrincipalTable.Name); Assert.Equal( - new List - { - "ForeignKeyId" - }, firstFk.Columns.Select(ic => ic.Name).ToList()); + new List { "ForeignKeyId" }, firstFk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id" - }, firstFk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id" }, firstFk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, firstFk.OnDelete); var secondFk = Assert.Single(dbModel.Tables.Single(t => t.Name == "SecondDependent").ForeignKeys); @@ -316,15 +304,9 @@ FOREIGN KEY (Id) REFERENCES PrincipalTable(Id) ON DELETE NO ACTION Assert.Equal("SecondDependent", secondFk.Table.Name); Assert.Equal("PrincipalTable", secondFk.PrincipalTable.Name); Assert.Equal( - new List - { - "Id" - }, secondFk.Columns.Select(ic => ic.Name).ToList()); + new List { "Id" }, secondFk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id" - }, secondFk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id" }, secondFk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.NoAction, secondFk.OnDelete); }, @" @@ -454,11 +436,7 @@ PRIMARY KEY ( Id2, Id1 ) Assert.Equal("CompositePrimaryKey", pk.Table.Name); Assert.Equal( - new List - { - "Id2", - "Id1" - }, pk.Columns.Select(ic => ic.Name).ToList()); + new List { "Id2", "Id1" }, pk.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE CompositePrimaryKey;"); } @@ -479,10 +457,7 @@ Id integer PRIMARY KEY Assert.Equal("RowidPrimaryKey", pk.Table.Name); Assert.Equal( - new List - { - "Id" - }, pk.Columns.Select(ic => ic.Name).ToList()); + new List { "Id" }, pk.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE RowidPrimaryKey;"); } @@ -505,10 +480,7 @@ CONSTRAINT PK PRIMARY KEY (Id) Assert.Equal("PrimaryKeyName", pk.Table.Name); Assert.Equal("PK", pk.Name); Assert.Equal( - new List - { - "Id" - }, pk.Columns.Select(ic => ic.Name).ToList()); + new List { "Id" }, pk.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE PrimaryKeyName;"); } @@ -536,11 +508,7 @@ CREATE TABLE CompositeUniqueConstraint ( // ReSharper disable once PossibleNullReferenceException Assert.Equal("CompositeUniqueConstraint", constraint.Table.Name); Assert.Equal( - new List - { - "Id2", - "Id1" - }, constraint.Columns.Select(ic => ic.Name).ToList()); + new List { "Id2", "Id1" }, constraint.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE CompositeUniqueConstraint;"); } @@ -564,10 +532,7 @@ CONSTRAINT UK UNIQUE (Id) Assert.Equal("UniqueConstraintName", constraint.Table.Name); Assert.Equal("UK", constraint.Name); Assert.Equal( - new List - { - "Id" - }, constraint.Columns.Select(ic => ic.Name).ToList()); + new List { "Id" }, constraint.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE UniqueConstraintName;"); } @@ -597,11 +562,7 @@ Id2 text Assert.Equal("CompositeIndex", index.Table.Name); Assert.Equal("IX_COMPOSITE", index.Name); Assert.Equal( - new List - { - "Id2", - "Id1" - }, index.Columns.Select(ic => ic.Name).ToList()); + new List { "Id2", "Id1" }, index.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE CompositeIndex;"); } @@ -628,10 +589,7 @@ Id2 text Assert.Equal("IX_UNIQUE", index.Name); Assert.True(index.IsUnique); Assert.Equal( - new List - { - "Id2" - }, index.Columns.Select(ic => ic.Name).ToList()); + new List { "Id2" }, index.Columns.Select(ic => ic.Name).ToList()); }, "DROP TABLE UniqueIndex;"); } @@ -667,17 +625,9 @@ FOREIGN KEY (ForeignKeyId1, ForeignKeyId2) REFERENCES PrincipalTable(Id1, Id2) O Assert.Equal("DependentTable", fk.Table.Name); Assert.Equal("PrincipalTable", fk.PrincipalTable.Name); Assert.Equal( - new List - { - "ForeignKeyId1", - "ForeignKeyId2" - }, fk.Columns.Select(ic => ic.Name).ToList()); + new List { "ForeignKeyId1", "ForeignKeyId2" }, fk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id1", - "Id2" - }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id1", "Id2" }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, fk.OnDelete); }, @" @@ -719,15 +669,9 @@ FOREIGN KEY (ForeignKeyId2) REFERENCES AnotherPrincipalTable(Id) ON DELETE CASCA Assert.Equal("DependentTable", principalFk.Table.Name); Assert.Equal("PrincipalTable", principalFk.PrincipalTable.Name); Assert.Equal( - new List - { - "ForeignKeyId1" - }, principalFk.Columns.Select(ic => ic.Name).ToList()); + new List { "ForeignKeyId1" }, principalFk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id" - }, principalFk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id" }, principalFk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, principalFk.OnDelete); var anotherPrincipalFk = Assert.Single(foreignKeys.Where(f => f.PrincipalTable.Name == "AnotherPrincipalTable")); @@ -736,15 +680,9 @@ FOREIGN KEY (ForeignKeyId2) REFERENCES AnotherPrincipalTable(Id) ON DELETE CASCA Assert.Equal("DependentTable", anotherPrincipalFk.Table.Name); Assert.Equal("AnotherPrincipalTable", anotherPrincipalFk.PrincipalTable.Name); Assert.Equal( - new List - { - "ForeignKeyId2" - }, anotherPrincipalFk.Columns.Select(ic => ic.Name).ToList()); + new List { "ForeignKeyId2" }, anotherPrincipalFk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id" - }, anotherPrincipalFk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id" }, anotherPrincipalFk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, anotherPrincipalFk.OnDelete); }, @" @@ -778,15 +716,9 @@ FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id2) ON DELETE CASCADE Assert.Equal("DependentTable", fk.Table.Name); Assert.Equal("PrincipalTable", fk.PrincipalTable.Name); Assert.Equal( - new List - { - "ForeignKeyId" - }, fk.Columns.Select(ic => ic.Name).ToList()); + new List { "ForeignKeyId" }, fk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id2" - }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id2" }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, fk.OnDelete); }, @" @@ -818,15 +750,9 @@ CONSTRAINT MYFK FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id) ON DELE Assert.Equal("DependentTable", fk.Table.Name); Assert.Equal("PrincipalTable", fk.PrincipalTable.Name); Assert.Equal( - new List - { - "ForeignKeyId" - }, fk.Columns.Select(ic => ic.Name).ToList()); + new List { "ForeignKeyId" }, fk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id" - }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id" }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.Cascade, fk.OnDelete); Assert.Equal("MYFK", fk.Name); }, @@ -859,15 +785,9 @@ FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id) ON DELETE SET NULL Assert.Equal("DependentTable", fk.Table.Name); Assert.Equal("PrincipalTable", fk.PrincipalTable.Name); Assert.Equal( - new List - { - "ForeignKeyId" - }, fk.Columns.Select(ic => ic.Name).ToList()); + new List { "ForeignKeyId" }, fk.Columns.Select(ic => ic.Name).ToList()); Assert.Equal( - new List - { - "Id" - }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); + new List { "Id" }, fk.PrincipalColumns.Select(ic => ic.Name).ToList()); Assert.Equal(ReferentialAction.SetNull, fk.OnDelete); }, @" @@ -891,7 +811,9 @@ public void Warn_for_schema_filtering() var (_, Id, Message, _, _) = Assert.Single(Fixture.ListLoggerFactory.Log.Where(t => t.Level == LogLevel.Warning)); Assert.Equal(SqliteResources.LogUsingSchemaSelectionsWarning(new TestLogger()).EventId, Id); - Assert.Equal(SqliteResources.LogUsingSchemaSelectionsWarning(new TestLogger()).GenerateMessage(), Message); + Assert.Equal( + SqliteResources.LogUsingSchemaSelectionsWarning(new TestLogger()).GenerateMessage(), + Message); }, "DROP TABLE Everest;"); } @@ -910,7 +832,8 @@ public void Warn_missing_table() var (Level, Id, Message, _, _) = Assert.Single(Fixture.ListLoggerFactory.Log.Where(t => t.Level == LogLevel.Warning)); Assert.Equal(SqliteResources.LogMissingTable(new TestLogger()).EventId, Id); - Assert.Equal(SqliteResources.LogMissingTable(new TestLogger()).GenerateMessage("MyTable"), Message); + Assert.Equal( + SqliteResources.LogMissingTable(new TestLogger()).GenerateMessage("MyTable"), Message); }, "DROP TABLE Blank;"); } @@ -935,8 +858,12 @@ CONSTRAINT MYFK FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id) ON DELE { var (_, Id, Message, _, _) = Assert.Single(Fixture.ListLoggerFactory.Log.Where(t => t.Level == LogLevel.Warning)); - Assert.Equal(SqliteResources.LogForeignKeyScaffoldErrorPrincipalTableNotFound(new TestLogger()).EventId, Id); - Assert.Equal(SqliteResources.LogForeignKeyScaffoldErrorPrincipalTableNotFound(new TestLogger()).GenerateMessage("0"), Message); + Assert.Equal( + SqliteResources.LogForeignKeyScaffoldErrorPrincipalTableNotFound(new TestLogger()) + .EventId, Id); + Assert.Equal( + SqliteResources.LogForeignKeyScaffoldErrorPrincipalTableNotFound(new TestLogger()) + .GenerateMessage("0"), Message); }, @" DROP TABLE DependentTable; @@ -965,7 +892,8 @@ CONSTRAINT MYFK FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(ImaginaryId Assert.Equal(SqliteResources.LogPrincipalColumnNotFound(new TestLogger()).EventId, Id); Assert.Equal( - SqliteResources.LogPrincipalColumnNotFound(new TestLogger()).GenerateMessage("0", "DependentTable", "ImaginaryId", "PrincipalTable"), + SqliteResources.LogPrincipalColumnNotFound(new TestLogger()).GenerateMessage( + "0", "DependentTable", "ImaginaryId", "PrincipalTable"), Message); }, @" diff --git a/test/EFCore.Sqlite.FunctionalTests/SqliteComplianceTest.cs b/test/EFCore.Sqlite.FunctionalTests/SqliteComplianceTest.cs index 30fc3b87f6b..a51a0f91539 100644 --- a/test/EFCore.Sqlite.FunctionalTests/SqliteComplianceTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/SqliteComplianceTest.cs @@ -12,9 +12,7 @@ public class SqliteComplianceTest : RelationalComplianceTestBase { protected override ICollection IgnoredTestBases { get; } = new HashSet { - typeof(FromSqlSprocQueryTestBase<>), - typeof(SqlExecutorTestBase<>), - typeof(UdfDbFunctionTestBase<>), + typeof(FromSqlSprocQueryTestBase<>), typeof(SqlExecutorTestBase<>), typeof(UdfDbFunctionTestBase<>) }; protected override Assembly TargetAssembly { get; } = typeof(SqliteComplianceTest).Assembly; diff --git a/test/EFCore.Sqlite.FunctionalTests/SqliteDatabaseCreatorTest.cs b/test/EFCore.Sqlite.FunctionalTests/SqliteDatabaseCreatorTest.cs index d5b88e63244..776151cba39 100644 --- a/test/EFCore.Sqlite.FunctionalTests/SqliteDatabaseCreatorTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/SqliteDatabaseCreatorTest.cs @@ -5,7 +5,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Microsoft.Extensions.DependencyInjection; using Xunit; diff --git a/test/EFCore.Sqlite.FunctionalTests/SqliteMigrationSqlGeneratorTest.cs b/test/EFCore.Sqlite.FunctionalTests/SqliteMigrationSqlGeneratorTest.cs index 087a016c17b..55aa01256c5 100644 --- a/test/EFCore.Sqlite.FunctionalTests/SqliteMigrationSqlGeneratorTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/SqliteMigrationSqlGeneratorTest.cs @@ -20,22 +20,11 @@ public virtual void It_lifts_foreign_key_additions() Generate( new CreateTableOperation { - Name = "Pie", - Columns = - { - new AddColumnOperation - { - ClrType = typeof(int), - Name = "FlavorId", - ColumnType = "INT" - } - } - }, new AddForeignKeyOperation + Name = "Pie", Columns = { new AddColumnOperation { ClrType = typeof(int), Name = "FlavorId", ColumnType = "INT" } } + }, + new AddForeignKeyOperation { - Table = "Pie", - PrincipalTable = "Flavor", - Columns = new[] { "FlavorId" }, - PrincipalColumns = new[] { "Id" } + Table = "Pie", PrincipalTable = "Flavor", Columns = new[] { "FlavorId" }, PrincipalColumns = new[] { "Id" } }); AssertSql( @@ -77,13 +66,7 @@ public virtual void DefaultValue_formats_literal_correctly() [InlineData(false, "PK_Id")] public void CreateTableOperation_with_annotations(bool autoincrement, string pkName) { - var addIdColumn = new AddColumnOperation - { - Name = "Id", - ClrType = typeof(long), - ColumnType = "INTEGER", - IsNullable = false - }; + var addIdColumn = new AddColumnOperation { Name = "Id", ClrType = typeof(long), ColumnType = "INTEGER", IsNullable = false }; if (autoincrement) { addIdColumn.AddAnnotation(SqliteAnnotationNames.Autoincrement, true); @@ -98,38 +81,20 @@ public void CreateTableOperation_with_annotations(bool autoincrement, string pkN addIdColumn, new AddColumnOperation { - Name = "EmployerId", - ClrType = typeof(int), - ColumnType = "int", - IsNullable = true + Name = "EmployerId", ClrType = typeof(int), ColumnType = "int", IsNullable = true }, new AddColumnOperation { - Name = "SSN", - ClrType = typeof(string), - ColumnType = "char(11)", - IsNullable = true - } - }, - PrimaryKey = new AddPrimaryKeyOperation - { - Name = pkName, - Columns = new[] { "Id" } - }, - UniqueConstraints = - { - new AddUniqueConstraintOperation - { - Columns = new[] { "SSN" } + Name = "SSN", ClrType = typeof(string), ColumnType = "char(11)", IsNullable = true } }, + PrimaryKey = new AddPrimaryKeyOperation { Name = pkName, Columns = new[] { "Id" } }, + UniqueConstraints = { new AddUniqueConstraintOperation { Columns = new[] { "SSN" } } }, ForeignKeys = { new AddForeignKeyOperation { - Columns = new[] { "EmployerId" }, - PrincipalTable = "Companies", - PrincipalColumns = new[] { "Id" } + Columns = new[] { "EmployerId" }, PrincipalTable = "Companies", PrincipalColumns = new[] { "Id" } } } }); @@ -157,7 +122,8 @@ public override void AddColumnOperation_with_defaultValue() { base.AddColumnOperation_with_defaultValue(); - AssertSql(@"ALTER TABLE ""People"" ADD ""Name"" varchar(30) NOT NULL DEFAULT 'John Doe'; + AssertSql( + @"ALTER TABLE ""People"" ADD ""Name"" varchar(30) NOT NULL DEFAULT 'John Doe'; "); } @@ -165,7 +131,8 @@ public override void AddColumnOperation_without_column_type() { base.AddColumnOperation_without_column_type(); - AssertSql(@"ALTER TABLE ""People"" ADD ""Alias"" TEXT NOT NULL; + AssertSql( + @"ALTER TABLE ""People"" ADD ""Alias"" TEXT NOT NULL; "); } @@ -183,7 +150,8 @@ public override void AddColumnOperation_with_defaultValueSql() DefaultValueSql = "10" }); - AssertSql(@"ALTER TABLE ""People"" ADD ""Age"" int NULL DEFAULT (10); + AssertSql( + @"ALTER TABLE ""People"" ADD ""Age"" int NULL DEFAULT (10); "); } @@ -192,7 +160,8 @@ public override void AddColumnOperation_with_maxLength() base.AddColumnOperation_with_maxLength(); // See issue #3698 - AssertSql(@"ALTER TABLE ""Person"" ADD ""Name"" TEXT NULL; + AssertSql( + @"ALTER TABLE ""Person"" ADD ""Name"" TEXT NULL; "); } @@ -201,7 +170,8 @@ public override void AddColumnOperation_with_maxLength_overridden() base.AddColumnOperation_with_maxLength_overridden(); // See issue #3698 - AssertSql(@"ALTER TABLE ""Person"" ADD ""Name"" TEXT NULL; + AssertSql( + @"ALTER TABLE ""Person"" ADD ""Name"" TEXT NULL; "); } @@ -210,7 +180,8 @@ public override void AddColumnOperation_with_maxLength_on_derived() base.AddColumnOperation_with_maxLength_on_derived(); // See issue #3698 - AssertSql(@"ALTER TABLE ""Person"" ADD ""Name"" TEXT NULL; + AssertSql( + @"ALTER TABLE ""Person"" ADD ""Name"" TEXT NULL; "); } @@ -218,7 +189,8 @@ public override void AddColumnOperation_with_shared_column() { base.AddColumnOperation_with_shared_column(); - AssertSql(@"ALTER TABLE ""Base"" ADD ""Foo"" TEXT NULL; + AssertSql( + @"ALTER TABLE ""Base"" ADD ""Foo"" TEXT NULL; "); } @@ -345,14 +317,10 @@ public override void AlterSequenceOperation_without_minValue_and_maxValue() public virtual void RenameColumnOperation() { Generate( - new RenameColumnOperation - { - Table = "People", - Name = "Name", - NewName = "FullName" - }); + new RenameColumnOperation { Table = "People", Name = "Name", NewName = "FullName" }); - AssertSql(@"ALTER TABLE ""People"" RENAME COLUMN ""Name"" TO ""FullName""; + AssertSql( + @"ALTER TABLE ""People"" RENAME COLUMN ""Name"" TO ""FullName""; "); } @@ -368,12 +336,7 @@ public virtual void RenameIndexOperation() x.HasKey("FullName"); x.HasIndex("FullName").IsUnique().HasFilter(@"""Id"" > 2"); }), - new RenameIndexOperation - { - Table = "Person", - Name = "IX_Person_Name", - NewName = "IX_Person_FullName" - }); + new RenameIndexOperation { Table = "Person", Name = "IX_Person_Name", NewName = "IX_Person_FullName" }); AssertSql( @"DROP INDEX ""IX_Person_Name""; @@ -401,7 +364,8 @@ public override void RenameTableOperation_legacy() { base.RenameTableOperation_legacy(); - AssertSql(@"ALTER TABLE ""People"" RENAME TO ""Person""; + AssertSql( + @"ALTER TABLE ""People"" RENAME TO ""Person""; "); } @@ -409,7 +373,8 @@ public override void RenameTableOperation() { base.RenameTableOperation(); - AssertSql(@"ALTER TABLE ""People"" RENAME TO ""Person""; + AssertSql( + @"ALTER TABLE ""People"" RENAME TO ""Person""; "); } @@ -447,7 +412,8 @@ public override void DropIndexOperation() { base.DropIndexOperation(); - AssertSql(@"DROP INDEX ""IX_People_Name""; + AssertSql( + @"DROP INDEX ""IX_People_Name""; "); } @@ -493,10 +459,7 @@ public virtual void CreateTableOperation_old_autoincrement_annotation() ["Autoincrement"] = true } }, - PrimaryKey = new AddPrimaryKeyOperation - { - Columns = new[] { "Id" } - } + PrimaryKey = new AddPrimaryKeyOperation { Columns = new[] { "Id" } } }); AssertSql( @@ -525,17 +488,11 @@ public virtual void CreateTableOperation_has_comment() }, new AddColumnOperation { - Name = "UncommentedColumn1", - Table = "People", - ClrType = typeof(string), - IsNullable = false + Name = "UncommentedColumn1", Table = "People", ClrType = typeof(string), IsNullable = false }, new AddColumnOperation { - Name = "UncommentedColumn2", - Table = "People", - ClrType = typeof(string), - IsNullable = false + Name = "UncommentedColumn2", Table = "People", ClrType = typeof(string), IsNullable = false }, new AddColumnOperation { @@ -582,8 +539,7 @@ public virtual void CreateTableOperation_has_multi_line_comment() comment. More information can be found in the docs." - - }, + } } }); @@ -616,7 +572,7 @@ public virtual void CreateTableOperation_has_multi_line_table_comment() ClrType = typeof(int), IsNullable = false, Comment = "My Comment" - }, + } } }); diff --git a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestHelpers.cs b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestHelpers.cs index a5c2b832d8f..d6f467cfc1e 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestHelpers.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestHelpers.cs @@ -3,13 +3,7 @@ using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Sqlite.Diagnostics.Internal; -using Microsoft.EntityFrameworkCore.Sqlite.Internal; -using Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal; -using Microsoft.EntityFrameworkCore.Storage; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.TestUtilities diff --git a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStore.cs b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStore.cs index 4cd4885292a..d21b8bc6397 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStore.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStore.cs @@ -37,8 +37,7 @@ private SqliteTestStore(string name, bool seed = true, bool sharedCache = true, ConnectionString = new SqliteConnectionStringBuilder { - DataSource = Name + ".db", - Cache = sharedCache ? SqliteCacheMode.Shared : SqliteCacheMode.Private + DataSource = Name + ".db", Cache = sharedCache ? SqliteCacheMode.Shared : SqliteCacheMode.Private }.ToString(); var connection = new SqliteConnection(ConnectionString); @@ -60,11 +59,11 @@ public override DbContextOptionsBuilder AddProviderOptions(DbContextOptionsBuild => AddProviderOptions(builder, configureSqlite: null); public SqliteTestStore InitializeSqlite(IServiceProvider serviceProvider, Func createContext, Action seed) - => (SqliteTestStore)Initialize(serviceProvider, createContext, seed, null); + => (SqliteTestStore)Initialize(serviceProvider, createContext, seed); public SqliteTestStore InitializeSqlite( IServiceProvider serviceProvider, Func createContext, Action seed) - => (SqliteTestStore)Initialize(serviceProvider, () => createContext(this), seed, null); + => (SqliteTestStore)Initialize(serviceProvider, () => createContext(this), seed); protected override void Initialize(Func createContext, Action seed, Action clean) { diff --git a/test/EFCore.Sqlite.FunctionalTests/TransactionInterceptionSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/TransactionInterceptionSqliteTest.cs index 4120b5ac862..7e2869dfd6d 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TransactionInterceptionSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TransactionInterceptionSqliteTest.cs @@ -42,7 +42,8 @@ public class InterceptionSqliteFixture : InterceptionSqliteFixtureBase } public class TransactionInterceptionWithDiagnosticsSqliteTest - : TransactionInterceptionSqliteTestBase, IClassFixture + : TransactionInterceptionSqliteTestBase, + IClassFixture { public TransactionInterceptionWithDiagnosticsSqliteTest(InterceptionSqliteFixture fixture) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/TransactionSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/TransactionSqliteTest.cs index 7bb446dbe39..48395089f72 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TransactionSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TransactionSqliteTest.cs @@ -19,7 +19,7 @@ protected override DbContext CreateContextWithConnectionString() { var options = Fixture.AddOptions( new DbContextOptionsBuilder().UseSqlite(TestStore.ConnectionString) - .ConfigureWarnings(w => w.Log(RelationalEventId.AmbientTransactionWarning))) + .ConfigureWarnings(w => w.Log(RelationalEventId.AmbientTransactionWarning))) .UseInternalServiceProvider(Fixture.ServiceProvider); return new DbContext(options.Options); diff --git a/test/EFCore.Sqlite.Tests/Infrastructure/SqliteModelValidatorTest.cs b/test/EFCore.Sqlite.Tests/Infrastructure/SqliteModelValidatorTest.cs index 0fd781e04a7..506cf60f2c1 100644 --- a/test/EFCore.Sqlite.Tests/Infrastructure/SqliteModelValidatorTest.cs +++ b/test/EFCore.Sqlite.Tests/Infrastructure/SqliteModelValidatorTest.cs @@ -70,7 +70,9 @@ public void Detects_schemas() var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.Entity().ToTable("Animals", "pet").Ignore(a => a.FavoritePerson); - VerifyWarning(SqliteResources.LogSchemaConfigured(new TestLogger()).GenerateMessage("Animal", "pet"), modelBuilder.Model); + VerifyWarning( + SqliteResources.LogSchemaConfigured(new TestLogger()).GenerateMessage("Animal", "pet"), + modelBuilder.Model); } [ConditionalFact] @@ -79,7 +81,9 @@ public void Detects_sequences() var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.HasSequence("Fibonacci"); - VerifyWarning(SqliteResources.LogSequenceConfigured(new TestLogger()).GenerateMessage("Fibonacci"), modelBuilder.Model); + VerifyWarning( + SqliteResources.LogSequenceConfigured(new TestLogger()).GenerateMessage("Fibonacci"), + modelBuilder.Model); } private static void GenerateMapping(IMutableProperty property) diff --git a/test/EFCore.Sqlite.Tests/SqliteMigrationBuilderTest.cs b/test/EFCore.Sqlite.Tests/SqliteMigrationBuilderTest.cs index 7ee28bea433..292c17c41f2 100644 --- a/test/EFCore.Sqlite.Tests/SqliteMigrationBuilderTest.cs +++ b/test/EFCore.Sqlite.Tests/SqliteMigrationBuilderTest.cs @@ -1,8 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Migrations; using Xunit; @@ -23,6 +21,5 @@ public void Not_IsSqlite_when_using_different_provider() var migrationBuilder = new MigrationBuilder("Microsoft.EntityFrameworkCore.InMemory"); Assert.False(migrationBuilder.IsSqlite()); } - } } diff --git a/test/EFCore.Sqlite.Tests/Storage/SqliteTypeMappingTest.cs b/test/EFCore.Sqlite.Tests/Storage/SqliteTypeMappingTest.cs index 9cdb24d95e0..16fbdf85e3f 100644 --- a/test/EFCore.Sqlite.Tests/Storage/SqliteTypeMappingTest.cs +++ b/test/EFCore.Sqlite.Tests/Storage/SqliteTypeMappingTest.cs @@ -59,10 +59,7 @@ public void SQLite_type_mapping_works_even_when_using_non_SQLite_store_type() context.Database.EnsureCreated(); context.Add( - new NoTiny - { - TinyState = TinyState.Two - }); + new NoTiny { TinyState = TinyState.Two }); context.SaveChanges(); } diff --git a/test/EFCore.Tests/ApiConsistencyTestBase.cs b/test/EFCore.Tests/ApiConsistencyTestBase.cs index 3d855cbb2a1..aff685ceab6 100644 --- a/test/EFCore.Tests/ApiConsistencyTestBase.cs +++ b/test/EFCore.Tests/ApiConsistencyTestBase.cs @@ -62,36 +62,36 @@ from method in type.GetMethods(PublicInstance | BindingFlags.Static) protected virtual Dictionary MetadataTypes => new Dictionary(); - private static readonly HashSet _ignoredMetadataReturnTypes = new HashSet() - { - typeof(bool), - typeof(bool?), - typeof(int), - typeof(int?), - typeof(string), - typeof(object), - typeof(Type), - typeof(DeleteBehavior), - typeof(ValueGenerated), - typeof(PropertyAccessMode), - typeof(PropertySaveBehavior), - typeof(ChangeTrackingStrategy), - typeof(ValueComparer), - typeof(ValueConverter), - typeof(Func), - typeof(IClrCollectionAccessor), - typeof(IClrPropertyGetter), - typeof(IClrPropertySetter), - typeof(LambdaExpression), - typeof(ServiceParameterBinding), - typeof(PropertyInfo), - typeof(FieldInfo), - typeof(MemberInfo), - typeof(CoreTypeMapping), - typeof(IAnnotation), - typeof(IEnumerable), - typeof(IEnumerable>) - }; + private static readonly HashSet _ignoredMetadataReturnTypes = new HashSet + { + typeof(bool), + typeof(bool?), + typeof(int), + typeof(int?), + typeof(string), + typeof(object), + typeof(Type), + typeof(DeleteBehavior), + typeof(ValueGenerated), + typeof(PropertyAccessMode), + typeof(PropertySaveBehavior), + typeof(ChangeTrackingStrategy), + typeof(ValueComparer), + typeof(ValueConverter), + typeof(Func), + typeof(IClrCollectionAccessor), + typeof(IClrPropertyGetter), + typeof(IClrPropertySetter), + typeof(LambdaExpression), + typeof(ServiceParameterBinding), + typeof(PropertyInfo), + typeof(FieldInfo), + typeof(MemberInfo), + typeof(CoreTypeMapping), + typeof(IAnnotation), + typeof(IEnumerable), + typeof(IEnumerable>) + }; protected virtual HashSet IgnoredMetadataReturnTypes => _ignoredMetadataReturnTypes; @@ -99,22 +99,23 @@ from method in type.GetMethods(PublicInstance | BindingFlags.Static) public void Mutable_metadata_types_have_matching_methods() { var errors = - MetadataTypes.Select(typeTuple => - from readonlyMethod in typeTuple.Key.GetMethods(PublicInstance | BindingFlags.Static) - where readonlyMethod.Name != "get_Item" - && readonlyMethod.Name != "FindRuntimeEntityType" - && readonlyMethod.Name != "GetConcreteDerivedTypesInclusive" - && readonlyMethod.Name != "GetClosestCommonParent" - && readonlyMethod.Name != "LeastDerivedType" - && readonlyMethod.Name != "GetAllBaseTypesInclusive" - && readonlyMethod.Name != "GetAllBaseTypesInclusiveAscending" - join mutableMethod in typeTuple.Value.Mutable.GetMethods(PublicInstance | BindingFlags.Static) - on readonlyMethod.Name equals mutableMethod.Name into mutableGroup - from mutableMethod in mutableGroup.DefaultIfEmpty() - select (readonlyMethod, mutableMethod)) - .SelectMany(m => m.Select(MatchMutable)) - .Where(e => e != null) - .ToList(); + MetadataTypes.Select( + typeTuple => + from readonlyMethod in typeTuple.Key.GetMethods(PublicInstance | BindingFlags.Static) + where readonlyMethod.Name != "get_Item" + && readonlyMethod.Name != "FindRuntimeEntityType" + && readonlyMethod.Name != "GetConcreteDerivedTypesInclusive" + && readonlyMethod.Name != "GetClosestCommonParent" + && readonlyMethod.Name != "LeastDerivedType" + && readonlyMethod.Name != "GetAllBaseTypesInclusive" + && readonlyMethod.Name != "GetAllBaseTypesInclusiveAscending" + join mutableMethod in typeTuple.Value.Mutable.GetMethods(PublicInstance | BindingFlags.Static) + on readonlyMethod.Name equals mutableMethod.Name into mutableGroup + from mutableMethod in mutableGroup.DefaultIfEmpty() + select (readonlyMethod, mutableMethod)) + .SelectMany(m => m.Select(MatchMutable)) + .Where(e => e != null) + .ToList(); Assert.False( errors.Count > 0, @@ -142,7 +143,8 @@ private string MatchMutable((MethodInfo Readonly, MethodInfo Mutable) methodTupl { if (mutableMethod.ReturnType != expectedReturnTypes.Mutable) { - return $"{mutableMethod.DeclaringType.Name}.{mutableMethod.Name} expected to have {expectedReturnTypes.Mutable} return type"; + return + $"{mutableMethod.DeclaringType.Name}.{mutableMethod.Name} expected to have {expectedReturnTypes.Mutable} return type"; } } else @@ -153,7 +155,8 @@ private string MatchMutable((MethodInfo Readonly, MethodInfo Mutable) methodTupl { if (mutableMethod.ReturnType.TryGetSequenceType() != expectedReturnTypes.Mutable) { - return $"{mutableMethod.DeclaringType.Name}.{mutableMethod.Name} expected to have a return type that derives from IEnumerable<{expectedReturnTypes.Mutable}>."; + return + $"{mutableMethod.DeclaringType.Name}.{mutableMethod.Name} expected to have a return type that derives from IEnumerable<{expectedReturnTypes.Mutable}>."; } } } @@ -166,19 +169,20 @@ private string MatchMutable((MethodInfo Readonly, MethodInfo Mutable) methodTupl public void Convention_metadata_types_have_matching_methods() { var errors = - MetadataTypes.Select(typeTuple => - from mutableMethod in typeTuple.Value.Mutable.GetMethods(PublicInstance | BindingFlags.Static) - where !mutableMethod.Name.StartsWith("set_") - && mutableMethod.Name != "get_Item" - && mutableMethod.Name != "RemoveIgnored" - && mutableMethod.Name != "GetContainingPrimaryKey" - join conventionMethod in typeTuple.Value.Convention.GetMethods(PublicInstance | BindingFlags.Static) - on mutableMethod.Name equals conventionMethod.Name into conventionGroup - from conventionMethod in conventionGroup.DefaultIfEmpty() - select (mutableMethod, conventionMethod)) - .SelectMany(m => m.Select(MatchConvention)) - .Where(e => e != null) - .ToList(); + MetadataTypes.Select( + typeTuple => + from mutableMethod in typeTuple.Value.Mutable.GetMethods(PublicInstance | BindingFlags.Static) + where !mutableMethod.Name.StartsWith("set_") + && mutableMethod.Name != "get_Item" + && mutableMethod.Name != "RemoveIgnored" + && mutableMethod.Name != "GetContainingPrimaryKey" + join conventionMethod in typeTuple.Value.Convention.GetMethods(PublicInstance | BindingFlags.Static) + on mutableMethod.Name equals conventionMethod.Name into conventionGroup + from conventionMethod in conventionGroup.DefaultIfEmpty() + select (mutableMethod, conventionMethod)) + .SelectMany(m => m.Select(MatchConvention)) + .Where(e => e != null) + .ToList(); Assert.False( errors.Count > 0, @@ -206,7 +210,8 @@ private string MatchConvention((MethodInfo Mutable, MethodInfo Convention) metho { if (conventionMethod.ReturnType != expectedReturnType) { - return $"{conventionMethod.DeclaringType.Name}.{conventionMethod.Name} expected to have {expectedReturnType} return type"; + return + $"{conventionMethod.DeclaringType.Name}.{conventionMethod.Name} expected to have {expectedReturnType} return type"; } } else @@ -217,7 +222,8 @@ private string MatchConvention((MethodInfo Mutable, MethodInfo Convention) metho { if (conventionMethod.ReturnType.TryGetSequenceType() != expectedReturnType) { - return $"{conventionMethod.DeclaringType.Name}.{conventionMethod.Name} expected to have a return type that derives from IEnumerable<{expectedReturnType}>."; + return + $"{conventionMethod.DeclaringType.Name}.{conventionMethod.Name} expected to have a return type that derives from IEnumerable<{expectedReturnType}>."; } } } @@ -237,7 +243,7 @@ var badServiceTypes = (from sd in serviceCollection where sd.ServiceType.Namespace.StartsWith("Microsoft.Entity", StringComparison.Ordinal) && sd.ServiceType != typeof(IDiagnosticsLogger<>) - && sd.ServiceType != typeof(LoggingDefinitions) + && sd.ServiceType != typeof(LoggingDefinitions) let it = TryGetImplementationType(sd) where !it.IsInterface let ns = it.Namespace @@ -391,7 +397,7 @@ where method.GetParameters().Any(pi => pi.ParameterType == typeof(CancellationTo var asyncMethodsWithoutToken = (from method in asyncMethods where !withoutCancellationToken.Contains(method.DeclaringType.Name + "." + method.Name) - && method.GetParameters().All(pi => pi.ParameterType != typeof(CancellationToken)) + && method.GetParameters().All(pi => pi.ParameterType != typeof(CancellationToken)) select method).ToList(); var missingOverloads @@ -424,12 +430,7 @@ var missingSuffixMethods [ConditionalFact] public virtual void Public_api_bool_parameters_should_not_be_prefixed() { - var prefixes = new[] - { - "is", - "can", - "has" - }; + var prefixes = new[] { "is", "can", "has" }; var parameters = ( from type in GetAllTypes(TargetAssembly.GetExportedTypes()) diff --git a/test/EFCore.Tests/ChangeTracking/AggregatesTest.cs b/test/EFCore.Tests/ChangeTracking/AggregatesTest.cs index bb5d61b42b6..36e8273c6b7 100644 --- a/test/EFCore.Tests/ChangeTracking/AggregatesTest.cs +++ b/test/EFCore.Tests/ChangeTracking/AggregatesTest.cs @@ -16,21 +16,8 @@ public void Can_add_aggregate() { var comments0 = new[] { new Comment(), new Comment() }; var comments1 = new[] { new Comment(), new Comment() }; - var posts = new[] - { - new Post - { - Comments = comments0.ToList() - }, - new Post - { - Comments = comments1.ToList() - } - }; - var blog = new Blog - { - Posts = posts.ToList() - }; + var posts = new[] { new Post { Comments = comments0.ToList() }, new Post { Comments = comments1.ToList() } }; + var blog = new Blog { Posts = posts.ToList() }; context.Add(blog); @@ -50,10 +37,7 @@ public void Can_add_one_to_one_aggregate() using (var context = new AggregateContext()) { var statistics = new BlogCategoryStatistics(); - var category = new BlogCategory - { - Statistics = statistics - }; + var category = new BlogCategory { Statistics = statistics }; context.Add(category); @@ -67,52 +51,14 @@ public void Can_attach_aggregate() { using (var context = new AggregateContext()) { - var comments0 = new[] - { - new Comment - { - Id = 33, - PostId = 55 - }, - new Comment - { - Id = 34, - PostId = 55 - } - }; - var comments1 = new[] - { - new Comment - { - Id = 44, - PostId = 56 - }, - new Comment - { - Id = 45, - PostId = 56 - } - }; + var comments0 = new[] { new Comment { Id = 33, PostId = 55 }, new Comment { Id = 34, PostId = 55 } }; + var comments1 = new[] { new Comment { Id = 44, PostId = 56 }, new Comment { Id = 45, PostId = 56 } }; var posts = new[] { - new Post - { - Id = 55, - BlogId = 66, - Comments = comments0.ToList() - }, - new Post - { - Id = 56, - BlogId = 66, - Comments = comments1.ToList() - } - }; - var blog = new Blog - { - Id = 66, - Posts = posts.ToList() + new Post { Id = 55, BlogId = 66, Comments = comments0.ToList() }, + new Post { Id = 56, BlogId = 66, Comments = comments1.ToList() } }; + var blog = new Blog { Id = 66, Posts = posts.ToList() }; context.Attach(blog); @@ -131,16 +77,8 @@ public void Can_attach_one_to_one_aggregate() { using (var context = new AggregateContext()) { - var statistics = new BlogCategoryStatistics - { - Id = 11, - BlogCategoryId = 22 - }; - var category = new BlogCategory - { - Id = 22, - Statistics = statistics - }; + var statistics = new BlogCategoryStatistics { Id = 11, BlogCategoryId = 22 }; + var category = new BlogCategory { Id = 22, Statistics = statistics }; context.Attach(category); @@ -156,21 +94,8 @@ public void Attaching_aggregate_with_no_key_set_adds_it_instead() { var comments0 = new[] { new Comment(), new Comment() }; var comments1 = new[] { new Comment(), new Comment() }; - var posts = new[] - { - new Post - { - Comments = comments0.ToList() - }, - new Post - { - Comments = comments1.ToList() - } - }; - var blog = new Blog - { - Posts = posts.ToList() - }; + var posts = new[] { new Post { Comments = comments0.ToList() }, new Post { Comments = comments1.ToList() } }; + var blog = new Blog { Posts = posts.ToList() }; context.Attach(blog); @@ -190,10 +115,7 @@ public void Attaching_one_to_one_aggregate_with_no_key_set_adds_it_instead() using (var context = new AggregateContext()) { var statistics = new BlogCategoryStatistics(); - var category = new BlogCategory - { - Statistics = statistics - }; + var category = new BlogCategory { Statistics = statistics }; context.Attach(category); @@ -207,49 +129,14 @@ public void Dependents_with_no_key_set_are_added() { using (var context = new AggregateContext()) { - var comments0 = new[] - { - new Comment - { - Id = 33, - PostId = 55 - }, - new Comment - { - Id = 34, - PostId = 55 - } - }; - var comments1 = new[] - { - new Comment - { - PostId = 56 - }, - new Comment - { - PostId = 56 - } - }; + var comments0 = new[] { new Comment { Id = 33, PostId = 55 }, new Comment { Id = 34, PostId = 55 } }; + var comments1 = new[] { new Comment { PostId = 56 }, new Comment { PostId = 56 } }; var posts = new[] { - new Post - { - Id = 55, - BlogId = 66, - Comments = comments0.ToList() - }, - new Post - { - BlogId = 66, - Comments = comments1.ToList() - } - }; - var blog = new Blog - { - Id = 66, - Posts = posts.ToList() + new Post { Id = 55, BlogId = 66, Comments = comments0.ToList() }, + new Post { BlogId = 66, Comments = comments1.ToList() } }; + var blog = new Blog { Id = 66, Posts = posts.ToList() }; context.Attach(blog); @@ -268,15 +155,8 @@ public void One_to_one_dependents_with_no_key_set_are_added() { using (var context = new AggregateContext()) { - var statistics = new BlogCategoryStatistics - { - BlogCategoryId = 22 - }; - var category = new BlogCategory - { - Id = 22, - Statistics = statistics - }; + var statistics = new BlogCategoryStatistics { BlogCategoryId = 22 }; + var category = new BlogCategory { Id = 22, Statistics = statistics }; context.Attach(category); @@ -290,70 +170,17 @@ public void Can_add_aggregate_with_linked_aggregate_also_added() { using (var context = new AggregateContext()) { - var reminders = new[] - { - new Reminder - { - Id = 11 - }, - new Reminder - { - Id = 12 - } - }; - var author = new Author - { - Id = 22, - Reminders = reminders.ToList() - }; + var reminders = new[] { new Reminder { Id = 11 }, new Reminder { Id = 12 } }; + var author = new Author { Id = 22, Reminders = reminders.ToList() }; - var comments0 = new[] - { - new Comment - { - Id = 33, - Author = author - }, - new Comment - { - Id = 34, - Author = author - } - }; - var comments1 = new[] - { - new Comment - { - Id = 44, - Author = author - }, - new Comment - { - Id = 45, - Author = author - } - }; + var comments0 = new[] { new Comment { Id = 33, Author = author }, new Comment { Id = 34, Author = author } }; + var comments1 = new[] { new Comment { Id = 44, Author = author }, new Comment { Id = 45, Author = author } }; var posts = new[] { - new Post - { - Id = 55, - Author = author, - Comments = comments0.ToList() - }, - new Post - { - Id = 56, - Author = author, - Comments = comments1.ToList() - } - }; - var blog = new Blog - { - Id = 66, - Author = author, - Posts = posts.ToList() + new Post { Id = 55, Author = author, Comments = comments0.ToList() }, + new Post { Id = 56, Author = author, Comments = comments1.ToList() } }; + var blog = new Blog { Id = 66, Author = author, Posts = posts.ToList() }; context.Add(blog); @@ -375,70 +202,17 @@ public void Can_add_aggregate_with_other_linked_aggregate_also_attached() { using (var context = new AggregateContext()) { - var reminders = new[] - { - new Reminder - { - Id = 11 - }, - new Reminder - { - Id = 12 - } - }; - var author = new Author - { - Id = 22, - Reminders = reminders.ToList() - }; + var reminders = new[] { new Reminder { Id = 11 }, new Reminder { Id = 12 } }; + var author = new Author { Id = 22, Reminders = reminders.ToList() }; - var comments0 = new[] - { - new Comment - { - Id = 33, - Author = author - }, - new Comment - { - Id = 34, - Author = author - } - }; - var comments1 = new[] - { - new Comment - { - Id = 44, - Author = author - }, - new Comment - { - Id = 45, - Author = author - } - }; + var comments0 = new[] { new Comment { Id = 33, Author = author }, new Comment { Id = 34, Author = author } }; + var comments1 = new[] { new Comment { Id = 44, Author = author }, new Comment { Id = 45, Author = author } }; var posts = new[] { - new Post - { - Id = 55, - Author = author, - Comments = comments0.ToList() - }, - new Post - { - Id = 56, - Author = author, - Comments = comments1.ToList() - } - }; - var blog = new Blog - { - Id = 66, - Author = author, - Posts = posts.ToList() + new Post { Id = 55, Author = author, Comments = comments0.ToList() }, + new Post { Id = 56, Author = author, Comments = comments1.ToList() } }; + var blog = new Blog { Id = 66, Author = author, Posts = posts.ToList() }; author.Comments = comments0.Concat(comments1).ToList(); comments0[0].Post = posts[0]; @@ -464,59 +238,19 @@ public void Can_attach_aggregate_with_linked_aggregate_also_attached() { using (var context = new AggregateContext()) { - var reminders = new[] - { - new Reminder - { - Id = 11, - AuthorId = 22 - }, - new Reminder - { - Id = 12, - AuthorId = 22 - } - }; - var author = new Author - { - Id = 22, - Reminders = reminders.ToList() - }; + var reminders = new[] { new Reminder { Id = 11, AuthorId = 22 }, new Reminder { Id = 12, AuthorId = 22 } }; + var author = new Author { Id = 22, Reminders = reminders.ToList() }; var comments0 = new[] { - new Comment - { - Id = 33, - AuthorId = 22, - PostId = 55, - Author = author - }, - new Comment - { - Id = 34, - AuthorId = 22, - PostId = 55, - Author = author - } + new Comment { Id = 33, AuthorId = 22, PostId = 55, Author = author }, + new Comment { Id = 34, AuthorId = 22, PostId = 55, Author = author } }; var comments1 = new[] { - new Comment - { - Id = 44, - AuthorId = 22, - PostId = 56, - Author = author - }, - new Comment - { - Id = 45, - AuthorId = 22, - PostId = 56, - Author = author - } + new Comment { Id = 44, AuthorId = 22, PostId = 56, Author = author }, + new Comment { Id = 45, AuthorId = 22, PostId = 56, Author = author } }; var posts = new[] @@ -539,13 +273,7 @@ public void Can_attach_aggregate_with_linked_aggregate_also_attached() } }; - var blog = new Blog - { - Id = 66, - AuthorId = 22, - Author = author, - Posts = posts.ToList() - }; + var blog = new Blog { Id = 66, AuthorId = 22, Author = author, Posts = posts.ToList() }; context.Attach(blog); @@ -567,70 +295,17 @@ public void Can_add_two_aggregates_linked_down_the_tree() { using (var context = new AggregateContext()) { - var reminders = new[] - { - new Reminder - { - Id = 11 - }, - new Reminder - { - Id = 12 - } - }; - var author = new Author - { - Id = 22, - Reminders = reminders.ToList() - }; + var reminders = new[] { new Reminder { Id = 11 }, new Reminder { Id = 12 } }; + var author = new Author { Id = 22, Reminders = reminders.ToList() }; - var comments0 = new[] - { - new Comment - { - Id = 33, - Author = author - }, - new Comment - { - Id = 34, - Author = author - } - }; - var comments1 = new[] - { - new Comment - { - Id = 44, - Author = author - }, - new Comment - { - Id = 45, - Author = author - } - }; + var comments0 = new[] { new Comment { Id = 33, Author = author }, new Comment { Id = 34, Author = author } }; + var comments1 = new[] { new Comment { Id = 44, Author = author }, new Comment { Id = 45, Author = author } }; var posts = new[] { - new Post - { - Id = 55, - Author = author, - Comments = comments0.ToList() - }, - new Post - { - Id = 56, - Author = author, - Comments = comments1.ToList() - } - }; - var blog = new Blog - { - Id = 66, - Author = author, - Posts = posts.ToList() + new Post { Id = 55, Author = author, Comments = comments0.ToList() }, + new Post { Id = 56, Author = author, Comments = comments1.ToList() } }; + var blog = new Blog { Id = 66, Author = author, Posts = posts.ToList() }; context.AddRange(blog, author); diff --git a/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs b/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs index f552d6e58cd..75bb31e5c02 100644 --- a/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs +++ b/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs @@ -39,11 +39,15 @@ public void DetectChanges_is_logged() var (level, _, message, _, _) = _loggerFactory.Log.Single(e => e.Id.Id == CoreEventId.DetectChangesStarting.Id); Assert.Equal(LogLevel.Debug, level); - Assert.Equal(CoreResources.LogDetectChangesStarting(new TestLogger()).GenerateMessage(nameof(LikeAZooContext)), message); + Assert.Equal( + CoreResources.LogDetectChangesStarting(new TestLogger()) + .GenerateMessage(nameof(LikeAZooContext)), message); (level, _, message, _, _) = _loggerFactory.Log.Single(e => e.Id.Id == CoreEventId.DetectChangesCompleted.Id); Assert.Equal(LogLevel.Debug, level); - Assert.Equal(CoreResources.LogDetectChangesCompleted(new TestLogger()).GenerateMessage(nameof(LikeAZooContext)), message); + Assert.Equal( + CoreResources.LogDetectChangesCompleted(new TestLogger()) + .GenerateMessage(nameof(LikeAZooContext)), message); } } @@ -69,7 +73,8 @@ public void Detect_property_change_is_logged(bool sensitive) sensitive ? CoreResources.LogPropertyChangeDetectedSensitive(new TestLogger()).GenerateMessage( nameof(Cat), nameof(Cat.Name), "Smokey", "Smoke-a-doke", "{Id: 1}") - : CoreResources.LogPropertyChangeDetected(new TestLogger()).GenerateMessage(nameof(Cat), nameof(Cat.Name)), + : CoreResources.LogPropertyChangeDetected(new TestLogger()) + .GenerateMessage(nameof(Cat), nameof(Cat.Name)), message); _loggerFactory.Log.Clear(); @@ -102,8 +107,10 @@ public void Detect_foreign_key_property_change_is_logged(bool sensitive) Assert.Equal(LogLevel.Debug, level); Assert.Equal( sensitive - ? CoreResources.LogForeignKeyChangeDetectedSensitive(new TestLogger()).GenerateMessage(nameof(Hat), nameof(Hat.CatId), 1, 2, "{Id: 77}") - : CoreResources.LogForeignKeyChangeDetected(new TestLogger()).GenerateMessage(nameof(Hat), nameof(Hat.CatId)), + ? CoreResources.LogForeignKeyChangeDetectedSensitive(new TestLogger()) + .GenerateMessage(nameof(Hat), nameof(Hat.CatId), 1, 2, "{Id: 77}") + : CoreResources.LogForeignKeyChangeDetected(new TestLogger()) + .GenerateMessage(nameof(Hat), nameof(Hat.CatId)), message); _loggerFactory.Log.Clear(); @@ -115,8 +122,10 @@ public void Detect_foreign_key_property_change_is_logged(bool sensitive) Assert.Equal(LogLevel.Debug, level); Assert.Equal( sensitive - ? CoreResources.LogForeignKeyChangeDetectedSensitive(new TestLogger()).GenerateMessage(nameof(Hat), nameof(Hat.CatId), 2, 1, "{Id: 77}") - : CoreResources.LogForeignKeyChangeDetected(new TestLogger()).GenerateMessage(nameof(Hat), nameof(Hat.CatId)), + ? CoreResources.LogForeignKeyChangeDetectedSensitive(new TestLogger()) + .GenerateMessage(nameof(Hat), nameof(Hat.CatId), 2, 1, "{Id: 77}") + : CoreResources.LogForeignKeyChangeDetected(new TestLogger()) + .GenerateMessage(nameof(Hat), nameof(Hat.CatId)), message); } } @@ -142,8 +151,10 @@ public void Detect_collection_change_is_logged(bool sensitive) Assert.Equal(LogLevel.Debug, level); Assert.Equal( sensitive - ? CoreResources.LogCollectionChangeDetectedSensitive(new TestLogger()).GenerateMessage(0, 1, nameof(Cat), nameof(Cat.Hats), "{Id: 1}") - : CoreResources.LogCollectionChangeDetected(new TestLogger()).GenerateMessage(0, 1, nameof(Cat), nameof(Cat.Hats)), + ? CoreResources.LogCollectionChangeDetectedSensitive(new TestLogger()) + .GenerateMessage(0, 1, nameof(Cat), nameof(Cat.Hats), "{Id: 1}") + : CoreResources.LogCollectionChangeDetected(new TestLogger()) + .GenerateMessage(0, 1, nameof(Cat), nameof(Cat.Hats)), message); _loggerFactory.Log.Clear(); @@ -155,8 +166,10 @@ public void Detect_collection_change_is_logged(bool sensitive) Assert.Equal(LogLevel.Debug, level); Assert.Equal( sensitive - ? CoreResources.LogCollectionChangeDetectedSensitive(new TestLogger()).GenerateMessage(1, 0, nameof(Cat), nameof(Cat.Hats), "{Id: 1}") - : CoreResources.LogCollectionChangeDetected(new TestLogger()).GenerateMessage(1, 0, nameof(Cat), nameof(Cat.Hats)), + ? CoreResources.LogCollectionChangeDetectedSensitive(new TestLogger()) + .GenerateMessage(1, 0, nameof(Cat), nameof(Cat.Hats), "{Id: 1}") + : CoreResources.LogCollectionChangeDetected(new TestLogger()) + .GenerateMessage(1, 0, nameof(Cat), nameof(Cat.Hats)), message); } } @@ -182,8 +195,10 @@ public void Detect_reference_change_is_logged(bool sensitive) Assert.Equal(LogLevel.Debug, level); Assert.Equal( sensitive - ? CoreResources.LogReferenceChangeDetectedSensitive(new TestLogger()).GenerateMessage(nameof(Hat), nameof(Hat.Cat), "{Id: 77}") - : CoreResources.LogReferenceChangeDetected(new TestLogger()).GenerateMessage(nameof(Hat), nameof(Hat.Cat)), + ? CoreResources.LogReferenceChangeDetectedSensitive(new TestLogger()) + .GenerateMessage(nameof(Hat), nameof(Hat.Cat), "{Id: 77}") + : CoreResources.LogReferenceChangeDetected(new TestLogger()) + .GenerateMessage(nameof(Hat), nameof(Hat.Cat)), message); _loggerFactory.Log.Clear(); @@ -195,8 +210,10 @@ public void Detect_reference_change_is_logged(bool sensitive) Assert.Equal(LogLevel.Debug, level); Assert.Equal( sensitive - ? CoreResources.LogReferenceChangeDetectedSensitive(new TestLogger()).GenerateMessage(nameof(Hat), nameof(Hat.Cat), "{Id: 77}") - : CoreResources.LogReferenceChangeDetected(new TestLogger()).GenerateMessage(nameof(Hat), nameof(Hat.Cat)), + ? CoreResources.LogReferenceChangeDetectedSensitive(new TestLogger()) + .GenerateMessage(nameof(Hat), nameof(Hat.Cat), "{Id: 77}") + : CoreResources.LogReferenceChangeDetected(new TestLogger()) + .GenerateMessage(nameof(Hat), nameof(Hat.Cat)), message); } } @@ -217,8 +234,10 @@ public void Start_tracking_is_logged_from_query(bool sensitive) Assert.Equal(LogLevel.Debug, level); Assert.Equal( sensitive - ? CoreResources.LogStartedTrackingSensitive(new TestLogger()).GenerateMessage(nameof(LikeAZooContextSensitive), nameof(Cat), "{Id: 1}") - : CoreResources.LogStartedTracking(new TestLogger()).GenerateMessage(nameof(LikeAZooContext), nameof(Cat)), + ? CoreResources.LogStartedTrackingSensitive(new TestLogger()).GenerateMessage( + nameof(LikeAZooContextSensitive), nameof(Cat), "{Id: 1}") + : CoreResources.LogStartedTracking(new TestLogger()) + .GenerateMessage(nameof(LikeAZooContext), nameof(Cat)), message); } } @@ -237,8 +256,10 @@ public void Start_tracking_is_logged_from_attach(bool sensitive) Assert.Equal(LogLevel.Debug, level); Assert.Equal( sensitive - ? CoreResources.LogStartedTrackingSensitive(new TestLogger()).GenerateMessage(nameof(LikeAZooContextSensitive), nameof(Hat), "{Id: 88}") - : CoreResources.LogStartedTracking(new TestLogger()).GenerateMessage(nameof(LikeAZooContext), nameof(Hat)), + ? CoreResources.LogStartedTrackingSensitive(new TestLogger()).GenerateMessage( + nameof(LikeAZooContextSensitive), nameof(Hat), "{Id: 88}") + : CoreResources.LogStartedTracking(new TestLogger()) + .GenerateMessage(nameof(LikeAZooContext), nameof(Hat)), message); } } @@ -308,7 +329,8 @@ public async Task Value_generation_is_logged(bool sensitive, bool async, bool te sensitive ? CoreResources.LogTempValueGeneratedSensitive(new TestLogger()).GenerateMessage( nameof(LikeAZooContextSensitive), 1, nameof(Hat.Id), nameof(Hat)) - : CoreResources.LogTempValueGenerated(new TestLogger()).GenerateMessage(nameof(LikeAZooContext), nameof(Hat.Id), nameof(Hat)), + : CoreResources.LogTempValueGenerated(new TestLogger()).GenerateMessage( + nameof(LikeAZooContext), nameof(Hat.Id), nameof(Hat)), message); } else @@ -317,7 +339,8 @@ public async Task Value_generation_is_logged(bool sensitive, bool async, bool te sensitive ? CoreResources.LogValueGeneratedSensitive(new TestLogger()).GenerateMessage( nameof(LikeAZooContextSensitive), 1, nameof(Hat.Id), nameof(Hat)) - : CoreResources.LogValueGenerated(new TestLogger()).GenerateMessage(nameof(LikeAZooContext), nameof(Hat.Id), nameof(Hat)), + : CoreResources.LogValueGenerated(new TestLogger()).GenerateMessage( + nameof(LikeAZooContext), nameof(Hat.Id), nameof(Hat)), message); } } @@ -412,8 +435,10 @@ public void Cascade_delete_is_logged( void CaptureMessages() { - (cascadeDeleteLevel, _, cascadeDeleteMessage, _, _) = _loggerFactory.Log.FirstOrDefault(e => e.Id.Id == CoreEventId.CascadeDelete.Id); - (_, _, deleteOrphansMessage, _, _) = _loggerFactory.Log.FirstOrDefault(e => e.Id.Id == CoreEventId.CascadeDeleteOrphan.Id); + (cascadeDeleteLevel, _, cascadeDeleteMessage, _, _) = + _loggerFactory.Log.FirstOrDefault(e => e.Id.Id == CoreEventId.CascadeDelete.Id); + (_, _, deleteOrphansMessage, _, _) = + _loggerFactory.Log.FirstOrDefault(e => e.Id.Id == CoreEventId.CascadeDeleteOrphan.Id); } void ClearMessages() @@ -464,8 +489,10 @@ void ClearMessages() Assert.Equal(LogLevel.Debug, cascadeDeleteLevel); Assert.Equal( sensitive - ? CoreResources.LogCascadeDeleteSensitive(new TestLogger()).GenerateMessage(nameof(Hat), "{Id: 77}", EntityState.Deleted, nameof(Cat), "{Id: 1}") - : CoreResources.LogCascadeDelete(new TestLogger()).GenerateMessage(nameof(Hat), EntityState.Deleted, nameof(Cat)), + ? CoreResources.LogCascadeDeleteSensitive(new TestLogger()).GenerateMessage( + nameof(Hat), "{Id: 77}", EntityState.Deleted, nameof(Cat), "{Id: 1}") + : CoreResources.LogCascadeDelete(new TestLogger()).GenerateMessage( + nameof(Hat), EntityState.Deleted, nameof(Cat)), cascadeDeleteMessage); } } @@ -532,7 +559,8 @@ public void Cascade_delete_orphan_is_logged( void CaptureMessages() { (_, _, cascadeDeleteMessage, _, _) = _loggerFactory.Log.FirstOrDefault(e => e.Id.Id == CoreEventId.CascadeDelete.Id); - (deleteOrphansLevel, _, deleteOrphansMessage, _, _) = _loggerFactory.Log.FirstOrDefault(e => e.Id.Id == CoreEventId.CascadeDeleteOrphan.Id); + (deleteOrphansLevel, _, deleteOrphansMessage, _, _) = + _loggerFactory.Log.FirstOrDefault(e => e.Id.Id == CoreEventId.CascadeDeleteOrphan.Id); } void ClearMessages() @@ -586,8 +614,10 @@ void ClearMessages() Assert.Equal(LogLevel.Debug, deleteOrphansLevel); Assert.Equal( sensitive - ? CoreResources.LogCascadeDeleteOrphanSensitive(new TestLogger()).GenerateMessage(nameof(Hat), "{Id: 77}", EntityState.Deleted, nameof(Cat)) - : CoreResources.LogCascadeDeleteOrphan(new TestLogger()).GenerateMessage(nameof(Hat), EntityState.Deleted, nameof(Cat)), + ? CoreResources.LogCascadeDeleteOrphanSensitive(new TestLogger()).GenerateMessage( + nameof(Hat), "{Id: 77}", EntityState.Deleted, nameof(Cat)) + : CoreResources.LogCascadeDeleteOrphan(new TestLogger()) + .GenerateMessage(nameof(Hat), EntityState.Deleted, nameof(Cat)), deleteOrphansMessage); } } @@ -619,11 +649,15 @@ public async Task SaveChanges_is_logged(bool async) var (level, _, message, _, _) = _loggerFactory.Log.Single(e => e.Id.Id == CoreEventId.SaveChangesStarting.Id); Assert.Equal(LogLevel.Debug, level); - Assert.Equal(CoreResources.LogSaveChangesStarting(new TestLogger()).GenerateMessage(nameof(LikeAZooContext)), message); + Assert.Equal( + CoreResources.LogSaveChangesStarting(new TestLogger()).GenerateMessage(nameof(LikeAZooContext)), + message); (level, _, message, _, _) = _loggerFactory.Log.Single(e => e.Id.Id == CoreEventId.SaveChangesCompleted.Id); Assert.Equal(LogLevel.Debug, level); - Assert.Equal(CoreResources.LogSaveChangesCompleted(new TestLogger()).GenerateMessage(nameof(LikeAZooContext), 1), message); + Assert.Equal( + CoreResources.LogSaveChangesCompleted(new TestLogger()) + .GenerateMessage(nameof(LikeAZooContext), 1), message); } } @@ -639,7 +673,9 @@ public void Context_Dispose_is_logged() var (level, _, message, _, _) = _loggerFactory.Log.Single(e => e.Id.Id == CoreEventId.ContextDisposed.Id); Assert.Equal(LogLevel.Debug, level); - Assert.Equal(CoreResources.LogContextDisposed(new TestLogger()).GenerateMessage(nameof(LikeAZooContext)), message); + Assert.Equal( + CoreResources.LogContextDisposed(new TestLogger()).GenerateMessage(nameof(LikeAZooContext)), + message); } [ConditionalFact] @@ -885,10 +921,7 @@ public void State_change_events_fire_when_property_modified_flags_cause_state_ch RegisterEvents(context, tracked, changed); var cat = context.Attach( - new Cat(3) - { - Name = "Achilles" - }).Entity; + new Cat(3) { Name = "Achilles" }).Entity; Assert.Equal(1, tracked.Count); Assert.Equal(0, changed.Count); @@ -1150,11 +1183,7 @@ public void Can_remove_dependent_identifying_one_to_many(bool saveEntities) { var product = new Product(); var order = new Order(); - var orderDetails = new OrderDetails - { - Order = order, - Product = product - }; + var orderDetails = new OrderDetails { Order = order, Product = product }; context.Add(orderDetails); if (saveEntities) @@ -1295,12 +1324,7 @@ public void Can_attach_nullable_PK_parent_with_child_collection(bool useAttach, { var category = new NullbileCategory { - Products = new List - { - new NullbileProduct(), - new NullbileProduct(), - new NullbileProduct() - } + Products = new List { new NullbileProduct(), new NullbileProduct(), new NullbileProduct() } }; if (setKeys) @@ -1372,10 +1396,7 @@ public void Can_attach_nullable_PK_parent_with_one_to_one_children(bool useAttac { using (var context = new EarlyLearningCenter()) { - var category = new NullbileCategory - { - Info = new NullbileCategoryInfo() - }; + var category = new NullbileCategory { Info = new NullbileCategoryInfo() }; if (setKeys) { @@ -1399,11 +1420,7 @@ public void Can_attach_nullable_PK_parent_with_one_to_one_children(bool useAttac }); Assert.Equal( - new List - { - " -----> NullbileCategory:1", - "NullbileCategory:1 ---Info--> NullbileCategoryInfo:1" - }, + new List { " -----> NullbileCategory:1", "NullbileCategory:1 ---Info--> NullbileCategoryInfo:1" }, traversal); } @@ -1430,14 +1447,7 @@ public void Can_attach_parent_with_owned_dependent(bool useAttach, bool setPrinc { using (var context = new EarlyLearningCenter()) { - var sweet = new Sweet - { - Dreams = new Dreams - { - Are = new AreMade(), - Made = new AreMade() - } - }; + var sweet = new Sweet { Dreams = new Dreams { Are = new AreMade(), Made = new AreMade() } }; if (setPrincipalKey) { @@ -1516,15 +1526,7 @@ public void Can_attach_owned_dependent_with_reference_to_parent(bool useAttach, { using (var context = new EarlyLearningCenter()) { - var dreams = new Dreams - { - Sweet = new Sweet - { - Id = 1 - }, - Are = new AreMade(), - Made = new AreMade() - }; + var dreams = new Dreams { Sweet = new Sweet { Id = 1 }, Are = new AreMade(), Made = new AreMade() }; if (setDependentKey) { @@ -1589,22 +1591,7 @@ public void Can_attach_parent_with_child_collection() { var category = new Category { - Id = 1, - Products = new List - { - new Product - { - Id = 1 - }, - new Product - { - Id = 2 - }, - new Product - { - Id = 3 - } - } + Id = 1, Products = new List { new Product { Id = 1 }, new Product { Id = 2 }, new Product { Id = 3 } } }; var traversal = new List(); @@ -1648,14 +1635,7 @@ public void Can_attach_child_with_reference_to_parent() { using (var context = new EarlyLearningCenter()) { - var product = new Product - { - Id = 1, - Category = new Category - { - Id = 1 - } - }; + var product = new Product { Id = 1, Category = new Category { Id = 1 } }; var traversal = new List(); @@ -1667,11 +1647,7 @@ public void Can_attach_child_with_reference_to_parent() }); Assert.Equal( - new List - { - " -----> Product:1", - "Product:1 ---Category--> Category:1" - }, + new List { " -----> Product:1", "Product:1 ---Category--> Category:1" }, traversal); Assert.Equal(2, context.ChangeTracker.Entries().Count()); @@ -1689,18 +1665,7 @@ public void Can_attach_parent_with_one_to_one_children() { using (var context = new EarlyLearningCenter()) { - var product = new Product - { - Id = 1, - Details = new ProductDetails - { - Id = 1, - Tag = new ProductDetailsTag - { - Id = 1 - } - } - }; + var product = new Product { Id = 1, Details = new ProductDetails { Id = 1, Tag = new ProductDetailsTag { Id = 1 } } }; var traversal = new List(); @@ -1736,18 +1701,7 @@ public void Can_attach_child_with_one_to_one_parents() { using (var context = new EarlyLearningCenter()) { - var tag = new ProductDetailsTag - { - Id = 1, - Details = new ProductDetails - { - Id = 1, - Product = new Product - { - Id = 1 - } - } - }; + var tag = new ProductDetailsTag { Id = 1, Details = new ProductDetails { Id = 1, Product = new Product { Id = 1 } } }; var traversal = new List(); @@ -1783,18 +1737,7 @@ public void Can_attach_entity_with_one_to_one_parent_and_child() { using (var context = new EarlyLearningCenter()) { - var details = new ProductDetails - { - Id = 1, - Product = new Product - { - Id = 1 - }, - Tag = new ProductDetailsTag - { - Id = 1 - } - }; + var details = new ProductDetails { Id = 1, Product = new Product { Id = 1 }, Tag = new ProductDetailsTag { Id = 1 } }; var traversal = new List(); @@ -1831,27 +1774,11 @@ public void Entities_that_are_already_tracked_will_not_get_attached() using (var context = new EarlyLearningCenter()) { var existingProduct = context.Attach( - new Product - { - Id = 2, - CategoryId = 1 - }).Entity; + new Product { Id = 2, CategoryId = 1 }).Entity; var category = new Category { - Id = 1, - Products = new List - { - new Product - { - Id = 1 - }, - existingProduct, - new Product - { - Id = 3 - } - } + Id = 1, Products = new List { new Product { Id = 1 }, existingProduct, new Product { Id = 3 } } }; var traversal = new List(); @@ -1866,9 +1793,7 @@ public void Entities_that_are_already_tracked_will_not_get_attached() Assert.Equal( new List { - " -----> Category:1", - "Category:1 ---Products--> Product:1", - "Category:1 ---Products--> Product:3" + " -----> Category:1", "Category:1 ---Products--> Product:1", "Category:1 ---Products--> Product:3" }, traversal); @@ -1899,33 +1824,9 @@ public void Further_graph_traversal_stops_if_an_entity_is_not_attached() Id = 1, Products = new List { - new Product - { - Id = 1, - CategoryId = 1, - Details = new ProductDetails - { - Id = 1 - } - }, - new Product - { - Id = 2, - CategoryId = 1, - Details = new ProductDetails - { - Id = 2 - } - }, - new Product - { - Id = 3, - CategoryId = 1, - Details = new ProductDetails - { - Id = 3 - } - } + new Product { Id = 1, CategoryId = 1, Details = new ProductDetails { Id = 1 } }, + new Product { Id = 2, CategoryId = 1, Details = new ProductDetails { Id = 2 } }, + new Product { Id = 3, CategoryId = 1, Details = new ProductDetails { Id = 3 } } } }; @@ -1983,14 +1884,7 @@ public void Graph_iterator_does_not_go_visit_Apple() { using (var context = new EarlyLearningCenter()) { - var details = new ProductDetails - { - Id = 1, - Product = new Product - { - Id = 1 - } - }; + var details = new ProductDetails { Id = 1, Product = new Product { Id = 1 } }; details.Product.Details = details; var traversal = new List(); @@ -1998,10 +1892,7 @@ public void Graph_iterator_does_not_go_visit_Apple() context.ChangeTracker.TrackGraph(details, e => traversal.Add(NodeString(e))); Assert.Equal( - new List - { - " -----> ProductDetails:1" - }, + new List { " -----> ProductDetails:1" }, traversal); Assert.Equal(0, context.ChangeTracker.Entries().Count(e => e.State != EntityState.Detached)); @@ -2063,21 +1954,9 @@ private static void KeyValueAttachTest(Action tracker, Id = 77, Products = new List { - new Product - { - Id = 77, - CategoryId = expectModified ? 0 : 77 - }, - new Product - { - Id = 0, - CategoryId = expectModified ? 0 : 77 - }, - new Product - { - Id = 78, - CategoryId = expectModified ? 0 : 77 - } + new Product { Id = 77, CategoryId = expectModified ? 0 : 77 }, + new Product { Id = 0, CategoryId = expectModified ? 0 : 77 }, + new Product { Id = 78, CategoryId = expectModified ? 0 : 77 } } }; @@ -2118,21 +1997,9 @@ public void Can_attach_graph_using_custom_delegate() Id = 77, Products = new List { - new Product - { - Id = 77, - CategoryId = 77 - }, - new Product - { - Id = 0, - CategoryId = 77 - }, - new Product - { - Id = 78, - CategoryId = 77 - } + new Product { Id = 77, CategoryId = 77 }, + new Product { Id = 0, CategoryId = 77 }, + new Product { Id = 78, CategoryId = 77 } } }; @@ -2187,15 +2054,7 @@ public void Can_add_owned_dependent_with_reference_to_parent(bool useAdd, bool s { using (var context = new EarlyLearningCenter()) { - var dreams = new Dreams - { - Sweet = new Sweet - { - Id = 1 - }, - Are = new AreMade(), - Made = new AreMade() - }; + var dreams = new Dreams { Sweet = new Sweet { Id = 1 }, Are = new AreMade(), Made = new AreMade() }; context.Entry(dreams.Sweet).State = EntityState.Unchanged; @@ -2263,33 +2122,29 @@ public void Adding_derived_owned_throws(bool useAdd) { using (var context = new EarlyLearningCenter()) { - var dreams = new Dreams - { - Sweet = new Sweet - { - Id = 1 - }, - Are = new OfThis() - }; + var dreams = new Dreams { Sweet = new Sweet { Id = 1 }, Are = new OfThis() }; context.Entry(dreams.Sweet).State = EntityState.Unchanged; if (useAdd) { - Assert.Equal(CoreStrings.TrackingTypeMismatch(nameof(OfThis), "Dreams.Are#AreMade"), + Assert.Equal( + CoreStrings.TrackingTypeMismatch(nameof(OfThis), "Dreams.Are#AreMade"), Assert.Throws(() => context.Add(dreams)).Message); } else { - Assert.Equal(CoreStrings.TrackingTypeMismatch(nameof(OfThis), "Dreams.Are#AreMade"), - Assert.Throws(() => - context.ChangeTracker.TrackGraph( - dreams, e => - { - e.Entry.State = e.Entry.IsKeySet && !e.Entry.Metadata.IsOwned() - ? EntityState.Unchanged - : EntityState.Added; - })).Message); + Assert.Equal( + CoreStrings.TrackingTypeMismatch(nameof(OfThis), "Dreams.Are#AreMade"), + Assert.Throws( + () => + context.ChangeTracker.TrackGraph( + dreams, e => + { + e.Entry.State = e.Entry.IsKeySet && !e.Entry.Metadata.IsOwned() + ? EntityState.Unchanged + : EntityState.Added; + })).Message); } } } @@ -2299,14 +2154,7 @@ public void Moving_derived_owned_to_non_derived_reference_throws() { using (var context = new EarlyLearningCenter()) { - var dreams = new Dreams - { - Sweet = new Sweet - { - Id = 1 - }, - OfThis = new OfThis() - }; + var dreams = new Dreams { Sweet = new Sweet { Id = 1 }, OfThis = new OfThis() }; context.Entry(dreams.Sweet).State = EntityState.Unchanged; context.Add(dreams); @@ -2314,7 +2162,8 @@ public void Moving_derived_owned_to_non_derived_reference_throws() dreams.Are = dreams.OfThis; dreams.OfThis = null; - Assert.Equal(CoreStrings.TrackingTypeMismatch(nameof(OfThis), "Dreams.Are#AreMade"), + Assert.Equal( + CoreStrings.TrackingTypeMismatch(nameof(OfThis), "Dreams.Are#AreMade"), Assert.Throws(() => context.Entry(dreams)).Message); } } @@ -2326,23 +2175,11 @@ public void Can_add_principal_and_then_identifying_dependents_with_key_generatio { var product1 = new Product { - Details = new ProductDetails - { - Tag = new ProductDetailsTag - { - TagDetails = new ProductDetailsTagDetails() - } - } + Details = new ProductDetails { Tag = new ProductDetailsTag { TagDetails = new ProductDetailsTagDetails() } } }; var product2 = new Product { - Details = new ProductDetails - { - Tag = new ProductDetailsTag - { - TagDetails = new ProductDetailsTagDetails() - } - } + Details = new ProductDetails { Tag = new ProductDetailsTag { TagDetails = new ProductDetailsTagDetails() } } }; context.Add(product1); @@ -2365,24 +2202,12 @@ public void Can_add_identifying_dependents_and_then_principal_with_key_generatio { var tagDetails1 = new ProductDetailsTagDetails { - Tag = new ProductDetailsTag - { - Details = new ProductDetails - { - Product = new Product() - } - } + Tag = new ProductDetailsTag { Details = new ProductDetails { Product = new Product() } } }; var tagDetails2 = new ProductDetailsTagDetails { - Tag = new ProductDetailsTag - { - Details = new ProductDetails - { - Product = new Product() - } - } + Tag = new ProductDetailsTag { Details = new ProductDetails { Product = new Product() } } }; context.Add(tagDetails1); @@ -2405,24 +2230,12 @@ public void Can_add_identifying_dependents_and_then_principal_interleaved_with_k { var tagDetails1 = new ProductDetailsTagDetails { - Tag = new ProductDetailsTag - { - Details = new ProductDetails - { - Product = new Product() - } - } + Tag = new ProductDetailsTag { Details = new ProductDetails { Product = new Product() } } }; var tagDetails2 = new ProductDetailsTagDetails { - Tag = new ProductDetailsTag - { - Details = new ProductDetails - { - Product = new Product() - } - } + Tag = new ProductDetailsTag { Details = new ProductDetails { Product = new Product() } } }; context.Add(tagDetails1); @@ -2445,24 +2258,12 @@ public void Can_add_identifying_dependents_and_principal_starting_in_the_middle_ { var tagDetails1 = new ProductDetailsTagDetails { - Tag = new ProductDetailsTag - { - Details = new ProductDetails - { - Product = new Product() - } - } + Tag = new ProductDetailsTag { Details = new ProductDetails { Product = new Product() } } }; var tagDetails2 = new ProductDetailsTagDetails { - Tag = new ProductDetailsTag - { - Details = new ProductDetails - { - Product = new Product() - } - } + Tag = new ProductDetailsTag { Details = new ProductDetails { Product = new Product() } } }; context.Add(tagDetails1.Tag); @@ -2485,23 +2286,11 @@ public void Can_add_principal_and_identifying_dependents_starting_in_the_middle_ { var product1 = new Product { - Details = new ProductDetails - { - Tag = new ProductDetailsTag - { - TagDetails = new ProductDetailsTagDetails() - } - } + Details = new ProductDetails { Tag = new ProductDetailsTag { TagDetails = new ProductDetailsTagDetails() } } }; var product2 = new Product { - Details = new ProductDetails - { - Tag = new ProductDetailsTag - { - TagDetails = new ProductDetailsTagDetails() - } - } + Details = new ProductDetails { Tag = new ProductDetailsTag { TagDetails = new ProductDetailsTagDetails() } } }; context.Add(product1.Details); @@ -2650,26 +2439,10 @@ public void Can_add_identifying_one_to_many_via_principal_with_key_generation() var order1 = new Order(); var order2 = new Order(); - var orderDetails1a = new OrderDetails - { - Order = order1, - Product = product1 - }; - var orderDetails1b = new OrderDetails - { - Order = order1, - Product = product2 - }; - var orderDetails2a = new OrderDetails - { - Order = order2, - Product = product1 - }; - var orderDetails2b = new OrderDetails - { - Order = order2, - Product = product2 - }; + var orderDetails1a = new OrderDetails { Order = order1, Product = product1 }; + var orderDetails1b = new OrderDetails { Order = order1, Product = product2 }; + var orderDetails2a = new OrderDetails { Order = order2, Product = product1 }; + var orderDetails2b = new OrderDetails { Order = order2, Product = product2 }; context.Add(product1); context.Add(order1); @@ -2695,26 +2468,10 @@ public void Can_add_identifying_one_to_many_via_dependents_with_key_generation() var order1 = new Order(); var order2 = new Order(); - var orderDetails1a = new OrderDetails - { - Order = order1, - Product = product1 - }; - var orderDetails1b = new OrderDetails - { - Order = order1, - Product = product2 - }; - var orderDetails2a = new OrderDetails - { - Order = order2, - Product = product1 - }; - var orderDetails2b = new OrderDetails - { - Order = order2, - Product = product2 - }; + var orderDetails1a = new OrderDetails { Order = order1, Product = product1 }; + var orderDetails1b = new OrderDetails { Order = order1, Product = product2 }; + var orderDetails2a = new OrderDetails { Order = order2, Product = product1 }; + var orderDetails2b = new OrderDetails { Order = order2, Product = product2 }; context.Add(orderDetails1a); context.Add(orderDetails2a); @@ -2797,11 +2554,7 @@ public void Entries_calls_DetectChanges_by_default(bool useGenericOverload) using (var context = new EarlyLearningCenter()) { var entry = context.Attach( - new Product - { - Id = 1, - CategoryId = 66 - }); + new Product { Id = 1, CategoryId = 66 }); entry.Entity.CategoryId = 77; @@ -2830,11 +2583,7 @@ public void Auto_DetectChanges_for_Entries_can_be_switched_off(bool useGenericOv context.ChangeTracker.AutoDetectChangesEnabled = false; var entry = context.Attach( - new Product - { - Id = 1, - CategoryId = 66 - }); + new Product { Id = 1, CategoryId = 66 }); entry.Entity.CategoryId = 77; @@ -2861,11 +2610,7 @@ public void Explicitly_calling_DetectChanges_works_even_if_auto_DetectChanges_is context.ChangeTracker.AutoDetectChangesEnabled = false; var entry = context.Attach( - new Product - { - Id = 1, - CategoryId = 66 - }); + new Product { Id = 1, CategoryId = 66 }); entry.Entity.CategoryId = 77; @@ -2909,33 +2654,9 @@ public void TrackGraph_overload_can_visit_an_already_attached_graph() Id = 1, Products = new List { - new Product - { - Id = 1, - CategoryId = 1, - Details = new ProductDetails - { - Id = 1 - } - }, - new Product - { - Id = 2, - CategoryId = 1, - Details = new ProductDetails - { - Id = 2 - } - }, - new Product - { - Id = 3, - CategoryId = 1, - Details = new ProductDetails - { - Id = 3 - } - } + new Product { Id = 1, CategoryId = 1, Details = new ProductDetails { Id = 1 } }, + new Product { Id = 2, CategoryId = 1, Details = new ProductDetails { Id = 2 } }, + new Product { Id = 3, CategoryId = 1, Details = new ProductDetails { Id = 3 } } } }; @@ -2986,33 +2707,9 @@ public void TrackGraph_overload_can_visit_a_graph_without_attaching() Id = 1, Products = new List { - new Product - { - Id = 1, - CategoryId = 1, - Details = new ProductDetails - { - Id = 1 - } - }, - new Product - { - Id = 2, - CategoryId = 1, - Details = new ProductDetails - { - Id = 2 - } - }, - new Product - { - Id = 3, - CategoryId = 1, - Details = new ProductDetails - { - Id = 3 - } - } + new Product { Id = 1, CategoryId = 1, Details = new ProductDetails { Id = 1 } }, + new Product { Id = 2, CategoryId = 1, Details = new ProductDetails { Id = 2 } }, + new Product { Id = 3, CategoryId = 1, Details = new ProductDetails { Id = 3 } } } }; @@ -3162,14 +2859,7 @@ private class Dark } private static Product CreateSimpleGraph(int id) - => new Product - { - Id = id, - Category = new Category - { - Id = id - } - }; + => new Product { Id = id, Category = new Category { Id = id } }; private class ChangeDetectorProxy : ChangeDetector { @@ -3384,11 +3074,7 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) b => { b.HasKey( - e => new - { - e.OrderId, - e.ProductId - }); + e => new { e.OrderId, e.ProductId }); b.HasOne(e => e.Order).WithMany(e => e.OrderDetails).HasForeignKey(e => e.OrderId); b.HasOne(e => e.Product).WithMany(e => e.OrderDetails).HasForeignKey(e => e.ProductId); }); diff --git a/test/EFCore.Tests/ChangeTracking/CollectionEntryTest.cs b/test/EFCore.Tests/ChangeTracking/CollectionEntryTest.cs index 7d3fbe59a9b..513b539adb6 100644 --- a/test/EFCore.Tests/ChangeTracking/CollectionEntryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/CollectionEntryTest.cs @@ -74,10 +74,7 @@ public void Can_get_and_set_current_value() Assert.Null(collection.CurrentValue); - collection.CurrentValue = new List - { - chunky - }; + collection.CurrentValue = new List { chunky }; Assert.Same(cherry, chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); @@ -108,10 +105,7 @@ public void Can_get_and_set_current_value_generic() Assert.Null(collection.CurrentValue); - collection.CurrentValue = new List - { - chunky - }; + collection.CurrentValue = new List { chunky }; Assert.Same(cherry, chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); @@ -141,10 +135,7 @@ public void Can_get_and_set_current_value_not_tracked() Assert.Null(collection.CurrentValue); - collection.CurrentValue = new List - { - chunky - }; + collection.CurrentValue = new List { chunky }; Assert.Null(chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); @@ -172,10 +163,7 @@ public void Can_get_and_set_current_value_generic_not_tracked() Assert.Null(collection.CurrentValue); - collection.CurrentValue = new List - { - chunky - }; + collection.CurrentValue = new List { chunky }; Assert.Null(chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); @@ -204,10 +192,7 @@ public void Can_get_and_set_current_value_start_tracking() Assert.Null(collection.CurrentValue); - collection.CurrentValue = new List - { - chunky - }; + collection.CurrentValue = new List { chunky }; Assert.Same(cherry, chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); @@ -242,10 +227,7 @@ public void Can_get_and_set_current_value_start_tracking_generic() Assert.Null(collection.CurrentValue); - collection.CurrentValue = new List - { - chunky - }; + collection.CurrentValue = new List { chunky }; Assert.Same(cherry, chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); @@ -280,10 +262,7 @@ public void Can_get_and_set_current_value_attached() Assert.Null(collection.CurrentValue); - collection.CurrentValue = new List - { - chunky - }; + collection.CurrentValue = new List { chunky }; Assert.Same(cherry, chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); @@ -320,10 +299,7 @@ public void Can_get_and_set_current_value_generic_attached() Assert.Null(collection.CurrentValue); - collection.CurrentValue = new List - { - chunky - }; + collection.CurrentValue = new List { chunky }; Assert.Same(cherry, chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); @@ -353,21 +329,9 @@ public void IsModified_tracks_state_of_FK_property_principal() using (var context = new FreezerContext()) { var cherry = new Cherry(); - var chunky1 = new Chunky - { - Id = 1, - Garcia = cherry - }; - var chunky2 = new Chunky - { - Id = 2, - Garcia = cherry - }; - cherry.Monkeys = new List - { - chunky1, - chunky2 - }; + var chunky1 = new Chunky { Id = 1, Garcia = cherry }; + var chunky2 = new Chunky { Id = 2, Garcia = cherry }; + cherry.Monkeys = new List { chunky1, chunky2 }; context.AttachRange(cherry, chunky1, chunky2); var collection = context.Entry(cherry).Collection(e => e.Monkeys); @@ -401,22 +365,10 @@ public void IsModified_can_set_fk_to_modified_principal_with_Added_or_Deleted_de using (var context = new FreezerContext()) { var cherry = new Cherry(); - var chunky1 = new Chunky - { - Id = 1, - Garcia = cherry - }; - var chunky2 = new Chunky - { - Id = 2, - Garcia = cherry - }; + var chunky1 = new Chunky { Id = 1, Garcia = cherry }; + var chunky2 = new Chunky { Id = 2, Garcia = cherry }; - cherry.Monkeys = new List - { - chunky1, - chunky2 - }; + cherry.Monkeys = new List { chunky1, chunky2 }; context.Entry(cherry).State = principalState; context.Entry(chunky1).State = dependentState; @@ -469,21 +421,9 @@ public void IsModified_can_set_fk_to_modified_principal_with_Unchanged_dependent using (var context = new FreezerContext()) { var cherry = new Cherry(); - var chunky1 = new Chunky - { - Id = 1, - Garcia = cherry - }; - var chunky2 = new Chunky - { - Id = 2, - Garcia = cherry - }; - cherry.Monkeys = new List - { - chunky1, - chunky2 - }; + var chunky1 = new Chunky { Id = 1, Garcia = cherry }; + var chunky2 = new Chunky { Id = 2, Garcia = cherry }; + cherry.Monkeys = new List { chunky1, chunky2 }; context.Entry(cherry).State = principalState; context.Entry(chunky1).State = dependentState; @@ -521,21 +461,9 @@ public void IsModified_can_set_fk_to_modified_principal_with_Modified_dependents using (var context = new FreezerContext()) { var cherry = new Cherry(); - var chunky1 = new Chunky - { - Id = 1, - Garcia = cherry - }; - var chunky2 = new Chunky - { - Id = 2, - Garcia = cherry - }; - cherry.Monkeys = new List - { - chunky1, - chunky2 - }; + var chunky1 = new Chunky { Id = 1, Garcia = cherry }; + var chunky2 = new Chunky { Id = 2, Garcia = cherry }; + cherry.Monkeys = new List { chunky1, chunky2 }; context.Entry(cherry).State = principalState; context.Entry(chunky1).State = dependentState; diff --git a/test/EFCore.Tests/ChangeTracking/EntityEntryTest.cs b/test/EFCore.Tests/ChangeTracking/EntityEntryTest.cs index 2b019b6d1c2..184233863e2 100644 --- a/test/EFCore.Tests/ChangeTracking/EntityEntryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/EntityEntryTest.cs @@ -21,10 +21,7 @@ public void Non_store_generated_key_is_always_set() Assert.True(context.Entry(new NotStoreGenerated()).IsKeySet); Assert.True( context.Entry( - new NotStoreGenerated - { - Id = 1 - }).IsKeySet); + new NotStoreGenerated { Id = 1 }).IsKeySet); } } @@ -36,23 +33,13 @@ public void Non_store_generated_composite_key_is_always_set() Assert.True(context.Entry(new CompositeNotStoreGenerated()).IsKeySet); Assert.True( context.Entry( - new CompositeNotStoreGenerated - { - Id1 = 1 - }).IsKeySet); + new CompositeNotStoreGenerated { Id1 = 1 }).IsKeySet); Assert.True( context.Entry( - new CompositeNotStoreGenerated - { - Id2 = true - }).IsKeySet); + new CompositeNotStoreGenerated { Id2 = true }).IsKeySet); Assert.True( context.Entry( - new CompositeNotStoreGenerated - { - Id1 = 1, - Id2 = true - }).IsKeySet); + new CompositeNotStoreGenerated { Id1 = 1, Id2 = true }).IsKeySet); } } @@ -64,10 +51,7 @@ public void Store_generated_key_is_set_only_if_non_default_value() Assert.False(context.Entry(new StoreGenerated()).IsKeySet); Assert.True( context.Entry( - new StoreGenerated - { - Id = 1 - }).IsKeySet); + new StoreGenerated { Id = 1 }).IsKeySet); } } @@ -79,23 +63,13 @@ public void Composite_store_generated_key_is_set_only_if_non_default_value_in_st Assert.False(context.Entry(new CompositeStoreGenerated()).IsKeySet); Assert.False( context.Entry( - new CompositeStoreGenerated - { - Id1 = 1 - }).IsKeySet); + new CompositeStoreGenerated { Id1 = 1 }).IsKeySet); Assert.True( context.Entry( - new CompositeStoreGenerated - { - Id2 = true - }).IsKeySet); + new CompositeStoreGenerated { Id2 = true }).IsKeySet); Assert.True( context.Entry( - new CompositeStoreGenerated - { - Id1 = 1, - Id2 = true - }).IsKeySet); + new CompositeStoreGenerated { Id1 = 1, Id2 = true }).IsKeySet); } } @@ -107,10 +81,7 @@ public void Primary_key_that_is_also_foreign_key_is_set_only_if_non_default_valu Assert.False(context.Entry(new Dependent()).IsKeySet); Assert.True( context.Entry( - new Dependent - { - Id = 1 - }).IsKeySet); + new Dependent { Id = 1 }).IsKeySet); } } @@ -168,21 +139,13 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().Property(e => e.Id).ValueGeneratedNever(); modelBuilder.Entity().HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); b.Property(e => e.Id2).ValueGeneratedOnAdd(); }); } @@ -193,10 +156,7 @@ public void Detached_entities_are_not_returned_from_the_change_tracker() { using (var context = new FreezerContext()) { - var entity = new Chunky - { - Id = 808 - }; + var entity = new Chunky { Id = 808 }; context.Attach(entity); Assert.Equal(1, context.ChangeTracker.Entries().Count()); @@ -829,11 +789,7 @@ public void Can_get_all_modified_properties() .Where(e => e.IsModified).Select(e => e.Metadata.Name).ToList(); Assert.Equal( - new List - { - "GarciaId", - "Nonkey" - }, modified); + new List { "GarciaId", "Nonkey" }, modified); } } @@ -854,23 +810,11 @@ public void Can_get_all_member_entries() context.Attach(new Chunky()).Members.Select(e => e.Metadata.Name).ToList()); Assert.Equal( - new List - { - "Id", - "Garcia", - "Baked", - "Monkeys" - }, + new List { "Id", "Garcia", "Baked", "Monkeys" }, context.Attach(new Cherry()).Members.Select(e => e.Metadata.Name).ToList()); Assert.Equal( - new List - { - "Id", - "Baked", - "GarciaId", - "Garcia" - }, + new List { "Id", "Baked", "GarciaId", "Garcia" }, context.Attach(new Half()).Members.Select(e => e.Metadata.Name).ToList()); } } @@ -881,30 +825,15 @@ public void Can_get_all_property_entries() using (var context = new FreezerContext()) { Assert.Equal( - new List - { - "Id", - "GarciaId", - "Monkey", - "Nonkey" - }, + new List { "Id", "GarciaId", "Monkey", "Nonkey" }, context.Attach(new Chunky()).Properties.Select(e => e.Metadata.Name).ToList()); Assert.Equal( - new List - { - "Id", - "Garcia" - }, + new List { "Id", "Garcia" }, context.Attach(new Cherry()).Properties.Select(e => e.Metadata.Name).ToList()); Assert.Equal( - new List - { - "Id", - "Baked", - "GarciaId" - }, + new List { "Id", "Baked", "GarciaId" }, context.Attach(new Half()).Properties.Select(e => e.Metadata.Name).ToList()); } } @@ -915,25 +844,15 @@ public void Can_get_all_navigation_entries() using (var context = new FreezerContext()) { Assert.Equal( - new List - { - "Garcia" - }, + new List { "Garcia" }, context.Attach(new Chunky()).Navigations.Select(e => e.Metadata.Name).ToList()); Assert.Equal( - new List - { - "Baked", - "Monkeys" - }, + new List { "Baked", "Monkeys" }, context.Attach(new Cherry()).Navigations.Select(e => e.Metadata.Name).ToList()); Assert.Equal( - new List - { - "Garcia" - }, + new List { "Garcia" }, context.Attach(new Half()).Navigations.Select(e => e.Metadata.Name).ToList()); } } @@ -944,24 +863,15 @@ public void Can_get_all_reference_entries() using (var context = new FreezerContext()) { Assert.Equal( - new List - { - "Garcia" - }, + new List { "Garcia" }, context.Attach(new Chunky()).References.Select(e => e.Metadata.Name).ToList()); Assert.Equal( - new List - { - "Baked" - }, + new List { "Baked" }, context.Attach(new Cherry()).References.Select(e => e.Metadata.Name).ToList()); Assert.Equal( - new List - { - "Garcia" - }, + new List { "Garcia" }, context.Attach(new Half()).References.Select(e => e.Metadata.Name).ToList()); } } @@ -974,10 +884,7 @@ public void Can_get_all_collection_entries() Assert.Empty(context.Attach(new Chunky()).Collections.Select(e => e.Metadata.Name).ToList()); Assert.Equal( - new List - { - "Monkeys" - }, + new List { "Monkeys" }, context.Attach(new Cherry()).Collections.Select(e => e.Metadata.Name).ToList()); Assert.Empty(context.Attach(new Half()).Collections.Select(e => e.Metadata.Name).ToList()); diff --git a/test/EFCore.Tests/ChangeTracking/Internal/ChangeDetectorTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/ChangeDetectorTest.cs index 32a188b66ff..cf2d4de55f2 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/ChangeDetectorTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/ChangeDetectorTest.cs @@ -43,10 +43,7 @@ public void PropertyChanging_does_not_snapshot_if_eager_snapshots_are_in_use() public void PropertyChanging_snapshots_original_and_FK_value_if_lazy_snapshots_are_in_use() { var contextServices = InMemoryTestHelpers.Instance.CreateContextServices(BuildNotifyingModel()); - var entity = new NotifyingProduct - { - DependentId = 77 - }; + var entity = new NotifyingProduct { DependentId = 77 }; var entry = CreateInternalEntry(contextServices, entity); entry.SetEntityState(EntityState.Unchanged); @@ -76,10 +73,7 @@ public void PropertyChanging_snapshots_original_and_FK_value_if_lazy_snapshots_a public void PropertyChanging_does_not_snapshot_original_values_for_properties_with_no_original_value_tracking() { var contextServices = InMemoryTestHelpers.Instance.CreateContextServices(BuildNotifyingModel()); - var entity = new NotifyingProduct - { - Name = "Cheese" - }; + var entity = new NotifyingProduct { Name = "Cheese" }; var entry = CreateInternalEntry(contextServices, entity); Assert.False(entry.EntityType.UseEagerSnapshots()); @@ -104,10 +98,7 @@ public void PropertyChanging_snapshots_reference_navigations_if_lazy_snapshots_a { var contextServices = InMemoryTestHelpers.Instance.CreateContextServices(BuildNotifyingModel()); var category = new NotifyingCategory(); - var entity = new NotifyingProduct - { - Category = category - }; + var entity = new NotifyingProduct { Category = category }; var entry = CreateInternalEntry(contextServices, entity); entry.SetEntityState(EntityState.Added); @@ -125,11 +116,7 @@ public void PropertyChanging_snapshots_reference_navigations_if_lazy_snapshots_a Assert.Same(category, entry.GetRelationshipSnapshotValue(navigation)); Assert.Same(category, entry.GetCurrentValue(navigation)); - var newCategory = new NotifyingCategory - { - Id = 7, - PrincipalId = 11 - }; + var newCategory = new NotifyingCategory { Id = 7, PrincipalId = 11 }; entity.Category = newCategory; Assert.Same(newCategory, entry.GetRelationshipSnapshotValue(navigation)); @@ -141,10 +128,7 @@ public void PropertyChanging_snapshots_PK_for_relationships_if_lazy_snapshots_ar { var contextServices = InMemoryTestHelpers.Instance.CreateContextServices(BuildNotifyingModel()); var id = Guid.NewGuid(); - var entity = new NotifyingProduct - { - Id = id - }; + var entity = new NotifyingProduct { Id = id }; var entry = CreateInternalEntry(contextServices, entity); entry.SetEntityState(EntityState.Added); @@ -176,11 +160,7 @@ public void Detects_scalar_property_change() var changeDetector = contextServices.GetRequiredService(); - var product = new Product - { - Id = Guid.NewGuid(), - Name = "Oculus Rift" - }; + var product = new Product { Id = Guid.NewGuid(), Name = "Oculus Rift" }; var entry = contextServices.GetRequiredService().GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); @@ -207,11 +187,7 @@ public void Can_insert_with_array_comparer(bool useTypeMapping, bool useStateCha { var value = nullValue ? null : new[] { 1, 2, 3, 4 }; - var baxter = new Baxter - { - Id = Guid.NewGuid(), - Demands = value - }; + var baxter = new Baxter { Id = Guid.NewGuid(), Demands = value }; var entityEntry = context.Entry(baxter); @@ -255,11 +231,7 @@ public void Detects_scalar_property_change_with_custom_comparer(bool useTypeMapp using (var context = useTypeMapping ? new BaxterWithMappingContext() : new BaxterContext()) { var baxter = context.Attach( - new Baxter - { - Id = Guid.NewGuid(), - Demands = new[] { 1, 2, 3, 4 } - }).Entity; + new Baxter { Id = Guid.NewGuid(), Demands = new[] { 1, 2, 3, 4 } }).Entity; baxter.Demands[2] = 33; @@ -287,10 +259,7 @@ public void Detects_scalar_shadow_property_change_with_custom_comparer(bool useT using (var context = useTypeMapping ? new BaxterWithMappingContext() : new BaxterContext()) { var entityEntry = context.Entry( - new Baxter - { - Id = Guid.NewGuid() - }); + new Baxter { Id = Guid.NewGuid() }); entityEntry.Property("ShadyDemands").CurrentValue = new[] { 1, 2, 3, 4 }; entityEntry.State = EntityState.Unchanged; @@ -413,11 +382,7 @@ public void Skips_detection_of_scalar_property_change_for_notification_entities( var stateManager = contextServices.GetRequiredService(); var changeDetector = contextServices.GetRequiredService(); - var product = new ProductWithChanged - { - Id = 1, - Name = "Oculus Rift" - }; + var product = new ProductWithChanged { Id = 1, Name = "Oculus Rift" }; var entry = contextServices.GetRequiredService().GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); @@ -437,11 +402,7 @@ public void Detects_principal_key_change() var stateManager = contextServices.GetRequiredService(); var changeDetector = contextServices.GetRequiredService(); - var category = new Category - { - Id = -1, - PrincipalId = 77 - }; + var category = new Category { Id = -1, PrincipalId = 77 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Added); @@ -472,11 +433,7 @@ public void Detects_principal_key_changing_back_to_original_value() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var category = new Category - { - Id = -1, - PrincipalId = 77 - }; + var category = new Category { Id = -1, PrincipalId = 77 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Added); @@ -509,11 +466,7 @@ public void Reacts_to_principal_key_change_in_sidecar() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var category = new Category - { - Id = -1, - PrincipalId = 77 - }; + var category = new Category { Id = -1, PrincipalId = 77 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Added); @@ -545,12 +498,7 @@ public void Detects_primary_key_change() var stateManager = contextServices.GetRequiredService(); var changeDetector = contextServices.GetRequiredService(); - var category = new Category - { - Id = -1, - TagId = 777, - PrincipalId = 778 - }; + var category = new Category { Id = -1, TagId = 777, PrincipalId = 778 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Added); @@ -579,12 +527,7 @@ public void Reacts_to_primary_key_change_in_sidecar() var stateManager = contextServices.GetRequiredService(); var changeDetector = contextServices.GetRequiredService(); - var category = new Category - { - Id = -1, - TagId = 777, - PrincipalId = 778 - }; + var category = new Category { Id = -1, TagId = 777, PrincipalId = 778 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Added); @@ -616,11 +559,7 @@ public void Ignores_no_change_to_principal_key() var stateManager = contextServices.GetRequiredService(); var changeDetector = contextServices.GetRequiredService(); - var category = new Category - { - Id = -1, - PrincipalId = 77 - }; + var category = new Category { Id = -1, PrincipalId = 77 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Added); @@ -643,11 +582,7 @@ public void Ignores_no_change_to_principal_key_in_sidecar() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var category = new Category - { - Id = -1, - PrincipalId = 77 - }; + var category = new Category { Id = -1, PrincipalId = 77 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Added); entry.PrepareToSave(); @@ -673,11 +608,7 @@ public void Detects_foreign_key_change() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var product = new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - }; + var product = new Product { Id = Guid.NewGuid(), DependentId = 77 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); @@ -706,11 +637,7 @@ public void Detects_foreign_key_changing_back_to_original_value() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var product = new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - }; + var product = new Product { Id = Guid.NewGuid(), DependentId = 77 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); @@ -743,11 +670,7 @@ public void Reacts_to_foreign_key_change_in_sidecar() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var product = new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - }; + var product = new Product { Id = Guid.NewGuid(), DependentId = 77 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); entry.PrepareToSave(); @@ -778,11 +701,7 @@ public void Ignores_no_change_to_foreign_key() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var product = new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - }; + var product = new Product { Id = Guid.NewGuid(), DependentId = 77 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); @@ -805,11 +724,7 @@ public void Ignores_no_change_to_foreign_key_in_sidecar() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var product = new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - }; + var product = new Product { Id = Guid.NewGuid(), DependentId = 77 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); entry.PrepareToSave(); @@ -834,25 +749,12 @@ public void Detects_reference_navigation_change() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var originalCategory = new Category - { - Id = 77, - PrincipalId = 1 - }; - var product = new Product - { - Id = Guid.NewGuid(), - Category = originalCategory, - DependentId = 1 - }; + var originalCategory = new Category { Id = 77, PrincipalId = 1 }; + var product = new Product { Id = Guid.NewGuid(), Category = originalCategory, DependentId = 1 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); - var newCategory = new Category - { - Id = 1, - PrincipalId = 2 - }; + var newCategory = new Category { Id = 1, PrincipalId = 2 }; product.Category = newCategory; changeDetector.DetectChanges(entry); @@ -881,29 +783,14 @@ public void Detects_reference_navigation_changing_back_to_original_value(bool us var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var originalCategory = new Category - { - Id = 77, - PrincipalId = 1, - TagId = 777 - }; - var product = new Product - { - Id = Guid.NewGuid(), - Category = originalCategory, - DependentId = 1 - }; + var originalCategory = new Category { Id = 77, PrincipalId = 1, TagId = 777 }; + var product = new Product { Id = Guid.NewGuid(), Category = originalCategory, DependentId = 1 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); var newCategory = useNull ? null - : new Category - { - Id = 99, - PrincipalId = 2, - TagId = 778 - }; + : new Category { Id = 99, PrincipalId = 2, TagId = 778 }; product.Category = newCategory; changeDetector.DetectChanges(entry); @@ -932,17 +819,8 @@ public void Ignores_no_change_to_reference_navigation() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var category = new Category - { - Id = 55, - PrincipalId = 1 - }; - var product = new Product - { - Id = Guid.NewGuid(), - Category = category, - DependentId = 1 - }; + var category = new Category { Id = 55, PrincipalId = 1 }; + var product = new Product { Id = Guid.NewGuid(), Category = category, DependentId = 1 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); @@ -965,34 +843,13 @@ public void Detects_adding_to_collection_navigation() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var product1 = new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - }; - var product2 = new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - }; - var category = new Category - { - Id = 1, - PrincipalId = 77, - Products = - { - product1, - product2 - } - }; + var product1 = new Product { Id = Guid.NewGuid(), DependentId = 77 }; + var product2 = new Product { Id = Guid.NewGuid(), DependentId = 77 }; + var category = new Category { Id = 1, PrincipalId = 77, Products = { product1, product2 } }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Unchanged); - var product3 = new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - }; + var product3 = new Product { Id = Guid.NewGuid(), DependentId = 77 }; category.Products.Add(product3); changeDetector.DetectChanges(entry); @@ -1018,26 +875,9 @@ public void Detects_removing_from_collection_navigation() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var product1 = new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - }; - var product2 = new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - }; - var category = new Category - { - Id = 1, - PrincipalId = 77, - Products = - { - product1, - product2 - } - }; + var product1 = new Product { Id = Guid.NewGuid(), DependentId = 77 }; + var product2 = new Product { Id = Guid.NewGuid(), DependentId = 77 }; + var category = new Category { Id = 1, PrincipalId = 77, Products = { product1, product2 } }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Unchanged); @@ -1064,26 +904,9 @@ public void Ignores_no_change_to_collection_navigation() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var product1 = new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - }; - var product2 = new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - }; - var category = new Category - { - Id = 1, - PrincipalId = 77, - Products = - { - product1, - product2 - } - }; + var product1 = new Product { Id = Guid.NewGuid(), DependentId = 77 }; + var product2 = new Product { Id = Guid.NewGuid(), DependentId = 77 }; + var category = new Category { Id = 1, PrincipalId = 77, Products = { product1, product2 } }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Unchanged); @@ -1107,10 +930,7 @@ public void Skips_detecting_changes_to_primary_principal_key_for_notification_en var stateManager = contextServices.GetRequiredService(); var changeDetector = contextServices.GetRequiredService(); - var product = new ProductWithChanged - { - Id = 77 - }; + var product = new ProductWithChanged { Id = 77 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Added); @@ -1133,11 +953,7 @@ public void Skips_detecting_changes_to_foreign_key_for_notification_entities() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var product = new ProductWithChanged - { - Id = 1, - DependentId = 77 - }; + var product = new ProductWithChanged { Id = 1, DependentId = 77 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); @@ -1160,23 +976,12 @@ public void Skips_detecting_changes_to_reference_navigation_for_notification_ent var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var category = new CategoryWithChanged - { - Id = 1 - }; - var product = new ProductWithChanged - { - Id = 2, - Category = category, - DependentId = 1 - }; + var category = new CategoryWithChanged { Id = 1 }; + var product = new ProductWithChanged { Id = 2, Category = category, DependentId = 1 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); - product.Category = new CategoryWithChanged - { - Id = 2 - }; + product.Category = new CategoryWithChanged { Id = 2 }; changeDetector.DetectChanges(stateManager); @@ -1194,33 +999,16 @@ public void Skips_detecting_changes_to_notifying_collections() var stateManager = contextServices.GetRequiredService(); - var product1 = new ProductWithChanged - { - Id = 1, - DependentId = 77 - }; - var product2 = new ProductWithChanged - { - Id = 2, - DependentId = 77 - }; + var product1 = new ProductWithChanged { Id = 1, DependentId = 77 }; + var product2 = new ProductWithChanged { Id = 2, DependentId = 77 }; var category = new CategoryWithChanged { - Id = 77, - Products = new ObservableCollection - { - product1, - product2 - } + Id = 77, Products = new ObservableCollection { product1, product2 } }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Unchanged); - var product3 = new ProductWithChanged - { - Id = 3, - DependentId = 77 - }; + var product3 = new ProductWithChanged { Id = 3, DependentId = 77 }; category.Products.Add(product3); var testListener = contextServices.GetRequiredService(); @@ -1242,25 +1030,12 @@ public void Brings_in_single_new_entity_set_on_reference_navigation() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var originalCategory = new Category - { - Id = 77, - PrincipalId = 1 - }; - var product = new Product - { - Id = Guid.NewGuid(), - Category = originalCategory, - DependentId = 1 - }; + var originalCategory = new Category { Id = 77, PrincipalId = 1 }; + var product = new Product { Id = Guid.NewGuid(), Category = originalCategory, DependentId = 1 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); - var newCategory = new Category - { - PrincipalId = 2, - Tag = new CategoryTag() - }; + var newCategory = new Category { PrincipalId = 2, Tag = new CategoryTag() }; product.Category = newCategory; changeDetector.DetectChanges(stateManager); @@ -1279,12 +1054,7 @@ public void Brings_in_new_entity_set_on_principal_of_one_to_one_navigation() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var category = new Category - { - Id = 1, - TagId = 77, - PrincipalId = 778 - }; + var category = new Category { Id = 1, TagId = 77, PrincipalId = 778 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Unchanged); @@ -1307,18 +1077,11 @@ public void Brings_in_new_entity_set_on_dependent_of_one_to_one_navigation() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var tag = new CategoryTag - { - Id = 1 - }; + var tag = new CategoryTag { Id = 1 }; var entry = stateManager.GetOrCreateEntry(tag); entry.SetEntityState(EntityState.Unchanged); - var category = new Category - { - TagId = 77, - PrincipalId = 777 - }; + var category = new Category { TagId = 77, PrincipalId = 777 }; tag.Category = category; changeDetector.DetectChanges(stateManager); @@ -1337,33 +1100,13 @@ public void Brings_in_single_new_entity_set_on_collection_navigation() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var product1 = new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - }; - var product2 = new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - }; - var category = new Category - { - Id = 1, - PrincipalId = 77, - Products = - { - product1, - product2 - } - }; + var product1 = new Product { Id = Guid.NewGuid(), DependentId = 77 }; + var product2 = new Product { Id = Guid.NewGuid(), DependentId = 77 }; + var category = new Category { Id = 1, PrincipalId = 77, Products = { product1, product2 } }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Unchanged); - var product3 = new Product - { - Tag = new ProductTag() - }; + var product3 = new Product { Tag = new ProductTag() }; category.Products.Add(product3); changeDetector.DetectChanges(stateManager); @@ -1428,11 +1171,7 @@ public void Handles_notification_of_principal_key_change() var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var category = new NotifyingCategory - { - Id = -1, - PrincipalId = 77 - }; + var category = new NotifyingCategory { Id = -1, PrincipalId = 77 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Added); @@ -1458,11 +1197,7 @@ public void Handles_notification_of_principal_key_changing_back_to_original_valu var stateManager = contextServices.GetRequiredService(); - var category = new NotifyingCategory - { - Id = -1, - PrincipalId = 77 - }; + var category = new NotifyingCategory { Id = -1, PrincipalId = 77 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Added); @@ -1489,12 +1224,7 @@ public void Handles_notification_of_primary_key_change() var stateManager = contextServices.GetRequiredService(); - var category = new NotifyingCategory - { - Id = -1, - TagId = 777, - PrincipalId = 778 - }; + var category = new NotifyingCategory { Id = -1, TagId = 777, PrincipalId = 778 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Added); @@ -1520,11 +1250,7 @@ public void Handles_notification_of_no_change_to_principal_key() var stateManager = contextServices.GetRequiredService(); - var category = new NotifyingCategory - { - Id = -1, - PrincipalId = 77 - }; + var category = new NotifyingCategory { Id = -1, PrincipalId = 77 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Added); @@ -1544,11 +1270,7 @@ public void Handles_notification_of_foreign_key_change() var stateManager = contextServices.GetRequiredService(); - var product = new NotifyingProduct - { - Id = Guid.NewGuid(), - DependentId = 77 - }; + var product = new NotifyingProduct { Id = Guid.NewGuid(), DependentId = 77 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); @@ -1574,11 +1296,7 @@ public void Handles_notification_of_foreign_key_changing_back_to_original_value( var stateManager = contextServices.GetRequiredService(); - var product = new NotifyingProduct - { - Id = Guid.NewGuid(), - DependentId = 77 - }; + var product = new NotifyingProduct { Id = Guid.NewGuid(), DependentId = 77 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); @@ -1605,11 +1323,7 @@ public void Handles_notification_of_no_change_to_foreign_key() var stateManager = contextServices.GetRequiredService(); - var product = new NotifyingProduct - { - Id = Guid.NewGuid(), - DependentId = 77 - }; + var product = new NotifyingProduct { Id = Guid.NewGuid(), DependentId = 77 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); @@ -1629,25 +1343,12 @@ public void Handles_notification_of_reference_navigation_change() var stateManager = contextServices.GetRequiredService(); - var originalCategory = new NotifyingCategory - { - Id = 66, - PrincipalId = 1 - }; - var product = new NotifyingProduct - { - Id = Guid.NewGuid(), - Category = originalCategory, - DependentId = 1 - }; + var originalCategory = new NotifyingCategory { Id = 66, PrincipalId = 1 }; + var product = new NotifyingProduct { Id = Guid.NewGuid(), Category = originalCategory, DependentId = 1 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); - var newCategory = new NotifyingCategory - { - Id = 67, - PrincipalId = 2 - }; + var newCategory = new NotifyingCategory { Id = 67, PrincipalId = 2 }; product.Category = newCategory; var testListener = contextServices.GetRequiredService(); @@ -1671,29 +1372,14 @@ public void Handles_notification_of_reference_navigation_changing_back_to_origin var stateManager = contextServices.GetRequiredService(); - var originalCategory = new NotifyingCategory - { - Id = 77, - PrincipalId = 1, - TagId = 777 - }; - var product = new NotifyingProduct - { - Id = Guid.NewGuid(), - Category = originalCategory, - DependentId = 1 - }; + var originalCategory = new NotifyingCategory { Id = 77, PrincipalId = 1, TagId = 777 }; + var product = new NotifyingProduct { Id = Guid.NewGuid(), Category = originalCategory, DependentId = 1 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); var newCategory = useNull ? null - : new NotifyingCategory - { - Id = 78, - PrincipalId = 2, - TagId = 778 - }; + : new NotifyingCategory { Id = 78, PrincipalId = 2, TagId = 778 }; product.Category = newCategory; product.Category = originalCategory; @@ -1717,17 +1403,8 @@ public void Handles_notification_of_no_change_to_reference_navigation() var stateManager = contextServices.GetRequiredService(); - var category = new NotifyingCategory - { - Id = 77, - PrincipalId = 1 - }; - var product = new NotifyingProduct - { - Id = Guid.NewGuid(), - Category = category, - DependentId = 1 - }; + var category = new NotifyingCategory { Id = 77, PrincipalId = 1 }; + var product = new NotifyingProduct { Id = Guid.NewGuid(), Category = category, DependentId = 1 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); @@ -1747,34 +1424,13 @@ public void Handles_notification_of_adding_to_collection_navigation() var stateManager = contextServices.GetRequiredService(); - var product1 = new NotifyingProduct - { - Id = Guid.NewGuid(), - DependentId = 77 - }; - var product2 = new NotifyingProduct - { - Id = Guid.NewGuid(), - DependentId = 77 - }; - var category = new NotifyingCategory - { - Id = 1, - PrincipalId = 77, - Products = - { - product1, - product2 - } - }; + var product1 = new NotifyingProduct { Id = Guid.NewGuid(), DependentId = 77 }; + var product2 = new NotifyingProduct { Id = Guid.NewGuid(), DependentId = 77 }; + var category = new NotifyingCategory { Id = 1, PrincipalId = 77, Products = { product1, product2 } }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Unchanged); - var product3 = new NotifyingProduct - { - Id = Guid.NewGuid(), - DependentId = 77 - }; + var product3 = new NotifyingProduct { Id = Guid.NewGuid(), DependentId = 77 }; category.Products.Add(product3); var testListener = contextServices.GetRequiredService(); @@ -1795,26 +1451,9 @@ public void Handles_notification_of_removing_from_collection_navigation() var stateManager = contextServices.GetRequiredService(); - var product1 = new NotifyingProduct - { - Id = Guid.NewGuid(), - DependentId = 77 - }; - var product2 = new NotifyingProduct - { - Id = Guid.NewGuid(), - DependentId = 77 - }; - var category = new NotifyingCategory - { - Id = 1, - PrincipalId = 77, - Products = - { - product1, - product2 - } - }; + var product1 = new NotifyingProduct { Id = Guid.NewGuid(), DependentId = 77 }; + var product2 = new NotifyingProduct { Id = Guid.NewGuid(), DependentId = 77 }; + var category = new NotifyingCategory { Id = 1, PrincipalId = 77, Products = { product1, product2 } }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Unchanged); @@ -1841,24 +1480,12 @@ public void Brings_in_single_new_entity_on_notification_of_set_on_reference_navi var stateManager = contextServices.GetRequiredService(); - var originalCategory = new NotifyingCategory - { - PrincipalId = 1 - }; - var product = new NotifyingProduct - { - Id = Guid.NewGuid(), - Category = originalCategory, - DependentId = 1 - }; + var originalCategory = new NotifyingCategory { PrincipalId = 1 }; + var product = new NotifyingProduct { Id = Guid.NewGuid(), Category = originalCategory, DependentId = 1 }; var entry = stateManager.GetOrCreateEntry(product); entry.SetEntityState(EntityState.Unchanged); - var newCategory = new NotifyingCategory - { - PrincipalId = 2, - Tag = new NotifyingCategoryTag() - }; + var newCategory = new NotifyingCategory { PrincipalId = 2, Tag = new NotifyingCategoryTag() }; product.Category = newCategory; var testAttacher = (TestAttacher)contextServices.GetRequiredService(); @@ -1874,19 +1501,11 @@ public void Brings_in_new_entity_on_notification_of_set_on_principal_of_one_to_o var stateManager = contextServices.GetRequiredService(); - var category = new NotifyingCategory - { - Id = 1, - TagId = 77, - PrincipalId = 777 - }; + var category = new NotifyingCategory { Id = 1, TagId = 77, PrincipalId = 777 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Unchanged); - var tag = new NotifyingCategoryTag - { - Id = 2 - }; + var tag = new NotifyingCategoryTag { Id = 2 }; category.Tag = tag; var testAttacher = (TestAttacher)contextServices.GetRequiredService(); @@ -1902,18 +1521,11 @@ public void Brings_in_new_entity_on_notification_of_set_on_dependent_of_one_to_o var stateManager = contextServices.GetRequiredService(); - var tag = new NotifyingCategoryTag - { - Id = 1 - }; + var tag = new NotifyingCategoryTag { Id = 1 }; var entry = stateManager.GetOrCreateEntry(tag); entry.SetEntityState(EntityState.Unchanged); - var category = new NotifyingCategory - { - PrincipalId = 777, - TagId = 77 - }; + var category = new NotifyingCategory { PrincipalId = 777, TagId = 77 }; tag.Category = category; var testAttacher = (TestAttacher)contextServices.GetRequiredService(); @@ -1930,33 +1542,13 @@ public void Brings_in_single_new_entity_on_notification_of_set_on_collection_nav var changeDetector = contextServices.GetRequiredService(); var stateManager = contextServices.GetRequiredService(); - var product1 = new NotifyingProduct - { - Id = Guid.NewGuid(), - DependentId = 77 - }; - var product2 = new NotifyingProduct - { - Id = Guid.NewGuid(), - DependentId = 77 - }; - var category = new NotifyingCategory - { - Id = 1, - PrincipalId = 77, - Products = - { - product1, - product2 - } - }; + var product1 = new NotifyingProduct { Id = Guid.NewGuid(), DependentId = 77 }; + var product2 = new NotifyingProduct { Id = Guid.NewGuid(), DependentId = 77 }; + var category = new NotifyingCategory { Id = 1, PrincipalId = 77, Products = { product1, product2 } }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Unchanged); - var product3 = new NotifyingProduct - { - Tag = new NotifyingProductTag() - }; + var product3 = new NotifyingProduct { Tag = new NotifyingProductTag() }; category.Products.Add(product3); var testAttacher = (TestAttacher)contextServices.GetRequiredService(); @@ -2356,7 +1948,8 @@ private static IModel BuildModelWithChanged() return builder.Model.FinalizeModel(); } - private static InternalEntityEntry CreateInternalEntry(IServiceProvider contextServices, + private static InternalEntityEntry CreateInternalEntry( + IServiceProvider contextServices, TEntity entity = null) where TEntity : class, new() => contextServices.GetRequiredService() @@ -2411,7 +2004,8 @@ public Tuple, IReadOnlyList< public Tuple ReferenceChange { get; set; } public Tuple, IEnumerable> CollectionChange { get; set; } - public override void NavigationReferenceChanged(InternalEntityEntry entry, INavigation navigation, object oldValue, object newValue) + public override void NavigationReferenceChanged( + InternalEntityEntry entry, INavigation navigation, object oldValue, object newValue) { ReferenceChange = Tuple.Create(entry, navigation, oldValue, newValue); diff --git a/test/EFCore.Tests/ChangeTracking/Internal/FixupCompositeTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/FixupCompositeTest.cs index d34828f66ee..a1f1bacfcab 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/FixupCompositeTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/FixupCompositeTest.cs @@ -25,11 +25,7 @@ public void Add_dependent_then_principal_one_to_many_FK_set_both_navs_set(Entity { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; var dependent = new Product { Id1 = 78, @@ -65,17 +61,8 @@ public void Add_dependent_then_principal_one_to_many_FK_not_set_both_navs_set(En { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78, - Category = principal - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78, Category = principal }; principal.Products.Add(dependent); context.Entry(dependent).State = entityState; @@ -103,18 +90,8 @@ public void Add_dependent_then_principal_one_to_many_FK_set_no_navs_set(EntitySt { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78, - CategoryId1 = principal.Id1, - CategoryId2 = principal.Id2 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2 }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -141,18 +118,8 @@ public void Add_dependent_then_principal_one_to_many_FK_set_principal_nav_set(En { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78, - CategoryId1 = principal.Id1, - CategoryId2 = principal.Id2 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2 }; principal.Products.Add(dependent); context.Entry(dependent).State = entityState; @@ -180,11 +147,7 @@ public void Add_dependent_then_principal_one_to_many_FK_set_dependent_nav_set(En { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; var dependent = new Product { Id1 = 78, @@ -219,16 +182,8 @@ public void Add_dependent_then_principal_one_to_many_FK_not_set_principal_nav_se { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; principal.Products.Add(dependent); context.Entry(dependent).State = entityState; @@ -256,17 +211,8 @@ public void Add_dependent_then_principal_one_to_many_FK_not_set_dependent_nav_se { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78, - Category = principal - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78, Category = principal }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -293,11 +239,7 @@ public void Add_principal_then_dependent_one_to_many_FK_set_both_navs_set(Entity { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; var dependent = new Product { Id1 = 78, @@ -333,17 +275,8 @@ public void Add_principal_then_dependent_one_to_many_FK_not_set_both_navs_set(En { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78, - Category = principal - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78, Category = principal }; principal.Products.Add(dependent); context.Entry(principal).State = entityState; @@ -371,18 +304,8 @@ public void Add_principal_then_dependent_one_to_many_FK_set_no_navs_set(EntitySt { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78, - CategoryId1 = principal.Id1, - CategoryId2 = principal.Id2 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2 }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -409,18 +332,8 @@ public void Add_principal_then_dependent_one_to_many_FK_set_principal_nav_set(En { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78, - CategoryId1 = principal.Id1, - CategoryId2 = principal.Id2 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2 }; principal.Products.Add(dependent); context.Entry(principal).State = entityState; @@ -448,11 +361,7 @@ public void Add_principal_then_dependent_one_to_many_FK_set_dependent_nav_set(En { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; var dependent = new Product { Id1 = 78, @@ -487,16 +396,8 @@ public void Add_principal_then_dependent_one_to_many_FK_not_set_principal_nav_se { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; principal.Products.Add(dependent); context.Entry(principal).State = entityState; @@ -524,17 +425,8 @@ public void Add_principal_then_dependent_one_to_many_FK_not_set_dependent_nav_se { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78, - Category = principal - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78, Category = principal }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -561,18 +453,8 @@ public void Add_dependent_then_principal_one_to_many_prin_uni_FK_set_no_navs_set { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductPN - { - Id1 = 78, - Id2 = Guid78, - CategoryId1 = principal.Id1, - CategoryId2 = principal.Id2 - }; + var principal = new CategoryPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductPN { Id1 = 78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2 }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -598,18 +480,8 @@ public void Add_principal_then_dependent_one_to_many_prin_uni_FK_set_no_navs_set { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductPN - { - Id1 = 78, - Id2 = Guid78, - CategoryId1 = principal.Id1, - CategoryId2 = principal.Id2 - }; + var principal = new CategoryPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductPN { Id1 = 78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2 }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -635,18 +507,8 @@ public void Add_dependent_then_principal_one_to_many_prin_uni_FK_set_principal_n { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductPN - { - Id1 = 78, - Id2 = Guid78, - CategoryId1 = principal.Id1, - CategoryId2 = principal.Id2 - }; + var principal = new CategoryPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductPN { Id1 = 78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2 }; principal.Products.Add(dependent); context.Entry(dependent).State = entityState; @@ -673,16 +535,8 @@ public void Add_dependent_then_principal_one_to_many_prin_uni_FK_not_set_princip { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductPN { Id1 = 78, Id2 = Guid78 }; principal.Products.Add(dependent); context.Entry(dependent).State = entityState; @@ -709,18 +563,8 @@ public void Add_principal_then_dependent_one_to_many_prin_uni_FK_set_principal_n { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductPN - { - Id1 = 78, - Id2 = Guid78, - CategoryId1 = principal.Id1, - CategoryId2 = principal.Id2 - }; + var principal = new CategoryPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductPN { Id1 = 78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2 }; principal.Products.Add(dependent); context.Entry(principal).State = entityState; @@ -747,16 +591,8 @@ public void Add_principal_then_dependent_one_to_many_prin_uni_FK_not_set_princip { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductPN { Id1 = 78, Id2 = Guid78 }; principal.Products.Add(dependent); context.Entry(principal).State = entityState; @@ -783,18 +619,8 @@ public void Add_dependent_then_principal_one_to_many_dep_uni_FK_set_no_navs_set( { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductDN - { - Id1 = 78, - Id2 = Guid78, - CategoryId1 = principal.Id1, - CategoryId2 = principal.Id2 - }; + var principal = new CategoryDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductDN { Id1 = 78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2 }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -820,11 +646,7 @@ public void Add_dependent_then_principal_one_to_many_dep_uni_FK_set_dependent_na { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id1 = 77, - Id2 = Guid77 - }; + var principal = new CategoryDN { Id1 = 77, Id2 = Guid77 }; var dependent = new ProductDN { Id1 = 78, @@ -858,17 +680,8 @@ public void Add_dependent_then_principal_one_to_many_dep_uni_FK_not_set_dependen { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductDN - { - Id1 = 78, - Id2 = Guid78, - Category = principal - }; + var principal = new CategoryDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductDN { Id1 = 78, Id2 = Guid78, Category = principal }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -894,18 +707,8 @@ public void Add_principal_then_dependent_one_to_many_dep_uni_FK_set_no_navs_set( { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductDN - { - Id1 = 78, - Id2 = Guid78, - CategoryId1 = principal.Id1, - CategoryId2 = principal.Id2 - }; + var principal = new CategoryDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductDN { Id1 = 78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2 }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -931,11 +734,7 @@ public void Add_principal_then_dependent_one_to_many_dep_uni_FK_set_dependent_na { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id1 = 77, - Id2 = Guid77 - }; + var principal = new CategoryDN { Id1 = 77, Id2 = Guid77 }; var dependent = new ProductDN { Id1 = 78, @@ -969,17 +768,8 @@ public void Add_principal_then_dependent_one_to_many_dep_uni_FK_not_set_dependen { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductDN - { - Id1 = 78, - Id2 = Guid78, - Category = principal - }; + var principal = new CategoryDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductDN { Id1 = 78, Id2 = Guid78, Category = principal }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -1005,18 +795,8 @@ public void Add_dependent_then_principal_one_to_many_no_navs_FK_set_no_navs_set( { using (var context = new FixupContext()) { - var principal = new CategoryNN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductNN - { - Id1 = 78, - Id2 = Guid78, - CategoryId1 = principal.Id1, - CategoryId2 = principal.Id2 - }; + var principal = new CategoryNN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductNN { Id1 = 78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2 }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -1041,18 +821,8 @@ public void Add_principal_then_dependent_one_to_many_no_navs_FK_set_no_navs_set( { using (var context = new FixupContext()) { - var principal = new CategoryNN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductNN - { - Id1 = 78, - Id2 = Guid78, - CategoryId1 = principal.Id1, - CategoryId2 = principal.Id2 - }; + var principal = new CategoryNN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductNN { Id1 = 78, Id2 = Guid78, CategoryId1 = principal.Id1, CategoryId2 = principal.Id2 }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -1077,11 +847,7 @@ public void Add_dependent_then_principal_one_to_one_FK_set_both_navs_set(EntityS { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; var dependent = new Child { Id1 = 78, @@ -1117,17 +883,8 @@ public void Add_dependent_then_principal_one_to_one_FK_not_set_both_navs_set(Ent { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78, - Parent = principal - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78, Parent = principal }; principal.Child = dependent; context.Entry(dependent).State = entityState; @@ -1155,18 +912,8 @@ public void Add_dependent_then_principal_one_to_one_FK_set_no_navs_set(EntitySta { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78, - ParentId1 = principal.Id1, - ParentId2 = principal.Id2 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2 }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -1193,18 +940,8 @@ public void Add_dependent_then_principal_one_to_one_FK_set_principal_nav_set(Ent { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78, - ParentId1 = principal.Id1, - ParentId2 = principal.Id2 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2 }; principal.Child = dependent; context.Entry(dependent).State = entityState; @@ -1232,11 +969,7 @@ public void Add_dependent_then_principal_one_to_one_FK_set_dependent_nav_set(Ent { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; var dependent = new Child { Id1 = 78, @@ -1271,16 +1004,8 @@ public void Add_dependent_then_principal_one_to_one_FK_not_set_principal_nav_set { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; principal.Child = dependent; context.Entry(dependent).State = entityState; @@ -1308,17 +1033,8 @@ public void Add_dependent_then_principal_one_to_one_FK_not_set_dependent_nav_set { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78, - Parent = principal - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78, Parent = principal }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -1345,11 +1061,7 @@ public void Add_principal_then_dependent_one_to_one_FK_set_both_navs_set(EntityS { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; var dependent = new Child { Id1 = 78, @@ -1385,17 +1097,8 @@ public void Add_principal_then_dependent_one_to_one_FK_not_set_both_navs_set(Ent { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78, - Parent = principal - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78, Parent = principal }; principal.Child = dependent; context.Entry(principal).State = entityState; @@ -1423,18 +1126,8 @@ public void Add_principal_then_dependent_one_to_one_FK_set_no_navs_set(EntitySta { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78, - ParentId1 = principal.Id1, - ParentId2 = principal.Id2 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2 }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -1461,18 +1154,8 @@ public void Add_principal_then_dependent_one_to_one_FK_set_principal_nav_set(Ent { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78, - ParentId1 = principal.Id1, - ParentId2 = principal.Id2 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2 }; principal.Child = dependent; context.Entry(principal).State = entityState; @@ -1500,11 +1183,7 @@ public void Add_principal_then_dependent_one_to_one_FK_set_dependent_nav_set(Ent { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; var dependent = new Child { Id1 = 78, @@ -1539,16 +1218,8 @@ public void Add_principal_then_dependent_one_to_one_FK_not_set_principal_nav_set { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; principal.Child = dependent; context.Entry(principal).State = entityState; @@ -1576,17 +1247,8 @@ public void Add_principal_then_dependent_one_to_one_FK_not_set_dependent_nav_set { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78, - Parent = principal - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78, Parent = principal }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -1613,18 +1275,8 @@ public void Add_dependent_then_principal_one_to_one_prin_uni_FK_set_no_navs_set( { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildPN - { - Id1 = 78, - Id2 = Guid78, - ParentId1 = principal.Id1, - ParentId2 = principal.Id2 - }; + var principal = new ParentPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildPN { Id1 = 78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2 }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -1650,18 +1302,8 @@ public void Add_principal_then_dependent_one_to_one_prin_uni_FK_set_no_navs_set( { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildPN - { - Id1 = 78, - Id2 = Guid78, - ParentId1 = principal.Id1, - ParentId2 = principal.Id2 - }; + var principal = new ParentPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildPN { Id1 = 78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2 }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -1687,18 +1329,8 @@ public void Add_dependent_then_principal_one_to_one_prin_uni_FK_set_principal_na { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildPN - { - Id1 = 78, - Id2 = Guid78, - ParentId1 = principal.Id1, - ParentId2 = principal.Id2 - }; + var principal = new ParentPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildPN { Id1 = 78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2 }; principal.Child = dependent; context.Entry(dependent).State = entityState; @@ -1725,16 +1357,8 @@ public void Add_dependent_then_principal_one_to_one_prin_uni_FK_not_set_principa { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildPN { Id1 = 78, Id2 = Guid78 }; principal.Child = dependent; context.Entry(dependent).State = entityState; @@ -1761,18 +1385,8 @@ public void Add_principal_then_dependent_one_to_one_prin_uni_FK_set_principal_na { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildPN - { - Id1 = 78, - Id2 = Guid78, - ParentId1 = principal.Id1, - ParentId2 = principal.Id2 - }; + var principal = new ParentPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildPN { Id1 = 78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2 }; principal.Child = dependent; context.Entry(principal).State = entityState; @@ -1799,16 +1413,8 @@ public void Add_principal_then_dependent_one_to_one_prin_uni_FK_not_set_principa { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildPN { Id1 = 78, Id2 = Guid78 }; principal.Child = dependent; context.Entry(principal).State = entityState; @@ -1835,18 +1441,8 @@ public void Add_dependent_then_principal_one_to_one_dep_uni_FK_set_no_navs_set(E { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildDN - { - Id1 = 78, - Id2 = Guid78, - ParentId1 = principal.Id1, - ParentId2 = principal.Id2 - }; + var principal = new ParentDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildDN { Id1 = 78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2 }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -1872,11 +1468,7 @@ public void Add_dependent_then_principal_one_to_one_dep_uni_FK_set_dependent_nav { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id1 = 77, - Id2 = Guid77 - }; + var principal = new ParentDN { Id1 = 77, Id2 = Guid77 }; var dependent = new ChildDN { Id1 = 78, @@ -1910,17 +1502,8 @@ public void Add_dependent_then_principal_one_to_one_dep_uni_FK_not_set_dependent { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildDN - { - Id1 = 78, - Id2 = Guid78, - Parent = principal - }; + var principal = new ParentDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildDN { Id1 = 78, Id2 = Guid78, Parent = principal }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -1946,18 +1529,8 @@ public void Add_principal_then_dependent_one_to_one_dep_uni_FK_set_no_navs_set(E { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildDN - { - Id1 = 78, - Id2 = Guid78, - ParentId1 = principal.Id1, - ParentId2 = principal.Id2 - }; + var principal = new ParentDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildDN { Id1 = 78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2 }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -1983,11 +1556,7 @@ public void Add_principal_then_dependent_one_to_one_dep_uni_FK_set_dependent_nav { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id1 = 77, - Id2 = Guid77 - }; + var principal = new ParentDN { Id1 = 77, Id2 = Guid77 }; var dependent = new ChildDN { Id1 = 78, @@ -2021,17 +1590,8 @@ public void Add_principal_then_dependent_one_to_one_dep_uni_FK_not_set_dependent { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildDN - { - Id1 = 78, - Id2 = Guid78, - Parent = principal - }; + var principal = new ParentDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildDN { Id1 = 78, Id2 = Guid78, Parent = principal }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -2057,18 +1617,8 @@ public void Add_dependent_then_principal_one_to_one_no_navs_FK_set_no_navs_set(E { using (var context = new FixupContext()) { - var principal = new ParentNN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildNN - { - Id1 = 78, - Id2 = Guid78, - ParentId1 = principal.Id1, - ParentId2 = principal.Id2 - }; + var principal = new ParentNN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildNN { Id1 = 78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2 }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -2093,18 +1643,8 @@ public void Add_principal_then_dependent_one_to_one_no_navs_FK_set_no_navs_set(E { using (var context = new FixupContext()) { - var principal = new ParentNN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildNN - { - Id1 = 78, - Id2 = Guid78, - ParentId1 = principal.Id1, - ParentId2 = principal.Id2 - }; + var principal = new ParentNN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildNN { Id1 = 78, Id2 = Guid78, ParentId1 = principal.Id1, ParentId2 = principal.Id2 }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -2129,16 +1669,8 @@ public void Add_dependent_but_not_principal_one_to_many_FK_set_both_navs_set(Ent { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -2172,16 +1704,8 @@ public void Add_dependent_but_not_principal_one_to_many_FK_not_set_both_navs_set { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -2213,16 +1737,8 @@ public void Add_dependent_but_not_principal_one_to_many_FK_set_no_navs_set(Entit { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -2254,16 +1770,8 @@ public void Add_dependent_but_not_principal_one_to_many_FK_set_principal_nav_set { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -2296,16 +1804,8 @@ public void Add_dependent_but_not_principal_one_to_many_FK_set_dependent_nav_set { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -2338,16 +1838,8 @@ public void Add_dependent_but_not_principal_one_to_many_FK_not_set_principal_nav { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -2376,16 +1868,8 @@ public void Add_dependent_but_not_principal_one_to_many_FK_not_set_dependent_nav { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -2416,16 +1900,8 @@ public void Add_principal_but_not_dependent_one_to_many_FK_set_both_navs_set(Ent { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -2458,16 +1934,8 @@ public void Add_principal_but_not_dependent_one_to_many_FK_not_set_both_navs_set { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -2498,16 +1966,8 @@ public void Add_principal_but_not_dependent_one_to_many_FK_set_no_navs_set(Entit { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -2536,18 +1996,10 @@ public void Add_principal_but_not_dependent_one_to_many_FK_set_no_navs_set(Entit [InlineData(EntityState.Unchanged)] public void Add_principal_but_not_dependent_one_to_many_FK_set_principal_nav_set(EntityState entityState) { - using (var context = new FixupContext()) - { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + using (var context = new FixupContext()) + { + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -2579,16 +2031,8 @@ public void Add_principal_but_not_dependent_one_to_many_FK_set_dependent_nav_set { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -2620,16 +2064,8 @@ public void Add_principal_but_not_dependent_one_to_many_FK_not_set_principal_nav { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -2661,16 +2097,8 @@ public void Add_principal_but_not_dependent_one_to_many_FK_not_set_dependent_nav { using (var context = new FixupContext()) { - var principal = new Category - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Product - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Category { Id1 = 77, Id2 = Guid77 }; + var dependent = new Product { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -2699,16 +2127,8 @@ public void Add_dependent_but_not_principal_one_to_many_prin_uni_FK_set_no_navs_ { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductPN { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -2739,16 +2159,8 @@ public void Add_principal_but_not_dependent_one_to_many_prin_uni_FK_set_no_navs_ { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductPN { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -2778,16 +2190,8 @@ public void Add_dependent_but_not_principal_one_to_many_prin_uni_FK_set_principa { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductPN { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -2819,16 +2223,8 @@ public void Add_dependent_but_not_principal_one_to_many_prin_uni_FK_not_set_prin { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductPN { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -2856,16 +2252,8 @@ public void Add_principal_but_not_dependent_one_to_many_prin_uni_FK_set_principa { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductPN { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -2896,16 +2284,8 @@ public void Add_principal_but_not_dependent_one_to_many_prin_uni_FK_not_set_prin { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductPN { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -2934,16 +2314,8 @@ public void Add_dependent_but_not_principal_one_to_many_dep_uni_FK_set_no_navs_s { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductDN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductDN { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -2974,16 +2346,8 @@ public void Add_dependent_but_not_principal_one_to_many_dep_uni_FK_set_dependent { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductDN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductDN { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -3015,16 +2379,8 @@ public void Add_dependent_but_not_principal_one_to_many_dep_uni_FK_not_set_depen { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductDN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductDN { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -3054,16 +2410,8 @@ public void Add_principal_but_not_dependent_one_to_many_dep_uni_FK_set_no_navs_s { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductDN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductDN { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -3093,16 +2441,8 @@ public void Add_principal_but_not_dependent_one_to_many_dep_uni_FK_set_dependent { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductDN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductDN { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -3133,16 +2473,8 @@ public void Add_principal_but_not_dependent_one_to_many_dep_uni_FK_not_set_depen { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductDN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductDN { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -3170,16 +2502,8 @@ public void Add_dependent_but_not_principal_one_to_many_no_navs_FK_set_no_navs_s { using (var context = new FixupContext()) { - var principal = new CategoryNN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductNN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryNN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductNN { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -3209,16 +2533,8 @@ public void Add_principal_but_not_dependent_one_to_many_no_navs_FK_set_no_navs_s { using (var context = new FixupContext()) { - var principal = new CategoryNN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ProductNN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new CategoryNN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ProductNN { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -3247,16 +2563,8 @@ public void Add_dependent_but_not_principal_one_to_one_FK_set_both_navs_set(Enti { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -3290,16 +2598,8 @@ public void Add_dependent_but_not_principal_one_to_one_FK_not_set_both_navs_set( { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -3331,16 +2631,8 @@ public void Add_dependent_but_not_principal_one_to_one_FK_set_no_navs_set(Entity { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -3372,16 +2664,8 @@ public void Add_dependent_but_not_principal_one_to_one_FK_set_principal_nav_set( { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -3414,16 +2698,8 @@ public void Add_dependent_but_not_principal_one_to_one_FK_set_dependent_nav_set( { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -3456,16 +2732,8 @@ public void Add_dependent_but_not_principal_one_to_one_FK_not_set_principal_nav_ { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -3494,16 +2762,8 @@ public void Add_dependent_but_not_principal_one_to_one_FK_not_set_dependent_nav_ { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -3534,16 +2794,8 @@ public void Add_principal_but_not_dependent_one_to_one_FK_set_both_navs_set(Enti { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -3576,16 +2828,8 @@ public void Add_principal_but_not_dependent_one_to_one_FK_not_set_both_navs_set( { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -3616,16 +2860,8 @@ public void Add_principal_but_not_dependent_one_to_one_FK_set_no_navs_set(Entity { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -3656,16 +2892,8 @@ public void Add_principal_but_not_dependent_one_to_one_FK_set_principal_nav_set( { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -3697,16 +2925,8 @@ public void Add_principal_but_not_dependent_one_to_one_FK_set_dependent_nav_set( { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -3738,16 +2958,8 @@ public void Add_principal_but_not_dependent_one_to_one_FK_not_set_principal_nav_ { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -3777,16 +2989,8 @@ public void Add_principal_but_not_dependent_one_to_one_FK_not_set_dependent_nav_ { using (var context = new FixupContext()) { - var principal = new Parent - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new Child - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new Parent { Id1 = 77, Id2 = Guid77 }; + var dependent = new Child { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -3815,16 +3019,8 @@ public void Add_dependent_but_not_principal_one_to_one_prin_uni_FK_set_no_navs_s { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildPN { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -3855,16 +3051,8 @@ public void Add_principal_but_not_dependent_one_to_one_prin_uni_FK_set_no_navs_s { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildPN { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -3894,16 +3082,8 @@ public void Add_dependent_but_not_principal_one_to_one_prin_uni_FK_set_principal { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildPN { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -3935,16 +3115,8 @@ public void Add_dependent_but_not_principal_one_to_one_prin_uni_FK_not_set_princ { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildPN { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -3972,16 +3144,8 @@ public void Add_principal_but_not_dependent_one_to_one_prin_uni_FK_set_principal { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildPN { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -4012,16 +3176,8 @@ public void Add_principal_but_not_dependent_one_to_one_prin_uni_FK_not_set_princ { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildPN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentPN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildPN { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -4050,16 +3206,8 @@ public void Add_dependent_but_not_principal_one_to_one_dep_uni_FK_set_no_navs_se { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildDN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildDN { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -4090,16 +3238,8 @@ public void Add_dependent_but_not_principal_one_to_one_dep_uni_FK_set_dependent_ { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildDN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildDN { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -4131,16 +3271,8 @@ public void Add_dependent_but_not_principal_one_to_one_dep_uni_FK_not_set_depend { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildDN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildDN { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -4170,16 +3302,8 @@ public void Add_principal_but_not_dependent_one_to_one_dep_uni_FK_set_no_navs_se { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildDN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildDN { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -4209,16 +3333,8 @@ public void Add_principal_but_not_dependent_one_to_one_dep_uni_FK_set_dependent_ { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildDN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildDN { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -4249,16 +3365,8 @@ public void Add_principal_but_not_dependent_one_to_one_dep_uni_FK_not_set_depend { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildDN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentDN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildDN { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -4286,16 +3394,8 @@ public void Add_dependent_but_not_principal_one_to_one_no_navs_FK_set_no_navs_se { using (var context = new FixupContext()) { - var principal = new ParentNN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildNN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentNN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildNN { Id1 = 78, Id2 = Guid78 }; context.Entry(dependent).State = entityState; @@ -4325,16 +3425,8 @@ public void Add_principal_but_not_dependent_one_to_one_no_navs_FK_set_no_navs_se { using (var context = new FixupContext()) { - var principal = new ParentNN - { - Id1 = 77, - Id2 = Guid77 - }; - var dependent = new ChildNN - { - Id1 = 78, - Id2 = Guid78 - }; + var principal = new ParentNN { Id1 = 77, Id2 = Guid77 }; + var dependent = new ChildNN { Id1 = 78, Id2 = Guid78 }; context.Entry(principal).State = entityState; @@ -4512,139 +3604,83 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); b.HasOne(e => e.Child) .WithOne(e => e.Parent) .HasForeignKey( - e => new - { - e.ParentId1, - e.ParentId2 - }); + e => new { e.ParentId1, e.ParentId2 }); }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); b.HasOne(e => e.Child) .WithOne() .HasForeignKey( - e => new - { - e.ParentId1, - e.ParentId2 - }); + e => new { e.ParentId1, e.ParentId2 }); }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); b.HasOne() .WithOne(e => e.Parent) .HasForeignKey( - e => new - { - e.ParentId1, - e.ParentId2 - }); + e => new { e.ParentId1, e.ParentId2 }); }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); b.HasOne() .WithOne() .HasForeignKey( - e => new - { - e.ParentId1, - e.ParentId2 - }); + e => new { e.ParentId1, e.ParentId2 }); }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); b.HasMany() .WithOne(e => e.Category) .HasForeignKey( - e => new - { - e.CategoryId1, - e.CategoryId2 - }) + e => new { e.CategoryId1, e.CategoryId2 }) .IsRequired(false); }); @@ -4652,30 +3688,18 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); b.HasMany(e => e.Products) .WithOne() .HasForeignKey( - e => new - { - e.CategoryId1, - e.CategoryId2 - }) + e => new { e.CategoryId1, e.CategoryId2 }) .IsRequired(false); }); @@ -4683,30 +3707,18 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); b.HasMany() .WithOne() .HasForeignKey( - e => new - { - e.CategoryId1, - e.CategoryId2 - }) + e => new { e.CategoryId1, e.CategoryId2 }) .IsRequired(false); }); @@ -4714,30 +3726,18 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); b.HasMany(e => e.Products) .WithOne(e => e.Category) .HasForeignKey( - e => new - { - e.CategoryId1, - e.CategoryId2 - }) + e => new { e.CategoryId1, e.CategoryId2 }) .IsRequired(false); }); @@ -4745,11 +3745,7 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); }); } diff --git a/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs index 28b9e8fed9c..d6b3f965481 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs @@ -4,12 +4,9 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Storage; using Xunit; @@ -266,14 +263,8 @@ private void Add_principal_and_dependent_one_to_many_prin_uni( { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id = 77 - }; - var dependent = new ProductPN - { - Id = 78 - }; + var principal = new CategoryPN { Id = 77 }; + var dependent = new ProductPN { Id = 78 }; if (setFk) { dependent.CategoryId = principal.Id; @@ -366,14 +357,8 @@ private void Add_principal_and_dependent_one_to_many_dep_uni( { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id = 77 - }; - var dependent = new ProductDN - { - Id = 78 - }; + var principal = new CategoryDN { Id = 77 }; + var dependent = new ProductDN { Id = 78 }; if (setFk) { dependent.CategoryId = principal.Id; @@ -415,15 +400,8 @@ public void Add_dependent_then_principal_one_to_many_no_navs_FK_set(EntityState { using (var context = new FixupContext()) { - var principal = new CategoryNN - { - Id = 77 - }; - var dependent = new ProductNN - { - Id = 78, - CategoryId = principal.Id - }; + var principal = new CategoryNN { Id = 77 }; + var dependent = new ProductNN { Id = 78, CategoryId = principal.Id }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -447,15 +425,8 @@ public void Add_principal_then_dependent_one_to_many_no_navs_FK_set(EntityState { using (var context = new FixupContext()) { - var principal = new CategoryNN - { - Id = 77 - }; - var dependent = new ProductNN - { - Id = 78, - CategoryId = principal.Id - }; + var principal = new CategoryNN { Id = 77 }; + var dependent = new ProductNN { Id = 78, CategoryId = principal.Id }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -716,14 +687,8 @@ private void Add_principal_and_dependent_one_to_one_prin_uni( { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; - var dependent = new ChildPN - { - Id = 78 - }; + var principal = new ParentPN { Id = 77 }; + var dependent = new ChildPN { Id = 78 }; if (setFk) { @@ -824,14 +789,8 @@ private void Add_principal_and_dependent_one_to_one_dep_uni( { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id = 77 - }; - var dependent = new ChildDN - { - Id = 78 - }; + var principal = new ParentDN { Id = 77 }; + var dependent = new ChildDN { Id = 78 }; if (setFk) { @@ -875,15 +834,8 @@ public void Add_dependent_then_principal_one_to_one_no_navs_FK_set(EntityState e { using (var context = new FixupContext()) { - var principal = new ParentNN - { - Id = 77 - }; - var dependent = new ChildNN - { - Id = 78, - ParentId = principal.Id - }; + var principal = new ParentNN { Id = 77 }; + var dependent = new ChildNN { Id = 78, ParentId = principal.Id }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -907,15 +859,8 @@ public void Add_principal_then_dependent_one_to_one_no_navs_FK_set(EntityState e { using (var context = new FixupContext()) { - var principal = new ParentNN - { - Id = 77 - }; - var dependent = new ChildNN - { - Id = 78, - ParentId = principal.Id - }; + var principal = new ParentNN { Id = 77 }; + var dependent = new ChildNN { Id = 78, ParentId = principal.Id }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -1170,14 +1115,8 @@ private void Add_dependent_but_not_principal_one_to_many_prin_uni(EntityState en { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id = 77 - }; - var dependent = new ProductPN - { - Id = 78 - }; + var principal = new CategoryPN { Id = 77 }; + var dependent = new ProductPN { Id = 78 }; context.Entry(dependent).State = entityState; @@ -1238,14 +1177,8 @@ private void Add_principal_but_not_dependent_one_to_many_prin_uni(EntityState en { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id = 77 - }; - var dependent = new ProductPN - { - Id = 78 - }; + var principal = new CategoryPN { Id = 77 }; + var dependent = new ProductPN { Id = 78 }; context.Entry(principal).State = entityState; @@ -1304,14 +1237,8 @@ private void Add_dependent_but_not_principal_one_to_many_dep_uni(EntityState ent { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id = 77 - }; - var dependent = new ProductDN - { - Id = 78 - }; + var principal = new CategoryDN { Id = 77 }; + var dependent = new ProductDN { Id = 78 }; context.Entry(dependent).State = entityState; @@ -1372,14 +1299,8 @@ private void Add_principal_but_not_dependent_one_to_many_dep_uni(EntityState ent { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id = 77 - }; - var dependent = new ProductDN - { - Id = 78 - }; + var principal = new CategoryDN { Id = 77 }; + var dependent = new ProductDN { Id = 78 }; context.Entry(principal).State = entityState; @@ -1415,14 +1336,8 @@ public void Add_dependent_but_not_principal_one_to_many_no_navs_FK_set(EntitySta { using (var context = new FixupContext()) { - var principal = new CategoryNN - { - Id = 77 - }; - var dependent = new ProductNN - { - Id = 78 - }; + var principal = new CategoryNN { Id = 77 }; + var dependent = new ProductNN { Id = 78 }; context.Entry(dependent).State = entityState; @@ -1450,14 +1365,8 @@ public void Add_principal_but_not_dependent_one_to_many_no_navs_FK_set(EntitySta { using (var context = new FixupContext()) { - var principal = new CategoryNN - { - Id = 77 - }; - var dependent = new ProductNN - { - Id = 78 - }; + var principal = new CategoryNN { Id = 77 }; + var dependent = new ProductNN { Id = 78 }; context.Entry(principal).State = entityState; @@ -1724,14 +1633,8 @@ private void Add_dependent_but_not_principal_one_to_one_prin_uni(EntityState ent { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; - var dependent = new ChildPN - { - Id = 78 - }; + var principal = new ParentPN { Id = 77 }; + var dependent = new ChildPN { Id = 78 }; context.Entry(dependent).State = entityState; @@ -1792,14 +1695,8 @@ private void Add_principal_but_not_dependent_one_to_one_prin_uni(EntityState ent { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; - var dependent = new ChildPN - { - Id = 78 - }; + var principal = new ParentPN { Id = 77 }; + var dependent = new ChildPN { Id = 78 }; context.Entry(principal).State = entityState; @@ -1858,14 +1755,8 @@ private void Add_dependent_but_not_principal_one_to_one_dep_uni(EntityState enti { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id = 77 - }; - var dependent = new ChildDN - { - Id = 78 - }; + var principal = new ParentDN { Id = 77 }; + var dependent = new ChildDN { Id = 78 }; context.Entry(dependent).State = entityState; @@ -1925,14 +1816,8 @@ private void Add_principal_but_not_dependent_one_to_one_dep_uni(EntityState enti { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id = 77 - }; - var dependent = new ChildDN - { - Id = 78 - }; + var principal = new ParentDN { Id = 77 }; + var dependent = new ChildDN { Id = 78 }; context.Entry(principal).State = entityState; @@ -1968,14 +1853,8 @@ public void Add_dependent_but_not_principal_one_to_one_no_navs_FK_set(EntityStat { using (var context = new FixupContext()) { - var principal = new ParentNN - { - Id = 77 - }; - var dependent = new ChildNN - { - Id = 78 - }; + var principal = new ParentNN { Id = 77 }; + var dependent = new ChildNN { Id = 78 }; context.Entry(dependent).State = entityState; @@ -2003,14 +1882,8 @@ public void Add_principal_but_not_dependent_one_to_one_no_navs_FK_set(EntityStat { using (var context = new FixupContext()) { - var principal = new ParentNN - { - Id = 77 - }; - var dependent = new ChildNN - { - Id = 78 - }; + var principal = new ParentNN { Id = 77 }; + var dependent = new ChildNN { Id = 78 }; context.Entry(principal).State = entityState; @@ -2226,25 +2099,14 @@ private void Replace_dependent_one_to_one_prin_uni( { context.ChangeTracker.DeleteOrphansTiming = CascadeTiming.OnSaveChanges; - var principal = new ParentPN - { - Id = 77 - }; - var oldDependent = new ChildPN - { - Id = 78, - ParentId = principal.Id - }; + var principal = new ParentPN { Id = 77 }; + var oldDependent = new ChildPN { Id = 78, ParentId = principal.Id }; principal.Child = oldDependent; context.Entry(principal).State = oldEntityState; context.Entry(oldDependent).State = oldEntityState; - var newDependent = new ChildPN - { - Id = 88, - ParentId = setFk ? principal.Id : 0 - }; + var newDependent = new ChildPN { Id = 88, ParentId = setFk ? principal.Id : 0 }; if (setToDependent) { principal.Child = newDependent; @@ -2322,25 +2184,13 @@ private void Replace_dependent_one_to_one_dep_uni( { context.ChangeTracker.DeleteOrphansTiming = CascadeTiming.OnSaveChanges; - var principal = new ParentDN - { - Id = 77 - }; - var oldDependent = new ChildDN - { - Id = 78, - ParentId = principal.Id, - Parent = principal - }; + var principal = new ParentDN { Id = 77 }; + var oldDependent = new ChildDN { Id = 78, ParentId = principal.Id, Parent = principal }; context.Entry(principal).State = oldEntityState; context.Entry(oldDependent).State = oldEntityState; - var newDependent = new ChildDN - { - Id = 88, - ParentId = setFk ? principal.Id : 0 - }; + var newDependent = new ChildDN { Id = 88, ParentId = setFk ? principal.Id : 0 }; if (setToPrincipal) { newDependent.Parent = principal; @@ -2381,24 +2231,13 @@ public void Replace_dependent_one_to_one_no_navs_FK_set(EntityState oldEntitySta { context.ChangeTracker.DeleteOrphansTiming = CascadeTiming.OnSaveChanges; - var principal = new ParentNN - { - Id = 77 - }; - var oldDependent = new ChildNN - { - Id = 78, - ParentId = principal.Id - }; + var principal = new ParentNN { Id = 77 }; + var oldDependent = new ChildNN { Id = 78, ParentId = principal.Id }; context.Entry(principal).State = oldEntityState; context.Entry(oldDependent).State = oldEntityState; - var newDependent = new ChildNN - { - Id = 88, - ParentId = principal.Id - }; + var newDependent = new ChildNN { Id = 88, ParentId = principal.Id }; context.Entry(newDependent).State = newEntityState; @@ -2636,23 +2475,11 @@ public void Comparable_entities_that_comply_are_tracked_correctly() { using (var context = new ComparableEntitiesContext("ComparableEntities")) { - var level2a = new Level2 - { - Name = "Foo" - }; + var level2a = new Level2 { Name = "Foo" }; - var level2b = new Level2 - { - Name = "Bar" - }; + var level2b = new Level2 { Name = "Bar" }; - var level1 = new Level1 - { - Children = - { - level2a, level2b, - }, - }; + var level1 = new Level1 { Children = { level2a, level2b } }; context.Add(level1); context.SaveChanges(); @@ -2675,15 +2502,9 @@ public void Comparable_entities_that_comply_are_tracked_correctly() Assert.Equal(0, level1.Children.Count); - var level2c = new Level2 - { - Name = "Foo" - }; + var level2c = new Level2 { Name = "Foo" }; - var level2d = new Level2 - { - Name = "Quz" - }; + var level2d = new Level2 { Name = "Quz" }; level1.Children.Add(level2c); level1.Children.Add(level2d); @@ -2717,7 +2538,7 @@ private class Level1 public int Id { get; set; } [Required] - public ICollection Children { get; set; } = new SortedSet(); + public ICollection Children { get; } = new SortedSet(); } private class Level2 : IComparable @@ -2751,25 +2572,11 @@ protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBu [ConditionalFact] public void Use_correct_entity_after_SetValues() { - var detachedProduct = new ProductX - { - Description = "Heavy Engine XT3" - }; + var detachedProduct = new ProductX { Description = "Heavy Engine XT3" }; - var detachedRoom = new ContainerRoomX - { - Number = 1, - Product = detachedProduct - }; + var detachedRoom = new ContainerRoomX { Number = 1, Product = detachedProduct }; - var detachedContainer = new ContainerX - { - Name = "C1", - Rooms = - { - detachedRoom - } - }; + var detachedContainer = new ContainerX { Name = "C1", Rooms = { detachedRoom } }; using (var context = new EscapeRoom(nameof(EscapeRoom))) { @@ -2779,11 +2586,7 @@ public void Use_correct_entity_after_SetValues() using (var context = new EscapeRoom(nameof(EscapeRoom))) { - var attachedProduct = new ProductX - { - Id = detachedProduct.Id, - Description = "Heavy Engine XT3" - }; + var attachedProduct = new ProductX { Id = detachedProduct.Id, Description = "Heavy Engine XT3" }; var attachedRoom = new ContainerRoomX { @@ -2794,15 +2597,7 @@ public void Use_correct_entity_after_SetValues() Product = attachedProduct }; - var attached = new ContainerX - { - Id = detachedContainer.Id, - Name = "C1", - Rooms = - { - attachedRoom - } - }; + var attached = new ContainerX { Id = detachedContainer.Id, Name = "C1", Rooms = { attachedRoom } }; context.Attach(attached); @@ -2871,18 +2666,9 @@ public void Replaced_duplicate_entities_are_used_even_with_bad_hash() using (var context = new BadHashDay("BadHashDay")) { context.AddRange( - new ParentX - { - Id = 101, Name = "Parent1" - }, - new ChildX - { - Id = 201, Name = "Child1" - }, - new ParentChildX - { - ParentId = 101, ChildId = 201, SortOrder = 1 - }); + new ParentX { Id = 101, Name = "Parent1" }, + new ChildX { Id = 201, Name = "Child1" }, + new ParentChildX { ParentId = 101, ChildId = 201, SortOrder = 1 }); context.SaveChanges(); } @@ -2898,17 +2684,9 @@ public void Replaced_duplicate_entities_are_used_even_with_bad_hash() parent.ParentChildren.Clear(); - var newJoin = new ParentChildX - { - ParentId = 101, - ChildId = 201, - SortOrder = 1 - }; + var newJoin = new ParentChildX { ParentId = 101, ChildId = 201, SortOrder = 1 }; - parent.ParentChildren = new List - { - newJoin - }; + parent.ParentChildren = new List { newJoin }; Assert.Equal(3, context.ChangeTracker.Entries().Count()); Assert.Equal(EntityState.Unchanged, context.Entry(parent).State); @@ -3004,10 +2782,7 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) .IsRequired(); modelBuilder.Entity().HasKey( - x => new - { - x.ParentId, x.ChildId - }); + x => new { x.ParentId, x.ChildId }); } } @@ -3016,21 +2791,12 @@ public void Detached_entity_is_not_replaced_by_tracked_entity() { using (var context = new BadBeeContext(nameof(BadBeeContext))) { - var b1 = new EntityB - { - EntityBId = 1 - }; + var b1 = new EntityB { EntityBId = 1 }; context.BEntities.Attach(b1); - var b2 = new EntityB - { - EntityBId = 1 - }; + var b2 = new EntityB { EntityBId = 1 }; - var a = new EntityA - { - EntityAId = 1, EntityB = b2 - }; + var a = new EntityA { EntityAId = 1, EntityB = b2 }; Assert.Equal( CoreStrings.IdentityConflict( @@ -3261,7 +3027,6 @@ private class Product private readonly int _id; private int _categoryId; private Category _category; - private ICollection _specialOffers; // ReSharper disable once UnusedMember.Local public Product() @@ -3288,10 +3053,14 @@ public Product(int id, int categoryId) public void SetCategory(Category category) => _category = category; // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter - public ICollection SpecialOffers => _specialOffers; + public ICollection SpecialOffers + { + get; + private set; + } public void AddSpecialOffer(SpecialOffer specialOffer) - => (_specialOffers ??= new List()).Add(specialOffer); + => (SpecialOffers ??= new List()).Add(specialOffer); } private class SpecialOffer @@ -3429,22 +3198,11 @@ public void Collection_nav_props_remain_fixed_up_after_DetectChanges() { using (var db = new Context4853()) { - var assembly = new TestAssembly - { - Name = "Assembly1" - }; + var assembly = new TestAssembly { Name = "Assembly1" }; db.Classes.Add( - new TestClass - { - Assembly = assembly, - Name = "Class1" - }); + new TestClass { Assembly = assembly, Name = "Class1" }); db.Classes.Add( - new TestClass - { - Assembly = assembly, - Name = "Class2" - }); + new TestClass { Assembly = assembly, Name = "Class2" }); db.SaveChanges(); } diff --git a/test/EFCore.Tests/ChangeTracking/Internal/InternalClrEntityEntryTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/InternalClrEntityEntryTest.cs index 3f935ad5eda..61bd8bf6e87 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/InternalClrEntityEntryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/InternalClrEntityEntryTest.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.ComponentModel; using System.Runtime.CompilerServices; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -112,14 +111,7 @@ public void AcceptChanges_handles_different_entity_states_for_owned_types(Entity using (var context = new KClrContext()) { var ownerEntry = context.Entry( - new OwnerClass - { - Id = 1, - Owned = new OwnedClass - { - Value = "Kool" - } - }).GetInfrastructure(); + new OwnerClass { Id = 1, Owned = new OwnedClass { Value = "Kool" } }).GetInfrastructure(); var entry = context.Entry(((OwnerClass)ownerEntry.Entity).Owned).GetInfrastructure(); var valueProperty = entry.EntityType.FindProperty(nameof(OwnedClass.Value)); @@ -190,29 +182,17 @@ public void Setting_an_explicit_value_on_the_entity_marks_property_as_not_tempor [ConditionalFact] public void Setting_CLR_property_with_snapshot_change_tracking_requires_DetectChanges() => SetPropertyClrTest( - new SomeEntity - { - Id = 1, - Name = "Kool" - }, needsDetectChanges: true); + new SomeEntity { Id = 1, Name = "Kool" }, needsDetectChanges: true); [ConditionalFact] public void Setting_CLR_property_with_changed_only_notifications_does_not_require_DetectChanges() => SetPropertyClrTest( - new ChangedOnlyEntity - { - Id = 1, - Name = "Kool" - }, needsDetectChanges: false); + new ChangedOnlyEntity { Id = 1, Name = "Kool" }, needsDetectChanges: false); [ConditionalFact] public void Setting_CLR_property_with_full_notifications_does_not_require_DetectChanges() => SetPropertyClrTest( - new FullNotificationEntity - { - Id = 1, - Name = "Kool" - }, needsDetectChanges: false); + new FullNotificationEntity { Id = 1, Name = "Kool" }, needsDetectChanges: false); private void SetPropertyClrTest(TEntity entity, bool needsDetectChanges) where TEntity : class, ISomeEntity @@ -473,21 +453,21 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); - modelBuilder.Entity( + modelBuilder.Entity( b => { b.Property(e => e.Name).IsConcurrencyToken(); b.HasChangeTrackingStrategy(ChangeTrackingStrategy.ChangingAndChangedNotifications); }); - modelBuilder.Entity( + modelBuilder.Entity( b => { b.Property(e => e.Name).IsConcurrencyToken(); b.HasChangeTrackingStrategy(ChangeTrackingStrategy.ChangedNotifications); }); - modelBuilder.Entity( + modelBuilder.Entity( eb => { eb.HasKey(e => e.Id); diff --git a/test/EFCore.Tests/ChangeTracking/Internal/InternalEntityEntryTestBase.cs b/test/EFCore.Tests/ChangeTracking/Internal/InternalEntityEntryTestBase.cs index 1b612728c9c..aab1526d6c6 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/InternalEntityEntryTestBase.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/InternalEntityEntryTestBase.cs @@ -36,9 +36,9 @@ public abstract class InternalEntityEntryTestBase< where TSomeDependentEntity : class, new() where TSomeMoreDependentEntity : class, new() where TRoot : class, IRoot, new() - where TFirstDependent: class, IFirstDependent, new() + where TFirstDependent : class, IFirstDependent, new() where TCompositeRoot : class, ICompositeRoot, new() - where TCompositeFirstDependent: class, ICompositeFirstDependent, new() + where TCompositeFirstDependent : class, ICompositeFirstDependent, new() where TSecondDependent : class, ISecondDependent, new() where TSomeCompositeEntityBase : class, new() where TCompositeSecondDependent : class, ICompositeSecondDependent, new() @@ -476,15 +476,7 @@ public virtual void Can_get_property_value_after_creation_from_value_buffer() var entityType = context.Model.FindEntityType(typeof(TSomeEntity)); var entry = stateManager.CreateEntry( - new Dictionary - { - { - "Id", 1 - }, - { - "Name", "Kool" - } - }, + new Dictionary { { "Id", 1 }, { "Name", "Kool" } }, entityType ); @@ -505,15 +497,7 @@ public virtual void Can_set_property_value_after_creation_from_value_buffer() var entityType = context.Model.FindEntityType(typeof(TSomeEntity)); var entry = stateManager.CreateEntry( - new Dictionary - { - { - "Id", 1 - }, - { - "Name", "Kool" - } - }, + new Dictionary { { "Id", 1 }, { "Name", "Kool" } }, entityType ); @@ -537,10 +521,7 @@ public virtual void Can_get_value_buffer_from_properties() entry[nonKeyProperty] = "Magic Tree House"; Assert.Equal( - new object[] - { - 77, "SomeEntity", 1, "Magic Tree House" - }, + new object[] { 77, "SomeEntity", 1, "Magic Tree House" }, CreateValueBuffer(entry)); } } diff --git a/test/EFCore.Tests/ChangeTracking/Internal/InternalEntryEntrySubscriberTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/InternalEntryEntrySubscriberTest.cs index a018326c86e..83069e62dd9 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/InternalEntryEntrySubscriberTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/InternalEntryEntrySubscriberTest.cs @@ -11,7 +11,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -147,10 +146,7 @@ public void Entry_subscribes_to_INotifyCollectionChanged_for_Remove(bool ourColl public void Entry_subscribes_to_INotifyCollectionChanged_for_Replace() { var item1 = new ChangedOnlyNotificationEntity(); - var collection = new ObservableCollection - { - item1 - }; + var collection = new ObservableCollection { item1 }; var testListener = SetupTestCollectionListener(collection); var item2 = new ChangedOnlyNotificationEntity(); @@ -166,11 +162,7 @@ public void Entry_ignores_INotifyCollectionChanged_for_Move() { var item1 = new ChangedOnlyNotificationEntity(); var item2 = new ChangedOnlyNotificationEntity(); - var collection = new ObservableCollection - { - item1, - item2 - }; + var collection = new ObservableCollection { item1, item2 }; var testListener = SetupTestCollectionListener(collection); collection.Move(0, 1); @@ -183,11 +175,7 @@ public void Entry_throws_for_INotifyCollectionChanged_Reset() { var item1 = new ChangedOnlyNotificationEntity(); var item2 = new ChangedOnlyNotificationEntity(); - var collection = new ObservableCollection - { - item1, - item2 - }; + var collection = new ObservableCollection { item1, item2 }; var testListener = SetupTestCollectionListener(collection); Assert.Equal( @@ -202,11 +190,7 @@ public void Entry_handles_clear_as_replace_with_ObservableHashSet() { var item1 = new ChangedOnlyNotificationEntity(); var item2 = new ChangedOnlyNotificationEntity(); - var collection = new ObservableHashSet - { - item1, - item2 - }; + var collection = new ObservableHashSet { item1, item2 }; var testListener = SetupTestCollectionListener(collection); collection.Clear(); @@ -237,10 +221,7 @@ private static TestNavigationListener SetupTestCollectionListener( .OfType() .Single(); - var entity = new FullNotificationEntity - { - RelatedCollection = collection - }; + var entity = new FullNotificationEntity { RelatedCollection = collection }; var entry = contextServices.GetRequiredService().GetOrCreateEntry(entity); entry.SetEntityState(EntityState.Unchanged); @@ -361,10 +342,7 @@ public void Entry_unsubscribes_to_INotifyPropertyChanging_and_INotifyPropertyCha for (var i = 0; i < 10; i++) { entities.Add( - new FullNotificationEntity - { - Id = i + 1 - }); + new FullNotificationEntity { Id = i + 1 }); entries.Add(contextServices.GetRequiredService().GetOrCreateEntry(entities[i])); entries[i].SetEntityState(EntityState.Unchanged); } @@ -420,11 +398,7 @@ public void Entry_unsubscribes_to_INotifyCollectionChanged() for (var i = 0; i < 10; i++) { entities.Add( - new FullNotificationEntity - { - Id = i + 1, - RelatedCollection = new ObservableHashSet() - }); + new FullNotificationEntity { Id = i + 1, RelatedCollection = new ObservableHashSet() }); entries.Add(contextServices.GetRequiredService().GetOrCreateEntry(entities[i])); entries[i].SetEntityState(EntityState.Unchanged); } @@ -470,10 +444,7 @@ public void Entries_are_unsubscribed_when_context_is_disposed() for (var i = 0; i < 10; i++) { entities.Add( - new FullNotificationEntity - { - Id = i + 1 - }); + new FullNotificationEntity { Id = i + 1 }); entries.Add(context.Add(entities[i])); entries[i].State = EntityState.Unchanged; } @@ -555,7 +526,8 @@ public void StateChanged(InternalEntityEntry entry, EntityState oldState, bool f } public void KeyPropertyChanged( - InternalEntityEntry entry, IProperty property, IReadOnlyList containingPrincipalKeys, IReadOnlyList containingForeignKeys, + InternalEntityEntry entry, IProperty property, IReadOnlyList containingPrincipalKeys, + IReadOnlyList containingForeignKeys, object oldValue, object newValue) { } diff --git a/test/EFCore.Tests/ChangeTracking/Internal/KeyPropagatorTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/KeyPropagatorTest.cs index f62d389bfea..3ab439cea51 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/KeyPropagatorTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/KeyPropagatorTest.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.EntityFrameworkCore.ValueGeneration.Internal; using Microsoft.Extensions.DependencyInjection; @@ -25,15 +24,8 @@ public void Foreign_key_value_is_obtained_from_reference_to_principal(bool gener { var model = BuildModel(generateTemporary); - var principal = new Category - { - Id = 11 - }; - var dependent = new Product - { - Id = 21, - Category = principal - }; + var principal = new Category { Id = 11 }; + var dependent = new Product { Id = 21, Category = principal }; var contextServices = CreateContextServices(model); var dependentEntry = contextServices.GetRequiredService().GetOrCreateEntry(dependent); @@ -57,14 +49,8 @@ public void Foreign_key_value_is_obtained_from_tracked_principal_with_populated_ var contextServices = CreateContextServices(model); var manager = contextServices.GetRequiredService(); - var principal = new Category - { - Id = 11 - }; - var dependent = new Product - { - Id = 21 - }; + var principal = new Category { Id = 11 }; + var dependent = new Product { Id = 21 }; principal.Products.Add(dependent); manager.GetOrCreateEntry(principal).SetEntityState(EntityState.Unchanged); @@ -88,11 +74,7 @@ public void Non_identifying_foreign_key_value_is_not_generated_if_principal_key_ var model = BuildModel(generateTemporary); var principal = new Category(); - var dependent = new Product - { - Id = 21, - Category = principal - }; + var dependent = new Product { Id = 21, Category = principal }; var contextServices = CreateContextServices(model); var dependentEntry = contextServices.GetRequiredService().GetOrCreateEntry(dependent); @@ -114,14 +96,8 @@ public void One_to_one_foreign_key_value_is_obtained_from_reference_to_principal { var model = BuildModel(generateTemporary); - var principal = new Product - { - Id = 21 - }; - var dependent = new ProductDetail - { - Product = principal - }; + var principal = new Product { Id = 21 }; + var dependent = new ProductDetail { Product = principal }; var contextServices = CreateContextServices(model); var dependentEntry = contextServices.GetRequiredService().GetOrCreateEntry(dependent); @@ -146,11 +122,7 @@ public void One_to_one_foreign_key_value_is_obtained_from_tracked_principal(bool var manager = contextServices.GetRequiredService(); var dependent = new ProductDetail(); - var principal = new Product - { - Id = 21, - Detail = dependent - }; + var principal = new Product { Id = 21, Detail = dependent }; manager.GetOrCreateEntry(principal).SetEntityState(EntityState.Unchanged); var dependentEntry = manager.GetOrCreateEntry(dependent); @@ -173,10 +145,7 @@ public void Identifying_foreign_key_value_is_generated_if_principal_key_not_set( var model = BuildModel(generateTemporary); var principal = new Product(); - var dependent = new ProductDetail - { - Product = principal - }; + var dependent = new ProductDetail { Product = principal }; var contextServices = CreateContextServices(model); var dependentEntry = contextServices.GetRequiredService().GetOrCreateEntry(dependent); @@ -199,10 +168,7 @@ public void Identifying_foreign_key_value_is_propagated_if_principal_key_is_gene var model = BuildModel(generateTemporary); var principal = new Product(); - var dependent = new ProductDetail - { - Product = principal - }; + var dependent = new ProductDetail { Product = principal }; var contextServices = CreateContextServices(model); var stateManager = contextServices.GetRequiredService(); @@ -231,15 +197,8 @@ public void Composite_foreign_key_value_is_obtained_from_reference_to_principal( { var model = BuildModel(generateTemporary); - var principal = new OrderLine - { - OrderId = 11, - ProductId = 21 - }; - var dependent = new OrderLineDetail - { - OrderLine = principal - }; + var principal = new OrderLine { OrderId = 11, ProductId = 21 }; + var dependent = new OrderLineDetail { OrderLine = principal }; var contextServices = CreateContextServices(model); var dependentEntry = contextServices.GetRequiredService().GetOrCreateEntry(dependent); @@ -268,12 +227,7 @@ public void Composite_foreign_key_value_is_obtained_from_tracked_principal(bool var manager = contextServices.GetRequiredService(); var dependent = new OrderLineDetail(); - var principal = new OrderLine - { - OrderId = 11, - ProductId = 21, - Detail = dependent - }; + var principal = new OrderLine { OrderId = 11, ProductId = 21, Detail = dependent }; manager.GetOrCreateEntry(principal).SetEntityState(EntityState.Unchanged); var dependentEntry = manager.GetOrCreateEntry(dependent); @@ -376,27 +330,15 @@ private static IModel BuildModel(bool generateTemporary = false) builder.Entity().HasMany(e => e.OrderLines).WithOne(e => e.Order); builder.Entity().HasKey( - e => new - { - e.OrderId, - e.ProductId - }); + e => new { e.OrderId, e.ProductId }); builder.Entity( b => { b.HasKey( - e => new - { - e.OrderId, - e.ProductId - }); + e => new { e.OrderId, e.ProductId }); b.HasOne(e => e.Detail).WithOne(e => e.OrderLine).HasForeignKey( - e => new - { - e.OrderId, - e.ProductId - }); + e => new { e.OrderId, e.ProductId }); }); if (generateTemporary) diff --git a/test/EFCore.Tests/ChangeTracking/Internal/NavigationFixerTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/NavigationFixerTest.cs index 76a21e08604..0d935dc6cef 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/NavigationFixerTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/NavigationFixerTest.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Linq; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -24,27 +23,15 @@ public void Does_not_throw_if_Add_during_fixup() { using (var context = new FixupContext()) { - var blog1 = new Blog - { - Id = 1 - }; - var blog2 = new Blog - { - Id = 2 - }; + var blog1 = new Blog { Id = 1 }; + var blog2 = new Blog { Id = 2 }; var post1 = context.Add( - new Post - { - BlogId = 2 - }).Entity; + new Post { BlogId = 2 }).Entity; blog1.Posts.Add(post1); blog1.Posts.Add( - new Post - { - BlogId = 2 - }); + new Post { BlogId = 2 }); context.Add(blog2); context.Add(blog1); @@ -91,19 +78,9 @@ public void Does_fixup_of_related_principals() var contextServices = CreateContextServices(); var manager = contextServices.GetRequiredService(); - var principal1 = new Category - { - Id = 11 - }; - var principal2 = new Category - { - Id = 12 - }; - var dependent = new Product - { - Id = 21, - CategoryId = 12 - }; + var principal1 = new Category { Id = 11 }; + var principal2 = new Category { Id = 12 }; + var dependent = new Product { Id = 21, CategoryId = 12 }; manager.StartTracking(manager.GetOrCreateEntry(principal1)); manager.StartTracking(manager.GetOrCreateEntry(principal2)); @@ -123,26 +100,11 @@ public void Does_fixup_of_related_dependents() var contextServices = CreateContextServices(); var manager = contextServices.GetRequiredService(); - var dependent1 = new Product - { - Id = 21, - CategoryId = 11 - }; - var dependent2 = new Product - { - Id = 22, - CategoryId = 12 - }; - var dependent3 = new Product - { - Id = 23, - CategoryId = 11 - }; + var dependent1 = new Product { Id = 21, CategoryId = 11 }; + var dependent2 = new Product { Id = 22, CategoryId = 12 }; + var dependent3 = new Product { Id = 23, CategoryId = 11 }; - var principal = new Category - { - Id = 11 - }; + var principal = new Category { Id = 11 }; manager.StartTracking(manager.GetOrCreateEntry(dependent1)); manager.StartTracking(manager.GetOrCreateEntry(dependent2)); @@ -168,31 +130,13 @@ public void Does_fixup_of_one_to_one_relationship() var contextServices = CreateContextServices(); var manager = contextServices.GetRequiredService(); - var principal1 = new Product - { - Id = 21 - }; - var principal2 = new Product - { - Id = 22 - }; - var principal3 = new Product - { - Id = 23 - }; + var principal1 = new Product { Id = 21 }; + var principal2 = new Product { Id = 22 }; + var principal3 = new Product { Id = 23 }; - var dependent1 = new ProductDetail - { - Id = 21 - }; - var dependent2 = new ProductDetail - { - Id = 22 - }; - var dependent4 = new ProductDetail - { - Id = 24 - }; + var dependent1 = new ProductDetail { Id = 21 }; + var dependent2 = new ProductDetail { Id = 22 }; + var dependent4 = new ProductDetail { Id = 24 }; var principalEntry1 = manager.StartTracking(manager.GetOrCreateEntry(principal1)); var principalEntry2 = manager.StartTracking(manager.GetOrCreateEntry(principal2)); @@ -234,20 +178,9 @@ public void Does_fixup_of_one_to_one_self_referencing_relationship() var contextServices = CreateContextServices(); var manager = contextServices.GetRequiredService(); - var entity1 = new Product - { - Id = 21, - AlternateProductId = 22 - }; - var entity2 = new Product - { - Id = 22, - AlternateProductId = 23 - }; - var entity3 = new Product - { - Id = 23 - }; + var entity1 = new Product { Id = 21, AlternateProductId = 22 }; + var entity2 = new Product { Id = 22, AlternateProductId = 23 }; + var entity3 = new Product { Id = 23 }; var entry1 = manager.StartTracking(manager.GetOrCreateEntry(entity1)); var entry2 = manager.StartTracking(manager.GetOrCreateEntry(entity2)); @@ -291,19 +224,9 @@ public void Does_fixup_of_FKs_and_related_principals_using_dependent_navigations var contextServices = CreateContextServices(); var manager = contextServices.GetRequiredService(); - var principal1 = new Category - { - Id = 11 - }; - var principal2 = new Category - { - Id = 12 - }; - var dependent = new Product - { - Id = 21, - Category = principal2 - }; + var principal1 = new Category { Id = 11 }; + var principal2 = new Category { Id = 12 }; + var dependent = new Product { Id = 21, Category = principal2 }; manager.StartTracking(manager.GetOrCreateEntry(principal1)); manager.StartTracking(manager.GetOrCreateEntry(principal2)); @@ -324,18 +247,9 @@ public void Does_fixup_of_FKs_and_related_principals_using_principal_navigations var contextServices = CreateContextServices(); var manager = contextServices.GetRequiredService(); - var principal1 = new Category - { - Id = 11 - }; - var principal2 = new Category - { - Id = 12 - }; - var dependent = new Product - { - Id = 21 - }; + var principal1 = new Category { Id = 11 }; + var principal2 = new Category { Id = 12 }; + var dependent = new Product { Id = 21 }; principal2.Products.Add(dependent); @@ -358,25 +272,11 @@ public void Does_fixup_of_FKs_and_related_dependents_using_dependent_navigations var contextServices = CreateContextServices(); var manager = contextServices.GetRequiredService(); - var principal = new Category - { - Id = 11 - }; + var principal = new Category { Id = 11 }; - var dependent1 = new Product - { - Id = 21, - Category = principal - }; - var dependent2 = new Product - { - Id = 22 - }; - var dependent3 = new Product - { - Id = 23, - Category = principal - }; + var dependent1 = new Product { Id = 21, Category = principal }; + var dependent2 = new Product { Id = 22 }; + var dependent3 = new Product { Id = 23, Category = principal }; manager.StartTracking(manager.GetOrCreateEntry(dependent1)).SetEntityState(EntityState.Added); manager.StartTracking(manager.GetOrCreateEntry(dependent2)).SetEntityState(EntityState.Added); @@ -405,23 +305,11 @@ public void Does_fixup_of_FKs_and_related_dependents_using_principal_navigations var contextServices = CreateContextServices(); var manager = contextServices.GetRequiredService(); - var principal = new Category - { - Id = 11 - }; + var principal = new Category { Id = 11 }; - var dependent1 = new Product - { - Id = 21 - }; - var dependent2 = new Product - { - Id = 22 - }; - var dependent3 = new Product - { - Id = 23 - }; + var dependent1 = new Product { Id = 21 }; + var dependent2 = new Product { Id = 22 }; + var dependent3 = new Product { Id = 23 }; principal.Products.Add(dependent1); principal.Products.Add(dependent3); @@ -453,18 +341,9 @@ public void Does_fixup_of_one_to_one_self_referencing_relationship_using_depende var contextServices = CreateContextServices(); var manager = contextServices.GetRequiredService(); - var entity1 = new Product - { - Id = 21 - }; - var entity2 = new Product - { - Id = 22 - }; - var entity3 = new Product - { - Id = 23 - }; + var entity1 = new Product { Id = 21 }; + var entity2 = new Product { Id = 22 }; + var entity3 = new Product { Id = 23 }; entity1.AlternateProduct = entity2; entity2.AlternateProduct = entity3; @@ -523,18 +402,9 @@ public void Does_fixup_of_one_to_one_self_referencing_relationship_using_princip var contextServices = CreateContextServices(); var manager = contextServices.GetRequiredService(); - var entity1 = new Product - { - Id = 21 - }; - var entity2 = new Product - { - Id = 22 - }; - var entity3 = new Product - { - Id = 23 - }; + var entity1 = new Product { Id = 21 }; + var entity2 = new Product { Id = 22 }; + var entity3 = new Product { Id = 23 }; entity2.OriginalProduct = entity1; entity3.OriginalProduct = entity2; @@ -609,19 +479,9 @@ public void Does_fixup_of_related_principals_when_FK_is_set() var contextServices = CreateContextServices(model); var manager = contextServices.GetRequiredService(); - var principal1 = new Category - { - Id = 11 - }; - var principal2 = new Category - { - Id = 12 - }; - var dependent = new Product - { - Id = 21, - CategoryId = 0 - }; + var principal1 = new Category { Id = 11 }; + var principal2 = new Category { Id = 12 }; + var dependent = new Product { Id = 21, CategoryId = 0 }; manager.StartTracking(manager.GetOrCreateEntry(principal1)); manager.StartTracking(manager.GetOrCreateEntry(principal2)); @@ -660,19 +520,9 @@ public void Does_fixup_of_related_principals_when_FK_is_cleared() var contextServices = CreateContextServices(model); var manager = contextServices.GetRequiredService(); - var principal1 = new Category - { - Id = 11 - }; - var principal2 = new Category - { - Id = 12 - }; - var dependent = new Product - { - Id = 21, - CategoryId = 12 - }; + var principal1 = new Category { Id = 11 }; + var principal2 = new Category { Id = 12 }; + var dependent = new Product { Id = 21, CategoryId = 12 }; manager.StartTracking(manager.GetOrCreateEntry(principal1)); manager.StartTracking(manager.GetOrCreateEntry(principal2)); @@ -711,19 +561,9 @@ public void Does_fixup_of_related_principals_when_FK_is_changed() var contextServices = CreateContextServices(model); var manager = contextServices.GetRequiredService(); - var principal1 = new Category - { - Id = 11 - }; - var principal2 = new Category - { - Id = 12 - }; - var dependent = new Product - { - Id = 21, - CategoryId = 12 - }; + var principal1 = new Category { Id = 11 }; + var principal2 = new Category { Id = 12 }; + var dependent = new Product { Id = 21, CategoryId = 12 }; manager.StartTracking(manager.GetOrCreateEntry(principal1)); manager.StartTracking(manager.GetOrCreateEntry(principal2)); @@ -762,18 +602,9 @@ public void Does_fixup_of_one_to_one_relationship_when_FK_changes() var contextServices = CreateContextServices(model); var manager = contextServices.GetRequiredService(); - var principal1 = new Product - { - Id = 21 - }; - var principal2 = new Product - { - Id = 22 - }; - var dependent = new ProductDetail - { - Id = 21 - }; + var principal1 = new Product { Id = 21 }; + var principal2 = new Product { Id = 22 }; + var dependent = new ProductDetail { Id = 21 }; var principalEntry1 = manager.StartTracking(manager.GetOrCreateEntry(principal1)); var principalEntry2 = manager.StartTracking(manager.GetOrCreateEntry(principal2)); @@ -814,14 +645,8 @@ public void Does_fixup_of_one_to_one_relationship_when_FK_cleared() var contextServices = CreateContextServices(model); var manager = contextServices.GetRequiredService(); - var principal = new Product - { - Id = 21 - }; - var dependent = new ProductDetail - { - Id = 21 - }; + var principal = new Product { Id = 21 }; + var dependent = new ProductDetail { Id = 21 }; var principalEntry = manager.StartTracking(manager.GetOrCreateEntry(principal)); var dependentEntry = manager.StartTracking(manager.GetOrCreateEntry(dependent)); @@ -858,14 +683,8 @@ public void Does_fixup_of_one_to_one_relationship_when_FK_set() var contextServices = CreateContextServices(model); var manager = contextServices.GetRequiredService(); - var principal = new Product - { - Id = 21 - }; - var dependent = new ProductDetail - { - Id = 7 - }; + var principal = new Product { Id = 21 }; + var dependent = new ProductDetail { Id = 7 }; var principalEntry = manager.StartTracking(manager.GetOrCreateEntry(principal)); var dependentEntry = manager.StartTracking(manager.GetOrCreateEntry(dependent)); @@ -902,19 +721,9 @@ public void Does_fixup_of_one_to_one_self_referencing_relationship_when_FK_chang var contextServices = CreateContextServices(model); var manager = contextServices.GetRequiredService(); - var entity1 = new Product - { - Id = 21, - AlternateProductId = 22 - }; - var entity2 = new Product - { - Id = 22 - }; - var entity3 = new Product - { - Id = 23 - }; + var entity1 = new Product { Id = 21, AlternateProductId = 22 }; + var entity2 = new Product { Id = 22 }; + var entity3 = new Product { Id = 23 }; var entry1 = manager.StartTracking(manager.GetOrCreateEntry(entity1)); var entry2 = manager.StartTracking(manager.GetOrCreateEntry(entity2)); @@ -965,20 +774,9 @@ public void Can_steal_reference_of_one_to_one_self_referencing_relationship_when var contextServices = CreateContextServices(model); var manager = contextServices.GetRequiredService(); - var entity1 = new Product - { - Id = 21, - AlternateProductId = 22 - }; - var entity2 = new Product - { - Id = 22, - AlternateProductId = 23 - }; - var entity3 = new Product - { - Id = 23 - }; + var entity1 = new Product { Id = 21, AlternateProductId = 22 }; + var entity2 = new Product { Id = 22, AlternateProductId = 23 }; + var entity3 = new Product { Id = 23 }; var entry1 = manager.StartTracking(manager.GetOrCreateEntry(entity1)); var entry2 = manager.StartTracking(manager.GetOrCreateEntry(entity2)); @@ -1031,106 +829,26 @@ public void Does_fixup_of_all_related_principals_when_part_of_overlapping_compos var contextServices = CreateContextServices(model); var manager = contextServices.GetRequiredService(); - var photo1 = new ProductPhoto - { - ProductId = 1, - PhotoId = "Photo1" - }; - var photo2 = new ProductPhoto - { - ProductId = 1, - PhotoId = "Photo2" - }; - var photo3 = new ProductPhoto - { - ProductId = 2, - PhotoId = "Photo1" - }; - var photo4 = new ProductPhoto - { - ProductId = 2, - PhotoId = "Photo2" - }; + var photo1 = new ProductPhoto { ProductId = 1, PhotoId = "Photo1" }; + var photo2 = new ProductPhoto { ProductId = 1, PhotoId = "Photo2" }; + var photo3 = new ProductPhoto { ProductId = 2, PhotoId = "Photo1" }; + var photo4 = new ProductPhoto { ProductId = 2, PhotoId = "Photo2" }; var reviewId1 = Guid.NewGuid(); var reviewId2 = Guid.NewGuid(); - var review1 = new ProductReview - { - ProductId = 1, - ReviewId = reviewId1 - }; - var review2 = new ProductReview - { - ProductId = 1, - ReviewId = reviewId2 - }; - var review3 = new ProductReview - { - ProductId = 2, - ReviewId = reviewId1 - }; - var review4 = new ProductReview - { - ProductId = 2, - ReviewId = reviewId2 - }; - - var tag1 = new ProductTag - { - Id = 1, - ProductId = 1, - PhotoId = "Photo1", - ReviewId = reviewId1 - }; - var tag2 = new ProductTag - { - Id = 2, - ProductId = 1, - PhotoId = "Photo1", - ReviewId = reviewId2 - }; - var tag3 = new ProductTag - { - Id = 3, - ProductId = 1, - PhotoId = "Photo2", - ReviewId = reviewId1 - }; - var tag4 = new ProductTag - { - Id = 4, - ProductId = 1, - PhotoId = "Photo2", - ReviewId = reviewId2 - }; - var tag5 = new ProductTag - { - Id = 5, - ProductId = 2, - PhotoId = "Photo1", - ReviewId = reviewId1 - }; - var tag6 = new ProductTag - { - Id = 6, - ProductId = 2, - PhotoId = "Photo1", - ReviewId = reviewId2 - }; - var tag7 = new ProductTag - { - Id = 7, - ProductId = 2, - PhotoId = "Photo2", - ReviewId = reviewId1 - }; - var tag8 = new ProductTag - { - Id = 8, - ProductId = 2, - PhotoId = "Photo2", - ReviewId = reviewId2 - }; + var review1 = new ProductReview { ProductId = 1, ReviewId = reviewId1 }; + var review2 = new ProductReview { ProductId = 1, ReviewId = reviewId2 }; + var review3 = new ProductReview { ProductId = 2, ReviewId = reviewId1 }; + var review4 = new ProductReview { ProductId = 2, ReviewId = reviewId2 }; + + var tag1 = new ProductTag { Id = 1, ProductId = 1, PhotoId = "Photo1", ReviewId = reviewId1 }; + var tag2 = new ProductTag { Id = 2, ProductId = 1, PhotoId = "Photo1", ReviewId = reviewId2 }; + var tag3 = new ProductTag { Id = 3, ProductId = 1, PhotoId = "Photo2", ReviewId = reviewId1 }; + var tag4 = new ProductTag { Id = 4, ProductId = 1, PhotoId = "Photo2", ReviewId = reviewId2 }; + var tag5 = new ProductTag { Id = 5, ProductId = 2, PhotoId = "Photo1", ReviewId = reviewId1 }; + var tag6 = new ProductTag { Id = 6, ProductId = 2, PhotoId = "Photo1", ReviewId = reviewId2 }; + var tag7 = new ProductTag { Id = 7, ProductId = 2, PhotoId = "Photo2", ReviewId = reviewId1 }; + var tag8 = new ProductTag { Id = 8, ProductId = 2, PhotoId = "Photo2", ReviewId = reviewId2 }; var photoEntry1 = manager.StartTracking(manager.GetOrCreateEntry(photo1)); var photoEntry2 = manager.StartTracking(manager.GetOrCreateEntry(photo2)); @@ -1245,29 +963,11 @@ public void Removes_dependent_from_collection_after_deletion() var contextServices = CreateContextServices(); var manager = contextServices.GetRequiredService(); - var principal1 = new Category - { - Id = 11 - }; - var principal2 = new Category - { - Id = 12 - }; - var dependent1 = new Product - { - Id = 21, - CategoryId = 12 - }; - var dependent2 = new Product - { - Id = 22, - CategoryId = 12 - }; - var dependent3 = new Product - { - Id = 23, - CategoryId = 11 - }; + var principal1 = new Category { Id = 11 }; + var principal2 = new Category { Id = 12 }; + var dependent1 = new Product { Id = 21, CategoryId = 12 }; + var dependent2 = new Product { Id = 22, CategoryId = 12 }; + var dependent3 = new Product { Id = 23, CategoryId = 11 }; var principal1Entry = manager.StartTracking(manager.GetOrCreateEntry(principal1)); var principal2Entry = manager.StartTracking(manager.GetOrCreateEntry(principal2)); @@ -1335,29 +1035,11 @@ public void Nulls_navigation_to_principal_after_after_deletion() var contextServices = CreateContextServices(); var manager = contextServices.GetRequiredService(); - var principal1 = new Category - { - Id = 11 - }; - var principal2 = new Category - { - Id = 12 - }; - var dependent1 = new Product - { - Id = 21, - CategoryId = 12 - }; - var dependent2 = new Product - { - Id = 22, - CategoryId = 12 - }; - var dependent3 = new Product - { - Id = 23, - CategoryId = 11 - }; + var principal1 = new Category { Id = 11 }; + var principal2 = new Category { Id = 12 }; + var dependent1 = new Product { Id = 21, CategoryId = 12 }; + var dependent2 = new Product { Id = 22, CategoryId = 12 }; + var dependent3 = new Product { Id = 23, CategoryId = 11 }; var principal1Entry = manager.StartTracking(manager.GetOrCreateEntry(principal1)); var principal2Entry = manager.StartTracking(manager.GetOrCreateEntry(principal2)); @@ -1414,24 +1096,10 @@ public void Nulls_one_to_one_navigation_to_principal_after_deletion() var contextServices = CreateContextServices(model); var manager = contextServices.GetRequiredService(); - var principal1 = new Product - { - Id = 21 - }; - var principal2 = new Product - { - Id = 22 - }; - var dependent1 = new Product - { - Id = 23, - AlternateProductId = 21 - }; - var dependent2 = new Product - { - Id = 24, - AlternateProductId = 22 - }; + var principal1 = new Product { Id = 21 }; + var principal2 = new Product { Id = 22 }; + var dependent1 = new Product { Id = 23, AlternateProductId = 21 }; + var dependent2 = new Product { Id = 24, AlternateProductId = 22 }; var principalEntry1 = manager.StartTracking(manager.GetOrCreateEntry(principal1)); var principalEntry2 = manager.StartTracking(manager.GetOrCreateEntry(principal2)); @@ -1476,24 +1144,10 @@ public void Nulls_one_to_one_navigation_to_dependent_after_after_deletion() var contextServices = CreateContextServices(model); var manager = contextServices.GetRequiredService(); - var principal1 = new Product - { - Id = 21 - }; - var principal2 = new Product - { - Id = 22 - }; - var dependent1 = new Product - { - Id = 23, - AlternateProductId = 21 - }; - var dependent2 = new Product - { - Id = 24, - AlternateProductId = 22 - }; + var principal1 = new Product { Id = 21 }; + var principal2 = new Product { Id = 22 }; + var dependent1 = new Product { Id = 23, AlternateProductId = 21 }; + var dependent2 = new Product { Id = 24, AlternateProductId = 22 }; var principalEntry1 = manager.StartTracking(manager.GetOrCreateEntry(principal1)); var principalEntry2 = manager.StartTracking(manager.GetOrCreateEntry(principal2)); @@ -1619,36 +1273,20 @@ private static IModel BuildModel() b => { b.HasKey( - e => new - { - e.ProductId, - e.PhotoId - }); + e => new { e.ProductId, e.PhotoId }); b.HasMany(e => e.ProductTags).WithOne(e => e.Photo) .HasForeignKey( - e => new - { - e.ProductId, - e.PhotoId - }); + e => new { e.ProductId, e.PhotoId }); }); builder.Entity( b => { b.HasKey( - e => new - { - e.ProductId, - e.ReviewId - }); + e => new { e.ProductId, e.ReviewId }); b.HasMany(e => e.ProductTags).WithOne(e => e.Review) .HasForeignKey( - e => new - { - e.ProductId, - e.ReviewId - }); + e => new { e.ProductId, e.ReviewId }); }); builder.Entity(); diff --git a/test/EFCore.Tests/ChangeTracking/Internal/ObservableBackedBindingListTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/ObservableBackedBindingListTest.cs index 3cf06c7bfe2..793d75586ad 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/ObservableBackedBindingListTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/ObservableBackedBindingListTest.cs @@ -249,10 +249,7 @@ public void Adding_duplicate_item_to_the_binding_list_adds_duplicate_to_the_Obse 5, 9 }; - var obbl = new ObservableBackedBindingList(oc) - { - item - }; + var obbl = new ObservableBackedBindingList(oc) { item }; Assert.Equal(7, oc.Count); Assert.Equal(2, oc.Count(i => ReferenceEquals(i, item))); @@ -499,10 +496,7 @@ public void Adding_duplicate_item_to_the_binding_list_is_ignored() 5, 9 }; - var obbl = new ObservableBackedBindingList(oc) - { - item - }; + var obbl = new ObservableBackedBindingList(oc) { item }; Assert.Equal(6, oc.Count); Assert.Equal(1, oc.Count(i => ReferenceEquals(i, item))); diff --git a/test/EFCore.Tests/ChangeTracking/Internal/ObservableCollectionListSourceTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/ObservableCollectionListSourceTest.cs index 85ab09aa7a8..be147b13007 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/ObservableCollectionListSourceTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/ObservableCollectionListSourceTest.cs @@ -27,11 +27,7 @@ public void ObservableCollectionListSource_exposes_ObservableCollection_IEnumera [ConditionalFact] public void ObservableCollectionListSource_exposes_ObservableCollection_List_constructor() { - var entities = new List - { - new FakeEntity(), - new FakeEntity() - }; + var entities = new List { new FakeEntity(), new FakeEntity() }; var ols = new ObservableCollectionListSource(entities); Assert.Equal(2, ols.Count); } @@ -45,11 +41,7 @@ public void ObservableCollectionListSource_ContainsListCollection_returns_false( [ConditionalFact] public void ObservableCollectionListSource_GetList_returns_BindingList_attached_to_the_ObservableCollection() { - var ols = new ObservableCollectionListSource - { - new FakeEntity(), - new FakeEntity() - }; + var ols = new ObservableCollectionListSource { new FakeEntity(), new FakeEntity() }; var bindingList = ((IListSource)ols).GetList(); Assert.Equal(2, bindingList.Count); diff --git a/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs index 0e7da9faf8c..10675eb4480 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs @@ -27,15 +27,9 @@ public void Can_get_owned_entity_entry() { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; + var principal = new ParentPN { Id = 77 }; - var dependent = new ChildPN - { - Name = "1" - }; + var dependent = new ChildPN { Name = "1" }; principal.Child1 = dependent; principal.Child2 = dependent; @@ -66,15 +60,9 @@ public void Adding_duplicate_owned_entity_throws_by_default() { using (var context = new FixupContext(false)) { - var principal = new ParentPN - { - Id = 77 - }; + var principal = new ParentPN { Id = 77 }; - var dependent = new ChildPN - { - Name = "1" - }; + var dependent = new ChildPN { Name = "1" }; principal.Child1 = dependent; principal.Child2 = dependent; @@ -107,25 +95,16 @@ public void Add_principal_with_dependent_unidirectional_nav(EntityState entitySt { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; + var principal = new ParentPN { Id = 77 }; if (useTrackGraph == null) { context.Entry(principal).State = entityState; } - var dependent = new ChildPN - { - Name = "1" - }; + var dependent = new ChildPN { Name = "1" }; principal.Child1 = dependent; - var subDependent = new SubChildPN - { - Name = "1S" - }; + var subDependent = new SubChildPN { Name = "1S" }; dependent.SubChild = subDependent; if (useTrackGraph == null) @@ -190,27 +169,16 @@ public void Add_principal_with_dependent_both_navs(EntityState entityState, bool { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; + var principal = new Parent { Id = 77 }; if (useTrackGraph == null) { context.Entry(principal).State = entityState; } - var dependent = new Child - { - Name = "1", - Parent = principal - }; + var dependent = new Child { Name = "1", Parent = principal }; principal.Child1 = dependent; - var subDependent = new SubChild - { - Name = "1S", - Parent = dependent - }; + var subDependent = new SubChild { Name = "1S", Parent = dependent }; dependent.SubChild = subDependent; if (useTrackGraph == null) @@ -273,25 +241,16 @@ public void Add_principal_with_dependent_principal_nav(EntityState entityState, { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; + var principal = new Parent { Id = 77 }; if (useTrackGraph == null) { context.Entry(principal).State = entityState; } - var dependent = new Child - { - Name = "1" - }; + var dependent = new Child { Name = "1" }; principal.Child1 = dependent; - var subDependent = new SubChild - { - Name = "1S" - }; + var subDependent = new SubChild { Name = "1S" }; dependent.SubChild = subDependent; if (useTrackGraph == null) @@ -395,29 +354,21 @@ public void Add_principal_with_dependent_principal_nav(EntityState entityState, [InlineData(EntityState.Unchanged, true, CollectionType.ObservableHashSet)] [InlineData(EntityState.Unchanged, false, CollectionType.ObservableHashSet)] [InlineData(EntityState.Unchanged, null, CollectionType.ObservableHashSet)] - public void Add_principal_with_dependent_unidirectional_nav_collection(EntityState entityState, bool? useTrackGraph, CollectionType collectionType) + public void Add_principal_with_dependent_unidirectional_nav_collection( + EntityState entityState, bool? useTrackGraph, CollectionType collectionType) { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; + var principal = new ParentPN { Id = 77 }; if (useTrackGraph == null) { context.Entry(principal).State = entityState; } - var dependent = new ChildPN - { - Name = "1" - }; + var dependent = new ChildPN { Name = "1" }; principal.ChildCollection1 = CreateChildCollection(collectionType, dependent); - var subDependent = new SubChildPN - { - Name = "1S" - }; + var subDependent = new SubChildPN { Name = "1S" }; dependent.SubChildCollection = CreateChildCollection(collectionType, subDependent); if (useTrackGraph == null) @@ -426,21 +377,23 @@ public void Add_principal_with_dependent_unidirectional_nav_collection(EntitySta } else if (useTrackGraph == true) { - context.ChangeTracker.TrackGraph(principal, e => - { - if (entityState != EntityState.Added) + context.ChangeTracker.TrackGraph( + principal, e => { - if (ReferenceEquals(e.Entry.Entity, dependent)) - { - e.Entry.Property("Id").CurrentValue = 10; - } - else if (ReferenceEquals(e.Entry.Entity, subDependent)) + if (entityState != EntityState.Added) { - e.Entry.Property("Id").CurrentValue = 100; + if (ReferenceEquals(e.Entry.Entity, dependent)) + { + e.Entry.Property("Id").CurrentValue = 10; + } + else if (ReferenceEquals(e.Entry.Entity, subDependent)) + { + e.Entry.Property("Id").CurrentValue = 100; + } } - } - e.Entry.State = entityState; - }); + + e.Entry.State = entityState; + }); } else { @@ -537,31 +490,21 @@ public void Add_principal_with_dependent_unidirectional_nav_collection(EntitySta [InlineData(EntityState.Unchanged, true, CollectionType.ObservableHashSet)] [InlineData(EntityState.Unchanged, false, CollectionType.ObservableHashSet)] [InlineData(EntityState.Unchanged, null, CollectionType.ObservableHashSet)] - public void Add_principal_with_dependent_both_navs_collection(EntityState entityState, bool? useTrackGraph, CollectionType collectionType) + public void Add_principal_with_dependent_both_navs_collection( + EntityState entityState, bool? useTrackGraph, CollectionType collectionType) { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; + var principal = new Parent { Id = 77 }; if (useTrackGraph == null) { context.Entry(principal).State = entityState; } - var dependent = new Child - { - Name = "1", - Parent = principal - }; + var dependent = new Child { Name = "1", Parent = principal }; principal.ChildCollection1 = CreateChildCollection(collectionType, dependent); - var subDependent = new SubChild - { - Name = "1S", - Parent = dependent - }; + var subDependent = new SubChild { Name = "1S", Parent = dependent }; dependent.SubChildCollection = CreateChildCollection(collectionType, subDependent); if (useTrackGraph == null) @@ -570,21 +513,23 @@ public void Add_principal_with_dependent_both_navs_collection(EntityState entity } else if (useTrackGraph == true) { - context.ChangeTracker.TrackGraph(principal, e => - { - if (entityState != EntityState.Added) + context.ChangeTracker.TrackGraph( + principal, e => { - if (ReferenceEquals(e.Entry.Entity, dependent)) - { - e.Entry.Property("Id").CurrentValue = 10; - } - else if (ReferenceEquals(e.Entry.Entity, subDependent)) + if (entityState != EntityState.Added) { - e.Entry.Property("Id").CurrentValue = 100; + if (ReferenceEquals(e.Entry.Entity, dependent)) + { + e.Entry.Property("Id").CurrentValue = 10; + } + else if (ReferenceEquals(e.Entry.Entity, subDependent)) + { + e.Entry.Property("Id").CurrentValue = 100; + } } - } - e.Entry.State = entityState; - }); + + e.Entry.State = entityState; + }); } else { @@ -680,29 +625,21 @@ public void Add_principal_with_dependent_both_navs_collection(EntityState entity [InlineData(EntityState.Unchanged, true, CollectionType.ObservableHashSet)] [InlineData(EntityState.Unchanged, false, CollectionType.ObservableHashSet)] [InlineData(EntityState.Unchanged, null, CollectionType.ObservableHashSet)] - public void Add_principal_with_dependent_principal_nav_collection(EntityState entityState, bool? useTrackGraph, CollectionType collectionType) + public void Add_principal_with_dependent_principal_nav_collection( + EntityState entityState, bool? useTrackGraph, CollectionType collectionType) { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; + var principal = new Parent { Id = 77 }; if (useTrackGraph == null) { context.Entry(principal).State = entityState; } - var dependent = new Child - { - Name = "1" - }; + var dependent = new Child { Name = "1" }; principal.ChildCollection1 = CreateChildCollection(collectionType, dependent); - var subDependent = new SubChild - { - Name = "1S" - }; + var subDependent = new SubChild { Name = "1S" }; dependent.SubChildCollection = CreateChildCollection(collectionType, subDependent); if (useTrackGraph == null) @@ -711,21 +648,23 @@ public void Add_principal_with_dependent_principal_nav_collection(EntityState en } else if (useTrackGraph == true) { - context.ChangeTracker.TrackGraph(principal, e => - { - if (entityState != EntityState.Added) + context.ChangeTracker.TrackGraph( + principal, e => { - if (ReferenceEquals(e.Entry.Entity, dependent)) - { - e.Entry.Property("Id").CurrentValue = 10; - } - else if (ReferenceEquals(e.Entry.Entity, subDependent)) + if (entityState != EntityState.Added) { - e.Entry.Property("Id").CurrentValue = 100; + if (ReferenceEquals(e.Entry.Entity, dependent)) + { + e.Entry.Property("Id").CurrentValue = 10; + } + else if (ReferenceEquals(e.Entry.Entity, subDependent)) + { + e.Entry.Property("Id").CurrentValue = 100; + } } - } - e.Entry.State = entityState; - }); + + e.Entry.State = entityState; + }); } else { @@ -771,15 +710,9 @@ public async Task Principal_nav_set_unidirectional_AddAsync() { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; + var principal = new ParentPN { Id = 77 }; - var dependent = new ChildPN - { - Name = "1" - }; + var dependent = new ChildPN { Name = "1" }; principal.Child1 = dependent; await context.AddAsync(principal); @@ -807,37 +740,22 @@ public void Instance_changed_unidirectional(EntityState entityState) { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; + var principal = new ParentPN { Id = 77 }; - var dependent1 = new ChildPN - { - Name = "1" - }; + var dependent1 = new ChildPN { Name = "1" }; principal.Child2 = dependent1; - var subDependent1 = new SubChildPN - { - Name = "1S" - }; + var subDependent1 = new SubChildPN { Name = "1S" }; dependent1.SubChild = subDependent1; context.ChangeTracker.TrackGraph(principal, e => e.Entry.State = entityState); var dependentEntry1 = context.Entry(principal).Reference(p => p.Child2).TargetEntry; - var dependent2 = new ChildPN - { - Name = "2" - }; + var dependent2 = new ChildPN { Name = "2" }; principal.Child2 = dependent2; - var subDependent2 = new SubChildPN - { - Name = "2S" - }; + var subDependent2 = new SubChildPN { Name = "2S" }; dependent2.SubChild = subDependent2; context.ChangeTracker.DetectChanges(); @@ -880,37 +798,22 @@ public void Instance_changed_bidirectional(EntityState entityState) { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; + var principal = new Parent { Id = 77 }; - var dependent1 = new Child - { - Name = "1" - }; + var dependent1 = new Child { Name = "1" }; principal.Child1 = dependent1; - var subDependent1 = new SubChild - { - Name = "1S" - }; + var subDependent1 = new SubChild { Name = "1S" }; dependent1.SubChild = subDependent1; context.ChangeTracker.TrackGraph(principal, e => e.Entry.State = entityState); var dependentEntry1 = context.Entry(principal).Reference(p => p.Child1).TargetEntry; - var dependent2 = new Child - { - Name = "2" - }; + var dependent2 = new Child { Name = "2" }; principal.Child1 = dependent2; - var subDependent2 = new SubChild - { - Name = "2S" - }; + var subDependent2 = new SubChild { Name = "2S" }; dependent2.SubChild = subDependent2; context.ChangeTracker.DetectChanges(); @@ -971,21 +874,12 @@ public void Instance_changed_unidirectional_collection(EntityState entityState, { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; + var principal = new ParentPN { Id = 77 }; - var dependent1 = new ChildPN - { - Name = "1" - }; + var dependent1 = new ChildPN { Name = "1" }; principal.ChildCollection2 = CreateChildCollection(collectionType, dependent1); - var subDependent1 = new SubChildPN - { - Name = "1S" - }; + var subDependent1 = new SubChildPN { Name = "1S" }; dependent1.SubChildCollection = CreateChildCollection(collectionType, subDependent1); switch (entityState) @@ -1004,16 +898,10 @@ public void Instance_changed_unidirectional_collection(EntityState entityState, var dependentEntry1 = context.Entry(dependent1); var subDependentEntry1 = context.Entry(subDependent1); - var dependent2 = new ChildPN - { - Name = "2" - }; + var dependent2 = new ChildPN { Name = "2" }; principal.ChildCollection2 = CreateChildCollection(collectionType, dependent2); - var subDependent2 = new SubChildPN - { - Name = "2S" - }; + var subDependent2 = new SubChildPN { Name = "2S" }; dependent2.SubChildCollection = CreateChildCollection(collectionType, subDependent2); var dependentEntry2 = context.Entry(principal).Collection(p => p.ChildCollection2) @@ -1078,21 +966,12 @@ public void Instance_changed_bidirectional_collection(EntityState entityState, C { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; + var principal = new Parent { Id = 77 }; - var dependent1 = new Child - { - Name = "1" - }; + var dependent1 = new Child { Name = "1" }; principal.ChildCollection1 = CreateChildCollection(collectionType, dependent1); - var subDependent1 = new SubChild - { - Name = "1S" - }; + var subDependent1 = new SubChild { Name = "1S" }; dependent1.SubChildCollection = CreateChildCollection(collectionType, subDependent1); switch (entityState) @@ -1111,16 +990,10 @@ public void Instance_changed_bidirectional_collection(EntityState entityState, C var dependentEntry1 = context.Entry(dependent1); var subDependentEntry1 = context.Entry(subDependent1); - var dependent2 = new Child - { - Name = "2" - }; + var dependent2 = new Child { Name = "2" }; principal.ChildCollection1 = CreateChildCollection(collectionType, dependent2); - var subDependent2 = new SubChild - { - Name = "2S" - }; + var subDependent2 = new SubChild { Name = "2S" }; dependent2.SubChildCollection = CreateChildCollection(collectionType, subDependent2); var dependentEntry2 = context.Entry(principal).Collection(p => p.ChildCollection1) @@ -1172,21 +1045,12 @@ public void Identity_changed_unidirectional(EntityState entityState) { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; + var principal = new ParentPN { Id = 77 }; - var dependent = new ChildPN - { - Name = "1" - }; + var dependent = new ChildPN { Name = "1" }; principal.Child1 = dependent; - var subDependent = new SubChildPN - { - Name = "1S" - }; + var subDependent = new SubChildPN { Name = "1S" }; dependent.SubChild = subDependent; switch (entityState) @@ -1247,21 +1111,12 @@ public void Identity_changed_bidirectional(EntityState entityState) { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; + var principal = new Parent { Id = 77 }; - var dependent = new Child - { - Name = "1" - }; + var dependent = new Child { Name = "1" }; principal.Child2 = dependent; - var subDependent = new SubChild - { - Name = "1S" - }; + var subDependent = new SubChild { Name = "1S" }; dependent.SubChild = subDependent; context.ChangeTracker.TrackGraph(principal, e => e.Entry.State = entityState); @@ -1329,21 +1184,12 @@ public void Identity_changed_unidirectional_collection(EntityState entityState, { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; + var principal = new ParentPN { Id = 77 }; - var dependent = new ChildPN - { - Name = "1" - }; + var dependent = new ChildPN { Name = "1" }; principal.ChildCollection1 = CreateChildCollection(collectionType, dependent); - var subDependent = new SubChildPN - { - Name = "1S" - }; + var subDependent = new SubChildPN { Name = "1S" }; dependent.SubChildCollection = CreateChildCollection(collectionType, subDependent); switch (entityState) @@ -1419,21 +1265,12 @@ public void Identity_changed_bidirectional_collection(EntityState entityState, C { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; + var principal = new Parent { Id = 77 }; - var dependent = new Child - { - Name = "1" - }; + var dependent = new Child { Name = "1" }; principal.ChildCollection2 = CreateChildCollection(collectionType, dependent); - var subDependent = new SubChild - { - Name = "1S" - }; + var subDependent = new SubChild { Name = "1S" }; dependent.SubChildCollection = CreateChildCollection(collectionType, subDependent); switch (entityState) @@ -1497,33 +1334,18 @@ public void Identity_swapped_unidirectional(EntityState entityState) { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; + var principal = new ParentPN { Id = 77 }; - var dependent1 = new ChildPN - { - Name = "1" - }; + var dependent1 = new ChildPN { Name = "1" }; principal.Child1 = dependent1; - var subDependent1 = new SubChildPN - { - Name = "1S" - }; + var subDependent1 = new SubChildPN { Name = "1S" }; dependent1.SubChild = subDependent1; - var dependent2 = new ChildPN - { - Name = "2" - }; + var dependent2 = new ChildPN { Name = "2" }; principal.Child2 = dependent2; - var subDependent2 = new SubChildPN - { - Name = "2S" - }; + var subDependent2 = new SubChildPN { Name = "2S" }; dependent2.SubChild = subDependent2; context.ChangeTracker.TrackGraph(principal, e => e.Entry.State = entityState); @@ -1591,33 +1413,18 @@ public void Identity_swapped_bidirectional(EntityState entityState) { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; + var principal = new Parent { Id = 77 }; - var dependent1 = new Child - { - Name = "1" - }; + var dependent1 = new Child { Name = "1" }; principal.Child1 = dependent1; - var subDependent1 = new SubChild - { - Name = "1S" - }; + var subDependent1 = new SubChild { Name = "1S" }; dependent1.SubChild = subDependent1; - var dependent2 = new Child - { - Name = "2" - }; + var dependent2 = new Child { Name = "2" }; principal.Child2 = dependent2; - var subDependent2 = new SubChild - { - Name = "2S" - }; + var subDependent2 = new SubChild { Name = "2S" }; dependent2.SubChild = subDependent2; context.ChangeTracker.TrackGraph(principal, e => e.Entry.State = entityState); @@ -1704,34 +1511,20 @@ public void Identity_swapped_unidirectional_collection(EntityState entityState, { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; + var principal = new ParentPN { Id = 77 }; - var dependent1 = new ChildPN - { - Name = "1" - }; + var dependent1 = new ChildPN { Name = "1" }; principal.ChildCollection1 = CreateChildCollection(collectionType, dependent1); - var subDependent1 = new SubChildPN - { - Name = "1S" - }; + var subDependent1 = new SubChildPN { Name = "1S" }; dependent1.SubChildCollection = CreateChildCollection(collectionType, subDependent1); - var dependent2 = new ChildPN - { - Name = "2" - }; + var dependent2 = new ChildPN { Name = "2" }; principal.ChildCollection2 = CreateChildCollection(collectionType, dependent2); - var subDependent2 = new SubChildPN - { - Name = "2S" - }; - dependent2.SubChildCollection = CreateChildCollection(collectionType, subDependent2);; + var subDependent2 = new SubChildPN { Name = "2S" }; + dependent2.SubChildCollection = CreateChildCollection(collectionType, subDependent2); + ; switch (entityState) { @@ -1842,33 +1635,18 @@ public void Identity_swapped_bidirectional_collection(EntityState entityState, C { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; + var principal = new Parent { Id = 77 }; - var dependent1 = new Child - { - Name = "1" - }; + var dependent1 = new Child { Name = "1" }; principal.ChildCollection1 = CreateChildCollection(collectionType, dependent1); - var subDependent1 = new SubChild - { - Name = "1S" - }; + var subDependent1 = new SubChild { Name = "1S" }; dependent1.SubChildCollection = CreateChildCollection(collectionType, subDependent1); - var dependent2 = new Child - { - Name = "2" - }; + var dependent2 = new Child { Name = "2" }; principal.ChildCollection2 = CreateChildCollection(collectionType, dependent2); - var subDependent2 = new SubChild - { - Name = "2S" - }; + var subDependent2 = new SubChild { Name = "2S" }; dependent2.SubChildCollection = CreateChildCollection(collectionType, subDependent2); switch (entityState) @@ -1969,26 +1747,14 @@ public void Parent_changed_unidirectional(EntityState entityState) { using (var context = new FixupContext()) { - var principal1 = new ParentPN - { - Id = 77 - }; + var principal1 = new ParentPN { Id = 77 }; - var principal2 = new ParentPN - { - Id = 78 - }; + var principal2 = new ParentPN { Id = 78 }; - var dependent = new ChildPN - { - Name = "1" - }; + var dependent = new ChildPN { Name = "1" }; principal1.Child1 = dependent; - var subDependent = new SubChildPN - { - Name = "1S" - }; + var subDependent = new SubChildPN { Name = "1S" }; dependent.SubChild = subDependent; context.ChangeTracker.TrackGraph(principal1, e => e.Entry.State = entityState); @@ -2054,26 +1820,14 @@ public void Parent_changed_bidirectional(EntityState entityState) { using (var context = new FixupContext()) { - var principal1 = new Parent - { - Id = 77 - }; + var principal1 = new Parent { Id = 77 }; - var principal2 = new Parent - { - Id = 78 - }; + var principal2 = new Parent { Id = 78 }; - var dependent = new Child - { - Name = "1" - }; + var dependent = new Child { Name = "1" }; principal1.Child1 = dependent; - var subDependent = new SubChild - { - Name = "1S" - }; + var subDependent = new SubChild { Name = "1S" }; dependent.SubChild = subDependent; context.ChangeTracker.TrackGraph(principal1, e => e.Entry.State = entityState); @@ -2156,26 +1910,14 @@ public void Parent_changed_unidirectional_collection(EntityState entityState, Co { using (var context = new FixupContext()) { - var principal1 = new ParentPN - { - Id = 77 - }; + var principal1 = new ParentPN { Id = 77 }; - var principal2 = new ParentPN - { - Id = 78 - }; + var principal2 = new ParentPN { Id = 78 }; - var dependent = new ChildPN - { - Name = "1" - }; + var dependent = new ChildPN { Name = "1" }; principal1.ChildCollection1 = CreateChildCollection(collectionType, dependent); - var subDependent = new SubChildPN - { - Name = "1S" - }; + var subDependent = new SubChildPN { Name = "1S" }; dependent.SubChildCollection = CreateChildCollection(collectionType, subDependent); switch (entityState) @@ -2272,26 +2014,14 @@ public void Parent_changed_bidirectional_collection(EntityState entityState, Col { using (var context = new FixupContext()) { - var principal1 = new Parent - { - Id = 77 - }; + var principal1 = new Parent { Id = 77 }; - var principal2 = new Parent - { - Id = 78 - }; + var principal2 = new Parent { Id = 78 }; - var dependent = new Child - { - Name = "1" - }; + var dependent = new Child { Name = "1" }; principal1.ChildCollection1 = CreateChildCollection(collectionType, dependent); - var subDependent = new SubChild - { - Name = "1S" - }; + var subDependent = new SubChild { Name = "1S" }; dependent.SubChildCollection = CreateChildCollection(collectionType, subDependent); switch (entityState) @@ -2376,38 +2106,20 @@ public void Parent_swapped_unidirectional(EntityState entityState) { using (var context = new FixupContext()) { - var principal1 = new ParentPN - { - Id = 77 - }; + var principal1 = new ParentPN { Id = 77 }; - var principal2 = new ParentPN - { - Id = 78 - }; + var principal2 = new ParentPN { Id = 78 }; - var dependent1 = new ChildPN - { - Name = "1" - }; + var dependent1 = new ChildPN { Name = "1" }; principal1.Child1 = dependent1; - var subDependent1 = new SubChildPN - { - Name = "1S" - }; + var subDependent1 = new SubChildPN { Name = "1S" }; dependent1.SubChild = subDependent1; - var dependent2 = new ChildPN - { - Name = "2" - }; + var dependent2 = new ChildPN { Name = "2" }; principal2.Child1 = dependent2; - var subDependent2 = new SubChildPN - { - Name = "2S" - }; + var subDependent2 = new SubChildPN { Name = "2S" }; dependent2.SubChild = subDependent2; context.ChangeTracker.TrackGraph(principal1, e => e.Entry.State = entityState); @@ -2484,38 +2196,20 @@ public void Parent_swapped_bidirectional(EntityState entityState) { using (var context = new FixupContext()) { - var principal1 = new Parent - { - Id = 77 - }; + var principal1 = new Parent { Id = 77 }; - var principal2 = new Parent - { - Id = 78 - }; + var principal2 = new Parent { Id = 78 }; - var dependent1 = new Child - { - Name = "1" - }; + var dependent1 = new Child { Name = "1" }; principal1.Child1 = dependent1; - var subDependent1 = new SubChild - { - Name = "1S" - }; + var subDependent1 = new SubChild { Name = "1S" }; dependent1.SubChild = subDependent1; - var dependent2 = new Child - { - Name = "2" - }; + var dependent2 = new Child { Name = "2" }; principal2.Child1 = dependent2; - var subDependent2 = new SubChild - { - Name = "2S" - }; + var subDependent2 = new SubChild { Name = "2S" }; dependent2.SubChild = subDependent2; context.ChangeTracker.TrackGraph(principal1, e => e.Entry.State = entityState); @@ -2613,38 +2307,20 @@ public void Parent_swapped_unidirectional_collection(EntityState entityState, Co { using (var context = new FixupContext()) { - var principal1 = new ParentPN - { - Id = 77 - }; + var principal1 = new ParentPN { Id = 77 }; - var principal2 = new ParentPN - { - Id = 78 - }; + var principal2 = new ParentPN { Id = 78 }; - var dependent1 = new ChildPN - { - Name = "1" - }; + var dependent1 = new ChildPN { Name = "1" }; principal1.ChildCollection1 = CreateChildCollection(collectionType, dependent1); - var subDependent1 = new SubChildPN - { - Name = "1S" - }; + var subDependent1 = new SubChildPN { Name = "1S" }; dependent1.SubChildCollection = CreateChildCollection(collectionType, subDependent1); - var dependent2 = new ChildPN - { - Name = "2" - }; + var dependent2 = new ChildPN { Name = "2" }; principal2.ChildCollection1 = CreateChildCollection(collectionType, dependent2); - var subDependent2 = new SubChildPN - { - Name = "2S" - }; + var subDependent2 = new SubChildPN { Name = "2S" }; dependent2.SubChildCollection = CreateChildCollection(collectionType, subDependent2); switch (entityState) @@ -2757,38 +2433,20 @@ public void Parent_swapped_bidirectional_collection(EntityState entityState, Col { using (var context = new FixupContext()) { - var principal1 = new Parent - { - Id = 77 - }; + var principal1 = new Parent { Id = 77 }; - var principal2 = new Parent - { - Id = 78 - }; + var principal2 = new Parent { Id = 78 }; - var dependent1 = new Child - { - Name = "1" - }; + var dependent1 = new Child { Name = "1" }; principal1.ChildCollection1 = CreateChildCollection(collectionType, dependent1); - var subDependent1 = new SubChild - { - Name = "1S" - }; + var subDependent1 = new SubChild { Name = "1S" }; dependent1.SubChildCollection = CreateChildCollection(collectionType, subDependent1); - var dependent2 = new Child - { - Name = "2" - }; + var dependent2 = new Child { Name = "2" }; principal2.ChildCollection1 = CreateChildCollection(collectionType, dependent2); - var subDependent2 = new SubChild - { - Name = "2S" - }; + var subDependent2 = new SubChild { Name = "2S" }; dependent2.SubChildCollection = CreateChildCollection(collectionType, subDependent2); switch (entityState) @@ -2892,26 +2550,14 @@ public void Parent_and_identity_changed_unidirectional(EntityState entityState) { using (var context = new FixupContext()) { - var principal1 = new ParentPN - { - Id = 77 - }; + var principal1 = new ParentPN { Id = 77 }; - var principal2 = new ParentPN - { - Id = 78 - }; + var principal2 = new ParentPN { Id = 78 }; - var dependent = new ChildPN - { - Name = "1" - }; + var dependent = new ChildPN { Name = "1" }; principal1.Child2 = dependent; - var subDependent = new SubChildPN - { - Name = "1S" - }; + var subDependent = new SubChildPN { Name = "1S" }; dependent.SubChild = subDependent; context.ChangeTracker.TrackGraph(principal1, e => e.Entry.State = entityState); @@ -2967,26 +2613,14 @@ public void Parent_and_identity_changed_bidirectional(EntityState entityState) { using (var context = new FixupContext()) { - var principal1 = new Parent - { - Id = 77 - }; + var principal1 = new Parent { Id = 77 }; - var principal2 = new Parent - { - Id = 78 - }; + var principal2 = new Parent { Id = 78 }; - var dependent = new Child - { - Name = "1" - }; + var dependent = new Child { Name = "1" }; principal1.Child2 = dependent; - var subDependent = new SubChild - { - Name = "1S" - }; + var subDependent = new SubChild { Name = "1S" }; dependent.SubChild = subDependent; context.ChangeTracker.TrackGraph(principal1, e => e.Entry.State = entityState); @@ -3060,26 +2694,14 @@ public void Parent_and_identity_changed_unidirectional_collection(EntityState en { using (var context = new FixupContext()) { - var principal1 = new ParentPN - { - Id = 77 - }; + var principal1 = new ParentPN { Id = 77 }; - var principal2 = new ParentPN - { - Id = 78 - }; + var principal2 = new ParentPN { Id = 78 }; - var dependent = new ChildPN - { - Name = "1" - }; + var dependent = new ChildPN { Name = "1" }; principal1.ChildCollection2 = CreateChildCollection(collectionType, dependent); - var subDependent = new SubChildPN - { - Name = "1S" - }; + var subDependent = new SubChildPN { Name = "1S" }; dependent.SubChildCollection = CreateChildCollection(collectionType, subDependent); switch (entityState) @@ -3163,26 +2785,15 @@ public void Parent_and_identity_changed_bidirectional_collection(EntityState ent { using (var context = new FixupContext()) { - var principal1 = new Parent - { - Id = 77 - }; + var principal1 = new Parent { Id = 77 }; - var principal2 = new Parent - { - Id = 78 - }; + var principal2 = new Parent { Id = 78 }; - var dependent = new Child - { - Name = "1" - }; - principal1.ChildCollection2 = CreateChildCollection(collectionType, dependent);; + var dependent = new Child { Name = "1" }; + principal1.ChildCollection2 = CreateChildCollection(collectionType, dependent); + ; - var subDependent = new SubChild - { - Name = "1S" - }; + var subDependent = new SubChild { Name = "1S" }; dependent.SubChildCollection = CreateChildCollection(collectionType, subDependent); switch (entityState) @@ -3254,38 +2865,20 @@ public void Parent_and_identity_swapped_unidirectional(EntityState entityState) { using (var context = new FixupContext()) { - var principal1 = new ParentPN - { - Id = 77 - }; + var principal1 = new ParentPN { Id = 77 }; - var principal2 = new ParentPN - { - Id = 78 - }; + var principal2 = new ParentPN { Id = 78 }; - var dependent1 = new ChildPN - { - Name = "1" - }; + var dependent1 = new ChildPN { Name = "1" }; principal1.Child2 = dependent1; - var subDependent1 = new SubChildPN - { - Name = "1S" - }; + var subDependent1 = new SubChildPN { Name = "1S" }; dependent1.SubChild = subDependent1; - var dependent2 = new ChildPN - { - Name = "2" - }; + var dependent2 = new ChildPN { Name = "2" }; principal2.Child1 = dependent2; - var subDependent2 = new SubChildPN - { - Name = "2S" - }; + var subDependent2 = new SubChildPN { Name = "2S" }; dependent2.SubChild = subDependent2; context.ChangeTracker.TrackGraph(principal1, e => e.Entry.State = entityState); @@ -3359,38 +2952,20 @@ public void Parent_and_identity_swapped_bidirectional(EntityState entityState) { using (var context = new FixupContext()) { - var principal1 = new Parent - { - Id = 77 - }; + var principal1 = new Parent { Id = 77 }; - var principal2 = new Parent - { - Id = 78 - }; + var principal2 = new Parent { Id = 78 }; - var dependent1 = new Child - { - Name = "1" - }; + var dependent1 = new Child { Name = "1" }; principal1.Child2 = dependent1; - var subDependent1 = new SubChild - { - Name = "1S" - }; + var subDependent1 = new SubChild { Name = "1S" }; dependent1.SubChild = subDependent1; - var dependent2 = new Child - { - Name = "2" - }; + var dependent2 = new Child { Name = "2" }; principal2.Child1 = dependent2; - var subDependent2 = new SubChild - { - Name = "2S" - }; + var subDependent2 = new SubChild { Name = "2S" }; dependent2.SubChild = subDependent2; context.ChangeTracker.TrackGraph(principal1, e => e.Entry.State = entityState); @@ -3461,6 +3036,7 @@ public void Parent_and_identity_swapped_bidirectional(EntityState entityState) Assert.Same(dependent2, subDependent2.Parent); } } + [ConditionalTheory] [InlineData(EntityState.Added, CollectionType.HashSet)] [InlineData(EntityState.Modified, CollectionType.HashSet)] @@ -3484,38 +3060,20 @@ public void Parent_and_identity_swapped_unidirectional_collection(EntityState en { using (var context = new FixupContext()) { - var principal1 = new ParentPN - { - Id = 77 - }; + var principal1 = new ParentPN { Id = 77 }; - var principal2 = new ParentPN - { - Id = 78 - }; + var principal2 = new ParentPN { Id = 78 }; - var dependent1 = new ChildPN - { - Name = "1" - }; + var dependent1 = new ChildPN { Name = "1" }; principal1.ChildCollection2 = CreateChildCollection(collectionType, dependent1); - var subDependent1 = new SubChildPN - { - Name = "1S" - }; + var subDependent1 = new SubChildPN { Name = "1S" }; dependent1.SubChildCollection = CreateChildCollection(collectionType, subDependent1); - var dependent2 = new ChildPN - { - Name = "2" - }; + var dependent2 = new ChildPN { Name = "2" }; principal2.ChildCollection1 = CreateChildCollection(collectionType, dependent2); - var subDependent2 = new SubChildPN - { - Name = "2S" - }; + var subDependent2 = new SubChildPN { Name = "2S" }; dependent2.SubChildCollection = CreateChildCollection(collectionType, subDependent2); switch (entityState) @@ -3635,38 +3193,21 @@ public void Parent_and_identity_swapped_bidirectional_collection(EntityState ent { using (var context = new FixupContext()) { - var principal1 = new Parent - { - Id = 77 - }; + var principal1 = new Parent { Id = 77 }; - var principal2 = new Parent - { - Id = 78 - }; + var principal2 = new Parent { Id = 78 }; - var dependent1 = new Child - { - Name = "1" - }; - principal1.ChildCollection2 = CreateChildCollection(collectionType, dependent1);; + var dependent1 = new Child { Name = "1" }; + principal1.ChildCollection2 = CreateChildCollection(collectionType, dependent1); + ; - var subDependent1 = new SubChild - { - Name = "1S" - }; + var subDependent1 = new SubChild { Name = "1S" }; dependent1.SubChildCollection = CreateChildCollection(collectionType, subDependent1); - var dependent2 = new Child - { - Name = "2" - }; + var dependent2 = new Child { Name = "2" }; principal2.ChildCollection1 = CreateChildCollection(collectionType, dependent2); - var subDependent2 = new SubChild - { - Name = "2S" - }; + var subDependent2 = new SubChild { Name = "2S" }; dependent2.SubChildCollection = CreateChildCollection(collectionType, subDependent2); switch (entityState) @@ -3776,15 +3317,9 @@ public void Fixup_works_when_changing_state_from_Detached_to_Modified(bool detac { using (var context = new OwnedModifiedContext(Guid.NewGuid().ToString())) { - var details = new ProductDetails - { - Color = "C1", Size = "S1" - }; + var details = new ProductDetails { Color = "C1", Size = "S1" }; - var product = new Product - { - Name = "Product1", Details = details - }; + var product = new Product { Name = "Product1", Details = details }; context.Add(product); context.SaveChanges(); @@ -3809,17 +3344,9 @@ public void Fixup_works_when_changing_state_from_Detached_to_Modified(bool detac Assert.Equal(EntityState.Deleted, context.Entry(details).State); } - var newDetails = new ProductDetails - { - Color = "C2", Size = "S2" - }; + var newDetails = new ProductDetails { Color = "C2", Size = "S2" }; - var newProduct = new Product - { - Id = product.Id, - Name = "Product1NewName", - Details = newDetails - }; + var newProduct = new Product { Id = product.Id, Name = "Product1NewName", Details = newDetails }; context.Update(newProduct); @@ -3891,23 +3418,11 @@ public void Can_save_multiple_deep_owned_entities() { using (var context = new StreetContext(nameof(StreetContext))) { - var address1 = new StreetAddress - { - Street = "1", City = "City" - }; + var address1 = new StreetAddress { Street = "1", City = "City" }; - var address2 = new StreetAddress - { - Street = "2", City = "City" - }; + var address2 = new StreetAddress { Street = "2", City = "City" }; - var distributor = new Distributor - { - ShippingCenters = new List - { - address1, address2 - } - }; + var distributor = new Distributor { ShippingCenters = new List { address1, address2 } }; context.Add(distributor); @@ -3959,12 +3474,13 @@ protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBu protected internal override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.Entity().OwnsMany(rt => rt.ShippingCenters, image => - { - image.WithOwner().HasForeignKey("DistributorId"); - image.Property("Id"); - image.HasKey("DistributorId", "Id"); - }); + modelBuilder.Entity().OwnsMany( + rt => rt.ShippingCenters, image => + { + image.WithOwner().HasForeignKey("DistributorId"); + image.Property("Id"); + image.HasKey("DistributorId", "Id"); + }); } } @@ -3973,17 +3489,9 @@ public void Can_replace_owned_entity_after_deleting() { const long MyBookId = 1234; - var info = new Info - { - Title = "MyBook", - }; + var info = new Info { Title = "MyBook" }; - var book = new Book - { - BookId = MyBookId, - Pages = 99, - EnglishInfo = info - }; + var book = new Book { BookId = MyBookId, Pages = 99, EnglishInfo = info }; using (var context = new BooksContext(nameof(BooksContext))) { @@ -4005,17 +3513,9 @@ public void Can_replace_owned_entity_after_deleting() Assert.Equal(EntityState.Unchanged, context.Entry(book).State); Assert.Equal(EntityState.Unchanged, context.Entry(info).State); - var newInfo = new Info - { - Title = "MyBook Rev 2", - }; + var newInfo = new Info { Title = "MyBook Rev 2" }; - var newBook = new Book - { - BookId = MyBookId, - Pages = 100, - EnglishInfo = newInfo - }; + var newBook = new Book { BookId = MyBookId, Pages = 100, EnglishInfo = newInfo }; context.Remove(book); context.Add(newBook); @@ -4040,7 +3540,8 @@ public void Can_replace_owned_entity_after_deleting() Assert.Same(info, book.EnglishInfo); Assert.Equal("MyBook", book.EnglishInfo.Title); Assert.Same(newInfo, newBook.EnglishInfo); - Assert.Equal("MyBook Rev 2", newBook.EnglishInfo.Title); } + Assert.Equal("MyBook Rev 2", newBook.EnglishInfo.Title); + } } private class Book @@ -4097,26 +3598,15 @@ public void Entities_with_owned_custom_enum_pattern_are_tracked_correctly_if_not { new TestOrderItem { - ProductName = "Test Product 1", - Price = new TestMoney - { - Amount = 99.99, Currency = TestCurrency.EUR - } + ProductName = "Test Product 1", Price = new TestMoney { Amount = 99.99, Currency = TestCurrency.EUR } }, new TestOrderItem { - ProductName = "Test Product 3", - Price = new TestMoney - { - Amount = 8.95, Currency = TestCurrency.USD - } + ProductName = "Test Product 3", Price = new TestMoney { Amount = 8.95, Currency = TestCurrency.USD } } }; - var order = new TestOrder - { - CustomerName = "Test Customer", TestOrderItems = items - }; + var order = new TestOrder { CustomerName = "Test Customer", TestOrderItems = items }; Assert.Equal(2, order.TestOrderItems.Count); Assert.Equal("EUR", order.TestOrderItems.Single(e => e.ProductName == "Test Product 1").Price.Currency.Code); @@ -4175,10 +3665,10 @@ public TestCurrency(int id, string code, int numericCode, string name) NumericCode = numericCode; } - public int Id { get; private set; } - public string Name { get; private set; } - public string Code { get; private set; } - public int NumericCode { get; private set; } + public int Id { get; } + public string Name { get; } + public string Code { get; } + public int NumericCode { get; } } private class TestCurrencyContext : DbContext @@ -4228,42 +3718,23 @@ public void Entities_with_owned_custom_enum_pattern_using_ValueConverter_are_tra { new TestOrderItem { - ProductName = "Test Product 1", - Price = new TestMoney - { - Amount = 99.99, Currency = TestCurrency.EUR - } + ProductName = "Test Product 1", Price = new TestMoney { Amount = 99.99, Currency = TestCurrency.EUR } }, new TestOrderItem { - ProductName = "Test Product 2", - Price = new TestMoney - { - Amount = 10, Currency = TestCurrency.EUR - } + ProductName = "Test Product 2", Price = new TestMoney { Amount = 10, Currency = TestCurrency.EUR } }, new TestOrderItem { - ProductName = "Test Product 3", - Price = new TestMoney - { - Amount = 8.95, Currency = TestCurrency.USD - } + ProductName = "Test Product 3", Price = new TestMoney { Amount = 8.95, Currency = TestCurrency.USD } }, new TestOrderItem { - ProductName = "Test Product 4", - Price = new TestMoney - { - Amount = 2.99, Currency = TestCurrency.USD - } + ProductName = "Test Product 4", Price = new TestMoney { Amount = 2.99, Currency = TestCurrency.USD } } }; - var order = new TestOrder - { - CustomerName = "Test Customer", TestOrderItems = items - }; + var order = new TestOrder { CustomerName = "Test Customer", TestOrderItems = items }; Assert.Equal(4, order.TestOrderItems.Count); Assert.Equal("EUR", order.TestOrderItems.Single(e => e.ProductName == "Test Product 1").Price.Currency.Code); @@ -4310,7 +3781,7 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) oi => oi.Price, ip => { ip.Property(p => p.Amount).IsRequired(); - ip.Property(p => p.Currency).HasConversion( + ip.Property(p => p.Currency).HasConversion( v => v.Code, v => v == "EUR" ? TestCurrency.EUR : v == "USD" ? TestCurrency.USD : null); }).HasKey(oi => oi.Id); @@ -4333,21 +3804,7 @@ EntityState GetEntryState(EquatableEntitiesContext context, string role var user = new User(); user.SetRoles( - new[] - { - new Role - { - Value = "Pascal" - }, - new Role - { - Value = "Smalltalk" - }, - new Role - { - Value = "COBOL" - } - }); + new[] { new Role { Value = "Pascal" }, new Role { Value = "Smalltalk" }, new Role { Value = "COBOL" } }); context.Add(user); context.SaveChanges(); @@ -4365,13 +3822,7 @@ EntityState GetEntryState(EquatableEntitiesContext context, string role Assert.Contains("COBOL", roles); user.SetRoles( - new List - { - new Role - { - Value = "BASIC" - } - }); + new List { new Role { Value = "BASIC" } }); Assert.Equal(5, context.ChangeTracker.Entries().Count()); Assert.Equal(EntityState.Unchanged, GetEntryState(context)); @@ -4402,8 +3853,8 @@ private class User public void SetRoles(IList roles) { - if (_roles.Count == roles.Count && - !_roles.Except(roles).Any()) + if (_roles.Count == roles.Count + && !_roles.Except(roles).Any()) { return; } @@ -4610,19 +4061,21 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) cb.WithOwner(c => c.Parent) .HasForeignKey("ParentId"); - cb.OwnsOne(c => c.SubChild, sb => - { - sb.Property("ParentId"); - sb.WithOwner(c => c.Parent) - .HasForeignKey("ParentId"); - }); - - cb.OwnsMany(c => c.SubChildCollection, sb => - { - sb.Property("ParentId"); - sb.WithOwner(c => c.Parent) - .HasForeignKey("ParentId"); - }); + cb.OwnsOne( + c => c.SubChild, sb => + { + sb.Property("ParentId"); + sb.WithOwner(c => c.Parent) + .HasForeignKey("ParentId"); + }); + + cb.OwnsMany( + c => c.SubChildCollection, sb => + { + sb.Property("ParentId"); + sb.WithOwner(c => c.Parent) + .HasForeignKey("ParentId"); + }); }); pb.OwnsOne( @@ -4632,19 +4085,21 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) cb.WithOwner(c => c.Parent) .HasForeignKey("ParentId"); - cb.OwnsOne(c => c.SubChild, sb => - { - sb.Property("ParentId"); - sb.WithOwner(c => c.Parent) - .HasForeignKey("ParentId"); - }); - - cb.OwnsMany(c => c.SubChildCollection, sb => - { - sb.Property("ParentId"); - sb.WithOwner(c => c.Parent) - .HasForeignKey("ParentId"); - }); + cb.OwnsOne( + c => c.SubChild, sb => + { + sb.Property("ParentId"); + sb.WithOwner(c => c.Parent) + .HasForeignKey("ParentId"); + }); + + cb.OwnsMany( + c => c.SubChildCollection, sb => + { + sb.Property("ParentId"); + sb.WithOwner(c => c.Parent) + .HasForeignKey("ParentId"); + }); }); pb.OwnsMany( @@ -4654,21 +4109,23 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) cb.WithOwner(c => c.Parent) .HasForeignKey("ParentId"); - cb.OwnsOne(c => c.SubChild, sb => - { - sb.Property("ParentId"); - sb.Property("ChildId"); - sb.WithOwner(c => c.Parent) - .HasForeignKey("ParentId", "ChildId"); - }); - - cb.OwnsMany(c => c.SubChildCollection, sb => - { - sb.Property("ParentId"); - sb.Property("ChildId"); - sb.WithOwner(c => c.Parent) - .HasForeignKey("ParentId", "ChildId"); - }); + cb.OwnsOne( + c => c.SubChild, sb => + { + sb.Property("ParentId"); + sb.Property("ChildId"); + sb.WithOwner(c => c.Parent) + .HasForeignKey("ParentId", "ChildId"); + }); + + cb.OwnsMany( + c => c.SubChildCollection, sb => + { + sb.Property("ParentId"); + sb.Property("ChildId"); + sb.WithOwner(c => c.Parent) + .HasForeignKey("ParentId", "ChildId"); + }); }); pb.OwnsMany( @@ -4678,21 +4135,23 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) cb.WithOwner(c => c.Parent) .HasForeignKey("ParentId"); - cb.OwnsOne(c => c.SubChild, sb => - { - sb.Property("ParentId"); - sb.Property("ChildId"); - sb.WithOwner(c => c.Parent) - .HasForeignKey("ParentId", "ChildId"); - }); - - cb.OwnsMany(c => c.SubChildCollection, sb => - { - sb.Property("ParentId"); - sb.Property("ChildId"); - sb.WithOwner(c => c.Parent) - .HasForeignKey("ParentId", "ChildId"); - }); + cb.OwnsOne( + c => c.SubChild, sb => + { + sb.Property("ParentId"); + sb.Property("ChildId"); + sb.WithOwner(c => c.Parent) + .HasForeignKey("ParentId", "ChildId"); + }); + + cb.OwnsMany( + c => c.SubChildCollection, sb => + { + sb.Property("ParentId"); + sb.Property("ChildId"); + sb.WithOwner(c => c.Parent) + .HasForeignKey("ParentId", "ChildId"); + }); }); }); @@ -4706,21 +4165,23 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) { cb.Property("ParentId"); cb.WithOwner() - .HasForeignKey("ParentId"); - - cb.OwnsOne(c => c.SubChild, sb => - { - sb.Property("ParentId"); - sb.WithOwner() - .HasForeignKey("ParentId"); - }); + .HasForeignKey("ParentId"); - cb.OwnsMany(c => c.SubChildCollection, sb => - { - sb.Property("ParentId"); - sb.WithOwner() - .HasForeignKey("ParentId"); - }); + cb.OwnsOne( + c => c.SubChild, sb => + { + sb.Property("ParentId"); + sb.WithOwner() + .HasForeignKey("ParentId"); + }); + + cb.OwnsMany( + c => c.SubChildCollection, sb => + { + sb.Property("ParentId"); + sb.WithOwner() + .HasForeignKey("ParentId"); + }); }); pb.OwnsOne( @@ -4728,21 +4189,23 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) { cb.Property("ParentId"); cb.WithOwner() - .HasForeignKey("ParentId"); - - cb.OwnsOne(c => c.SubChild, sb => - { - sb.Property("ParentId"); - sb.WithOwner() - .HasForeignKey("ParentId"); - }); + .HasForeignKey("ParentId"); - cb.OwnsMany(c => c.SubChildCollection, sb => - { - sb.Property("ParentId"); - sb.WithOwner() - .HasForeignKey("ParentId"); - }); + cb.OwnsOne( + c => c.SubChild, sb => + { + sb.Property("ParentId"); + sb.WithOwner() + .HasForeignKey("ParentId"); + }); + + cb.OwnsMany( + c => c.SubChildCollection, sb => + { + sb.Property("ParentId"); + sb.WithOwner() + .HasForeignKey("ParentId"); + }); }); pb.OwnsMany( @@ -4752,21 +4215,23 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) cb.WithOwner() .HasForeignKey("ParentId"); - cb.OwnsOne(c => c.SubChild, sb => - { - sb.Property("ParentId"); - sb.Property("ChildId"); - sb.WithOwner() - .HasForeignKey("ParentId", "ChildId"); - }); - - cb.OwnsMany(c => c.SubChildCollection, sb => - { - sb.Property("ParentId"); - sb.Property("ChildId"); - sb.WithOwner() - .HasForeignKey("ParentId", "ChildId"); - }); + cb.OwnsOne( + c => c.SubChild, sb => + { + sb.Property("ParentId"); + sb.Property("ChildId"); + sb.WithOwner() + .HasForeignKey("ParentId", "ChildId"); + }); + + cb.OwnsMany( + c => c.SubChildCollection, sb => + { + sb.Property("ParentId"); + sb.Property("ChildId"); + sb.WithOwner() + .HasForeignKey("ParentId", "ChildId"); + }); }); pb.OwnsMany( @@ -4776,21 +4241,23 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) cb.WithOwner() .HasForeignKey("ParentId"); - cb.OwnsOne(c => c.SubChild, sb => - { - sb.Property("ParentId"); - sb.Property("ChildId"); - sb.WithOwner() - .HasForeignKey("ParentId", "ChildId"); - }); - - cb.OwnsMany(c => c.SubChildCollection, sb => - { - sb.Property("ParentId"); - sb.Property("ChildId"); - sb.WithOwner() - .HasForeignKey("ParentId", "ChildId"); - }); + cb.OwnsOne( + c => c.SubChild, sb => + { + sb.Property("ParentId"); + sb.Property("ChildId"); + sb.WithOwner() + .HasForeignKey("ParentId", "ChildId"); + }); + + cb.OwnsMany( + c => c.SubChildCollection, sb => + { + sb.Property("ParentId"); + sb.Property("ChildId"); + sb.WithOwner() + .HasForeignKey("ParentId", "ChildId"); + }); }); }); } @@ -4827,7 +4294,7 @@ private static ICollection CreateChildCollection(CollectionType collection CollectionType.List => (ICollection)new List { dependent }, CollectionType.SortedSet => new SortedSet { dependent }, CollectionType.Collection => new Collection { dependent }, - CollectionType.ObservableCollection=> new ObservableCollection { dependent }, + CollectionType.ObservableCollection => new ObservableCollection { dependent }, CollectionType.ObservableHashSet => new ObservableHashSet(ReferenceEqualityComparer.Instance) { dependent }, _ => new HashSet(ReferenceEqualityComparer.Instance) { dependent } }; diff --git a/test/EFCore.Tests/ChangeTracking/Internal/QueryFixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/QueryFixupTest.cs index 0e4940fc2df..357d0bc3085 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/QueryFixupTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/QueryFixupTest.cs @@ -534,10 +534,7 @@ public void Query_dependent_include_principal_with_existing(EntityState existing using (var context = new QueryFixupContext()) { - var newDependent = new Product - { - CategoryId = 77 - }; + var newDependent = new Product { CategoryId = 77 }; context.Entry(newDependent).State = existingState; var dependent = context.Set().Include(e => e.Category).Single(); @@ -568,10 +565,7 @@ public void Query_principal_include_dependent_with_existing(EntityState existing using (var context = new QueryFixupContext()) { - var newDependent = new Product - { - CategoryId = 77 - }; + var newDependent = new Product { CategoryId = 77 }; context.Entry(newDependent).State = existingState; var principal = context.Set().Include(e => e.Products).Single(); @@ -602,10 +596,7 @@ public void Query_dependent_include_principal_unidirectional_with_existing(Entit using (var context = new QueryFixupContext()) { - var newDependent = new ProductDN - { - CategoryId = 77 - }; + var newDependent = new ProductDN { CategoryId = 77 }; context.Entry(newDependent).State = existingState; var dependent = context.Set().Include(e => e.Category).Single(); @@ -634,10 +625,7 @@ public void Query_principal_include_dependent_unidirectional_with_existing(Entit using (var context = new QueryFixupContext()) { - var newDependent = new ProductPN - { - CategoryId = 77 - }; + var newDependent = new ProductPN { CategoryId = 77 }; context.Entry(newDependent).State = existingState; var principal = context.Set().Include(e => e.Products).Single(); @@ -666,10 +654,7 @@ public void Query_self_ref_with_existing(EntityState existingState) using (var context = new QueryFixupContext()) { - var newDependent = new Widget - { - ParentWidgetId = 77 - }; + var newDependent = new Widget { ParentWidgetId = 77 }; context.Entry(newDependent).State = existingState; var widgets = context.Set().ToList(); @@ -701,10 +686,7 @@ public void Query_dependent_include_principal_self_ref_with_existing(EntityState using (var context = new QueryFixupContext()) { - var newDependent = new Widget - { - ParentWidgetId = 77 - }; + var newDependent = new Widget { ParentWidgetId = 77 }; context.Entry(newDependent).State = existingState; var widgets = context.Set().Include(e => e.ParentWidget).ToList(); @@ -736,10 +718,7 @@ public void Query_principal_include_dependent_self_ref_with_existing(EntityState using (var context = new QueryFixupContext()) { - var newDependent = new Widget - { - ParentWidgetId = 77 - }; + var newDependent = new Widget { ParentWidgetId = 77 }; context.Entry(newDependent).State = existingState; var widgets = context.Set().Include(e => e.ChildWidgets).ToList(); @@ -771,10 +750,7 @@ public void Query_self_ref_prinipal_nav_only_with_existing(EntityState existingS using (var context = new QueryFixupContext()) { - var newDependent = new WidgetPN - { - ParentWidgetId = 77 - }; + var newDependent = new WidgetPN { ParentWidgetId = 77 }; context.Entry(newDependent).State = existingState; var widgets = context.Set().ToList(); @@ -804,10 +780,7 @@ public void Query_self_ref_dependent_nav_only_with_existing(EntityState existing using (var context = new QueryFixupContext()) { - var newDependent = new WidgetDN - { - ParentWidgetId = 77 - }; + var newDependent = new WidgetDN { ParentWidgetId = 77 }; context.Entry(newDependent).State = existingState; var widgets = context.Set().ToList(); @@ -837,10 +810,7 @@ public void Query_dependent_include_principal_self_ref_unidirectional_with_exist using (var context = new QueryFixupContext()) { - var newDependent = new WidgetDN - { - ParentWidgetId = 77 - }; + var newDependent = new WidgetDN { ParentWidgetId = 77 }; context.Entry(newDependent).State = existingState; var widgets = context.Set().Include(e => e.ParentWidget).ToList(); @@ -870,10 +840,7 @@ public void Query_principal_include_dependent_self_ref_unidirectional_with_exist using (var context = new QueryFixupContext()) { - var newDependent = new WidgetPN - { - ParentWidgetId = 77 - }; + var newDependent = new WidgetPN { ParentWidgetId = 77 }; context.Entry(newDependent).State = existingState; var widgets = context.Set().Include(e => e.ChildWidgets).ToList(); @@ -1044,137 +1011,38 @@ private static void Seed() context.Database.EnsureCreated(); context.AddRange( - new Blog - { - Id = 77, - TopPostId = 78 - }, - new Post - { - Id = 78, - BlogId = 77 - }, - new Widget - { - Id = 77 - }, - new Widget - { - Id = 78, - ParentWidgetId = 77 - }, - new WidgetPN - { - Id = 77 - }, - new WidgetPN - { - Id = 78, - ParentWidgetId = 77 - }, - new WidgetDN - { - Id = 77 - }, - new WidgetDN - { - Id = 78, - ParentWidgetId = 77 - }, - new Smidget - { - Id = 77 - }, - new Smidget - { - Id = 78, - ParentSmidgetId = 77 - }, - new SmidgetPN - { - Id = 77 - }, - new SmidgetPN - { - Id = 78, - ParentSmidgetId = 77 - }, - new SmidgetDN - { - Id = 77 - }, - new SmidgetDN - { - Id = 78, - ParentSmidgetId = 77 - }, - new Category - { - Id = 77 - }, - new Product - { - Id = 78, - CategoryId = 77 - }, - new CategoryPN - { - Id = 77 - }, - new ProductPN - { - Id = 78, - CategoryId = 77 - }, - new CategoryDN - { - Id = 77 - }, - new ProductDN - { - Id = 78, - CategoryId = 77 - }, - new Parent - { - Id = 77 - }, - new Child - { - Id = 78, - ParentId = 77 - }, - new ParentPN - { - Id = 77 - }, - new ChildPN - { - Id = 78, - ParentId = 77 - }, - new ParentDN - { - Id = 77 - }, - new ChildDN - { - Id = 78, - ParentId = 77 - }, + new Blog { Id = 77, TopPostId = 78 }, + new Post { Id = 78, BlogId = 77 }, + new Widget { Id = 77 }, + new Widget { Id = 78, ParentWidgetId = 77 }, + new WidgetPN { Id = 77 }, + new WidgetPN { Id = 78, ParentWidgetId = 77 }, + new WidgetDN { Id = 77 }, + new WidgetDN { Id = 78, ParentWidgetId = 77 }, + new Smidget { Id = 77 }, + new Smidget { Id = 78, ParentSmidgetId = 77 }, + new SmidgetPN { Id = 77 }, + new SmidgetPN { Id = 78, ParentSmidgetId = 77 }, + new SmidgetDN { Id = 77 }, + new SmidgetDN { Id = 78, ParentSmidgetId = 77 }, + new Category { Id = 77 }, + new Product { Id = 78, CategoryId = 77 }, + new CategoryPN { Id = 77 }, + new ProductPN { Id = 78, CategoryId = 77 }, + new CategoryDN { Id = 77 }, + new ProductDN { Id = 78, CategoryId = 77 }, + new Parent { Id = 77 }, + new Child { Id = 78, ParentId = 77 }, + new ParentPN { Id = 77 }, + new ChildPN { Id = 78, ParentId = 77 }, + new ParentDN { Id = 77 }, + new ChildDN { Id = 78, ParentId = 77 }, new Order { Id = 77, OrderDetails = new OrderDetails { - BillingAddress = new Address - { - Street = "BillMe" - }, - ShippingAddress = new Address - { - Street = "ShipMe" - } + BillingAddress = new Address { Street = "BillMe" }, ShippingAddress = new Address { Street = "ShipMe" } } }); @@ -1445,12 +1313,12 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) .HasForeignKey("OrderId"); cb.OwnsOne(c => c.BillingAddress) - .WithOwner(c => c.OrderDetails) - .HasForeignKey("OrderDetailsId"); + .WithOwner(c => c.OrderDetails) + .HasForeignKey("OrderDetailsId"); cb.OwnsOne(c => c.ShippingAddress) - .WithOwner(c => c.OrderDetails) - .HasForeignKey("OrderDetailsId"); + .WithOwner(c => c.OrderDetails) + .HasForeignKey("OrderDetailsId"); }); }); } diff --git a/test/EFCore.Tests/ChangeTracking/Internal/ShadowFixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/ShadowFixupTest.cs index c83a27a45eb..856ff5d8374 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/ShadowFixupTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/ShadowFixupTest.cs @@ -107,10 +107,7 @@ private void Add_principal_and_dependent_one_to_many( if (setToDependent) { - var collection = new HashSet - { - dependent - }; + var collection = new HashSet { dependent }; principalEntry.Collection("Products").CurrentValue = collection; } diff --git a/test/EFCore.Tests/ChangeTracking/Internal/ShadowFkFixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/ShadowFkFixupTest.cs index d41ee5951f1..e0b6b134ab4 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/ShadowFkFixupTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/ShadowFkFixupTest.cs @@ -23,15 +23,8 @@ public void Add_dependent_then_principal_one_to_many_FK_set_both_navs_set(Entity { using (var context = new FixupContext()) { - var principal = new Category - { - Id = 77 - }; - var dependent = new Product - { - Id = 78, - Category = principal - }; + var principal = new Category { Id = 77 }; + var dependent = new Product { Id = 78, Category = principal }; principal.Products.Add(dependent); context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -60,15 +53,8 @@ public void Add_dependent_then_principal_one_to_many_FK_not_set_both_navs_set(En { using (var context = new FixupContext()) { - var principal = new Category - { - Id = 77 - }; - var dependent = new Product - { - Id = 78, - Category = principal - }; + var principal = new Category { Id = 77 }; + var dependent = new Product { Id = 78, Category = principal }; principal.Products.Add(dependent); context.Entry(dependent).State = entityState; @@ -95,14 +81,8 @@ public void Add_dependent_then_principal_one_to_many_FK_set_no_navs_set(EntitySt { using (var context = new FixupContext()) { - var principal = new Category - { - Id = 77 - }; - var dependent = new Product - { - Id = 78 - }; + var principal = new Category { Id = 77 }; + var dependent = new Product { Id = 78 }; context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -130,14 +110,8 @@ public void Add_dependent_then_principal_one_to_many_FK_set_principal_nav_set(En { using (var context = new FixupContext()) { - var principal = new Category - { - Id = 77 - }; - var dependent = new Product - { - Id = 78 - }; + var principal = new Category { Id = 77 }; + var dependent = new Product { Id = 78 }; principal.Products.Add(dependent); context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -166,15 +140,8 @@ public void Add_dependent_then_principal_one_to_many_FK_set_dependent_nav_set(En { using (var context = new FixupContext()) { - var principal = new Category - { - Id = 77 - }; - var dependent = new Product - { - Id = 78, - Category = principal - }; + var principal = new Category { Id = 77 }; + var dependent = new Product { Id = 78, Category = principal }; context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -202,14 +169,8 @@ public void Add_dependent_then_principal_one_to_many_FK_not_set_principal_nav_se { using (var context = new FixupContext()) { - var principal = new Category - { - Id = 77 - }; - var dependent = new Product - { - Id = 78 - }; + var principal = new Category { Id = 77 }; + var dependent = new Product { Id = 78 }; principal.Products.Add(dependent); context.Entry(dependent).State = entityState; @@ -236,15 +197,8 @@ public void Add_dependent_then_principal_one_to_many_FK_not_set_dependent_nav_se { using (var context = new FixupContext()) { - var principal = new Category - { - Id = 77 - }; - var dependent = new Product - { - Id = 78, - Category = principal - }; + var principal = new Category { Id = 77 }; + var dependent = new Product { Id = 78, Category = principal }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -270,15 +224,8 @@ public void Add_principal_then_dependent_one_to_many_FK_set_both_navs_set(Entity { using (var context = new FixupContext()) { - var principal = new Category - { - Id = 77 - }; - var dependent = new Product - { - Id = 78, - Category = principal - }; + var principal = new Category { Id = 77 }; + var dependent = new Product { Id = 78, Category = principal }; principal.Products.Add(dependent); context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -307,15 +254,8 @@ public void Add_principal_then_dependent_one_to_many_FK_not_set_both_navs_set(En { using (var context = new FixupContext()) { - var principal = new Category - { - Id = 77 - }; - var dependent = new Product - { - Id = 78, - Category = principal - }; + var principal = new Category { Id = 77 }; + var dependent = new Product { Id = 78, Category = principal }; principal.Products.Add(dependent); context.Entry(principal).State = entityState; @@ -342,14 +282,8 @@ public void Add_principal_then_dependent_one_to_many_FK_set_no_navs_set(EntitySt { using (var context = new FixupContext()) { - var principal = new Category - { - Id = 77 - }; - var dependent = new Product - { - Id = 78 - }; + var principal = new Category { Id = 77 }; + var dependent = new Product { Id = 78 }; context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -377,14 +311,8 @@ public void Add_principal_then_dependent_one_to_many_FK_set_principal_nav_set(En { using (var context = new FixupContext()) { - var principal = new Category - { - Id = 77 - }; - var dependent = new Product - { - Id = 78 - }; + var principal = new Category { Id = 77 }; + var dependent = new Product { Id = 78 }; principal.Products.Add(dependent); context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -413,15 +341,8 @@ public void Add_principal_then_dependent_one_to_many_FK_set_dependent_nav_set(En { using (var context = new FixupContext()) { - var principal = new Category - { - Id = 77 - }; - var dependent = new Product - { - Id = 78, - Category = principal - }; + var principal = new Category { Id = 77 }; + var dependent = new Product { Id = 78, Category = principal }; context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -449,14 +370,8 @@ public void Add_principal_then_dependent_one_to_many_FK_not_set_principal_nav_se { using (var context = new FixupContext()) { - var principal = new Category - { - Id = 77 - }; - var dependent = new Product - { - Id = 78 - }; + var principal = new Category { Id = 77 }; + var dependent = new Product { Id = 78 }; principal.Products.Add(dependent); context.Entry(principal).State = entityState; @@ -483,15 +398,8 @@ public void Add_principal_then_dependent_one_to_many_FK_not_set_dependent_nav_se { using (var context = new FixupContext()) { - var principal = new Category - { - Id = 77 - }; - var dependent = new Product - { - Id = 78, - Category = principal - }; + var principal = new Category { Id = 77 }; + var dependent = new Product { Id = 78, Category = principal }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -517,14 +425,8 @@ public void Add_dependent_then_principal_one_to_many_prin_uni_FK_set_no_navs_set { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id = 77 - }; - var dependent = new ProductPN - { - Id = 78 - }; + var principal = new CategoryPN { Id = 77 }; + var dependent = new ProductPN { Id = 78 }; context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -551,14 +453,8 @@ public void Add_principal_then_dependent_one_to_many_prin_uni_FK_set_no_navs_set { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id = 77 - }; - var dependent = new ProductPN - { - Id = 78 - }; + var principal = new CategoryPN { Id = 77 }; + var dependent = new ProductPN { Id = 78 }; context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -585,14 +481,8 @@ public void Add_dependent_then_principal_one_to_many_prin_uni_FK_set_principal_n { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id = 77 - }; - var dependent = new ProductPN - { - Id = 78 - }; + var principal = new CategoryPN { Id = 77 }; + var dependent = new ProductPN { Id = 78 }; principal.Products.Add(dependent); context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -620,14 +510,8 @@ public void Add_dependent_then_principal_one_to_many_prin_uni_FK_not_set_princip { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id = 77 - }; - var dependent = new ProductPN - { - Id = 78 - }; + var principal = new CategoryPN { Id = 77 }; + var dependent = new ProductPN { Id = 78 }; principal.Products.Add(dependent); context.Entry(dependent).State = entityState; @@ -653,14 +537,8 @@ public void Add_principal_then_dependent_one_to_many_prin_uni_FK_set_principal_n { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id = 77 - }; - var dependent = new ProductPN - { - Id = 78 - }; + var principal = new CategoryPN { Id = 77 }; + var dependent = new ProductPN { Id = 78 }; principal.Products.Add(dependent); context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -688,14 +566,8 @@ public void Add_principal_then_dependent_one_to_many_prin_uni_FK_not_set_princip { using (var context = new FixupContext()) { - var principal = new CategoryPN - { - Id = 77 - }; - var dependent = new ProductPN - { - Id = 78 - }; + var principal = new CategoryPN { Id = 77 }; + var dependent = new ProductPN { Id = 78 }; principal.Products.Add(dependent); context.Entry(principal).State = entityState; @@ -721,14 +593,8 @@ public void Add_dependent_then_principal_one_to_many_dep_uni_FK_set_no_navs_set( { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id = 77 - }; - var dependent = new ProductDN - { - Id = 78 - }; + var principal = new CategoryDN { Id = 77 }; + var dependent = new ProductDN { Id = 78 }; context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -755,15 +621,8 @@ public void Add_dependent_then_principal_one_to_many_dep_uni_FK_set_dependent_na { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id = 77 - }; - var dependent = new ProductDN - { - Id = 78, - Category = principal - }; + var principal = new CategoryDN { Id = 77 }; + var dependent = new ProductDN { Id = 78, Category = principal }; context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -790,15 +649,8 @@ public void Add_dependent_then_principal_one_to_many_dep_uni_FK_not_set_dependen { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id = 77 - }; - var dependent = new ProductDN - { - Id = 78, - Category = principal - }; + var principal = new CategoryDN { Id = 77 }; + var dependent = new ProductDN { Id = 78, Category = principal }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -823,14 +675,8 @@ public void Add_principal_then_dependent_one_to_many_dep_uni_FK_set_no_navs_set( { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id = 77 - }; - var dependent = new ProductDN - { - Id = 78 - }; + var principal = new CategoryDN { Id = 77 }; + var dependent = new ProductDN { Id = 78 }; context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -857,15 +703,8 @@ public void Add_principal_then_dependent_one_to_many_dep_uni_FK_set_dependent_na { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id = 77 - }; - var dependent = new ProductDN - { - Id = 78, - Category = principal - }; + var principal = new CategoryDN { Id = 77 }; + var dependent = new ProductDN { Id = 78, Category = principal }; context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -892,15 +731,8 @@ public void Add_principal_then_dependent_one_to_many_dep_uni_FK_not_set_dependen { using (var context = new FixupContext()) { - var principal = new CategoryDN - { - Id = 77 - }; - var dependent = new ProductDN - { - Id = 78, - Category = principal - }; + var principal = new CategoryDN { Id = 77 }; + var dependent = new ProductDN { Id = 78, Category = principal }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -925,14 +757,8 @@ public void Add_dependent_then_principal_one_to_many_no_navs_FK_set_no_navs_set( { using (var context = new FixupContext()) { - var principal = new CategoryNN - { - Id = 77 - }; - var dependent = new ProductNN - { - Id = 78 - }; + var principal = new CategoryNN { Id = 77 }; + var dependent = new ProductNN { Id = 78 }; context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -958,14 +784,8 @@ public void Add_principal_then_dependent_one_to_many_no_navs_FK_set_no_navs_set( { using (var context = new FixupContext()) { - var principal = new CategoryNN - { - Id = 77 - }; - var dependent = new ProductNN - { - Id = 78 - }; + var principal = new CategoryNN { Id = 77 }; + var dependent = new ProductNN { Id = 78 }; context.Entry(dependent).Property("CategoryId").CurrentValue = principal.Id; @@ -991,15 +811,8 @@ public void Add_dependent_then_principal_one_to_one_FK_set_both_navs_set(EntityS { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; - var dependent = new Child - { - Id = 78, - Parent = principal - }; + var principal = new Parent { Id = 77 }; + var dependent = new Child { Id = 78, Parent = principal }; principal.Child = dependent; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1029,15 +842,8 @@ public void Add_dependent_then_principal_one_to_one_FK_not_set_both_navs_set(Ent { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; - var dependent = new Child - { - Id = 78, - Parent = principal - }; + var principal = new Parent { Id = 77 }; + var dependent = new Child { Id = 78, Parent = principal }; principal.Child = dependent; context.Entry(dependent).State = entityState; @@ -1064,14 +870,8 @@ public void Add_dependent_then_principal_one_to_one_FK_set_no_navs_set(EntitySta { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; - var dependent = new Child - { - Id = 78 - }; + var principal = new Parent { Id = 77 }; + var dependent = new Child { Id = 78 }; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1099,14 +899,8 @@ public void Add_dependent_then_principal_one_to_one_FK_set_principal_nav_set(Ent { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; - var dependent = new Child - { - Id = 78 - }; + var principal = new Parent { Id = 77 }; + var dependent = new Child { Id = 78 }; principal.Child = dependent; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1135,15 +929,8 @@ public void Add_dependent_then_principal_one_to_one_FK_set_dependent_nav_set(Ent { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; - var dependent = new Child - { - Id = 78, - Parent = principal - }; + var principal = new Parent { Id = 77 }; + var dependent = new Child { Id = 78, Parent = principal }; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1171,14 +958,8 @@ public void Add_dependent_then_principal_one_to_one_FK_not_set_principal_nav_set { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; - var dependent = new Child - { - Id = 78 - }; + var principal = new Parent { Id = 77 }; + var dependent = new Child { Id = 78 }; principal.Child = dependent; context.Entry(dependent).State = entityState; @@ -1205,15 +986,8 @@ public void Add_dependent_then_principal_one_to_one_FK_not_set_dependent_nav_set { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; - var dependent = new Child - { - Id = 78, - Parent = principal - }; + var principal = new Parent { Id = 77 }; + var dependent = new Child { Id = 78, Parent = principal }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -1239,15 +1013,8 @@ public void Add_principal_then_dependent_one_to_one_FK_set_both_navs_set(EntityS { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; - var dependent = new Child - { - Id = 78, - Parent = principal - }; + var principal = new Parent { Id = 77 }; + var dependent = new Child { Id = 78, Parent = principal }; principal.Child = dependent; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1276,15 +1043,8 @@ public void Add_principal_then_dependent_one_to_one_FK_not_set_both_navs_set(Ent { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; - var dependent = new Child - { - Id = 78, - Parent = principal - }; + var principal = new Parent { Id = 77 }; + var dependent = new Child { Id = 78, Parent = principal }; principal.Child = dependent; context.Entry(principal).State = entityState; @@ -1311,14 +1071,8 @@ public void Add_principal_then_dependent_one_to_one_FK_set_no_navs_set(EntitySta { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; - var dependent = new Child - { - Id = 78 - }; + var principal = new Parent { Id = 77 }; + var dependent = new Child { Id = 78 }; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1346,14 +1100,8 @@ public void Add_principal_then_dependent_one_to_one_FK_set_principal_nav_set(Ent { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; - var dependent = new Child - { - Id = 78 - }; + var principal = new Parent { Id = 77 }; + var dependent = new Child { Id = 78 }; principal.Child = dependent; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1382,15 +1130,8 @@ public void Add_principal_then_dependent_one_to_one_FK_set_dependent_nav_set(Ent { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; - var dependent = new Child - { - Id = 78, - Parent = principal - }; + var principal = new Parent { Id = 77 }; + var dependent = new Child { Id = 78, Parent = principal }; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1418,14 +1159,8 @@ public void Add_principal_then_dependent_one_to_one_FK_not_set_principal_nav_set { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; - var dependent = new Child - { - Id = 78 - }; + var principal = new Parent { Id = 77 }; + var dependent = new Child { Id = 78 }; principal.Child = dependent; context.Entry(principal).State = entityState; @@ -1452,15 +1187,8 @@ public void Add_principal_then_dependent_one_to_one_FK_not_set_dependent_nav_set { using (var context = new FixupContext()) { - var principal = new Parent - { - Id = 77 - }; - var dependent = new Child - { - Id = 78, - Parent = principal - }; + var principal = new Parent { Id = 77 }; + var dependent = new Child { Id = 78, Parent = principal }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -1486,14 +1214,8 @@ public void Add_dependent_then_principal_one_to_one_prin_uni_FK_set_no_navs_set( { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; - var dependent = new ChildPN - { - Id = 78 - }; + var principal = new ParentPN { Id = 77 }; + var dependent = new ChildPN { Id = 78 }; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1520,14 +1242,8 @@ public void Add_principal_then_dependent_one_to_one_prin_uni_FK_set_no_navs_set( { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; - var dependent = new ChildPN - { - Id = 78 - }; + var principal = new ParentPN { Id = 77 }; + var dependent = new ChildPN { Id = 78 }; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1554,14 +1270,8 @@ public void Add_dependent_then_principal_one_to_one_prin_uni_FK_set_principal_na { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; - var dependent = new ChildPN - { - Id = 78 - }; + var principal = new ParentPN { Id = 77 }; + var dependent = new ChildPN { Id = 78 }; principal.Child = dependent; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1589,14 +1299,8 @@ public void Add_dependent_then_principal_one_to_one_prin_uni_FK_not_set_principa { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; - var dependent = new ChildPN - { - Id = 78 - }; + var principal = new ParentPN { Id = 77 }; + var dependent = new ChildPN { Id = 78 }; principal.Child = dependent; context.Entry(dependent).State = entityState; @@ -1622,14 +1326,8 @@ public void Add_principal_then_dependent_one_to_one_prin_uni_FK_set_principal_na { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; - var dependent = new ChildPN - { - Id = 78 - }; + var principal = new ParentPN { Id = 77 }; + var dependent = new ChildPN { Id = 78 }; principal.Child = dependent; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1657,14 +1355,8 @@ public void Add_principal_then_dependent_one_to_one_prin_uni_FK_not_set_principa { using (var context = new FixupContext()) { - var principal = new ParentPN - { - Id = 77 - }; - var dependent = new ChildPN - { - Id = 78 - }; + var principal = new ParentPN { Id = 77 }; + var dependent = new ChildPN { Id = 78 }; principal.Child = dependent; context.Entry(principal).State = entityState; @@ -1690,14 +1382,8 @@ public void Add_dependent_then_principal_one_to_one_dep_uni_FK_set_no_navs_set(E { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id = 77 - }; - var dependent = new ChildDN - { - Id = 78 - }; + var principal = new ParentDN { Id = 77 }; + var dependent = new ChildDN { Id = 78 }; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1724,15 +1410,8 @@ public void Add_dependent_then_principal_one_to_one_dep_uni_FK_set_dependent_nav { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id = 77 - }; - var dependent = new ChildDN - { - Id = 78, - Parent = principal - }; + var principal = new ParentDN { Id = 77 }; + var dependent = new ChildDN { Id = 78, Parent = principal }; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1759,15 +1438,8 @@ public void Add_dependent_then_principal_one_to_one_dep_uni_FK_not_set_dependent { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id = 77 - }; - var dependent = new ChildDN - { - Id = 78, - Parent = principal - }; + var principal = new ParentDN { Id = 77 }; + var dependent = new ChildDN { Id = 78, Parent = principal }; context.Entry(dependent).State = entityState; context.Entry(principal).State = entityState; @@ -1792,14 +1464,8 @@ public void Add_principal_then_dependent_one_to_one_dep_uni_FK_set_no_navs_set(E { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id = 77 - }; - var dependent = new ChildDN - { - Id = 78 - }; + var principal = new ParentDN { Id = 77 }; + var dependent = new ChildDN { Id = 78 }; context.Entry(principal).State = entityState; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1825,15 +1491,8 @@ public void Add_principal_then_dependent_one_to_one_dep_uni_FK_set_dependent_nav { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id = 77 - }; - var dependent = new ChildDN - { - Id = 78, - Parent = principal - }; + var principal = new ParentDN { Id = 77 }; + var dependent = new ChildDN { Id = 78, Parent = principal }; context.Entry(principal).State = entityState; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1859,15 +1518,8 @@ public void Add_principal_then_dependent_one_to_one_dep_uni_FK_not_set_dependent { using (var context = new FixupContext()) { - var principal = new ParentDN - { - Id = 77 - }; - var dependent = new ChildDN - { - Id = 78, - Parent = principal - }; + var principal = new ParentDN { Id = 77 }; + var dependent = new ChildDN { Id = 78, Parent = principal }; context.Entry(principal).State = entityState; context.Entry(dependent).State = entityState; @@ -1892,14 +1544,8 @@ public void Add_dependent_then_principal_one_to_one_no_navs_FK_set_no_navs_set(E { using (var context = new FixupContext()) { - var principal = new ParentNN - { - Id = 77 - }; - var dependent = new ChildNN - { - Id = 78 - }; + var principal = new ParentNN { Id = 77 }; + var dependent = new ChildNN { Id = 78 }; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; @@ -1925,14 +1571,8 @@ public void Add_principal_then_dependent_one_to_one_no_navs_FK_set_no_navs_set(E { using (var context = new FixupContext()) { - var principal = new ParentNN - { - Id = 77 - }; - var dependent = new ChildNN - { - Id = 78 - }; + var principal = new ParentNN { Id = 77 }; + var dependent = new ChildNN { Id = 78 }; context.Entry(dependent).Property("ParentId").CurrentValue = principal.Id; diff --git a/test/EFCore.Tests/ChangeTracking/Internal/SortableBindingListTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/SortableBindingListTest.cs index dd759d09a80..5f1bacb4826 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/SortableBindingListTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/SortableBindingListTest.cs @@ -144,18 +144,8 @@ public void SortableBindingList_does_not_sort_for_byte_arrays() [ConditionalFact] public void SortableBindingList_can_sort_when_list_contains_derived_objects() { - var list = new List - { - new DerivedListElement(3), - new DerivedListElement(1), - new DerivedListElement(4) - }; - var sortedList = new List - { - new DerivedListElement(1), - new DerivedListElement(3), - new DerivedListElement(4) - }; + var list = new List { new DerivedListElement(3), new DerivedListElement(1), new DerivedListElement(4) }; + var sortedList = new List { new DerivedListElement(1), new DerivedListElement(3), new DerivedListElement(4) }; var bindingList = new SortableBindingList(list); @@ -167,17 +157,10 @@ public void SortableBindingList_can_sort_when_list_contains_derived_objects() [ConditionalFact] public void SortableBindingList_can_sort_when_list_is_of_derived_type() { - var list = new List - { - new DerivedListElement(3), - new DerivedListElement(1), - new DerivedListElement(4) - }; + var list = new List { new DerivedListElement(3), new DerivedListElement(1), new DerivedListElement(4) }; var sortedList = new List { - new DerivedListElement(1), - new DerivedListElement(3), - new DerivedListElement(4) + new DerivedListElement(1), new DerivedListElement(3), new DerivedListElement(4) }; var bindingList = new SortableBindingList(list); diff --git a/test/EFCore.Tests/ChangeTracking/Internal/StateManagerTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/StateManagerTest.cs index 8f386150d69..e7d5bba5f9e 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/StateManagerTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/StateManagerTest.cs @@ -23,11 +23,7 @@ public class StateManagerTest public void Can_get_existing_entry_if_entity_is_already_tracked_otherwise_new_entry() { var stateManager = CreateStateManager(BuildModel()); - var category = new Category - { - Id = 1, - PrincipalId = 777 - }; + var category = new Category { Id = 1, PrincipalId = 777 }; var entry = stateManager.GetOrCreateEntry(category); @@ -45,21 +41,13 @@ public void Identity_conflict_throws_for_primary_key() using (var context = new IdentityConflictContext()) { context.Attach( - new SingleKey - { - Id = 77, - AlternateId = 66 - }); + new SingleKey { Id = 77, AlternateId = 66 }); Assert.Equal( CoreStrings.IdentityConflict("SingleKey", "{'Id'}"), Assert.Throws( () => context.Attach( - new SingleKey - { - Id = 77, - AlternateId = 67 - })).Message); + new SingleKey { Id = 77, AlternateId = 67 })).Message); } } @@ -69,21 +57,13 @@ public void Identity_conflict_throws_for_alternate_key() using (var context = new IdentityConflictContext()) { context.Attach( - new SingleKey - { - Id = 77, - AlternateId = 66 - }); + new SingleKey { Id = 77, AlternateId = 66 }); Assert.Equal( CoreStrings.IdentityConflict("SingleKey", "{'AlternateId'}"), Assert.Throws( () => context.Attach( - new SingleKey - { - Id = 78, - AlternateId = 66 - })).Message); + new SingleKey { Id = 78, AlternateId = 66 })).Message); } } @@ -93,25 +73,13 @@ public void Identity_conflict_throws_for_composite_primary_key() using (var context = new IdentityConflictContext()) { context.Attach( - new CompositeKey - { - Id1 = 77, - Id2 = 78, - AlternateId1 = 66, - AlternateId2 = 67 - }); + new CompositeKey { Id1 = 77, Id2 = 78, AlternateId1 = 66, AlternateId2 = 67 }); Assert.Equal( CoreStrings.IdentityConflict("CompositeKey", "{'Id1', 'Id2'}"), Assert.Throws( () => context.Attach( - new CompositeKey - { - Id1 = 77, - Id2 = 78, - AlternateId1 = 66, - AlternateId2 = 68 - })).Message); + new CompositeKey { Id1 = 77, Id2 = 78, AlternateId1 = 66, AlternateId2 = 68 })).Message); } } @@ -121,25 +89,13 @@ public void Identity_conflict_throws_for_composite_alternate_key() using (var context = new IdentityConflictContext()) { context.Attach( - new CompositeKey - { - Id1 = 77, - Id2 = 78, - AlternateId1 = 66, - AlternateId2 = 67 - }); + new CompositeKey { Id1 = 77, Id2 = 78, AlternateId1 = 66, AlternateId2 = 67 }); Assert.Equal( CoreStrings.IdentityConflict("CompositeKey", "{'AlternateId1', 'AlternateId2'}"), Assert.Throws( () => context.Attach( - new CompositeKey - { - Id1 = 77, - Id2 = 79, - AlternateId1 = 66, - AlternateId2 = 67 - })).Message); + new CompositeKey { Id1 = 77, Id2 = 79, AlternateId1 = 66, AlternateId2 = 67 })).Message); } } @@ -149,21 +105,13 @@ public void Identity_conflict_throws_for_primary_key_values_logged() using (var context = new SensitiveIdentityConflictContext()) { context.Attach( - new SingleKey - { - Id = 77, - AlternateId = 66 - }); + new SingleKey { Id = 77, AlternateId = 66 }); Assert.Equal( CoreStrings.IdentityConflictSensitive("SingleKey", "{Id: 77}"), Assert.Throws( () => context.Attach( - new SingleKey - { - Id = 77, - AlternateId = 67 - })).Message); + new SingleKey { Id = 77, AlternateId = 67 })).Message); } } @@ -173,21 +121,13 @@ public void Identity_conflict_throws_for_alternate_key_values_logged() using (var context = new SensitiveIdentityConflictContext()) { context.Attach( - new SingleKey - { - Id = 77, - AlternateId = 66 - }); + new SingleKey { Id = 77, AlternateId = 66 }); Assert.Equal( CoreStrings.IdentityConflictSensitive("SingleKey", "{AlternateId: 66}"), Assert.Throws( () => context.Attach( - new SingleKey - { - Id = 78, - AlternateId = 66 - })).Message); + new SingleKey { Id = 78, AlternateId = 66 })).Message); } } @@ -197,25 +137,13 @@ public void Identity_conflict_throws_for_composite_primary_key_values_logged() using (var context = new SensitiveIdentityConflictContext()) { context.Attach( - new CompositeKey - { - Id1 = 77, - Id2 = 78, - AlternateId1 = 66, - AlternateId2 = 67 - }); + new CompositeKey { Id1 = 77, Id2 = 78, AlternateId1 = 66, AlternateId2 = 67 }); Assert.Equal( CoreStrings.IdentityConflictSensitive("CompositeKey", "{Id1: 77, Id2: 78}"), Assert.Throws( () => context.Attach( - new CompositeKey - { - Id1 = 77, - Id2 = 78, - AlternateId1 = 66, - AlternateId2 = 68 - })).Message); + new CompositeKey { Id1 = 77, Id2 = 78, AlternateId1 = 66, AlternateId2 = 68 })).Message); } } @@ -225,25 +153,13 @@ public void Identity_conflict_throws_for_composite_alternate_key_values_logged() using (var context = new SensitiveIdentityConflictContext()) { context.Attach( - new CompositeKey - { - Id1 = 77, - Id2 = 78, - AlternateId1 = 66, - AlternateId2 = 67 - }); + new CompositeKey { Id1 = 77, Id2 = 78, AlternateId1 = 66, AlternateId2 = 67 }); Assert.Equal( CoreStrings.IdentityConflictSensitive("CompositeKey", "{AlternateId1: 66, AlternateId2: 67}"), Assert.Throws( () => context.Attach( - new CompositeKey - { - Id1 = 77, - Id2 = 79, - AlternateId1 = 66, - AlternateId2 = 67 - })).Message); + new CompositeKey { Id1 = 77, Id2 = 79, AlternateId1 = 66, AlternateId2 = 67 })).Message); } } @@ -256,11 +172,7 @@ public void Identity_null_throws_for_primary_key() CoreStrings.InvalidKeyValue("SingleKey", "Id"), Assert.Throws( () => context.Attach( - new SingleKey - { - Id = null, - AlternateId = 67 - })).Message); + new SingleKey { Id = null, AlternateId = 67 })).Message); } } @@ -273,11 +185,7 @@ public void Identity_null_throws_for_alternate_key() CoreStrings.InvalidAlternateKeyValue("SingleKey", "AlternateId"), Assert.Throws( () => context.Attach( - new SingleKey - { - Id = 77, - AlternateId = null - })).Message); + new SingleKey { Id = 77, AlternateId = null })).Message); } } @@ -290,13 +198,7 @@ public void Identity_null_throws_for_composite_primary_key() CoreStrings.InvalidKeyValue("CompositeKey", "Id2"), Assert.Throws( () => context.Attach( - new CompositeKey - { - Id1 = 77, - Id2 = null, - AlternateId1 = 66, - AlternateId2 = 68 - })).Message); + new CompositeKey { Id1 = 77, Id2 = null, AlternateId1 = 66, AlternateId2 = 68 })).Message); } } @@ -309,13 +211,7 @@ public void Identity_null_throws_for_composite_alternate_key() CoreStrings.InvalidAlternateKeyValue("CompositeKey", "AlternateId2"), Assert.Throws( () => context.Attach( - new CompositeKey - { - Id1 = 77, - Id2 = 79, - AlternateId1 = 66, - AlternateId2 = null - })).Message); + new CompositeKey { Id1 = 77, Id2 = 79, AlternateId1 = 66, AlternateId2 = null })).Message); } } @@ -350,17 +246,9 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); b.HasAlternateKey( - e => new - { - e.AlternateId1, - e.AlternateId2 - }); + e => new { e.AlternateId1, e.AlternateId2 }); }); } } @@ -387,11 +275,7 @@ public void StartTracking_is_no_op_if_entity_is_already_tracked() var categoryType = model.FindEntityType(typeof(Category)); var stateManager = CreateStateManager(model); - var category = new Category - { - Id = 77, - PrincipalId = 777 - }; + var category = new Category { Id = 77, PrincipalId = 777 }; var valueBuffer = new ValueBuffer(new object[] { 77, "Bjork", 777 }); var entry = stateManager.StartTrackingFromQuery(categoryType, category, valueBuffer); @@ -406,10 +290,7 @@ public void StartTracking_throws_for_invalid_entity_key() var stateManager = CreateStateManager(model); var entry = stateManager.GetOrCreateEntry( - new Dogegory - { - Id = null - }); + new Dogegory { Id = null }); Assert.Equal( CoreStrings.InvalidKeyValue("Dogegory", "Id"), @@ -424,11 +305,7 @@ public void StartTracking_throws_for_invalid_alternate_key() var stateManager = CreateStateManager(model); var entry = stateManager.GetOrCreateEntry( - new Category - { - Id = 77, - PrincipalId = null - }); + new Category { Id = 77, PrincipalId = null }); Assert.Equal( CoreStrings.InvalidAlternateKeyValue("Category", "PrincipalId"), @@ -440,10 +317,7 @@ public void StartTracking_throws_for_invalid_alternate_key() public void Can_get_existing_entry_even_if_state_not_yet_set() { var stateManager = CreateStateManager(BuildModel()); - var category = new Category - { - Id = 1 - }; + var category = new Category { Id = 1 }; var entry = stateManager.GetOrCreateEntry(category); var entry2 = stateManager.GetOrCreateEntry(category); @@ -456,11 +330,7 @@ public void Can_get_existing_entry_even_if_state_not_yet_set() public void Can_stop_tracking_and_then_start_tracking_again() { var stateManager = CreateStateManager(BuildModel()); - var category = new Category - { - Id = 1, - PrincipalId = 777 - }; + var category = new Category { Id = 1, PrincipalId = 777 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Added); @@ -475,11 +345,7 @@ public void Can_stop_tracking_and_then_start_tracking_again() public void Can_stop_tracking_and_then_start_tracking_using_a_new_state_entry() { var stateManager = CreateStateManager(BuildModel()); - var category = new Category - { - Id = 1, - PrincipalId = 777 - }; + var category = new Category { Id = 1, PrincipalId = 777 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Added); @@ -495,11 +361,7 @@ public void Can_stop_tracking_and_then_start_tracking_using_a_new_state_entry() public void StopTracking_releases_reference_to_entry() { var stateManager = CreateStateManager(BuildModel()); - var category = new Category - { - Id = 1, - PrincipalId = 777 - }; + var category = new Category { Id = 1, PrincipalId = 777 }; var entry = stateManager.GetOrCreateEntry(category); entry.SetEntityState(EntityState.Added); @@ -546,15 +408,9 @@ public void Will_get_new_entry_if_another_entity_with_the_same_key_is_already_tr Assert.NotSame( stateManager.GetOrCreateEntry( - new Category - { - Id = 77 - }), + new Category { Id = 77 }), stateManager.GetOrCreateEntry( - new Category - { - Id = 77 - })); + new Category { Id = 77 })); } [ConditionalFact] @@ -567,36 +423,22 @@ public void Can_get_all_entities() stateManager.StartTracking( stateManager.GetOrCreateEntry( - new Category - { - Id = 77, - PrincipalId = 777 - })) + new Category { Id = 77, PrincipalId = 777 })) .SetEntityState(EntityState.Unchanged); stateManager.StartTracking( stateManager.GetOrCreateEntry( - new Category - { - Id = 78, - PrincipalId = 778 - })) + new Category { Id = 78, PrincipalId = 778 })) .SetEntityState(EntityState.Unchanged); stateManager.StartTracking( stateManager.GetOrCreateEntry( - new Product - { - Id = productId1 - })) + new Product { Id = productId1 })) .SetEntityState(EntityState.Unchanged); stateManager.StartTracking( stateManager.GetOrCreateEntry( - new Product - { - Id = productId2 - })) + new Product { Id = productId2 })) .SetEntityState(EntityState.Unchanged); Assert.Equal(4, stateManager.Entries.Count()); @@ -631,7 +473,8 @@ public void NavigationReferenceChanged(InternalEntityEntry entry, INavigation na { } - public void NavigationCollectionChanged(InternalEntityEntry entry, INavigation navigation, IEnumerable added, IEnumerable removed) + public void NavigationCollectionChanged( + InternalEntityEntry entry, INavigation navigation, IEnumerable added, IEnumerable removed) { } @@ -640,7 +483,8 @@ public void TrackedFromQuery(InternalEntityEntry entry) } public void KeyPropertyChanged( - InternalEntityEntry entry, IProperty property, IReadOnlyList containingPrincipalKeys, IReadOnlyList containingForeignKeys, + InternalEntityEntry entry, IProperty property, IReadOnlyList containingPrincipalKeys, + IReadOnlyList containingForeignKeys, object oldValue, object newValue) { } @@ -668,26 +512,11 @@ public void DetectChanges_is_called_for_all_tracked_entities_and_returns_true_if var stateManager = contextServices.GetRequiredService(); var entry1 = stateManager.GetOrCreateEntry( - new Category - { - Id = 77, - Name = "Beverages", - PrincipalId = 777 - }); + new Category { Id = 77, Name = "Beverages", PrincipalId = 777 }); var entry2 = stateManager.GetOrCreateEntry( - new Category - { - Id = 78, - Name = "Foods", - PrincipalId = 778 - }); + new Category { Id = 78, Name = "Foods", PrincipalId = 778 }); var entry3 = stateManager.GetOrCreateEntry( - new Category - { - Id = 79, - Name = "Stuff", - PrincipalId = 779 - }); + new Category { Id = 79, Name = "Stuff", PrincipalId = 779 }); entry1.SetEntityState(EntityState.Unchanged); entry2.SetEntityState(EntityState.Unchanged); @@ -704,7 +533,6 @@ public void DetectChanges_is_called_for_all_tracked_entities_and_returns_true_if Assert.Equal(EntityState.Modified, entry1.EntityState); Assert.Equal(EntityState.Modified, entry2.EntityState); Assert.Equal(EntityState.Modified, entry3.EntityState); - } [ConditionalFact] @@ -716,27 +544,13 @@ public void AcceptAllChanges_processes_all_tracked_entities() var productId2 = new Guid("0edc9136-7eed-463b-9b97-bdb9648ab877"); var entry1 = stateManager.GetOrCreateEntry( - new Category - { - Id = 77, - PrincipalId = 777 - }); + new Category { Id = 77, PrincipalId = 777 }); var entry2 = stateManager.GetOrCreateEntry( - new Category - { - Id = 78, - PrincipalId = 778 - }); + new Category { Id = 78, PrincipalId = 778 }); var entry3 = stateManager.GetOrCreateEntry( - new Product - { - Id = productId1 - }); + new Product { Id = productId1 }); var entry4 = stateManager.GetOrCreateEntry( - new Product - { - Id = productId2 - }); + new Product { Id = productId2 }); entry1.SetEntityState(EntityState.Added); entry2.SetEntityState(EntityState.Modified); @@ -764,67 +578,31 @@ public void Can_get_all_dependent_entries() var categoryEntry1 = stateManager.StartTracking( stateManager.GetOrCreateEntry( - new Category - { - Id = 1, - PrincipalId = 77 - })); + new Category { Id = 1, PrincipalId = 77 })); var categoryEntry2 = stateManager.StartTracking( stateManager.GetOrCreateEntry( - new Category - { - Id = 2, - PrincipalId = 78 - })); + new Category { Id = 2, PrincipalId = 78 })); var categoryEntry3 = stateManager.StartTracking( stateManager.GetOrCreateEntry( - new Category - { - Id = 3, - PrincipalId = 79 - })); + new Category { Id = 3, PrincipalId = 79 })); var categoryEntry4 = stateManager.StartTracking( stateManager.GetOrCreateEntry( - new Category - { - Id = 4, - PrincipalId = 0 - })); + new Category { Id = 4, PrincipalId = 0 })); var productEntry1 = stateManager.StartTracking( stateManager.GetOrCreateEntry( - new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - })); + new Product { Id = Guid.NewGuid(), DependentId = 77 })); var productEntry2 = stateManager.StartTracking( stateManager.GetOrCreateEntry( - new Product - { - Id = Guid.NewGuid(), - DependentId = 77 - })); + new Product { Id = Guid.NewGuid(), DependentId = 77 })); var productEntry3 = stateManager.StartTracking( stateManager.GetOrCreateEntry( - new Product - { - Id = Guid.NewGuid(), - DependentId = 78 - })); + new Product { Id = Guid.NewGuid(), DependentId = 78 })); var productEntry4 = stateManager.StartTracking( stateManager.GetOrCreateEntry( - new Product - { - Id = Guid.NewGuid(), - DependentId = 78 - })); + new Product { Id = Guid.NewGuid(), DependentId = 78 })); stateManager.StartTracking( stateManager.GetOrCreateEntry( - new Product - { - Id = Guid.NewGuid(), - DependentId = null - })); + new Product { Id = Guid.NewGuid(), DependentId = null })); var fk = model.FindEntityType(typeof(Product)).GetForeignKeys().Single(); diff --git a/test/EFCore.Tests/ChangeTracking/MemberEntryTest.cs b/test/EFCore.Tests/ChangeTracking/MemberEntryTest.cs index 5c385ef6a5b..77c534db751 100644 --- a/test/EFCore.Tests/ChangeTracking/MemberEntryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/MemberEntryTest.cs @@ -146,10 +146,7 @@ public void Can_get_and_set_current_value_collection() Assert.Null(collection.CurrentValue); - collection.CurrentValue = new List - { - chunky - }; + collection.CurrentValue = new List { chunky }; Assert.Same(cherry, chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); @@ -171,14 +168,8 @@ public void IsModified_tracks_state_of_FK_property_reference() using (var context = new FreezerContext()) { var cherry = new Cherry(); - var chunky = new Chunky - { - Garcia = cherry - }; - cherry.Monkeys = new List - { - chunky - }; + var chunky = new Chunky { Garcia = cherry }; + cherry.Monkeys = new List { chunky }; context.AttachRange(cherry, chunky); var reference = context.Entry(chunky).Member("Garcia"); @@ -202,19 +193,9 @@ public void IsModified_can_set_fk_to_modified_collection() using (var context = new FreezerContext()) { var cherry = new Cherry(); - var chunky1 = new Chunky - { - Garcia = cherry - }; - var chunky2 = new Chunky - { - Garcia = cherry - }; - cherry.Monkeys = new List - { - chunky1, - chunky2 - }; + var chunky1 = new Chunky { Garcia = cherry }; + var chunky2 = new Chunky { Garcia = cherry }; + cherry.Monkeys = new List { chunky1, chunky2 }; context.AttachRange(cherry, chunky1, chunky2); var collection = context.Entry(cherry).Member("Monkeys"); diff --git a/test/EFCore.Tests/ChangeTracking/NavigationEntryTest.cs b/test/EFCore.Tests/ChangeTracking/NavigationEntryTest.cs index 94b04fb5544..50b0717dcba 100644 --- a/test/EFCore.Tests/ChangeTracking/NavigationEntryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/NavigationEntryTest.cs @@ -103,10 +103,7 @@ public void Can_get_and_set_current_value_collection() Assert.Null(collection.CurrentValue); - collection.CurrentValue = new List - { - chunky - }; + collection.CurrentValue = new List { chunky }; Assert.Same(cherry, chunky.Garcia); Assert.Same(chunky, cherry.Monkeys.Single()); @@ -128,14 +125,8 @@ public void IsModified_tracks_state_of_FK_property_reference() using (var context = new FreezerContext()) { var cherry = new Cherry(); - var chunky = new Chunky - { - Garcia = cherry - }; - cherry.Monkeys = new List - { - chunky - }; + var chunky = new Chunky { Garcia = cherry }; + cherry.Monkeys = new List { chunky }; context.AttachRange(cherry, chunky); var reference = context.Entry(chunky).Navigation("Garcia"); @@ -159,19 +150,9 @@ public void IsModified_can_set_fk_to_modified_collection() using (var context = new FreezerContext()) { var cherry = new Cherry(); - var chunky1 = new Chunky - { - Garcia = cherry - }; - var chunky2 = new Chunky - { - Garcia = cherry - }; - cherry.Monkeys = new List - { - chunky1, - chunky2 - }; + var chunky1 = new Chunky { Garcia = cherry }; + var chunky2 = new Chunky { Garcia = cherry }; + cherry.Monkeys = new List { chunky1, chunky2 }; context.AttachRange(cherry, chunky1, chunky2); var collection = context.Entry(cherry).Navigation("Monkeys"); diff --git a/test/EFCore.Tests/ChangeTracking/ObservableHashSetTest.cs b/test/EFCore.Tests/ChangeTracking/ObservableHashSetTest.cs index dd451004b20..1b9f747e89e 100644 --- a/test/EFCore.Tests/ChangeTracking/ObservableHashSetTest.cs +++ b/test/EFCore.Tests/ChangeTracking/ObservableHashSetTest.cs @@ -174,11 +174,7 @@ public void Can_copy_to_array() [ConditionalFact] public void Can_remove() { - var hashSet = new ObservableHashSet - { - "Palmer", - "Carmack" - }; + var hashSet = new ObservableHashSet { "Palmer", "Carmack" }; var countChanging = 0; var countChanged = 0; var collectionChanged = 0; @@ -229,11 +225,7 @@ public void Not_read_only() [ConditionalFact] public void Can_union_with() { - var hashSet = new ObservableHashSet - { - "Palmer", - "Carmack" - }; + var hashSet = new ObservableHashSet { "Palmer", "Carmack" }; var countChanging = 0; var countChanged = 0; var collectionChanged = 0; @@ -269,13 +261,7 @@ public void Can_union_with() [ConditionalFact] public void Can_intersect_with() { - var hashSet = new ObservableHashSet - { - "Brendan", - "Carmack", - "Nate", - "Palmer" - }; + var hashSet = new ObservableHashSet { "Brendan", "Carmack", "Nate", "Palmer" }; var countChanging = 0; var countChanged = 0; var collectionChanged = 0; @@ -311,13 +297,7 @@ public void Can_intersect_with() [ConditionalFact] public void Can_except_with() { - var hashSet = new ObservableHashSet - { - "Brendan", - "Carmack", - "Nate", - "Palmer" - }; + var hashSet = new ObservableHashSet { "Brendan", "Carmack", "Nate", "Palmer" }; var countChanging = 0; var countChanged = 0; var collectionChanged = 0; @@ -353,13 +333,7 @@ public void Can_except_with() [ConditionalFact] public void Can_symmetrical_except_with() { - var hashSet = new ObservableHashSet - { - "Brendan", - "Carmack", - "Nate", - "Palmer" - }; + var hashSet = new ObservableHashSet { "Brendan", "Carmack", "Nate", "Palmer" }; var countChanging = 0; var countChanged = 0; var collectionChanged = 0; @@ -477,13 +451,7 @@ public void TrimExcess_doesnt_throw() [ConditionalFact] public void Can_remove_with_predicate() { - var hashSet = new ObservableHashSet - { - "Brendan", - "Carmack", - "Nate", - "Palmer" - }; + var hashSet = new ObservableHashSet { "Brendan", "Carmack", "Nate", "Palmer" }; var countChanging = 0; var countChanged = 0; var collectionChanged = 0; diff --git a/test/EFCore.Tests/ChangeTracking/PropertyEntryTest.cs b/test/EFCore.Tests/ChangeTracking/PropertyEntryTest.cs index 306d1f511e8..9d7893da02d 100644 --- a/test/EFCore.Tests/ChangeTracking/PropertyEntryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/PropertyEntryTest.cs @@ -23,11 +23,7 @@ public void Setting_IsModified_should_not_be_dependent_on_other_properties() using (var context = new UserContext()) { id = context.Add( - new User - { - Name = "A", - LongName = "B" - }).Entity.Id; + new User { Name = "A", LongName = "B" }).Entity.Id; context.SaveChanges(); } @@ -35,12 +31,7 @@ public void Setting_IsModified_should_not_be_dependent_on_other_properties() using (var context = new UserContext()) { var user = context.Attach( - new User - { - Id = id, - Name = "NewA", - LongName = "NewB" - }).Entity; + new User { Id = id, Name = "NewA", LongName = "NewB" }).Entity; context.Entry(user).Property(x => x.Name).IsModified = false; context.Entry(user).Property(x => x.LongName).IsModified = true; @@ -68,22 +59,14 @@ public void SetValues_with_IsModified_can_mark_a_set_of_values_as_changed() using (var context = new UserContext()) { id = context.Add( - new User - { - Name = "A", - LongName = "B" - }).Entity.Id; + new User { Name = "A", LongName = "B" }).Entity.Id; context.SaveChanges(); } using (var context = new UserContext()) { - var disconnectedEntity = new User - { - Id = id, - LongName = "NewLongName" - }; + var disconnectedEntity = new User { Id = id, LongName = "NewLongName" }; var trackedEntity = context.Find(id); Assert.Equal("A", trackedEntity.Name); @@ -157,12 +140,7 @@ public void Setting_IsModified_is_not_reset_by_OriginalValues() using (var context = new UserContext()) { id = context.Add( - new User - { - Id = Guid.NewGuid(), - Name = "A", - LongName = "B" - }).Entity.Id; + new User { Id = Guid.NewGuid(), Name = "A", LongName = "B" }).Entity.Id; context.SaveChanges(); } @@ -170,10 +148,7 @@ public void Setting_IsModified_is_not_reset_by_OriginalValues() using (var context = new UserContext()) { var user = context.Update( - new User - { - Id = id - }).Entity; + new User { Id = id }).Entity; user.Name = "A2"; user.LongName = "B2"; @@ -201,18 +176,14 @@ public void Can_get_name() public void Can_get_name_with_object_field() => Can_get_name(); - private void Can_get_name() where TWotty : IWotty, new() + private void Can_get_name() + where TWotty : IWotty, new() { using (var context = new PrimateContext()) { var entry = context .Entry( - new TWotty - { - Id = 1, - Primate = "Monkey", - RequiredPrimate = "Tarsier" - }) + new TWotty { Id = 1, Primate = "Monkey", RequiredPrimate = "Tarsier" }) .GetInfrastructure(); entry.SetEntityState(EntityState.Unchanged); @@ -229,18 +200,14 @@ public void Can_get_current_value() public void Can_get_current_value_with_object_field() => Can_get_current_value(); - private void Can_get_current_value() where TWotty : IWotty, new() + private void Can_get_current_value() + where TWotty : IWotty, new() { using (var context = new PrimateContext()) { var entry = context .Entry( - new TWotty - { - Id = 1, - Primate = "Monkey", - RequiredPrimate = "Tarsier" - }) + new TWotty { Id = 1, Primate = "Monkey", RequiredPrimate = "Tarsier" }) .GetInfrastructure(); entry.SetEntityState(EntityState.Unchanged); @@ -258,16 +225,12 @@ public void Can_set_current_value() public void Can_set_current_value_with_object_field() => Can_set_current_value(); - private void Can_set_current_value() where TWotty : IWotty, new() + private void Can_set_current_value() + where TWotty : IWotty, new() { using (var context = new PrimateContext()) { - var entity = new TWotty - { - Id = 1, - Primate = "Monkey", - RequiredPrimate = "Tarsier" - }; + var entity = new TWotty { Id = 1, Primate = "Monkey", RequiredPrimate = "Tarsier" }; var entry = context.Entry(entity).GetInfrastructure(); entry.SetEntityState(EntityState.Unchanged); @@ -292,16 +255,12 @@ public void Can_set_current_value_to_null() public void Can_set_current_value_to_null_with_object_field() => Can_set_current_value_to_null(); - private void Can_set_current_value_to_null() where TWotty : IWotty, new() + private void Can_set_current_value_to_null() + where TWotty : IWotty, new() { using (var context = new PrimateContext()) { - var entity = new TWotty - { - Id = 1, - Primate = "Monkey", - RequiredPrimate = "Tarsier" - }; + var entity = new TWotty { Id = 1, Primate = "Monkey", RequiredPrimate = "Tarsier" }; var entry = context.Entry(entity).GetInfrastructure(); entry.SetEntityState(EntityState.Unchanged); @@ -326,16 +285,12 @@ public void Can_set_and_get_original_value() public void Can_set_and_get_original_value_with_object_field() => Can_set_and_get_original_value(); - private void Can_set_and_get_original_value() where TWotty : IWotty, new() + private void Can_set_and_get_original_value() + where TWotty : IWotty, new() { using (var context = new PrimateContext()) { - var entity = new TWotty - { - Id = 1, - Primate = "Monkey", - RequiredPrimate = "Tarsier" - }; + var entity = new TWotty { Id = 1, Primate = "Monkey", RequiredPrimate = "Tarsier" }; var entry = context.Entry(entity).GetInfrastructure(); entry.SetEntityState(EntityState.Unchanged); @@ -369,14 +324,12 @@ public void Can_set_and_get_original_value_starting_null() public void Can_set_and_get_original_value_starting_null_with_object_field() => Can_set_and_get_original_value_starting_null(); - private void Can_set_and_get_original_value_starting_null() where TWotty : IWotty, new() + private void Can_set_and_get_original_value_starting_null() + where TWotty : IWotty, new() { using (var context = new PrimateContext()) { - var entity = new TWotty - { - Id = 1 - }; + var entity = new TWotty { Id = 1 }; var entry = context.Entry(entity).GetInfrastructure(); entry.SetEntityState(EntityState.Unchanged); @@ -410,16 +363,12 @@ public void Can_set_original_value_to_null() public void Can_set_original_value_to_null_with_object_field() => Can_set_original_value_to_null(); - private void Can_set_original_value_to_null() where TWotty : IWotty, new() + private void Can_set_original_value_to_null() + where TWotty : IWotty, new() { using (var context = new PrimateContext()) { - var entity = new TWotty - { - Id = 1, - Primate = "Monkey", - RequiredPrimate = "Tarsier" - }; + var entity = new TWotty { Id = 1, Primate = "Monkey", RequiredPrimate = "Tarsier" }; var entry = context.Entry(entity).GetInfrastructure(); entry.SetEntityState(EntityState.Unchanged); @@ -444,14 +393,12 @@ public void Can_set_and_clear_modified_on_Modified_entity() public void Can_set_and_clear_modified_on_Modified_entity_with_object_field() => Can_set_and_clear_modified_on_Modified_entity(); - private void Can_set_and_clear_modified_on_Modified_entity() where TWotty : IWotty, new() + private void Can_set_and_clear_modified_on_Modified_entity() + where TWotty : IWotty, new() { using (var context = new PrimateContext()) { - var entity = new TWotty - { - Id = 1 - }; + var entity = new TWotty { Id = 1 }; var entry = context.Entry(entity).GetInfrastructure(); entry.SetEntityState(EntityState.Modified); @@ -499,14 +446,12 @@ public void Can_set_and_clear_modified_on_Added_or_Deleted_entity(EntityState in public void Can_set_and_clear_modified_on_Added_or_Deleted_entity_with_object_field(EntityState initialState) => Can_set_and_clear_modified_on_Added_or_Deleted_entity(initialState); - private void Can_set_and_clear_modified_on_Added_or_Deleted_entity(EntityState initialState) where TWotty : IWotty, new() + private void Can_set_and_clear_modified_on_Added_or_Deleted_entity(EntityState initialState) + where TWotty : IWotty, new() { using (var context = new PrimateContext()) { - var entity = new TWotty - { - Id = 1 - }; + var entity = new TWotty { Id = 1 }; var entry = context.Entry(entity).GetInfrastructure(); entry.SetEntityState(initialState); @@ -545,14 +490,12 @@ public void Can_set_and_clear_modified_on_Unchanged_or_Detached_entity(EntitySta public void Can_set_and_clear_modified_on_Unchanged_or_Detached_entity_with_object_field(EntityState initialState) => Can_set_and_clear_modified_on_Unchanged_or_Detached_entity(initialState); - private void Can_set_and_clear_modified_on_Unchanged_or_Detached_entity(EntityState initialState) where TWotty : IWotty, new() + private void Can_set_and_clear_modified_on_Unchanged_or_Detached_entity(EntityState initialState) + where TWotty : IWotty, new() { using (var context = new PrimateContext()) { - var entity = new TWotty - { - Id = 1 - }; + var entity = new TWotty { Id = 1 }; var entry = context.Entry(entity).GetInfrastructure(); entry.SetEntityState(initialState); @@ -587,37 +530,20 @@ public void Can_reject_changes_when_clearing_modified_flag() public void Can_reject_changes_when_clearing_modified_flag_with_object_field() => Can_reject_changes_when_clearing_modified_flag(); - private void Can_reject_changes_when_clearing_modified_flag() where TWotty : IWotty, new() + private void Can_reject_changes_when_clearing_modified_flag() + where TWotty : IWotty, new() { using (var context = new PrimateContext()) { - var entity = new TWotty - { - Id = 1, - Primate = "Monkey", - Marmate = "Bovril", - RequiredPrimate = "Tarsier" - }; + var entity = new TWotty { Id = 1, Primate = "Monkey", Marmate = "Bovril", RequiredPrimate = "Tarsier" }; var entry = context.Entry(entity).GetInfrastructure(); entry.SetEntityState(EntityState.Unchanged); - var primateEntry = new PropertyEntry(entry, "Primate") - { - OriginalValue = "Chimp", - IsModified = true - }; + var primateEntry = new PropertyEntry(entry, "Primate") { OriginalValue = "Chimp", IsModified = true }; - var marmateEntry = new PropertyEntry(entry, "Marmate") - { - OriginalValue = "Marmite", - IsModified = true - }; + var marmateEntry = new PropertyEntry(entry, "Marmate") { OriginalValue = "Marmite", IsModified = true }; - var requiredEntry = new PropertyEntry(entry, "RequiredPrimate") - { - OriginalValue = "Bushbaby", - IsModified = true - }; + var requiredEntry = new PropertyEntry(entry, "RequiredPrimate") { OriginalValue = "Bushbaby", IsModified = true }; Assert.Equal(EntityState.Modified, entry.EntityState); Assert.Equal("Monkey", entity.Primate); @@ -679,16 +605,13 @@ public void Can_get_name_generic() public void Can_get_name_generic_with_object_field() => Can_get_name_generic(); - private void Can_get_name_generic() where TWotty : class, IWotty, new() + private void Can_get_name_generic() + where TWotty : class, IWotty, new() { var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), EntityState.Unchanged, - new TWotty - { - Id = 1, - Primate = "Monkey" - }); + new TWotty { Id = 1, Primate = "Monkey" }); Assert.Equal("Primate", new PropertyEntry(entry, "Primate").Metadata.Name); } @@ -701,16 +624,13 @@ public void Can_get_current_value_generic() public void Can_get_current_value_generic_with_object_field() => Can_get_current_value_generic(); - private void Can_get_current_value_generic() where TWotty : class, IWotty, new() + private void Can_get_current_value_generic() + where TWotty : class, IWotty, new() { var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), EntityState.Unchanged, - new TWotty - { - Id = 1, - Primate = "Monkey" - }); + new TWotty { Id = 1, Primate = "Monkey" }); Assert.Equal("Monkey", new PropertyEntry(entry, "Primate").CurrentValue); } @@ -723,13 +643,10 @@ public void Can_set_current_value_generic() public void Can_set_current_value_generic_with_object_field() => Can_set_current_value_generic(); - private void Can_set_current_value_generic() where TWotty : class, IWotty, new() + private void Can_set_current_value_generic() + where TWotty : class, IWotty, new() { - var entity = new TWotty - { - Id = 1, - Primate = "Monkey" - }; + var entity = new TWotty { Id = 1, Primate = "Monkey" }; var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), @@ -749,13 +666,10 @@ public void Can_set_current_value_to_null_generic() public void Can_set_current_value_to_null_generic_with_object_field() => Can_set_current_value_to_null_generic(); - private void Can_set_current_value_to_null_generic() where TWotty : class, IWotty, new() + private void Can_set_current_value_to_null_generic() + where TWotty : class, IWotty, new() { - var entity = new TWotty - { - Id = 1, - Primate = "Monkey" - }; + var entity = new TWotty { Id = 1, Primate = "Monkey" }; var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), @@ -775,13 +689,10 @@ public void Can_set_and_get_original_value_generic() public void Can_set_and_get_original_value_generic_with_object_field() => Can_set_and_get_original_value_generic(); - private void Can_set_and_get_original_value_generic() where TWotty : class, IWotty, new() + private void Can_set_and_get_original_value_generic() + where TWotty : class, IWotty, new() { - var entity = new TWotty - { - Id = 1, - Primate = "Monkey" - }; + var entity = new TWotty { Id = 1, Primate = "Monkey" }; var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), @@ -804,16 +715,13 @@ public void Can_set_original_value_to_null_generic() public void Can_set_original_value_to_null_generic_with_object_field() => Can_set_original_value_to_null_generic(); - private void Can_set_original_value_to_null_generic() where TWotty : class, IWotty, new() + private void Can_set_original_value_to_null_generic() + where TWotty : class, IWotty, new() { var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), EntityState.Unchanged, - new TWotty - { - Id = 1, - Primate = "Monkey" - }); + new TWotty { Id = 1, Primate = "Monkey" }); new PropertyEntry(entry, "Primate").OriginalValue = null; @@ -828,13 +736,10 @@ public void Can_set_and_clear_modified_generic() public void Can_set_and_clear_modified_generic_with_object_field() => Can_set_and_clear_modified_generic(); - private void Can_set_and_clear_modified_generic() where TWotty : class, IWotty, new() + private void Can_set_and_clear_modified_generic() + where TWotty : class, IWotty, new() { - var entity = new TWotty - { - Id = 1, - Primate = "Monkey" - }; + var entity = new TWotty { Id = 1, Primate = "Monkey" }; var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), @@ -855,11 +760,7 @@ public void Can_set_and_clear_modified_generic_with_object_field() [ConditionalFact] public void Can_set_and_get_original_value_notifying_entities() { - var entity = new NotifyingWotty - { - Id = 1, - Primate = "Monkey" - }; + var entity = new NotifyingWotty { Id = 1, Primate = "Monkey" }; var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), @@ -880,11 +781,7 @@ public void Can_set_original_value_to_null_notifying_entities() var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), EntityState.Unchanged, - new NotifyingWotty - { - Id = 1, - Primate = "Monkey" - }); + new NotifyingWotty { Id = 1, Primate = "Monkey" }); new PropertyEntry(entry, "Primate").OriginalValue = null; @@ -894,11 +791,7 @@ public void Can_set_original_value_to_null_notifying_entities() [ConditionalFact] public void Can_set_and_get_original_value_generic_notifying_entities() { - var entity = new NotifyingWotty - { - Id = 1, - Primate = "Monkey" - }; + var entity = new NotifyingWotty { Id = 1, Primate = "Monkey" }; var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), @@ -919,11 +812,7 @@ public void Can_set_original_value_to_null_generic_notifying_entities() var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), EntityState.Unchanged, - new NotifyingWotty - { - Id = 1, - Primate = "Monkey" - }); + new NotifyingWotty { Id = 1, Primate = "Monkey" }); new PropertyEntry(entry, "Primate").OriginalValue = null; @@ -933,11 +822,7 @@ public void Can_set_original_value_to_null_generic_notifying_entities() [ConditionalFact] public void Can_set_and_get_concurrency_token_original_value_full_notification_entities() { - var entity = new FullyNotifyingWotty - { - Id = 1, - ConcurrentPrimate = "Monkey" - }; + var entity = new FullyNotifyingWotty { Id = 1, ConcurrentPrimate = "Monkey" }; var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), @@ -958,11 +843,7 @@ public void Can_set_concurrency_token_original_value_to_null_full_notification_e var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), EntityState.Unchanged, - new FullyNotifyingWotty - { - Id = 1, - ConcurrentPrimate = "Monkey" - }); + new FullyNotifyingWotty { Id = 1, ConcurrentPrimate = "Monkey" }); new PropertyEntry(entry, "ConcurrentPrimate").OriginalValue = null; @@ -972,11 +853,7 @@ public void Can_set_concurrency_token_original_value_to_null_full_notification_e [ConditionalFact] public void Can_set_and_get_concurrency_token_original_value_generic_full_notification_entities() { - var entity = new FullyNotifyingWotty - { - Id = 1, - ConcurrentPrimate = "Monkey" - }; + var entity = new FullyNotifyingWotty { Id = 1, ConcurrentPrimate = "Monkey" }; var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), @@ -997,11 +874,7 @@ public void Can_set_concurrency_token_original_value_to_null_generic_full_notifi var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), EntityState.Unchanged, - new FullyNotifyingWotty - { - Id = 1, - ConcurrentPrimate = "Monkey" - }); + new FullyNotifyingWotty { Id = 1, ConcurrentPrimate = "Monkey" }); new PropertyEntry(entry, "ConcurrentPrimate").OriginalValue = null; @@ -1011,11 +884,7 @@ public void Can_set_concurrency_token_original_value_to_null_generic_full_notifi [ConditionalFact] public void Cannot_set_or_get_original_value_when_not_tracked() { - var entity = new FullyNotifyingWotty - { - Id = 1, - Primate = "Monkey" - }; + var entity = new FullyNotifyingWotty { Id = 1, Primate = "Monkey" }; var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), @@ -1036,11 +905,7 @@ public void Cannot_set_or_get_original_value_when_not_tracked() [ConditionalFact] public void Cannot_set_or_get_original_value_when_not_tracked_generic() { - var entity = new FullyNotifyingWotty - { - Id = 1, - ConcurrentPrimate = "Monkey" - }; + var entity = new FullyNotifyingWotty { Id = 1, ConcurrentPrimate = "Monkey" }; var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(), @@ -1061,11 +926,7 @@ public void Cannot_set_or_get_original_value_when_not_tracked_generic() [ConditionalFact] public void Can_set_or_get_original_value_when_property_explicitly_marked_to_be_tracked() { - var entity = new FullyNotifyingWotty - { - Id = 1, - Primate = "Monkey" - }; + var entity = new FullyNotifyingWotty { Id = 1, Primate = "Monkey" }; var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(ChangeTrackingStrategy.ChangingAndChangedNotificationsWithOriginalValues), @@ -1083,11 +944,7 @@ public void Can_set_or_get_original_value_when_property_explicitly_marked_to_be_ [ConditionalFact] public void Can_set_or_get_original_value_when_property_explicitly_marked_to_be_tracked_generic() { - var entity = new FullyNotifyingWotty - { - Id = 1, - Primate = "Monkey" - }; + var entity = new FullyNotifyingWotty { Id = 1, Primate = "Monkey" }; var entry = InMemoryTestHelpers.Instance.CreateInternalEntry( BuildModel(ChangeTrackingStrategy.ChangingAndChangedNotificationsWithOriginalValues), diff --git a/test/EFCore.Tests/ChangeTracking/ReferenceEntryTest.cs b/test/EFCore.Tests/ChangeTracking/ReferenceEntryTest.cs index 50b435cddf1..6de6b8a6219 100644 --- a/test/EFCore.Tests/ChangeTracking/ReferenceEntryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/ReferenceEntryTest.cs @@ -332,14 +332,8 @@ public void IsModified_tracks_state_of_FK_property() using (var context = new FreezerContext()) { var cherry = new Cherry(); - var chunky = new Chunky - { - Garcia = cherry - }; - cherry.Monkeys = new List - { - chunky - }; + var chunky = new Chunky { Garcia = cherry }; + cherry.Monkeys = new List { chunky }; context.AttachRange(cherry, chunky); var reference = context.Entry(chunky).Reference(e => e.Garcia); @@ -363,14 +357,8 @@ public void IsModified_can_set_fk_to_modified() using (var context = new FreezerContext()) { var cherry = new Cherry(); - var chunky = new Chunky - { - Garcia = cherry - }; - cherry.Monkeys = new List - { - chunky - }; + var chunky = new Chunky { Garcia = cherry }; + cherry.Monkeys = new List { chunky }; context.AttachRange(cherry, chunky); var entityEntry = context.Entry(chunky); @@ -397,10 +385,7 @@ public void IsModified_tracks_state_of_FK_property_principal() using (var context = new FreezerContext()) { var half = new Half(); - var chunky = new Chunky - { - Baked = half - }; + var chunky = new Chunky { Baked = half }; half.Monkey = chunky; context.AttachRange(chunky, half); @@ -435,11 +420,7 @@ public void IsModified_can_set_fk_to_modified_principal_with_Added_or_Deleted_de using (var context = new FreezerContext()) { var half = new Half(); - var chunky = new Chunky - { - Id = 1, - Baked = half - }; + var chunky = new Chunky { Id = 1, Baked = half }; half.Monkey = chunky; context.Entry(chunky).State = principalState; @@ -474,11 +455,7 @@ public void IsModified_can_set_fk_to_modified_principal_with_Unchanged_dependent using (var context = new FreezerContext()) { var half = new Half(); - var chunky = new Chunky - { - Id = 1, - Baked = half - }; + var chunky = new Chunky { Id = 1, Baked = half }; half.Monkey = chunky; context.Entry(chunky).State = principalState; @@ -513,11 +490,7 @@ public void IsModified_can_set_fk_to_modified_principal_with_Modified_dependent( using (var context = new FreezerContext()) { var half = new Half(); - var chunky = new Chunky - { - Id = 1, - Baked = half - }; + var chunky = new Chunky { Id = 1, Baked = half }; half.Monkey = chunky; context.Entry(chunky).State = principalState; diff --git a/test/EFCore.Tests/DbContextOptionsTest.cs b/test/EFCore.Tests/DbContextOptionsTest.cs index d64e15e93e6..a13fb56d979 100644 --- a/test/EFCore.Tests/DbContextOptionsTest.cs +++ b/test/EFCore.Tests/DbContextOptionsTest.cs @@ -75,14 +75,8 @@ public void Can_update_an_existing_extension() { var optionsBuilder = new DbContextOptionsBuilder(); - var extension1 = new FakeDbContextOptionsExtension1 - { - Something = "One " - }; - var extension2 = new FakeDbContextOptionsExtension1 - { - Something = "Two " - }; + var extension1 = new FakeDbContextOptionsExtension1 { Something = "One " }; + var extension2 = new FakeDbContextOptionsExtension1 { Something = "Two " }; ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension1); ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension2); diff --git a/test/EFCore.Tests/DbContextServicesTest.cs b/test/EFCore.Tests/DbContextServicesTest.cs index 34ed107ce9e..0cd36bff436 100644 --- a/test/EFCore.Tests/DbContextServicesTest.cs +++ b/test/EFCore.Tests/DbContextServicesTest.cs @@ -966,7 +966,7 @@ public void Can_use_non_derived_context_with_options_and_external_services() InMemoryFixture.BuildServiceProvider( new ServiceCollection() .AddSingleton(loggerFactory) - .AddSingleton(memoryCache))) + .AddSingleton(memoryCache))) .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; @@ -1401,9 +1401,10 @@ public void Can_add_derived_context_one_service_provider_with_options_and_extern public void Can_add_derived_context_with_options_no_OnConfiguring() { var appServiceProvider = new ServiceCollection() - .AddDbContext(b => - b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(Guid.NewGuid().ToString())) + .AddDbContext( + b => + b.EnableServiceProviderCaching(false) + .UseInMemoryDatabase(Guid.NewGuid().ToString())) .BuildServiceProvider(); var singleton = new object[3]; @@ -1437,9 +1438,10 @@ public void Can_add_derived_context_with_options_no_OnConfiguring() public void Can_add_derived_context_with_options_and_external_services_no_OnConfiguring() { var appServiceProvider = new ServiceCollection() - .AddDbContext(b => - b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(Guid.NewGuid().ToString())) + .AddDbContext( + b => + b.EnableServiceProviderCaching(false) + .UseInMemoryDatabase(Guid.NewGuid().ToString())) .BuildServiceProvider(); ILoggerFactory loggerFactory; @@ -1593,9 +1595,10 @@ public void Can_add_derived_context_one_provider_with_options_and_external_servi public void Can_add_non_derived_context_with_options() { var appServiceProvider = new ServiceCollection() - .AddDbContext(b => - b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(Guid.NewGuid().ToString())) + .AddDbContext( + b => + b.EnableServiceProviderCaching(false) + .UseInMemoryDatabase(Guid.NewGuid().ToString())) .BuildServiceProvider(); var singleton = new object[4]; @@ -1999,14 +2002,16 @@ public void Can_add_non_derived_context_as_singleton(bool addSingletonFirst) var appServiceProvider = addSingletonFirst ? new ServiceCollection() .AddSingleton() - .AddDbContext(b => - b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(Guid.NewGuid().ToString())) + .AddDbContext( + b => + b.EnableServiceProviderCaching(false) + .UseInMemoryDatabase(Guid.NewGuid().ToString())) .BuildServiceProvider() : new ServiceCollection() - .AddDbContext(b => - b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(Guid.NewGuid().ToString())) + .AddDbContext( + b => + b.EnableServiceProviderCaching(false) + .UseInMemoryDatabase(Guid.NewGuid().ToString())) .AddSingleton() .BuildServiceProvider(); @@ -2120,14 +2125,16 @@ public void Can_add_non_derived_context_as_transient(bool addTransientFirst) var appServiceProvider = addTransientFirst ? new ServiceCollection() .AddTransient() - .AddDbContext(b => - b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(Guid.NewGuid().ToString())) + .AddDbContext( + b => + b.EnableServiceProviderCaching(false) + .UseInMemoryDatabase(Guid.NewGuid().ToString())) .BuildServiceProvider() : new ServiceCollection() - .AddDbContext(b => - b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(Guid.NewGuid().ToString())) + .AddDbContext( + b => + b.EnableServiceProviderCaching(false) + .UseInMemoryDatabase(Guid.NewGuid().ToString())) .AddTransient() .BuildServiceProvider(); @@ -2271,7 +2278,8 @@ public void Can_use_logger_before_context_exists_and_after_disposed_when_logger_ var appServiceProvider = new ServiceCollection() .AddEntityFrameworkInMemoryDatabase() - .AddDbContext((p, b) => + .AddDbContext( + (p, b) => b.UseInMemoryDatabase(Guid.NewGuid().ToString()) .EnableServiceProviderCaching(false) .UseLoggerFactory(loggerFactory = new WrappingLoggerFactory(p.GetService()))) @@ -3427,12 +3435,14 @@ public void Last_DbContextOptions_in_serviceCollection_selected() public void Can_resolve_multiple_contexts_in_hierarchy_with_appropriate_constructors() { var services = new ServiceCollection() - .AddDbContext(b => - b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(nameof(DerivedContext1))) - .AddDbContext(b => - b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(nameof(DerivedContext2))) + .AddDbContext( + b => + b.EnableServiceProviderCaching(false) + .UseInMemoryDatabase(nameof(DerivedContext1))) + .AddDbContext( + b => + b.EnableServiceProviderCaching(false) + .UseInMemoryDatabase(nameof(DerivedContext2))) .BuildServiceProvider(); using (var scope = services.CreateScope()) diff --git a/test/EFCore.Tests/DbContextTest.cs b/test/EFCore.Tests/DbContextTest.cs index 0b7c1fcf7e5..ed257b98efd 100644 --- a/test/EFCore.Tests/DbContextTest.cs +++ b/test/EFCore.Tests/DbContextTest.cs @@ -55,11 +55,7 @@ public void Local_calls_DetectChanges() changeDetector.DetectChangesCalled = false; var entry = context.Attach( - new Product - { - Id = 1, - Name = "Little Hedgehogs" - }); + new Product { Id = 1, Name = "Little Hedgehogs" }); entry.Entity.Name = "Big Hedgehogs"; @@ -88,11 +84,7 @@ public void Local_does_not_call_DetectChanges_when_disabled() changeDetector.DetectChangesCalled = false; var entry = context.Attach( - new Product - { - Id = 1, - Name = "Little Hedgehogs" - }); + new Product { Id = 1, Name = "Little Hedgehogs" }); entry.Entity.Name = "Big Hedgehogs"; @@ -217,13 +209,7 @@ public async Task Can_change_navigation_while_attaching_entities(bool async) context.Database.EnsureDeleted(); context.AddRange( - new User - { - Id = 3 - }, new User - { - Id = 4 - }); + new User { Id = 3 }, new User { Id = 4 }); context.SaveChanges(); } @@ -233,14 +219,7 @@ public async Task Can_change_navigation_while_attaching_entities(bool async) { new Question { - Author = context.Users.First(), - Answers = new List - { - new Answer - { - Author = context.Users.Last() - } - } + Author = context.Users.First(), Answers = new List { new Answer { Author = context.Users.Last() } } } }; @@ -497,11 +476,7 @@ public async Task SaveChanges_calls_DetectChanges_by_default(bool async) Assert.True(context.ChangeTracker.AutoDetectChangesEnabled); var product = context.Add( - new Product - { - Id = 1, - Name = "Little Hedgehogs" - }).Entity; + new Product { Id = 1, Name = "Little Hedgehogs" }).Entity; if (async) { @@ -543,11 +518,7 @@ public async Task Auto_DetectChanges_for_SaveChanges_can_be_switched_off(bool as Assert.False(context.ChangeTracker.AutoDetectChangesEnabled); var product = context.Add( - new Product - { - Id = 1, - Name = "Little Hedgehogs" - }).Entity; + new Product { Id = 1, Name = "Little Hedgehogs" }).Entity; if (async) { @@ -601,11 +572,7 @@ public void Entry_calls_DetectChanges_by_default(bool useGenericOverload) using (var context = new ButTheHedgehogContext(InMemoryTestHelpers.Instance.CreateServiceProvider())) { var entry = context.Attach( - new Product - { - Id = 1, - Name = "Little Hedgehogs" - }); + new Product { Id = 1, Name = "Little Hedgehogs" }); entry.Entity.Name = "Cracked Cookies"; @@ -634,11 +601,7 @@ public void Auto_DetectChanges_for_Entry_can_be_switched_off(bool useGenericOver context.ChangeTracker.AutoDetectChangesEnabled = false; var entry = context.Attach( - new Product - { - Id = 1, - Name = "Little Hedgehogs" - }); + new Product { Id = 1, Name = "Little Hedgehogs" }); entry.Entity.Name = "Cracked Cookies"; @@ -672,215 +635,65 @@ public async Task Add_Attach_Remove_Update_do_not_call_DetectChanges() changeDetector.DetectChangesCalled = false; context.Add( - new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + new Product { Id = id++, Name = "Little Hedgehogs" }); context.Add( - (object)new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + (object)new Product { Id = id++, Name = "Little Hedgehogs" }); context.AddRange( - new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + new Product { Id = id++, Name = "Little Hedgehogs" }); context.AddRange( - new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + new Product { Id = id++, Name = "Little Hedgehogs" }); context.AddRange( - new List - { - new Product - { - Id = id++, - Name = "Little Hedgehogs" - } - }); + new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); context.AddRange( - new List - { - new Product - { - Id = id++, - Name = "Little Hedgehogs" - } - }); + new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); await context.AddAsync( - new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + new Product { Id = id++, Name = "Little Hedgehogs" }); await context.AddAsync( - (object)new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + (object)new Product { Id = id++, Name = "Little Hedgehogs" }); await context.AddRangeAsync( - new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + new Product { Id = id++, Name = "Little Hedgehogs" }); await context.AddRangeAsync( - new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + new Product { Id = id++, Name = "Little Hedgehogs" }); await context.AddRangeAsync( - new List - { - new Product - { - Id = id++, - Name = "Little Hedgehogs" - } - }); + new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); await context.AddRangeAsync( - new List - { - new Product - { - Id = id++, - Name = "Little Hedgehogs" - } - }); + new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); context.Attach( - new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + new Product { Id = id++, Name = "Little Hedgehogs" }); context.Attach( - (object)new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + (object)new Product { Id = id++, Name = "Little Hedgehogs" }); context.AttachRange( - new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + new Product { Id = id++, Name = "Little Hedgehogs" }); context.AttachRange( - new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + new Product { Id = id++, Name = "Little Hedgehogs" }); context.AttachRange( - new List - { - new Product - { - Id = id++, - Name = "Little Hedgehogs" - } - }); + new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); context.AttachRange( - new List - { - new Product - { - Id = id++, - Name = "Little Hedgehogs" - } - }); + new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); context.Update( - new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + new Product { Id = id++, Name = "Little Hedgehogs" }); context.Update( - (object)new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + (object)new Product { Id = id++, Name = "Little Hedgehogs" }); context.UpdateRange( - new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + new Product { Id = id++, Name = "Little Hedgehogs" }); context.UpdateRange( - new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + new Product { Id = id++, Name = "Little Hedgehogs" }); context.UpdateRange( - new List - { - new Product - { - Id = id++, - Name = "Little Hedgehogs" - } - }); + new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); context.UpdateRange( - new List - { - new Product - { - Id = id++, - Name = "Little Hedgehogs" - } - }); + new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); context.Remove( - new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + new Product { Id = id++, Name = "Little Hedgehogs" }); context.Remove( - (object)new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + (object)new Product { Id = id++, Name = "Little Hedgehogs" }); context.RemoveRange( - new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + new Product { Id = id++, Name = "Little Hedgehogs" }); context.RemoveRange( - new Product - { - Id = id++, - Name = "Little Hedgehogs" - }); + new Product { Id = id++, Name = "Little Hedgehogs" }); context.RemoveRange( - new List - { - new Product - { - Id = id++, - Name = "Little Hedgehogs" - } - }); + new List { new Product { Id = id++, Name = "Little Hedgehogs" } }); context.RemoveRange( - new List - { - new Product - { - Id = id, - Name = "Little Hedgehogs" - } - }); + new List { new Product { Id = id, Name = "Little Hedgehogs" } }); Assert.False(changeDetector.DetectChangesCalled); @@ -1052,21 +865,10 @@ public void Adding_entities_with_shadow_keys_should_not_throw() { using (var context = new NullShadowKeyContext()) { - var assembly = new TestAssembly - { - Name = "Assembly1" - }; - var testClass = new TestClass - { - Assembly = assembly, - Name = "Class1" - }; + var assembly = new TestAssembly { Name = "Assembly1" }; + var testClass = new TestClass { Assembly = assembly, Name = "Class1" }; var test = context.Tests.Add( - new Test - { - Class = testClass, - Name = "Test1" - }).Entity; + new Test { Class = testClass, Name = "Test1" }).Entity; context.SaveChanges(); diff --git a/test/EFCore.Tests/DbContextTrackingTest.cs b/test/EFCore.Tests/DbContextTrackingTest.cs index 9777b926834..87088f5789d 100644 --- a/test/EFCore.Tests/DbContextTrackingTest.cs +++ b/test/EFCore.Tests/DbContextTrackingTest.cs @@ -58,34 +58,11 @@ private static async Task TrackEntitiesTest( { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var relatedDependent = new Product - { - Id = 1, - Name = "Marmite", - Price = 7.99m - }; - var principal = new Category - { - Id = 1, - Name = "Beverages", - Products = new List - { - relatedDependent - } - }; + var relatedDependent = new Product { Id = 1, Name = "Marmite", Price = 7.99m }; + var principal = new Category { Id = 1, Name = "Beverages", Products = new List { relatedDependent } }; - var relatedPrincipal = new Category - { - Id = 2, - Name = "Foods" - }; - var dependent = new Product - { - Id = 2, - Name = "Bovril", - Price = 4.99m, - Category = relatedPrincipal - }; + var relatedPrincipal = new Category { Id = 2, Name = "Foods" }; + var dependent = new Product { Id = 2, Name = "Bovril", Price = 4.99m, Category = relatedPrincipal }; var principalEntry = await categoryAdder(context, principal); var dependentEntry = await productAdder(context, dependent); @@ -162,34 +139,11 @@ private static async Task TrackMultipleEntitiesTest( { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var relatedDependent = new Product - { - Id = 1, - Name = "Marmite", - Price = 7.99m - }; - var principal = new Category - { - Id = 1, - Name = "Beverages", - Products = new List - { - relatedDependent - } - }; + var relatedDependent = new Product { Id = 1, Name = "Marmite", Price = 7.99m }; + var principal = new Category { Id = 1, Name = "Beverages", Products = new List { relatedDependent } }; - var relatedPrincipal = new Category - { - Id = 2, - Name = "Foods" - }; - var dependent = new Product - { - Id = 2, - Name = "Bovril", - Price = 4.99m, - Category = relatedPrincipal - }; + var relatedPrincipal = new Category { Id = 2, Name = "Foods" }; + var dependent = new Product { Id = 2, Name = "Bovril", Price = 4.99m, Category = relatedPrincipal }; await adder(context, new object[] { principal, dependent }); @@ -201,7 +155,8 @@ private static async Task TrackMultipleEntitiesTest( Assert.Same(principal, context.Entry(principal).Entity); Assert.Equal(expectedState, context.Entry(principal).State); Assert.Same(relatedPrincipal, context.Entry(relatedPrincipal).Entity); - Assert.Equal(expectedState == EntityState.Deleted ? EntityState.Unchanged : expectedState, context.Entry(relatedPrincipal).State); + Assert.Equal( + expectedState == EntityState.Deleted ? EntityState.Unchanged : expectedState, context.Entry(relatedPrincipal).State); Assert.Same(relatedDependent, context.Entry(relatedDependent).Entity); Assert.Equal(expectedState, context.Entry(relatedDependent).State); @@ -255,17 +210,8 @@ private static async Task TrackEntitiesDefaultValueTest( { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category1 = new Category - { - Id = 0, - Name = "Beverages" - }; - var product1 = new Product - { - Id = 0, - Name = "Marmite", - Price = 7.99m - }; + var category1 = new Category { Id = 0, Name = "Beverages" }; + var product1 = new Product { Id = 0, Name = "Marmite", Price = 7.99m }; var categoryEntry1 = await categoryAdder(context, category1); var productEntry1 = await productAdder(context, product1); @@ -339,17 +285,8 @@ private static async Task TrackMultipleEntitiesDefaultValuesTest( { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category1 = new Category - { - Id = 0, - Name = "Beverages" - }; - var product1 = new Product - { - Id = 0, - Name = "Marmite", - Price = 7.99m - }; + var category1 = new Category { Id = 0, Name = "Beverages" }; + var product1 = new Product { Id = 0, Name = "Marmite", Price = 7.99m }; await categoryAdder(context, new[] { category1 }); await productAdder(context, new[] { product1 }); @@ -454,34 +391,11 @@ private static async Task TrackEntitiesTestNonGeneric( { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var relatedDependent = new Product - { - Id = 1, - Name = "Marmite", - Price = 7.99m - }; - var principal = new Category - { - Id = 1, - Name = "Beverages", - Products = new List - { - relatedDependent - } - }; + var relatedDependent = new Product { Id = 1, Name = "Marmite", Price = 7.99m }; + var principal = new Category { Id = 1, Name = "Beverages", Products = new List { relatedDependent } }; - var relatedPrincipal = new Category - { - Id = 2, - Name = "Foods" - }; - var dependent = new Product - { - Id = 2, - Name = "Bovril", - Price = 4.99m, - Category = relatedPrincipal - }; + var relatedPrincipal = new Category { Id = 2, Name = "Foods" }; + var dependent = new Product { Id = 2, Name = "Bovril", Price = 4.99m, Category = relatedPrincipal }; var principalEntry = await categoryAdder(context, principal); var dependentEntry = await productAdder(context, dependent); @@ -558,34 +472,11 @@ private static async Task TrackMultipleEntitiesTestEnumerable( { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var relatedDependent = new Product - { - Id = 1, - Name = "Marmite", - Price = 7.99m - }; - var principal = new Category - { - Id = 1, - Name = "Beverages", - Products = new List - { - relatedDependent - } - }; + var relatedDependent = new Product { Id = 1, Name = "Marmite", Price = 7.99m }; + var principal = new Category { Id = 1, Name = "Beverages", Products = new List { relatedDependent } }; - var relatedPrincipal = new Category - { - Id = 2, - Name = "Foods" - }; - var dependent = new Product - { - Id = 2, - Name = "Bovril", - Price = 4.99m, - Category = relatedPrincipal - }; + var relatedPrincipal = new Category { Id = 2, Name = "Foods" }; + var dependent = new Product { Id = 2, Name = "Bovril", Price = 4.99m, Category = relatedPrincipal }; await adder(context, new object[] { principal, dependent }); @@ -597,7 +488,8 @@ private static async Task TrackMultipleEntitiesTestEnumerable( Assert.Same(principal, context.Entry(principal).Entity); Assert.Equal(expectedState, context.Entry(principal).State); Assert.Same(relatedPrincipal, context.Entry(relatedPrincipal).Entity); - Assert.Equal(expectedState == EntityState.Deleted ? EntityState.Unchanged : expectedState, context.Entry(relatedPrincipal).State); + Assert.Equal( + expectedState == EntityState.Deleted ? EntityState.Unchanged : expectedState, context.Entry(relatedPrincipal).State); Assert.Same(relatedDependent, context.Entry(relatedDependent).Entity); Assert.Equal(expectedState, context.Entry(relatedDependent).State); @@ -651,17 +543,8 @@ private static async Task TrackEntitiesDefaultValuesTestNonGeneric( { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category1 = new Category - { - Id = 0, - Name = "Beverages" - }; - var product1 = new Product - { - Id = 0, - Name = "Marmite", - Price = 7.99m - }; + var category1 = new Category { Id = 0, Name = "Beverages" }; + var product1 = new Product { Id = 0, Name = "Marmite", Price = 7.99m }; var categoryEntry1 = await categoryAdder(context, category1); var productEntry1 = await productAdder(context, product1); @@ -737,28 +620,13 @@ private static async Task TrackMultipleEntitiesDefaultValueTestEnumerable( { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category1 = new Category - { - Id = 0, - Name = "Beverages" - }; - var product1 = new Product - { - Id = 0, - Name = "Marmite", - Price = 7.99m - }; + var category1 = new Category { Id = 0, Name = "Beverages" }; + var product1 = new Product { Id = 0, Name = "Marmite", Price = 7.99m }; await categoryAdder( - context, new List - { - category1 - }); + context, new List { category1 }); await productAdder( - context, new List - { - product1 - }); + context, new List { product1 }); Assert.Same(category1, context.Entry(category1).Entity); Assert.Same(product1, context.Entry(product1).Entity); @@ -829,14 +697,8 @@ public async Task Can_add_new_entities_to_context_with_key_generation_graph(bool { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var gu1 = new TheGu - { - ShirtColor = "Red" - }; - var gu2 = new TheGu - { - ShirtColor = "Still Red" - }; + var gu1 = new TheGu { ShirtColor = "Red" }; + var gu2 = new TheGu { ShirtColor = "Still Red" }; if (attachFirst) { @@ -948,11 +810,7 @@ private async Task ChangeStateWithMethod( { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var entity = new Category - { - Id = 1, - Name = "Beverages" - }; + var entity = new Category { Id = 1, Name = "Beverages" }; var entry = context.Entry(entity); entry.State = initialState; @@ -968,22 +826,9 @@ public void Can_attach_with_inconsistent_FK_principal_first_fully_fixed_up() { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; - category.Products = new List - { - product - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; + category.Products = new List { product }; context.Entry(category).State = EntityState.Unchanged; @@ -1010,22 +855,9 @@ public void Can_attach_with_inconsistent_FK_dependent_first_fully_fixed_up() { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; - category.Products = new List - { - product - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; + category.Products = new List { product }; context.Attach(product); @@ -1050,18 +882,8 @@ public void Can_attach_with_inconsistent_FK_principal_first_collection_not_fixed { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; category.Products = new List(); context.Attach(category); @@ -1087,18 +909,8 @@ public void Can_attach_with_inconsistent_FK_dependent_first_collection_not_fixed { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; category.Products = new List(); context.Attach(product); @@ -1124,21 +936,9 @@ public void Can_attach_with_inconsistent_FK_principal_first_reference_not_fixed_ { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite" - }; - category.Products = new List - { - product - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite" }; + category.Products = new List { product }; context.Entry(category).State = EntityState.Unchanged; @@ -1163,21 +963,9 @@ public void Can_attach_with_inconsistent_FK_dependent_first_reference_not_fixed_ { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite" - }; - category.Products = new List - { - product - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite" }; + category.Products = new List { product }; context.Attach(product); @@ -1202,22 +990,9 @@ public void Can_set_set_to_Unchanged_with_inconsistent_FK_principal_first_fully_ { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; - category.Products = new List - { - product - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; + category.Products = new List { product }; context.Entry(category).State = EntityState.Unchanged; @@ -1244,22 +1019,9 @@ public void Can_set_set_to_Unchanged_with_inconsistent_FK_dependent_first_fully_ { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; - category.Products = new List - { - product - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; + category.Products = new List { product }; context.Entry(product).State = EntityState.Unchanged; @@ -1284,18 +1046,8 @@ public void Can_set_set_to_Unchanged_with_inconsistent_FK_principal_first_collec { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; category.Products = new List(); context.Entry(category).State = EntityState.Unchanged; @@ -1321,18 +1073,8 @@ public void Can_set_set_to_Unchanged_with_inconsistent_FK_dependent_first_collec { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; category.Products = new List(); context.Entry(product).State = EntityState.Unchanged; @@ -1358,21 +1100,9 @@ public void Can_set_set_to_Unchanged_with_inconsistent_FK_principal_first_refere { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite" - }; - category.Products = new List - { - product - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite" }; + category.Products = new List { product }; context.Entry(category).State = EntityState.Unchanged; @@ -1397,21 +1127,9 @@ public void Can_set_set_to_Unchanged_with_inconsistent_FK_dependent_first_refere { using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite" - }; - category.Products = new List - { - product - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite" }; + category.Products = new List { product }; context.Entry(product).State = EntityState.Unchanged; @@ -1437,28 +1155,11 @@ public void Can_attach_with_inconsistent_FK_principal_first_fully_fixed_up_with_ using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { var category7 = context.Attach( - new Category - { - Id = 7, - Products = new List() - }).Entity; + new Category { Id = 7, Products = new List() }).Entity; - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; - category.Products = new List - { - product - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; + category.Products = new List { product }; context.Entry(category).State = EntityState.Unchanged; @@ -1487,30 +1188,13 @@ public void Can_attach_with_inconsistent_FK_dependent_first_fully_fixed_up_with_ using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { var category7 = context.Attach( - new Category - { - Id = 7, - Products = new List() - }).Entity; + new Category { Id = 7, Products = new List() }).Entity; - var category = new Category - { - Id = 1, - Name = "Beverages" - }; + var category = new Category { Id = 1, Name = "Beverages" }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; - category.Products = new List - { - product - }; + category.Products = new List { product }; context.Attach(product); @@ -1540,25 +1224,11 @@ public void Can_attach_with_inconsistent_FK_principal_first_collection_not_fixed using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { var category7 = context.Attach( - new Category - { - Id = 7, - Products = new List() - }).Entity; + new Category { Id = 7, Products = new List() }).Entity; - var category = new Category - { - Id = 1, - Name = "Beverages" - }; + var category = new Category { Id = 1, Name = "Beverages" }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; category.Products = new List(); @@ -1590,25 +1260,11 @@ public void Can_attach_with_inconsistent_FK_dependent_first_collection_not_fixed using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { var category7 = context.Attach( - new Category - { - Id = 7, - Products = new List() - }).Entity; + new Category { Id = 7, Products = new List() }).Entity; - var category = new Category - { - Id = 1, - Name = "Beverages" - }; + var category = new Category { Id = 1, Name = "Beverages" }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; category.Products = new List(); @@ -1640,27 +1296,11 @@ public void Can_attach_with_inconsistent_FK_principal_first_reference_not_fixed_ using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { var category7 = context.Attach( - new Category - { - Id = 7, - Products = new List() - }).Entity; + new Category { Id = 7, Products = new List() }).Entity; - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite" - }; - category.Products = new List - { - product - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite" }; + category.Products = new List { product }; context.Entry(category).State = EntityState.Unchanged; @@ -1688,27 +1328,11 @@ public void Can_attach_with_inconsistent_FK_dependent_first_reference_not_fixed_ using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { var category7 = context.Attach( - new Category - { - Id = 7, - Products = new List() - }).Entity; + new Category { Id = 7, Products = new List() }).Entity; - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite" - }; - category.Products = new List - { - product - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite" }; + category.Products = new List { product }; context.Attach(product); @@ -1735,28 +1359,11 @@ public void Can_set_set_to_Unchanged_with_inconsistent_FK_principal_first_fully_ using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { var category7 = context.Attach( - new Category - { - Id = 7, - Products = new List() - }).Entity; + new Category { Id = 7, Products = new List() }).Entity; - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; - category.Products = new List - { - product - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; + category.Products = new List { product }; context.Entry(category).State = EntityState.Unchanged; @@ -1784,30 +1391,13 @@ public void Can_set_set_to_Unchanged_with_inconsistent_FK_dependent_first_fully_ using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { var category7 = context.Attach( - new Category - { - Id = 7, - Products = new List() - }).Entity; + new Category { Id = 7, Products = new List() }).Entity; - var category = new Category - { - Id = 1, - Name = "Beverages" - }; + var category = new Category { Id = 1, Name = "Beverages" }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; - category.Products = new List - { - product - }; + category.Products = new List { product }; context.Entry(product).State = EntityState.Unchanged; @@ -1837,24 +1427,10 @@ public void Can_set_set_to_Unchanged_with_inconsistent_FK_principal_first_collec using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { var category7 = context.Attach( - new Category - { - Id = 7, - Products = new List() - }).Entity; + new Category { Id = 7, Products = new List() }).Entity; - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; category.Products = new List(); context.Entry(category).State = EntityState.Unchanged; @@ -1884,25 +1460,11 @@ public void Can_set_set_to_Unchanged_with_inconsistent_FK_dependent_first_collec using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { var category7 = context.Attach( - new Category - { - Id = 7, - Products = new List() - }).Entity; + new Category { Id = 7, Products = new List() }).Entity; - var category = new Category - { - Id = 1, - Name = "Beverages" - }; + var category = new Category { Id = 1, Name = "Beverages" }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite", - Category = category - }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite", Category = category }; category.Products = new List(); @@ -1934,27 +1496,11 @@ public void Can_set_set_to_Unchanged_with_inconsistent_FK_principal_first_refere using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { var category7 = context.Attach( - new Category - { - Id = 7, - Products = new List() - }).Entity; + new Category { Id = 7, Products = new List() }).Entity; - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite" - }; - category.Products = new List - { - product - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite" }; + category.Products = new List { product }; context.Entry(category).State = EntityState.Unchanged; @@ -1982,27 +1528,11 @@ public void Can_set_set_to_Unchanged_with_inconsistent_FK_dependent_first_refere using (var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider())) { var category7 = context.Attach( - new Category - { - Id = 7, - Products = new List() - }).Entity; + new Category { Id = 7, Products = new List() }).Entity; - var category = new Category - { - Id = 1, - Name = "Beverages" - }; - var product = new Product - { - Id = 1, - CategoryId = 7, - Name = "Marmite" - }; - category.Products = new List - { - product - }; + var category = new Category { Id = 1, Name = "Beverages" }; + var product = new Product { Id = 1, CategoryId = 7, Name = "Marmite" }; + category.Products = new List { product }; context.Entry(product).State = EntityState.Unchanged; diff --git a/test/EFCore.Tests/DbSetTest.cs b/test/EFCore.Tests/DbSetTest.cs index 1db97c2b75f..991b5c6b3d8 100644 --- a/test/EFCore.Tests/DbSetTest.cs +++ b/test/EFCore.Tests/DbSetTest.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; @@ -180,28 +179,10 @@ private static async Task TrackEntitiesTest( { using (var context = new EarlyLearningCenter()) { - var category1 = new Category - { - Id = 1, - Name = "Beverages" - }; - var category2 = new Category - { - Id = 2, - Name = "Foods" - }; - var product1 = new Product - { - Id = 1, - Name = "Marmite", - Price = 7.99m - }; - var product2 = new Product - { - Id = 2, - Name = "Bovril", - Price = 4.99m - }; + var category1 = new Category { Id = 1, Name = "Beverages" }; + var category2 = new Category { Id = 2, Name = "Foods" }; + var product1 = new Product { Id = 1, Name = "Marmite", Price = 7.99m }; + var product2 = new Product { Id = 2, Name = "Bovril", Price = 4.99m }; var categoryEntry1 = await categoryAdder(context.Categories, category1); var categoryEntry2 = await categoryAdder(context.Categories, category2); @@ -297,28 +278,10 @@ private static async Task TrackMultipleEntitiesTest( { using (var context = new EarlyLearningCenter()) { - var category1 = new Category - { - Id = 1, - Name = "Beverages" - }; - var category2 = new Category - { - Id = 2, - Name = "Foods" - }; - var product1 = new Product - { - Id = 1, - Name = "Marmite", - Price = 7.99m - }; - var product2 = new Product - { - Id = 2, - Name = "Bovril", - Price = 4.99m - }; + var category1 = new Category { Id = 1, Name = "Beverages" }; + var category2 = new Category { Id = 2, Name = "Foods" }; + var product1 = new Product { Id = 1, Name = "Marmite", Price = 7.99m }; + var product2 = new Product { Id = 2, Name = "Bovril", Price = 4.99m }; await categoryAdder(context, new[] { category1, category2 }); await productAdder(context, new[] { product1, product2 }); @@ -452,41 +415,15 @@ private static async Task TrackMultipleEntitiesTestEnumerable( { using (var context = new EarlyLearningCenter()) { - var category1 = new Category - { - Id = 1, - Name = "Beverages" - }; - var category2 = new Category - { - Id = 2, - Name = "Foods" - }; - var product1 = new Product - { - Id = 1, - Name = "Marmite", - Price = 7.99m - }; - var product2 = new Product - { - Id = 2, - Name = "Bovril", - Price = 4.99m - }; + var category1 = new Category { Id = 1, Name = "Beverages" }; + var category2 = new Category { Id = 2, Name = "Foods" }; + var product1 = new Product { Id = 1, Name = "Marmite", Price = 7.99m }; + var product2 = new Product { Id = 2, Name = "Bovril", Price = 4.99m }; await categoryAdder( - context, new List - { - category1, - category2 - }); + context, new List { category1, category2 }); await productAdder( - context, new List - { - product1, - product2 - }); + context, new List { product1, product2 }); Assert.Same(category1, context.Entry(category1).Entity); Assert.Same(category2, context.Entry(category2).Entity); @@ -622,11 +559,7 @@ private async Task ChangeStateWithMethod( { using (var context = new EarlyLearningCenter()) { - var entity = new Category - { - Id = 1, - Name = "Beverages" - }; + var entity = new Category { Id = 1, Name = "Beverages" }; var entry = context.Entry(entity); entry.State = initialState; @@ -644,14 +577,8 @@ public async Task Can_add_new_entities_to_context_with_key_generation(bool async { using (var context = new EarlyLearningCenter()) { - var gu1 = new TheGu - { - ShirtColor = "Red" - }; - var gu2 = new TheGu - { - ShirtColor = "Still Red" - }; + var gu1 = new TheGu { ShirtColor = "Red" }; + var gu2 = new TheGu { ShirtColor = "Still Red" }; if (async) { diff --git a/test/EFCore.Tests/ExceptionTest.cs b/test/EFCore.Tests/ExceptionTest.cs index 26fd7fad630..060dde068b4 100644 --- a/test/EFCore.Tests/ExceptionTest.cs +++ b/test/EFCore.Tests/ExceptionTest.cs @@ -13,6 +13,7 @@ using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.EntityFrameworkCore.Update; using Xunit; + // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore @@ -96,10 +97,7 @@ public void Deserialized_DbUpdateException_can_be_serialized_and_deserialized_ag new DbUpdateException( "But somehow the vital connection is made", new Exception("Bang!"), - new IUpdateEntry[] - { - new FakeUpdateEntry() - }))); + new IUpdateEntry[] { new FakeUpdateEntry() }))); Assert.Equal("But somehow the vital connection is made", transportedException.Message); Assert.Equal("Bang!", transportedException.InnerException.Message); @@ -149,10 +147,7 @@ public void Deserialized_DbUpdateConcurrencyException_can_be_serialized_and_dese new DbUpdateConcurrencyException( "But somehow the vital connection is made", new Exception("Bang!"), - new IUpdateEntry[] - { - new FakeUpdateEntry() - }))); + new IUpdateEntry[] { new FakeUpdateEntry() }))); Assert.Equal("But somehow the vital connection is made", transportedException.Message); Assert.Equal("Bang!", transportedException.InnerException.Message); @@ -195,7 +190,8 @@ private static IEntityType CreateEntityType() return entityType; } - private TException SerializeAndDeserialize(TException exception) where TException : Exception + private TException SerializeAndDeserialize(TException exception) + where TException : Exception { var stream = new MemoryStream(); var formatter = new BinaryFormatter(); diff --git a/test/EFCore.Tests/Extensions/PropertyExtensionsTest.cs b/test/EFCore.Tests/Extensions/PropertyExtensionsTest.cs index 4694c9fb00b..17bd1e7008f 100644 --- a/test/EFCore.Tests/Extensions/PropertyExtensionsTest.cs +++ b/test/EFCore.Tests/Extensions/PropertyExtensionsTest.cs @@ -308,11 +308,7 @@ private IMutableModel BuildModel() b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); b.HasOne(e => e.TagDetails) .WithOne(e => e.Tag) .HasPrincipalKey(e => e.Id2) @@ -324,20 +320,12 @@ private IMutableModel BuildModel() b => { b.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); b.Property(e => e.Id2).ValueGeneratedOnAdd(); b.HasOne(e => e.Tag) .WithOne(e => e.Details) .HasForeignKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); }); modelBuilder @@ -345,20 +333,13 @@ private IMutableModel BuildModel() .HasOne(e => e.Details) .WithOne(e => e.Product) .HasForeignKey( - e => new - { - e.Id1 - }); + e => new { e.Id1 }); modelBuilder.Entity( b => { b.HasKey( - e => new - { - e.OrderId, - e.ProductId - }); + e => new { e.OrderId, e.ProductId }); b.HasOne(e => e.Order) .WithMany(e => e.OrderDetails) .HasForeignKey(e => e.OrderId); diff --git a/test/EFCore.Tests/Infrastructure/CoreEventIdTest.cs b/test/EFCore.Tests/Infrastructure/CoreEventIdTest.cs index 98edab497e1..2992a1bbbe8 100644 --- a/test/EFCore.Tests/Infrastructure/CoreEventIdTest.cs +++ b/test/EFCore.Tests/Infrastructure/CoreEventIdTest.cs @@ -26,7 +26,8 @@ public void Every_eventId_has_a_logger_method_and_logs_when_level_enabled() var entityType = new Model(new ConventionSet()).AddEntityType(typeof(object), ConfigurationSource.Convention); var property = entityType.AddProperty("A", typeof(int), ConfigurationSource.Convention, ConfigurationSource.Convention); var otherEntityType = new EntityType(typeof(object), entityType.Model, ConfigurationSource.Convention); - var otherProperty = otherEntityType.AddProperty("A", typeof(int), ConfigurationSource.Convention, ConfigurationSource.Convention); + var otherProperty = otherEntityType.AddProperty( + "A", typeof(int), ConfigurationSource.Convention, ConfigurationSource.Convention); var otherKey = otherEntityType.AddKey(otherProperty, ConfigurationSource.Convention); var foreignKey = new ForeignKey(new[] { property }, otherKey, entityType, otherEntityType, ConfigurationSource.Convention); var navigation = new Navigation("N", propertyInfo, null, foreignKey); @@ -49,7 +50,10 @@ public void Every_eventId_has_a_logger_method_and_logs_when_level_enabled() { typeof(IServiceProvider), () => new FakeServiceProvider() }, { typeof(ICollection), () => new List() }, { typeof(IReadOnlyList), () => new[] { property } }, - { typeof(IEnumerable>), () => new[] { new Tuple(propertyInfo, typeof(object)) } }, + { + typeof(IEnumerable>), + () => new[] { new Tuple(propertyInfo, typeof(object)) } + }, { typeof(MemberInfo), () => propertyInfo }, { typeof(IReadOnlyList), () => new[] { new Exception() } }, { typeof(IProperty), () => property }, diff --git a/test/EFCore.Tests/Infrastructure/EventIdTestBase.cs b/test/EFCore.Tests/Infrastructure/EventIdTestBase.cs index 2d5e5a5072f..012bf286218 100644 --- a/test/EFCore.Tests/Infrastructure/EventIdTestBase.cs +++ b/test/EFCore.Tests/Infrastructure/EventIdTestBase.cs @@ -42,10 +42,7 @@ public void TestEventLogging( if (eventMappings == null || !eventMappings.TryGetValue(eventName, out var mappedNames)) { - mappedNames = new List - { - eventName - }; + mappedNames = new List { eventName }; } foreach (var mappedName in mappedNames) @@ -98,10 +95,7 @@ public void TestEventLogging( } } - foreach (var enableFor in new[] - { - "Foo", eventId.Name - }) + foreach (var enableFor in new[] { "Foo", eventId.Name }) { testDiagnostics.EnableFor = enableFor; diff --git a/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs b/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs index a963aaadd41..6041aa977e1 100644 --- a/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs +++ b/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs @@ -62,7 +62,9 @@ public virtual void Passes_on_shadow_key_created_explicitly() var keyProperty = entityType.AddProperty("Key", typeof(int)); entityType.AddKey(keyProperty); - VerifyWarning(CoreResources.LogShadowPropertyCreated(new TestLogger()).GenerateMessage("Key", "A"), model, LogLevel.Debug); + VerifyWarning( + CoreResources.LogShadowPropertyCreated(new TestLogger()).GenerateMessage("Key", "A"), model, + LogLevel.Debug); } [ConditionalFact] @@ -77,8 +79,9 @@ public virtual void Passes_on_shadow_primary_key_created_by_convention_in_depend var keyProperty = entityType.AddProperty("Key", typeof(int)); entityType.SetPrimaryKey(keyProperty); - VerifyWarning(CoreResources.LogShadowPropertyCreated(new TestLogger()) - .GenerateMessage("Key", "A"), (IMutableModel)model, LogLevel.Debug); + VerifyWarning( + CoreResources.LogShadowPropertyCreated(new TestLogger()) + .GenerateMessage("Key", "A"), (IMutableModel)model, LogLevel.Debug); } [ConditionalFact] @@ -90,18 +93,12 @@ public virtual void Detects_shadow_key_referenced_by_foreign_key_by_convention() dependentEntityBuilder.Ignore(nameof(SampleEntityMinimal.ReferencedEntity), ConfigurationSource.Explicit); dependentEntityBuilder.PrimaryKey( - new List - { - "Id" - }, ConfigurationSource.Convention); + new List { "Id" }, ConfigurationSource.Convention); var principalEntityBuilder = modelBuilder.Entity(typeof(ReferencedEntityMinimal), ConfigurationSource.Convention); principalEntityBuilder.Property(typeof(int), "Id", ConfigurationSource.Convention); principalEntityBuilder.PrimaryKey( - new List - { - "Id" - }, ConfigurationSource.Convention); + new List { "Id" }, ConfigurationSource.Convention); dependentEntityBuilder.Property(typeof(string), "Foo", ConfigurationSource.Convention); principalEntityBuilder.Property(typeof(string), "ReferencedFoo", ConfigurationSource.Convention); @@ -109,10 +106,7 @@ public virtual void Detects_shadow_key_referenced_by_foreign_key_by_convention() dependentEntityBuilder.HasRelationship( principalEntityBuilder.Metadata, dependentEntityBuilder.GetOrCreateProperties( - new List - { - "Foo" - }, ConfigurationSource.Convention), + new List { "Foo" }, ConfigurationSource.Convention), principalEntityBuilder.HasKey(new[] { "ReferencedFoo" }, ConfigurationSource.Convention).Metadata, ConfigurationSource.Convention); @@ -190,7 +184,9 @@ public virtual void Passes_on_redundant_foreign_key() modelBuilder.Entity().HasOne().WithOne().IsRequired().HasForeignKey(a => a.Id).HasPrincipalKey(b => b.Id); - VerifyWarning(CoreResources.LogRedundantForeignKey(new TestLogger()).GenerateMessage("{'Id'}", "A"), modelBuilder.Model, LogLevel.Warning); + VerifyWarning( + CoreResources.LogRedundantForeignKey(new TestLogger()).GenerateMessage("{'Id'}", "A"), + modelBuilder.Model); } [ConditionalFact] @@ -449,7 +445,8 @@ public virtual void Detects_weak_entity_type_without_defining_navigation() VerifyError( CoreStrings.NoDefiningNavigation( nameof(SampleEntityMinimal.ReferencedEntity), - nameof(SampleEntityMinimal) + "." + nameof(SampleEntityMinimal.ReferencedEntity) + "#" + nameof(ReferencedEntityMinimal), + nameof(SampleEntityMinimal) + "." + nameof(SampleEntityMinimal.ReferencedEntity) + "#" + + nameof(ReferencedEntityMinimal), nameof(SampleEntityMinimal)), modelBuilder.Metadata); } @@ -504,14 +501,16 @@ public virtual void Detects_weak_entity_type_with_non_defining_ownership() ownedTypeBuilder.PrimaryKey(ownershipBuilder.Metadata.Properties.Select(p => p.Name).ToList(), ConfigurationSource.Convention); ownershipBuilder.Metadata.IsOwnership = false; - ownedTypeBuilder.HasRelationship(entityTypeBuilder.Metadata, (string)null, null, ConfigurationSource.Convention, setTargetAsPrincipal: true) + ownedTypeBuilder.HasRelationship( + entityTypeBuilder.Metadata, (string)null, null, ConfigurationSource.Convention, setTargetAsPrincipal: true) .Metadata.IsOwnership = true; VerifyError( CoreStrings.NonDefiningOwnership( nameof(SampleEntityMinimal), nameof(SampleEntityMinimal.ReferencedEntity), - nameof(SampleEntityMinimal) + "." + nameof(SampleEntityMinimal.ReferencedEntity) + "#" + nameof(ReferencedEntityMinimal)), + nameof(SampleEntityMinimal) + "." + nameof(SampleEntityMinimal.ReferencedEntity) + "#" + + nameof(ReferencedEntityMinimal)), modelBuilder.Metadata); } @@ -538,8 +537,10 @@ public virtual void Detects_weak_entity_type_without_ownership() VerifyError( CoreStrings.InconsistentOwnership( - nameof(SampleEntityMinimal) + "." + nameof(SampleEntityMinimal.ReferencedEntity) + "#" + nameof(ReferencedEntityMinimal), - nameof(AnotherSampleEntityMinimal) + "." + nameof(AnotherSampleEntityMinimal.ReferencedEntity) + "#" + nameof(ReferencedEntityMinimal)), + nameof(SampleEntityMinimal) + "." + nameof(SampleEntityMinimal.ReferencedEntity) + "#" + + nameof(ReferencedEntityMinimal), + nameof(AnotherSampleEntityMinimal) + "." + nameof(AnotherSampleEntityMinimal.ReferencedEntity) + "#" + + nameof(ReferencedEntityMinimal)), modelBuilder.Metadata); } @@ -780,16 +781,9 @@ public virtual void Passes_for_valid_seeds() { var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.Entity().HasData( - new A - { - Id = 1 - }); + new A { Id = 1 }); modelBuilder.Entity().HasData( - new D - { - Id = 2, - P0 = 3 - }); + new D { Id = 2, P0 = 3 }); Validate(modelBuilder.Model); } @@ -804,10 +798,7 @@ public virtual void Passes_for_ignored_invalid_properties() eb.Ignore(e => e.NotImplemented); eb.HasData( - new EntityWithInvalidProperties - { - Id = -1 - }); + new EntityWithInvalidProperties { Id = -1 }); eb.HasData( new @@ -837,11 +828,7 @@ public virtual void Detects_derived_seeds() CoreStrings.SeedDatumDerivedType(nameof(A), nameof(D)), Assert.Throws( () => modelBuilder.Entity().HasData( - new D - { - Id = 2, - P0 = 3 - })).Message); + new D { Id = 2, P0 = 3 })).Message); } [ConditionalFact] @@ -855,11 +842,7 @@ public virtual void Detects_derived_seeds_for_owned_types() () => modelBuilder.Entity() .OwnsOne( b => b.A, a => a.HasData( - new D - { - Id = 2, - P0 = 3 - })) + new D { Id = 2, P0 = 3 })) .OwnsOne(b => b.AnotherA)).Message); } @@ -872,10 +855,7 @@ public virtual void Detects_missing_required_values_in_seeds() { e.Property(a => a.P0).IsRequired(); e.HasData( - new A - { - Id = 1 - }); + new A { Id = 1 }); }); VerifyError( @@ -892,10 +872,7 @@ public virtual void Passes_on_missing_required_store_generated_values_in_seeds() { e.Property(a => a.P0).IsRequired().ValueGeneratedOnAddOrUpdate(); e.HasData( - new A - { - Id = 1 - }); + new A { Id = 1 }); }); Validate(modelBuilder.Model); @@ -935,15 +912,9 @@ public virtual void Detects_duplicate_seeds(bool sensitiveDataLoggingEnabled) { var modelBuilder = CreateConventionalModelBuilder(sensitiveDataLoggingEnabled); modelBuilder.Entity().HasData( - new A - { - Id = 1 - }); + new A { Id = 1 }); modelBuilder.Entity().HasData( - new D - { - Id = 1 - }); + new D { Id = 1 }); VerifyError( sensitiveDataLoggingEnabled @@ -962,11 +933,7 @@ public virtual void Detects_incompatible_values(bool sensitiveDataLoggingEnabled e => { e.HasData( - new - { - Id = 1, - P0 = "invalid" - }); + new { Id = 1, P0 = "invalid" }); }); VerifyError( @@ -986,14 +953,7 @@ public virtual void Detects_reference_navigations_in_seeds(bool sensitiveDataLog e => { e.HasData( - new SampleEntity - { - Id = 1, - ReferencedEntity = new ReferencedEntity - { - Id = 2 - } - }); + new SampleEntity { Id = 1, ReferencedEntity = new ReferencedEntity { Id = 2 } }); }); VerifyError( @@ -1026,13 +986,7 @@ public virtual void Detects_collection_navigations_in_seeds(bool sensitiveDataLo { Id = 1, OtherSamples = new HashSet( - new[] - { - new SampleEntity - { - Id = 2 - } - }) + new[] { new SampleEntity { Id = 2 } }) }); }); @@ -1052,7 +1006,6 @@ public virtual void Detects_collection_navigations_in_seeds(bool sensitiveDataLo modelBuilder.Model); } - [ConditionalFact] public virtual void Detects_missing_discriminator_property() { diff --git a/test/EFCore.Tests/Metadata/Conventions/BackingFieldConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/BackingFieldConventionTest.cs index aa398ec31d5..a06113facce 100644 --- a/test/EFCore.Tests/Metadata/Conventions/BackingFieldConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/BackingFieldConventionTest.cs @@ -337,6 +337,7 @@ public int Eclipse set { m_Eclipse = value; } } } + private class TheDarkerSideOfTheMoon { private readonly string m_SpeakToMe; @@ -421,7 +422,7 @@ private class HesNotTheMessiah public int OnTheRun { - get { return (int)m_onTheRun; } + get { return m_onTheRun; } set { m_onTheRun = value; } } } diff --git a/test/EFCore.Tests/Metadata/Conventions/ConstructorBindingConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/ConstructorBindingConventionTest.cs index dd44fb36c61..0156f8d93a4 100644 --- a/test/EFCore.Tests/Metadata/Conventions/ConstructorBindingConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/ConstructorBindingConventionTest.cs @@ -389,11 +389,7 @@ public void Does_not_throw_if_explicit_binding_has_been_set() var constructorBinding = GetBinding( e => e[CoreAnnotationNames.ConstructorBinding] = new ConstructorBinding( typeof(BlogConflict).GetConstructor( - new[] - { - typeof(string), - typeof(int) - }), + new[] { typeof(string), typeof(int) }), new[] { new PropertyParameterBinding(e.FindProperty(nameof(Blog.Title))), diff --git a/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs b/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs index e6e21596ac6..6e40eb0d0b8 100644 --- a/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs @@ -570,7 +570,8 @@ public void OnBaseTypeChanged_calls_conventions_in_order(bool useBuilder, bool u } else { - builder.Metadata.HasBaseType(builder.Metadata.Model.AddEntityType(typeof(Order), ConfigurationSource.Explicit), ConfigurationSource.Convention); + builder.Metadata.HasBaseType( + builder.Metadata.Model.AddEntityType(typeof(Order), ConfigurationSource.Explicit), ConfigurationSource.Convention); } if (useScope) @@ -1197,7 +1198,8 @@ public void OnForeignKeyUniquenessChanged_calls_conventions_in_order(bool useBui var builder = new InternalModelBuilder(new Model(conventions)); var principalEntityBuilder = builder.Entity(typeof(Order), ConfigurationSource.Convention); var dependentEntityBuilder = builder.Entity(typeof(OrderDetails), ConfigurationSource.Convention); - var foreignKey = dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, ConfigurationSource.Convention).Metadata; + var foreignKey = dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, ConfigurationSource.Convention) + .Metadata; var scope = useScope ? builder.Metadata.ConventionDispatcher.DelayConventions() : null; @@ -1296,7 +1298,8 @@ public void OnForeignKeyRequirednessChanged_calls_conventions_in_order(bool useB var builder = new InternalModelBuilder(new Model(conventions)); var principalEntityBuilder = builder.Entity(typeof(Order), ConfigurationSource.Convention); var dependentEntityBuilder = builder.Entity(typeof(OrderDetails), ConfigurationSource.Convention); - var foreignKey = dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, ConfigurationSource.Convention).Metadata; + var foreignKey = dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, ConfigurationSource.Convention) + .Metadata; var scope = useScope ? builder.Metadata.ConventionDispatcher.DelayConventions() : null; @@ -1395,7 +1398,8 @@ public void OnForeignKeyOwnershipChanged_calls_conventions_in_order(bool useBuil var builder = new InternalModelBuilder(new Model(conventions)); var principalEntityBuilder = builder.Entity(typeof(Order), ConfigurationSource.Convention); var dependentEntityBuilder = builder.Entity(typeof(OrderDetails), ConfigurationSource.Convention); - var foreignKey = dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, ConfigurationSource.Convention).Metadata; + var foreignKey = dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, ConfigurationSource.Convention) + .Metadata; var scope = useScope ? builder.Metadata.ConventionDispatcher.DelayConventions() : null; @@ -1495,7 +1499,8 @@ public void OnForeignKeyAnnotationChanged_calls_conventions_in_order(bool useBui var builder = new InternalModelBuilder(new Model(conventions)); var principalEntityBuilder = builder.Entity(typeof(Order), ConfigurationSource.Convention); var dependentEntityBuilder = builder.Entity(typeof(OrderDetails), ConfigurationSource.Convention); - var foreignKey = dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, ConfigurationSource.Convention).Metadata; + var foreignKey = dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, ConfigurationSource.Convention) + .Metadata; var scope = useScope ? builder.Metadata.ConventionDispatcher.DelayConventions() : null; @@ -1673,7 +1678,6 @@ public void ProcessNavigationAdded( context.StopProcessing(); } - } } @@ -1703,10 +1707,11 @@ public void OnNavigationRemoved_calls_conventions_in_order(bool useBuilder, bool if (useBuilder) { - Assert.NotNull(relationshipBuilder.HasNavigation( - (string)null, - pointsToPrincipal: true, - ConfigurationSource.Convention)); + Assert.NotNull( + relationshipBuilder.HasNavigation( + (string)null, + pointsToPrincipal: true, + ConfigurationSource.Convention)); } else { @@ -1726,10 +1731,11 @@ public void OnNavigationRemoved_calls_conventions_in_order(bool useBuilder, bool if (useBuilder) { - Assert.NotNull(relationshipBuilder.HasNavigation( - (string)null, - pointsToPrincipal: true, - ConfigurationSource.Convention)); + Assert.NotNull( + relationshipBuilder.HasNavigation( + (string)null, + pointsToPrincipal: true, + ConfigurationSource.Convention)); } else { @@ -1791,10 +1797,7 @@ public void OnKeyAdded_calls_conventions_in_order(bool useBuilder, bool useScope if (useBuilder) { var result = entityBuilder.HasKey( - new List - { - keyPropertyName - }, ConfigurationSource.Convention); + new List { keyPropertyName }, ConfigurationSource.Convention); Assert.Equal(!useScope, result == null); } @@ -1861,10 +1864,7 @@ public void OnKeyRemoved_calls_conventions_in_order(bool useScope) var entityBuilder = builder.Entity(typeof(Order), ConfigurationSource.Convention); var key = entityBuilder.HasKey( - new List - { - "OrderId" - }, ConfigurationSource.Convention).Metadata; + new List { "OrderId" }, ConfigurationSource.Convention).Metadata; var scope = useScope ? builder.Metadata.ConventionDispatcher.DelayConventions() : null; @@ -1928,10 +1928,7 @@ public void OnKeyAnnotationChanged_calls_conventions_in_order(bool useBuilder, b var builder = new InternalModelBuilder(new Model(conventions)); var entityBuilder = builder.Entity(typeof(Order), ConfigurationSource.Convention); var key = entityBuilder.HasKey( - new List - { - "OrderId" - }, ConfigurationSource.Convention).Metadata; + new List { "OrderId" }, ConfigurationSource.Convention).Metadata; var scope = useScope ? builder.Metadata.ConventionDispatcher.DelayConventions() : null; @@ -2036,10 +2033,7 @@ public void OnIndexAdded_calls_conventions_in_order(bool useBuilder, bool useSco if (useBuilder) { var result = entityBuilder.HasIndex( - new List - { - "OrderId" - }, ConfigurationSource.Convention); + new List { "OrderId" }, ConfigurationSource.Convention); Assert.Equal(!useScope, result == null); } @@ -2105,10 +2099,7 @@ public void OnIndexRemoved_calls_conventions_in_order(bool useScope) var builder = new InternalModelBuilder(new Model(conventions)); var entityBuilder = builder.Entity(typeof(Order), ConfigurationSource.Convention); var index = entityBuilder.HasIndex( - new List - { - "OrderId" - }, ConfigurationSource.Convention).Metadata; + new List { "OrderId" }, ConfigurationSource.Convention).Metadata; var scope = useScope ? builder.Metadata.ConventionDispatcher.DelayConventions() : null; @@ -2170,10 +2161,7 @@ public void OnIndexUniquenessChanged_calls_conventions_in_order(bool useBuilder, var builder = new InternalModelBuilder(new Model(conventions)); var entityBuilder = builder.Entity(typeof(Order), ConfigurationSource.Convention); var index = entityBuilder.HasIndex( - new List - { - "OrderId" - }, ConfigurationSource.Convention).Metadata; + new List { "OrderId" }, ConfigurationSource.Convention).Metadata; var scope = useScope ? builder.Metadata.ConventionDispatcher.DelayConventions() : null; diff --git a/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs index 4b8dd84c4ec..ee1a2f54fea 100644 --- a/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs @@ -213,7 +213,8 @@ public void Matches_navigation_plus_Id_property() public void Matches_principal_type_plus_PK_name_property() { var dependentTypeBuilder = DependentType.Builder; - var fkProperty = dependentTypeBuilder.Property(DependentEntity.PrincipalEntityPeEKaYProperty, ConfigurationSource.Convention).Metadata; + var fkProperty = dependentTypeBuilder.Property(DependentEntity.PrincipalEntityPeEKaYProperty, ConfigurationSource.Convention) + .Metadata; dependentTypeBuilder.Property(DependentEntity.PrincipalEntityIDProperty, ConfigurationSource.Convention); dependentTypeBuilder.Property(DependentEntity.PeEKaYProperty, ConfigurationSource.Convention); @@ -238,7 +239,8 @@ public void Matches_principal_type_plus_PK_name_property() public void Matches_principal_type_plus_Id_property() { var dependentTypeBuilder = DependentType.Builder; - var fkProperty = dependentTypeBuilder.Property(DependentEntity.PrincipalEntityIDProperty, ConfigurationSource.Convention).Metadata; + var fkProperty = dependentTypeBuilder.Property(DependentEntity.PrincipalEntityIDProperty, ConfigurationSource.Convention) + .Metadata; dependentTypeBuilder.Property(DependentEntity.PeEKaYProperty, ConfigurationSource.Convention); var relationshipBuilder = dependentTypeBuilder.HasRelationship( @@ -369,7 +371,7 @@ public void Does_not_match_PK_name_properties() dependentTypeBuilder.Property( DependentEntityWithCompositeKey.IdProperty, ConfigurationSource.Convention); dependentTypeBuilder.Property( - DependentEntityWithCompositeKey.NameProperty, ConfigurationSource.Convention) + DependentEntityWithCompositeKey.NameProperty, ConfigurationSource.Convention) .IsRequired(true, ConfigurationSource.Convention); var relationshipBuilder = dependentTypeBuilder.HasRelationship( @@ -395,14 +397,14 @@ public void Does_not_match_PK_name_properties_if_subset_of_dependent_PK_and_cont { var dependentTypeBuilder = DependentTypeWithCompositeKey.Builder; var pkProperty1 = dependentTypeBuilder.Property( - DependentEntityWithCompositeKey.IdProperty, ConfigurationSource.Convention) + DependentEntityWithCompositeKey.IdProperty, ConfigurationSource.Convention) .Metadata; var pkProperty2 = dependentTypeBuilder.Property( - DependentEntityWithCompositeKey.NameProperty, ConfigurationSource.Convention) + DependentEntityWithCompositeKey.NameProperty, ConfigurationSource.Convention) .IsRequired(true, ConfigurationSource.Convention) .Metadata; var pkProperty3 = dependentTypeBuilder.Property( - DependentEntityWithCompositeKey.NavPropIdProperty, ConfigurationSource.Convention) + DependentEntityWithCompositeKey.NavPropIdProperty, ConfigurationSource.Convention) .Metadata; dependentTypeBuilder.PrimaryKey(new[] { pkProperty1, pkProperty2, pkProperty3 }, ConfigurationSource.Explicit); @@ -431,11 +433,11 @@ public void Matches_PK_name_properties_if_subset_of_dependent_PK() var dependentTypeBuilder = DependentType.Builder; dependentTypeBuilder.PrimaryKey(new[] { DependentEntity.PrincipalEntityPeEKaYProperty }, ConfigurationSource.Explicit); var pkProperty = dependentTypeBuilder.Property( - DependentEntity.IDProperty, ConfigurationSource.Convention) + DependentEntity.IDProperty, ConfigurationSource.Convention) .IsRequired(true, ConfigurationSource.Convention) .Metadata; var fkProperty = dependentTypeBuilder.Property( - DependentEntity.PeEKaYProperty, ConfigurationSource.Convention) + DependentEntity.PeEKaYProperty, ConfigurationSource.Convention) .Metadata; dependentTypeBuilder.PrimaryKey(new[] { pkProperty, fkProperty }, ConfigurationSource.Explicit); @@ -854,7 +856,8 @@ public void Inverts_if_principal_entity_type_can_have_non_pk_fk_property() [ConditionalFact] public void Does_not_invert_if_weak_entity_type_can_have_non_pk_fk_property() { - var fkProperty = DependentType.Builder.Property(DependentEntity.PrincipalEntityPeEKaYProperty, ConfigurationSource.Convention).Metadata; + var fkProperty = DependentType.Builder.Property(DependentEntity.PrincipalEntityPeEKaYProperty, ConfigurationSource.Convention) + .Metadata; var relationshipBuilder = DependentType.Builder.HasRelationship(PrincipalType, ConfigurationSource.Convention) .IsUnique(true, ConfigurationSource.Convention); diff --git a/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs index 13ea5ef3c16..7a27ab62c4a 100644 --- a/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs @@ -344,9 +344,10 @@ public void InversePropertyAttribute_does_not_configure_ambiguous_navigations() nav => nav.Name == nameof(AmbiguousDependent.AnotherAmbiguousPrincipal)); var convention = new InversePropertyAttributeConvention(CreateDependencies(CreateLogger())); - convention.ProcessEntityTypeAdded(dependentEntityTypeBuilder, + convention.ProcessEntityTypeAdded( + dependentEntityTypeBuilder, new ConventionContext( - dependentEntityTypeBuilder.Metadata.Model.ConventionDispatcher)); + dependentEntityTypeBuilder.Metadata.Model.ConventionDispatcher)); Assert.DoesNotContain( principalEntityTypeBuilder.Metadata.GetNavigations(), @@ -388,9 +389,10 @@ public void InversePropertyAttribute_does_not_configure_non_defining_navigation( Assert.Contains(dependentEntityTypeBuilder.Metadata.GetNavigations(), nav => nav.Name == nameof(Dependent.Principal)); var convention = new InversePropertyAttributeConvention(CreateDependencies(CreateLogger())); - convention.ProcessEntityTypeAdded(dependentEntityTypeBuilder, + convention.ProcessEntityTypeAdded( + dependentEntityTypeBuilder, new ConventionContext( - dependentEntityTypeBuilder.Metadata.Model.ConventionDispatcher)); + dependentEntityTypeBuilder.Metadata.Model.ConventionDispatcher)); var logEntry = ListLoggerFactory.Log.Single(); Assert.Equal(LogLevel.Warning, logEntry.Level); @@ -421,17 +423,19 @@ public void InversePropertyAttribute_does_not_configure_non_ownership_navigation Assert.DoesNotContain(dependentEntityTypeBuilder.Metadata.GetNavigations(), nav => nav.Name == nameof(Dependent.Principal)); var convention = new InversePropertyAttributeConvention(CreateDependencies(CreateLogger())); - convention.ProcessEntityTypeAdded(dependentEntityTypeBuilder, + convention.ProcessEntityTypeAdded( + dependentEntityTypeBuilder, new ConventionContext( - dependentEntityTypeBuilder.Metadata.Model.ConventionDispatcher)); + dependentEntityTypeBuilder.Metadata.Model.ConventionDispatcher)); Assert.Contains(principalEntityTypeBuilder.Metadata.GetNavigations(), nav => nav.Name == nameof(Principal.Dependents)); Assert.DoesNotContain(principalEntityTypeBuilder.Metadata.GetNavigations(), nav => nav.Name == nameof(Principal.Dependent)); Assert.DoesNotContain(dependentEntityTypeBuilder.Metadata.GetNavigations(), nav => nav.Name == nameof(Dependent.Principal)); - convention.ProcessModelFinalized(dependentEntityTypeBuilder.ModelBuilder, + convention.ProcessModelFinalized( + dependentEntityTypeBuilder.ModelBuilder, new ConventionContext( - dependentEntityTypeBuilder.Metadata.Model.ConventionDispatcher)); + dependentEntityTypeBuilder.Metadata.Model.ConventionDispatcher)); var logEntry = ListLoggerFactory.Log.Single(); Assert.Equal(LogLevel.Warning, logEntry.Level); @@ -506,10 +510,7 @@ public void ForeignKeyAttribute_overrides_configuration_from_convention_source() ConfigurationSource.Convention) .HasForeignKey( dependentEntityTypeBuilder.GetOrCreateProperties( - new List - { - Dependent.PrincipalIdProperty - }, ConfigurationSource.Convention), + new List { Dependent.PrincipalIdProperty }, ConfigurationSource.Convention), ConfigurationSource.Convention); Assert.Equal("PrincipalId", relationshipBuilder.Metadata.Properties.First().Name); @@ -533,10 +534,7 @@ public void ForeignKeyAttribute_does_not_override_configuration_from_explicit_so ConfigurationSource.Convention) .HasForeignKey( dependentEntityTypeBuilder.GetOrCreateProperties( - new List - { - Dependent.PrincipalIdProperty - }, ConfigurationSource.Convention), + new List { Dependent.PrincipalIdProperty }, ConfigurationSource.Convention), ConfigurationSource.Explicit); Assert.Equal("PrincipalId", relationshipBuilder.Metadata.Properties.First().Name); @@ -560,10 +558,7 @@ public void ForeignKeyAttribute_sets_foreign_key_properties_when_applied_on_depe ConfigurationSource.Convention) .HasForeignKey( dependentEntityTypeBuilder.GetOrCreateProperties( - new List - { - Dependent.PrincipalIdProperty - }, ConfigurationSource.Convention), + new List { Dependent.PrincipalIdProperty }, ConfigurationSource.Convention), ConfigurationSource.Convention); Assert.Equal("PrincipalId", relationshipBuilder.Metadata.Properties.First().Name); @@ -587,10 +582,7 @@ public void ForeignKeyAttribute_sets_foreign_key_properties_when_applied_on_prin ConfigurationSource.Convention) .HasForeignKey( dependentEntityTypeBuilder.GetOrCreateProperties( - new List - { - Dependent.PrincipalIdProperty - }, ConfigurationSource.Convention), + new List { Dependent.PrincipalIdProperty }, ConfigurationSource.Convention), ConfigurationSource.Convention); Assert.Equal("PrincipalId", relationshipBuilder.Metadata.Properties.First().Name); @@ -614,10 +606,7 @@ public void ForeignKeyAttribute_sets_foreign_key_properties_when_applied_on_prop ConfigurationSource.Convention) .HasForeignKey( dependentEntityTypeBuilder.GetOrCreateProperties( - new List - { - Dependent.PrincipalIdProperty - }, ConfigurationSource.Convention), + new List { Dependent.PrincipalIdProperty }, ConfigurationSource.Convention), ConfigurationSource.Convention); Assert.Equal("PrincipalId", relationshipBuilder.Metadata.Properties.First().Name); @@ -641,10 +630,7 @@ public void ForeignKeyAttribute_on_field_sets_foreign_key_properties_when_applie ConfigurationSource.Convention) .HasForeignKey( dependentEntityTypeBuilder.GetOrCreateProperties( - new List - { - DependentField.PrincipalIdProperty - }, ConfigurationSource.Convention), + new List { DependentField.PrincipalIdProperty }, ConfigurationSource.Convention), ConfigurationSource.Convention); Assert.Equal("PrincipalFieldId", relationshipBuilder.Metadata.Properties.First().Name); @@ -668,10 +654,7 @@ public void ForeignKeyAttribute_sets_foreign_key_properties_after_inverting_when ConfigurationSource.Convention) .HasForeignKey( dependentEntityTypeBuilder.GetOrCreateProperties( - new List - { - Principal.DependentIdProperty - }, ConfigurationSource.Convention), + new List { Principal.DependentIdProperty }, ConfigurationSource.Convention), ConfigurationSource.Convention); Assert.Equal("DependentId", relationshipBuilder.Metadata.Properties.First().Name); @@ -699,10 +682,7 @@ public void ForeignKeyAttribute_sets_composite_foreign_key_properties_when_appli ConfigurationSource.Convention) .HasForeignKey( dependentEntityTypeBuilder.GetOrCreateProperties( - new List - { - Dependent.PrincipalIdProperty - }, ConfigurationSource.Convention), + new List { Dependent.PrincipalIdProperty }, ConfigurationSource.Convention), ConfigurationSource.Convention); Assert.Equal("PrincipalId", relationshipBuilder.Metadata.Properties.First().Name); @@ -904,7 +884,8 @@ private ModelBuilder CreateModelBuilder() } private static ProviderConventionSetBuilderDependencies CreateDependencies(DiagnosticsLogger logger) - => InMemoryTestHelpers.Instance.CreateContextServices().GetRequiredService().With(logger); + => InMemoryTestHelpers.Instance.CreateContextServices().GetRequiredService() + .With(logger); private DiagnosticsLogger CreateLogger() { diff --git a/test/EFCore.Tests/Metadata/Conventions/NonNullableNavigationConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/NonNullableNavigationConventionTest.cs index 213030e5333..f457d0e9c59 100644 --- a/test/EFCore.Tests/Metadata/Conventions/NonNullableNavigationConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/NonNullableNavigationConventionTest.cs @@ -141,7 +141,6 @@ public void Non_nullability_inverts_when_navigation_to_dependent() Assert.Equal(nameof(Principal), navigation.ForeignKey.DeclaringEntityType.DisplayName()); Assert.True(navigation.ForeignKey.IsRequired); - var logEntry = ListLoggerFactory.Log.Single(); Assert.Equal(LogLevel.Debug, logEntry.Level); Assert.Equal( diff --git a/test/EFCore.Tests/Metadata/Conventions/NonNullableReferencePropertyConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/NonNullableReferencePropertyConventionTest.cs index ef4aa7aa29d..91effdd68d4 100644 --- a/test/EFCore.Tests/Metadata/Conventions/NonNullableReferencePropertyConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/NonNullableReferencePropertyConventionTest.cs @@ -56,21 +56,17 @@ public void Non_nullability_sets_is_nullable_with_conventional_builder() [ConditionalTheory] [InlineData(typeof(A), nameof(A.NonNullable), false)] [InlineData(typeof(A), nameof(A.Nullable), true)] - [InlineData(typeof(A), nameof(A.NonNullablePropertyMaybeNull), true)] [InlineData(typeof(A), nameof(A.NonNullablePropertyAllowNull), false)] [InlineData(typeof(A), nameof(A.NullablePropertyNotNull), true)] [InlineData(typeof(A), nameof(A.NullablePropertyDisallowNull), true)] - [InlineData(typeof(A), nameof(A.NonNullableFieldMaybeNull), true)] [InlineData(typeof(A), nameof(A.NonNullableFieldAllowNull), false)] [InlineData(typeof(A), nameof(A.NullableFieldNotNull), true)] [InlineData(typeof(A), nameof(A.NullableFieldDisallowNull), true)] - [InlineData(typeof(A), nameof(A.RequiredAndNullable), false)] [InlineData(typeof(A), nameof(A.NullObliviousNonNullable), true)] [InlineData(typeof(A), nameof(A.NullObliviousNullable), true)] - [InlineData(typeof(B), nameof(B.NonNullableValueType), false)] [InlineData(typeof(B), nameof(B.NullableValueType), true)] [InlineData(typeof(B), nameof(B.NonNullableRefType), false)] @@ -111,24 +107,30 @@ private class A public int Id { get; set; } #nullable enable - public string NonNullable { get; set; } = ""; + public string NonNullable { get; } = ""; public string? Nullable { get; set; } [MaybeNull] - public string NonNullablePropertyMaybeNull { get; set; } = ""; + public string NonNullablePropertyMaybeNull { get; } = ""; + [AllowNull] - public string NonNullablePropertyAllowNull { get; set; } = ""; + public string NonNullablePropertyAllowNull { get; } = ""; + [NotNull] - public string? NullablePropertyNotNull { get; set; } = ""; + public string? NullablePropertyNotNull { get; } = ""; + [DisallowNull] - public string? NullablePropertyDisallowNull { get; set; } = ""; + public string? NullablePropertyDisallowNull { get; } = ""; [MaybeNull] public string NonNullableFieldMaybeNull = ""; + [AllowNull] public string NonNullableFieldAllowNull = ""; + [NotNull] public string? NullableFieldNotNull = ""; + [DisallowNull] public string? NullableFieldDisallowNull = ""; @@ -145,7 +147,9 @@ private class A #nullable enable public class B { - [Key] public Guid NonNullableValueType { get; set; } + [Key] + public Guid NonNullableValueType { get; set; } + public Guid? NullableValueType { get; set; } public string NonNullableRefType { get; set; } = ""; public string? NullableRefType { get; set; } diff --git a/test/EFCore.Tests/Metadata/Conventions/PropertyAttributeConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/PropertyAttributeConventionTest.cs index dd064781346..5b135cc3602 100644 --- a/test/EFCore.Tests/Metadata/Conventions/PropertyAttributeConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/PropertyAttributeConventionTest.cs @@ -133,10 +133,7 @@ public void KeyAttribute_overrides_configuration_from_convention_source() var propertyBuilder = entityTypeBuilder.Property(typeof(int), "MyPrimaryKey", ConfigurationSource.Explicit); entityTypeBuilder.PrimaryKey( - new List - { - "Id" - }, ConfigurationSource.Convention); + new List { "Id" }, ConfigurationSource.Convention); RunConvention(propertyBuilder); @@ -151,10 +148,7 @@ public void KeyAttribute_does_not_override_configuration_from_explicit_source() var propertyBuilder = entityTypeBuilder.Property(typeof(int), "MyPrimaryKey", ConfigurationSource.Explicit); entityTypeBuilder.PrimaryKey( - new List - { - "Id" - }, ConfigurationSource.Explicit); + new List { "Id" }, ConfigurationSource.Explicit); RunConvention(propertyBuilder); @@ -235,11 +229,7 @@ public void KeyAttribute_allows_composite_key_with_inheritance() derivedEntityTypeBuilder.HasBaseType(baseEntityTypeBuilder.Metadata, ConfigurationSource.Explicit); baseEntityTypeBuilder.PrimaryKey( - new List - { - "Id", - "Name" - }, ConfigurationSource.Explicit); + new List { "Id", "Name" }, ConfigurationSource.Explicit); Validate(derivedEntityTypeBuilder); @@ -683,11 +673,7 @@ protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBu protected internal override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.Entity().HasKey( - e => new - { - e.MyPrimaryKey, - e.Id - }); + e => new { e.MyPrimaryKey, e.Id }); } } } diff --git a/test/EFCore.Tests/Metadata/Conventions/PropertyMappingValidationConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/PropertyMappingValidationConventionTest.cs index 4ee984ece24..8771e103b93 100644 --- a/test/EFCore.Tests/Metadata/Conventions/PropertyMappingValidationConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/PropertyMappingValidationConventionTest.cs @@ -25,7 +25,8 @@ public virtual void Throws_when_added_property_is_not_of_primitive_type() { var modelBuilder = CreateConventionlessModelBuilder().GetInfrastructure(); var entityTypeBuilder = modelBuilder.Entity(typeof(NonPrimitiveAsPropertyEntity), ConfigurationSource.Convention); - entityTypeBuilder.Property(typeof(NavigationAsProperty), nameof(NonPrimitiveAsPropertyEntity.Property), ConfigurationSource.Convention); + entityTypeBuilder.Property( + typeof(NavigationAsProperty), nameof(NonPrimitiveAsPropertyEntity.Property), ConfigurationSource.Convention); Assert.Equal( CoreStrings.PropertyNotMapped( @@ -208,10 +209,7 @@ protected virtual Action CreatePropertyMappingValidator() { ((Model)m).FinalizeModel(); validatePropertyMappingMethod.Invoke( - validator, new object[] - { - m, logger - }); + validator, new object[] { m, logger }); } catch (TargetInvocationException exception) { diff --git a/test/EFCore.Tests/Metadata/Conventions/RelationshipDiscoveryConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/RelationshipDiscoveryConventionTest.cs index 5e2f596d607..1063a24bea9 100644 --- a/test/EFCore.Tests/Metadata/Conventions/RelationshipDiscoveryConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/RelationshipDiscoveryConventionTest.cs @@ -291,7 +291,8 @@ public void Existing_relationship_removes_ambiguity_if_higher_source() typeof(MultipleNavigationsSecond), ConfigurationSource.Convention); entityBuilderFirst.HasRelationship( - entityBuilderSecond.Metadata, MultipleNavigationsFirst.CollectionNavigationProperty, null, ConfigurationSource.DataAnnotation); + entityBuilderSecond.Metadata, MultipleNavigationsFirst.CollectionNavigationProperty, null, + ConfigurationSource.DataAnnotation); Assert.Same(entityBuilderFirst, RunConvention(entityBuilderFirst)); @@ -357,7 +358,8 @@ public void Existing_relationship_removes_ambiguity_in_inverse_if_higher_source( typeof(MultipleNavigationsSecond), ConfigurationSource.Convention); entityBuilderFirst.HasRelationship( - entityBuilderSecond.Metadata, MultipleNavigationsFirst.CollectionNavigationProperty, null, ConfigurationSource.DataAnnotation); + entityBuilderSecond.Metadata, MultipleNavigationsFirst.CollectionNavigationProperty, null, + ConfigurationSource.DataAnnotation); Assert.Same(entityBuilderSecond, RunConvention(entityBuilderSecond)); @@ -1116,7 +1118,8 @@ private RelationshipDiscoveryConvention CreateRelationshipDiscoveryConvention() private void Cleanup(InternalModelBuilder modelBuilder) { new ModelCleanupConvention(CreateDependencies()) - .ProcessModelFinalized(modelBuilder, + .ProcessModelFinalized( + modelBuilder, new ConventionContext(modelBuilder.Metadata.ConventionDispatcher)); } diff --git a/test/EFCore.Tests/Metadata/Conventions/ServicePropertyDiscoveryConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/ServicePropertyDiscoveryConventionTest.cs index 1bf5b36a4bf..20bf72ab652 100644 --- a/test/EFCore.Tests/Metadata/Conventions/ServicePropertyDiscoveryConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/ServicePropertyDiscoveryConventionTest.cs @@ -94,14 +94,16 @@ public void Finds_service_property_duplicate_ignored() private void Validate(EntityType entityType) { var convention = CreateServicePropertyDiscoveryConvention(); - convention.ProcessModelFinalized(entityType.Model.Builder, + convention.ProcessModelFinalized( + entityType.Model.Builder, new ConventionContext(entityType.Model.ConventionDispatcher)); } private void RunConvention(EntityType entityType, string ignoredMember) { var convention = CreateServicePropertyDiscoveryConvention(); - convention.ProcessEntityTypeMemberIgnored(entityType.Builder, ignoredMember, + convention.ProcessEntityTypeMemberIgnored( + entityType.Builder, ignoredMember, new ConventionContext(entityType.Model.ConventionDispatcher)); } diff --git a/test/EFCore.Tests/Metadata/Conventions/ValueGeneratorConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/ValueGeneratorConventionTest.cs index 13f4615cd80..2d1eed99ac4 100644 --- a/test/EFCore.Tests/Metadata/Conventions/ValueGeneratorConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/ValueGeneratorConventionTest.cs @@ -44,11 +44,7 @@ public void RequiresValueGenerator_flag_is_set_for_key_properties_that_use_value var modelBuilder = CreateInternalModelBuilder(); var entityBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention); - var properties = new List - { - "Id", - "Name" - }; + var properties = new List { "Id", "Name" }; entityBuilder.Property(properties[0], ConfigurationSource.Convention) .ValueGenerated(ValueGenerated.OnAdd, ConfigurationSource.Explicit); @@ -74,10 +70,7 @@ public void RequiresValueGenerator_flag_is_not_set_for_foreign_key() var principalEntityBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention); var referencedEntityBuilder = modelBuilder.Entity(typeof(ReferencedEntity), ConfigurationSource.Convention); - var properties = new List - { - "SampleEntityId" - }; + var properties = new List { "SampleEntityId" }; referencedEntityBuilder.Property(properties[0], ConfigurationSource.Convention); @@ -104,11 +97,7 @@ public void RequiresValueGenerator_flag_is_set_for_property_which_are_not_part_o var principalEntityBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention); var referencedEntityBuilder = modelBuilder.Entity(typeof(ReferencedEntity), ConfigurationSource.Convention); - var properties = new List - { - "Id", - "SampleEntityId" - }; + var properties = new List { "Id", "SampleEntityId" }; referencedEntityBuilder.Property(properties[0], ConfigurationSource.Convention) .ValueGenerated(ValueGenerated.OnAdd, ConfigurationSource.Explicit); referencedEntityBuilder.Property(properties[1], ConfigurationSource.Convention) @@ -137,11 +126,7 @@ public void RequiresValueGenerator_flag_is_not_set_for_properties_which_are_part var principalEntityBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention); var referencedEntityBuilder = modelBuilder.Entity(typeof(ReferencedEntity), ConfigurationSource.Convention); - var properties = new List - { - "Id", - "SampleEntityId" - }; + var properties = new List { "Id", "SampleEntityId" }; referencedEntityBuilder.Property(properties[0], ConfigurationSource.Convention) .ValueGenerated(ValueGenerated.OnAdd, ConfigurationSource.Explicit); @@ -167,10 +152,7 @@ public void KeyConvention_does_not_override_ValueGenerated_when_configured_expli var modelBuilder = CreateInternalModelBuilder(); var entityBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention); - var properties = new List - { - "Id" - }; + var properties = new List { "Id" }; entityBuilder.Property(properties[0], ConfigurationSource.Convention) .ValueGenerated(ValueGenerated.OnAdd, ConfigurationSource.Explicit); @@ -192,10 +174,7 @@ public void RequiresValueGenerator_flag_is_turned_off_when_foreign_key_is_added( var principalEntityBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention); var referencedEntityBuilder = modelBuilder.Entity(typeof(ReferencedEntity), ConfigurationSource.Convention); - var properties = new List - { - "SampleEntityId" - }; + var properties = new List { "SampleEntityId" }; referencedEntityBuilder.Property(properties[0], ConfigurationSource.Convention); @@ -226,10 +205,7 @@ public void RequiresValueGenerator_flag_is_set_when_foreign_key_is_removed() var principalEntityBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention); var referencedEntityBuilder = modelBuilder.Entity(typeof(ReferencedEntity), ConfigurationSource.Convention); - var properties = new List - { - "SampleEntityId" - }; + var properties = new List { "SampleEntityId" }; referencedEntityBuilder.Property(properties[0], ConfigurationSource.Convention); @@ -270,10 +246,7 @@ public void Identity_is_set_for_primary_key() var entityBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention); var keyBuilder = entityBuilder.PrimaryKey( - new List - { - "Id" - }, ConfigurationSource.Convention); + new List { "Id" }, ConfigurationSource.Convention); RunConvention(entityBuilder); @@ -289,10 +262,7 @@ public void Identity_is_not_set_for_non_primary_key() var entityBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention); var keyBuilder = entityBuilder.HasKey( - new List - { - "Number" - }, ConfigurationSource.Convention); + new List { "Number" }, ConfigurationSource.Convention); RunConvention(entityBuilder); @@ -308,11 +278,7 @@ public void Identity_not_set_when_composite_primary_key() var entityBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention); var keyBuilder = entityBuilder.PrimaryKey( - new List - { - "Id", - "Number" - }, ConfigurationSource.Convention); + new List { "Id", "Number" }, ConfigurationSource.Convention); RunConvention(entityBuilder); @@ -329,10 +295,7 @@ public void Identity_not_set_when_primary_key_property_is_string() var entityBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention); var keyBuilder = entityBuilder.PrimaryKey( - new List - { - "Name" - }, ConfigurationSource.Convention); + new List { "Name" }, ConfigurationSource.Convention); var property = keyBuilder.Metadata.Properties.First(); @@ -386,10 +349,7 @@ public void Identity_is_recomputed_when_primary_key_is_changed() Assert.Equal(ValueGenerated.Never, numberProperty.ValueGenerated); var keyBuilder = entityBuilder.PrimaryKey( - new List - { - "Number" - }, ConfigurationSource.Convention); + new List { "Number" }, ConfigurationSource.Convention); Assert.NotNull(keyBuilder); Assert.Same(idProperty, entityBuilder.Metadata.FindProperty("Id")); @@ -414,10 +374,7 @@ public void Convention_does_not_override_None_when_configured_explicitly() .ValueGenerated(ValueGenerated.Never, ConfigurationSource.Explicit); var keyBuilder = entityBuilder.PrimaryKey( - new List - { - "Id" - }, ConfigurationSource.Convention); + new List { "Id" }, ConfigurationSource.Convention); RunConvention(entityBuilder); @@ -434,10 +391,7 @@ public void Identity_is_removed_when_foreign_key_is_added() var principalEntityBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention); var referencedEntityBuilder = modelBuilder.Entity(typeof(ReferencedEntity), ConfigurationSource.Convention); - var properties = new List - { - "Id" - }; + var properties = new List { "Id" }; var keyBuilder = referencedEntityBuilder.PrimaryKey(properties, ConfigurationSource.Convention); RunConvention(referencedEntityBuilder); @@ -464,10 +418,7 @@ public void Identity_is_added_when_foreign_key_is_removed_and_key_is_primary_key var principalEntityBuilder = modelBuilder.Entity(typeof(SampleEntity), ConfigurationSource.Convention); var referencedEntityBuilder = modelBuilder.Entity(typeof(ReferencedEntity), ConfigurationSource.Convention); - var properties = new List - { - "Id" - }; + var properties = new List { "Id" }; var keyBuilder = referencedEntityBuilder.PrimaryKey(properties, ConfigurationSource.Convention); RunConvention(referencedEntityBuilder); @@ -514,8 +465,9 @@ private static void RunConvention(InternalRelationshipBuilder foreignKeyBuilder) private static void RunConvention(InternalEntityTypeBuilder entityBuilder, ForeignKey foreignKey) { new ValueGenerationConvention(CreateDependencies()) - .ProcessForeignKeyRemoved(entityBuilder, foreignKey, - new ConventionContext(entityBuilder.Metadata.Model.ConventionDispatcher)); + .ProcessForeignKeyRemoved( + entityBuilder, foreignKey, + new ConventionContext(entityBuilder.Metadata.Model.ConventionDispatcher)); } private static ProviderConventionSetBuilderDependencies CreateDependencies() diff --git a/test/EFCore.Tests/Metadata/Internal/ClrCollectionAccessorFactoryTest.cs b/test/EFCore.Tests/Metadata/Internal/ClrCollectionAccessorFactoryTest.cs index acd0b6f3306..2bd25aeb035 100644 --- a/test/EFCore.Tests/Metadata/Internal/ClrCollectionAccessorFactoryTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ClrCollectionAccessorFactoryTest.cs @@ -257,8 +257,7 @@ public void Delegate_accessor_always_creates_collections_that_use_reference_equa var accessor = new ClrCollectionAccessorFactory().Create(navigation); var entity = new MyEntity(initialize: false); - var value = new MyEntityWithCustomComparer - { Id = 1 }; + var value = new MyEntityWithCustomComparer { Id = 1 }; Assert.False(accessor.Contains(entity, value)); diff --git a/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs b/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs index e3b732bd98b..b87650fa6eb 100644 --- a/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs @@ -48,10 +48,7 @@ public void Delegate_getter_is_returned_for_IProperty_property() Assert.Equal( 7, new ClrPropertyGetterFactory().Create(idProperty).GetClrValue( - new Customer - { - Id = 7 - })); + new Customer { Id = 7 })); } [ConditionalFact] @@ -59,10 +56,7 @@ public void Delegate_getter_is_returned_for_property_info() { Assert.Equal( 7, new ClrPropertyGetterFactory().Create(typeof(Customer).GetAnyProperty("Id")).GetClrValue( - new Customer - { - Id = 7 - })); + new Customer { Id = 7 })); } [ConditionalFact] @@ -76,11 +70,7 @@ public void Delegate_getter_is_returned_for_IProperty_struct_property() Assert.Equal( new Fuel(1.0), new ClrPropertyGetterFactory().Create(fuelProperty).GetClrValue( - new Customer - { - Id = 7, - Fuel = new Fuel(1.0) - })); + new Customer { Id = 7, Fuel = new Fuel(1.0) })); } [ConditionalFact] @@ -89,11 +79,7 @@ public void Delegate_getter_is_returned_for_struct_property_info() Assert.Equal( new Fuel(1.0), new ClrPropertyGetterFactory().Create(typeof(Customer).GetAnyProperty("Fuel")).GetClrValue( - new Customer - { - Id = 7, - Fuel = new Fuel(1.0) - })); + new Customer { Id = 7, Fuel = new Fuel(1.0) })); } private class Customer diff --git a/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs b/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs index eb3e78361ee..79d9c78bb56 100644 --- a/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs @@ -48,10 +48,7 @@ public void Delegate_setter_is_returned_for_IProperty_property() var entityType = CreateModel().AddEntityType(typeof(Customer)); var idProperty = entityType.AddProperty(Customer.IdProperty); - var customer = new Customer - { - Id = 7 - }; + var customer = new Customer { Id = 7 }; new ClrPropertySetterFactory().Create(idProperty).SetClrValue(customer, 77); @@ -61,10 +58,7 @@ public void Delegate_setter_is_returned_for_IProperty_property() [ConditionalFact] public void Delegate_setter_is_returned_for_property_type_and_name() { - var customer = new Customer - { - Id = 7 - }; + var customer = new Customer { Id = 7 }; new ClrPropertySetterFactory().Create(typeof(Customer).GetAnyProperty("Id")).SetClrValue(customer, 77); @@ -77,10 +71,7 @@ public void Delegate_setter_can_set_value_type_property() var entityType = CreateModel().AddEntityType(typeof(Customer)); var idProperty = entityType.AddProperty(Customer.IdProperty); - var customer = new Customer - { - Id = 7 - }; + var customer = new Customer { Id = 7 }; new ClrPropertySetterFactory().Create(idProperty).SetClrValue(customer, 1); @@ -93,10 +84,7 @@ public void Delegate_setter_can_set_reference_type_property() var entityType = CreateModel().AddEntityType(typeof(Customer)); var idProperty = entityType.AddProperty(Customer.ContentProperty); - var customer = new Customer - { - Id = 7 - }; + var customer = new Customer { Id = 7 }; new ClrPropertySetterFactory().Create(idProperty).SetClrValue(customer, "MyString"); @@ -109,10 +97,7 @@ public void Delegate_setter_can_set_nullable_property() var entityType = CreateModel().AddEntityType(typeof(Customer)); var idProperty = entityType.AddProperty(Customer.OptionalIntProperty); - var customer = new Customer - { - Id = 7 - }; + var customer = new Customer { Id = 7 }; new ClrPropertySetterFactory().Create(idProperty).SetClrValue(customer, 3); @@ -125,10 +110,7 @@ public void Delegate_setter_can_set_nullable_property_with_null_value() var entityType = CreateModel().AddEntityType(typeof(Customer)); var idProperty = entityType.AddProperty(Customer.OptionalIntProperty); - var customer = new Customer - { - Id = 7 - }; + var customer = new Customer { Id = 7 }; new ClrPropertySetterFactory().Create(idProperty).SetClrValue(customer, null); @@ -141,10 +123,7 @@ public void Delegate_setter_can_set_enum_property() var entityType = CreateModel().AddEntityType(typeof(Customer)); var idProperty = entityType.AddProperty(Customer.FlagProperty); - var customer = new Customer - { - Id = 7 - }; + var customer = new Customer { Id = 7 }; new ClrPropertySetterFactory().Create(idProperty).SetClrValue(customer, Flag.One); @@ -157,10 +136,7 @@ public void Delegate_setter_can_set_nullable_enum_property() var entityType = CreateModel().AddEntityType(typeof(Customer)); var idProperty = entityType.AddProperty(Customer.OptionalFlagProperty); - var customer = new Customer - { - Id = 7 - }; + var customer = new Customer { Id = 7 }; new ClrPropertySetterFactory().Create(idProperty).SetClrValue(customer, Flag.Two); diff --git a/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs b/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs index 370e08ed351..4d50c0c24fa 100644 --- a/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs @@ -144,10 +144,7 @@ public void Can_create_materializer_for_entity_with_instance_factory_method() = new FactoryMethodBinding( TestProxyFactory.Instance, typeof(TestProxyFactory).GetTypeInfo().GetDeclaredMethod(nameof(TestProxyFactory.Create)), - new List - { - new EntityTypeParameterBinding() - }, + new List { new EntityTypeParameterBinding() }, entityType.ClrType); ((Model)entityType.Model).FinalizeModel(); @@ -291,7 +288,8 @@ public void Throws_if_parameterless_constructor_is_not_defined_on_entity_type() Assert.Equal( CoreStrings.NoParameterlessConstructor(typeof(EntityWithoutParameterlessConstructor).Name), - Assert.Throws(() => GetMaterializer(new EntityMaterializerSource(new EntityMaterializerSourceDependencies()), entityType)).Message); + Assert.Throws( + () => GetMaterializer(new EntityMaterializerSource(new EntityMaterializerSourceDependencies()), entityType)).Message); } private static readonly ParameterExpression _contextParameter @@ -322,10 +320,7 @@ public SomeEntity(int id, Guid? goo) } public static SomeEntity Factory(int id, Guid? goo) - => new SomeEntity(id, goo) - { - FactoryUsed = true - }; + => new SomeEntity(id, goo) { FactoryUsed = true }; public static SomeEntity GeneralFactory(object[] constructorArguments) { diff --git a/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs b/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs index c1eb9c2c974..5bedcf3cc0a 100644 --- a/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs @@ -1178,7 +1178,7 @@ public void Can_add_retrieve_and_remove_indexes() Assert.Same(property1, index2.Properties[0]); Assert.Same(property2, index2.Properties[1]); Assert.True(property1.IsIndex()); - Assert.Equal(new [] { index1, index2 }, property1.GetContainingIndexes().ToArray()); + Assert.Equal(new[] { index1, index2 }, property1.GetContainingIndexes().ToArray()); Assert.Equal(2, entityType.GetIndexes().Count()); Assert.Same(index1, entityType.GetIndexes().First()); @@ -2066,7 +2066,8 @@ public void Change_tracking_can_be_set_to_snapshot_only_for_non_notifying_entiti CoreStrings.ChangeTrackingInterfaceMissing( "Customer", "ChangingAndChangedNotificationsWithOriginalValues", "INotifyPropertyChanged"), Assert.Throws( - () => entityType.SetChangeTrackingStrategy(ChangeTrackingStrategy.ChangingAndChangedNotificationsWithOriginalValues)) + () => entityType.SetChangeTrackingStrategy( + ChangeTrackingStrategy.ChangingAndChangedNotificationsWithOriginalValues)) .Message); } @@ -2077,20 +2078,21 @@ public void Entity_type_with_deeply_nested_owned_weak_types_builds_correctly() { var entityTypes = context.Model.GetEntityTypes(); - Assert.Equal(new[] - { - "Application", - "ApplicationVersion", - "Rejection", - "Application.Attitude#Attitude", - "ApplicationVersion.Attitude#Attitude", - "Rejection.FirstTest#FirstTest", - "Application.Attitude#Attitude.FirstTest#FirstTest", - "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest", - "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff", - "Application.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff", - "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff" - }, entityTypes.Select(e => e.DisplayName()).ToList()); + Assert.Equal( + new[] + { + "Application", + "ApplicationVersion", + "Rejection", + "Application.Attitude#Attitude", + "ApplicationVersion.Attitude#Attitude", + "Rejection.FirstTest#FirstTest", + "Application.Attitude#Attitude.FirstTest#FirstTest", + "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest", + "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff", + "Application.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff", + "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff" + }, entityTypes.Select(e => e.DisplayName()).ToList()); } } @@ -2167,92 +2169,104 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) List GetTypeNames() => modelBuilder.Model.GetEntityTypes().Select(e => e.DisplayName()).ToList(); - modelBuilder.Entity(entity => - { - entity.OwnsOne(x => x.Attitude, - amb => - { - amb.OwnsOne(x => x.FirstTest, mb => + modelBuilder.Entity( + entity => + { + entity.OwnsOne( + x => x.Attitude, + amb => { - mb.OwnsOne(a => a.Tester); + amb.OwnsOne( + x => x.FirstTest, mb => + { + mb.OwnsOne(a => a.Tester); + }); }); - }); - entity.OwnsOne(x => x.Rejection, - amb => - { - amb.OwnsOne(x => x.FirstTest, mb => + entity.OwnsOne( + x => x.Rejection, + amb => { - mb.OwnsOne(a => a.Tester); + amb.OwnsOne( + x => x.FirstTest, mb => + { + mb.OwnsOne(a => a.Tester); + }); }); - }); - }); + }); - Assert.Equal(new[] - { - "Application", - "Attitude", - "Rejection", - "Attitude.FirstTest#FirstTest", // FirstTest is weak - "Rejection.FirstTest#FirstTest", // FirstTest is weak - "Attitude.FirstTest#FirstTest.Tester#SpecialistStaff", // SpecialistStaff is weak - "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff" // SpecialistStaff is weak - }, GetTypeNames()); - - modelBuilder.Entity(entity => - { - Assert.Equal(new[] + Assert.Equal( + new[] { "Application", - "ApplicationVersion", "Attitude", "Rejection", - "Attitude.FirstTest#FirstTest", - "Rejection.FirstTest#FirstTest", - "Attitude.FirstTest#FirstTest.Tester#SpecialistStaff", - "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff" + "Attitude.FirstTest#FirstTest", // FirstTest is weak + "Rejection.FirstTest#FirstTest", // FirstTest is weak + "Attitude.FirstTest#FirstTest.Tester#SpecialistStaff", // SpecialistStaff is weak + "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff" // SpecialistStaff is weak }, GetTypeNames()); - entity.OwnsOne(x => x.Attitude, - amb => - { - var typeNames = GetTypeNames(); - Assert.Equal(new[] + modelBuilder.Entity( + entity => + { + Assert.Equal( + new[] { "Application", "ApplicationVersion", + "Attitude", "Rejection", - "Application.Attitude#Attitude", // Attitude becomes weak - "ApplicationVersion.Attitude#Attitude", // Attitude becomes weak + "Attitude.FirstTest#FirstTest", "Rejection.FirstTest#FirstTest", - "Application.Attitude#Attitude.FirstTest#FirstTest", // Attitude becomes weak - "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest", // Attitude becomes weak - "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff", - "Application.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff", // Attitude becomes weak - "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff" // Attitude becomes weak - }, typeNames); - - amb.OwnsOne(x => x.FirstTest, mb => + "Attitude.FirstTest#FirstTest.Tester#SpecialistStaff", + "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff" + }, GetTypeNames()); + + entity.OwnsOne( + x => x.Attitude, + amb => { - mb.OwnsOne(a => a.Tester); + var typeNames = GetTypeNames(); + Assert.Equal( + new[] + { + "Application", + "ApplicationVersion", + "Rejection", + "Application.Attitude#Attitude", // Attitude becomes weak + "ApplicationVersion.Attitude#Attitude", // Attitude becomes weak + "Rejection.FirstTest#FirstTest", + "Application.Attitude#Attitude.FirstTest#FirstTest", // Attitude becomes weak + "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest", // Attitude becomes weak + "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff", + "Application.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff", // Attitude becomes weak + "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff" // Attitude becomes weak + }, typeNames); + + amb.OwnsOne( + x => x.FirstTest, mb => + { + mb.OwnsOne(a => a.Tester); + }); }); - }); - }); + }); - Assert.Equal(new[] - { - "Application", - "ApplicationVersion", - "Rejection", - "Application.Attitude#Attitude", - "ApplicationVersion.Attitude#Attitude", - "Rejection.FirstTest#FirstTest", - "Application.Attitude#Attitude.FirstTest#FirstTest", - "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest", - "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff", - "Application.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff", - "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff" - }, GetTypeNames()); + Assert.Equal( + new[] + { + "Application", + "ApplicationVersion", + "Rejection", + "Application.Attitude#Attitude", + "ApplicationVersion.Attitude#Attitude", + "Rejection.FirstTest#FirstTest", + "Application.Attitude#Attitude.FirstTest#FirstTest", + "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest", + "Rejection.FirstTest#FirstTest.Tester#SpecialistStaff", + "Application.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff", + "ApplicationVersion.Attitude#Attitude.FirstTest#FirstTest.Tester#SpecialistStaff" + }, GetTypeNames()); } } diff --git a/test/EFCore.Tests/Metadata/Internal/ForeignKeyTest.cs b/test/EFCore.Tests/Metadata/Internal/ForeignKeyTest.cs index 94815b4c783..c8c2c4ab280 100644 --- a/test/EFCore.Tests/Metadata/Internal/ForeignKeyTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ForeignKeyTest.cs @@ -114,11 +114,7 @@ public void Constructor_throws_when_principal_and_dependent_property_types_do_no var property2 = principalEntityType.AddProperty("Id1", typeof(int)); var property3 = principalEntityType.AddProperty("Id2", typeof(int)); principalEntityType.SetPrimaryKey( - new[] - { - property2, - property3 - }); + new[] { property2, property3 }); Assert.Equal( CoreStrings.ForeignKeyTypeMismatch("{'P1', 'P2'}", "D", "{'Id1', 'Id2'}", "P"), @@ -186,11 +182,7 @@ public void IsRequired_false_when_no_part_of_composite_FK_is_nullable() var property1 = entityType.AddProperty("Id2", typeof(string)); property1.IsNullable = false; entityType.SetPrimaryKey( - new[] - { - property, - property1 - }); + new[] { property, property1 }); var dependentProp1 = entityType.AddProperty("P1", typeof(int)); var dependentProp2 = entityType.AddProperty("P2", typeof(string)); @@ -212,11 +204,7 @@ public void Setting_IsRequired_to_true_does_not_configure_FK_properties_as_non_n var property3 = entityType.AddProperty("Id2", typeof(string)); property3.IsNullable = false; entityType.SetPrimaryKey( - new[] - { - property, - property3 - }); + new[] { property, property3 }); var dependentProp1 = entityType.AddProperty("P1", typeof(int)); var dependentProp2 = entityType.AddProperty("P2", typeof(string)); @@ -237,11 +225,7 @@ public void Setting_IsRequired_to_false_will_not_configure_FK_properties_as_null var property1 = entityType.AddProperty("Id2", typeof(string)); property1.IsNullable = false; entityType.SetPrimaryKey( - new[] - { - property, - property1 - }); + new[] { property, property1 }); var dependentProp1 = entityType.AddProperty("P1", typeof(int?)); dependentProp1.IsNullable = false; diff --git a/test/EFCore.Tests/Metadata/Internal/IndexTest.cs b/test/EFCore.Tests/Metadata/Internal/IndexTest.cs index 98c9186405e..38cbafb5f1e 100644 --- a/test/EFCore.Tests/Metadata/Internal/IndexTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/IndexTest.cs @@ -53,6 +53,7 @@ public void Constructor_validates_properties_from_same_entity() } private static IMutableModel CreateModel() => new Model(); + private class Customer { public static readonly PropertyInfo IdProperty = typeof(Customer).GetProperty("Id"); diff --git a/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs index 803bc9698e5..d53b62a5516 100644 --- a/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs @@ -29,13 +29,14 @@ public void Relationship_returns_same_instance_for_same_navigations() var principalEntityBuilder = modelBuilder.Entity(typeof(Customer), ConfigurationSource.Explicit); var dependentEntityBuilder = modelBuilder.Entity(typeof(Order), ConfigurationSource.Explicit); - var relationshipBuilder = dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, ConfigurationSource.Explicit).HasNavigation( - Order.CustomerProperty.Name, - pointsToPrincipal: true, - ConfigurationSource.Explicit).HasNavigation( - Customer.OrdersProperty.Name, - pointsToPrincipal: false, - ConfigurationSource.Explicit); + var relationshipBuilder = dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, ConfigurationSource.Explicit) + .HasNavigation( + Order.CustomerProperty.Name, + pointsToPrincipal: true, + ConfigurationSource.Explicit).HasNavigation( + Customer.OrdersProperty.Name, + pointsToPrincipal: false, + ConfigurationSource.Explicit); Assert.NotNull(relationshipBuilder); Assert.Same( @@ -196,10 +197,7 @@ public void ForeignKey_does_not_create_shadow_properties_if_corresponding_princi var customerEntityBuilder = modelBuilder.Entity(typeof(Customer), ConfigurationSource.Explicit); customerEntityBuilder.Property(typeof(int), "ShadowPrimaryKey", ConfigurationSource.Explicit); customerEntityBuilder.PrimaryKey( - new List - { - "ShadowPrimaryKey" - }, ConfigurationSource.Explicit); + new List { "ShadowPrimaryKey" }, ConfigurationSource.Explicit); var orderEntityBuilder = modelBuilder.Entity(typeof(Order), ConfigurationSource.Explicit); Assert.Equal( @@ -218,10 +216,7 @@ public void ForeignKey_creates_shadow_properties_if_corresponding_principal_key_ var customerEntityBuilder = modelBuilder.Entity(typeof(Customer), ConfigurationSource.Explicit); customerEntityBuilder.Property(typeof(int), "ShadowPrimaryKey", ConfigurationSource.Explicit); customerEntityBuilder.PrimaryKey( - new List - { - "ShadowPrimaryKey" - }, ConfigurationSource.Explicit); + new List { "ShadowPrimaryKey" }, ConfigurationSource.Explicit); var orderEntityBuilder = modelBuilder.Entity(typeof(Order), ConfigurationSource.Explicit); var relationshipBuilder = orderEntityBuilder.HasRelationship( @@ -427,8 +422,7 @@ public void Does_not_add_index_on_foreign_key_properties_by_convention() var relationshipBuilder = dependentEntityBuilder.HasRelationship( principalEntityBuilder.Metadata, - new[] - { dependentEntityBuilder.Property(Order.CustomerIdProperty, ConfigurationSource.Convention).Metadata }, + new[] { dependentEntityBuilder.Property(Order.CustomerIdProperty, ConfigurationSource.Convention).Metadata }, ConfigurationSource.Convention); Assert.NotNull(relationshipBuilder); @@ -441,10 +435,7 @@ public void Can_create_foreign_key_on_mix_of_inherited_properties() var modelBuilder = CreateModelBuilder(); var customerEntityTypeBuilder = modelBuilder.Entity(typeof(Customer), ConfigurationSource.Explicit); customerEntityTypeBuilder.PrimaryKey( - new List - { - Customer.IdProperty - }, ConfigurationSource.Explicit); + new List { Customer.IdProperty }, ConfigurationSource.Explicit); var entityBuilder = modelBuilder.Entity(typeof(Order), ConfigurationSource.Explicit); entityBuilder.Property(Order.IdProperty, ConfigurationSource.Convention); @@ -526,8 +517,7 @@ public void Removing_relationship_removes_unused_conventional_index() var relationshipBuilder = dependentEntityBuilder.HasRelationship( principalEntityBuilder.Metadata, - new[] - { dependentEntityBuilder.Property(Order.CustomerIdProperty, ConfigurationSource.Convention).Metadata }, + new[] { dependentEntityBuilder.Property(Order.CustomerIdProperty, ConfigurationSource.Convention).Metadata }, ConfigurationSource.Convention); Assert.NotNull(relationshipBuilder); @@ -547,8 +537,7 @@ public void Removing_relationship_does_not_remove_conventional_index_if_in_use() var relationshipBuilder = dependentEntityBuilder.HasRelationship( principalEntityBuilder.Metadata, - new[] - { dependentEntityBuilder.Property(Order.CustomerIdProperty, ConfigurationSource.Convention).Metadata }, + new[] { dependentEntityBuilder.Property(Order.CustomerIdProperty, ConfigurationSource.Convention).Metadata }, ConfigurationSource.Convention); Assert.NotNull(relationshipBuilder); dependentEntityBuilder.HasIndex(new[] { Order.CustomerIdProperty }, ConfigurationSource.Explicit); @@ -798,7 +787,8 @@ public void Removing_index_does_not_remove_contained_shadow_properties_if_refere ConfigurationSource.Convention)); Test_removing_index_does_not_remove_contained_shadow_properties_if_referenced_elsewhere( - (entityBuilder, property) => entityBuilder.Property(property.ClrType, ((IProperty)property).Name, ConfigurationSource.Explicit)); + (entityBuilder, property) => entityBuilder.Property( + property.ClrType, ((IProperty)property).Name, ConfigurationSource.Explicit)); } private void Test_removing_index_does_not_remove_contained_shadow_properties_if_referenced_elsewhere( @@ -900,10 +890,12 @@ public void Key_throws_for_derived_type() var derivedEntityBuilder = modelBuilder.Entity(typeof(SpecialOrder), ConfigurationSource.Convention); derivedEntityBuilder.HasBaseType(entityBuilder.Metadata, ConfigurationSource.Convention); - Assert.Equal(CoreStrings.DerivedEntityTypeKey(typeof(SpecialOrder).Name, typeof(Order).Name), - Assert.Throws(() => - derivedEntityBuilder.HasKey( - new[] { Order.IdProperty.Name, Order.CustomerIdProperty.Name }, ConfigurationSource.DataAnnotation)).Message); + Assert.Equal( + CoreStrings.DerivedEntityTypeKey(typeof(SpecialOrder).Name, typeof(Order).Name), + Assert.Throws( + () => + derivedEntityBuilder.HasKey( + new[] { Order.IdProperty.Name, Order.CustomerIdProperty.Name }, ConfigurationSource.DataAnnotation)).Message); } [ConditionalFact] @@ -1017,11 +1009,8 @@ public void Removing_key_does_not_remove_contained_shadow_properties_if_referenc { Test_removing_key_does_not_remove_contained_shadow_properties_if_referenced_elsewhere( (entityBuilder, property) => entityBuilder.PrimaryKey( - new[] - { - entityBuilder.Property(typeof(int), "Shadow2", ConfigurationSource.Convention).Metadata.Name, - property.Name - }, ConfigurationSource.Convention)); + new[] { entityBuilder.Property(typeof(int), "Shadow2", ConfigurationSource.Convention).Metadata.Name, property.Name }, + ConfigurationSource.Convention)); Test_removing_key_does_not_remove_contained_shadow_properties_if_referenced_elsewhere( (entityBuilder, property) => entityBuilder.HasIndex(new[] { property.Name }, ConfigurationSource.Convention)); @@ -1091,9 +1080,11 @@ public void HasNoKey_can_override_lower_or_equal_source_key() Assert.Equal(ConfigurationSource.Explicit, entityType.GetIsKeylessConfigurationSource()); Assert.NotEmpty(entityType.GetKeys()); - Assert.Equal(CoreStrings.KeylessTypeExistingKey(nameof(Order)), - Assert.Throws(() => - entityBuilder.HasNoKey(ConfigurationSource.Explicit)).Message); + Assert.Equal( + CoreStrings.KeylessTypeExistingKey(nameof(Order)), + Assert.Throws( + () => + entityBuilder.HasNoKey(ConfigurationSource.Explicit)).Message); Assert.NotEmpty(entityType.GetKeys()); } @@ -1131,9 +1122,11 @@ public void HasKey_can_override_lower_or_equal_source_HasNoKey() Assert.Equal(ConfigurationSource.Explicit, entityType.GetIsKeylessConfigurationSource()); Assert.Empty(entityType.GetKeys()); - Assert.Equal(CoreStrings.KeylessTypeWithKey("{'CustomerId'}", nameof(Order)), - Assert.Throws(() => - entityBuilder.HasKey(new[] { Order.CustomerIdProperty.Name }, ConfigurationSource.Explicit)).Message); + Assert.Equal( + CoreStrings.KeylessTypeWithKey("{'CustomerId'}", nameof(Order)), + Assert.Throws( + () => + entityBuilder.HasKey(new[] { Order.CustomerIdProperty.Name }, ConfigurationSource.Explicit)).Message); } [ConditionalFact] @@ -1289,9 +1282,11 @@ public void Can_only_override_existing_primary_key_explicitly() Assert.Null(entityType.GetPrimaryKeyConfigurationSource()); entityType.SetPrimaryKey( - new[] { + new[] + { entityType.AddProperty(Order.IdProperty, ConfigurationSource.Explicit), - entityType.AddProperty(Order.CustomerIdProperty, ConfigurationSource.Explicit) }, + entityType.AddProperty(Order.CustomerIdProperty, ConfigurationSource.Explicit) + }, ConfigurationSource.Explicit); Assert.Equal(ConfigurationSource.Explicit, entityType.GetPrimaryKeyConfigurationSource()); @@ -1403,11 +1398,14 @@ public void Property_returns_same_instance_if_type_matches() Assert.Same( propertyBuilder, entityBuilder.Property( - typeof(int), Order.IdProperty.Name, typeConfigurationSource: ConfigurationSource.DataAnnotation, configurationSource: ConfigurationSource.DataAnnotation)); + typeof(int), Order.IdProperty.Name, typeConfigurationSource: ConfigurationSource.DataAnnotation, + configurationSource: ConfigurationSource.DataAnnotation)); Assert.Same( propertyBuilder, - entityBuilder.Property(typeof(int), Order.IdProperty.Name, typeConfigurationSource: null, configurationSource: ConfigurationSource.Convention)); + entityBuilder.Property( + typeof(int), Order.IdProperty.Name, typeConfigurationSource: null, + configurationSource: ConfigurationSource.Convention)); Assert.Same( propertyBuilder, @@ -1416,7 +1414,8 @@ public void Property_returns_same_instance_if_type_matches() Assert.Null( entityBuilder.Property( - typeof(string), Order.IdProperty.Name, typeConfigurationSource: ConfigurationSource.Convention, configurationSource: ConfigurationSource.Convention)); + typeof(string), Order.IdProperty.Name, typeConfigurationSource: ConfigurationSource.Convention, + configurationSource: ConfigurationSource.Convention)); Assert.Equal(new[] { propertyBuilder.Metadata }, entityBuilder.GetActualProperties(new[] { propertyBuilder.Metadata }, null)); } @@ -1491,7 +1490,8 @@ public void Can_configure_inherited_property() var derivedEntityBuilder = modelBuilder.Entity(typeof(SpecialOrder), ConfigurationSource.Convention); derivedEntityBuilder.HasBaseType(entityBuilder.Metadata, ConfigurationSource.Convention); - var propertyBuilder = derivedEntityBuilder.Property(typeof(int), nameof(SpecialOrder.Specialty), ConfigurationSource.DataAnnotation); + var propertyBuilder = derivedEntityBuilder.Property( + typeof(int), nameof(SpecialOrder.Specialty), ConfigurationSource.DataAnnotation); Assert.Same(entityBuilder.Metadata.FindProperty(nameof(SpecialOrder.Specialty)), propertyBuilder.Metadata); Assert.NotNull(propertyBuilder.IsConcurrencyToken(true, ConfigurationSource.Convention)); @@ -1723,8 +1723,8 @@ private void VerifyIgnoreMember( Assert.False(findMember(addedEntityTypeBuilder)); var exceptionExpected = ignoredOnType == typeof(ExtraSpecialOrderMinimal) - && (ignoreConfigurationSource == ConfigurationSource.Explicit - || (!ignoredFirst && setBaseFirst)); + && (ignoreConfigurationSource == ConfigurationSource.Explicit + || (!ignoredFirst && setBaseFirst)); var expectedAdded = ignoredOnType == typeof(ExtraSpecialOrderMinimal) || (addConfigurationSource.Overrides(ignoreConfigurationSource) @@ -1739,7 +1739,8 @@ private void VerifyIgnoreMember( if (ignoredFirst) { Assert.NotNull(ignoredEntityTypeBuilder.Ignore(memberToIgnore, ignoreConfigurationSource)); - Assert.Equal(expectedAdded || (!setBaseFirst && ignoredOnType != typeof(SpecialOrderMinimal)), addMember(addedEntityTypeBuilder)); + Assert.Equal( + expectedAdded || (!setBaseFirst && ignoredOnType != typeof(SpecialOrderMinimal)), addMember(addedEntityTypeBuilder)); } else { @@ -1749,7 +1750,8 @@ private void VerifyIgnoreMember( { Assert.Equal( CoreStrings.InheritedPropertyCannotBeIgnored( - memberToIgnore, typeof(ExtraSpecialOrderMinimal).ShortDisplayName(), typeof(SpecialOrderMinimal).ShortDisplayName()), + memberToIgnore, typeof(ExtraSpecialOrderMinimal).ShortDisplayName(), + typeof(SpecialOrderMinimal).ShortDisplayName()), Assert.Throws( () => ignoredEntityTypeBuilder.Ignore(memberToIgnore, ignoreConfigurationSource)).Message); return; @@ -1834,7 +1836,8 @@ public void Can_ignore_property_that_is_part_of_lower_source_foreign_key_preserv var dependentEntityBuilder = modelBuilder.Entity(typeof(Order), ConfigurationSource.Explicit); var relationshipBuilder = - dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, (string)null, null, ConfigurationSource.DataAnnotation) + dependentEntityBuilder.HasRelationship( + principalEntityBuilder.Metadata, (string)null, null, ConfigurationSource.DataAnnotation) .HasForeignKey( new[] { @@ -1861,7 +1864,8 @@ public void Can_ignore_property_that_is_part_of_lower_source_foreign_key_preserv Assert.True(newFk.IsRequired); Assert.Equal(DeleteBehavior.Cascade, newFk.DeleteBehavior); - Assert.NotNull(dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, newFk.Properties, ConfigurationSource.Convention)); + Assert.NotNull( + dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, newFk.Properties, ConfigurationSource.Convention)); Assert.NotNull(dependentEntityBuilder.Metadata.GetForeignKeys().Where(foreignKey => foreignKey != newFk)); } @@ -1995,7 +1999,8 @@ public void Navigation_returns_same_value() var modelBuilder = CreateModelBuilder(); var principalEntityBuilder = modelBuilder.Entity(typeof(Customer), ConfigurationSource.Explicit); var dependentEntityBuilder = modelBuilder.Entity(typeof(Order), ConfigurationSource.Explicit); - var foreignKeyBuilder = dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, ConfigurationSource.DataAnnotation); + var foreignKeyBuilder = dependentEntityBuilder.HasRelationship( + principalEntityBuilder.Metadata, ConfigurationSource.DataAnnotation); Assert.True(dependentEntityBuilder.CanAddNavigation(Order.CustomerProperty.Name, ConfigurationSource.Convention)); @@ -2014,15 +2019,17 @@ public void Navigation_returns_same_value() Assert.True(principalEntityBuilder.CanAddNavigation(Customer.OrdersProperty.Name, ConfigurationSource.Explicit)); - var newForeignKeyBuilder = dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, ConfigurationSource.Convention).HasNavigation( - Customer.OrdersProperty.Name, - pointsToPrincipal: false, - ConfigurationSource.Convention); + var newForeignKeyBuilder = dependentEntityBuilder + .HasRelationship(principalEntityBuilder.Metadata, ConfigurationSource.Convention).HasNavigation( + Customer.OrdersProperty.Name, + pointsToPrincipal: false, + ConfigurationSource.Convention); Assert.Same(foreignKeyBuilder, newForeignKeyBuilder); - newForeignKeyBuilder = principalEntityBuilder.HasRelationship(dependentEntityBuilder.Metadata, ConfigurationSource.Convention).HasNavigation( - Order.CustomerProperty.Name, - pointsToPrincipal: false, - ConfigurationSource.Convention); + newForeignKeyBuilder = principalEntityBuilder.HasRelationship(dependentEntityBuilder.Metadata, ConfigurationSource.Convention) + .HasNavigation( + Order.CustomerProperty.Name, + pointsToPrincipal: false, + ConfigurationSource.Convention); Assert.Same(foreignKeyBuilder, newForeignKeyBuilder); Assert.Same(foreignKeyBuilder.Metadata, dependentEntityBuilder.Metadata.GetForeignKeys().Single()); @@ -2063,14 +2070,16 @@ public void Can_ignore_lower_or_equal_source_navigation() foreignKeyBuilder = dependentEntityBuilder.HasRelationship( typeof(Customer).FullName, new[] { Order.CustomerIdProperty.Name, Order.CustomerUniqueProperty.Name }, ConfigurationSource.DataAnnotation); - Assert.Null(foreignKeyBuilder.HasNavigation( - Order.CustomerProperty.Name, - pointsToPrincipal: true, - ConfigurationSource.DataAnnotation)); - Assert.Null(foreignKeyBuilder.HasNavigation( - Customer.OrdersProperty.Name, - pointsToPrincipal: false, - ConfigurationSource.DataAnnotation)); + Assert.Null( + foreignKeyBuilder.HasNavigation( + Order.CustomerProperty.Name, + pointsToPrincipal: true, + ConfigurationSource.DataAnnotation)); + Assert.Null( + foreignKeyBuilder.HasNavigation( + Customer.OrdersProperty.Name, + pointsToPrincipal: false, + ConfigurationSource.DataAnnotation)); foreignKeyBuilder = foreignKeyBuilder.HasNavigation( Order.CustomerProperty.Name, @@ -2122,10 +2131,11 @@ public void Cannot_ignore_higher_source_navigation() Customer.OrdersProperty.Name, pointsToPrincipal: false, ConfigurationSource.Explicit)); - Assert.Null(foreignKeyBuilder.HasNavigation( - (string)null, - pointsToPrincipal: true, - ConfigurationSource.DataAnnotation)); + Assert.Null( + foreignKeyBuilder.HasNavigation( + (string)null, + pointsToPrincipal: true, + ConfigurationSource.DataAnnotation)); } [ConditionalFact] @@ -2140,11 +2150,7 @@ public void Can_ignore_existing_navigation() var property2 = dependentEntityBuilder.Metadata.AddProperty( Order.CustomerUniqueProperty.Name, typeof(Guid?), ConfigurationSource.Explicit, ConfigurationSource.Explicit); var foreignKey = dependentEntityBuilder.Metadata.AddForeignKey( - new[] - { - property1, - property2 - }, + new[] { property1, property2 }, principalEntityBuilder.Metadata.FindPrimaryKey(), principalEntityBuilder.Metadata, ConfigurationSource.Explicit, @@ -2314,7 +2320,8 @@ public void Can_ignore_lower_source_navigation_to_principal() var dependentEntityBuilder = modelBuilder.Entity(typeof(Order), ConfigurationSource.Explicit); Assert.NotNull( - dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, Order.CustomerProperty, null, ConfigurationSource.Convention)); + dependentEntityBuilder.HasRelationship( + principalEntityBuilder.Metadata, Order.CustomerProperty, null, ConfigurationSource.Convention)); Assert.NotNull(dependentEntityBuilder.Ignore(Order.CustomerProperty.Name, ConfigurationSource.Explicit)); @@ -2322,7 +2329,8 @@ public void Can_ignore_lower_source_navigation_to_principal() Assert.Empty(principalEntityBuilder.Metadata.GetForeignKeys()); Assert.NotNull(dependentEntityBuilder.Ignore(Order.CustomerProperty.Name, ConfigurationSource.Convention)); Assert.Null( - dependentEntityBuilder.HasRelationship(principalEntityBuilder.Metadata, Order.CustomerProperty, null, ConfigurationSource.Convention)); + dependentEntityBuilder.HasRelationship( + principalEntityBuilder.Metadata, Order.CustomerProperty, null, ConfigurationSource.Convention)); } [ConditionalFact] @@ -2336,7 +2344,8 @@ public void Cannot_add_navigation_to_principal_if_null_navigation_is_higher_sour Assert.Null( dependentEntityBuilder.HasRelationship( - principalEntityBuilder.Metadata, Order.CustomerProperty.Name, Customer.OrdersProperty.Name, ConfigurationSource.Convention)); + principalEntityBuilder.Metadata, Order.CustomerProperty.Name, Customer.OrdersProperty.Name, + ConfigurationSource.Convention)); Assert.Empty(principalEntityBuilder.Metadata.GetForeignKeys()); var fk = dependentEntityBuilder.Metadata.GetForeignKeys().Single(); @@ -2929,8 +2938,9 @@ public void DiscriminatorValue_throws_if_base_cannot_be_set() var discriminatorBuilder = typeBuilder.HasDiscriminator(); Assert.Equal( CoreStrings.DiscriminatorEntityTypeNotDerived("Splow", "Splot"), - Assert.Throws(() - => discriminatorBuilder.HasValue(nonDerivedTypeBuilder.Metadata, "1")).Message); + Assert.Throws( + () + => discriminatorBuilder.HasValue(nonDerivedTypeBuilder.Metadata, "1")).Message); } private InternalModelBuilder CreateModelBuilder() => new InternalModelBuilder(new Model()); diff --git a/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs index 7b914d39a01..f388f641732 100644 --- a/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs @@ -252,10 +252,11 @@ public void Ignoring_an_entity_type_does_not_remove_referenced_lower_source_enti .PrimaryKey(new[] { Product.IdProperty }, ConfigurationSource.Convention); var orderEntityTypeBuilder = modelBuilder.Entity(typeof(Order), ConfigurationSource.Explicit); - orderEntityTypeBuilder.HasRelationship(typeof(Product), new[] { Order.ProductIdProperty }, ConfigurationSource.Convention).HasNavigation( - "Product", - pointsToPrincipal: true, - ConfigurationSource.Convention); + orderEntityTypeBuilder.HasRelationship(typeof(Product), new[] { Order.ProductIdProperty }, ConfigurationSource.Convention) + .HasNavigation( + "Product", + pointsToPrincipal: true, + ConfigurationSource.Convention); Assert.NotNull(modelBuilder.Ignore(typeof(Customer), ConfigurationSource.DataAnnotation)); @@ -276,10 +277,11 @@ public void Ignoring_an_entity_type_does_not_remove_referencing_lower_source_ent .PrimaryKey(new[] { Product.IdProperty }, ConfigurationSource.Convention); var orderEntityTypeBuilder = modelBuilder.Entity(typeof(Order), ConfigurationSource.Convention); - orderEntityTypeBuilder.HasRelationship(typeof(Product), new[] { Order.ProductIdProperty }, ConfigurationSource.Convention).HasNavigation( - "Order", - pointsToPrincipal: false, - ConfigurationSource.Convention); + orderEntityTypeBuilder.HasRelationship(typeof(Product), new[] { Order.ProductIdProperty }, ConfigurationSource.Convention) + .HasNavigation( + "Order", + pointsToPrincipal: false, + ConfigurationSource.Convention); Assert.NotNull(modelBuilder.Ignore(typeof(Customer), ConfigurationSource.DataAnnotation)); @@ -348,7 +350,8 @@ public void Can_mark_type_as_owned_type() private static void Cleanup(InternalModelBuilder modelBuilder) { new ModelCleanupConvention(CreateDependencies()) - .ProcessModelFinalized(modelBuilder, + .ProcessModelFinalized( + modelBuilder, new ConventionContext(modelBuilder.Metadata.ConventionDispatcher)); } diff --git a/test/EFCore.Tests/Metadata/Internal/InternalPropertyBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalPropertyBuilderTest.cs index 384df9f6474..76c887167cf 100644 --- a/test/EFCore.Tests/Metadata/Internal/InternalPropertyBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/InternalPropertyBuilderTest.cs @@ -9,6 +9,7 @@ using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.EntityFrameworkCore.ValueGeneration; using Xunit; + // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Metadata.Internal diff --git a/test/EFCore.Tests/Metadata/Internal/InternalRelationshipBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalRelationshipBuilderTest.cs index 56bac9bd6e1..b17ab0b2fb0 100644 --- a/test/EFCore.Tests/Metadata/Internal/InternalRelationshipBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/InternalRelationshipBuilderTest.cs @@ -74,14 +74,16 @@ public void Facets_are_configured_with_the_specified_source() Assert.Null( relationshipBuilder.DependentEntityType( relationshipBuilder.Metadata.PrincipalEntityType, ConfigurationSource.DataAnnotation)); - Assert.Null(relationshipBuilder.HasNavigation( - (string)null, - pointsToPrincipal: true, - ConfigurationSource.DataAnnotation)); - Assert.Null(relationshipBuilder.HasNavigation( - (string)null, - pointsToPrincipal: false, - ConfigurationSource.DataAnnotation)); + Assert.Null( + relationshipBuilder.HasNavigation( + (string)null, + pointsToPrincipal: true, + ConfigurationSource.DataAnnotation)); + Assert.Null( + relationshipBuilder.HasNavigation( + (string)null, + pointsToPrincipal: false, + ConfigurationSource.DataAnnotation)); } [ConditionalFact] @@ -425,7 +427,8 @@ public void Unique_overrides_incompatible_lower_or_equal_source_principalToDepen var orderEntityBuilder = modelBuilder.Entity(typeof(Order), ConfigurationSource.Explicit); var relationshipBuilder = orderEntityBuilder.HasRelationship( - customerEntityBuilder.Metadata, nameof(Order.Customer), nameof(Customer.NotCollectionOrders), ConfigurationSource.DataAnnotation); + customerEntityBuilder.Metadata, nameof(Order.Customer), nameof(Customer.NotCollectionOrders), + ConfigurationSource.DataAnnotation); Assert.True(relationshipBuilder.Metadata.IsUnique); relationshipBuilder = relationshipBuilder.IsUnique(true, ConfigurationSource.Convention); @@ -478,7 +481,8 @@ public void Can_set_Required_independently_from_nullability() ConfigurationSource.Explicit, ConfigurationSource.Explicit); - var relationshipBuilder = orderEntityBuilder.HasRelationship(customerEntityBuilder.Metadata, fk.Properties, ConfigurationSource.Explicit); + var relationshipBuilder = orderEntityBuilder.HasRelationship( + customerEntityBuilder.Metadata, fk.Properties, ConfigurationSource.Explicit); relationshipBuilder = relationshipBuilder.IsRequired(false, ConfigurationSource.Convention); Assert.False(((IForeignKey)relationshipBuilder.Metadata).IsRequired); Assert.False(customerIdProperty.IsNullable); @@ -923,10 +927,11 @@ public void Navigation_to_dependent_does_not_change_uniqueness_for_relationship_ foreignKeyBuilder = foreignKeyBuilder.IsUnique(false, ConfigurationSource.DataAnnotation); Assert.False(foreignKeyBuilder.Metadata.IsUnique); - Assert.Null(foreignKeyBuilder.HasNavigation( - nameof(Customer.NotCollectionOrders), - pointsToPrincipal: false, - ConfigurationSource.Convention)); + Assert.Null( + foreignKeyBuilder.HasNavigation( + nameof(Customer.NotCollectionOrders), + pointsToPrincipal: false, + ConfigurationSource.Convention)); Assert.False(foreignKeyBuilder.Metadata.IsUnique); foreignKeyBuilder = foreignKeyBuilder.HasNavigation( diff --git a/test/EFCore.Tests/Metadata/Internal/PropertyAccessorsFactoryTest.cs b/test/EFCore.Tests/Metadata/Internal/PropertyAccessorsFactoryTest.cs index 2063451e3f7..7fbaf9a8cea 100644 --- a/test/EFCore.Tests/Metadata/Internal/PropertyAccessorsFactoryTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/PropertyAccessorsFactoryTest.cs @@ -42,10 +42,7 @@ public void Can_use_PropertyAccessorsFactory_on_non_indexed_property() private class IndexedClass { - private readonly Dictionary _internalValues = new Dictionary - { - { "PropertyA", "ValueA" } - }; + private readonly Dictionary _internalValues = new Dictionary { { "PropertyA", "ValueA" } }; internal int Id { get; set; } diff --git a/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs b/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs index bf4e077d8ae..b6e20d6d4a1 100644 --- a/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs @@ -64,7 +64,9 @@ public void Get_MemberInfos_for_read_only_props() MemberInfoTest(CreateProperty(field), null, field, field, field); MemberInfoTest(CreateProperty(field), PropertyAccessMode.Field, field, field, field); MemberInfoTest(CreateProperty(field), PropertyAccessMode.FieldDuringConstruction, field, field, Property); - MemberInfoTest(CreateProperty(field), PropertyAccessMode.Property, NoSetter(), NoSetter(), Property); + MemberInfoTest( + CreateProperty(field), PropertyAccessMode.Property, NoSetter(), NoSetter(), + Property); MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferField, field, field, field); MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, Property); MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferProperty, field, field, Property); @@ -78,9 +80,12 @@ public void Get_MemberInfos_for_read_only_auto_props() MemberInfoTest(CreateProperty(field), null, field, field, field); MemberInfoTest(CreateProperty(field), PropertyAccessMode.Field, field, field, field); MemberInfoTest(CreateProperty(field), PropertyAccessMode.FieldDuringConstruction, field, field, Property); - MemberInfoTest(CreateProperty(field), PropertyAccessMode.Property, NoSetter(), NoSetter(), Property); + MemberInfoTest( + CreateProperty(field), PropertyAccessMode.Property, NoSetter(), + NoSetter(), Property); MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, Property); + MemberInfoTest( + CreateProperty(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, Property); MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferProperty, field, field, Property); } @@ -92,9 +97,12 @@ public void Get_MemberInfos_for_read_only_field_props() MemberInfoTest(CreateProperty(field), null, field, field, field); MemberInfoTest(CreateProperty(field), PropertyAccessMode.Field, field, field, field); MemberInfoTest(CreateProperty(field), PropertyAccessMode.FieldDuringConstruction, field, field, Property); - MemberInfoTest(CreateProperty(field), PropertyAccessMode.Property, NoSetter(), NoSetter(), Property); + MemberInfoTest( + CreateProperty(field), PropertyAccessMode.Property, NoSetter(), + NoSetter(), Property); MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, Property); + MemberInfoTest( + CreateProperty(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, Property); MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferProperty, field, field, Property); } @@ -106,7 +114,8 @@ public void Get_MemberInfos_for_write_only_props() MemberInfoTest(CreateProperty(field), null, field, field, field); MemberInfoTest(CreateProperty(field), PropertyAccessMode.Field, field, field, field); MemberInfoTest(CreateProperty(field), PropertyAccessMode.FieldDuringConstruction, field, Property, field); - MemberInfoTest(CreateProperty(field), PropertyAccessMode.Property, Property, Property, NoGetter()); + MemberInfoTest( + CreateProperty(field), PropertyAccessMode.Property, Property, Property, NoGetter()); MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferField, field, field, field); MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Property, field); MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferProperty, Property, Property, field); @@ -121,7 +130,8 @@ public void Get_MemberInfos_for_field_only_props() MemberInfoTest(CreateProperty(field, field), PropertyAccessMode.Field, field, field, field); MemberInfoTest(CreateProperty(field, field), PropertyAccessMode.FieldDuringConstruction, field, field, field); MemberInfoTest( - CreateProperty(field, field), PropertyAccessMode.Property, NoProperty(field), NoProperty(field), + CreateProperty(field, field), PropertyAccessMode.Property, NoProperty(field), + NoProperty(field), NoProperty(field)); MemberInfoTest(CreateProperty(field, field), PropertyAccessMode.PreferField, field, field, field); MemberInfoTest(CreateProperty(field, field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, field); @@ -135,12 +145,14 @@ public void Get_MemberInfos_for_read_only_field_only_props() MemberInfoTest(CreateProperty(field, field), null, field, field, field); MemberInfoTest(CreateProperty(field, field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateProperty(field, field), PropertyAccessMode.FieldDuringConstruction, field, field, field); + MemberInfoTest( + CreateProperty(field, field), PropertyAccessMode.FieldDuringConstruction, field, field, field); MemberInfoTest( CreateProperty(field, field), PropertyAccessMode.Property, NoProperty(field), NoProperty(field), NoProperty(field)); MemberInfoTest(CreateProperty(field, field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateProperty(field, field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, field); + MemberInfoTest( + CreateProperty(field, field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, field); MemberInfoTest(CreateProperty(field, field), PropertyAccessMode.PreferProperty, field, field, field); } @@ -148,13 +160,16 @@ public void Get_MemberInfos_for_read_only_field_only_props() public void Get_MemberInfos_for_full_props_with_field_not_found() { MemberInfoTest(CreateProperty(null), null, Property, Property, Property); - MemberInfoTest(CreateProperty(null), PropertyAccessMode.Field, NoField(), + MemberInfoTest( + CreateProperty(null), PropertyAccessMode.Field, NoField(), NoField(), NoField()); - MemberInfoTest(CreateProperty(null), PropertyAccessMode.FieldDuringConstruction, + MemberInfoTest( + CreateProperty(null), PropertyAccessMode.FieldDuringConstruction, NoField(), Property, Property); MemberInfoTest(CreateProperty(null), PropertyAccessMode.Property, Property, Property, Property); MemberInfoTest(CreateProperty(null), PropertyAccessMode.PreferField, Property, Property, Property); - MemberInfoTest(CreateProperty(null), PropertyAccessMode.PreferFieldDuringConstruction, Property, Property, Property); + MemberInfoTest( + CreateProperty(null), PropertyAccessMode.PreferFieldDuringConstruction, Property, Property, Property); MemberInfoTest(CreateProperty(null), PropertyAccessMode.PreferProperty, Property, Property, Property); } @@ -215,10 +230,12 @@ public void Get_MemberInfos_for_full_props_private_setter_in_base() MemberInfoTest(CreateProperty(field), null, field, field, field); MemberInfoTest(CreateProperty(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateProperty(field), PropertyAccessMode.FieldDuringConstruction, field, Property, Property); + MemberInfoTest( + CreateProperty(field), PropertyAccessMode.FieldDuringConstruction, field, Property, Property); MemberInfoTest(CreateProperty(field), PropertyAccessMode.Property, Property, Property, Property); MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Property, Property); + MemberInfoTest( + CreateProperty(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Property, Property); MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferProperty, Property, Property, Property); } @@ -229,10 +246,12 @@ public void Get_MemberInfos_for_full_props_private_getter_in_base() MemberInfoTest(CreateProperty(field), null, field, field, field); MemberInfoTest(CreateProperty(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateProperty(field), PropertyAccessMode.FieldDuringConstruction, field, Property, Property); + MemberInfoTest( + CreateProperty(field), PropertyAccessMode.FieldDuringConstruction, field, Property, Property); MemberInfoTest(CreateProperty(field), PropertyAccessMode.Property, Property, Property, Property); MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Property, Property); + MemberInfoTest( + CreateProperty(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Property, Property); MemberInfoTest(CreateProperty(field), PropertyAccessMode.PreferProperty, Property, Property, Property); } @@ -243,10 +262,12 @@ public void Get_MemberInfos_for_auto_prop_navigations() MemberInfoTest(CreateReferenceNavigation(field), null, field, field, field); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Reference, Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Reference, Reference); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.Property, Reference, Reference, Reference); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Reference, Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Reference, Reference); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferProperty, Reference, Reference, Reference); } @@ -257,10 +278,12 @@ public void Get_MemberInfos_for_full_prop_navigations() MemberInfoTest(CreateReferenceNavigation(field), null, field, field, field); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Reference, Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Reference, Reference); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.Property, Reference, Reference, Reference); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Reference, Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Reference, Reference); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferProperty, Reference, Reference, Reference); } @@ -271,10 +294,14 @@ public void Get_MemberInfos_for_read_only_prop_navigations() MemberInfoTest(CreateReferenceNavigation(field), null, field, field, field); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, Reference); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.Property, NoSetterRef(), NoSetterRef(), Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.Property, NoSetterRef(), + NoSetterRef(), Reference); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, Reference); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferProperty, field, field, Reference); } @@ -285,11 +312,15 @@ public void Get_MemberInfos_for_read_only_auto_prop_navigations() MemberInfoTest(CreateReferenceNavigation(field), null, field, field, field); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, Reference); MemberInfoTest( - CreateReferenceNavigation(field), PropertyAccessMode.Property, NoSetterRef(), NoSetterRef(), Reference); + CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.Property, NoSetterRef(), + NoSetterRef(), Reference); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, + Reference); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferProperty, field, field, Reference); } @@ -300,11 +331,15 @@ public void Get_MemberInfos_for_read_only_field_prop_navigations() MemberInfoTest(CreateReferenceNavigation(field), null, field, field, field); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, Reference); MemberInfoTest( - CreateReferenceNavigation(field), PropertyAccessMode.Property, NoSetterRef(), NoSetterRef(), Reference); + CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.Property, NoSetterRef(), + NoSetterRef(), Reference); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, + Reference); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferProperty, field, field, Reference); } @@ -315,10 +350,14 @@ public void Get_MemberInfos_for_write_only_prop_navigations() MemberInfoTest(CreateReferenceNavigation(field), null, field, field, field); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Reference, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.Property, Reference, Reference, NoGetterRef()); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Reference, field); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.Property, Reference, Reference, + NoGetterRef()); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Reference, field); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Reference, field); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferProperty, Reference, Reference, field); } @@ -327,43 +366,58 @@ public void Get_MemberInfos_for_full_prop_navigations_with_field_not_found() { MemberInfoTest(CreateReferenceNavigation(null), null, Reference, Reference, Reference); MemberInfoTest( - CreateReferenceNavigation(null), PropertyAccessMode.Field, NoFieldRef(), NoFieldRef(), + CreateReferenceNavigation(null), PropertyAccessMode.Field, NoFieldRef(), + NoFieldRef(), NoFieldRef()); - MemberInfoTest(CreateReferenceNavigation(null), PropertyAccessMode.FieldDuringConstruction, NoFieldRef(), Reference, Reference); + MemberInfoTest( + CreateReferenceNavigation(null), PropertyAccessMode.FieldDuringConstruction, NoFieldRef(), + Reference, Reference); MemberInfoTest(CreateReferenceNavigation(null), PropertyAccessMode.Property, Reference, Reference, Reference); - MemberInfoTest(CreateReferenceNavigation(null), PropertyAccessMode.PreferField, Reference, Reference, Reference); - MemberInfoTest(CreateReferenceNavigation(null), PropertyAccessMode.PreferFieldDuringConstruction, Reference, Reference, Reference); - MemberInfoTest(CreateReferenceNavigation(null), PropertyAccessMode.PreferProperty, Reference, Reference, Reference); + MemberInfoTest( + CreateReferenceNavigation(null), PropertyAccessMode.PreferField, Reference, Reference, Reference); + MemberInfoTest( + CreateReferenceNavigation(null), PropertyAccessMode.PreferFieldDuringConstruction, Reference, Reference, + Reference); + MemberInfoTest( + CreateReferenceNavigation(null), PropertyAccessMode.PreferProperty, Reference, Reference, Reference); } [ConditionalFact] public void Get_MemberInfos_for_read_only_prop_navigations_with_field_not_found() { MemberInfoTest( - CreateReferenceNavigation(null), null, NoFieldOrSetterRef(), NoFieldOrSetterRef(), Reference); + CreateReferenceNavigation(null), null, NoFieldOrSetterRef(), + NoFieldOrSetterRef(), Reference); MemberInfoTest( - CreateReferenceNavigation(null), PropertyAccessMode.Field, NoFieldRef(), NoFieldRef(), + CreateReferenceNavigation(null), PropertyAccessMode.Field, NoFieldRef(), + NoFieldRef(), NoFieldRef()); MemberInfoTest( - CreateReferenceNavigation(null), PropertyAccessMode.FieldDuringConstruction, NoFieldRef(), + CreateReferenceNavigation(null), PropertyAccessMode.FieldDuringConstruction, + NoFieldRef(), NoFieldOrSetterRef(), Reference); MemberInfoTest( - CreateReferenceNavigation(null), PropertyAccessMode.Property, NoSetterRef(), NoSetterRef(), Reference); + CreateReferenceNavigation(null), PropertyAccessMode.Property, NoSetterRef(), + NoSetterRef(), Reference); MemberInfoTest( - CreateReferenceNavigation(null), PropertyAccessMode.PreferField, NoFieldOrSetterRef(), + CreateReferenceNavigation(null), PropertyAccessMode.PreferField, + NoFieldOrSetterRef(), NoFieldOrSetterRef(), Reference); MemberInfoTest( - CreateReferenceNavigation(null), PropertyAccessMode.PreferFieldDuringConstruction, NoFieldOrSetterRef(), + CreateReferenceNavigation(null), PropertyAccessMode.PreferFieldDuringConstruction, + NoFieldOrSetterRef(), NoFieldOrSetterRef(), Reference); MemberInfoTest( - CreateReferenceNavigation(null), PropertyAccessMode.PreferProperty, NoFieldOrSetterRef(), + CreateReferenceNavigation(null), PropertyAccessMode.PreferProperty, + NoFieldOrSetterRef(), NoFieldOrSetterRef(), Reference); } [ConditionalFact] public void Get_MemberInfos_for_write_only_prop_navigations_with_field_not_found() { - MemberInfoTest(CreateReferenceNavigation(null), null, + MemberInfoTest( + CreateReferenceNavigation(null), null, Reference, Reference, NoFieldOrGetterRef()); MemberInfoTest( CreateReferenceNavigation(null), PropertyAccessMode.Field, @@ -371,14 +425,17 @@ public void Get_MemberInfos_for_write_only_prop_navigations_with_field_not_found MemberInfoTest( CreateReferenceNavigation(null), PropertyAccessMode.FieldDuringConstruction, NoFieldRef(), Reference, NoFieldOrGetterRef()); - MemberInfoTest(CreateReferenceNavigation(null), PropertyAccessMode.Property, + MemberInfoTest( + CreateReferenceNavigation(null), PropertyAccessMode.Property, Reference, Reference, NoGetterRef()); - MemberInfoTest(CreateReferenceNavigation(null), PropertyAccessMode.PreferField, + MemberInfoTest( + CreateReferenceNavigation(null), PropertyAccessMode.PreferField, Reference, Reference, NoFieldOrGetterRef()); MemberInfoTest( CreateReferenceNavigation(null), PropertyAccessMode.PreferFieldDuringConstruction, Reference, Reference, NoFieldOrGetterRef()); - MemberInfoTest(CreateReferenceNavigation(null), PropertyAccessMode.PreferProperty, + MemberInfoTest( + CreateReferenceNavigation(null), PropertyAccessMode.PreferProperty, Reference, Reference, NoFieldOrGetterRef()); } @@ -389,11 +446,17 @@ public void Get_MemberInfos_for_full_prop_navigations_private_setter_in_base() MemberInfoTest(CreateReferenceNavigation(field), null, field, field, field); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Reference, Reference); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.Property, Reference, Reference, Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Reference, + Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.Property, Reference, Reference, Reference); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Reference, Reference); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferProperty, Reference, Reference, Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Reference, + Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.PreferProperty, Reference, Reference, Reference); } [ConditionalFact] @@ -403,13 +466,17 @@ public void Get_MemberInfos_for_full_prop_navigations_private_getter_in_base() MemberInfoTest(CreateReferenceNavigation(field), null, field, field, field); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Reference, Reference); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.Property, Reference, Reference, Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.Property, Reference, Reference, Reference); MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Reference, Reference); - MemberInfoTest(CreateReferenceNavigation(field), PropertyAccessMode.PreferProperty, Reference, Reference, Reference); + MemberInfoTest( + CreateReferenceNavigation(field), PropertyAccessMode.PreferProperty, Reference, Reference, Reference); } [ConditionalFact] @@ -419,11 +486,15 @@ public void Get_MemberInfos_for_auto_prop_collection_navigations() MemberInfoTest(CreateCollectionNavigation(field), null, field, field, field); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Collection, Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Collection, Collection); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Property, Collection, Collection, Collection); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Collection, Collection); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferProperty, Collection, Collection, Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Collection, + Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.PreferProperty, Collection, Collection, Collection); } [ConditionalFact] @@ -433,11 +504,15 @@ public void Get_MemberInfos_for_full_prop_collection_navigations() MemberInfoTest(CreateCollectionNavigation(field), null, field, field, field); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Collection, Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Collection, Collection); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Property, Collection, Collection, Collection); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Collection, Collection); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferProperty, Collection, Collection, Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Collection, + Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.PreferProperty, Collection, Collection, Collection); } [ConditionalFact] @@ -447,10 +522,13 @@ public void Get_MemberInfos_for_read_only_prop_collection_navigations() MemberInfoTest(CreateCollectionNavigation(field), null, field, field, field); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, Collection); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Property, null, null, Collection); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, + Collection); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferProperty, field, field, Collection); } @@ -461,12 +539,15 @@ public void Get_MemberInfos_for_read_only_auto_prop_collection_navigations() MemberInfoTest(CreateCollectionNavigation(field), null, field, field, field); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, Collection); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Property, null, null, Collection); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, Collection); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferProperty, field, field, Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.PreferProperty, field, field, Collection); } [ConditionalFact] @@ -476,12 +557,15 @@ public void Get_MemberInfos_for_read_only_field_prop_collection_navigations() MemberInfoTest(CreateCollectionNavigation(field), null, field, field, field); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, field, Collection); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Property, null, null, Collection); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, field, Collection); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferProperty, field, field, Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.PreferProperty, field, field, Collection); } [ConditionalFact] @@ -491,55 +575,77 @@ public void Get_MemberInfos_for_write_only_prop_collection_navigations() MemberInfoTest(CreateCollectionNavigation(field), null, field, field, field); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Collection, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Property, + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Collection, field); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.Property, Collection, Collection, NoGetterColl()); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Collection, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferProperty, Collection, Collection, field); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.PreferFieldDuringConstruction, field, Collection, + field); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.PreferProperty, Collection, Collection, field); } [ConditionalFact] public void Get_MemberInfos_for_full_prop_collection_navigations_with_field_not_found() { MemberInfoTest(CreateCollectionNavigation(null), null, Collection, Collection, Collection); - MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.Field, null, null, NoFieldColl()); - MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.FieldDuringConstruction, null, Collection, Collection); - MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.Property, Collection, Collection, Collection); - MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.PreferField, Collection, Collection, Collection); - MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.PreferFieldDuringConstruction, + MemberInfoTest( + CreateCollectionNavigation(null), PropertyAccessMode.Field, null, null, NoFieldColl()); + MemberInfoTest( + CreateCollectionNavigation(null), PropertyAccessMode.FieldDuringConstruction, null, Collection, + Collection); + MemberInfoTest( + CreateCollectionNavigation(null), PropertyAccessMode.Property, Collection, Collection, Collection); + MemberInfoTest( + CreateCollectionNavigation(null), PropertyAccessMode.PreferField, Collection, Collection, Collection); + MemberInfoTest( + CreateCollectionNavigation(null), PropertyAccessMode.PreferFieldDuringConstruction, Collection, Collection, Collection); - MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.PreferProperty, Collection, Collection, Collection); + MemberInfoTest( + CreateCollectionNavigation(null), PropertyAccessMode.PreferProperty, Collection, Collection, Collection); } [ConditionalFact] public void Get_MemberInfos_for_read_only_prop_collection_navigations_with_field_not_found() { MemberInfoTest(CreateCollectionNavigation(null), null, null, null, Collection); - MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.Field, + MemberInfoTest( + CreateCollectionNavigation(null), PropertyAccessMode.Field, null, null, NoFieldColl()); - MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.FieldDuringConstruction, null, null, Collection); + MemberInfoTest( + CreateCollectionNavigation(null), PropertyAccessMode.FieldDuringConstruction, null, null, Collection); MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.Property, null, null, Collection); MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.PreferField, null, null, Collection); - MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.PreferFieldDuringConstruction, + MemberInfoTest( + CreateCollectionNavigation(null), PropertyAccessMode.PreferFieldDuringConstruction, null, null, Collection); - MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.PreferProperty, null, null, Collection); + MemberInfoTest( + CreateCollectionNavigation(null), PropertyAccessMode.PreferProperty, null, null, Collection); } [ConditionalFact] public void Get_MemberInfos_for_write_only_prop_collection_navigations_with_field_not_found() { - MemberInfoTest(CreateCollectionNavigation(null), null, + MemberInfoTest( + CreateCollectionNavigation(null), null, Collection, Collection, NoFieldOrGetterColl()); - MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.Field, + MemberInfoTest( + CreateCollectionNavigation(null), PropertyAccessMode.Field, null, null, NoFieldColl()); - MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.FieldDuringConstruction, + MemberInfoTest( + CreateCollectionNavigation(null), PropertyAccessMode.FieldDuringConstruction, null, Collection, NoFieldOrGetterColl()); - MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.Property, + MemberInfoTest( + CreateCollectionNavigation(null), PropertyAccessMode.Property, Collection, Collection, NoGetterColl()); - MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.PreferField, + MemberInfoTest( + CreateCollectionNavigation(null), PropertyAccessMode.PreferField, Collection, Collection, NoFieldOrGetterColl()); - MemberInfoTest(CreateCollectionNavigation(null), PropertyAccessMode.PreferProperty, + MemberInfoTest( + CreateCollectionNavigation(null), PropertyAccessMode.PreferProperty, Collection, Collection, NoFieldOrGetterColl()); } @@ -550,11 +656,15 @@ public void Get_MemberInfos_for_full_prop_collection_navigations_private_setter_ MemberInfoTest(CreateCollectionNavigation(field), null, field, field, field); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Collection, Collection); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Property, Collection, Collection, Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.Property, Collection, Collection, Collection); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferProperty, Collection, Collection, Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.PreferProperty, Collection, Collection, + Collection); } [ConditionalFact] @@ -564,11 +674,15 @@ public void Get_MemberInfos_for_full_prop_collection_navigations_private_getter_ MemberInfoTest(CreateCollectionNavigation(field), null, field, field, field); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Field, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.FieldDuringConstruction, field, Collection, Collection); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.Property, Collection, Collection, Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.Property, Collection, Collection, Collection); MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferField, field, field, field); - MemberInfoTest(CreateCollectionNavigation(field), PropertyAccessMode.PreferProperty, Collection, Collection, Collection); + MemberInfoTest( + CreateCollectionNavigation(field), PropertyAccessMode.PreferProperty, Collection, Collection, + Collection); } private static string NoProperty(string fieldName) @@ -792,7 +906,8 @@ public virtual void Field_only_properties_throws_when_field_cleared() { var propertyBase = ((IMutableModel)new Model()).AddEntityType(typeof(FieldOnly)).AddProperty("_foo", typeof(int)); - Assert.Equal(CoreStrings.FieldNameMismatch(null, nameof(FieldOnly), "_foo"), + Assert.Equal( + CoreStrings.FieldNameMismatch(null, nameof(FieldOnly), "_foo"), Assert.Throws(() => propertyBase.SetField(null)).Message); } @@ -849,7 +964,8 @@ public virtual void Setting_fieldInfo_for_shadow_property_throws() var entityType = model.AddEntityType(typeof(FullProp)); var property = entityType.AddProperty("shadow", typeof(int)); - Assert.Equal(CoreStrings.FieldNameMismatch("_foo", nameof(FullProp), "shadow"), + Assert.Equal( + CoreStrings.FieldNameMismatch("_foo", nameof(FullProp), "shadow"), Assert.Throws(() => property.SetField("_foo")).Message); } diff --git a/test/EFCore.Tests/ModelBuilding/IEntityTypeConfigurationTest.cs b/test/EFCore.Tests/ModelBuilding/IEntityTypeConfigurationTest.cs index 36f84e5f7b0..8f59981615c 100644 --- a/test/EFCore.Tests/ModelBuilding/IEntityTypeConfigurationTest.cs +++ b/test/EFCore.Tests/ModelBuilding/IEntityTypeConfigurationTest.cs @@ -90,6 +90,7 @@ public void Configure(EntityTypeBuilder builder) builder.Property(c => c.Name).HasMaxLength(1000); } } + protected class Order { public int OrderId { get; set; } diff --git a/test/EFCore.Tests/ModelBuilding/InheritanceTestBase.cs b/test/EFCore.Tests/ModelBuilding/InheritanceTestBase.cs index 95cfde4bb2d..0f98b68700e 100644 --- a/test/EFCore.Tests/ModelBuilding/InheritanceTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/InheritanceTestBase.cs @@ -79,11 +79,7 @@ public virtual void Can_map_derived_self_ref_many_to_one() var modelBuilder = CreateModelBuilder(); modelBuilder.Entity().HasData( - new SelfRefManyToOneDerived - { - Id = 1, - SelfRefId = 1 - }); + new SelfRefManyToOneDerived { Id = 1, SelfRefId = 1 }); modelBuilder.Entity(); modelBuilder.FinalizeModel(); @@ -509,31 +505,17 @@ public virtual void Index_removed_when_covered_by_an_inherited_foreign_key() principalEntityBuilder.HasMany(c => c.Orders).WithOne(o => o.Customer) .HasForeignKey( - o => new - { - o.CustomerId, - o.AnotherCustomerId - }) + o => new { o.CustomerId, o.AnotherCustomerId }) .HasPrincipalKey( - c => new - { - c.Id, - c.AlternateKey - }); + c => new { c.Id, c.AlternateKey }); Assert.Empty(derivedDependentEntityType.GetDeclaredIndexes()); derivedPrincipalEntityBuilder.HasMany().WithOne() .HasForeignKey( - o => new - { - o.CustomerId - }) + o => new { o.CustomerId }) .HasPrincipalKey( - c => new - { - c.Id - }); + c => new { c.Id }); var fk = dependentEntityType.GetForeignKeys().Single(); Assert.Equal(1, dependentEntityType.GetIndexes().Count()); @@ -567,15 +549,9 @@ public virtual void Index_removed_when_covered_by_an_inherited_foreign_key() principalEntityBuilder.HasOne().WithOne() .HasPrincipalKey( - c => new - { - c.Id - }) + c => new { c.Id }) .HasForeignKey( - o => new - { - o.CustomerId - }); + o => new { o.CustomerId }); modelBuilder.FinalizeModel(); @@ -606,24 +582,14 @@ public virtual void Index_removed_when_covered_by_an_inherited_index() var derivedDependentEntityBuilder = modelBuilder.Entity(); dependentEntityBuilder.HasIndex( - o => new - { - o.CustomerId, - o.AnotherCustomerId - }) + o => new { o.CustomerId, o.AnotherCustomerId }) .IsUnique(); derivedPrincipalEntityBuilder.HasMany().WithOne() .HasPrincipalKey( - c => new - { - c.Id - }) + c => new { c.Id }) .HasForeignKey( - o => new - { - o.CustomerId - }); + o => new { o.CustomerId }); var dependentEntityType = dependentEntityBuilder.Metadata; var derivedDependentEntityType = derivedDependentEntityBuilder.Metadata; diff --git a/test/EFCore.Tests/ModelBuilding/ManyToOneTestBase.cs b/test/EFCore.Tests/ModelBuilding/ManyToOneTestBase.cs index 9643aa03bda..6d474b93aef 100644 --- a/test/EFCore.Tests/ModelBuilding/ManyToOneTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/ManyToOneTestBase.cs @@ -315,7 +315,9 @@ public virtual void Creates_relationship_with_no_navigations() AssertEqual( new[] { - "AnotherCustomerId", existingFk.Properties.Single().Name, fk.Properties.Single().Name, + "AnotherCustomerId", + existingFk.Properties.Single().Name, + fk.Properties.Single().Name, dependentKey.Properties.Single().Name }, dependentType.GetProperties().Select(p => p.Name)); @@ -1272,19 +1274,11 @@ public virtual void Creates_both_navigations_and_finds_existing_composite_FK() var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder .Entity().HasOne(e => e.Whoopper).WithMany() .HasForeignKey( - c => new - { - c.BurgerId1, - c.BurgerId2 - }); + c => new { c.BurgerId1, c.BurgerId2 }); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -1297,11 +1291,7 @@ public virtual void Creates_both_navigations_and_finds_existing_composite_FK() modelBuilder .Entity().HasOne(e => e.Whoopper).WithMany(e => e.Tomatoes) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.FinalizeModel(); @@ -1333,11 +1323,7 @@ public virtual void Creates_both_navigations_and_creates_composite_FK_specified( var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity(); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -1354,11 +1340,7 @@ public virtual void Creates_both_navigations_and_creates_composite_FK_specified( modelBuilder .Entity().HasOne(e => e.Whoopper).WithMany(e => e.Tomatoes) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.FinalizeModel(); @@ -1393,11 +1375,7 @@ public virtual void Can_use_alternate_composite_key() var model = modelBuilder.Model; modelBuilder.Entity( b => b.HasKey( - c => new - { - c.Id1, - c.Id2 - })); + c => new { c.Id1, c.Id2 })); modelBuilder.Entity(); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -1416,17 +1394,9 @@ public virtual void Can_use_alternate_composite_key() modelBuilder .Entity().HasOne(e => e.Whoopper).WithMany(e => e.Tomatoes) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }) + e => new { e.BurgerId1, e.BurgerId2 }) .HasPrincipalKey( - e => new - { - e.AlternateKey1, - e.AlternateKey2 - }); + e => new { e.AlternateKey1, e.AlternateKey2 }); modelBuilder.FinalizeModel(); @@ -1469,11 +1439,7 @@ public virtual void Can_use_alternate_composite_key_in_any_order() var model = modelBuilder.Model; modelBuilder.Entity( b => b.HasKey( - c => new - { - c.Id1, - c.Id2 - })); + c => new { c.Id1, c.Id2 })); modelBuilder.Entity(); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -1492,17 +1458,9 @@ public virtual void Can_use_alternate_composite_key_in_any_order() modelBuilder .Entity().HasOne(e => e.Whoopper).WithMany(e => e.Tomatoes) .HasPrincipalKey( - e => new - { - e.AlternateKey1, - e.AlternateKey2 - }) + e => new { e.AlternateKey1, e.AlternateKey2 }) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.FinalizeModel(); @@ -1544,11 +1502,7 @@ public virtual void Creates_specified_composite_FK_with_navigation_to_principal( var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity(); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -1565,11 +1519,7 @@ public virtual void Creates_specified_composite_FK_with_navigation_to_principal( modelBuilder .Entity().HasOne(e => e.Whoopper).WithMany() .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.FinalizeModel(); @@ -1595,11 +1545,7 @@ public virtual void Creates_specified_composite_FK_with_navigation_to_dependent( var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity(); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -1616,11 +1562,7 @@ public virtual void Creates_specified_composite_FK_with_navigation_to_dependent( modelBuilder .Entity().HasOne().WithMany(e => e.Tomatoes) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.FinalizeModel(); @@ -1646,11 +1588,7 @@ public virtual void Creates_relationship_with_no_navigations_and_specified_compo var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity().HasMany(w => w.Tomatoes).WithOne(t => t.Whoopper); modelBuilder.Entity(); modelBuilder.Ignore(); @@ -1670,11 +1608,7 @@ public virtual void Creates_relationship_with_no_navigations_and_specified_compo modelBuilder .Entity().HasOne().WithMany() .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.FinalizeModel(); @@ -1704,18 +1638,10 @@ public virtual void Creates_relationship_on_existing_FK_is_using_different_princ var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity().HasOne(e => e.ToastedBun).WithOne(e => e.Whoopper) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -1728,17 +1654,9 @@ public virtual void Creates_relationship_on_existing_FK_is_using_different_princ modelBuilder .Entity().HasOne().WithMany() .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }) + e => new { e.BurgerId1, e.BurgerId2 }) .HasPrincipalKey( - e => new - { - e.AlternateKey1, - e.AlternateKey2 - }); + e => new { e.AlternateKey1, e.AlternateKey2 }); var navigation = dependentType.GetNavigations().Single(); var existingFk = navigation.ForeignKey; @@ -1770,18 +1688,10 @@ public virtual void Creates_relationship_on_existing_FK_is_using_different_princ var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity().HasOne(e => e.ToastedBun).WithOne(e => e.Whoopper) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -1794,17 +1704,9 @@ public virtual void Creates_relationship_on_existing_FK_is_using_different_princ modelBuilder .Entity().HasOne().WithMany() .HasPrincipalKey( - e => new - { - e.AlternateKey1, - e.AlternateKey2 - }) + e => new { e.AlternateKey1, e.AlternateKey2 }) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); var existingFk = dependentType.GetNavigations().Single().ForeignKey; Assert.Same(existingFk, principalType.GetNavigations().Single().ForeignKey); @@ -1831,11 +1733,7 @@ public virtual void Throws_on_existing_one_to_one_relationship() modelBuilder.Entity() .HasOne(e => e.Hob).WithOne(e => e.Nob) .HasForeignKey( - e => new - { - e.HobId1, - e.HobId2 - }); + e => new { e.HobId1, e.HobId2 }); var dependentType = model.FindEntityType(typeof(Hob)); var principalType = model.FindEntityType(typeof(Nob)); @@ -1863,11 +1761,7 @@ public virtual void Removes_existing_unidirectional_one_to_one_relationship() modelBuilder.Entity() .HasOne(e => e.Hob).WithOne(e => e.Nob) .HasForeignKey( - e => new - { - e.HobId1, - e.HobId2 - }); + e => new { e.HobId1, e.HobId2 }); modelBuilder.Entity().HasOne().WithOne(e => e.Nob); @@ -1924,11 +1818,7 @@ public virtual void Nullable_FK_are_optional_by_default() modelBuilder .Entity().HasOne(e => e.Hob).WithMany(e => e.Nobs) .HasForeignKey( - e => new - { - e.HobId1, - e.HobId2 - }); + e => new { e.HobId1, e.HobId2 }); modelBuilder.FinalizeModel(); @@ -1951,11 +1841,7 @@ public virtual void Non_nullable_FK_are_required_by_default() modelBuilder .Entity().HasOne(e => e.Nob).WithMany(e => e.Hobs) .HasForeignKey( - e => new - { - e.NobId1, - e.NobId2 - }); + e => new { e.NobId1, e.NobId2 }); modelBuilder.FinalizeModel(); @@ -1978,11 +1864,7 @@ public virtual void Nullable_FK_can_be_made_required() modelBuilder .Entity().HasOne(e => e.Hob).WithMany(e => e.Nobs) .HasForeignKey( - e => new - { - e.HobId1, - e.HobId2 - }) + e => new { e.HobId1, e.HobId2 }) .IsRequired(); modelBuilder.FinalizeModel(); @@ -2006,11 +1888,7 @@ public virtual void Non_nullable_FK_can_be_made_optional() modelBuilder .Entity().HasOne(e => e.Nob).WithMany(e => e.Hobs) .HasForeignKey( - e => new - { - e.NobId1, - e.NobId2 - }) + e => new { e.NobId1, e.NobId2 }) .IsRequired(false); modelBuilder.FinalizeModel(); @@ -2034,11 +1912,7 @@ public virtual void Non_nullable_FK_can_be_made_optional_separately() modelBuilder .Entity().HasOne(e => e.Nob).WithMany(e => e.Hobs) .HasForeignKey( - e => new - { - e.NobId1, - e.NobId2 - }); + e => new { e.NobId1, e.NobId2 }); modelBuilder .Entity().HasOne(e => e.Nob).WithMany(e => e.Hobs) diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilder.Other.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilder.Other.cs index be41422a9e8..ed15618d71c 100644 --- a/test/EFCore.Tests/ModelBuilding/ModelBuilder.Other.cs +++ b/test/EFCore.Tests/ModelBuilding/ModelBuilder.Other.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Microsoft.Extensions.DependencyInjection; using Xunit; diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericRelationshipStringTest.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericRelationshipStringTest.cs index f9b1a47b1ed..5617a046bf5 100644 --- a/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericRelationshipStringTest.cs +++ b/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericRelationshipStringTest.cs @@ -7,7 +7,6 @@ using System.Linq.Expressions; using System.Reflection; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -246,22 +245,29 @@ public override TestOwnershipBuilder WithOwner( public override TestOwnedNavigationBuilder OwnsOne( Expression> navigationExpression) - => Wrap(OwnedNavigationBuilder.OwnsOne(navigationExpression?.GetPropertyAccess().GetSimpleMemberName())); + => Wrap( + OwnedNavigationBuilder.OwnsOne(navigationExpression?.GetPropertyAccess().GetSimpleMemberName())); public override TestOwnedNavigationBuilder OwnsOne( Expression> navigationExpression, Action> buildAction) - => Wrap(OwnedNavigationBuilder.OwnsOne(navigationExpression?.GetPropertyAccess().GetSimpleMemberName(), - r => buildAction(Wrap(r)))); + => Wrap( + OwnedNavigationBuilder.OwnsOne( + navigationExpression?.GetPropertyAccess().GetSimpleMemberName(), + r => buildAction(Wrap(r)))); - public override TestOwnedNavigationBuilder OwnsMany(Expression>> navigationExpression) - => Wrap(OwnedNavigationBuilder.OwnsMany(navigationExpression?.GetPropertyAccess().GetSimpleMemberName())); + public override TestOwnedNavigationBuilder OwnsMany( + Expression>> navigationExpression) + => Wrap( + OwnedNavigationBuilder.OwnsMany(navigationExpression?.GetPropertyAccess().GetSimpleMemberName())); public override TestOwnedNavigationBuilder OwnsMany( Expression>> navigationExpression, Action> buildAction) - => Wrap(OwnedNavigationBuilder.OwnsMany(navigationExpression?.GetPropertyAccess().GetSimpleMemberName(), - r => buildAction(Wrap(r)))); + => Wrap( + OwnedNavigationBuilder.OwnsMany( + navigationExpression?.GetPropertyAccess().GetSimpleMemberName(), + r => buildAction(Wrap(r)))); public override TestReferenceNavigationBuilder HasOne( Expression> navigationExpression = null) diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs index 3001eaab043..2481762eda5 100644 --- a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs +++ b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs @@ -8,7 +8,6 @@ using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -34,8 +33,9 @@ public override void Reconfiguring_owned_type_as_non_owned_throws() Assert.Equal( CoreStrings.ClashingOwnedEntityType(typeof(CustomerDetails).FullName), - Assert.Throws(() => - modelBuilder.Entity().HasOne(c => c.Details)).Message); + Assert.Throws( + () => + modelBuilder.Entity().HasOne(c => c.Details)).Message); } //Shadow navigations not supported #3864 @@ -130,7 +130,8 @@ public override TestEntityTypeBuilder OwnsOne( public override TestOwnedNavigationBuilder OwnsMany( Expression>> navigationExpression) => new NonGenericTestOwnedNavigationBuilder( - EntityTypeBuilder.OwnsMany(typeof(TRelatedEntity).FullName, + EntityTypeBuilder.OwnsMany( + typeof(TRelatedEntity).FullName, navigationExpression.GetPropertyAccess().GetSimpleMemberName())); public override TestEntityTypeBuilder OwnsMany( diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericTest.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericTest.cs index 6eac854d6c2..9d509651708 100644 --- a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericTest.cs +++ b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericTest.cs @@ -7,7 +7,6 @@ using System.Linq.Expressions; using System.Reflection; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericUnqualifiedStringTest.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericUnqualifiedStringTest.cs index efa29b1d854..ed94646c33c 100644 --- a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericUnqualifiedStringTest.cs +++ b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericUnqualifiedStringTest.cs @@ -7,7 +7,6 @@ using System.Linq.Expressions; using System.Reflection; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -78,7 +77,8 @@ public override TestEntityTypeBuilder OwnsOne( public override TestOwnedNavigationBuilder OwnsMany( Expression>> navigationExpression) => new NonGenericTestOwnedNavigationBuilder( - EntityTypeBuilder.OwnsMany(typeof(TRelatedEntity).Name, + EntityTypeBuilder.OwnsMany( + typeof(TRelatedEntity).Name, navigationExpression.GetPropertyAccess().GetSimpleMemberName())); public override TestEntityTypeBuilder OwnsMany( @@ -108,8 +108,8 @@ public override TestCollectionNavigationBuilder HasMany return new NonGenericTestCollectionNavigationBuilder( navigationName == null - ? EntityTypeBuilder.HasMany(typeof(TRelatedEntity).FullName, navigationName) - : EntityTypeBuilder.HasMany(navigationName)); + ? EntityTypeBuilder.HasMany(typeof(TRelatedEntity).FullName, navigationName) + : EntityTypeBuilder.HasMany(navigationName)); } } @@ -187,8 +187,8 @@ public override TestReferenceNavigationBuilder( navigationName == null - ? OwnedNavigationBuilder.HasOne(typeof(TNewDependentEntity).FullName, navigationName) - : OwnedNavigationBuilder.HasOne(navigationName)); + ? OwnedNavigationBuilder.HasOne(typeof(TNewDependentEntity).FullName, navigationName) + : OwnedNavigationBuilder.HasOne(navigationName)); } } } diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilderTestBase.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilderTestBase.cs index 59eb428dc94..1c9280cb390 100644 --- a/test/EFCore.Tests/ModelBuilding/ModelBuilderTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/ModelBuilderTestBase.cs @@ -101,17 +101,9 @@ protected TestModelBuilder HobNobBuilder() var builder = CreateModelBuilder(); builder.Entity().HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); builder.Entity().HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); return builder; } diff --git a/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs b/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs index bf33e37edee..cbbcb8b7e98 100644 --- a/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs @@ -144,11 +144,7 @@ public virtual void Can_set_composite_entity_key_from_clr_properties() modelBuilder .Entity() .HasKey( - e => new - { - e.Id, - e.Name - }); + e => new { e.Id, e.Name }); var entity = model.FindEntityType(typeof(Customer)); @@ -188,11 +184,7 @@ public virtual void Can_set_entity_key_with_annotations() var keyBuilder = modelBuilder .Entity() .HasKey( - e => new - { - e.Id, - e.Name - }); + e => new { e.Id, e.Name }); keyBuilder.HasAnnotation("A1", "V1") .HasAnnotation("A2", "V2"); @@ -559,10 +551,7 @@ public virtual void Key_properties_cannot_be_made_optional() b => { b.HasAlternateKey( - e => new - { - e.Down - }); + e => new { e.Down }); b.Property(e => e.Down).IsRequired(false); })).Message); } @@ -637,7 +626,7 @@ public virtual void Properties_can_be_made_concurrency_tokens() { b.Property(e => e.Up).IsConcurrencyToken(); b.Property(e => e.Down).IsConcurrencyToken(false); - b.Property("Charm").IsConcurrencyToken(true); + b.Property("Charm").IsConcurrencyToken(); b.Property("Strange").IsConcurrencyToken(false); b.Property("Top").IsConcurrencyToken(); b.Property("Bottom").IsConcurrencyToken(false); @@ -825,7 +814,8 @@ public virtual void IEnumerable_properties_with_value_converter_set_are_not_disc var model = modelBuilder.Model; modelBuilder.Entity( - b => b.Property(e => e.ExpandoObject).HasConversion(v => (string)((IDictionary)v)["Value"], v => DeserializeExpandoObject(v))); + b => b.Property(e => e.ExpandoObject).HasConversion( + v => (string)((IDictionary)v)["Value"], v => DeserializeExpandoObject(v))); modelBuilder.FinalizeModel(); @@ -1211,16 +1201,9 @@ public virtual void Can_add_contained_indexes() var entityBuilder = modelBuilder.Entity(); var firstIndexBuilder = entityBuilder.HasIndex( - ix => new - { - ix.Id, - ix.AlternateKey - }).IsUnique(); + ix => new { ix.Id, ix.AlternateKey }).IsUnique(); var secondIndexBuilder = entityBuilder.HasIndex( - ix => new - { - ix.Id - }); + ix => new { ix.Id }); var entityType = (IEntityType)model.FindEntityType(typeof(Customer)); @@ -1265,17 +1248,8 @@ public virtual void Can_add_seed_data_objects() c => { c.HasData( - new Beta - { - Id = -1 - }); - var customers = new List - { - new Beta - { - Id = -2 - } - }; + new Beta { Id = -1 }); + var customers = new List { new Beta { Id = -2 } }; c.HasData(customers); }); @@ -1297,17 +1271,8 @@ public virtual void Can_add_seed_data_anonymous_objects() c => { c.HasData( - new - { - Id = -1 - }); - var customers = new List - { - new - { - Id = -2 - } - }; + new { Id = -1 }); + var customers = new List { new { Id = -2 } }; c.HasData(customers); }); diff --git a/test/EFCore.Tests/ModelBuilding/OneToManyTestBase.cs b/test/EFCore.Tests/ModelBuilding/OneToManyTestBase.cs index d3213f209a6..23223878549 100644 --- a/test/EFCore.Tests/ModelBuilding/OneToManyTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/OneToManyTestBase.cs @@ -330,7 +330,9 @@ public virtual void Creates_relationship_with_no_navigations() AssertEqual( new[] { - "AnotherCustomerId", fk.Properties.Single().Name, newFk.Properties.Single().Name, + "AnotherCustomerId", + fk.Properties.Single().Name, + newFk.Properties.Single().Name, dependentKey.Properties.Single().Name }, dependentType.GetProperties().Select(p => p.Name)); @@ -1387,11 +1389,7 @@ public virtual void Principal_key_by_convention_is_not_replaced_with_new_incompa modelBuilder .Entity().HasMany(e => e.Pickles).WithOne(e => e.BigMak) .HasForeignKey( - e => new - { - e.BurgerId, - e.Id - }); + e => new { e.BurgerId, e.Id }); modelBuilder.Ignore(); var dependentType = model.FindEntityType(typeof(Pickle)); @@ -1443,10 +1441,7 @@ public virtual void Explicit_principal_key_is_not_replaced_with_new_primary_key( modelBuilder .Entity().HasMany(e => e.Pickles).WithOne(e => e.BigMak) .HasPrincipalKey( - e => new - { - e.Id - }); + e => new { e.Id }); modelBuilder.Ignore(); var principalType = model.FindEntityType(typeof(BigMak)); @@ -1498,19 +1493,11 @@ public virtual void Creates_both_navigations_and_uses_existing_composite_FK() var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder .Entity().HasOne(e => e.Whoopper).WithMany() .HasForeignKey( - c => new - { - c.BurgerId1, - c.BurgerId2 - }); + c => new { c.BurgerId1, c.BurgerId2 }); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -1523,11 +1510,7 @@ public virtual void Creates_both_navigations_and_uses_existing_composite_FK() modelBuilder .Entity().HasMany(e => e.Tomatoes).WithOne(e => e.Whoopper) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.FinalizeModel(); @@ -1554,11 +1537,7 @@ public virtual void Creates_both_navigations_and_creates_composite_FK_specified( var model = modelBuilder.Model; modelBuilder.Entity( b => b.HasKey( - c => new - { - c.Id1, - c.Id2 - })); + c => new { c.Id1, c.Id2 })); modelBuilder.Entity(); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -1575,11 +1554,7 @@ public virtual void Creates_both_navigations_and_creates_composite_FK_specified( modelBuilder .Entity().HasMany(e => e.Tomatoes).WithOne(e => e.Whoopper) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.FinalizeModel(); @@ -1615,11 +1590,7 @@ public virtual void Can_use_alternate_composite_key() var model = modelBuilder.Model; modelBuilder.Entity( b => b.HasKey( - c => new - { - c.Id1, - c.Id2 - })); + c => new { c.Id1, c.Id2 })); modelBuilder.Entity(); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -1638,17 +1609,9 @@ public virtual void Can_use_alternate_composite_key() modelBuilder .Entity().HasMany(e => e.Tomatoes).WithOne(e => e.Whoopper) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }) + e => new { e.BurgerId1, e.BurgerId2 }) .HasPrincipalKey( - e => new - { - e.AlternateKey1, - e.AlternateKey2 - }); + e => new { e.AlternateKey1, e.AlternateKey2 }); modelBuilder.FinalizeModel(); @@ -1691,11 +1654,7 @@ public virtual void Can_use_alternate_composite_key_in_any_order() var model = modelBuilder.Model; modelBuilder.Entity( b => b.HasKey( - c => new - { - c.Id1, - c.Id2 - })); + c => new { c.Id1, c.Id2 })); modelBuilder.Entity(); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -1714,17 +1673,9 @@ public virtual void Can_use_alternate_composite_key_in_any_order() modelBuilder .Entity().HasMany(e => e.Tomatoes).WithOne(e => e.Whoopper) .HasPrincipalKey( - e => new - { - e.AlternateKey1, - e.AlternateKey2 - }) + e => new { e.AlternateKey1, e.AlternateKey2 }) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.FinalizeModel(); @@ -1766,11 +1717,7 @@ public virtual void Creates_specified_composite_FK_with_navigation_to_dependent( var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity( b => { @@ -1792,11 +1739,7 @@ public virtual void Creates_specified_composite_FK_with_navigation_to_dependent( modelBuilder .Entity().HasMany(e => e.Tomatoes).WithOne() .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.FinalizeModel(); @@ -1822,11 +1765,7 @@ public virtual void Creates_specified_composite_FK_with_navigation_to_principal( var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity(); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -1840,11 +1779,7 @@ public virtual void Creates_specified_composite_FK_with_navigation_to_principal( modelBuilder .Entity().HasMany().WithOne(e => e.Whoopper) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.FinalizeModel(); @@ -1871,11 +1806,7 @@ public virtual void Creates_relationship_with_no_navigations_and_specified_compo var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity().HasMany(w => w.Tomatoes).WithOne(t => t.Whoopper); modelBuilder.Entity(); modelBuilder.Ignore(); @@ -1894,11 +1825,7 @@ public virtual void Creates_relationship_with_no_navigations_and_specified_compo modelBuilder .Entity().HasMany().WithOne() .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.FinalizeModel(); @@ -1914,7 +1841,10 @@ public virtual void Creates_relationship_with_no_navigations_and_specified_compo AssertEqual( new[] { - fkProperty1.Name, fkProperty2.Name, dependentKey.Properties.Single().Name, fk.Properties[0].Name, + fkProperty1.Name, + fkProperty2.Name, + dependentKey.Properties.Single().Name, + fk.Properties[0].Name, fk.Properties[1].Name }, dependentType.GetProperties().Select(p => p.Name)); Assert.Empty(principalType.GetForeignKeys()); @@ -1933,18 +1863,10 @@ public virtual void Creates_relationship_on_existing_FK_is_using_different_princ var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity().HasOne(e => e.ToastedBun).WithOne(e => e.Whoopper) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -1957,17 +1879,9 @@ public virtual void Creates_relationship_on_existing_FK_is_using_different_princ modelBuilder .Entity().HasMany().WithOne() .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }) + e => new { e.BurgerId1, e.BurgerId2 }) .HasPrincipalKey( - e => new - { - e.AlternateKey1, - e.AlternateKey2 - }); + e => new { e.AlternateKey1, e.AlternateKey2 }); var navigation = dependentType.GetNavigations().Single(); var existingFk = navigation.ForeignKey; @@ -2001,18 +1915,10 @@ public virtual void Creates_relationship_on_existing_FK_is_using_different_princ var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity().HasOne(e => e.ToastedBun).WithOne(e => e.Whoopper) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -2025,17 +1931,9 @@ public virtual void Creates_relationship_on_existing_FK_is_using_different_princ modelBuilder .Entity().HasMany().WithOne() .HasPrincipalKey( - e => new - { - e.AlternateKey1, - e.AlternateKey2 - }) + e => new { e.AlternateKey1, e.AlternateKey2 }) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); var existingFk = dependentType.GetNavigations().Single().ForeignKey; Assert.Same(existingFk, principalType.GetNavigations().Single().ForeignKey); @@ -2065,11 +1963,7 @@ public virtual void Creates_overlapping_foreign_keys_with_different_nullability( eb => { eb.HasKey( - c => new - { - c.OrderId, - c.CustomerId - }); + c => new { c.OrderId, c.CustomerId }); }); modelBuilder.Entity(eb => { eb.HasKey(c => new { c.Id, c.Name }); }); @@ -2080,7 +1974,7 @@ public virtual void Creates_overlapping_foreign_keys_with_different_nullability( eb.HasOne(p => p.Order).WithMany(o => o.Products).HasForeignKey("CommonId", "OrderId"); eb.HasOne().WithMany(c => c.Products).HasForeignKey("CommonId", "Category").IsRequired(); - eb.HasIndex("Id", "OrderId").IsUnique(true); + eb.HasIndex("Id", "OrderId").IsUnique(); eb.HasKey("Id", "CommonId"); }); @@ -2204,11 +2098,7 @@ public virtual void Nullable_FK_are_optional_by_default() modelBuilder .Entity().HasMany(e => e.Nobs).WithOne(e => e.Hob) .HasForeignKey( - e => new - { - e.HobId1, - e.HobId2 - }); + e => new { e.HobId1, e.HobId2 }); modelBuilder.FinalizeModel(); @@ -2231,11 +2121,7 @@ public virtual void Non_nullable_FK_are_required_by_default() modelBuilder .Entity().HasMany(e => e.Hobs).WithOne(e => e.Nob) .HasForeignKey( - e => new - { - e.NobId1, - e.NobId2 - }); + e => new { e.NobId1, e.NobId2 }); modelBuilder.FinalizeModel(); @@ -2258,11 +2144,7 @@ public virtual void Nullable_FK_can_be_made_required() modelBuilder .Entity().HasMany(e => e.Nobs).WithOne(e => e.Hob) .HasForeignKey( - e => new - { - e.HobId1, - e.HobId2 - }) + e => new { e.HobId1, e.HobId2 }) .IsRequired(); modelBuilder.FinalizeModel(); @@ -2286,11 +2168,7 @@ public virtual void Non_nullable_FK_cannot_be_made_optional() modelBuilder .Entity().HasMany(e => e.Hobs).WithOne(e => e.Nob) .HasForeignKey( - e => new - { - e.NobId1, - e.NobId2 - }) + e => new { e.NobId1, e.NobId2 }) .IsRequired(false); modelBuilder.FinalizeModel(); @@ -2314,11 +2192,7 @@ public virtual void Non_nullable_FK_can_be_made_optional_separately() modelBuilder .Entity().HasMany(e => e.Hobs).WithOne(e => e.Nob) .HasForeignKey( - e => new - { - e.NobId1, - e.NobId2 - }); + e => new { e.NobId1, e.NobId2 }); modelBuilder .Entity().HasMany(e => e.Hobs).WithOne(e => e.Nob) @@ -2745,21 +2619,13 @@ public virtual void Can_use_self_referencing_overlapping_FK_PK() modelBuilder.Entity() .HasKey( - x => new - { - x.GroupHeaderId, - x.AccountId - }); + x => new { x.GroupHeaderId, x.AccountId }); modelBuilder.Entity() .HasOne(x => x.ModifierGroupHeader2) .WithMany(x => x.ModifierGroupHeader1) .HasForeignKey( - x => new - { - x.LinkedGroupHeaderId, - x.AccountId - }); + x => new { x.LinkedGroupHeaderId, x.AccountId }); var contextOptions = new DbContextOptionsBuilder() .UseModel(((Model)modelBuilder.Model).FinalizeModel()) @@ -2770,23 +2636,11 @@ public virtual void Can_use_self_referencing_overlapping_FK_PK() using (var context = new DbContext(contextOptions)) { var parent = context.Add( - new ModifierGroupHeader - { - GroupHeaderId = 77, - AccountId = 90 - }).Entity; + new ModifierGroupHeader { GroupHeaderId = 77, AccountId = 90 }).Entity; var child1 = context.Add( - new ModifierGroupHeader - { - GroupHeaderId = 78, - AccountId = 90 - }).Entity; + new ModifierGroupHeader { GroupHeaderId = 78, AccountId = 90 }).Entity; var child2 = context.Add( - new ModifierGroupHeader - { - GroupHeaderId = 79, - AccountId = 90 - }).Entity; + new ModifierGroupHeader { GroupHeaderId = 79, AccountId = 90 }).Entity; child1.ModifierGroupHeader2 = parent; child2.ModifierGroupHeader2 = parent; diff --git a/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs b/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs index 71bfc0e793b..23d4d22694e 100644 --- a/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs @@ -2056,19 +2056,11 @@ public virtual void Creates_both_navigations_and_uses_existing_composite_FK() var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); var dependentType = model.FindEntityType(typeof(ToastedBun)); modelBuilder.Entity().HasOne().WithOne() .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -2080,11 +2072,7 @@ public virtual void Creates_both_navigations_and_uses_existing_composite_FK() modelBuilder .Entity().HasOne(e => e.ToastedBun).WithOne(e => e.Whoopper) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.FinalizeModel(); @@ -2115,11 +2103,7 @@ public virtual void Creates_both_navigations_and_creates_composite_FK_specified( var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity(); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -2136,11 +2120,7 @@ public virtual void Creates_both_navigations_and_creates_composite_FK_specified( modelBuilder .Entity().HasOne(e => e.ToastedBun).WithOne(e => e.Whoopper) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); var fk = dependentType.GetForeignKeys().Single(); Assert.Same(fkProperty1, fk.Properties[0]); @@ -2172,11 +2152,7 @@ public virtual void Can_use_alternate_composite_key() var model = modelBuilder.Model; modelBuilder.Entity( b => b.HasKey( - c => new - { - c.Id1, - c.Id2 - })); + c => new { c.Id1, c.Id2 })); modelBuilder.Entity(); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -2195,17 +2171,9 @@ public virtual void Can_use_alternate_composite_key() modelBuilder .Entity().HasOne(e => e.ToastedBun).WithOne(e => e.Whoopper) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }) + e => new { e.BurgerId1, e.BurgerId2 }) .HasPrincipalKey( - e => new - { - e.AlternateKey1, - e.AlternateKey2 - }); + e => new { e.AlternateKey1, e.AlternateKey2 }); var fk = dependentType.GetForeignKeys().Single(); Assert.Same(fkProperty1, fk.Properties[0]); @@ -2246,11 +2214,7 @@ public virtual void Can_use_alternate_composite_key_in_any_order() var model = modelBuilder.Model; modelBuilder.Entity( b => b.HasKey( - c => new - { - c.Id1, - c.Id2 - })); + c => new { c.Id1, c.Id2 })); modelBuilder.Entity(); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -2269,17 +2233,9 @@ public virtual void Can_use_alternate_composite_key_in_any_order() modelBuilder .Entity().HasOne(e => e.ToastedBun).WithOne(e => e.Whoopper) .HasPrincipalKey( - e => new - { - e.AlternateKey1, - e.AlternateKey2 - }) + e => new { e.AlternateKey1, e.AlternateKey2 }) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); var fk = dependentType.GetForeignKeys().Single(); Assert.Same(fkProperty1, fk.Properties[0]); @@ -2319,17 +2275,9 @@ public virtual void Uses_composite_PK_for_FK_by_convention() var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -2378,17 +2326,9 @@ public virtual void Principal_and_dependent_can_be_flipped_and_composite_PK_is_s var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -2436,17 +2376,9 @@ public virtual void Principal_and_dependent_can_be_flipped_using_principal_and_c var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -2462,11 +2394,7 @@ public virtual void Principal_and_dependent_can_be_flipped_using_principal_and_c modelBuilder .Entity().HasOne(e => e.Whoopper).WithOne(e => e.Mustard) .HasPrincipalKey( - e => new - { - e.Id1, - e.Id2 - }) + e => new { e.Id1, e.Id2 }) .IsRequired(); var fk = dependentType.GetForeignKeys().Single(); @@ -2498,11 +2426,7 @@ public virtual void Creates_composite_FK_when_specified_on_principal_with_naviga var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity(); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -2519,11 +2443,7 @@ public virtual void Creates_composite_FK_when_specified_on_principal_with_naviga modelBuilder .Entity().HasOne(e => e.ToastedBun).WithOne() .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); var fk = principalType.GetNavigations().Single().ForeignKey; Assert.Same(fkProperty1, fk.Properties[0]); @@ -2547,11 +2467,7 @@ public virtual void Creates_composite_FK_when_specified_on_principal_with_naviga var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity(); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -2568,11 +2484,7 @@ public virtual void Creates_composite_FK_when_specified_on_principal_with_naviga modelBuilder .Entity().HasOne().WithOne(e => e.Whoopper) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); var fk = dependentType.GetNavigations().Single().ForeignKey; Assert.Same(fkProperty1, fk.Properties[0]); @@ -2599,11 +2511,7 @@ public virtual void Creates_composite_FK_when_specified_on_principal_with_no_nav var model = modelBuilder.Model; modelBuilder.Entity().HasOne(b => b.Whoopper).WithOne(w => w.ToastedBun).HasPrincipalKey(); modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -2619,11 +2527,7 @@ public virtual void Creates_composite_FK_when_specified_on_principal_with_no_nav modelBuilder .Entity().HasOne().WithOne() .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); modelBuilder.FinalizeModel(); @@ -2636,7 +2540,10 @@ public virtual void Creates_composite_FK_when_specified_on_principal_with_no_nav AssertEqual( new[] { - "AlternateKey1", "AlternateKey2", principalKey.Properties[0].Name, principalKey.Properties[1].Name, + "AlternateKey1", + "AlternateKey2", + principalKey.Properties[0].Name, + principalKey.Properties[1].Name, principalType.GetForeignKeys().Single().Properties.Single().Name }, principalType.GetProperties().Select(p => p.Name)); @@ -2649,7 +2556,8 @@ public virtual void Creates_composite_FK_when_specified_on_principal_with_no_nav Assert.Same(dependentKey, dependentType.FindPrimaryKey()); Assert.Equal(dependentType.GetForeignKeys().Count(), dependentType.GetIndexes().Count()); Assert.True(fk.DeclaringEntityType.FindIndex(fk.Properties).IsUnique); - Assert.True(principalType.GetForeignKeys() + Assert.True( + principalType.GetForeignKeys() .All(foreignKey => principalType.FindIndex(foreignKey.Properties).IsUnique == foreignKey.IsUnique)); } @@ -2924,16 +2832,10 @@ public virtual void Can_specify_shadow_fk_before_configuring_principal_PK() modelBuilder.Entity() .HasKey( - e => new - { - e.NobId1 - }); + e => new { e.NobId1 }); modelBuilder.Entity() .HasKey( - e => new - { - e.HobId1 - }); + e => new { e.HobId1 }); modelBuilder.FinalizeModel(); @@ -2949,16 +2851,10 @@ public virtual void Can_specify_shadow_fk_before_reconfiguring_principal_PK() var modelBuilder = CreateModelBuilder(); modelBuilder.Entity() .HasKey( - e => new - { - e.Id1 - }); + e => new { e.Id1 }); modelBuilder.Entity() .HasKey( - e => new - { - e.Id1 - }); + e => new { e.Id1 }); modelBuilder.Entity() .HasMany(c => c.Nobs) @@ -2967,16 +2863,10 @@ public virtual void Can_specify_shadow_fk_before_reconfiguring_principal_PK() modelBuilder.Entity() .HasKey( - e => new - { - e.NobId1 - }); + e => new { e.NobId1 }); modelBuilder.Entity() .HasKey( - e => new - { - e.HobId1 - }); + e => new { e.HobId1 }); modelBuilder.FinalizeModel(); @@ -3223,19 +3113,11 @@ public virtual void Creates_relationship_on_existing_FK_if_using_different_princ var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder .Entity().HasOne(e => e.Whoopper).WithMany(e => e.Tomatoes) .HasForeignKey( - c => new - { - c.BurgerId1, - c.BurgerId2 - }); + c => new { c.BurgerId1, c.BurgerId2 }); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -3248,17 +3130,9 @@ public virtual void Creates_relationship_on_existing_FK_if_using_different_princ modelBuilder .Entity().HasOne().WithOne() .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }) + e => new { e.BurgerId1, e.BurgerId2 }) .HasPrincipalKey( - e => new - { - e.AlternateKey1, - e.AlternateKey2 - }); + e => new { e.AlternateKey1, e.AlternateKey2 }); var existingFk = dependentType.GetNavigations().Single().ForeignKey; Assert.Same(existingFk, principalType.GetNavigations().Single().ForeignKey); @@ -3285,19 +3159,11 @@ public virtual void Creates_relationship_on_existing_FK_if_using_different_princ var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder .Entity().HasOne(e => e.Whoopper).WithMany(e => e.Tomatoes) .HasForeignKey( - c => new - { - c.BurgerId1, - c.BurgerId2 - }); + c => new { c.BurgerId1, c.BurgerId2 }); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -3310,17 +3176,9 @@ public virtual void Creates_relationship_on_existing_FK_if_using_different_princ modelBuilder .Entity().HasOne().WithOne() .HasPrincipalKey( - e => new - { - e.AlternateKey1, - e.AlternateKey2 - }) + e => new { e.AlternateKey1, e.AlternateKey2 }) .HasForeignKey( - e => new - { - e.BurgerId1, - e.BurgerId2 - }); + e => new { e.BurgerId1, e.BurgerId2 }); var existingFk = dependentType.GetNavigations().Single().ForeignKey; Assert.Same(existingFk, principalType.GetNavigations().Single().ForeignKey); @@ -3346,17 +3204,9 @@ public virtual void Creates_index_even_if_covered_by_an_alternate_key() var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; modelBuilder.Entity().HasKey( - c => new - { - c.Id1, - c.Id2 - }); + c => new { c.Id1, c.Id2 }); modelBuilder.Entity().HasAlternateKey( - c => new - { - c.BurgerId1, - c.BurgerId2 - }); + c => new { c.BurgerId1, c.BurgerId2 }); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -3366,15 +3216,9 @@ public virtual void Creates_index_even_if_covered_by_an_alternate_key() modelBuilder .Entity().HasOne().WithOne() .HasForeignKey( - e => new - { - e.BurgerId1 - }) + e => new { e.BurgerId1 }) .HasPrincipalKey( - e => new - { - e.AlternateKey1 - }); + e => new { e.AlternateKey1 }); var existingFk = dependentType.GetNavigations().Single().ForeignKey; Assert.Empty(principalType.GetForeignKeys()); @@ -3527,11 +3371,7 @@ public virtual void Nullable_FK_are_optional_by_default() modelBuilder .Entity().HasOne(e => e.Nob).WithOne(e => e.Hob) .HasForeignKey( - e => new - { - e.HobId1, - e.HobId2 - }); + e => new { e.HobId1, e.HobId2 }); var entityType = (IEntityType)modelBuilder.Model.FindEntityType(typeof(Nob)); @@ -3549,11 +3389,7 @@ public virtual void Non_nullable_FK_are_required_by_default() modelBuilder .Entity().HasOne(e => e.Hob).WithOne(e => e.Nob) .HasForeignKey( - e => new - { - e.NobId1, - e.NobId2 - }); + e => new { e.NobId1, e.NobId2 }); var entityType = (IEntityType)modelBuilder.Model.FindEntityType(typeof(Hob)); @@ -3577,11 +3413,7 @@ public virtual void Nullable_FK_can_be_made_required() .HasOne(e => e.Nob).WithOne(e => e.Hob) .IsRequired() .HasForeignKey( - e => new - { - e.HobId1, - e.HobId2 - }); + e => new { e.HobId1, e.HobId2 }); modelBuilder.FinalizeModel(); @@ -3614,11 +3446,7 @@ public virtual void Non_nullable_FK_can_be_made_optional() .Ignore(e => e.Hobs) .HasOne(e => e.Hob).WithOne(e => e.Nob) .HasForeignKey( - e => new - { - e.NobId1, - e.NobId2 - }) + e => new { e.NobId1, e.NobId2 }) .IsRequired(false); modelBuilder.FinalizeModel(); @@ -3649,11 +3477,7 @@ public virtual void Non_nullable_FK_can_be_made_optional_separately() .Ignore(e => e.Hobs) .HasOne(e => e.Hob).WithOne(e => e.Nob) .HasForeignKey( - e => new - { - e.NobId1, - e.NobId2 - }); + e => new { e.NobId1, e.NobId2 }); modelBuilder .Entity() @@ -3687,11 +3511,7 @@ public virtual void Unspecified_FK_can_be_made_optional() .Entity().HasOne(e => e.Nob).WithOne(e => e.Hob) .IsRequired(false) .HasPrincipalKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); var fk = dependentType.GetForeignKeys().Single(); Assert.False(fk.IsRequired); @@ -3713,11 +3533,7 @@ public virtual void Unspecified_FK_can_be_made_optional_in_any_order() modelBuilder .Entity().HasOne(e => e.Nob).WithOne(e => e.Hob) .HasPrincipalKey( - e => new - { - e.Id1, - e.Id2 - }) + e => new { e.Id1, e.Id2 }) .IsRequired(false); var fk = dependentType.GetForeignKeys().Single(); @@ -3741,11 +3557,7 @@ public virtual void Unspecified_FK_can_be_made_required() .Entity().HasOne(e => e.Nob).WithOne(e => e.Hob) .IsRequired() .HasPrincipalKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); var fk = dependentType.GetForeignKeys().Single(); Assert.True(fk.IsRequired); @@ -3768,31 +3580,15 @@ public virtual void Can_be_defined_before_the_PK_from_principal() { eb.HasOne(e => e.Nob).WithOne(e => e.Hob) .HasForeignKey( - e => new - { - e.HobId1, - e.HobId2 - }) + e => new { e.HobId1, e.HobId2 }) .HasPrincipalKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); eb.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); }); modelBuilder.Entity().HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); var dependentEntityType = modelBuilder.Model.FindEntityType(typeof(Nob)); var fk = dependentEntityType.GetForeignKeys().Single(); @@ -3815,31 +3611,15 @@ public virtual void Can_be_defined_before_the_PK_from_dependent() { eb.HasOne(e => e.Nob).WithOne(e => e.Hob) .HasForeignKey( - e => new - { - e.NobId1, - e.NobId2 - }) + e => new { e.NobId1, e.NobId2 }) .HasPrincipalKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); eb.HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); }); modelBuilder.Entity().HasKey( - e => new - { - e.Id1, - e.Id2 - }); + e => new { e.Id1, e.Id2 }); var dependentEntityType = modelBuilder.Model.FindEntityType(typeof(Hob)); var fk = dependentEntityType.GetForeignKeys().Single(); @@ -4399,19 +4179,11 @@ public virtual void Can_use_self_referencing_overlapping_FK_PK() b => { b.HasKey( - e => new - { - e.ListId, - e.PreviousNodeId - }); + e => new { e.ListId, e.PreviousNodeId }); b.HasOne(e => e.NextNode) .WithOne(e => e.PreviousNode) .HasForeignKey( - e => new - { - e.ListId, - e.NextNodeId - }); + e => new { e.ListId, e.NextNodeId }); }); var contextOptions = new DbContextOptionsBuilder() @@ -4423,23 +4195,11 @@ public virtual void Can_use_self_referencing_overlapping_FK_PK() using (var context = new DbContext(contextOptions)) { var node1 = context.Add( - new Node - { - ListId = 90, - PreviousNodeId = 77 - }).Entity; + new Node { ListId = 90, PreviousNodeId = 77 }).Entity; var node2 = context.Add( - new Node - { - ListId = 90, - PreviousNodeId = 78 - }).Entity; + new Node { ListId = 90, PreviousNodeId = 78 }).Entity; var node3 = context.Add( - new Node - { - ListId = 90, - PreviousNodeId = 79 - }).Entity; + new Node { ListId = 90, PreviousNodeId = 79 }).Entity; node1.NextNode = node2; node3.PreviousNode = node2; diff --git a/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs b/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs index 9b76478c3e8..fd17645677f 100644 --- a/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs @@ -23,13 +23,14 @@ public virtual void Can_configure_owned_type() var model = modelBuilder.Model; modelBuilder.Entity() - .OwnsOne(c => c.Details, db => - { - db.WithOwner(d => d.Customer) - .HasPrincipalKey(c => c.AlternateKey); - db.Property(d => d.CustomerId); - db.HasIndex(d => d.CustomerId); - }); + .OwnsOne( + c => c.Details, db => + { + db.WithOwner(d => d.Customer) + .HasPrincipalKey(c => c.AlternateKey); + db.Property(d => d.CustomerId); + db.HasIndex(d => d.CustomerId); + }); modelBuilder.FinalizeModel(); @@ -395,10 +396,7 @@ public virtual void Can_configure_owned_type_from_an_owned_type_collection() ob.HasKey(o => o.OrderId); ob.OwnsOne(o => o.Details) .HasData( - new OrderDetails - { - OrderId = -1 - }); + new OrderDetails { OrderId = -1 }); }); modelBuilder.FinalizeModel(); @@ -432,11 +430,7 @@ public virtual void Can_chain_owned_type_collection_configurations() { ob.HasKey(o => o.OrderId); ob.HasData( - new Order - { - OrderId = -2, - CustomerId = -1 - }); + new Order { OrderId = -2, CustomerId = -1 }); ob.OwnsMany(o => o.Products) .HasKey(p => p.Id); }); @@ -688,8 +682,8 @@ public virtual void Can_configure_fk_on_multiple_ownerships() b => b.Label, lb => { lb.WithOwner() - .HasForeignKey("BookLabelId") - .HasAnnotation("Foo", "Bar"); + .HasForeignKey("BookLabelId") + .HasAnnotation("Foo", "Bar"); }); modelBuilder.Entity() .OwnsOne(b => b.AlternateLabel) @@ -822,7 +816,7 @@ public virtual void Throws_on_FK_matching_two_relationships() Assert.Equal( CoreStrings.AmbiguousForeignKeyPropertyCandidates( - nameof(BookLabel) +"." + nameof(BookLabel.Book), + nameof(BookLabel) + "." + nameof(BookLabel.Book), nameof(Book) + "." + nameof(Book.Label), nameof(BookLabel), nameof(Book) + "." + nameof(Book.AlternateLabel), @@ -1115,8 +1109,9 @@ public virtual void Reconfiguring_entity_type_as_owned_throws() Assert.Equal( CoreStrings.ClashingNonOwnedEntityType(nameof(CustomerDetails)), - Assert.Throws(() => - modelBuilder.Entity().OwnsOne(c => c.Details)).Message); + Assert.Throws( + () => + modelBuilder.Entity().OwnsOne(c => c.Details)).Message); } [ConditionalFact] @@ -1129,8 +1124,9 @@ public virtual void Reconfiguring_owned_type_as_non_owned_throws() Assert.Equal( CoreStrings.ClashingOwnedEntityType(nameof(CustomerDetails)), - Assert.Throws(() => - modelBuilder.Entity().HasOne(c => c.Details)).Message); + Assert.Throws( + () => + modelBuilder.Entity().HasOne(c => c.Details)).Message); } [ConditionalFact] diff --git a/test/EFCore.Tests/ModelBuilding/TestModel.cs b/test/EFCore.Tests/ModelBuilding/TestModel.cs index 7c2ff836da3..8f46435e4fb 100644 --- a/test/EFCore.Tests/ModelBuilding/TestModel.cs +++ b/test/EFCore.Tests/ModelBuilding/TestModel.cs @@ -287,14 +287,19 @@ protected class User { [Required] public Guid Id { get; set; } + [Required] [MaxLength(150)] public string Name { get; set; } + [Required] public User CreatedBy { get; set; } + public User UpdatedBy { get; set; } + [Required] public Guid CreatedById { get; set; } + public Guid? UpdatedById { get; set; } } diff --git a/test/EFCore.Tests/ModelSourceTest.cs b/test/EFCore.Tests/ModelSourceTest.cs index 3d01927920c..a1fe7b3c8b2 100644 --- a/test/EFCore.Tests/ModelSourceTest.cs +++ b/test/EFCore.Tests/ModelSourceTest.cs @@ -78,9 +78,11 @@ public void Adds_all_entities_based_on_all_distinct_entity_types_found() var model = CreateDefaultModelSource(setFinder) .GetModel( InMemoryTestHelpers.Instance.CreateContext(), - new RuntimeConventionSetBuilder(new ProviderConventionSetBuilder( - InMemoryTestHelpers.Instance.CreateContextServices().GetRequiredService() - .With(setFinder)), new List())); + new RuntimeConventionSetBuilder( + new ProviderConventionSetBuilder( + InMemoryTestHelpers.Instance.CreateContextServices() + .GetRequiredService() + .With(setFinder)), new List())); Assert.Equal( new[] { typeof(SetA).DisplayName(), typeof(SetB).DisplayName() }, diff --git a/test/EFCore.Tests/Query/ExpressionEqualityComparerTest.cs b/test/EFCore.Tests/Query/ExpressionEqualityComparerTest.cs index f2207c383ba..ed90b20dea1 100644 --- a/test/EFCore.Tests/Query/ExpressionEqualityComparerTest.cs +++ b/test/EFCore.Tests/Query/ExpressionEqualityComparerTest.cs @@ -33,19 +33,12 @@ public void Member_init_expressions_are_compared_correctly() Expression e1 = Expression.MemberInit( Expression.New(typeof(Node)), - new List - { - bindingMessages - } + new List { bindingMessages } ); Expression e2 = Expression.MemberInit( Expression.New(typeof(Node)), - new List - { - bindingMessages, - bindingDescriptions - } + new List { bindingMessages, bindingDescriptions } ); Assert.NotEqual(expressionComparer.GetHashCode(e1), expressionComparer.GetHashCode(e2)); diff --git a/test/EFCore.Tests/Storage/ValueComparerTest.cs b/test/EFCore.Tests/Storage/ValueComparerTest.cs index 99263db3602..4de8839c0a6 100644 --- a/test/EFCore.Tests/Storage/ValueComparerTest.cs +++ b/test/EFCore.Tests/Storage/ValueComparerTest.cs @@ -92,29 +92,13 @@ public void Default_comparer_works_for_structs() { CompareTest( typeof(JustAStruct), - new JustAStruct - { - A = 1, - B = "B1" - }, - new JustAStruct - { - A = 1, - B = "B2" - }); + new JustAStruct { A = 1, B = "B1" }, + new JustAStruct { A = 1, B = "B2" }); CompareTest( typeof(JustAStruct), - new JustAStruct - { - A = 1, - B = "B" - }, - new JustAStruct - { - A = 2, - B = "B" - }); + new JustAStruct { A = 1, B = "B" }, + new JustAStruct { A = 2, B = "B" }); } private struct JustAStruct @@ -128,16 +112,8 @@ public void Default_comparer_works_for_structs_with_equality() { CompareTest( typeof(JustAStructWithEquality), - new JustAStructWithEquality - { - A = 1, - B = "B" - }, - new JustAStructWithEquality - { - A = 2, - B = "B" - }); + new JustAStructWithEquality { A = 1, B = "B" }, + new JustAStructWithEquality { A = 2, B = "B" }); } private struct JustAStructWithEquality @@ -158,16 +134,8 @@ public void Default_comparer_works_for_structs_with_equality_operators() { CompareTest( typeof(JustAStructWithEqualityOperators), - new JustAStructWithEqualityOperators - { - A = 1, - B = "B" - }, - new JustAStructWithEqualityOperators - { - A = 2, - B = "B" - }); + new JustAStructWithEqualityOperators { A = 1, B = "B" }, + new JustAStructWithEqualityOperators { A = 2, B = "B" }); } #pragma warning disable 660,661 @@ -190,14 +158,8 @@ public void Default_comparer_works_for_classes() { CompareTest( typeof(JustAClass), // Reference equality - new JustAClass - { - A = 1 - }, - new JustAClass - { - A = 1 - }); + new JustAClass { A = 1 }, + new JustAClass { A = 1 }); } private class JustAClass @@ -210,25 +172,13 @@ public void Default_comparer_works_for_classes_with_equality_members() { var comparer = CompareTest( typeof(JustAClassWithEquality), - new JustAClassWithEquality - { - A = 1 - }, - new JustAClassWithEquality - { - A = 2 - }); + new JustAClassWithEquality { A = 1 }, + new JustAClassWithEquality { A = 2 }); Assert.True( comparer.Equals( - new JustAClassWithEquality - { - A = 1 - }, - new JustAClassWithEquality - { - A = 1 - })); + new JustAClassWithEquality { A = 1 }, + new JustAClassWithEquality { A = 1 })); } private sealed class JustAClassWithEquality @@ -251,25 +201,13 @@ public void Default_comparer_works_for_classes_with_equality_operators() { var comparer = CompareTest( typeof(JustAClassWithEqualityOperators), - new JustAClassWithEqualityOperators - { - A = 1 - }, - new JustAClassWithEqualityOperators - { - A = 2 - }); + new JustAClassWithEqualityOperators { A = 1 }, + new JustAClassWithEqualityOperators { A = 2 }); Assert.True( comparer.Equals( - new JustAClassWithEqualityOperators - { - A = 1 - }, - new JustAClassWithEqualityOperators - { - A = 1 - })); + new JustAClassWithEqualityOperators { A = 1 }, + new JustAClassWithEqualityOperators { A = 1 })); } #pragma warning disable 660,661 @@ -335,53 +273,17 @@ public void Default_raw_comparer_works_for_non_null_normal_types() GenericCompareTest(1, "A"); GenericCompareTest(JustAnEnum.A, JustAnEnum.B); GenericCompareTest( - new JustAClass - { - A = 1 - }, new JustAClass - { - A = 2 - }); + new JustAClass { A = 1 }, new JustAClass { A = 2 }); GenericCompareTest( - new JustAClassWithEquality - { - A = 1 - }, new JustAClassWithEquality - { - A = 2 - }); + new JustAClassWithEquality { A = 1 }, new JustAClassWithEquality { A = 2 }); GenericCompareTest( - new JustAClassWithEqualityOperators - { - A = 1 - }, new JustAClassWithEqualityOperators - { - A = 2 - }); + new JustAClassWithEqualityOperators { A = 1 }, new JustAClassWithEqualityOperators { A = 2 }); GenericCompareTest( - new JustAStruct - { - A = 1 - }, new JustAStruct - { - A = 2 - }); + new JustAStruct { A = 1 }, new JustAStruct { A = 2 }); GenericCompareTest( - new JustAStructWithEquality - { - A = 1 - }, new JustAStructWithEquality - { - A = 2 - }); + new JustAStructWithEquality { A = 1 }, new JustAStructWithEquality { A = 2 }); GenericCompareTest( - new JustAStructWithEqualityOperators - { - A = 1 - }, new JustAStructWithEqualityOperators - { - A = 2 - }); + new JustAStructWithEqualityOperators { A = 1 }, new JustAStructWithEqualityOperators { A = 2 }); } [ConditionalFact] @@ -403,36 +305,18 @@ public void Default_comparer_works_for_normal_types_mixing_nullables() CompareTest( typeof(JustAStruct), - (JustAStruct?)new JustAStruct - { - A = 1 - }, - new JustAStruct - { - A = 2 - }); + (JustAStruct?)new JustAStruct { A = 1 }, + new JustAStruct { A = 2 }); CompareTest( typeof(JustAStructWithEquality), - (JustAStructWithEquality?)new JustAStructWithEquality - { - A = 1 - }, - new JustAStructWithEquality - { - A = 2 - }); + (JustAStructWithEquality?)new JustAStructWithEquality { A = 1 }, + new JustAStructWithEquality { A = 2 }); CompareTest( typeof(JustAStructWithEqualityOperators), - (JustAStructWithEqualityOperators?)new JustAStructWithEqualityOperators - { - A = 1 - }, - new JustAStructWithEqualityOperators - { - A = 2 - }); + (JustAStructWithEqualityOperators?)new JustAStructWithEqualityOperators { A = 1 }, + new JustAStructWithEqualityOperators { A = 2 }); } [ConditionalFact] @@ -454,36 +338,18 @@ public void Default_comparer_works_for_normal_nullable_types_mixing_nullables() CompareTest( typeof(JustAStruct?), - (JustAStruct?)new JustAStruct - { - A = 1 - }, - new JustAStruct - { - A = 2 - }); + (JustAStruct?)new JustAStruct { A = 1 }, + new JustAStruct { A = 2 }); CompareTest( typeof(JustAStructWithEquality?), - (JustAStructWithEquality?)new JustAStructWithEquality - { - A = 1 - }, - new JustAStructWithEquality - { - A = 2 - }); + (JustAStructWithEquality?)new JustAStructWithEquality { A = 1 }, + new JustAStructWithEquality { A = 2 }); CompareTest( typeof(JustAStructWithEqualityOperators?), - (JustAStructWithEqualityOperators?)new JustAStructWithEqualityOperators - { - A = 1 - }, - new JustAStructWithEqualityOperators - { - A = 2 - }); + (JustAStructWithEqualityOperators?)new JustAStructWithEqualityOperators { A = 1 }, + new JustAStructWithEqualityOperators { A = 2 }); } [ConditionalFact] @@ -505,40 +371,22 @@ public void Can_clone_to_nullable() CompareTest( typeof(JustAStruct), - (JustAStruct?)new JustAStruct - { - A = 1 - }, - new JustAStruct - { - A = 2 - }, + (JustAStruct?)new JustAStruct { A = 1 }, + new JustAStruct { A = 2 }, null, true); CompareTest( typeof(JustAStructWithEquality), - (JustAStructWithEquality?)new JustAStructWithEquality - { - A = 1 - }, - new JustAStructWithEquality - { - A = 2 - }, + (JustAStructWithEquality?)new JustAStructWithEquality { A = 1 }, + new JustAStructWithEquality { A = 2 }, null, true); CompareTest( typeof(JustAStructWithEqualityOperators), - (JustAStructWithEqualityOperators?)new JustAStructWithEqualityOperators - { - A = 1 - }, - new JustAStructWithEqualityOperators - { - A = 2 - }, + (JustAStructWithEqualityOperators?)new JustAStructWithEqualityOperators { A = 1 }, + new JustAStructWithEqualityOperators { A = 2 }, null, true); } diff --git a/test/EFCore.Tests/Storage/ValueConverterSelectorTest.cs b/test/EFCore.Tests/Storage/ValueConverterSelectorTest.cs index 0d2f813f33f..94e6297f20f 100644 --- a/test/EFCore.Tests/Storage/ValueConverterSelectorTest.cs +++ b/test/EFCore.Tests/Storage/ValueConverterSelectorTest.cs @@ -281,9 +281,17 @@ public void Can_get_explicit_converters_for_numeric_types() { var types = new[] { - typeof(int), typeof(short), typeof(long), typeof(sbyte), - typeof(uint), typeof(ushort), typeof(ulong), typeof(byte), - typeof(decimal), typeof(double), typeof(float) + typeof(int), + typeof(short), + typeof(long), + typeof(sbyte), + typeof(uint), + typeof(ushort), + typeof(ulong), + typeof(byte), + typeof(decimal), + typeof(double), + typeof(float) }; foreach (var fromType in types) diff --git a/test/EFCore.Tests/Storage/ValueConverterTest.cs b/test/EFCore.Tests/Storage/ValueConverterTest.cs index 4f4b52f15a8..d6d29bc86c1 100644 --- a/test/EFCore.Tests/Storage/ValueConverterTest.cs +++ b/test/EFCore.Tests/Storage/ValueConverterTest.cs @@ -144,12 +144,30 @@ public void Can_cast_between_numeric_types() { var types = new[] { - typeof(sbyte), typeof(short), typeof(int), typeof(long), - typeof(byte), typeof(ushort), typeof(uint), typeof(ulong), - typeof(char), typeof(double), typeof(float), typeof(decimal), - typeof(sbyte?), typeof(short?), typeof(int?), typeof(long?), - typeof(byte?), typeof(ushort?), typeof(uint?), typeof(ulong?), - typeof(char?), typeof(double?), typeof(float?), typeof(decimal?) + typeof(sbyte), + typeof(short), + typeof(int), + typeof(long), + typeof(byte), + typeof(ushort), + typeof(uint), + typeof(ulong), + typeof(char), + typeof(double), + typeof(float), + typeof(decimal), + typeof(sbyte?), + typeof(short?), + typeof(int?), + typeof(long?), + typeof(byte?), + typeof(ushort?), + typeof(uint?), + typeof(ulong?), + typeof(char?), + typeof(double?), + typeof(float?), + typeof(decimal?) }; foreach (var fromType in types) diff --git a/test/EFCore.Tests/TestUtilities/FakeStateManager.cs b/test/EFCore.Tests/TestUtilities/FakeStateManager.cs index 79d71acd7da..fc9d8993665 100644 --- a/test/EFCore.Tests/TestUtilities/FakeStateManager.cs +++ b/test/EFCore.Tests/TestUtilities/FakeStateManager.cs @@ -105,8 +105,10 @@ public InternalEntityEntry TryGetEntry(IKey key, in ValueBuffer valueBuffer, boo throw new NotImplementedException(); public InternalEntityEntry TryGetEntry(object entity, bool throwOnNonUniqueness = true) => throw new NotImplementedException(); + public InternalEntityEntry TryGetEntry(object entity, IEntityType type, bool throwOnTypeMismatch = true) => throw new NotImplementedException(); + public IInternalEntityEntryNotifier InternalEntityEntryNotifier => throw new NotImplementedException(); public void StateChanging(InternalEntityEntry entry, EntityState newState) => throw new NotImplementedException(); public IValueGenerationManager ValueGenerationManager => throw new NotImplementedException(); @@ -130,10 +132,11 @@ public InternalEntityEntry FindPrincipalUsingPreStoreGeneratedValues(InternalEnt public InternalEntityEntry FindPrincipalUsingRelationshipSnapshot(InternalEntityEntry entityEntry, IForeignKey foreignKey) => throw new NotImplementedException(); - public DbContext Context => new DbContext(new DbContextOptionsBuilder() - .UseInternalServiceProvider(InMemoryFixture.DefaultServiceProvider) - .UseInMemoryDatabase("D") - .Options); + public DbContext Context => new DbContext( + new DbContextOptionsBuilder() + .UseInternalServiceProvider(InMemoryFixture.DefaultServiceProvider) + .UseInMemoryDatabase("D") + .Options); public IModel Model => throw new NotImplementedException(); public event EventHandler Tracked; @@ -142,7 +145,9 @@ public InternalEntityEntry FindPrincipalUsingRelationshipSnapshot(InternalEntity public void OnStateChanged(InternalEntityEntry internalEntityEntry, EntityState oldState) => StateChanged?.Invoke(null, null); public bool SensitiveLoggingEnabled { get; } public void CascadeChanges(bool force) => throw new NotImplementedException(); - public void CascadeDelete(InternalEntityEntry entry, bool force, IEnumerable foreignKeys = null) => throw new NotImplementedException(); + + public void CascadeDelete(InternalEntityEntry entry, bool force, IEnumerable foreignKeys = null) => + throw new NotImplementedException(); public InternalEntityEntry TryGetEntry([NotNull] IKey key, object[] keyValues, bool throwOnNullKey, out bool hasNullKey) { diff --git a/test/EFCore.Tests/Utilities/ExpressionExtensionsTest.cs b/test/EFCore.Tests/Utilities/ExpressionExtensionsTest.cs index b552fff38ec..8d6de36ffc5 100644 --- a/test/EFCore.Tests/Utilities/ExpressionExtensionsTest.cs +++ b/test/EFCore.Tests/Utilities/ExpressionExtensionsTest.cs @@ -6,7 +6,6 @@ using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Xunit; // ReSharper disable InconsistentNaming @@ -60,11 +59,7 @@ public void Get_property_access_should_remove_convert() [ConditionalFact] public void Get_property_access_list_should_return_property_info_collection() { - Expression> expression = d => new - { - d.Date, - d.Day - }; + Expression> expression = d => new { d.Date, d.Day }; var propertyInfos = expression.GetPropertyAccessList(); @@ -87,11 +82,7 @@ public void Get_property_access_should_handle_convert() [ConditionalFact] public void Get_property_access_list_should_handle_convert() { - Expression> expression = d => new - { - d.Date, - d.Day - }; + Expression> expression = d => new { d.Date, d.Day }; var propertyInfos = expression.GetPropertyAccessList(); @@ -104,10 +95,7 @@ public void Get_property_access_list_should_handle_convert() [ConditionalFact] public void Get_property_access_list_should_throw_when_invalid_expression() { - Expression> expression = d => new - { - P = d.AddTicks(23) - }; + Expression> expression = d => new { P = d.AddTicks(23) }; Assert.Contains( CoreStrings.InvalidPropertiesExpression(expression), @@ -119,11 +107,7 @@ public void Get_property_access_list_should_throw_when_property_access_not_on_th { var closure = DateTime.Now; - Expression> expression = d => new - { - d.Date, - closure.Day - }; + Expression> expression = d => new { d.Date, closure.Day }; Assert.Contains( CoreStrings.InvalidPropertiesExpression(expression), diff --git a/test/EFCore.Tests/Utilities/MultigraphTest.cs b/test/EFCore.Tests/Utilities/MultigraphTest.cs index 8a32f8ee109..2fa0dd4abd5 100644 --- a/test/EFCore.Tests/Utilities/MultigraphTest.cs +++ b/test/EFCore.Tests/Utilities/MultigraphTest.cs @@ -95,14 +95,8 @@ public void Populate(params IEntityType[] entityTypes) [ConditionalFact] public void AddVertex_adds_a_vertex() { - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; var graph = new Multigraph(); @@ -116,18 +110,9 @@ public void AddVertex_adds_a_vertex() [ConditionalFact] public void AddVertices_add_vertices() { - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; - var vertexThree = new Vertex - { - Id = 3 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; + var vertexThree = new Vertex { Id = 3 }; var graph = new Multigraph(); @@ -141,23 +126,11 @@ public void AddVertices_add_vertices() [ConditionalFact] public void AddEdge_adds_an_edge() { - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; - var edgeOne = new Edge - { - Id = 1 - }; - var edgeTwo = new Edge - { - Id = 2 - }; + var edgeOne = new Edge { Id = 1 }; + var edgeTwo = new Edge { Id = 2 }; var graph = new Multigraph(); graph.AddVertices(new[] { vertexOne, vertexTwo }); @@ -175,19 +148,10 @@ public void AddEdge_adds_an_edge() [ConditionalFact] public void AddEdge_throws_on_vertices_not_in_the_graph() { - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; - var edgeOne = new Edge - { - Id = 1 - }; + var edgeOne = new Edge { Id = 1 }; var graph = new Multigraph(); graph.AddVertex(vertexOne); @@ -204,27 +168,12 @@ public void AddEdge_throws_on_vertices_not_in_the_graph() [ConditionalFact] public void AddEdges_adds_multiple_edges() { - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; - var edgeOne = new Edge - { - Id = 1 - }; - var edgeTwo = new Edge - { - Id = 2 - }; - var edgeThree = new Edge - { - Id = 3 - }; + var edgeOne = new Edge { Id = 1 }; + var edgeTwo = new Edge { Id = 2 }; + var edgeThree = new Edge { Id = 3 }; var graph = new Multigraph(); graph.AddVertices(new[] { vertexOne, vertexTwo }); @@ -239,19 +188,10 @@ public void AddEdges_adds_multiple_edges() [ConditionalFact] public void AddEdges_throws_on_vertices_not_in_the_graph() { - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; - var edgeOne = new Edge - { - Id = 1 - }; + var edgeOne = new Edge { Id = 1 }; var graph = new Multigraph(); graph.AddVertex(vertexOne); @@ -268,31 +208,13 @@ public void AddEdges_throws_on_vertices_not_in_the_graph() [ConditionalFact] public void AddEdge_updates_incoming_and_outgoing_neighbors() { - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; - var vertexThree = new Vertex - { - Id = 3 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; + var vertexThree = new Vertex { Id = 3 }; - var edgeOne = new Edge - { - Id = 1 - }; - var edgeTwo = new Edge - { - Id = 2 - }; - var edgeThree = new Edge - { - Id = 3 - }; + var edgeOne = new Edge { Id = 1 }; + var edgeTwo = new Edge { Id = 2 }; + var edgeThree = new Edge { Id = 3 }; var graph = new Multigraph(); graph.AddVertices(new[] { vertexOne, vertexTwo, vertexThree }); @@ -310,18 +232,9 @@ public void AddEdge_updates_incoming_and_outgoing_neighbors() [ConditionalFact] public void TopologicalSort_on_graph_with_no_edges_returns_all_vertices() { - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; - var vertexThree = new Vertex - { - Id = 3 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; + var vertexThree = new Vertex { Id = 3 }; var graph = new Multigraph(); graph.AddVertices(new[] { vertexOne, vertexTwo, vertexThree }); @@ -334,27 +247,12 @@ public void TopologicalSort_on_graph_with_no_edges_returns_all_vertices() [ConditionalFact] public void TopologicalSort_on_simple_graph_returns_all_vertices_in_order() { - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; - var vertexThree = new Vertex - { - Id = 3 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; + var vertexThree = new Vertex { Id = 3 }; - var edgeOne = new Edge - { - Id = 1 - }; - var edgeTwo = new Edge - { - Id = 2 - }; + var edgeOne = new Edge { Id = 1 }; + var edgeTwo = new Edge { Id = 2 }; var graph = new Multigraph(); graph.AddVertices(new[] { vertexOne, vertexTwo, vertexThree }); @@ -372,31 +270,13 @@ public void TopologicalSort_on_simple_graph_returns_all_vertices_in_order() [ConditionalFact] public void TopologicalSort_on_tree_graph_returns_all_vertices_in_order() { - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; - var vertexThree = new Vertex - { - Id = 3 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; + var vertexThree = new Vertex { Id = 3 }; - var edgeOne = new Edge - { - Id = 1 - }; - var edgeTwo = new Edge - { - Id = 2 - }; - var edgeThree = new Edge - { - Id = 3 - }; + var edgeOne = new Edge { Id = 1 }; + var edgeTwo = new Edge { Id = 2 }; + var edgeThree = new Edge { Id = 3 }; var graph = new Multigraph(); graph.AddVertices(new[] { vertexOne, vertexTwo, vertexThree }); @@ -415,15 +295,9 @@ public void TopologicalSort_on_tree_graph_returns_all_vertices_in_order() [ConditionalFact] public void TopologicalSort_on_self_ref_can_break_cycle() { - var vertexOne = new Vertex - { - Id = 1 - }; + var vertexOne = new Vertex { Id = 1 }; - var edgeOne = new Edge - { - Id = 1 - }; + var edgeOne = new Edge { Id = 1 }; var graph = new Multigraph(); graph.AddVertex(vertexOne); @@ -443,31 +317,13 @@ public void TopologicalSort_on_self_ref_can_break_cycle() [ConditionalFact] public void TopologicalSort_can_break_simple_cycle() { - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; - var vertexThree = new Vertex - { - Id = 3 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; + var vertexThree = new Vertex { Id = 3 }; - var edgeOne = new Edge - { - Id = 1 - }; - var edgeTwo = new Edge - { - Id = 2 - }; - var edgeThree = new Edge - { - Id = 3 - }; + var edgeOne = new Edge { Id = 1 }; + var edgeTwo = new Edge { Id = 2 }; + var edgeThree = new Edge { Id = 3 }; var graph = new Multigraph(); graph.AddVertices(new[] { vertexOne, vertexTwo, vertexThree }); @@ -491,51 +347,18 @@ public void TopologicalSort_can_break_simple_cycle() [ConditionalFact] public void TopologicalSort_can_break_two_cycles() { - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; - var vertexThree = new Vertex - { - Id = 3 - }; - var vertexFour = new Vertex - { - Id = 4 - }; - var vertexFive = new Vertex - { - Id = 5 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; + var vertexThree = new Vertex { Id = 3 }; + var vertexFour = new Vertex { Id = 4 }; + var vertexFive = new Vertex { Id = 5 }; - var edgeOne = new Edge - { - Id = 1 - }; - var edgeTwo = new Edge - { - Id = 2 - }; - var edgeThree = new Edge - { - Id = 3 - }; - var edgeFour = new Edge - { - Id = 4 - }; - var edgeFive = new Edge - { - Id = 5 - }; - var edgeSix = new Edge - { - Id = 6 - }; + var edgeOne = new Edge { Id = 1 }; + var edgeTwo = new Edge { Id = 2 }; + var edgeThree = new Edge { Id = 3 }; + var edgeFour = new Edge { Id = 4 }; + var edgeFive = new Edge { Id = 5 }; + var edgeSix = new Edge { Id = 6 }; var graph = new Multigraph(); graph.AddVertices(new[] { vertexOne, vertexTwo, vertexThree, vertexFour, vertexFive }); @@ -565,31 +388,13 @@ public void TopologicalSort_can_break_two_cycles() [ConditionalFact] public void TopologicalSort_throws_with_default_message_when_cycle_cannot_be_broken() { - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; - var vertexThree = new Vertex - { - Id = 3 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; + var vertexThree = new Vertex { Id = 3 }; - var edgeOne = new Edge - { - Id = 1 - }; - var edgeTwo = new Edge - { - Id = 2 - }; - var edgeThree = new Edge - { - Id = 3 - }; + var edgeOne = new Edge { Id = 1 }; + var edgeTwo = new Edge { Id = 2 }; + var edgeThree = new Edge { Id = 3 }; var graph = new Multigraph(); graph.AddVertices(new[] { vertexOne, vertexTwo, vertexThree }); @@ -612,31 +417,13 @@ public void TopologicalSort_throws_with_formatted_message_when_cycle_cannot_be_b { const string message = "Formatted cycle"; - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; - var vertexThree = new Vertex - { - Id = 3 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; + var vertexThree = new Vertex { Id = 3 }; - var edgeOne = new Edge - { - Id = 1 - }; - var edgeTwo = new Edge - { - Id = 2 - }; - var edgeThree = new Edge - { - Id = 3 - }; + var edgeOne = new Edge { Id = 1 }; + var edgeTwo = new Edge { Id = 2 }; + var edgeThree = new Edge { Id = 3 }; var graph = new Multigraph(); graph.AddVertices(new[] { vertexOne, vertexTwo, vertexThree }); @@ -677,31 +464,13 @@ public void BatchingTopologicalSort_throws_with_formatted_message_when_cycle_can { const string message = "Formatted cycle"; - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; - var vertexThree = new Vertex - { - Id = 3 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; + var vertexThree = new Vertex { Id = 3 }; - var edgeOne = new Edge - { - Id = 1 - }; - var edgeTwo = new Edge - { - Id = 2 - }; - var edgeThree = new Edge - { - Id = 3 - }; + var edgeOne = new Edge { Id = 1 }; + var edgeTwo = new Edge { Id = 2 }; + var edgeThree = new Edge { Id = 3 }; var graph = new Multigraph(); graph.AddVertices(new[] { vertexOne, vertexTwo, vertexThree }); @@ -742,39 +511,15 @@ public void BatchingTopologicalSort_throws_with_formatted_message_with_no_tail_w { const string message = "Formatted cycle"; - var vertexOne = new Vertex - { - Id = 1 - }; - var vertexTwo = new Vertex - { - Id = 2 - }; - var vertexThree = new Vertex - { - Id = 3 - }; - var vertexFour = new Vertex - { - Id = 4 - }; + var vertexOne = new Vertex { Id = 1 }; + var vertexTwo = new Vertex { Id = 2 }; + var vertexThree = new Vertex { Id = 3 }; + var vertexFour = new Vertex { Id = 4 }; - var edgeOne = new Edge - { - Id = 1 - }; - var edgeTwo = new Edge - { - Id = 2 - }; - var edgeThree = new Edge - { - Id = 3 - }; - var edgeFour = new Edge - { - Id = 4 - }; + var edgeOne = new Edge { Id = 1 }; + var edgeTwo = new Edge { Id = 2 }; + var edgeThree = new Edge { Id = 3 }; + var edgeFour = new Edge { Id = 4 }; var graph = new Multigraph(); graph.AddVertices(new[] { vertexOne, vertexTwo, vertexThree, vertexFour }); diff --git a/test/EFCore.Tests/Utilities/StringBuilderExtensionsTest.cs b/test/EFCore.Tests/Utilities/StringBuilderExtensionsTest.cs index ccc38480777..1eac63484ae 100644 --- a/test/EFCore.Tests/Utilities/StringBuilderExtensionsTest.cs +++ b/test/EFCore.Tests/Utilities/StringBuilderExtensionsTest.cs @@ -19,7 +19,7 @@ public void AppendJoin_joins_values() Assert.Equal( "11, 22, 33", - new StringBuilder().AppendJoin(new[] { 1, 2, 3 }, (sb, v) => sb.Append(v).Append(v), ", ").ToString()); + new StringBuilder().AppendJoin(new[] { 1, 2, 3 }, (sb, v) => sb.Append(v).Append(v)).ToString()); } } } diff --git a/test/EFCore.Tests/Utilities/TypeNameHelperTest.cs b/test/EFCore.Tests/Utilities/TypeNameHelperTest.cs index b846676503c..4c7f74e2834 100644 --- a/test/EFCore.Tests/Utilities/TypeNameHelperTest.cs +++ b/test/EFCore.Tests/Utilities/TypeNameHelperTest.cs @@ -142,24 +142,17 @@ public static TheoryData CreateOpenGenericsTestData() var closedInnerType = openInnerType.MakeGenericType(genArgsInnerType); return new TheoryData { - { - typeof(List<>), false, "List<>" - }, - { - typeof(Dictionary<,>), false, "Dictionary<,>" - }, - { - typeof(List<>), true, "System.Collections.Generic.List<>" - }, - { - typeof(Dictionary<,>), true, "System.Collections.Generic.Dictionary<,>" - }, + { typeof(List<>), false, "List<>" }, + { 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.Utilities.TypeNameHelperTest+Level1<>+Level2<>+Level3<>" }, { - typeof(PartiallyClosedGeneric<>).BaseType, true, "Microsoft.EntityFrameworkCore.Utilities.TypeNameHelperTest+C<, int>" + typeof(PartiallyClosedGeneric<>).BaseType, true, + "Microsoft.EntityFrameworkCore.Utilities.TypeNameHelperTest+C<, int>" }, { typeof(OuterGeneric<>.InnerNonGeneric.InnerGeneric<,>.InnerGenericLeafNode<>), true, diff --git a/test/Microsoft.Data.Sqlite.Tests/SqliteBlobTest.cs b/test/Microsoft.Data.Sqlite.Tests/SqliteBlobTest.cs index 66347f75cc3..c98e355f2ad 100644 --- a/test/Microsoft.Data.Sqlite.Tests/SqliteBlobTest.cs +++ b/test/Microsoft.Data.Sqlite.Tests/SqliteBlobTest.cs @@ -5,7 +5,6 @@ using System.IO; using Microsoft.Data.Sqlite.Properties; using Xunit; - using static SQLitePCL.raw; namespace Microsoft.Data.Sqlite @@ -293,7 +292,7 @@ public void Seek_validates_origin() [Fact] public void SetLength_throws() { - using (var stream = CreateStream(readOnly: false)) + using (var stream = CreateStream()) { var ex = Assert.Throws( () => stream.SetLength(1)); @@ -317,7 +316,7 @@ public void Write_works( int offset, int count) { - using (var stream = CreateStream(readOnly: false)) + using (var stream = CreateStream()) { stream.Position = initialPosition; stream.Write(buffer, offset, count); @@ -334,7 +333,7 @@ public void Write_works( [Fact] public void Write_throws_when_buffer_null() { - using (var stream = CreateStream(readOnly: false)) + using (var stream = CreateStream()) { var ex = Assert.Throws( () => stream.Write(null, 0, 0)); @@ -345,7 +344,7 @@ public void Write_throws_when_buffer_null() [Fact] public void Write_throws_when_count_out_of_range() { - using (var stream = CreateStream(readOnly: false)) + using (var stream = CreateStream()) { var ex = Assert.Throws( () => stream.Write(new byte[] { 3 }, 0, 2)); @@ -357,7 +356,7 @@ public void Write_throws_when_count_out_of_range() [Fact] public void Write_throws_when_count_negative() { - using (var stream = CreateStream(readOnly: false)) + using (var stream = CreateStream()) { var ex = Assert.Throws( () => stream.Write(Array.Empty(), 0, -1)); @@ -369,7 +368,7 @@ public void Write_throws_when_count_negative() [Fact] public void Write_throws_when_offset_out_of_range() { - using (var stream = CreateStream(readOnly: false)) + using (var stream = CreateStream()) { var ex = Assert.Throws( () => stream.Write(new byte[] { 3 }, 1, 1)); @@ -381,7 +380,7 @@ public void Write_throws_when_offset_out_of_range() [Fact] public void Write_throws_when_offset_negative() { - using (var stream = CreateStream(readOnly: false)) + using (var stream = CreateStream()) { var ex = Assert.Throws( () => stream.Write(new byte[] { 3, 4 }, -1, 2)); @@ -392,7 +391,7 @@ public void Write_throws_when_offset_negative() [Fact] public void Write_throws_when_position_at_end_of_stream() { - using (var stream = CreateStream(readOnly: false)) + using (var stream = CreateStream()) { stream.Position = 2; var ex = Assert.Throws( @@ -416,7 +415,7 @@ public void Write_throws_when_readOnly() [Fact] public void Write_throws_when_disposed() { - var stream = CreateStream(readOnly: false); + var stream = CreateStream(); stream.Dispose(); var ex = Assert.Throws( diff --git a/test/Microsoft.Data.Sqlite.Tests/SqliteCommandTest.cs b/test/Microsoft.Data.Sqlite.Tests/SqliteCommandTest.cs index ededc3b9b5e..b9d292c3a2e 100644 --- a/test/Microsoft.Data.Sqlite.Tests/SqliteCommandTest.cs +++ b/test/Microsoft.Data.Sqlite.Tests/SqliteCommandTest.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Microsoft.Data.Sqlite.Properties; using Xunit; - using static SQLitePCL.raw; namespace Microsoft.Data.Sqlite @@ -886,7 +885,8 @@ public void ExecuteReader_works_when_subsequent_DML() using (var connection = new SqliteConnection("Data Source=:memory:")) { connection.Open(); - connection.ExecuteNonQuery(@" + connection.ExecuteNonQuery( + @" CREATE TABLE Test(Value); INSERT INTO Test VALUES(1), (2);"); diff --git a/test/Microsoft.Data.Sqlite.Tests/SqliteConnectionStringBuilderTest.cs b/test/Microsoft.Data.Sqlite.Tests/SqliteConnectionStringBuilderTest.cs index 1574413c720..cad9b0b6e84 100644 --- a/test/Microsoft.Data.Sqlite.Tests/SqliteConnectionStringBuilderTest.cs +++ b/test/Microsoft.Data.Sqlite.Tests/SqliteConnectionStringBuilderTest.cs @@ -318,10 +318,7 @@ public void ToString_builds_string() [Fact] public void ToString_builds_minimal_string() { - var builder = new SqliteConnectionStringBuilder - { - DataSource = "test.db" - }; + var builder = new SqliteConnectionStringBuilder { DataSource = "test.db" }; Assert.Equal("Data Source=test.db", builder.ToString()); } diff --git a/test/Microsoft.Data.Sqlite.Tests/SqliteConnectionTest.cs b/test/Microsoft.Data.Sqlite.Tests/SqliteConnectionTest.cs index 245833e6b94..11f2b6377e9 100644 --- a/test/Microsoft.Data.Sqlite.Tests/SqliteConnectionTest.cs +++ b/test/Microsoft.Data.Sqlite.Tests/SqliteConnectionTest.cs @@ -10,9 +10,7 @@ using System.Linq; using System.Threading; using Microsoft.Data.Sqlite.Properties; -using SQLitePCL; using Xunit; - using static SQLitePCL.raw; namespace Microsoft.Data.Sqlite @@ -263,7 +261,7 @@ public void Open_works_when_memory_shared() [Fact] public void Open_works_when_password() { - switch (SQLitePCL.raw.GetNativeLibraryName()) + switch (GetNativeLibraryName()) { case "e_sqlite3": Open_works_when_password_e_sqlite3(); diff --git a/test/Microsoft.Data.Sqlite.Tests/SqliteDataReaderTest.cs b/test/Microsoft.Data.Sqlite.Tests/SqliteDataReaderTest.cs index c4a4151979b..aca57006ddb 100644 --- a/test/Microsoft.Data.Sqlite.Tests/SqliteDataReaderTest.cs +++ b/test/Microsoft.Data.Sqlite.Tests/SqliteDataReaderTest.cs @@ -1551,7 +1551,8 @@ public void RecordsAffected_works_during_enumeration() connection.Open(); connection.ExecuteNonQuery("CREATE TABLE Test(Value);"); - var reader = connection.ExecuteReader(@" + var reader = connection.ExecuteReader( + @" SELECT 1; INSERT INTO Test VALUES(1); SELECT 1; @@ -1761,7 +1762,8 @@ public void Dispose_executes_remaining_statements() connection.ExecuteNonQuery("CREATE TABLE Test(Value);"); connection.CreateFunction("throw", message => throw new Exception(message)); - var reader = connection.ExecuteReader(@" + var reader = connection.ExecuteReader( + @" SELECT 1; INSERT INTO Test VALUES (1);"); ((IDisposable)reader).Dispose(); @@ -1780,7 +1782,8 @@ public void Dispose_doesnt_throw_but_stops_on_error() connection.ExecuteNonQuery("CREATE TABLE Test(Value);"); connection.CreateFunction("throw", message => throw new Exception(message)); - var reader = connection.ExecuteReader(@" + var reader = connection.ExecuteReader( + @" SELECT 1; SELECT throw('An error'); INSERT INTO Test VALUES (1);"); diff --git a/test/Microsoft.Data.Sqlite.Tests/SqliteExceptionTest.cs b/test/Microsoft.Data.Sqlite.Tests/SqliteExceptionTest.cs index 8558c09bd0b..bc0d5506c6d 100644 --- a/test/Microsoft.Data.Sqlite.Tests/SqliteExceptionTest.cs +++ b/test/Microsoft.Data.Sqlite.Tests/SqliteExceptionTest.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Xunit; - using static SQLitePCL.raw; namespace Microsoft.Data.Sqlite diff --git a/test/Microsoft.Data.Sqlite.Tests/SqliteParameterTest.cs b/test/Microsoft.Data.Sqlite.Tests/SqliteParameterTest.cs index 205b5d97768..9ddca04ec3f 100644 --- a/test/Microsoft.Data.Sqlite.Tests/SqliteParameterTest.cs +++ b/test/Microsoft.Data.Sqlite.Tests/SqliteParameterTest.cs @@ -71,11 +71,7 @@ public void Direction_validates_value() [Fact] public void ResetDbType_works() { - var parameter = new SqliteParameter - { - DbType = DbType.Int64, - SqliteType = SqliteType.Integer - }; + var parameter = new SqliteParameter { DbType = DbType.Int64, SqliteType = SqliteType.Integer }; parameter.ResetDbType(); @@ -86,11 +82,7 @@ public void ResetDbType_works() [Fact] public void ResetSqliteType_works() { - var parameter = new SqliteParameter - { - DbType = DbType.Int64, - SqliteType = SqliteType.Integer - }; + var parameter = new SqliteParameter { DbType = DbType.Int64, SqliteType = SqliteType.Integer }; parameter.ResetSqliteType(); diff --git a/test/Microsoft.Data.Sqlite.Tests/SqliteTransactionTest.cs b/test/Microsoft.Data.Sqlite.Tests/SqliteTransactionTest.cs index 6da836d8a03..9cb0ede916c 100644 --- a/test/Microsoft.Data.Sqlite.Tests/SqliteTransactionTest.cs +++ b/test/Microsoft.Data.Sqlite.Tests/SqliteTransactionTest.cs @@ -5,7 +5,6 @@ using System.Data; using Microsoft.Data.Sqlite.Properties; using Xunit; - using static SQLitePCL.raw; namespace Microsoft.Data.Sqlite diff --git a/test/dotnet-ef.Tests/CommandsTest.cs b/test/dotnet-ef.Tests/CommandsTest.cs index 5799ac8c074..42734b0875c 100644 --- a/test/dotnet-ef.Tests/CommandsTest.cs +++ b/test/dotnet-ef.Tests/CommandsTest.cs @@ -28,10 +28,7 @@ public void Short_names_are_unique() private static IEnumerable GetCommands() { - var app = new CommandLineApplication - { - Name = "dotnet ef" - }; + var app = new CommandLineApplication { Name = "dotnet ef" }; new EFCommand().Configure(app); diff --git a/test/ef.Tests/CommandsTest.cs b/test/ef.Tests/CommandsTest.cs index 67a225b8ccd..5c128fe4ddf 100644 --- a/test/ef.Tests/CommandsTest.cs +++ b/test/ef.Tests/CommandsTest.cs @@ -28,10 +28,7 @@ public void Short_names_are_unique() private static IEnumerable GetCommands() { - var app = new CommandLineApplication - { - Name = "ef" - }; + var app = new CommandLineApplication { Name = "ef" }; new RootCommand().Configure(app);