From dff794aeb6a993ffd54cc331594c166a8af2e2df Mon Sep 17 00:00:00 2001 From: Arthur Vickers Date: Sun, 23 Aug 2020 12:50:21 -0700 Subject: [PATCH] Code cleanup for tests --- src/Shared/Check.cs | 2 +- .../InternalUsageDiagnosticAnalyzerTest.cs | 12 +- .../BuiltInDataTypesCosmosTest.cs | 30 +- .../ConfigPatternsCosmosTest.cs | 3 +- .../ConnectionSpecificationTest.cs | 3 +- .../CosmosConcurrencyTest.cs | 32 +- .../CustomConvertersCosmosTest.cs | 32 +- .../EmbeddedDocumentsTest.cs | 20 +- .../EndToEndCosmosTest.cs | 76 +- .../OverzealousInitializationCosmosTest.cs | 3 +- .../PartitionKeyTest.cs | 37 +- .../Query/InheritanceQueryCosmosFixture.cs | 3 +- .../Query/InheritanceQueryCosmosTest.cs | 3 +- ...thwindAggregateOperatorsQueryCosmosTest.cs | 3 +- .../NorthwindFunctionsQueryCosmosTest.cs | 1 - ...NorthwindKeylessEntitiesQueryCosmosTest.cs | 3 +- .../NorthwindMiscellaneousQueryCosmosTest.cs | 17 +- .../Query/NorthwindQueryCosmosFixture.cs | 6 +- .../Query/NorthwindSelectQueryCosmosTest.cs | 8 +- .../Query/NorthwindWhereQueryCosmosTest.cs | 3 +- .../Query/OwnedQueryCosmosTest.cs | 133 +- .../Query/QueryLoggingCosmosTest.cs | 4 +- .../ReloadTest.cs | 13 +- .../TestUtilities/CosmosTestStore.cs | 181 +- .../TestUtilities/CosmosTestStoreFactory.cs | 6 +- .../CustomPartitionKeyIdGenerator.cs | 9 +- ...stomPartitionKeyIdValueGeneratorFactory.cs | 2 +- .../TestUtilities/TestSqlLoggerFactory.cs | 21 +- .../CosmosApiConsistencyTest.cs | 15 +- .../CosmosModelValidatorTest.cs | 126 +- .../CosmosConventionSetBuilderTests.cs | 3 +- .../Metadata/CosmosBuilderExtensionsTest.cs | 3 +- .../Metadata/CosmosMetadataExtensionsTest.cs | 4 +- .../CosmosModelBuilderGenericTest.cs | 19 +- .../CosmosTestModelBuilderExtensions.cs | 6 +- .../Internal/IdValueGeneratorTest.cs | 3 +- .../ConfigurationPatternsTest.cs | 6 +- .../EndToEndTest.cs | 16 +- .../Design/Internal/CSharpHelperTest.cs | 52 +- .../Design/Internal/DatabaseOperationsTest.cs | 1 - .../Internal/MigrationsOperationsTest.cs | 1 - .../DesignApiConsistencyTest.cs | 8 +- .../CSharpMigrationOperationGeneratorTest.cs | 21 +- .../Design/CSharpMigrationsGeneratorTest.cs | 28 +- .../Design/MigrationScaffolderTest.cs | 49 +- .../Design/SnapshotModelProcessorTest.cs | 1537 +++++++++-------- .../Migrations/ModelSnapshotSqlServerTest.cs | 205 ++- .../Internal/CSharpDbContextGeneratorTest.cs | 46 +- .../Internal/CSharpEntityTypeGeneratorTest.cs | 50 +- .../Scaffolding/Internal/CSharpNamerTest.cs | 1 - .../Internal/CSharpUniqueNamerTest.cs | 15 +- .../RelationalScaffoldingModelFactoryTest.cs | 372 +++- .../Internal/ReverseEngineerScaffolderTest.cs | 31 +- .../ScaffoldingTypeMapperSqlServerTest.cs | 66 +- .../TestUtilities/DatabaseColumnRef.cs | 2 +- .../TestUtilities/DatabaseTableRef.cs | 10 +- .../TestUtilities/TestDatabaseOperations.cs | 2 +- .../TestUtilities/TestMigrationsOperations.cs | 2 +- .../TestUtilities/TestOperationReporter.cs | 6 +- .../BuiltInDataTypesInMemoryTest.cs | 25 +- .../CompositeKeyEndToEndInMemoryTest.cs | 3 +- .../ConvertToProviderTypesInMemoryTest.cs | 25 +- .../CustomConvertersInMemoryTest.cs | 24 +- .../CustomValueGeneratorTest.cs | 6 +- .../DataAnnotationInMemoryTest.cs | 4 +- .../DatabaseErrorLogStateTest.cs | 9 +- .../EndToEndTest.cs | 4 +- .../F1InMemoryFixture.cs | 6 +- .../FieldMappingInMemoryTest.cs | 3 +- .../FindInMemoryTest.cs | 3 +- .../GraphUpdates/GraphUpdatesInMemoryTest.cs | 3 +- .../ProxyGraphUpdatesInMemoryTest.cs | 27 +- .../IntegerValueGeneratorTest.cs | 6 +- .../InterceptionInMemoryTest.cs | 16 +- .../KeysWithConvertersInMemoryTest.cs | 3 +- .../LazyLoadProxyInMemoryTest.cs | 3 +- .../LoadInMemoryTest.cs | 3 +- .../LoggingInMemoryTest.cs | 6 +- .../ManyToManyLoadInMemoryTest.cs | 3 +- .../ManyToManyTrackingInMemoryTest.cs | 6 +- .../MonsterFixupSnapshotInMemoryTest.cs | 3 +- .../MusicStoreInMemoryTest.cs | 14 +- .../NotificationEntitiesInMemoryTest.cs | 3 +- .../OverzealousInitializationInMemoryTest.cs | 3 +- .../PropertyValuesInMemoryTest.cs | 3 +- .../ComplexNavigationsQueryInMemoryFixture.cs | 3 +- ...plexNavigationsWeakQueryInMemoryFixture.cs | 3 +- ...ComplexNavigationsWeakQueryInMemoryTest.cs | 3 +- .../FiltersInheritanceQueryInMemoryFixture.cs | 3 +- .../Query/GearsOfWarQueryInMemoryFixture.cs | 3 +- .../Query/GearsOfWarQueryInMemoryTest.cs | 6 +- .../Query/IncludeOneToOneInMemoryTest.cs | 3 +- ...eMappingInheritanceQueryInMemoryFixture.cs | 3 +- ...leteMappingInheritanceQueryInMemoryTest.cs | 3 +- .../Query/InheritanceQueryInMemoryFixture.cs | 3 +- .../Query/InheritanceQueryInMemoryTest.cs | 3 +- ...itanceRelationshipsQueryInMemoryFixture.cs | 3 +- .../Query/ManyToManyQueryInMemoryFixture.cs | 3 +- .../Query/ManyToManyQueryInMemoryTest.cs | 1 - ...windAggregateOperatorsQueryInMemoryTest.cs | 3 +- .../NorthwindAsNoTrackingQueryInMemoryTest.cs | 3 +- .../NorthwindAsyncSimpleQueryInMemoryTest.cs | 3 +- ...orthwindChangeTrackingQueryInMemoryTest.cs | 7 +- .../NorthwindCompiledQueryInMemoryTest.cs | 3 +- .../NorthwindDbFunctionsQueryInMemoryTest.cs | 7 +- .../Query/NorthwindInMemoryContext.cs | 14 +- ...hwindIncludeNoTrackingQueryInMemoryTest.cs | 7 +- .../NorthwindIncludeQueryInMemoryTest.cs | 4 +- ...rthwindKeylessEntitiesQueryInMemoryTest.cs | 4 +- ...NorthwindMiscellaneousQueryInMemoryTest.cs | 3 +- .../NorthwindNavigationsQueryInMemoryTest.cs | 6 +- .../NorthwindQueryFiltersQueryInMemoryTest.cs | 7 +- .../Query/NorthwindQueryInMemoryFixture.cs | 6 +- .../NorthwindQueryTaggingQueryInMemoryTest.cs | 6 +- ...NorthwindSetOperationsQueryInMemoryTest.cs | 3 +- ...NorthwindStringIncludeQueryInMemoryTest.cs | 7 +- .../Query/NorthwindWhereQueryInMemoryTest.cs | 6 +- .../Query/NullKeysInMemoryTest.cs | 3 +- .../Query/OwnedQueryInMemoryTest.cs | 3 +- .../Query/QueryBugsInMemoryTest.cs | 40 +- .../QueryFilterFuncletizationInMemoryTest.cs | 6 +- .../StoreGeneratedFixupInMemoryTest.cs | 6 +- .../TestUtilities/InMemoryTestStore.cs | 8 +- .../UpdatesInMemoryFixtureBase.cs | 3 +- ...InMemoryWithSensitiveDataLoggingFixture.cs | 3 +- ...emoryWithoutSensitiveDataLoggingFixture.cs | 3 +- .../WithConstructorsInMemoryTest.cs | 3 +- .../InMemoryApiConsistencyTest.cs | 5 +- .../InMemoryDatabaseCreatorTest.cs | 1 - .../InMemoryDatabaseTest.cs | 1 - .../InMemoryValueGeneratorSelectorTest.cs | 3 +- .../InMemoryModelValidatorTest.cs | 3 +- .../ChangeDetectionProxyTests.cs | 9 +- .../ProxiesApiConsistencyTest.cs | 8 +- test/EFCore.Proxies.Tests/ProxyTests.cs | 14 +- .../TestUtilities/TestContext.cs | 2 +- .../CommandInterceptionTestBase.cs | 142 +- .../F1RelationalFixture.cs | 3 +- .../MigrationsInfrastructureTestBase.cs | 16 +- .../MigrationsTestBase.cs | 84 +- .../PropertyEntryTestBase.cs | 6 +- .../Query/AsyncFromSqlQueryTestBase.cs | 3 +- .../AsyncGearsOfWarQueryRelationalTestBase.cs | 6 +- ...exNavigationsQueryRelationalFixtureBase.cs | 3 +- ...mplexNavigationsQueryRelationalTestBase.cs | 125 +- ...vigationsWeakQueryRelationalFixtureBase.cs | 3 +- ...xNavigationsWeakQueryRelationalTestBase.cs | 111 +- .../Query/FromSqlQueryTestBase.cs | 3 +- .../Query/FromSqlSprocQueryTestBase.cs | 6 +- .../Query/GearsOfWarFromSqlQueryTestBase.cs | 6 +- .../Query/GearsOfWarQueryRelationalFixture.cs | 6 +- .../GearsOfWarQueryRelationalTestBase.cs | 6 +- .../InheritanceQueryRelationalFixture.cs | 3 +- .../InheritanceRelationalQueryTestBase.cs | 6 +- ...anceRelationshipsQueryRelationalFixture.cs | 3 +- ...nceRelationshipsQueryRelationalTestBase.cs | 79 +- ...ToManyNoTrackingQueryRelationalTestBase.cs | 80 +- .../Query/ManyToManyQueryRelationalFixture.cs | 3 +- .../ManyToManyQueryRelationalTestBase.cs | 80 +- .../Query/MappingQueryTestBase.cs | 10 +- ...gregateOperatorsQueryRelationalTestBase.cs | 12 +- ...hwindAsyncSimpleQueryRelationalTestBase.cs | 6 +- ...rthwindFunctionsQueryRelationalTestBase.cs | 6 +- ...NorthwindGroupByQueryRelationalTestBase.cs | 6 +- ...NorthwindIncludeQueryRelationalTestBase.cs | 6 +- .../NorthwindJoinQueryRelationalTestBase.cs | 6 +- ...dKeylessEntitiesQueryRelationalTestBase.cs | 19 +- ...indMiscellaneousQueryRelationalTestBase.cs | 16 +- ...hwindNavigationsQueryRelationalTestBase.cs | 6 +- .../Query/NorthwindQueryRelationalFixture.cs | 10 +- .../NorthwindSelectQueryRelationalTestBase.cs | 6 +- ...indSetOperationsQueryRelationalTestBase.cs | 6 +- ...windSplitIncludeNoTrackingQueryTestBase.cs | 7 +- .../NorthwindSplitIncludeQueryTestBase.cs | 1 - .../NorthwindWhereQueryRelationalTestBase.cs | 6 +- .../Query/NullSemanticsQueryFixtureBase.cs | 137 +- .../Query/NullSemanticsQueryTestBase.cs | 482 ++++-- .../Query/OwnedQueryRelationalTestBase.cs | 14 +- ...ryFilterFuncletizationRelationalFixture.cs | 3 +- .../Query/QueryNoClientEvalTestBase.cs | 11 +- ...tionalNorthwindDbFunctionsQueryTestBase.cs | 6 +- .../Query/SpatialQueryRelationalTestBase.cs | 6 +- .../Query/SqlExecutorTestBase.cs | 8 +- .../TPTFiltersInheritanceQueryTestBase.cs | 1 - .../TPTGearsOfWarQueryRelationalFixture.cs | 7 +- .../Query/TPTInheritanceQueryFixture.cs | 9 +- .../Query/TPTInheritanceQueryTestBase.cs | 20 +- .../Query/TPTRelationshipsQueryTestBase.cs | 1 + .../Query/UdfDbFunctionTestBase.cs | 321 ++-- .../Query/WarningsTestBase.cs | 3 +- .../Northwind/NorthwindRelationalContext.cs | 6 +- .../RelationalDatabaseCleaner.cs | 21 +- .../TestUtilities/RelationalTestStore.cs | 31 +- .../TestUtilities/TestSqlLoggerFactory.cs | 20 +- .../TransactionInterceptionTestBase.cs | 21 +- .../TransactionTestBase.cs | 42 +- .../TwoDatabasesTestBase.cs | 19 +- .../UpdatesRelationalFixture.cs | 3 +- .../UpdatesRelationalTestBase.cs | 3 +- .../Design/AnnotationCodeGeneratorTest.cs | 14 +- .../RelationalModelValidatorTest.cs | 102 +- ...PropertyMappingValidationConventionTest.cs | 3 +- .../TableValuedDbFunctionConventionTest.cs | 38 +- .../SequenceUniquificationConventionTest.cs | 9 +- ...leSharingConcurrencyTokenConventionTest.cs | 3 +- .../Metadata/DbFunctionMetadataTests.cs | 104 +- .../RelationalBuilderExtensionsTest.cs | 3 +- .../Metadata/RelationalIndexTest.cs | 14 +- .../RelationalMetadataExtensionsTest.cs | 1 - .../Metadata/RelationalModelTest.cs | 315 ++-- .../Internal/MigrationsModelDifferTest.cs | 194 ++- .../Internal/MigrationsModelDifferTestBase.cs | 4 +- .../MigrationsSqlGeneratorTestBase.cs | 403 +++-- .../RelationalTestModelBuilderExtensions.cs | 41 +- .../Query/Internal/BufferedDataReaderTest.cs | 10 +- .../Query/Internal/QuerySqlGeneratorTest.cs | 2 +- .../RelationalApiConsistencyTest.cs | 49 +- .../RelationalConnectionTest.cs | 1 - .../RelationalDatabaseFacadeExtensionsTest.cs | 46 +- .../RelationalEventIdTest.cs | 427 +++-- .../NamedConnectionStringResolverTest.cs | 3 +- .../Storage/RelationalCommandTest.cs | 4 +- .../RelationalDatabaseFacadeExtensionsTest.cs | 3 +- .../RelationalGeometryTypeMappingTest.cs | 28 +- .../RelationalTransactionExtensionsTest.cs | 23 +- .../Storage/RelationalTypeMapperTest.cs | 3 +- .../Storage/RelationalTypeMappingTest.cs | 4 +- .../TestUtilities/FakeDiagnosticsLogger.cs | 15 +- .../FakeProvider/FakeCommandExecutor.cs | 6 +- .../FakeProvider/FakeDbConnection.cs | 12 +- .../FakeProvider/FakeDbDataReader.cs | 66 +- .../FakeProvider/FakeDbParameterCollection.cs | 9 +- .../FakeProvider/FakeRelationalConnection.cs | 9 +- .../FakeRelationalDatabaseCreator.cs | 73 +- .../FakeProvider/FakeSqlGenerator.cs | 17 +- .../TestUtilities/ListDiagnosticSource.cs | 3 +- .../TestRelationalMigrationSqlGenerator.cs | 5 +- .../TestRelationalTypeMappingSource.cs | 3 +- .../ReaderModificationCommandBatchTest.cs | 15 +- .../Update/UpdateSqlGeneratorTest.cs | 9 +- .../Update/UpdateSqlGeneratorTestBase.cs | 502 +++++- .../BuiltInDataTypesTestBase.cs | 87 +- .../CompositeKeyEndToEndTestBase.cs | 6 +- .../ConcurrencyDetectorTestBase.cs | 6 +- .../ConferencePlannerTestBase.cs | 10 +- .../ConvertToProviderTypesTestBase.cs | 2 +- .../CustomConvertersTestBase.cs | 67 +- .../DataAnnotationTestBase.cs | 6 +- .../DatabindingTestBase.cs | 3 +- .../F1FixtureBase.cs | 9 +- .../FieldMappingTestBase.cs | 91 +- .../FindTestBase.cs | 6 +- .../GraphUpdates/GraphUpdatesTestBase.cs | 328 ++-- .../GraphUpdatesTestBaseOneToManyAk.cs | 1 - .../ProxyGraphUpdatesFixtureBase.cs | 339 ++-- .../ProxyGraphUpdatesTestBaseOneToManyAk.cs | 84 +- .../ProxyGraphUpdatesTestBaseOneToOne.cs | 1 - .../ProxyGraphUpdatesTestBaseOneToOneAk.cs | 39 +- .../KeysWithConvertersTestBase.cs | 750 +++++--- .../LazyLoadProxyTestBase.cs | 75 +- .../LoadTestBase.cs | 38 +- .../LoggingTestBase.cs | 3 +- .../ManyToManyLoadTestBase.cs | 11 +- .../ManyToManyTrackingTestBase.cs | 213 ++- .../MonsterFixupTestBase.cs | 33 +- .../MusicStoreTestBase.cs | 24 +- .../NotificationEntitiesTestBase.cs | 6 +- .../OptimisticConcurrencyTestBase.cs | 15 +- .../OverzealousInitializationTestBase.cs | 31 +- .../PropertyValuesTestBase.cs | 12 +- .../Query/AsyncGearsOfWarQueryTestBase.cs | 3 +- .../ComplexNavigationsQueryFixtureBase.cs | 10 +- .../Query/ComplexNavigationsQueryTestBase.cs | 537 +++--- .../ComplexNavigationsWeakQueryFixtureBase.cs | 3 +- .../ComplexNavigationsWeakQueryTestBase.cs | 3 +- .../Query/FiltersInheritanceQueryTestBase.cs | 6 +- .../Query/FunkyDataQueryTestBase.cs | 37 +- .../Query/GearsOfWarQueryFixtureBase.cs | 19 +- .../Query/GearsOfWarQueryTestBase.cs | 224 +-- .../Query/IQueryFixtureBase.cs | 3 +- .../Query/IncludeOneToOneTestBase.cs | 6 +- .../Query/InheritanceQueryFixtureBase.cs | 23 +- .../Query/InheritanceQueryTestBase.cs | 15 +- ...nheritanceRelationshipsQueryFixtureBase.cs | 25 +- .../InheritanceRelationshipsQueryTestBase.cs | 144 +- .../ManyToManyNoTrackingQueryTestBase.cs | 22 +- .../Query/ManyToManyQueryFixtureBase.cs | 48 +- .../Query/ManyToManyQueryTestBase.cs | 144 +- ...orthwindAggregateOperatorsQueryTestBase.cs | 46 +- .../NorthwindAsNoTrackingQueryTestBase.cs | 6 +- .../Query/NorthwindAsTrackingQueryTestBase.cs | 3 +- .../NorthwindAsyncSimpleQueryTestBase.cs | 3 +- .../NorthwindChangeTrackingQueryTestBase.cs | 6 +- .../Query/NorthwindCompiledQueryTestBase.cs | 334 +++- .../NorthwindDbFunctionsQueryTestBase.cs | 4 +- .../Query/NorthwindFunctionsQueryTestBase.cs | 10 +- .../Query/NorthwindGroupByQueryTestBase.cs | 218 ++- ...NorthwindIncludeNoTrackingQueryTestBase.cs | 6 +- .../Query/NorthwindIncludeQueryTestBase.cs | 333 ++-- .../Query/NorthwindJoinQueryTestBase.cs | 51 +- .../NorthwindKeylessEntitiesQueryTestBase.cs | 15 +- .../NorthwindMiscellaneousQueryTestBase.cs | 339 ++-- .../NorthwindNavigationsQueryTestBase.cs | 26 +- .../NorthwindQueryFiltersQueryTestBase.cs | 6 +- .../Query/NorthwindQueryFixtureBase.cs | 18 +- .../NorthwindQueryTaggingQueryTestBase.cs | 6 +- .../Query/NorthwindSelectQueryTestBase.cs | 132 +- .../NorthwindSetOperationsQueryTestBase.cs | 9 +- .../NorthwindStringIncludeQueryTestBase.cs | 36 +- .../Query/NorthwindWhereQueryTestBase.cs | 40 +- .../Query/NullKeysTestBase.cs | 6 +- .../Query/OwnedQueryTestBase.cs | 173 +- .../QueryFilterFuncletizationFixtureBase.cs | 3 +- .../QueryFilterFuncletizationTestBase.cs | 6 +- .../Query/QueryTestBase.cs | 6 +- .../Query/SpatialQueryFixtureBase.cs | 12 +- .../Query/SpatialQueryTestBase.cs | 80 +- .../SaveChangesInterceptionTestBase.cs | 22 +- .../SerializationTestBase.cs | 28 +- .../ServiceProviderFixtureBase.cs | 3 +- .../SharedStoreFixtureBase.cs | 10 +- .../SpatialTestBase.cs | 3 +- .../StoreGeneratedFixupTestBase.cs | 6 +- .../StoreGeneratedTestBase.cs | 8 +- .../AspNetIdentity/IdentityUserContext.cs | 7 +- .../ComplexNavigationsData.cs | 20 +- .../ComplexNavigationsModel/Level1.cs | 3 +- .../ComplexNavigationsModel/Level2.cs | 3 +- .../ComplexNavigationsModel/Level3.cs | 3 +- .../ComplexNavigationsModel/Level4.cs | 3 +- .../TestModels/ConcurrencyModel/Sponsor.cs | 4 +- .../TestModels/ConcurrencyModel/Team.cs | 3 +- .../ConcurrencyModel/TeamSponsor.cs | 3 + .../ConferenceDTO/Session.cs | 3 +- .../ConferencePlanner/EntityExtensions.cs | 12 +- .../TestModels/GearsOfWarModel/Gear.cs | 3 +- .../GearsOfWarModel/GearsOfWarData.cs | 64 +- .../InheritanceModel/InheritanceData.cs | 89 +- .../InheritanceRelationshipsData.cs | 224 ++- .../NestedCollectionBase.cs | 2 - .../TestModels/ManyToManyModel/EntityOne.cs | 2 +- .../TestModels/ManyToManyModel/EntityThree.cs | 2 +- .../ManyToManyModel/ImplicitManyToManyA.cs | 1 + .../ManyToManyModel/ImplicitManyToManyB.cs | 1 + .../ManyToManyModel/ManyToManyContext.cs | 4 +- .../ManyToManyModel/ManyToManyData.cs | 294 ++-- .../TestModels/MonsterContext`.cs | 93 +- .../TestModels/Northwind/Customer.cs | 22 +- .../TestModels/Northwind/CustomerQuery.cs | 3 +- .../TestModels/Northwind/Employee.cs | 9 +- .../TestModels/Northwind/NorthwindContext.cs | 1 - .../TestModels/Northwind/NorthwindData.cs | 7 +- .../TestModels/Northwind/Order.cs | 9 +- .../TestModels/Northwind/OrderDetail.cs | 3 +- .../TestModels/Northwind/OrderQuery.cs | 6 +- .../TestModels/Northwind/Product.cs | 9 +- .../QueryFilterFuncletizationContext.cs | 25 +- .../TransportationModel/CombustionEngine.cs | 3 +- .../TestModels/TransportationModel/Engine.cs | 3 +- .../TransportationModel/LicensedOperator.cs | 3 +- .../TransportationModel/PoweredVehicle.cs | 3 +- .../TransportationModel/SolidFuelTank.cs | 3 +- .../TransportationContext.cs | 9 +- .../TestModels/TransportationModel/Vehicle.cs | 3 +- .../TestUtilities/AnnotationComparer.cs | 6 +- .../TestUtilities/DataGenerator.cs | 1 + .../ExpectedQueryRewritingVisitor.cs | 36 +- .../TestUtilities/ForeignKeyStrictComparer.cs | 6 +- .../TestUtilities/ListLoggerFactory.cs | 44 +- .../TestUtilities/MetadataExtensions.cs | 3 +- .../TestUtilities/NavigationComparer.cs | 6 +- .../TestUtilities/PropertyComparer.cs | 6 +- .../TestUtilities/QueryAsserter.cs | 29 +- .../AppendSelectConstantExpressionMutator.cs | 3 +- .../AppendSelectIdentityExpressionMutator.cs | 3 +- .../TestUtilities/TestDbContextLogger.cs | 3 +- .../TestUtilities/TestDiagnosticSource.cs | 3 +- .../TestUtilities/TestHelpers.cs | 10 +- .../TestUtilities/TestIndexComparer.cs | 6 +- .../TestUtilities/TestKeyComparer.cs | 6 +- .../TestUtilities/TestLogger.cs | 21 +- .../TestUtilities/TestModelSource.cs | 4 +- .../TestUtilities/TestStore.cs | 3 +- .../Xunit/PlatformSkipConditionAttribute.cs | 3 +- .../UpdatesTestBase.cs | 6 +- .../WithConstructorsTestBase.cs | 385 +++-- .../BatchingTest.cs | 12 +- .../BuiltInDataTypesSqlServerTest.cs | 58 +- .../CommandConfigurationTest.cs | 11 +- .../CommandInterceptionSqlServerTest.cs | 13 +- .../CompositeKeyEndToEndSqlServerTest.cs | 3 +- .../ComputedColumnTest.cs | 3 +- .../ConferencePlannerSqlServerTest.cs | 3 +- .../ConnectionInterceptionSqlServerTest.cs | 49 +- .../ConvertToProviderTypesSqlServerTest.cs | 24 +- .../CustomConvertersSqlServerTest.cs | 29 +- .../DataAnnotationSqlServerTest.cs | 10 +- .../DbContextPoolingTest.cs | 6 +- .../DefaultValuesTest.cs | 3 +- .../EverythingIsBytesSqlServerTest.cs | 24 +- .../EverythingIsStringsSqlServerTest.cs | 24 +- .../ExecutionStrategyTest.cs | 25 +- .../F1SqlServerFixture.cs | 7 +- .../FieldMappingSqlServerTest.cs | 3 +- .../FindSqlServerTest.cs | 10 +- .../GraphUpdates/GraphUpdatesSqlServerTest.cs | 18 +- .../ProxyGraphUpdatesSqlServerTest.cs | 31 +- .../LazyLoadProxySqlServerTest.cs | 19 +- .../LoadSqlServerTest.cs | 44 +- .../LoggingSqlServerTest.cs | 3 +- .../ManyToManyLoadSqlServerTest.cs | 12 +- .../ManyToManyTrackingProxySqlServerTest.cs | 3 +- .../ManyToManyTrackingSqlServerTestBase.cs | 3 +- .../MemoryOptimizedTablesTest.cs | 9 +- .../MigrationsInfrastructureSqlServerTest.cs | 3 +- .../MigrationsSqlServerTest.cs | 11 +- ...onsterFixupChangedChangingSqlServerTest.cs | 3 +- .../MusicStoreSqlServerTest.cs | 3 +- .../NavigationTest.cs | 9 +- .../NotificationEntitiesSqlServerTest.cs | 3 +- .../OverzealousInitializationSqlServerTest.cs | 3 +- .../PropertyValuesSqlServerTest.cs | 3 +- .../AsyncGearsOfWarQuerySqlServerTest.cs | 3 +- ...ComplexNavigationsQuerySqlServerFixture.cs | 3 +- .../ComplexNavigationsQuerySqlServerTest.cs | 21 +- ...lexNavigationsWeakQuerySqlServerFixture.cs | 3 +- ...omplexNavigationsWeakQuerySqlServerTest.cs | 6 +- ...FiltersInheritanceQuerySqlServerFixture.cs | 3 +- .../Query/FromSqlQuerySqlServerTest.cs | 7 +- .../Query/FromSqlSprocQuerySqlServerTest.cs | 6 +- .../Query/FunkyDataQuerySqlServerTest.cs | 12 +- .../GearsOfWarFromSqlQuerySqlServerTest.cs | 6 +- .../Query/GearsOfWarQuerySqlServerFixture.cs | 3 +- .../Query/GearsOfWarQuerySqlServerTest.cs | 29 +- .../Query/IncludeOneToOneSqlServerTest.cs | 7 +- ...MappingInheritanceQuerySqlServerFixture.cs | 3 +- ...eteMappingInheritanceQuerySqlServerTest.cs | 6 +- .../Query/InheritanceQuerySqlServerFixture.cs | 3 +- .../Query/InheritanceQuerySqlServerTest.cs | 2 - ...eritanceRelationshipsQuerySqlServerTest.cs | 15 +- .../ManyToManyNoTrackingQuerySqlServerTest.cs | 3 +- .../Query/ManyToManyQuerySqlServerFixture.cs | 3 +- .../Query/ManyToManyQuerySqlServerTest.cs | 4 +- .../Query/MappingQuerySqlServerTest.cs | 3 +- ...indAggregateOperatorsQuerySqlServerTest.cs | 9 +- ...NorthwindAsNoTrackingQuerySqlServerTest.cs | 6 +- .../NorthwindAsTrackingQuerySqlServerTest.cs | 3 +- .../NorthwindAsyncSimpleQuerySqlServerTest.cs | 9 +- ...rthwindChangeTrackingQuerySqlServerTest.cs | 3 +- .../NorthwindCompiledQuerySqlServerTest.cs | 4 +- .../NorthwindDbFunctionsQuerySqlServerTest.cs | 82 +- .../NorthwindFunctionsQuerySqlServerTest.cs | 15 +- .../NorthwindGroupByQuerySqlServerTest.cs | 14 +- ...windIncludeNoTrackingQuerySqlServerTest.cs | 3 +- .../NorthwindIncludeQuerySqlServerTest.cs | 12 +- .../Query/NorthwindJoinQuerySqlServerTest.cs | 7 +- ...thwindKeylessEntitiesQuerySqlServerTest.cs | 10 +- ...orthwindMiscellaneousQuerySqlServerTest.cs | 27 +- .../NorthwindNavigationsQuerySqlServerTest.cs | 9 +- ...NorthwindQueryFiltersQuerySqlServerTest.cs | 7 +- .../Query/NorthwindQuerySqlServerFixture.cs | 3 +- ...NorthwindQueryTaggingQuerySqlServerTest.cs | 10 +- .../NorthwindSelectQuerySqlServerTest.cs | 20 +- ...orthwindSetOperationsQuerySqlServerTest.cs | 10 +- ...plitIncludeNoTrackingQuerySqlServerTest.cs | 7 +- ...NorthwindSplitIncludeQuerySqlServerTest.cs | 7 +- ...orthwindStringIncludeQuerySqlServerTest.cs | 3 +- .../Query/NorthwindWhereQuerySqlServerTest.cs | 32 +- .../Query/NullKeysSqlServerTest.cs | 3 +- .../NullSemanticsQuerySqlServerFixture.cs | 3 +- .../Query/NullSemanticsQuerySqlServerTest.cs | 2 +- .../Query/OwnedQuerySqlServerTest.cs | 6 +- .../Query/QueryBugsTest.cs | 266 ++- .../QueryFilterFuncletizationSqlServerTest.cs | 3 +- .../Query/QueryLoggingSqlServerTest.cs | 4 +- .../SpatialQuerySqlServerGeographyTest.cs | 3 +- .../SpatialQuerySqlServerGeometryTest.cs | 12 +- .../Query/SqlExecutorSqlServerTest.cs | 11 +- ...FiltersInheritanceQuerySqlServerFixture.cs | 3 +- ...TPTFiltersInheritanceQuerySqlServerTest.cs | 4 +- .../TPTGearsOfWarQuerySqlServerFixture.cs | 3 +- .../Query/TPTGearsOfWarQuerySqlServerTest.cs | 24 +- .../TPTInheritanceQuerySqlServerFixture.cs | 3 +- ...TManyToManyNoTrackingQuerySqlServerTest.cs | 6 +- .../TPTManyToManyQuerySqlServerFixture.cs | 3 +- .../Query/TPTManyToManyQuerySqlServerTest.cs | 3 +- .../TPTRelationshipsQuerySqlServerTest.cs | 6 +- .../Query/UdfDbFunctionSqlServerTests.cs | 19 +- .../SaveChangesInterceptionSqlServerTest.cs | 15 +- .../SqlServerDatabaseModelFactoryTest.cs | 24 +- .../SequenceEndToEndTest.cs | 3 +- .../SequentialGuidEndToEndTest.cs | 3 +- .../SqlAzure/Model/AdventureWorksContext.cs | 30 +- .../SqlAzure/SqlAzureFixture.cs | 8 +- .../SqlAzure/SqlAzureFundamentalsTest.cs | 7 +- .../SqlServerConfigPatternsTest.cs | 12 +- .../SqlServerDatabaseCreatorTest.cs | 8 +- .../SqlServerFixture.cs | 7 +- .../SqlServerQueryTriggersTest.cs | 10 +- .../SqlServerTriggersTest.cs | 10 +- .../SqlServerValueGenerationConflictTest.cs | 25 +- .../StoreGeneratedFixupSqlServerTest.cs | 6 +- .../StoreGeneratedSqlServerTest.cs | 3 +- .../TPTTableSplittingSqlServerTest.cs | 3 +- .../TableSplittingSqlServerTest.cs | 3 +- .../SqlServerConditionAttribute.cs | 19 +- .../SqlServerConfiguredConditionAttribute.cs | 7 +- .../TestUtilities/SqlServerDatabaseCleaner.cs | 3 +- .../TestUtilities/SqlServerTestStore.cs | 41 +- .../TestUtilities/TestEnvironment.cs | 6 +- .../TestRelationalCommandBuilderFactory.cs | 15 +- .../TestRelationalTransaction.cs | 11 +- .../TransactionInterceptionSqlServerTest.cs | 19 +- .../TransactionSqlServerTest.cs | 9 +- .../TwoDatabasesSqlServerTest.cs | 6 +- .../UpdatesSqlServerFixture.cs | 3 +- .../UpdatesSqlServerTest.cs | 9 +- .../WithConstructorsSqlServerTest.cs | 3 +- .../DbSetAsTableNameSqlServerTest.cs | 6 +- .../SqlServerAnnotationCodeGeneratorTest.cs | 15 +- .../SqlServerModelValidatorTest.cs | 19 +- .../SqlServerConventionSetBuilderTests.cs | 7 +- .../SqlServerBuilderExtensionsTest.cs | 16 +- .../SqlServerMetadataExtensionsTest.cs | 3 +- .../SqlServerHistoryRepositoryTest.cs | 3 +- .../SqlServerMigrationsSqlGeneratorTest.cs | 16 +- .../Migrations/SqlServerModelDifferTest.cs | 196 +-- .../SqlServerModelBuilderGenericTest.cs | 6 +- .../SqlServerTestModelBuilderExtensions.cs | 6 +- .../SqlServerApiConsistencyTest.cs | 24 +- .../SqlServerDatabaseCreatorTest.cs | 15 +- .../SqlServerNTSApiConsistencyTest.cs | 2 +- .../SqlServerSequenceValueGeneratorTest.cs | 33 +- .../SqlServerTypeMapperTest.cs | 4 +- .../SqlServerValueGeneratorCacheTest.cs | 12 +- .../SqlServerValueGeneratorSelectorTest.cs | 10 +- .../Storage/SqlServerTypeMappingTest.cs | 163 +- .../Update/SqlServerUpdateSqlGeneratorTest.cs | 15 +- .../AutoincrementTest.cs | 14 +- .../BuiltInDataTypesSqliteTest.cs | 28 +- .../CommandConfigurationTest.cs | 10 +- .../CommandInterceptionSqliteTest.cs | 13 +- .../CompositeKeyEndToEndSqliteTest.cs | 3 +- .../ConferencePlannerSqliteTest.cs | 3 +- .../ConnectionInterceptionSqliteTest.cs | 13 +- .../ConvertToProviderTypesSqliteTest.cs | 28 +- .../CustomConvertersSqliteTest.cs | 28 +- .../DataAnnotationSqliteTest.cs | 7 +- .../DefaultValuesTest.cs | 8 +- .../F1SqliteFixture.cs | 7 +- .../FieldMappingSqliteTest.cs | 3 +- .../FindSqliteTest.cs | 3 +- .../GraphUpdates/GraphUpdatesSqliteTest.cs | 17 +- .../ProxyGraphUpdatesSqliteTest.cs | 31 +- .../LazyLoadProxySqliteTest.cs | 3 +- .../LoadSqliteTest.cs | 3 +- .../LoggingSqliteTest.cs | 3 +- .../ManyToManyLoadProxySqliteTest.cs | 3 +- .../ManyToManyLoadSqliteTestBase.cs | 3 +- .../ManyToManyTrackingSqliteTest.cs | 3 +- .../MigrationsInfrastructureSqliteTest.cs | 3 +- .../MigrationsSqliteTest.cs | 29 +- .../MonsterFixupChangedOnlySqliteTest.cs | 3 +- .../MusicStoreSqliteTest.cs | 3 +- .../NotificationEntitiesSqliteTest.cs | 3 +- .../OptimisticConcurrencySqliteTest.cs | 40 +- .../OverzealousInitializationSqliteTest.cs | 3 +- .../PropertyValuesSqliteTest.cs | 3 +- .../Query/BadDataSqliteTest.cs | 103 +- .../ComplexNavigationsQuerySqliteFixture.cs | 3 +- .../ComplexNavigationsQuerySqliteTest.cs | 39 +- ...omplexNavigationsWeakQuerySqliteFixture.cs | 3 +- .../ComplexNavigationsWeakQuerySqliteTest.cs | 28 +- .../FiltersInheritanceQuerySqliteFixture.cs | 3 +- .../Query/FromSqlQuerySqliteTest.cs | 6 +- .../Query/FunkyDataQuerySqliteTest.cs | 12 +- .../Query/GearsOfWarQuerySqliteFixture.cs | 3 +- .../Query/GearsOfWarQuerySqliteTest.cs | 71 +- .../Query/IncludeOneToOneSqliteTest.cs | 6 +- ...eteMappingInheritanceQuerySqliteFixture.cs | 3 +- ...mpleteMappingInheritanceQuerySqliteTest.cs | 3 +- .../Query/InheritanceQuerySqliteFixture.cs | 3 +- ...InheritanceRelationshipsQuerySqliteTest.cs | 3 +- .../ManyToManyNoTrackingQuerySqliteTest.cs | 3 +- .../Query/ManyToManyQuerySqliteFixture.cs | 3 +- .../Query/MappingQuerySqliteTest.cs | 6 +- ...thwindAggregateOperatorsQuerySqliteTest.cs | 7 +- .../NorthwindAsyncSimpleQuerySqliteTest.cs | 3 +- .../NorthwindChangeTrackingQuerySqliteTest.cs | 3 +- .../NorthwindDbFunctionsQuerySqliteTest.cs | 14 +- .../NorthwindFunctionsQuerySqliteTest.cs | 11 +- .../Query/NorthwindGroupByQuerySqliteTest.cs | 3 - ...rthwindIncludeNoTrackingQuerySqliteTest.cs | 7 +- ...NorthwindKeylessEntitiesQuerySqliteTest.cs | 7 +- .../NorthwindMiscellaneousQuerySqliteTest.cs | 12 +- .../NorthwindNavigationsQuerySqliteTest.cs | 3 +- .../NorthwindQueryFiltersQuerySqliteTest.cs | 7 +- .../Query/NorthwindQuerySqliteFixture.cs | 3 +- .../NorthwindQueryTaggingQuerySqliteTest.cs | 3 +- .../Query/NorthwindSelectQuerySqliteTest.cs | 2 +- .../NorthwindSetOperationsQuerySqliteTest.cs | 7 +- ...ndSplitIncludeNoTrackingQuerySqliteTest.cs | 7 +- .../NorthwindSplitIncludeQuerySqliteTest.cs | 4 +- .../NorthwindStringIncludeQuerySqliteTest.cs | 7 +- .../Query/NullKeysSqliteTest.cs | 3 +- .../Query/NullSemanticsQuerySqliteFixture.cs | 3 +- .../Query/OwnedQuerySqliteTest.cs | 3 +- .../QueryFilterFuncletizationSqliteTest.cs | 6 +- ...TPTFiltersInheritanceQuerySqliteFixture.cs | 3 +- .../Query/TPTGearsOfWarQuerySqliteFixture.cs | 3 +- .../Query/TPTGearsOfWarQuerySqliteTest.cs | 70 +- .../Query/TPTInheritanceQuerySqliteFixture.cs | 3 +- .../TPTManyToManyNoTrackingQuerySqliteTest.cs | 3 +- .../Query/TPTManyToManyQuerySqliteFixture.cs | 3 +- .../Query/TPTManyToManyQuerySqliteTest.cs | 3 +- .../Query/TPTRelationshipsQuerySqliteTest.cs | 3 +- .../SaveChangesInterceptionSqliteTestBase.cs | 13 +- .../SqliteDatabaseModelFactoryTest.cs | 15 +- .../StoreGeneratedFixupSqliteTest.cs | 6 +- .../StoreGeneratedSqliteTest.cs | 3 +- .../TPTTableSplittingSqliteTest.cs | 3 +- .../TableSplittingSqliteTest.cs | 3 +- .../SpatialiteRequiredAttribute.cs | 3 +- .../TestUtilities/SqliteDatabaseCleaner.cs | 9 +- .../TestUtilities/SqliteTestStore.cs | 4 +- .../SqliteVersionConditionAttribute.cs | 7 +- .../TransactionInterceptionSqliteTest.cs | 13 +- .../TransactionSqliteTest.cs | 6 +- .../TwoDatabasesSqliteTest.cs | 9 +- .../UpdatesSqliteFixture.cs | 3 +- .../WithConstructorsSqliteTest.cs | 3 +- .../DbSetAsTableNameSqliteTest.cs | 6 +- .../SqliteModelValidatorTest.cs | 6 +- .../SqliteConventionSetBuilderTests.cs | 7 +- .../Migrations/SqliteHistoryRepositoryTest.cs | 3 +- .../SqliteMigrationAnnotationProviderTest.cs | 18 +- .../SqliteMigrationsSqlGeneratorTest.cs | 44 +- .../SqliteApiConsistencyTest.cs | 5 +- test/EFCore.Sqlite.Tests/SqliteEventIdTest.cs | 44 +- .../SqliteNTSApiConsistencyTest.cs | 2 +- .../Storage/SqliteRelationalConnectionTest.cs | 5 +- .../Update/SqliteUpdateSqlGeneratorTest.cs | 10 +- test/EFCore.Tests/ApiConsistencyTest.cs | 92 +- test/EFCore.Tests/ApiConsistencyTestBase.cs | 194 ++- .../ChangeTracking/ChangeTrackerTest.cs | 33 +- .../ChangeTracking/CollectionEntryTest.cs | 9 +- .../ChangeTracking/InstanceFactoryTest.cs | 32 +- .../Internal/ChangeDetectorTest.cs | 16 +- .../Internal/CurrentValueComparerTest.cs | 41 +- .../ChangeTracking/Internal/FixupTest.cs | 190 +- .../InternalEntityEntryFactoryTest.cs | 3 +- .../InternalEntryEntrySubscriberTest.cs | 20 +- .../Internal/NavigationFixerTest.cs | 3 +- .../ObservableBackedBindingListTest.cs | 3 +- .../ChangeTracking/Internal/OwnedFixupTest.cs | 61 +- .../Internal/PropertyValuesTest.cs | 13 +- .../Internal/ShadowFixupTest.cs | 12 +- .../Internal/SortableBindingListTest.cs | 10 +- .../Internal/StateManagerTest.cs | 18 +- .../ChangeTracking/MemberEntryTest.cs | 5 +- .../ChangeTracking/ReferenceEntryTest.cs | 9 +- .../ChangeTracking/SkipCollectionEntryTest.cs | 1 - .../ChangeTracking/TrackGraphTestBase.cs | 18 +- test/EFCore.Tests/DatabaseFacadeTest.cs | 54 +- test/EFCore.Tests/DbContextFactoryTest.cs | 15 +- test/EFCore.Tests/DbContextLoggerTests.cs | 5 +- test/EFCore.Tests/DbContextOptionsTest.cs | 43 +- test/EFCore.Tests/DbContextServicesTest.cs | 162 +- test/EFCore.Tests/DbContextTest.cs | 10 +- test/EFCore.Tests/DbContextTrackingTest.cs | 36 +- test/EFCore.Tests/DbSetInitializerTest.cs | 6 +- test/EFCore.Tests/DbSetTest.cs | 18 +- test/EFCore.Tests/EntitySetFinderTest.cs | 3 +- test/EFCore.Tests/ExceptionTest.cs | 57 +- .../Extensions/PropertyExtensionsTest.cs | 3 +- .../Extensions/QueryableExtensionsTest.cs | 38 +- .../Infrastructure/CoreEventIdTest.cs | 20 +- .../Infrastructure/DiagnosticsLoggerTest.cs | 9 +- .../EntityFrameworkServicesBuilderTest.cs | 9 +- .../Infrastructure/EventIdTestBase.cs | 9 +- .../Infrastructure/ModelValidatorTest.cs | 35 +- .../Infrastructure/ModelValidatorTestBase.cs | 13 +- .../Conventions/BackingFieldConventionTest.cs | 6 +- .../Conventions/ConventionDispatcherTest.cs | 110 +- .../Conventions/ConventionSetBuilderTests.cs | 7 +- .../EntityTypeAttributeConventionTest.cs | 3 +- ...reignKeyPropertyDiscoveryConventionTest.cs | 30 +- .../IndexAttributeConventionTest.cs | 63 +- .../Conventions/KeyDiscoveryConventionTest.cs | 3 +- .../ManyToManyJoinEntityTypeConventionTest.cs | 31 +- .../NavigationAttributeConventionTest.cs | 38 +- .../NonNullableNavigationConventionTest.cs | 3 +- ...NullableReferencePropertyConventionTest.cs | 3 +- .../PropertyAttributeConventionTest.cs | 3 +- .../RelationshipDiscoveryConventionTest.cs | 19 +- .../Metadata/EntityTypeExtensionsTest.cs | 4 +- .../ClrCollectionAccessorFactoryTest.cs | 66 +- .../Internal/ClrPropertyGetterFactoryTest.cs | 35 +- .../Internal/ClrPropertySetterFactoryTest.cs | 25 +- .../Internal/EntityMaterializerSourceTest.cs | 19 +- .../Internal/EntityTypeTest.BaseType.cs | 16 +- .../Metadata/Internal/EntityTypeTest.cs | 139 +- .../Metadata/Internal/ForeignKeyTest.cs | 23 +- .../Metadata/Internal/IndexTest.cs | 4 +- .../Internal/InternalEntityTypeBuilderTest.cs | 112 +- .../Internal/InternalForeignKeyBuilderTest.cs | 6 +- .../Internal/InternalModelBuilderTest.cs | 21 +- .../Internal/InternalNavigationBuilderTest.cs | 22 +- .../Internal/InternalPropertyBuilderTest.cs | 12 +- .../InternalSkipNavigationBuilderTest.cs | 15 +- .../EFCore.Tests/Metadata/Internal/KeyTest.cs | 15 +- .../Metadata/Internal/ModelTest.cs | 40 +- .../Metadata/Internal/NavigationTest.cs | 12 +- .../Internal/PropertyAccessorsFactoryTest.cs | 3 +- .../Metadata/Internal/PropertyBaseTest.cs | 74 +- .../Metadata/Internal/PropertyTest.cs | 16 +- .../Metadata/Internal/SkipNavigationTest.cs | 22 +- .../Metadata/MetadataBuilderTest.cs | 6 +- .../Metadata/NavigationExtensionsTest.cs | 6 +- .../ModelBuilding/ManyToManyTestBase.cs | 68 +- .../ModelBuilding/ManyToOneTestBase.cs | 35 +- .../ModelBuilding/ModelBuilder.Other.cs | 3 +- ...delBuilderGenericRelationshipStringTest.cs | 3 +- .../ModelBuilding/ModelBuilderGenericTest.cs | 152 +- .../ModelBuilderNonGenericStringTest.cs | 17 +- .../ModelBuilderNonGenericTest.cs | 142 +- .../ModelBuilding/ModelBuilderTestBase.cs | 71 +- .../ModelBuilding/NonRelationshipTestBase.cs | 16 +- .../ModelBuilding/OneToManyTestBase.cs | 12 +- .../ModelBuilding/OneToOneTestBase.cs | 44 +- .../ModelBuilding/OwnedTypesTestBase.cs | 153 +- test/EFCore.Tests/ModelBuilding/TestModel.cs | 6 +- test/EFCore.Tests/ModelSourceTest.cs | 4 +- .../Query/ExpressionEqualityComparerTest.cs | 3 +- .../Query/ExpressionPrinterTest.cs | 2 +- test/EFCore.Tests/ServiceProviderCacheTest.cs | 18 +- .../Storage/ExecutionStrategyTest.cs | 6 +- .../Storage/IPAddressToBytesConverterTest.cs | 2 +- .../Storage/IPAddressToStringConverterTest.cs | 2 +- .../Storage/NumberToBytesConverterTest.cs | 10 +- .../PhysicalAddressToBytesConverterTest.cs | 4 +- .../PhysicalAddressToStringConverterTest.cs | 19 +- .../EFCore.Tests/Storage/ValueComparerTest.cs | 12 +- .../TestUtilities/FakeStateManager.cs | 153 +- .../TestUtilities/MockAssembly.cs | 50 +- .../TestInMemoryTransactionManager.cs | 18 +- test/EFCore.Tests/Utilities/MultigraphTest.cs | 12 +- .../Utilities/PropertyInfoExtensionsTest.cs | 6 +- .../Utilities/TypeExtensionsTest.cs | 16 +- .../Utilities/TypeNameHelperTest.cs | 1 - .../ValueGeneratorSelectorTest.cs | 3 +- 751 files changed, 14117 insertions(+), 8332 deletions(-) diff --git a/src/Shared/Check.cs b/src/Shared/Check.cs index 0a3ab5dc2da..d06aa69dfdb 100644 --- a/src/Shared/Check.cs +++ b/src/Shared/Check.cs @@ -112,7 +112,7 @@ public static IReadOnlyList HasNoEmptyElements( } [Conditional("DEBUG")] - public static void DebugAssert([CA.DoesNotReturnIf(false)] bool condition, string message) + public static void DebugAssert([CA.DoesNotReturnIfAttribute(false)] bool condition, string message) { if (!condition) { diff --git a/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTest.cs b/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTest.cs index fe15fac6eac..e12143b121b 100644 --- a/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTest.cs +++ b/test/EFCore.Analyzers.Tests/InternalUsageDiagnosticAnalyzerTest.cs @@ -12,7 +12,8 @@ namespace Microsoft.EntityFrameworkCore { public class InternalUsageDiagnosticAnalyzerTest : DiagnosticAnalyzerTestBase { - protected override DiagnosticAnalyzer CreateDiagnosticAnalyzer() => new InternalUsageDiagnosticAnalyzer(); + protected override DiagnosticAnalyzer CreateDiagnosticAnalyzer() + => new InternalUsageDiagnosticAnalyzer(); [ConditionalFact] public Task Invocation_on_type_in_internal_namespace() @@ -38,14 +39,16 @@ class MyClass : Microsoft.EntityFrameworkCore.Storage.Internal.RawRelationalPara var diagnostics = await GetDiagnosticsFullSourceAsync(source); - Assert.Collection(diagnostics, + Assert.Collection( + diagnostics, diagnostic => { Assert.Equal(InternalUsageDiagnosticAnalyzer.Id, diagnostic.Id); Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity); Assert.Equal( string.Format( - InternalUsageDiagnosticAnalyzer.MessageFormat, "Microsoft.EntityFrameworkCore.Storage.Internal.RawRelationalParameter"), + InternalUsageDiagnosticAnalyzer.MessageFormat, + "Microsoft.EntityFrameworkCore.Storage.Internal.RawRelationalParameter"), diagnostic.GetMessage()); var span = diagnostic.Location.SourceSpan; @@ -59,7 +62,8 @@ class MyClass : Microsoft.EntityFrameworkCore.Storage.Internal.RawRelationalPara Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity); Assert.Equal( string.Format( - InternalUsageDiagnosticAnalyzer.MessageFormat, "Microsoft.EntityFrameworkCore.Storage.Internal.RawRelationalParameter"), + InternalUsageDiagnosticAnalyzer.MessageFormat, + "Microsoft.EntityFrameworkCore.Storage.Internal.RawRelationalParameter"), diagnostic.GetMessage()); var span = diagnostic.Location.SourceSpan; diff --git a/test/EFCore.Cosmos.FunctionalTests/BuiltInDataTypesCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/BuiltInDataTypesCosmosTest.cs index f685f4ac7de..914bf7a82b9 100644 --- a/test/EFCore.Cosmos.FunctionalTests/BuiltInDataTypesCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/BuiltInDataTypesCosmosTest.cs @@ -85,25 +85,35 @@ private void AssertSql(params string[] expected) public class BuiltInDataTypesCosmosFixture : BuiltInDataTypesFixtureBase { - protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => CosmosTestStoreFactory.Instance; - public override bool StrictEquality => true; + public override bool StrictEquality + => true; - public override int IntegerPrecision => 53; + public override int IntegerPrecision + => 53; - public override bool SupportsAnsi => false; + public override bool SupportsAnsi + => false; - public override bool SupportsUnicodeToAnsiConversion => false; + public override bool SupportsUnicodeToAnsiConversion + => false; - public override bool SupportsLargeStringComparisons => true; + public override bool SupportsLargeStringComparisons + => true; - public override bool SupportsBinaryKeys => true; + public override bool SupportsBinaryKeys + => true; - public override bool SupportsDecimalComparisons => true; + public override bool SupportsDecimalComparisons + => true; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; - public override DateTime DefaultDateTime => new DateTime(); + public override DateTime DefaultDateTime + => new DateTime(); protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Cosmos.FunctionalTests/ConfigPatternsCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/ConfigPatternsCosmosTest.cs index 9677cdeb951..534062d69cb 100644 --- a/test/EFCore.Cosmos.FunctionalTests/ConfigPatternsCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/ConfigPatternsCosmosTest.cs @@ -153,7 +153,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) public class CosmosFixture : ServiceProviderFixtureBase { - protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => CosmosTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Cosmos.FunctionalTests/ConnectionSpecificationTest.cs b/test/EFCore.Cosmos.FunctionalTests/ConnectionSpecificationTest.cs index 48233605778..04b6b4d5025 100644 --- a/test/EFCore.Cosmos.FunctionalTests/ConnectionSpecificationTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/ConnectionSpecificationTest.cs @@ -53,7 +53,8 @@ public async Task Specifying_connection_string_and_account_endpoint_throws() using var context = new BloggingContextWithConnectionConflict(testDatabase); - Assert.Equal(CosmosStrings.ConnectionStringConflictingConfiguration, + Assert.Equal( + CosmosStrings.ConnectionStringConflictingConfiguration, Assert.Throws(() => context.GetService()).Message); } diff --git a/test/EFCore.Cosmos.FunctionalTests/CosmosConcurrencyTest.cs b/test/EFCore.Cosmos.FunctionalTests/CosmosConcurrencyTest.cs index 47b4ce53715..9acafc60c39 100644 --- a/test/EFCore.Cosmos.FunctionalTests/CosmosConcurrencyTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/CosmosConcurrencyTest.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 System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -21,14 +24,22 @@ public CosmosConcurrencyTest(CosmosFixture fixture) public virtual Task Adding_the_same_entity_twice_results_in_DbUpdateException() { return ConcurrencyTestAsync( - ctx => ctx.Customers.Add(new Customer { Id = "1", Name = "CreatedTwice", })); + ctx => ctx.Customers.Add( + new Customer + { + Id = "1", Name = "CreatedTwice", + })); } [ConditionalFact] public virtual Task Updating_then_deleting_the_same_entity_results_in_DbUpdateConcurrencyException() { return ConcurrencyTestAsync( - ctx => ctx.Customers.Add(new Customer { Id = "2", Name = "Added", }), + ctx => ctx.Customers.Add( + new Customer + { + Id = "2", Name = "Added", + }), ctx => ctx.Customers.Single(c => c.Id == "2").Name = "Updated", ctx => ctx.Customers.Remove(ctx.Customers.Single(c => c.Id == "2"))); } @@ -37,7 +48,11 @@ public virtual Task Updating_then_deleting_the_same_entity_results_in_DbUpdateCo public virtual Task Updating_then_updating_the_same_entity_results_in_DbUpdateConcurrencyException() { return ConcurrencyTestAsync( - ctx => ctx.Customers.Add(new Customer { Id = "3", Name = "Added", }), + ctx => ctx.Customers.Add( + new Customer + { + Id = "3", Name = "Added", + }), ctx => ctx.Customers.Single(c => c.Id == "3").Name = "Updated", ctx => ctx.Customers.Single(c => c.Id == "3").Name = "Updated"); } @@ -90,13 +105,16 @@ protected virtual async Task ConcurrencyTestAsync( Assert.IsAssignableFrom(entry.Entity); } - protected ConcurrencyContext CreateContext() => Fixture.CreateContext(); + protected ConcurrencyContext CreateContext() + => Fixture.CreateContext(); public class CosmosFixture : SharedStoreFixtureBase { - protected override string StoreName => DatabaseName; + protected override string StoreName + => DatabaseName; - protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => CosmosTestStoreFactory.Instance; } public class ConcurrencyContext : PoolableDbContext diff --git a/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs index 76dae8422d4..6bb93535514 100644 --- a/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs @@ -157,23 +157,35 @@ private void AssertSql(params string[] expected) public class CustomConvertersCosmosFixture : CustomConvertersFixtureBase { - protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; - public override bool StrictEquality => true; + protected override ITestStoreFactory TestStoreFactory + => CosmosTestStoreFactory.Instance; - public override int IntegerPrecision => 53; + public override bool StrictEquality + => true; - public override bool SupportsAnsi => false; + public override int IntegerPrecision + => 53; - public override bool SupportsUnicodeToAnsiConversion => false; + public override bool SupportsAnsi + => false; - public override bool SupportsLargeStringComparisons => true; + public override bool SupportsUnicodeToAnsiConversion + => false; - public override bool SupportsBinaryKeys => true; + public override bool SupportsLargeStringComparisons + => true; - public override bool SupportsDecimalComparisons => true; + public override bool SupportsBinaryKeys + => true; - public override DateTime DefaultDateTime => new DateTime(); - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public override bool SupportsDecimalComparisons + => true; + + public override DateTime DefaultDateTime + => new DateTime(); + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs b/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs index 780e10f2b9d..30da6054959 100644 --- a/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs @@ -449,7 +449,8 @@ public virtual async Task Can_change_principal_instance_non_derived() } } - protected TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)Fixture.ListLoggerFactory; + protected TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)Fixture.ListLoggerFactory; protected void AssertSql(params string[] expected) => TestSqlLoggerFactory.AssertBaseline(expected); @@ -464,7 +465,9 @@ public CosmosFixture() TestStore = CosmosTestStore.Create(DatabaseName); } - protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => CosmosTestStoreFactory.Instance; + public virtual CosmosTestStore TestStore { get; } private Action OnModelCreatingAction { get; set; } private object AdditionalModelCacheKey { get; set; } @@ -475,7 +478,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con } public DbContextOptions CreateOptions( - Action onModelCreating = null, object additionalModelCacheKey = null, bool seed = true) + Action onModelCreating = null, + object additionalModelCacheKey = null, + bool seed = true) { OnModelCreatingAction = onModelCreating; AdditionalModelCacheKey = additionalModelCacheKey; @@ -497,9 +502,11 @@ protected override IServiceCollection AddServices(IServiceCollection serviceColl => base.AddServices(serviceCollection) .AddSingleton(new TestModelCacheKeyFactory(() => AdditionalModelCacheKey)); - public Task InitializeAsync() => Task.CompletedTask; + public Task InitializeAsync() + => Task.CompletedTask; - public Task DisposeAsync() => TestStore.DisposeAsync(); + public Task DisposeAsync() + => TestStore.DisposeAsync(); private class TestModelCacheKeyFactory : IModelCacheKeyFactory { @@ -510,7 +517,8 @@ public TestModelCacheKeyFactory(Func getAdditionalKey) _getAdditionalKey = getAdditionalKey; } - public object Create(DbContext context) => Tuple.Create(context.GetType(), _getAdditionalKey()); + public object Create(DbContext context) + => Tuple.Create(context.GetType(), _getAdditionalKey()); } } diff --git a/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs index eaeab75c650..df2b11cfb40 100644 --- a/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs @@ -4,10 +4,8 @@ using System; using System.Linq; using System.Threading.Tasks; -using Microsoft.Azure.Cosmos; using Microsoft.EntityFrameworkCore.Cosmos.Internal; using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -216,10 +214,7 @@ public void Can_add_update_untracked_properties() var entry = context.Add(customer); - entry.Property("__jObject").CurrentValue = new JObject - { - ["key1"] = "value1" - }; + entry.Property("__jObject").CurrentValue = new JObject { ["key1"] = "value1" }; context.SaveChanges(); @@ -303,10 +298,7 @@ public async Task Can_add_update_untracked_properties_async() var entry = context.Add(customer); - entry.Property("__jObject").CurrentValue = new JObject - { - ["key1"] = "value1" - }; + entry.Property("__jObject").CurrentValue = new JObject { ["key1"] = "value1" }; await context.SaveChangesAsync(); @@ -365,7 +357,12 @@ public async Task Can_add_update_delete_end_to_end_with_Guid_async() { var options = Fixture.CreateOptions(); - var customer = new CustomerGuid { Id = Guid.NewGuid(), Name = "Theon", PartitionKey = 42 }; + var customer = new CustomerGuid + { + Id = Guid.NewGuid(), + Name = "Theon", + PartitionKey = 42 + }; using (var context = new CustomerContextGuid(options)) { @@ -455,12 +452,13 @@ public CustomerContextGuid(DbContextOptions dbContextOptions) protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.Entity(cb => - { - cb.Property(c => c.Id).HasConversion().ToJsonProperty("id"); - cb.Property(c => c.PartitionKey).HasConversion().ToJsonProperty("pk"); - cb.HasPartitionKey(c => c.PartitionKey); - }); + modelBuilder.Entity( + cb => + { + cb.Property(c => c.Id).HasConversion().ToJsonProperty("id"); + cb.Property(c => c.PartitionKey).HasConversion().ToJsonProperty("pk"); + cb.HasPartitionKey(c => c.PartitionKey); + }); } } @@ -482,8 +480,9 @@ public async Task Can_read_with_find_with_resource_id_async() { await context.Database.EnsureCreatedAsync(); - Assert.Null(context.Model.FindEntityType(typeof(CustomerWithResourceId)) - .FindProperty(StoreKeyConvention.DefaultIdPropertyName)); + Assert.Null( + context.Model.FindEntityType(typeof(CustomerWithResourceId)) + .FindProperty(StoreKeyConvention.DefaultIdPropertyName)); context.Add(customer); context.Add( @@ -589,7 +588,8 @@ public void Find_with_empty_resource_id_throws() { context.Database.EnsureCreated(); - Assert.Equal(CosmosStrings.InvalidResourceId, + Assert.Equal( + CosmosStrings.InvalidResourceId, Assert.Throws(() => context.Set().Find(1, "")).Message); } } @@ -739,7 +739,8 @@ public void Can_read_with_find_with_partition_key_without_value_generator() Assert.Equal(42, customerFromStore.Id); Assert.Equal("Theon", customerFromStore.Name); Assert.Equal(pk1, customerFromStore.PartitionKey); - AssertSql(context, @"@__p_1='42' + AssertSql( + context, @"@__p_1='42' SELECT c FROM root c @@ -799,11 +800,7 @@ public async Task Can_read_with_find_without_partition_key() { var options = Fixture.CreateOptions(); - var customer = new CustomerNoPartitionKey - { - Id = 42, - Name = "Theon" - }; + var customer = new CustomerNoPartitionKey { Id = 42, Name = "Theon" }; await using (var context = new PartitionKeyContextEntityWithNoPartitionKey(options)) { @@ -829,11 +826,7 @@ public async Task Can_read_with_find_with_PK_partition_key() { var options = Fixture.CreateOptions(); - var customer = new Customer - { - Id = 42, - Name = "Theon" - }; + var customer = new Customer { Id = 42, Name = "Theon" }; await using (var context = new PartitionKeyContextPrimaryKey(options)) { @@ -859,11 +852,7 @@ public async Task Can_read_with_find_with_PK_resource_id() { var options = Fixture.CreateOptions(); - var customer = new CustomerWithResourceId - { - id = "42", - Name = "Theon" - }; + var customer = new CustomerWithResourceId { id = "42", Name = "Theon" }; await using (var context = new PartitionKeyContextWithPrimaryKeyResourceId(options)) { @@ -880,7 +869,8 @@ public async Task Can_read_with_find_with_PK_resource_id() Assert.Equal("42", customerFromStore.id); Assert.Equal("Theon", customerFromStore.Name); - AssertSql(context, @"@__p_0='42' + AssertSql( + context, @"@__p_0='42' SELECT c FROM root c @@ -941,7 +931,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) cb.Property(c => c.PartitionKey).HasConversion(); cb.HasPartitionKey(c => c.PartitionKey); - cb.HasKey(c => new { c.PartitionKey, c.Id}); + cb.HasKey(c => new { c.PartitionKey, c.Id }); }); } } @@ -1411,7 +1401,9 @@ public CosmosFixture() TestStore = CosmosTestStore.Create(DatabaseName); } - protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => CosmosTestStoreFactory.Instance; + public virtual CosmosTestStore TestStore { get; } public DbContextOptions CreateOptions() @@ -1421,9 +1413,11 @@ public DbContextOptions CreateOptions() return CreateOptions(TestStore); } - public Task InitializeAsync() => Task.CompletedTask; + public Task InitializeAsync() + => Task.CompletedTask; - public Task DisposeAsync() => TestStore.DisposeAsync(); + public Task DisposeAsync() + => TestStore.DisposeAsync(); } } } diff --git a/test/EFCore.Cosmos.FunctionalTests/OverzealousInitializationCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/OverzealousInitializationCosmosTest.cs index 28cb72e46d1..326c3d5a6bd 100644 --- a/test/EFCore.Cosmos.FunctionalTests/OverzealousInitializationCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/OverzealousInitializationCosmosTest.cs @@ -21,7 +21,8 @@ public override void Fixup_does_not_ignore_eagerly_initialized_reference_navs() public class OverzealousInitializationCosmosFixture : OverzealousInitializationFixtureBase { - protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => CosmosTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Cosmos.FunctionalTests/PartitionKeyTest.cs b/test/EFCore.Cosmos.FunctionalTests/PartitionKeyTest.cs index a367f7ab076..d3652a0f7f7 100644 --- a/test/EFCore.Cosmos.FunctionalTests/PartitionKeyTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/PartitionKeyTest.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 System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -21,7 +24,7 @@ protected void ClearLog() => Fixture.TestSqlLoggerFactory.Clear(); protected CosmosPartitionKeyFixture Fixture { get; } - + public PartitionKeyTest(CosmosPartitionKeyFixture fixture) { Fixture = fixture; @@ -32,14 +35,14 @@ public PartitionKeyTest(CosmosPartitionKeyFixture fixture) public virtual async Task Can_add_update_delete_end_to_end_with_partition_key() { const string readSql = -@"SELECT c + @"SELECT c FROM root c WHERE (c[""Discriminator""] = ""Customer"") ORDER BY c[""PartitionKey""] OFFSET 0 LIMIT 1"; await PartitionKeyTestAsync( - ctx => ctx.Customers.OrderBy(c => c.PartitionKey).FirstAsync(), + ctx => ctx.Customers.OrderBy(c => c.PartitionKey).FirstAsync(), readSql, ctx => ctx.Customers.OrderBy(c => c.PartitionKey).LastAsync(), ctx => ctx.Customers.OrderBy(c => c.PartitionKey).ToListAsync(), @@ -50,7 +53,7 @@ await PartitionKeyTestAsync( public virtual async Task Can_add_update_delete_end_to_end_with_with_partition_key_extension() { const string readSql = -@"SELECT c + @"SELECT c FROM root c WHERE (c[""Discriminator""] = ""Customer"") OFFSET 0 LIMIT 1"; @@ -67,7 +70,7 @@ await PartitionKeyTestAsync( public async Task Can_query_with_implicit_partition_key_filter() { const string readSql = -@"SELECT c + @"SELECT c FROM root c WHERE ((c[""Discriminator""] = ""Customer"") AND ((c[""Id""] = 42) OR (c[""Name""] = ""John Snow""))) OFFSET 0 LIMIT 1"; @@ -102,7 +105,7 @@ protected virtual async Task PartitionKeyTestAsync( { Id = 42, Name = "Theon Twin", - PartitionKey = 2 + PartitionKey = 2 }; await using (var innerContext = CreateContext()) @@ -113,7 +116,7 @@ protected virtual async Task PartitionKeyTestAsync( await innerContext.AddAsync(customer2); await innerContext.SaveChangesAsync(); } - + // Read & update await using (var innerContext = CreateContext()) { @@ -124,7 +127,7 @@ protected virtual async Task PartitionKeyTestAsync( Assert.Equal(42, customerFromStore.Id); Assert.Equal("Theon", customerFromStore.Name); Assert.Equal(1, customerFromStore.PartitionKey); - + customerFromStore.Name = "Theon Greyjoy"; await innerContext.SaveChangesAsync(); @@ -143,7 +146,7 @@ protected virtual async Task PartitionKeyTestAsync( { var customerFromStore = await readSingleTask(innerContext); customerFromStore.PartitionKey = 2; - + Assert.Equal( CoreStrings.KeyReadOnly(nameof(Customer.PartitionKey), nameof(Customer)), Assert.Throws(() => innerContext.SaveChanges()).Message); @@ -171,15 +174,19 @@ protected virtual async Task PartitionKeyTestAsync( } } - protected PartitionKeyContext CreateContext() => Fixture.CreateContext(); + protected PartitionKeyContext CreateContext() + => Fixture.CreateContext(); public class CosmosPartitionKeyFixture : SharedStoreFixtureBase { - protected override string StoreName => DatabaseName; + protected override string StoreName + => DatabaseName; + + protected override bool UsePooling + => false; - protected override bool UsePooling => false; - - protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => CosmosTestStoreFactory.Instance; public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ServiceProvider.GetRequiredService(); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosFixture.cs b/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosFixture.cs index 40b4713c1e7..1fce3c27c78 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosFixture.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosFixture.cs @@ -9,7 +9,8 @@ namespace Microsoft.EntityFrameworkCore.Query { public class InheritanceQueryCosmosFixture : InheritanceQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => CosmosTestStoreFactory.Instance; public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ServiceProvider.GetRequiredService(); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosTest.cs index c0f2243a979..5a7acdc4380 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosTest.cs @@ -429,7 +429,8 @@ FROM root c WHERE c[""Discriminator""] IN (""Eagle"", ""Kiwi"")"); } - protected override bool EnforcesFkConstraints => false; + protected override bool EnforcesFkConstraints + => false; private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs index b8a95b55380..fd58a709d54 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs @@ -10,7 +10,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindAggregateOperatorsQueryCosmosTest : NorthwindAggregateOperatorsQueryTestBase> + public class NorthwindAggregateOperatorsQueryCosmosTest : NorthwindAggregateOperatorsQueryTestBase< + NorthwindQueryCosmosFixture> { public NorthwindAggregateOperatorsQueryCosmosTest( NorthwindQueryCosmosFixture fixture, diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs index bc1ae6651a9..5937253d50f 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs @@ -650,7 +650,6 @@ FROM root c WHERE ((c[""Discriminator""] = ""Order"") AND (c[""CustomerID""] = ""ALFKI""))"); } - [ConditionalTheory(Skip = "Issue #17246")] public override async Task Convert_ToByte(bool async) { diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindKeylessEntitiesQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindKeylessEntitiesQueryCosmosTest.cs index 4846afefd9e..4bad939c927 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindKeylessEntitiesQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindKeylessEntitiesQueryCosmosTest.cs @@ -10,7 +10,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindKeylessEntitiesQueryCosmosTest : NorthwindKeylessEntitiesQueryTestBase> + public class NorthwindKeylessEntitiesQueryCosmosTest : NorthwindKeylessEntitiesQueryTestBase< + NorthwindQueryCosmosFixture> { public NorthwindKeylessEntitiesQueryCosmosTest( NorthwindQueryCosmosFixture fixture, diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs index 66b4613435d..3af01b1b23e 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs @@ -14,7 +14,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindMiscellaneousQueryCosmosTest : NorthwindMiscellaneousQueryTestBase> + public class NorthwindMiscellaneousQueryCosmosTest : NorthwindMiscellaneousQueryTestBase< + NorthwindQueryCosmosFixture> { public NorthwindMiscellaneousQueryCosmosTest( NorthwindQueryCosmosFixture fixture, @@ -1032,7 +1033,7 @@ await AssertSingleResult( .Any( c2 => ss.Set() .Any(c3 => EF.Property(c1, "CustomerID") == c3.CustomerID)), - default)); + default)); AssertSql( @"SELECT c @@ -3963,7 +3964,8 @@ public override Task Select_DTO_with_member_init_distinct_in_subquery_translated } [ConditionalTheory(Skip = "Issue #17246")] - public override Task All_client(bool async) => base.All_client(async); + public override Task All_client(bool async) + => base.All_client(async); [ConditionalTheory(Skip = "Issue #17246")] public override Task Client_OrderBy_GroupBy_Group_ordering_works(bool async) @@ -3974,7 +3976,8 @@ public override Task Subquery_member_pushdown_does_not_change_original_subquery_ => base.Subquery_member_pushdown_does_not_change_original_subquery_model2(async); [ConditionalTheory(Skip = "Issue #17246")] - public override Task Where_query_composition3(bool async) => base.Where_query_composition3(async); + public override Task Where_query_composition3(bool async) + => base.Where_query_composition3(async); [ConditionalTheory(Skip = "Issue #17246")] public override Task OrderBy_object_type_server_evals(bool async) @@ -4090,7 +4093,8 @@ public override async Task Checked_context_with_case_to_same_nullable_type_does_ { await base.Checked_context_with_case_to_same_nullable_type_does_not_fail(isAsync); - AssertSql(@"SELECT MAX(c[""Quantity""]) AS c + AssertSql( + @"SELECT MAX(c[""Quantity""]) AS c FROM root c WHERE (c[""Discriminator""] = ""OrderDetail"")"); } @@ -4150,7 +4154,8 @@ public override Task Select_distinct_Select_with_client_bindings(bool async) } [ConditionalTheory(Skip = "Non embedded collection subquery Issue#17246")] - public override Task Pending_selector_in_cardinality_reducing_method_is_applied_before_expanding_collection_navigation_member(bool async) + public override Task Pending_selector_in_cardinality_reducing_method_is_applied_before_expanding_collection_navigation_member( + bool async) { return base.Pending_selector_in_cardinality_reducing_method_is_applied_before_expanding_collection_navigation_member(async); } diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindQueryCosmosFixture.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindQueryCosmosFixture.cs index 7587cf1bc29..c217c7cf96c 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindQueryCosmosFixture.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindQueryCosmosFixture.cs @@ -12,9 +12,11 @@ namespace Microsoft.EntityFrameworkCore.Query public class NorthwindQueryCosmosFixture : NorthwindQueryFixtureBase where TModelCustomizer : IModelCustomizer, new() { - protected override ITestStoreFactory TestStoreFactory => CosmosNorthwindTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => CosmosNorthwindTestStoreFactory.Instance; - protected override bool UsePooling => false; + protected override bool UsePooling + => false; public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ServiceProvider.GetRequiredService(); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs index d68a1bc52d5..308675c97b1 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs @@ -1101,7 +1101,8 @@ public override async Task Reverse_changes_asc_order_to_desc(bool async) { await base.Reverse_changes_asc_order_to_desc(async); - AssertSql(@"SELECT c[""EmployeeID""] + AssertSql( + @"SELECT c[""EmployeeID""] FROM root c WHERE (c[""Discriminator""] = ""Employee"") ORDER BY c[""EmployeeID""] DESC"); @@ -1111,7 +1112,8 @@ public override async Task Reverse_changes_desc_order_to_asc(bool async) { await base.Reverse_changes_desc_order_to_asc(async); - AssertSql(@"SELECT c[""EmployeeID""] + AssertSql( + @"SELECT c[""EmployeeID""] FROM root c WHERE (c[""Discriminator""] = ""Employee"") ORDER BY c[""EmployeeID""]"); @@ -1149,7 +1151,7 @@ public override Task Projecting_after_navigation_and_distinct_works_correctly(bo public override Task Reverse_without_explicit_ordering_throws(bool async) { return AssertTranslationFailedWithDetails( - () => base.Reverse_without_explicit_ordering_throws(async), CosmosStrings.MissingOrderingInSqlExpression); + () => base.Reverse_without_explicit_ordering_throws(async), CosmosStrings.MissingOrderingInSqlExpression); } [ConditionalTheory(Skip = "Cross collection join Issue#17246")] diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs index 66531046563..fc5fd36fb9c 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs @@ -406,7 +406,8 @@ FROM root c @"-- @__city_0='London' SELECT c FROM root c -WHERE ((c[""Discriminator""] = ""Customer"") AND (c[""City""] = @__city_0))", queryString, ignoreLineEndingDifferences: true, ignoreWhiteSpaceDifferences: true); +WHERE ((c[""Discriminator""] = ""Customer"") AND (c[""City""] = @__city_0))", queryString, ignoreLineEndingDifferences: true, + ignoreWhiteSpaceDifferences: true); return null; } diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs index e1ed1f52927..49c8f4fa429 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs @@ -490,7 +490,8 @@ private void ClearLog() public class OwnedQueryCosmosFixture : OwnedQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => CosmosTestStoreFactory.Instance; public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ServiceProvider.GetRequiredService(); @@ -502,7 +503,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con { eb.IndexerProperty("Name"); eb.HasData( - new { Id = 1, id = Guid.NewGuid().ToString(), Name = "Mona Cy" }); + new + { + Id = 1, + id = Guid.NewGuid().ToString(), + Name = "Mona Cy" + }); eb.OwnsOne( p => p.PersonAddress, ab => @@ -510,10 +516,34 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con ab.IndexerProperty("AddressLine"); ab.IndexerProperty(typeof(int), "ZipCode"); ab.HasData( - new { OwnedPersonId = 1, PlaceType = "Land", AddressLine = "804 S. Lakeshore Road", ZipCode = 38654 }, - new { OwnedPersonId = 2, PlaceType = "Land", AddressLine = "7 Church Dr.", ZipCode = 28655 }, - new { OwnedPersonId = 3, PlaceType = "Land", AddressLine = "72 Hickory Rd.", ZipCode = 07728 }, - new { OwnedPersonId = 4, PlaceType = "Land", AddressLine = "28 Strawberry St.", ZipCode = 19053 }); + new + { + OwnedPersonId = 1, + PlaceType = "Land", + AddressLine = "804 S. Lakeshore Road", + ZipCode = 38654 + }, + new + { + OwnedPersonId = 2, + PlaceType = "Land", + AddressLine = "7 Church Dr.", + ZipCode = 28655 + }, + new + { + OwnedPersonId = 3, + PlaceType = "Land", + AddressLine = "72 Hickory Rd.", + ZipCode = 07728 + }, + new + { + OwnedPersonId = 4, + PlaceType = "Land", + AddressLine = "28 Strawberry St.", + ZipCode = 19053 + }); ab.OwnsOne( a => a.Country, cb => @@ -555,11 +585,36 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con ob.HasKey(o => o.Id); ob.IndexerProperty("OrderDate"); ob.HasData( - new { Id = -10, ClientId = 1, OrderDate = Convert.ToDateTime("2018-07-11 10:01:41") }, - new { Id = -11, ClientId = 1, OrderDate = Convert.ToDateTime("2015-03-03 04:37:59") }, - new { Id = -20, ClientId = 2, OrderDate = Convert.ToDateTime("2015-05-25 20:35:48") }, - new { Id = -30, ClientId = 3, OrderDate = Convert.ToDateTime("2014-11-10 04:32:42") }, - new { Id = -40, ClientId = 4, OrderDate = Convert.ToDateTime("2016-04-25 19:23:56") } + new + { + Id = -10, + ClientId = 1, + OrderDate = Convert.ToDateTime("2018-07-11 10:01:41") + }, + new + { + Id = -11, + ClientId = 1, + OrderDate = Convert.ToDateTime("2015-03-03 04:37:59") + }, + new + { + Id = -20, + ClientId = 2, + OrderDate = Convert.ToDateTime("2015-05-25 20:35:48") + }, + new + { + Id = -30, + ClientId = 3, + OrderDate = Convert.ToDateTime("2014-11-10 04:32:42") + }, + new + { + Id = -40, + ClientId = 4, + OrderDate = Convert.ToDateTime("2016-04-25 19:23:56") + } ); }); }); @@ -568,15 +623,30 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb => { eb.HasData( - new { Id = 2, id = Guid.NewGuid().ToString(), Name = "Antigonus Mitul" }); + new + { + Id = 2, + id = Guid.NewGuid().ToString(), + Name = "Antigonus Mitul" + }); eb.OwnsOne( p => p.BranchAddress, ab => { ab.IndexerProperty("BranchName"); ab.HasData( - new { BranchId = 2, PlaceType = "Land", BranchName = "BranchA" }, - new { BranchId = 3, PlaceType = "Land", BranchName = "BranchB" }); + new + { + BranchId = 2, + PlaceType = "Land", + BranchName = "BranchA" + }, + new + { + BranchId = 3, + PlaceType = "Land", + BranchName = "BranchB" + }); ab.OwnsOne( a => a.Country, cb => @@ -602,14 +672,24 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb => { eb.HasData( - new { Id = 3, id = Guid.NewGuid().ToString(), Name = "Madalena Morana" }); + new + { + Id = 3, + id = Guid.NewGuid().ToString(), + Name = "Madalena Morana" + }); eb.OwnsOne( p => p.LeafAAddress, ab => { ab.IndexerProperty("LeafType"); ab.HasData( - new { LeafAId = 3, PlaceType = "Land", LeafType = 1 }); + new + { + LeafAId = 3, + PlaceType = "Land", + LeafType = 1 + }); ab.OwnsOne( a => a.Country, cb => @@ -629,14 +709,24 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con eb => { eb.HasData( - new { Id = 4, id = Guid.NewGuid().ToString(), Name = "Vanda Waldemar" }); + new + { + Id = 4, + id = Guid.NewGuid().ToString(), + Name = "Vanda Waldemar" + }); eb.OwnsOne( p => p.LeafBAddress, ab => { ab.IndexerProperty("LeafBType"); ab.HasData( - new { LeafBId = 4, PlaceType = "Land", LeafBType = "Green" }); + new + { + LeafBId = 4, + PlaceType = "Land", + LeafBType = "Green" + }); ab.OwnsOne( a => a.Country, cb => @@ -713,7 +803,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con { b.OwnsOne( e => e.Throned, b => b.HasData( - new { BartonId = 1, Property = "Property", Value = 42 })); + new + { + BartonId = 1, + Property = "Property", + Value = 42 + })); b.HasData( new Barton { Id = 1, Simple = "Simple" }, new Barton { Id = 2, Simple = "Not" }); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTest.cs index a3365b64322..a7af72b8175 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTest.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.Linq; using Microsoft.EntityFrameworkCore.Cosmos.Diagnostics.Internal; using Microsoft.EntityFrameworkCore.Diagnostics; @@ -89,6 +88,7 @@ public virtual void Take_without_order_by() Fixture.TestSqlLoggerFactory.Log[1].Message); } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); } } diff --git a/test/EFCore.Cosmos.FunctionalTests/ReloadTest.cs b/test/EFCore.Cosmos.FunctionalTests/ReloadTest.cs index 9534df5beaa..8c4e0e86242 100644 --- a/test/EFCore.Cosmos.FunctionalTests/ReloadTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/ReloadTest.cs @@ -1,18 +1,17 @@ -using System.Collections.Generic; +// 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.Collections.Generic; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestUtilities; -using Xunit; using Newtonsoft.Json.Linq; +using Xunit; namespace Microsoft.EntityFrameworkCore.Cosmos { public class ReloadTest { - public static IEnumerable IsAsyncData = new[] - { - new object[] { true }, - new object[] { false } - }; + public static IEnumerable IsAsyncData = new[] { new object[] { true }, new object[] { false } }; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs index 371ac35d54f..909c3db8a5c 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStore.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.IO; using System.Threading.Tasks; -using System.Text.Json; using Azure.Cosmos; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal; @@ -33,13 +32,16 @@ public static CosmosTestStore Create(string name, Action extensionConfiguration = null) => (CosmosTestStore)Create(name, extensionConfiguration).Initialize(null, (Func)null); - public static CosmosTestStore GetOrCreate(string name) => new CosmosTestStore(name); + public static CosmosTestStore GetOrCreate(string name) + => new CosmosTestStore(name); public static CosmosTestStore GetOrCreate(string name, string dataFilePath) => new CosmosTestStore(name, dataFilePath: dataFilePath); private CosmosTestStore( - string name, bool shared = true, string dataFilePath = null, + string name, + bool shared = true, + string dataFilePath = null, Action extensionConfiguration = null) : base(CreateName(name), shared) { @@ -64,15 +66,17 @@ private CosmosTestStore( } } - private static string CreateName(string name) => TestEnvironment.IsEmulator || name == "Northwind" - ? name - : name + _runId; + private static string CreateName(string name) + => TestEnvironment.IsEmulator || name == "Northwind" + ? name + : name + _runId; public string ConnectionUri { get; } public string AuthToken { get; } public string ConnectionString { get; } - protected override DbContext CreateDefaultContext() => new TestStoreContext(this); + protected override DbContext CreateDefaultContext() + => new TestStoreContext(this); public override DbContextOptionsBuilder AddProviderOptions(DbContextOptionsBuilder builder) => builder.UseCosmos( @@ -246,52 +250,133 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) private class FakeUpdateEntry : IUpdateEntry { - public IEntityType EntityType => new FakeEntityType(); + public IEntityType EntityType + => new FakeEntityType(); + public EntityState EntityState { get => EntityState.Added; set => throw new NotImplementedException(); } - public IUpdateEntry SharedIdentityEntry => throw new NotImplementedException(); - public object GetCurrentValue(IPropertyBase propertyBase) => throw new NotImplementedException(); - public TProperty GetCurrentValue(IPropertyBase propertyBase) => throw new NotImplementedException(); - public object GetOriginalValue(IPropertyBase propertyBase) => throw new NotImplementedException(); - public TProperty GetOriginalValue(IProperty property) => throw new NotImplementedException(); - public bool HasTemporaryValue(IProperty property) => throw new NotImplementedException(); - public bool IsModified(IProperty property) => throw new NotImplementedException(); - public bool IsStoreGenerated(IProperty property) => throw new NotImplementedException(); - public void SetOriginalValue(IProperty property, object value) => throw new NotImplementedException(); - public void SetPropertyModified(IProperty property) => throw new NotImplementedException(); - public void SetStoreGeneratedValue(IProperty property, object value) => throw new NotImplementedException(); - public EntityEntry ToEntityEntry() => throw new NotImplementedException(); - public object GetRelationshipSnapshotValue(IPropertyBase propertyBase) => throw new NotImplementedException(); - public object GetPreStoreGeneratedCurrentValue(IPropertyBase propertyBase) => throw new NotImplementedException(); - public bool IsConceptualNull(IProperty property) => throw new NotImplementedException(); + + public IUpdateEntry SharedIdentityEntry + => throw new NotImplementedException(); + + public object GetCurrentValue(IPropertyBase propertyBase) + => throw new NotImplementedException(); + + public TProperty GetCurrentValue(IPropertyBase propertyBase) + => throw new NotImplementedException(); + + public object GetOriginalValue(IPropertyBase propertyBase) + => throw new NotImplementedException(); + + public TProperty GetOriginalValue(IProperty property) + => throw new NotImplementedException(); + + public bool HasTemporaryValue(IProperty property) + => throw new NotImplementedException(); + + public bool IsModified(IProperty property) + => throw new NotImplementedException(); + + public bool IsStoreGenerated(IProperty property) + => throw new NotImplementedException(); + + public void SetOriginalValue(IProperty property, object value) + => throw new NotImplementedException(); + + public void SetPropertyModified(IProperty property) + => throw new NotImplementedException(); + + public void SetStoreGeneratedValue(IProperty property, object value) + => throw new NotImplementedException(); + + public EntityEntry ToEntityEntry() + => throw new NotImplementedException(); + + public object GetRelationshipSnapshotValue(IPropertyBase propertyBase) + => throw new NotImplementedException(); + + public object GetPreStoreGeneratedCurrentValue(IPropertyBase propertyBase) + => throw new NotImplementedException(); + + public bool IsConceptualNull(IProperty property) + => throw new NotImplementedException(); } public class FakeEntityType : IEntityType { - public object this[string name] => null; - public IEntityType BaseType => throw new NotImplementedException(); - public string DefiningNavigationName => throw new NotImplementedException(); - public IEntityType DefiningEntityType => throw new NotImplementedException(); - public IModel Model => throw new NotImplementedException(); - public string Name => throw new NotImplementedException(); - public Type ClrType => throw new NotImplementedException(); - public bool HasSharedClrType => throw new NotImplementedException(); - public bool IsPropertyBag => throw new NotImplementedException(); - public IAnnotation FindAnnotation(string name) => throw new NotImplementedException(); - public IForeignKey FindForeignKey(IReadOnlyList properties, IKey principalKey, IEntityType principalEntityType) => throw new NotImplementedException(); - public IIndex FindIndex(IReadOnlyList properties) => throw new NotImplementedException(); - public IIndex FindIndex(string name) => throw new NotImplementedException(); - public IKey FindKey(IReadOnlyList properties) => throw new NotImplementedException(); - public IKey FindPrimaryKey() => throw new NotImplementedException(); - public IProperty FindProperty(string name) => null; - public IServiceProperty FindServiceProperty(string name) => throw new NotImplementedException(); - public ISkipNavigation FindSkipNavigation(string name) => throw new NotImplementedException(); - public IEnumerable GetAnnotations() => throw new NotImplementedException(); - public IEnumerable GetForeignKeys() => throw new NotImplementedException(); - public IEnumerable GetIndexes() => throw new NotImplementedException(); - public IEnumerable GetKeys() => throw new NotImplementedException(); - public IEnumerable GetProperties() => throw new NotImplementedException(); - public IEnumerable GetServiceProperties() => throw new NotImplementedException(); - public IEnumerable GetSkipNavigations() => throw new NotImplementedException(); + public object this[string name] + => null; + + public IEntityType BaseType + => throw new NotImplementedException(); + + public string DefiningNavigationName + => throw new NotImplementedException(); + + public IEntityType DefiningEntityType + => throw new NotImplementedException(); + + public IModel Model + => throw new NotImplementedException(); + + public string Name + => throw new NotImplementedException(); + + public Type ClrType + => throw new NotImplementedException(); + + public bool HasSharedClrType + => throw new NotImplementedException(); + + public bool IsPropertyBag + => throw new NotImplementedException(); + + public IAnnotation FindAnnotation(string name) + => throw new NotImplementedException(); + + public IForeignKey FindForeignKey(IReadOnlyList properties, IKey principalKey, IEntityType principalEntityType) + => throw new NotImplementedException(); + + public IIndex FindIndex(IReadOnlyList properties) + => throw new NotImplementedException(); + + public IIndex FindIndex(string name) + => throw new NotImplementedException(); + + public IKey FindKey(IReadOnlyList properties) + => throw new NotImplementedException(); + + public IKey FindPrimaryKey() + => throw new NotImplementedException(); + + public IProperty FindProperty(string name) + => null; + + public IServiceProperty FindServiceProperty(string name) + => throw new NotImplementedException(); + + public ISkipNavigation FindSkipNavigation(string name) + => throw new NotImplementedException(); + + public IEnumerable GetAnnotations() + => throw new NotImplementedException(); + + public IEnumerable GetForeignKeys() + => throw new NotImplementedException(); + + public IEnumerable GetIndexes() + => throw new NotImplementedException(); + + public IEnumerable GetKeys() + => throw new NotImplementedException(); + + public IEnumerable GetProperties() + => throw new NotImplementedException(); + + public IEnumerable GetServiceProperties() + => throw new NotImplementedException(); + + public IEnumerable GetSkipNavigations() + => throw new NotImplementedException(); } } } diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStoreFactory.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStoreFactory.cs index 2431bf16725..6838a95d371 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStoreFactory.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CosmosTestStoreFactory.cs @@ -21,9 +21,11 @@ public IServiceCollection AddProviderServices(IServiceCollection serviceCollecti .AddSingleton(new TestSqlLoggerFactory()) .AddSingleton(); - public TestStore Create(string storeName) => CosmosTestStore.Create(storeName); + public TestStore Create(string storeName) + => CosmosTestStore.Create(storeName); - public virtual TestStore GetOrCreate(string storeName) => CosmosTestStore.GetOrCreate(storeName); + public virtual TestStore GetOrCreate(string storeName) + => CosmosTestStore.GetOrCreate(storeName); public virtual ListLoggerFactory CreateListLoggerFactory(Func shouldLogCategory) => new TestSqlLoggerFactory(shouldLogCategory); diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CustomPartitionKeyIdGenerator.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CustomPartitionKeyIdGenerator.cs index 1ba9809724c..819037043bc 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CustomPartitionKeyIdGenerator.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CustomPartitionKeyIdGenerator.cs @@ -1,8 +1,10 @@ -using System.Collections; +// 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.Collections; using System.Linq; using System.Text; using Microsoft.EntityFrameworkCore.ChangeTracking; -using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal; using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.ValueGeneration; @@ -10,7 +12,8 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public class CustomPartitionKeyIdGenerator : ValueGenerator { - public override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; public override T Next(EntityEntry entry) { diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CustomPartitionKeyIdValueGeneratorFactory.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CustomPartitionKeyIdValueGeneratorFactory.cs index 24e8eb96403..8b4b5ee9d34 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CustomPartitionKeyIdValueGeneratorFactory.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/CustomPartitionKeyIdValueGeneratorFactory.cs @@ -6,7 +6,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { - class CustomPartitionKeyIdValueGeneratorFactory : ValueGeneratorFactory + internal class CustomPartitionKeyIdValueGeneratorFactory : ValueGeneratorFactory { public override ValueGenerator Create(IProperty property) { diff --git a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs index cb6ccde53e4..df47bc27ce8 100644 --- a/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs +++ b/test/EFCore.Cosmos.FunctionalTests/TestUtilities/TestSqlLoggerFactory.cs @@ -29,9 +29,14 @@ public TestSqlLoggerFactory(Func shouldLogCategory) Logger = new TestSqlLogger(shouldLogCategory(DbLoggerCategory.Database.Command.Name)); } - public IReadOnlyList SqlStatements => ((TestSqlLogger)Logger).SqlStatements; - public IReadOnlyList Parameters => ((TestSqlLogger)Logger).Parameters; - public string Sql => string.Join(_eol + _eol, SqlStatements); + public IReadOnlyList SqlStatements + => ((TestSqlLogger)Logger).SqlStatements; + + public IReadOnlyList Parameters + => ((TestSqlLogger)Logger).Parameters; + + public string Sql + => string.Join(_eol + _eol, SqlStatements); public void AssertBaseline(string[] expected, bool assertOrder = true) { @@ -103,7 +108,8 @@ protected class TestSqlLogger : ListLogger { private readonly bool _shouldLogCommands; - public TestSqlLogger(bool shouldLogCommands) => _shouldLogCommands = shouldLogCommands; + public TestSqlLogger(bool shouldLogCommands) + => _shouldLogCommands = shouldLogCommands; public List SqlStatements { get; } = new List(); public List Parameters { get; } = new List(); @@ -117,7 +123,11 @@ protected override void UnsafeClear() } protected override void UnsafeLog( - LogLevel logLevel, EventId eventId, string message, TState state, Exception exception) + LogLevel logLevel, + EventId eventId, + string message, + TState state, + Exception exception) { if (eventId.Id == CosmosEventId.ExecutingSqlQuery) { @@ -142,6 +152,7 @@ protected override void UnsafeLog( SqlStatements.Add(parameters + commandText); } } + if (eventId.Id == CosmosEventId.ExecutingReadItem) { if (_shouldLogCommands) diff --git a/test/EFCore.Cosmos.Tests/CosmosApiConsistencyTest.cs b/test/EFCore.Cosmos.Tests/CosmosApiConsistencyTest.cs index ec3c899e3ce..813e6200685 100644 --- a/test/EFCore.Cosmos.Tests/CosmosApiConsistencyTest.cs +++ b/test/EFCore.Cosmos.Tests/CosmosApiConsistencyTest.cs @@ -5,9 +5,9 @@ using System.Collections.Generic; using System.Reflection; using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal; -using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; namespace Microsoft.EntityFrameworkCore.Cosmos @@ -22,7 +22,8 @@ public CosmosApiConsistencyTest(CosmosApiConsistencyFixture fixture) protected override void AddServices(ServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkCosmos(); - protected override Assembly TargetAssembly => typeof(CosmosDatabaseWrapper).Assembly; + protected override Assembly TargetAssembly + => typeof(CosmosDatabaseWrapper).Assembly; public class CosmosApiConsistencyFixture : ApiConsistencyFixtureBase { @@ -42,11 +43,15 @@ public override bool TryGetProviderOptionsDelegate(out Action MetadataExtensionTypes { get; } + public override + List<(Type Type, Type ReadonlyExtensions, Type MutableExtensions, Type ConventionExtensions, Type + ConventionBuilderExtensions)> MetadataExtensionTypes { get; } = new List<(Type, Type, Type, Type, Type)> { - { (typeof(IModel), typeof(CosmosModelExtensions), typeof(CosmosModelExtensions), typeof(CosmosModelExtensions), typeof(CosmosModelBuilderExtensions)) }, - { (typeof(IProperty), typeof(CosmosPropertyExtensions), typeof(CosmosPropertyExtensions), typeof(CosmosPropertyExtensions), typeof(CosmosPropertyBuilderExtensions)) } + (typeof(IModel), typeof(CosmosModelExtensions), typeof(CosmosModelExtensions), typeof(CosmosModelExtensions), + typeof(CosmosModelBuilderExtensions)), + (typeof(IProperty), typeof(CosmosPropertyExtensions), typeof(CosmosPropertyExtensions), + typeof(CosmosPropertyExtensions), typeof(CosmosPropertyBuilderExtensions)) }; } } diff --git a/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs b/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs index 87290f1077c..030d3beeac8 100644 --- a/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs +++ b/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs @@ -34,15 +34,16 @@ public virtual void Passes_on_valid_keyless_entity_type() public virtual void Detects_missing_id_property() { var modelBuilder = CreateConventionlessModelBuilder(); - modelBuilder.Entity(b => - { - b.Property(o => o.Id); - b.HasKey(o => o.Id); - b.Ignore(o => o.PartitionId); - b.Ignore(o => o.Customer); - b.Ignore(o => o.OrderDetails); - b.Ignore(o => o.Products); - }); + modelBuilder.Entity( + b => + { + b.Property(o => o.Id); + b.HasKey(o => o.Id); + b.Ignore(o => o.PartitionId); + b.Ignore(o => o.Customer); + b.Ignore(o => o.OrderDetails); + b.Ignore(o => o.Products); + }); var model = modelBuilder.Model; VerifyError(CosmosStrings.NoIdProperty(typeof(Order).Name), model); @@ -52,16 +53,17 @@ public virtual void Detects_missing_id_property() public virtual void Detects_non_key_id_property() { var modelBuilder = CreateConventionlessModelBuilder(); - modelBuilder.Entity(b => - { - b.Property(o => o.Id); - b.HasKey(o => o.Id); - b.Property("id"); - b.Ignore(o => o.PartitionId); - b.Ignore(o => o.Customer); - b.Ignore(o => o.OrderDetails); - b.Ignore(o => o.Products); - }); + modelBuilder.Entity( + b => + { + b.Property(o => o.Id); + b.HasKey(o => o.Id); + b.Property("id"); + b.Ignore(o => o.PartitionId); + b.Ignore(o => o.Customer); + b.Ignore(o => o.OrderDetails); + b.Ignore(o => o.Products); + }); var model = modelBuilder.Model; VerifyError(CosmosStrings.NoIdKey(typeof(Order).Name, "id"), model); @@ -71,17 +73,18 @@ public virtual void Detects_non_key_id_property() public virtual void Detects_non_string_id_property() { var modelBuilder = CreateConventionlessModelBuilder(); - modelBuilder.Entity(b => - { - b.Property(o => o.Id); - b.HasKey(o => o.Id); - b.Property("id"); - b.HasKey("id"); - b.Ignore(o => o.PartitionId); - b.Ignore(o => o.Customer); - b.Ignore(o => o.OrderDetails); - b.Ignore(o => o.Products); - }); + modelBuilder.Entity( + b => + { + b.Property(o => o.Id); + b.HasKey(o => o.Id); + b.Property("id"); + b.HasKey("id"); + b.Ignore(o => o.PartitionId); + b.Ignore(o => o.Customer); + b.Ignore(o => o.OrderDetails); + b.Ignore(o => o.Products); + }); var model = modelBuilder.Model; VerifyError(CosmosStrings.IdNonStringStoreType("id", typeof(Order).Name, "int"), model); @@ -102,13 +105,14 @@ public virtual void Passes_on_valid_partition_keys() public virtual void Passes_PK_partition_key() { var modelBuilder = CreateConventionalModelBuilder(); - modelBuilder.Entity(b => - { - b.HasKey(o => o.PartitionId); - b.Ignore(o => o.Customer); - b.Ignore(o => o.OrderDetails); - b.Ignore(o => o.Products); - }); + modelBuilder.Entity( + b => + { + b.HasKey(o => o.PartitionId); + b.Ignore(o => o.Customer); + b.Ignore(o => o.OrderDetails); + b.Ignore(o => o.Products); + }); Validate(modelBuilder.Model); } @@ -117,17 +121,18 @@ public virtual void Passes_PK_partition_key() public virtual void Detects_non_key_partition_key_property() { var modelBuilder = CreateConventionlessModelBuilder(); - modelBuilder.Entity(b => - { - b.Property(o => o.Id); - b.Property("id"); - b.HasKey("id"); - b.Property(o => o.PartitionId); - b.HasPartitionKey(o => o.PartitionId); - b.Ignore(o => o.Customer); - b.Ignore(o => o.OrderDetails); - b.Ignore(o => o.Products); - }); + modelBuilder.Entity( + b => + { + b.Property(o => o.Id); + b.Property("id"); + b.HasKey("id"); + b.Property(o => o.PartitionId); + b.HasPartitionKey(o => o.PartitionId); + b.Ignore(o => o.Customer); + b.Ignore(o => o.OrderDetails); + b.Ignore(o => o.Products); + }); VerifyError(CosmosStrings.NoPartitionKeyKey(typeof(Order).Name, nameof(Order.PartitionId), "id"), modelBuilder.Model); } @@ -197,11 +202,12 @@ public virtual void Detects_partition_key_of_different_type() public virtual void Detects_properties_mapped_to_same_property() { var modelBuilder = CreateConventionalModelBuilder(); - modelBuilder.Entity(ob => - { - ob.Property(o => o.Id).ToJsonProperty("Details"); - ob.Property(o => o.PartitionId).ToJsonProperty("Details"); - }); + modelBuilder.Entity( + ob => + { + ob.Property(o => o.Id).ToJsonProperty("Details"); + ob.Property(o => o.PartitionId).ToJsonProperty("Details"); + }); var model = modelBuilder.Model; VerifyError( @@ -213,11 +219,12 @@ public virtual void Detects_properties_mapped_to_same_property() public virtual void Detects_property_and_embedded_type_mapped_to_same_property() { var modelBuilder = CreateConventionalModelBuilder(); - modelBuilder.Entity(ob => - { - ob.Property(o => o.PartitionId).ToJsonProperty("Details"); - ob.OwnsOne(o => o.OrderDetails).ToJsonProperty("Details"); - }); + modelBuilder.Entity( + ob => + { + ob.Property(o => o.PartitionId).ToJsonProperty("Details"); + ob.OwnsOne(o => o.OrderDetails).ToJsonProperty("Details"); + }); var model = modelBuilder.Model; VerifyError( @@ -284,6 +291,7 @@ public virtual void Detects_invalid_concurrency_token() VerifyError(CosmosStrings.NonETagConcurrencyToken(typeof(Customer).Name, "_not_etag"), model); } - protected override TestHelpers TestHelpers => CosmosTestHelpers.Instance; + protected override TestHelpers TestHelpers + => CosmosTestHelpers.Instance; } } diff --git a/test/EFCore.Cosmos.Tests/Metadata/Conventions/CosmosConventionSetBuilderTests.cs b/test/EFCore.Cosmos.Tests/Metadata/Conventions/CosmosConventionSetBuilderTests.cs index f11b9cddd02..5a5b420afb1 100644 --- a/test/EFCore.Cosmos.Tests/Metadata/Conventions/CosmosConventionSetBuilderTests.cs +++ b/test/EFCore.Cosmos.Tests/Metadata/Conventions/CosmosConventionSetBuilderTests.cs @@ -23,6 +23,7 @@ public override IModel Can_build_a_model_with_default_conventions_without_DI_new return model; } - protected override ModelBuilder GetModelBuilder() => CosmosConventionSetBuilder.CreateModelBuilder(); + protected override ModelBuilder GetModelBuilder() + => CosmosConventionSetBuilder.CreateModelBuilder(); } } diff --git a/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs b/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs index f5f0eb581bc..2f8a76bdc05 100644 --- a/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs +++ b/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs @@ -136,7 +136,8 @@ public void Can_set_etag_concurrency_property() Assert.Equal("_etag", etagProperty.GetJsonPropertyName()); } - protected virtual ModelBuilder CreateConventionModelBuilder() => CosmosTestHelpers.Instance.CreateConventionBuilder(); + protected virtual ModelBuilder CreateConventionModelBuilder() + => CosmosTestHelpers.Instance.CreateConventionBuilder(); private class Customer { diff --git a/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.cs b/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.cs index daf75bfe688..8590e8ee326 100644 --- a/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.cs +++ b/test/EFCore.Cosmos.Tests/Metadata/CosmosMetadataExtensionsTest.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.Metadata.Conventions; using Xunit; // ReSharper disable once CheckNamespace @@ -86,7 +85,8 @@ public void Can_get_and_set_etag_name() Assert.Null(((IConventionEntityType)entityType).GetETagPropertyNameConfigurationSource()); } - private static ModelBuilder CreateModelBuilder() => new ModelBuilder(); + private static ModelBuilder CreateModelBuilder() + => new ModelBuilder(); private class Customer { diff --git a/test/EFCore.Cosmos.Tests/ModelBuilding/CosmosModelBuilderGenericTest.cs b/test/EFCore.Cosmos.Tests/ModelBuilding/CosmosModelBuilderGenericTest.cs index d38df677d60..11c5b0a8c9b 100644 --- a/test/EFCore.Cosmos.Tests/ModelBuilding/CosmosModelBuilderGenericTest.cs +++ b/test/EFCore.Cosmos.Tests/ModelBuilding/CosmosModelBuilderGenericTest.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.Collections.Generic; using System.Linq; using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -44,9 +43,11 @@ public virtual void Partition_key_is_added_to_the_keys() var entity = model.FindEntityType(typeof(Customer)); - Assert.Equal(new[] { nameof(Customer.Id), nameof(Customer.AlternateKey) }, + Assert.Equal( + new[] { nameof(Customer.Id), nameof(Customer.AlternateKey) }, entity.FindPrimaryKey().Properties.Select(p => p.Name)); - Assert.Equal(new[] { StoreKeyConvention.DefaultIdPropertyName, nameof(Customer.AlternateKey) }, + Assert.Equal( + new[] { StoreKeyConvention.DefaultIdPropertyName, nameof(Customer.AlternateKey) }, entity.GetKeys().First(k => k != entity.FindPrimaryKey()).Properties.Select(p => p.Name)); var idProperty = entity.FindProperty(StoreKeyConvention.DefaultIdPropertyName); @@ -70,9 +71,11 @@ public virtual void Partition_key_is_added_to_the_alternate_key_if_primary_key_c var entity = model.FindEntityType(typeof(Customer)); - Assert.Equal(new[] { StoreKeyConvention.DefaultIdPropertyName }, + Assert.Equal( + new[] { StoreKeyConvention.DefaultIdPropertyName }, entity.FindPrimaryKey().Properties.Select(p => p.Name)); - Assert.Equal(new[] { StoreKeyConvention.DefaultIdPropertyName, nameof(Customer.AlternateKey) }, + Assert.Equal( + new[] { StoreKeyConvention.DefaultIdPropertyName, nameof(Customer.AlternateKey) }, entity.GetKeys().First(k => k != entity.FindPrimaryKey()).Properties.Select(p => p.Name)); } @@ -141,7 +144,8 @@ public virtual void No_alternate_key_is_created_if_primary_key_contains_id() var entity = model.FindEntityType(typeof(Customer)); - Assert.Equal(new[] { StoreKeyConvention.DefaultIdPropertyName }, + Assert.Equal( + new[] { StoreKeyConvention.DefaultIdPropertyName }, entity.FindPrimaryKey().Properties.Select(p => p.Name)); Assert.Empty(entity.GetKeys().Where(k => k != entity.FindPrimaryKey())); @@ -166,7 +170,8 @@ public virtual void No_alternate_key_is_created_if_primary_key_contains_id_and_p var entity = model.FindEntityType(typeof(Customer)); - Assert.Equal(new[] { nameof(Customer.AlternateKey), StoreKeyConvention.DefaultIdPropertyName }, + Assert.Equal( + new[] { nameof(Customer.AlternateKey), StoreKeyConvention.DefaultIdPropertyName }, entity.FindPrimaryKey().Properties.Select(p => p.Name)); Assert.Empty(entity.GetKeys().Where(k => k != entity.FindPrimaryKey())); } diff --git a/test/EFCore.Cosmos.Tests/ModelBuilding/CosmosTestModelBuilderExtensions.cs b/test/EFCore.Cosmos.Tests/ModelBuilding/CosmosTestModelBuilderExtensions.cs index ee1ddb1dba9..f2857c2a95f 100644 --- a/test/EFCore.Cosmos.Tests/ModelBuilding/CosmosTestModelBuilderExtensions.cs +++ b/test/EFCore.Cosmos.Tests/ModelBuilding/CosmosTestModelBuilderExtensions.cs @@ -11,7 +11,8 @@ namespace Microsoft.EntityFrameworkCore.ModelBuilding public static class CosmosTestModelBuilderExtensions { public static ModelBuilderTest.TestEntityTypeBuilder HasPartitionKey( - this ModelBuilderTest.TestEntityTypeBuilder builder, Expression> propertyExpression) + this ModelBuilderTest.TestEntityTypeBuilder builder, + Expression> propertyExpression) where TEntity : class { switch (builder) @@ -29,7 +30,8 @@ public static ModelBuilderTest.TestEntityTypeBuilder HasPartitionKey ToJsonProperty( - this ModelBuilderTest.TestPropertyBuilder builder, string name) + this ModelBuilderTest.TestPropertyBuilder builder, + string name) { switch (builder) { diff --git a/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs b/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs index 25eb106a16d..9c3daaf9345 100644 --- a/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs +++ b/test/EFCore.Cosmos.Tests/ValueGenerator/Internal/IdValueGeneratorTest.cs @@ -84,7 +84,8 @@ public override bool Equals(object obj) || obj?.GetType() == GetType() && Equals((IntClass)obj); - public override int GetHashCode() => Value; + public override int GetHashCode() + => Value; public int Value { get; } } diff --git a/test/EFCore.CrossStore.FunctionalTests/ConfigurationPatternsTest.cs b/test/EFCore.CrossStore.FunctionalTests/ConfigurationPatternsTest.cs index d47c2b30121..faaf453d927 100644 --- a/test/EFCore.CrossStore.FunctionalTests/ConfigurationPatternsTest.cs +++ b/test/EFCore.CrossStore.FunctionalTests/ConfigurationPatternsTest.cs @@ -215,7 +215,8 @@ private void Seed(CrossStoreContext context) } #pragma warning disable xUnit1013 // Public method should be marked as test - public void Dispose() => ExistingTestStore.Dispose(); + public void Dispose() + => ExistingTestStore.Dispose(); #pragma warning restore xUnit1013 // Public method should be marked as test [SqlServerConfiguredCondition] @@ -279,7 +280,8 @@ private void Seed(CrossStoreContext context) } #pragma warning disable xUnit1013 // Public method should be marked as test - public void Dispose() => ExistingTestStore.Dispose(); + public void Dispose() + => ExistingTestStore.Dispose(); #pragma warning restore xUnit1013 // Public method should be marked as test private class BlogContext : DbContext diff --git a/test/EFCore.CrossStore.FunctionalTests/EndToEndTest.cs b/test/EFCore.CrossStore.FunctionalTests/EndToEndTest.cs index 4d8016c5614..97a9ef358ce 100644 --- a/test/EFCore.CrossStore.FunctionalTests/EndToEndTest.cs +++ b/test/EFCore.CrossStore.FunctionalTests/EndToEndTest.cs @@ -21,7 +21,9 @@ protected EndToEndTest(CrossStoreFixture fixture) protected CrossStoreFixture Fixture { get; } protected abstract ITestStoreFactory TestStoreFactory { get; } protected TestStore TestStore { get; } - public void Dispose() => TestStore.Dispose(); + + public void Dispose() + => TestStore.Dispose(); [ConditionalFact] public virtual void Can_save_changes_and_query() @@ -69,7 +71,8 @@ public virtual void Can_save_changes_and_query() } } - protected CrossStoreContext CreateContext() => Fixture.CreateContext(TestStore); + protected CrossStoreContext CreateContext() + => Fixture.CreateContext(TestStore); } public class InMemoryEndToEndTest : EndToEndTest, IClassFixture @@ -79,7 +82,8 @@ public InMemoryEndToEndTest(CrossStoreFixture fixture) { } - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } [SqlServerConfiguredCondition] @@ -90,7 +94,8 @@ public SqlServerEndToEndTest(CrossStoreFixture fixture) { } - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } public class SqliteEndToEndTest : EndToEndTest, IClassFixture @@ -100,6 +105,7 @@ public SqliteEndToEndTest(CrossStoreFixture fixture) { } - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } diff --git a/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs b/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs index 5099d446ef4..b6ffebdf708 100644 --- a/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs +++ b/test/EFCore.Design.Tests/Design/Internal/CSharpHelperTest.cs @@ -110,76 +110,76 @@ public void Literal_works(object value, string expected) } [ConditionalFact] - public void Literal_works_when_empty_ByteArray() => - Literal_works( + public void Literal_works_when_empty_ByteArray() + => Literal_works( Array.Empty(), "new byte[0]"); [ConditionalFact] - public void Literal_works_when_single_ByteArray() => - Literal_works( + public void Literal_works_when_single_ByteArray() + => Literal_works( new byte[] { 1 }, "new byte[] { 1 }"); [ConditionalFact] - public void Literal_works_when_many_ByteArray() => - Literal_works( + public void Literal_works_when_many_ByteArray() + => Literal_works( new byte[] { 1, 2 }, "new byte[] { 1, 2 }"); [ConditionalFact] - public void Literal_works_when_multiline_string() => - Literal_works( + public void Literal_works_when_multiline_string() + => Literal_works( "multi-line\r\nstring\nwith\r\"", "\"multi-line\\r\\nstring\\nwith\\r\\\"\""); [ConditionalFact] [UseCulture("de-DE")] - public void Literal_works_when_DateTime() => - Literal_works( + public void Literal_works_when_DateTime() + => Literal_works( new DateTime(2015, 3, 15, 20, 45, 17, 300, DateTimeKind.Local), "new DateTime(2015, 3, 15, 20, 45, 17, 300, DateTimeKind.Local)"); [ConditionalFact] [UseCulture("de-DE")] - public void Literal_works_when_DateTimeOffset() => - Literal_works( + public void Literal_works_when_DateTimeOffset() + => Literal_works( new DateTimeOffset(new DateTime(2015, 3, 15, 19, 43, 47, 500), new TimeSpan(-7, 0, 0)), "new DateTimeOffset(new DateTime(2015, 3, 15, 19, 43, 47, 500, DateTimeKind.Unspecified), new TimeSpan(0, -7, 0, 0, 0))"); [ConditionalFact] - public void Literal_works_when_decimal() => - Literal_works( + public void Literal_works_when_decimal() + => Literal_works( 4.2m, "4.2m"); [ConditionalFact] - public void Literal_works_when_decimal_max_value() => - Literal_works( + public void Literal_works_when_decimal_max_value() + => Literal_works( 79228162514264337593543950335m, // Decimal MaxValue "79228162514264337593543950335m"); [ConditionalFact] - public void Literal_works_when_decimal_min_value() => - Literal_works( + public void Literal_works_when_decimal_min_value() + => Literal_works( -79228162514264337593543950335m, // Decimal MinValue "-79228162514264337593543950335m"); [ConditionalFact] - public void Literal_works_when_Guid() => - Literal_works( + public void Literal_works_when_Guid() + => Literal_works( new Guid("fad4f3c3-9501-4b3a-af99-afeb496f7664"), "new Guid(\"fad4f3c3-9501-4b3a-af99-afeb496f7664\")"); [ConditionalFact] - public void Literal_works_when_TimeSpan() => - Literal_works( + public void Literal_works_when_TimeSpan() + => Literal_works( new TimeSpan(17, 21, 42, 37, 250), "new TimeSpan(17, 21, 42, 37, 250)"); [ConditionalFact] - public void Literal_works_when_NullableInt() => - Literal_works( + public void Literal_works_when_NullableInt() + => Literal_works( (int?)42, "42"); @@ -217,8 +217,8 @@ public void Literal_works_when_MultidimensionalArray() } [ConditionalFact] - public void Literal_works_when_BigInteger() => - Literal_works( + public void Literal_works_when_BigInteger() + => Literal_works( new BigInteger(42), "BigInteger.Parse(\"42\", NumberFormatInfo.InvariantInfo)"); diff --git a/test/EFCore.Design.Tests/Design/Internal/DatabaseOperationsTest.cs b/test/EFCore.Design.Tests/Design/Internal/DatabaseOperationsTest.cs index 97fb41fc4c4..665fce0c11d 100644 --- a/test/EFCore.Design.Tests/Design/Internal/DatabaseOperationsTest.cs +++ b/test/EFCore.Design.Tests/Design/Internal/DatabaseOperationsTest.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 Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; diff --git a/test/EFCore.Design.Tests/Design/Internal/MigrationsOperationsTest.cs b/test/EFCore.Design.Tests/Design/Internal/MigrationsOperationsTest.cs index e71542d9176..1ebb8f50505 100644 --- a/test/EFCore.Design.Tests/Design/Internal/MigrationsOperationsTest.cs +++ b/test/EFCore.Design.Tests/Design/Internal/MigrationsOperationsTest.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 Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; diff --git a/test/EFCore.Design.Tests/DesignApiConsistencyTest.cs b/test/EFCore.Design.Tests/DesignApiConsistencyTest.cs index b7b2994a8fd..e66b1cf6086 100644 --- a/test/EFCore.Design.Tests/DesignApiConsistencyTest.cs +++ b/test/EFCore.Design.Tests/DesignApiConsistencyTest.cs @@ -21,7 +21,8 @@ protected override void AddServices(ServiceCollection serviceCollection) { } - protected override Assembly TargetAssembly => typeof(OperationExecutor).Assembly; + protected override Assembly TargetAssembly + => typeof(OperationExecutor).Assembly; public class DesignApiConsistencyFixture : ApiConsistencyFixtureBase { @@ -32,10 +33,7 @@ public override bool TryGetProviderOptionsDelegate(out Action FluentApiTypes { get; } = new HashSet() - { - typeof(DesignTimeServiceCollectionExtensions) - }; + public override HashSet FluentApiTypes { get; } = new HashSet { typeof(DesignTimeServiceCollectionExtensions) }; } } } diff --git a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs index 3bfafd9cc6d..fbcbfa4f8ae 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationOperationGeneratorTest.cs @@ -791,11 +791,7 @@ public void AlterDatabaseOperation() { Collation = "Some collation", ["foo"] = "bar", - OldDatabase = - { - Collation = "Some other collation", - ["bar"] = "foo" - } + OldDatabase = { Collation = "Some other collation", ["bar"] = "foo" } }, "mb.AlterDatabase(" + _eol @@ -2539,10 +2535,7 @@ public void SqlOperation_required_args() }; private static readonly MultiPoint _multiPoint = new MultiPoint( - new[] { 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( @@ -2561,16 +2554,10 @@ public void SqlOperation_required_args() private static readonly Point _point1 = new Point(1.1, 2.2, 3.3) { SRID = 4326 }; private static readonly MultiLineString _multiLineString = new MultiLineString( - new[] { _lineString1, _lineString2 }) - { - SRID = 4326 - }; + new[] { _lineString1, _lineString2 }) { SRID = 4326 }; private static readonly MultiPolygon _multiPolygon = new MultiPolygon( - new[] { _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 }) diff --git a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs index 6a6b6f74126..55f25b04dc1 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/CSharpMigrationsGeneratorTest.cs @@ -220,7 +220,8 @@ public void Test_new_annotations_handled_for_properties() }, { RelationalAnnotationNames.Collation, - ("Some Collation", $@"{columnMapping}{_nl}.{nameof(RelationalPropertyBuilderExtensions.UseCollation)}(""Some Collation"")") + ("Some Collation", + $@"{columnMapping}{_nl}.{nameof(RelationalPropertyBuilderExtensions.UseCollation)}(""Some Collation"")") } }; @@ -307,7 +308,9 @@ public TestCSharpSnapshotGenerator(CSharpSnapshotGeneratorDependencies dependenc } public virtual void TestGenerateEntityTypeAnnotations( - string builderName, IEntityType entityType, IndentedStringBuilder stringBuilder) + string builderName, + IEntityType entityType, + IndentedStringBuilder stringBuilder) => GenerateEntityTypeAnnotations(builderName, entityType, stringBuilder); public virtual void TestGeneratePropertyAnnotations(IProperty property, IndentedStringBuilder stringBuilder) @@ -428,11 +431,11 @@ public void Migrations_compile() Table = "T1", ClrType = typeof(PropertyEntry) }, - new InsertDataOperation() + new InsertDataOperation { Table = "T1", - Columns = new string[] {"Id", "C2", "C3"}, - Values = new object[,] { { 1, null, -1} } + Columns = new[] { "Id", "C2", "C3" }, + Values = new object[,] { { 1, null, -1 } } } }, Array.Empty()); @@ -482,13 +485,14 @@ protected override void Down(MigrationBuilder migrationBuilder) var modelBuilder = new ModelBuilder(); modelBuilder.HasAnnotation("Some:EnumValue", RegexOptions.Multiline); modelBuilder.HasAnnotation(RelationalAnnotationNames.DbFunctions, new object()); - modelBuilder.Entity("T1", eb => - { - eb.Property("Id"); - eb.Property("C2").IsRequired(); - eb.Property("C3"); - eb.HasKey("Id"); - }); + modelBuilder.Entity( + "T1", eb => + { + eb.Property("Id"); + eb.Property("C2").IsRequired(); + eb.Property("C3"); + eb.HasKey("Id"); + }); var migrationMetadataCode = generator.GenerateMetadata( "MyNamespace", diff --git a/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs b/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs index 7c6f3add1b2..9b2a016a6d0 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/MigrationScaffolderTest.cs @@ -97,8 +97,8 @@ var migrationAssembly new TestRelationalTypeMappingSource( TestServiceFactory.Instance.Create(), TestServiceFactory.Instance.Create()), - new MigrationsAnnotationProvider( - new MigrationsAnnotationProviderDependencies()), + new MigrationsAnnotationProvider( + new MigrationsAnnotationProviderDependencies()), services.GetRequiredService(), services.GetRequiredService(), services.GetRequiredService()), @@ -158,26 +158,47 @@ protected override void BuildModel(ModelBuilder modelBuilder) private class MockHistoryRepository : IHistoryRepository { - public string GetBeginIfExistsScript(string migrationId) => null; - public string GetBeginIfNotExistsScript(string migrationId) => null; - public string GetCreateScript() => null; - public string GetCreateIfNotExistsScript() => null; - public string GetEndIfScript() => null; - public bool Exists() => false; - public Task ExistsAsync(CancellationToken cancellationToken) => Task.FromResult(false); - public IReadOnlyList GetAppliedMigrations() => null; + public string GetBeginIfExistsScript(string migrationId) + => null; + + public string GetBeginIfNotExistsScript(string migrationId) + => null; + + public string GetCreateScript() + => null; + + public string GetCreateIfNotExistsScript() + => null; + + public string GetEndIfScript() + => null; + + public bool Exists() + => false; + + public Task ExistsAsync(CancellationToken cancellationToken) + => Task.FromResult(false); + + public IReadOnlyList GetAppliedMigrations() + => null; public Task> GetAppliedMigrationsAsync(CancellationToken cancellationToken) => Task.FromResult>(null); - public string GetDeleteScript(string migrationId) => null; - public string GetInsertScript(HistoryRow row) => null; + public string GetDeleteScript(string migrationId) + => null; + + public string GetInsertScript(HistoryRow row) + => null; } private class MockProvider : IDatabaseProvider { - public string Name => "Mock.Provider"; - public bool IsConfigured(IDbContextOptions options) => true; + public string Name + => "Mock.Provider"; + + public bool IsConfigured(IDbContextOptions options) + => true; } } } diff --git a/test/EFCore.Design.Tests/Migrations/Design/SnapshotModelProcessorTest.cs b/test/EFCore.Design.Tests/Migrations/Design/SnapshotModelProcessorTest.cs index 8c3512b29f4..bd54c865e4c 100644 --- a/test/EFCore.Design.Tests/Migrations/Design/SnapshotModelProcessorTest.cs +++ b/test/EFCore.Design.Tests/Migrations/Design/SnapshotModelProcessorTest.cs @@ -14,6 +14,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; +using Ownership; using Xunit; // ReSharper disable ClassNeverInstantiated.Local @@ -171,7 +172,8 @@ public void Sets_owned_type_keys() Assert.Empty(reporter.Messages); Assert.Equal( nameof(BlogDetails.BlogId), - model.FindEntityType(typeof(Blog)).FindNavigation(nameof(Blog.Details)).TargetEntityType.FindPrimaryKey().Properties.Single() + model.FindEntityType(typeof(Blog)).FindNavigation(nameof(Blog.Details)).TargetEntityType.FindPrimaryKey().Properties + .Single() .Name); } @@ -182,7 +184,7 @@ public void Sets_owned_type_keys() [InlineData(typeof(OwnershipModelSnapshot3_0))] public void Can_diff_against_older_ownership_model(Type snapshotType) { - using var context = new Ownership.OwnershipContext(); + using var context = new OwnershipContext(); var differ = context.GetService(); var snapshot = (ModelSnapshot)Activator.CreateInstance(snapshotType); var reporter = new TestOperationReporter(); @@ -217,9 +219,10 @@ public void Can_diff_against_older_sequence_model(Type snapshotType) private void AddAnnotations(IMutableAnnotatable element) { foreach (var annotationName in GetAnnotationNames() - .Where(a => a != RelationalAnnotationNames.MaxIdentifierLength + .Where( + a => a != RelationalAnnotationNames.MaxIdentifierLength #pragma warning disable CS0618 // Type or member is obsolete - && a != RelationalAnnotationNames.SequencePrefix) + && a != RelationalAnnotationNames.SequencePrefix) #pragma warning restore CS0618 // Type or member is obsolete .Select(a => "Unicorn" + a.Substring(RelationalAnnotationNames.Prefix.Length - 1))) { @@ -230,24 +233,25 @@ private void AddAnnotations(IMutableAnnotatable element) private void AssertAnnotations(IMutableAnnotatable element) { foreach (var annotationName in GetAnnotationNames() - .Where(a => a != RelationalAnnotationNames.MaxIdentifierLength - && a != RelationalAnnotationNames.RelationalModel - && a != RelationalAnnotationNames.DefaultMappings - && a != RelationalAnnotationNames.DefaultColumnMappings - && a != RelationalAnnotationNames.TableMappings - && a != RelationalAnnotationNames.TableColumnMappings - && a != RelationalAnnotationNames.ViewMappings - && a != RelationalAnnotationNames.ViewColumnMappings - && a != RelationalAnnotationNames.SqlQueryMappings - && a != RelationalAnnotationNames.SqlQueryColumnMappings - && a != RelationalAnnotationNames.FunctionMappings - && a != RelationalAnnotationNames.FunctionColumnMappings - && a != RelationalAnnotationNames.ForeignKeyMappings - && a != RelationalAnnotationNames.TableIndexMappings - && a != RelationalAnnotationNames.UniqueConstraintMappings - && a != RelationalAnnotationNames.RelationalOverrides + .Where( + a => a != RelationalAnnotationNames.MaxIdentifierLength + && a != RelationalAnnotationNames.RelationalModel + && a != RelationalAnnotationNames.DefaultMappings + && a != RelationalAnnotationNames.DefaultColumnMappings + && a != RelationalAnnotationNames.TableMappings + && a != RelationalAnnotationNames.TableColumnMappings + && a != RelationalAnnotationNames.ViewMappings + && a != RelationalAnnotationNames.ViewColumnMappings + && a != RelationalAnnotationNames.SqlQueryMappings + && a != RelationalAnnotationNames.SqlQueryColumnMappings + && a != RelationalAnnotationNames.FunctionMappings + && a != RelationalAnnotationNames.FunctionColumnMappings + && a != RelationalAnnotationNames.ForeignKeyMappings + && a != RelationalAnnotationNames.TableIndexMappings + && a != RelationalAnnotationNames.UniqueConstraintMappings + && a != RelationalAnnotationNames.RelationalOverrides #pragma warning disable CS0618 // Type or member is obsolete - && a != RelationalAnnotationNames.SequencePrefix)) + && a != RelationalAnnotationNames.SequencePrefix)) #pragma warning restore CS0618 // Type or member is obsolete { Assert.Equal("Value", (string)element[annotationName]); @@ -261,7 +265,6 @@ private static IEnumerable GetAnnotationNames() .Where(p => p.Name != nameof(RelationalAnnotationNames.Prefix)) .Select(p => (string)p.GetValue(null)); - private class NullConventionSetBuilder : IConventionSetBuilder { private NullConventionSetBuilder() @@ -306,191 +309,207 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasAnnotation("ProductVersion", "2.0.3-rtm-10026") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - modelBuilder.Entity("Ownership.OwningType1", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); + modelBuilder.Entity( + "Ownership.OwningType1", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("OwningType1"); - }); + b.ToTable("OwningType1"); + }); - modelBuilder.Entity("Ownership.OwningType2", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); + modelBuilder.Entity( + "Ownership.OwningType2", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("OwningType2"); - }); + b.ToTable("OwningType2"); + }); - modelBuilder.Entity("Ownership.OwningType1", b => - { - b.OwnsOne("Ownership.OwnedType", "OwnedType1", b1 => + modelBuilder.Entity( + "Ownership.OwningType1", b => { - b1.Property("OwningType1Id"); + b.OwnsOne( + "Ownership.OwnedType", "OwnedType1", b1 => + { + b1.Property("OwningType1Id"); - b1.ToTable("OwningType1"); + b1.ToTable("OwningType1"); - b1.HasOne("Ownership.OwningType1") - .WithOne("OwnedType1") - .HasForeignKey("Ownership.OwnedType", "OwningType1Id") - .OnDelete(DeleteBehavior.Cascade); + b1.HasOne("Ownership.OwningType1") + .WithOne("OwnedType1") + .HasForeignKey("Ownership.OwnedType", "OwningType1Id") + .OnDelete(DeleteBehavior.Cascade); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType1Id"); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType1Id"); - b2.Property("Value"); + b2.Property("Value"); - b2.ToTable("OwningType1"); + b2.ToTable("OwningType1"); - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType1") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType1") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + }); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType1Id"); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType1Id"); - b2.Property("Value"); + b2.Property("Value"); - b2.ToTable("OwningType1"); + b2.ToTable("OwningType1"); - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType2") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - }); - }); + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType2") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + }); + }); - b.OwnsOne("Ownership.OwnedType", "OwnedType2", b1 => - { - b1.Property("OwningType1Id"); + b.OwnsOne( + "Ownership.OwnedType", "OwnedType2", b1 => + { + b1.Property("OwningType1Id"); - b1.ToTable("OwningType1"); + b1.ToTable("OwningType1"); - b1.HasOne("Ownership.OwningType1") - .WithOne("OwnedType2") - .HasForeignKey("Ownership.OwnedType", "OwningType1Id") - .OnDelete(DeleteBehavior.Cascade); + b1.HasOne("Ownership.OwningType1") + .WithOne("OwnedType2") + .HasForeignKey("Ownership.OwnedType", "OwningType1Id") + .OnDelete(DeleteBehavior.Cascade); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType1Id"); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType1Id"); - b2.Property("Value"); + b2.Property("Value"); - b2.ToTable("OwningType1"); + b2.ToTable("OwningType1"); - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType1") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType1") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + }); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType1Id"); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType1Id"); - b2.Property("Value"); + b2.Property("Value"); - b2.ToTable("OwningType1"); + b2.ToTable("OwningType1"); - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType2") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType2") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + }); + }); }); - }); - modelBuilder.Entity("Ownership.OwningType2", b => - { - b.OwnsOne("Ownership.OwnedType", "OwnedType1", b1 => + modelBuilder.Entity( + "Ownership.OwningType2", b => { - b1.Property("OwningType2Id"); + b.OwnsOne( + "Ownership.OwnedType", "OwnedType1", b1 => + { + b1.Property("OwningType2Id"); - b1.ToTable("OwningType2"); + b1.ToTable("OwningType2"); - b1.HasOne("Ownership.OwningType2") - .WithOne("OwnedType1") - .HasForeignKey("Ownership.OwnedType", "OwningType2Id") - .OnDelete(DeleteBehavior.Cascade); + b1.HasOne("Ownership.OwningType2") + .WithOne("OwnedType1") + .HasForeignKey("Ownership.OwnedType", "OwningType2Id") + .OnDelete(DeleteBehavior.Cascade); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType2Id"); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType2Id"); - b2.Property("Value"); + b2.Property("Value"); - b2.ToTable("OwningType2"); + b2.ToTable("OwningType2"); - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType1") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType1") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + }); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType2Id"); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType2Id"); - b2.Property("Value"); + b2.Property("Value"); - b2.ToTable("OwningType2"); + b2.ToTable("OwningType2"); - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType2") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") - .OnDelete(DeleteBehavior.Cascade); - }); - }); + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType2") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + }); + }); - b.OwnsOne("Ownership.OwnedType", "OwnedType2", b1 => - { - b1.Property("OwningType2Id"); + b.OwnsOne( + "Ownership.OwnedType", "OwnedType2", b1 => + { + b1.Property("OwningType2Id"); - b1.ToTable("OwningType2"); + b1.ToTable("OwningType2"); - b1.HasOne("Ownership.OwningType2") - .WithOne("OwnedType2") - .HasForeignKey("Ownership.OwnedType", "OwningType2Id") - .OnDelete(DeleteBehavior.Cascade); + b1.HasOne("Ownership.OwningType2") + .WithOne("OwnedType2") + .HasForeignKey("Ownership.OwnedType", "OwningType2Id") + .OnDelete(DeleteBehavior.Cascade); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType2Id"); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType2Id"); - b2.Property("Value"); + b2.Property("Value"); - b2.ToTable("OwningType2"); + b2.ToTable("OwningType2"); - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType1") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType1") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + }); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType2Id"); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType2Id"); - b2.Property("Value"); + b2.Property("Value"); - b2.ToTable("OwningType2"); + b2.ToTable("OwningType2"); - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType2") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType2") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + }); + }); }); - }); #pragma warning restore 612, 618 } } @@ -505,217 +524,241 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - modelBuilder.Entity("Ownership.OwningType1", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.HasKey("Id"); - - b.ToTable("OwningType1"); - }); - - modelBuilder.Entity("Ownership.OwningType2", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.HasKey("Id"); - - b.ToTable("OwningType2"); - }); - - modelBuilder.Entity("Ownership.OwningType1", b => - { - b.OwnsOne("Ownership.OwnedType", "OwnedType1", b1 => + modelBuilder.Entity( + "Ownership.OwningType1", b => { - b1.Property("OwningType1Id") + b.Property("Id") .ValueGeneratedOnAdd() .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b1.ToTable("OwningType1"); - - b1.HasOne("Ownership.OwningType1") - .WithOne("OwnedType1") - .HasForeignKey("Ownership.OwnedType", "OwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType1Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b.HasKey("Id"); - b2.Property("Value"); - - b2.ToTable("OwningType1"); - - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType1") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - }); - - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType1Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b2.Property("Value"); - - b2.ToTable("OwningType1"); - - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType2") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b.ToTable("OwningType1"); }); - b.OwnsOne("Ownership.OwnedType", "OwnedType2", b1 => + modelBuilder.Entity( + "Ownership.OwningType2", b => { - b1.Property("OwningType1Id") + b.Property("Id") .ValueGeneratedOnAdd() .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b1.ToTable("OwningType1"); - - b1.HasOne("Ownership.OwningType1") - .WithOne("OwnedType2") - .HasForeignKey("Ownership.OwnedType", "OwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType1Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b2.Property("Value"); - - b2.ToTable("OwningType1"); + b.HasKey("Id"); - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType1") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - }); - - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType1Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b2.Property("Value"); - - b2.ToTable("OwningType1"); - - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType2") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b.ToTable("OwningType2"); }); - }); - modelBuilder.Entity("Ownership.OwningType2", b => - { - b.OwnsOne("Ownership.OwnedType", "OwnedType1", b1 => + modelBuilder.Entity( + "Ownership.OwningType1", b => { - b1.Property("OwningType2Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.ToTable("OwningType2"); - - b1.HasOne("Ownership.OwningType2") - .WithOne("OwnedType1") - .HasForeignKey("Ownership.OwnedType", "OwningType2Id") - .OnDelete(DeleteBehavior.Cascade); - - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType2Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b2.Property("Value"); - - b2.ToTable("OwningType2"); - - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType1") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") - .OnDelete(DeleteBehavior.Cascade); - }); - - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType2Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b2.Property("Value"); - - b2.ToTable("OwningType2"); - - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType2") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b.OwnsOne( + "Ownership.OwnedType", "OwnedType1", b1 => + { + b1.Property("OwningType1Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.ToTable("OwningType1"); + + b1.HasOne("Ownership.OwningType1") + .WithOne("OwnedType1") + .HasForeignKey("Ownership.OwnedType", "OwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType1Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); + + b2.ToTable("OwningType1"); + + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType1") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + }); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType1Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); + + b2.ToTable("OwningType1"); + + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType2") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + }); + }); + + b.OwnsOne( + "Ownership.OwnedType", "OwnedType2", b1 => + { + b1.Property("OwningType1Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.ToTable("OwningType1"); + + b1.HasOne("Ownership.OwningType1") + .WithOne("OwnedType2") + .HasForeignKey("Ownership.OwnedType", "OwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType1Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); + + b2.ToTable("OwningType1"); + + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType1") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + }); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType1Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); + + b2.ToTable("OwningType1"); + + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType2") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + }); + }); }); - b.OwnsOne("Ownership.OwnedType", "OwnedType2", b1 => + modelBuilder.Entity( + "Ownership.OwningType2", b => { - b1.Property("OwningType2Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.ToTable("OwningType2"); - - b1.HasOne("Ownership.OwningType2") - .WithOne("OwnedType2") - .HasForeignKey("Ownership.OwnedType", "OwningType2Id") - .OnDelete(DeleteBehavior.Cascade); - - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType2Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b2.Property("Value"); - - b2.ToTable("OwningType2"); - - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType1") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") - .OnDelete(DeleteBehavior.Cascade); - }); - - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType2Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b2.Property("Value"); - - b2.ToTable("OwningType2"); - - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType2") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b.OwnsOne( + "Ownership.OwnedType", "OwnedType1", b1 => + { + b1.Property("OwningType2Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.ToTable("OwningType2"); + + b1.HasOne("Ownership.OwningType2") + .WithOne("OwnedType1") + .HasForeignKey("Ownership.OwnedType", "OwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType2Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); + + b2.ToTable("OwningType2"); + + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType1") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + }); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType2Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); + + b2.ToTable("OwningType2"); + + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType2") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + }); + }); + + b.OwnsOne( + "Ownership.OwnedType", "OwnedType2", b1 => + { + b1.Property("OwningType2Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.ToTable("OwningType2"); + + b1.HasOne("Ownership.OwningType2") + .WithOne("OwnedType2") + .HasForeignKey("Ownership.OwnedType", "OwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType2Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); + + b2.ToTable("OwningType2"); + + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType1") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + }); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType2Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); + + b2.ToTable("OwningType2"); + + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType2") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + }); + }); }); - }); #pragma warning restore 612, 618 } } @@ -730,241 +773,265 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - modelBuilder.Entity("Ownership.OwningType1", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.HasKey("Id"); - - b.ToTable("OwningType1"); - }); - - modelBuilder.Entity("Ownership.OwningType2", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.HasKey("Id"); - - b.ToTable("OwningType2"); - }); - - modelBuilder.Entity("Ownership.OwningType1", b => - { - b.OwnsOne("Ownership.OwnedType", "OwnedType1", b1 => + modelBuilder.Entity( + "Ownership.OwningType1", b => { - b1.Property("OwningType1Id") + b.Property("Id") .ValueGeneratedOnAdd() .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b1.HasKey("OwningType1Id"); - - b1.ToTable("OwningType1"); - - b1.HasOne("Ownership.OwningType1") - .WithOne("OwnedType1") - .HasForeignKey("Ownership.OwnedType", "OwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType1Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b2.Property("Value"); - - b2.HasKey("OwnedTypeOwningType1Id"); - - b2.ToTable("OwningType1"); - - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType1") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - }); - - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType1Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b.HasKey("Id"); - b2.Property("Value"); - - b2.HasKey("OwnedTypeOwningType1Id"); - - b2.ToTable("OwningType1"); - - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType2") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b.ToTable("OwningType1"); }); - b.OwnsOne("Ownership.OwnedType", "OwnedType2", b1 => + modelBuilder.Entity( + "Ownership.OwningType2", b => { - b1.Property("OwningType1Id") + b.Property("Id") .ValueGeneratedOnAdd() .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b1.HasKey("OwningType1Id"); - - b1.ToTable("OwningType1"); - - b1.HasOne("Ownership.OwningType1") - .WithOne("OwnedType2") - .HasForeignKey("Ownership.OwnedType", "OwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType1Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b2.Property("Value"); - - b2.HasKey("OwnedTypeOwningType1Id"); - - b2.ToTable("OwningType1"); - - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType1") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b.HasKey("Id"); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType1Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b2.Property("Value"); - - b2.HasKey("OwnedTypeOwningType1Id"); - - b2.ToTable("OwningType1"); - - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType2") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b.ToTable("OwningType2"); }); - }); - modelBuilder.Entity("Ownership.OwningType2", b => - { - b.OwnsOne("Ownership.OwnedType", "OwnedType1", b1 => + modelBuilder.Entity( + "Ownership.OwningType1", b => { - b1.Property("OwningType2Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.HasKey("OwningType2Id"); - - b1.ToTable("OwningType2"); + b.OwnsOne( + "Ownership.OwnedType", "OwnedType1", b1 => + { + b1.Property("OwningType1Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b1.HasOne("Ownership.OwningType2") - .WithOne("OwnedType1") - .HasForeignKey("Ownership.OwnedType", "OwningType2Id") - .OnDelete(DeleteBehavior.Cascade); + b1.HasKey("OwningType1Id"); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType2Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b1.ToTable("OwningType1"); - b2.Property("Value"); + b1.HasOne("Ownership.OwningType1") + .WithOne("OwnedType1") + .HasForeignKey("Ownership.OwnedType", "OwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType1Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); + + b2.HasKey("OwnedTypeOwningType1Id"); + + b2.ToTable("OwningType1"); + + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType1") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + }); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType1Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); + + b2.HasKey("OwnedTypeOwningType1Id"); + + b2.ToTable("OwningType1"); + + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType2") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + }); + }); + + b.OwnsOne( + "Ownership.OwnedType", "OwnedType2", b1 => + { + b1.Property("OwningType1Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.HasKey("OwningType1Id"); + + b1.ToTable("OwningType1"); + + b1.HasOne("Ownership.OwningType1") + .WithOne("OwnedType2") + .HasForeignKey("Ownership.OwnedType", "OwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType1Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); + + b2.HasKey("OwnedTypeOwningType1Id"); + + b2.ToTable("OwningType1"); + + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType1") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + }); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType1Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); - b2.HasKey("OwnedTypeOwningType2Id"); + b2.HasKey("OwnedTypeOwningType1Id"); - b2.ToTable("OwningType2"); + b2.ToTable("OwningType1"); - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType1") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") - .OnDelete(DeleteBehavior.Cascade); - }); - - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType2Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b2.Property("Value"); - - b2.HasKey("OwnedTypeOwningType2Id"); - - b2.ToTable("OwningType2"); - - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType2") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType2") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType1Id") + .OnDelete(DeleteBehavior.Cascade); + }); + }); }); - b.OwnsOne("Ownership.OwnedType", "OwnedType2", b1 => + modelBuilder.Entity( + "Ownership.OwningType2", b => { - b1.Property("OwningType2Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b1.HasKey("OwningType2Id"); - - b1.ToTable("OwningType2"); - - b1.HasOne("Ownership.OwningType2") - .WithOne("OwnedType2") - .HasForeignKey("Ownership.OwnedType", "OwningType2Id") - .OnDelete(DeleteBehavior.Cascade); + b.OwnsOne( + "Ownership.OwnedType", "OwnedType1", b1 => + { + b1.Property("OwningType2Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType2Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b1.HasKey("OwningType2Id"); - b2.Property("Value"); + b1.ToTable("OwningType2"); - b2.HasKey("OwnedTypeOwningType2Id"); + b1.HasOne("Ownership.OwningType2") + .WithOne("OwnedType1") + .HasForeignKey("Ownership.OwnedType", "OwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType2Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); + + b2.HasKey("OwnedTypeOwningType2Id"); + + b2.ToTable("OwningType2"); + + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType1") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + }); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType2Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); + + b2.HasKey("OwnedTypeOwningType2Id"); + + b2.ToTable("OwningType2"); + + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType2") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + }); + }); + + b.OwnsOne( + "Ownership.OwnedType", "OwnedType2", b1 => + { + b1.Property("OwningType2Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b1.HasKey("OwningType2Id"); + + b1.ToTable("OwningType2"); + + b1.HasOne("Ownership.OwningType2") + .WithOne("OwnedType2") + .HasForeignKey("Ownership.OwnedType", "OwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType2Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); + + b2.HasKey("OwnedTypeOwningType2Id"); + + b2.ToTable("OwningType2"); + + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType1") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + }); + + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType2Id") + .ValueGeneratedOnAdd() + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b2.Property("Value"); - b2.ToTable("OwningType2"); + b2.HasKey("OwnedTypeOwningType2Id"); - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType1") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b2.ToTable("OwningType2"); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType2Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b2.Property("Value"); - - b2.HasKey("OwnedTypeOwningType2Id"); - - b2.ToTable("OwningType2"); - - b2.HasOne("Ownership.OwnedType") - .WithOne("NestedOwnedType2") - .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") - .OnDelete(DeleteBehavior.Cascade); - }); + b2.HasOne("Ownership.OwnedType") + .WithOne("NestedOwnedType2") + .HasForeignKey("Ownership.NestedOwnedType", "OwnedTypeOwningType2Id") + .OnDelete(DeleteBehavior.Cascade); + }); + }); }); - }); #pragma warning restore 612, 618 } } @@ -979,239 +1046,263 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - modelBuilder.Entity("Ownership.OwningType1", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.HasKey("Id"); - - b.ToTable("OwningType1"); - }); - - modelBuilder.Entity("Ownership.OwningType2", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + modelBuilder.Entity( + "Ownership.OwningType1", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("OwningType2"); - }); + b.ToTable("OwningType1"); + }); - modelBuilder.Entity("Ownership.OwningType1", b => - { - b.OwnsOne("Ownership.OwnedType", "OwnedType1", b1 => + modelBuilder.Entity( + "Ownership.OwningType2", b => { - b1.Property("OwningType1Id") + b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b1.HasKey("OwningType1Id"); + b.HasKey("Id"); - b1.ToTable("OwningType1"); + b.ToTable("OwningType2"); + }); - b1.WithOwner() - .HasForeignKey("OwningType1Id"); + modelBuilder.Entity( + "Ownership.OwningType1", b => + { + b.OwnsOne( + "Ownership.OwnedType", "OwnedType1", b1 => + { + b1.Property("OwningType1Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType1Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b1.HasKey("OwningType1Id"); - b2.Property("Value") - .HasColumnType("int"); + b1.ToTable("OwningType1"); - b2.HasKey("OwnedTypeOwningType1Id"); + b1.WithOwner() + .HasForeignKey("OwningType1Id"); - b2.ToTable("OwningType1"); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType1Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b2.WithOwner() - .HasForeignKey("OwnedTypeOwningType1Id"); - }); + b2.Property("Value") + .HasColumnType("int"); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType1Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b2.HasKey("OwnedTypeOwningType1Id"); - b2.Property("Value") - .HasColumnType("int"); + b2.ToTable("OwningType1"); - b2.HasKey("OwnedTypeOwningType1Id"); + b2.WithOwner() + .HasForeignKey("OwnedTypeOwningType1Id"); + }); - b2.ToTable("OwningType1"); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType1Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b2.WithOwner() - .HasForeignKey("OwnedTypeOwningType1Id"); - }); - }); + b2.Property("Value") + .HasColumnType("int"); - b.OwnsOne("Ownership.OwnedType", "OwnedType2", b1 => - { - b1.Property("OwningType1Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b2.HasKey("OwnedTypeOwningType1Id"); - b1.HasKey("OwningType1Id"); + b2.ToTable("OwningType1"); - b1.ToTable("OwningType1"); + b2.WithOwner() + .HasForeignKey("OwnedTypeOwningType1Id"); + }); + }); - b1.WithOwner() - .HasForeignKey("OwningType1Id"); + b.OwnsOne( + "Ownership.OwnedType", "OwnedType2", b1 => + { + b1.Property("OwningType1Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType1Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b1.HasKey("OwningType1Id"); - b2.Property("Value") - .HasColumnType("int"); + b1.ToTable("OwningType1"); - b2.HasKey("OwnedTypeOwningType1Id"); + b1.WithOwner() + .HasForeignKey("OwningType1Id"); - b2.ToTable("OwningType1"); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType1Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b2.WithOwner() - .HasForeignKey("OwnedTypeOwningType1Id"); - }); + b2.Property("Value") + .HasColumnType("int"); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType1Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b2.HasKey("OwnedTypeOwningType1Id"); - b2.Property("Value") - .HasColumnType("int"); + b2.ToTable("OwningType1"); - b2.HasKey("OwnedTypeOwningType1Id"); + b2.WithOwner() + .HasForeignKey("OwnedTypeOwningType1Id"); + }); - b2.ToTable("OwningType1"); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType1Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b2.WithOwner() - .HasForeignKey("OwnedTypeOwningType1Id"); - }); + b2.Property("Value") + .HasColumnType("int"); + + b2.HasKey("OwnedTypeOwningType1Id"); + + b2.ToTable("OwningType1"); + + b2.WithOwner() + .HasForeignKey("OwnedTypeOwningType1Id"); + }); + }); }); - }); - modelBuilder.Entity("Ownership.OwningType2", b => - { - b.OwnsOne("Ownership.OwnedType", "OwnedType1", b1 => + modelBuilder.Entity( + "Ownership.OwningType2", b => { - b1.Property("OwningType2Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b.OwnsOne( + "Ownership.OwnedType", "OwnedType1", b1 => + { + b1.Property("OwningType2Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b1.HasKey("OwningType2Id"); + b1.HasKey("OwningType2Id"); - b1.ToTable("OwningType2"); + b1.ToTable("OwningType2"); - b1.WithOwner() - .HasForeignKey("OwningType2Id"); + b1.WithOwner() + .HasForeignKey("OwningType2Id"); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType2Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType2Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b2.Property("Value") - .HasColumnType("int"); + b2.Property("Value") + .HasColumnType("int"); - b2.HasKey("OwnedTypeOwningType2Id"); + b2.HasKey("OwnedTypeOwningType2Id"); - b2.ToTable("OwningType2"); + b2.ToTable("OwningType2"); - b2.WithOwner() - .HasForeignKey("OwnedTypeOwningType2Id"); - }); + b2.WithOwner() + .HasForeignKey("OwnedTypeOwningType2Id"); + }); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType2Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType2Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b2.Property("Value") - .HasColumnType("int"); + b2.Property("Value") + .HasColumnType("int"); - b2.HasKey("OwnedTypeOwningType2Id"); + b2.HasKey("OwnedTypeOwningType2Id"); - b2.ToTable("OwningType2"); + b2.ToTable("OwningType2"); - b2.WithOwner() - .HasForeignKey("OwnedTypeOwningType2Id"); - }); - }); + b2.WithOwner() + .HasForeignKey("OwnedTypeOwningType2Id"); + }); + }); - b.OwnsOne("Ownership.OwnedType", "OwnedType2", b1 => - { - b1.Property("OwningType2Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b.OwnsOne( + "Ownership.OwnedType", "OwnedType2", b1 => + { + b1.Property("OwningType2Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b1.HasKey("OwningType2Id"); + b1.HasKey("OwningType2Id"); - b1.ToTable("OwningType2"); + b1.ToTable("OwningType2"); - b1.WithOwner() - .HasForeignKey("OwningType2Id"); + b1.WithOwner() + .HasForeignKey("OwningType2Id"); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType1", b2 => - { - b2.Property("OwnedTypeOwningType2Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType1", b2 => + { + b2.Property("OwnedTypeOwningType2Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b2.Property("Value") - .HasColumnType("int"); + b2.Property("Value") + .HasColumnType("int"); - b2.HasKey("OwnedTypeOwningType2Id"); + b2.HasKey("OwnedTypeOwningType2Id"); - b2.ToTable("OwningType2"); + b2.ToTable("OwningType2"); - b2.WithOwner() - .HasForeignKey("OwnedTypeOwningType2Id"); - }); + b2.WithOwner() + .HasForeignKey("OwnedTypeOwningType2Id"); + }); - b1.OwnsOne("Ownership.NestedOwnedType", "NestedOwnedType2", b2 => - { - b2.Property("OwnedTypeOwningType2Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b1.OwnsOne( + "Ownership.NestedOwnedType", "NestedOwnedType2", b2 => + { + b2.Property("OwnedTypeOwningType2Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation( + "SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - b2.Property("Value") - .HasColumnType("int"); + b2.Property("Value") + .HasColumnType("int"); - b2.HasKey("OwnedTypeOwningType2Id"); + b2.HasKey("OwnedTypeOwningType2Id"); - b2.ToTable("OwningType2"); + b2.ToTable("OwningType2"); - b2.WithOwner() - .HasForeignKey("OwnedTypeOwningType2Id"); - }); + b2.WithOwner() + .HasForeignKey("OwnedTypeOwningType2Id"); + }); + }); }); - }); #pragma warning restore 612, 618 } } @@ -1265,11 +1356,11 @@ protected override void OnConfiguring(DbContextOptionsBuilder options) protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.HasSequence("Foo", "Bar") - .StartsAt(2) - .HasMin(1) - .HasMax(3) - .IncrementsBy(2) - .IsCyclic(); + .StartsAt(2) + .HasMin(1) + .HasMax(3) + .IncrementsBy(2) + .IsCyclic(); } } } diff --git a/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs b/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs index 005bf8fdbc5..4dff8a5fa86 100644 --- a/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs +++ b/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs @@ -201,7 +201,7 @@ public class TestOwnee public TestEnum TestEnum { get; set; } } - public enum TestEnum : int + public enum TestEnum { Value0 = 0, Value1, @@ -275,9 +275,11 @@ private class ManyToManyRight private class CustomValueGenerator : ValueGenerator { - public override int Next(EntityEntry entry) => throw new NotImplementedException(); + public override int Next(EntityEntry entry) + => throw new NotImplementedException(); - public override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; } #region Model @@ -430,8 +432,10 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPT() { Assert.Equal(5, o.GetAnnotations().Count()); - Assert.Equal("DerivedEntity", - o.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+DerivedEntity").GetTableName()); + Assert.Equal( + "DerivedEntity", + o.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+DerivedEntity") + .GetTableName()); }); } @@ -485,8 +489,10 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPT_with_one_exclu { Assert.Equal(5, o.GetAnnotations().Count()); - Assert.Equal("DerivedEntity", - o.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+DerivedEntity").GetTableName()); + Assert.Equal( + "DerivedEntity", + o.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+DerivedEntity") + .GetTableName()); }); } @@ -495,7 +501,6 @@ public void Views_are_stored_in_the_model_snapshot() { Test( builder => builder.Entity().Ignore(e => e.EntityWithTwoProperties).ToView("EntityWithOneProperty"), - AddBoilerPlate( GetHeading() + @" @@ -525,14 +530,14 @@ public void TVF_types_are_stored_in_the_model_snapshot() { Test( builder => - { - builder.HasDbFunction(typeof(ModelSnapshotSqlServerTest).GetMethod( - nameof(GetCountByYear), - BindingFlags.NonPublic | BindingFlags.Static)); - - builder.Entity().HasNoKey(); - }, + { + builder.HasDbFunction( + typeof(ModelSnapshotSqlServerTest).GetMethod( + nameof(GetCountByYear), + BindingFlags.NonPublic | BindingFlags.Static)); + builder.Entity().HasNoKey(); + }, AddBoilerPlate( GetHeading() + @" @@ -549,10 +554,12 @@ public void Entity_types_mapped_to_functions_are_stored_in_the_model_snapshot() { Test( builder => - builder.Entity(kb => { - kb.Property(k => k.Something); - kb.HasNoKey().ToFunction("GetCount"); - }), + builder.Entity( + kb => + { + kb.Property(k => k.Something); + kb.HasNoKey().ToFunction("GetCount"); + }), AddBoilerPlate( GetHeading() + @" @@ -1210,7 +1217,8 @@ public virtual void Many_to_many_join_table_stored_in_snapshot() { var joinEntity = model.FindEntityType("ManyToManyLeftManyToManyRight"); Assert.NotNull(joinEntity); - Assert.Collection(joinEntity.GetDeclaredProperties(), + Assert.Collection( + joinEntity.GetDeclaredProperties(), p => { Assert.Equal("LeftsId", p.Name); @@ -1221,7 +1229,8 @@ public virtual void Many_to_many_join_table_stored_in_snapshot() Assert.Equal("RightsId", p.Name); Assert.True(p.IsShadowProperty()); }); - Assert.Collection(joinEntity.FindDeclaredPrimaryKey().Properties, + Assert.Collection( + joinEntity.FindDeclaredPrimaryKey().Properties, p => { Assert.Equal("LeftsId", p.Name); @@ -1230,16 +1239,21 @@ public virtual void Many_to_many_join_table_stored_in_snapshot() { Assert.Equal("RightsId", p.Name); }); - Assert.Collection(joinEntity.GetDeclaredForeignKeys(), + Assert.Collection( + joinEntity.GetDeclaredForeignKeys(), fk => { - Assert.Equal("Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+ManyToManyLeft", fk.PrincipalEntityType.Name); - Assert.Collection(fk.PrincipalKey.Properties, + Assert.Equal( + "Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+ManyToManyLeft", + fk.PrincipalEntityType.Name); + Assert.Collection( + fk.PrincipalKey.Properties, p => { Assert.Equal("Id", p.Name); }); - Assert.Collection(fk.Properties, + Assert.Collection( + fk.Properties, p => { Assert.Equal("LeftsId", p.Name); @@ -1247,13 +1261,17 @@ public virtual void Many_to_many_join_table_stored_in_snapshot() }, fk => { - Assert.Equal("Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+ManyToManyRight", fk.PrincipalEntityType.Name); - Assert.Collection(fk.PrincipalKey.Properties, + Assert.Equal( + "Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+ManyToManyRight", + fk.PrincipalEntityType.Name); + Assert.Collection( + fk.PrincipalKey.Properties, p => { Assert.Equal("Id", p.Name); }); - Assert.Collection(fk.Properties, + Assert.Collection( + fk.Properties, p => { Assert.Equal("RightsId", p.Name); @@ -1341,7 +1359,8 @@ public virtual void Can_override_table_name_for_many_to_many_join_table_stored_i var joinEntity = model.FindEntityType("ManyToManyLeftManyToManyRight"); Assert.NotNull(joinEntity); Assert.Equal("MyJoinTable", joinEntity.GetTableName()); - Assert.Collection(joinEntity.GetDeclaredProperties(), + Assert.Collection( + joinEntity.GetDeclaredProperties(), p => { Assert.Equal("LeftsId", p.Name); @@ -1352,7 +1371,8 @@ public virtual void Can_override_table_name_for_many_to_many_join_table_stored_i Assert.Equal("RightsId", p.Name); Assert.True(p.IsShadowProperty()); }); - Assert.Collection(joinEntity.FindDeclaredPrimaryKey().Properties, + Assert.Collection( + joinEntity.FindDeclaredPrimaryKey().Properties, p => { Assert.Equal("LeftsId", p.Name); @@ -1361,16 +1381,21 @@ public virtual void Can_override_table_name_for_many_to_many_join_table_stored_i { Assert.Equal("RightsId", p.Name); }); - Assert.Collection(joinEntity.GetDeclaredForeignKeys(), + Assert.Collection( + joinEntity.GetDeclaredForeignKeys(), fk => { - Assert.Equal("Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+ManyToManyLeft", fk.PrincipalEntityType.Name); - Assert.Collection(fk.PrincipalKey.Properties, + Assert.Equal( + "Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+ManyToManyLeft", + fk.PrincipalEntityType.Name); + Assert.Collection( + fk.PrincipalKey.Properties, p => { Assert.Equal("Id", p.Name); }); - Assert.Collection(fk.Properties, + Assert.Collection( + fk.Properties, p => { Assert.Equal("LeftsId", p.Name); @@ -1378,13 +1403,17 @@ public virtual void Can_override_table_name_for_many_to_many_join_table_stored_i }, fk => { - Assert.Equal("Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+ManyToManyRight", fk.PrincipalEntityType.Name); - Assert.Collection(fk.PrincipalKey.Properties, + Assert.Equal( + "Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+ManyToManyRight", + fk.PrincipalEntityType.Name); + Assert.Collection( + fk.PrincipalKey.Properties, p => { Assert.Equal("Id", p.Name); }); - Assert.Collection(fk.Properties, + Assert.Collection( + fk.Properties, p => { Assert.Equal("RightsId", p.Name); @@ -1948,7 +1977,8 @@ public virtual void Weak_owned_types_are_stored_in_snapshot() var orderBillingDetails = order.FindNavigation(nameof(Order.OrderBillingDetails)).TargetEntityType; Assert.Equal(1, orderBillingDetails.PropertyCount()); - var orderBillingDetailsAddress = orderBillingDetails.FindNavigation(nameof(OrderDetails.StreetAddress)).TargetEntityType; + var orderBillingDetailsAddress = + orderBillingDetails.FindNavigation(nameof(OrderDetails.StreetAddress)).TargetEntityType; Assert.Equal(2, orderBillingDetailsAddress.PropertyCount()); var orderShippingDetails = order.FindNavigation(nameof(Order.OrderShippingDetails)).TargetEntityType; @@ -1970,7 +2000,6 @@ public virtual void Snapshot_with_OwnedNavigationBuilder_HasCheckConstraint_comp .OwnsMany( o => o.OwnedEntities, ownee => ownee.HasCheckConstraint("CK_TestOwnee_TestEnum_Enum_Constraint", "[TestEnum] IN (0, 1, 2)")); - }, @"// using Microsoft.EntityFrameworkCore; @@ -2034,13 +2063,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) } } ", - model => - { - Assert.Equal(2, model.GetEntityTypes().Count()); - var testOwnee = model.FindEntityType( - "Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+TestOwnee"); - Assert.NotNull(testOwnee.FindCheckConstraint("CK_TestOwnee_TestEnum_Enum_Constraint")); - }); + model => + { + Assert.Equal(2, model.GetEntityTypes().Count()); + var testOwnee = model.FindEntityType( + "Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+TestOwnee"); + Assert.NotNull(testOwnee.FindCheckConstraint("CK_TestOwnee_TestEnum_Enum_Constraint")); + }); } private class Order @@ -2453,7 +2482,7 @@ public virtual void Property_default_value_annotation_is_stored_in_snapshot_as_f b.ToTable(""EntityWithTwoProperties""); });", - usingSystem: true), + usingSystem: true), o => Assert.Equal(DBNull.Value, o.GetEntityTypes().First().FindProperty("AlternateId")["Relational:DefaultValue"])); } @@ -3040,7 +3069,7 @@ public virtual void Index_database_name_annotation_is_stored_in_snapshot_as_flue { builder.Entity() .HasIndex(t => t.AlternateId) - .HasDatabaseName("IndexName"); + .HasDatabaseName("IndexName"); builder.Ignore(); }, AddBoilerPlate( @@ -3214,15 +3243,15 @@ public virtual void IndexAttribute_causes_column_to_have_key_or_index_column_len Assert.Collection( model.GetEntityTypes().First().GetIndexes().First().Properties, p0 => - { - Assert.Equal("FirstName", p0.Name); - Assert.Equal("nvarchar(450)", p0.GetColumnType()); - }, + { + Assert.Equal("FirstName", p0.Name); + Assert.Equal("nvarchar(450)", p0.GetColumnType()); + }, p1 => - { - Assert.Equal("LastName", p1.Name); - Assert.Equal("nvarchar(450)", p1.GetColumnType()); - } + { + Assert.Equal("LastName", p1.Name); + Assert.Equal("nvarchar(450)", p1.GetColumnType()); + } )); } @@ -3254,26 +3283,25 @@ public virtual void IndexAttribute_name_is_stored_in_snapshot() b.ToTable(""EntityWithNamedIndexAttribute""); });"), model => - { - var index = model.GetEntityTypes().First().GetIndexes().First(); - Assert.Equal("NamedIndex", index.Name); - Assert.Collection( - index.Properties, - p0 => - { - Assert.Equal("FirstName", p0.Name); - Assert.Equal("nvarchar(450)", p0.GetColumnType()); - }, - p1 => - { - Assert.Equal("LastName", p1.Name); - Assert.Equal("nvarchar(450)", p1.GetColumnType()); - } - ); - }); + { + var index = model.GetEntityTypes().First().GetIndexes().First(); + Assert.Equal("NamedIndex", index.Name); + Assert.Collection( + index.Properties, + p0 => + { + Assert.Equal("FirstName", p0.Name); + Assert.Equal("nvarchar(450)", p0.GetColumnType()); + }, + p1 => + { + Assert.Equal("LastName", p1.Name); + Assert.Equal("nvarchar(450)", p1.GetColumnType()); + } + ); + }); } - [ConditionalFact] public virtual void IndexAttribute_IsUnique_is_stored_in_snapshot() { @@ -4672,22 +4700,24 @@ protected override void BuildModel(ModelBuilder modelBuilder) #endregion - protected virtual string GetHeading(bool empty = false) => @" + protected virtual string GetHeading(bool empty = false) + => @" modelBuilder .UseIdentityColumns() .HasAnnotation(""Relational:MaxIdentifierLength"", 128);" - + (empty - ? null - : @" + + (empty + ? null + : @" "); - protected virtual ICollection GetReferences() => new List - { - BuildReference.ByName("Microsoft.EntityFrameworkCore"), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Relational"), - BuildReference.ByName("Microsoft.EntityFrameworkCore.SqlServer"), - BuildReference.ByName("NetTopologySuite") - }; + protected virtual ICollection GetReferences() + => new List + { + BuildReference.ByName("Microsoft.EntityFrameworkCore"), + BuildReference.ByName("Microsoft.EntityFrameworkCore.Relational"), + BuildReference.ByName("Microsoft.EntityFrameworkCore.SqlServer"), + BuildReference.ByName("NetTopologySuite") + }; protected virtual string AddBoilerPlate(string code, bool usingSystem = false) => $@"// @@ -4775,8 +4805,9 @@ protected IModel BuildModelFromSnapshotSource(string code) protected ModelBuilder CreateConventionalModelBuilder() { - var serviceProvider = SqlServerTestHelpers.Instance.CreateContextServices(new ServiceCollection() - .AddEntityFrameworkSqlServerNetTopologySuite()); + var serviceProvider = SqlServerTestHelpers.Instance.CreateContextServices( + new ServiceCollection() + .AddEntityFrameworkSqlServerNetTopologySuite()); return new ModelBuilder( serviceProvider.GetService().CreateConventionSet(), diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs index a4adfa6d485..d30134dd231 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpDbContextGeneratorTest.cs @@ -249,8 +249,7 @@ public void ModelInDifferentNamespaceDbContext_works() { var modelGenerationOptions = new ModelCodeGenerationOptions { - ContextNamespace = "TestNamespace", - ModelNamespace = "AnotherNamespaceOfModel" + ContextNamespace = "TestNamespace", ModelNamespace = "AnotherNamespaceOfModel" }; const string entityInAnotherNamespaceTypeName = "EntityInAnotherNamespace"; @@ -295,7 +294,9 @@ public void ValueGenerated_works() new ModelCodeGenerationOptions(), code => { - Assert.Contains(@$"Property(e => e.ValueGeneratedOnAdd){Environment.NewLine} .ValueGeneratedOnAdd()", code.ContextFile.Code); + Assert.Contains( + @$"Property(e => e.ValueGeneratedOnAdd){Environment.NewLine} .ValueGeneratedOnAdd()", + code.ContextFile.Code); Assert.Contains("Property(e => e.ValueGeneratedOnAddOrUpdate).ValueGeneratedOnAddOrUpdate()", code.ContextFile.Code); Assert.Contains("Property(e => e.ConcurrencyToken).IsConcurrencyToken()", code.ContextFile.Code); Assert.Contains("Property(e => e.ValueGeneratedOnUpdate).ValueGeneratedOnUpdate()", code.ContextFile.Code); @@ -371,7 +372,8 @@ public void ComputedColumnSql_works() public void ComputedColumnSql_works_stored() { Test( - modelBuilder => modelBuilder.Entity("Entity").Property("ComputedColumn").HasComputedColumnSql("1 + 2", stored: true), + modelBuilder => modelBuilder.Entity("Entity").Property("ComputedColumn") + .HasComputedColumnSql("1 + 2", stored: true), new ModelCodeGenerationOptions(), code => Assert.Contains(".HasComputedColumnSql(\"1 + 2\", true)", code.ContextFile.Code), model => @@ -592,22 +594,24 @@ public void Entity_lambda_uses_correct_identifiers() Test( modelBuilder => { - modelBuilder.Entity("PrincipalEntity", b => - { - b.Property("Id"); - b.Property("PrincipalId"); - b.Property("AlternateId"); - b.HasKey("AlternateId"); - }); - modelBuilder.Entity("DependentEntity", b => - { - b.Property("Id"); - b.Property("DependentId"); - b.HasOne("PrincipalEntity", "NavigationToPrincipal") - .WithOne("NavigationToDependent") - .HasForeignKey("DependentEntity", "DependentId") - .HasPrincipalKey("PrincipalEntity", "PrincipalId"); - }); + modelBuilder.Entity( + "PrincipalEntity", b => + { + b.Property("Id"); + b.Property("PrincipalId"); + b.Property("AlternateId"); + b.HasKey("AlternateId"); + }); + modelBuilder.Entity( + "DependentEntity", b => + { + b.Property("Id"); + b.Property("DependentId"); + b.HasOne("PrincipalEntity", "NavigationToPrincipal") + .WithOne("NavigationToDependent") + .HasForeignKey("DependentEntity", "DependentId") + .HasPrincipalKey("PrincipalEntity", "PrincipalId"); + }); }, new ModelCodeGenerationOptions { UseDataAnnotations = false }, code => @@ -678,7 +682,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) code.ContextFile); }, model => { }); - } + } 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 6c47f00144f..72ad7fb1783 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpEntityTypeGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpEntityTypeGeneratorTest.cs @@ -93,13 +93,14 @@ public void TableAttribute_is_generated_for_custom_name() Test( modelBuilder => { - modelBuilder.Entity("Vista", - b => - { - b.ToTable("Vistas"); // Default name is "Vista" in the absence of pluralizer - b.Property("Id"); - b.HasKey("Id"); - }); + modelBuilder.Entity( + "Vista", + b => + { + b.ToTable("Vistas"); // Default name is "Vista" in the absence of pluralizer + b.Property("Id"); + b.HasKey("Id"); + }); }, new ModelCodeGenerationOptions { UseDataAnnotations = true }, code => @@ -140,13 +141,14 @@ public void TableAttribute_is_not_generated_for_default_schema() modelBuilder => { modelBuilder.HasDefaultSchema("dbo"); - modelBuilder.Entity("Vista", - b => - { - b.ToTable("Vista", "dbo"); // Default name is "Vista" in the absence of pluralizer - b.Property("Id"); - b.HasKey("Id"); - }); + modelBuilder.Entity( + "Vista", + b => + { + b.ToTable("Vista", "dbo"); // Default name is "Vista" in the absence of pluralizer + b.Property("Id"); + b.HasKey("Id"); + }); }, new ModelCodeGenerationOptions { UseDataAnnotations = true }, code => @@ -186,13 +188,14 @@ public void TableAttribute_is_generated_for_non_default_schema() modelBuilder => { modelBuilder.HasDefaultSchema("dbo"); - modelBuilder.Entity("Vista", - b => - { - b.ToTable("Vista", "custom"); - b.Property("Id"); - b.HasKey("Id"); - }); + modelBuilder.Entity( + "Vista", + b => + { + b.ToTable("Vista", "custom"); + b.Property("Id"); + b.HasKey("Id"); + }); }, new ModelCodeGenerationOptions { UseDataAnnotations = true }, code => @@ -315,7 +318,8 @@ public partial class EntityWithIndexes { var entityType = model.FindEntityType("TestNamespace.EntityWithIndexes"); var indexes = entityType.GetIndexes(); - Assert.Collection(indexes, + Assert.Collection( + indexes, t => Assert.Null(t.Name), t => Assert.Equal("IndexOnAAndB", t.Name), t => Assert.Equal("IndexOnBAndC", t.Name)); @@ -1398,7 +1402,5 @@ public partial class Post Assert.Equal("OriginalPosts", originalInverseNavigation.Name); }); } - - } } diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpNamerTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpNamerTest.cs index 20dcdb974a4..8945433c58d 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpNamerTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpNamerTest.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.Design.Internal; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Scaffolding.Internal; using Xunit; diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpUniqueNamerTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpUniqueNamerTest.cs index 3aa970491f3..04b38b66a8c 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpUniqueNamerTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpUniqueNamerTest.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.Design.Internal; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Scaffolding.Internal; using Microsoft.EntityFrameworkCore.Scaffolding.Metadata; using Xunit; @@ -16,8 +15,18 @@ public void Returns_unique_name_for_type() { var namer = new CSharpUniqueNamer(s => s.Name, new CSharpUtilities(), null); var table = new DatabaseTable { Database = new DatabaseModel(), Name = "foo" }; - var input1 = new DatabaseColumn { Table = table, Name = "Id", StoreType = "int" }; - var input2 = new DatabaseColumn { Table = table, Name = "Id", StoreType = "int" }; + var input1 = new DatabaseColumn + { + Table = table, + Name = "Id", + StoreType = "int" + }; + var input2 = new DatabaseColumn + { + Table = table, + Name = "Id", + StoreType = "int" + }; Assert.Equal("Id", namer.GetName(input1)); Assert.Equal("Id", namer.GetName(input1)); diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs index 702b15e00ab..4f3daae5cd7 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs @@ -33,8 +33,14 @@ static RelationalDatabaseModelFactoryTest() { Database = new DatabaseModel(); Table = new DatabaseTable { Database = Database, Name = "Foo" }; - IdColumn = new DatabaseColumn { Table = Table, Name = "Id", StoreType = "int" }; - IdPrimaryKey = new DatabasePrimaryKey { + IdColumn = new DatabaseColumn + { + Table = Table, + Name = "Id", + StoreType = "int" + }; + IdPrimaryKey = new DatabasePrimaryKey + { Table = Table, Name = "IdPrimaryKey", Columns = { IdColumn } @@ -159,7 +165,8 @@ public void Loads_column_types() }, new DatabaseColumn { - Table = Table, Name = "salary", + Table = Table, + Name = "salary", StoreType = "int", IsNullable = true }, @@ -191,7 +198,8 @@ public void Loads_column_types() } }; - var entityType = (EntityType)_factory.Create(info, new ModelReverseEngineerOptions { NoPluralize = true }).FindEntityType("Jobs"); + var entityType = + (EntityType)_factory.Create(info, new ModelReverseEngineerOptions { NoPluralize = true }).FindEntityType("Jobs"); Assert.Collection( entityType.GetProperties(), @@ -247,9 +255,24 @@ public void Use_database_names_for_columns() Columns = { IdColumn, - new DatabaseColumn { Table = Table, Name = "ProductSKU" , StoreType = "nvarchar(max)" }, - new DatabaseColumn { Table = Table, Name = "supplierID" , StoreType = "nvarchar(max)" }, - new DatabaseColumn { Table = Table, Name = "Vendor_Discount" , StoreType = "nvarchar(max)" } + new DatabaseColumn + { + Table = Table, + Name = "ProductSKU", + StoreType = "nvarchar(max)" + }, + new DatabaseColumn + { + Table = Table, + Name = "supplierID", + StoreType = "nvarchar(max)" + }, + new DatabaseColumn + { + Table = Table, + Name = "Vendor_Discount", + StoreType = "nvarchar(max)" + } }, PrimaryKey = IdPrimaryKey } @@ -282,16 +305,32 @@ public void Do_not_use_database_names_for_columns() Columns = { IdColumn, - new DatabaseColumn { Table = Table, Name = "ProductSKU" , StoreType = "nvarchar(max)" }, - new DatabaseColumn { Table = Table, Name = "supplierID" , StoreType = "nvarchar(max)" }, - new DatabaseColumn { Table = Table, Name = "Vendor_Discount" , StoreType = "nvarchar(max)" } + new DatabaseColumn + { + Table = Table, + Name = "ProductSKU", + StoreType = "nvarchar(max)" + }, + new DatabaseColumn + { + Table = Table, + Name = "supplierID", + StoreType = "nvarchar(max)" + }, + new DatabaseColumn + { + Table = Table, + Name = "Vendor_Discount", + StoreType = "nvarchar(max)" + } }, PrimaryKey = IdPrimaryKey } } }; - var entityType = _factory.Create(info, new ModelReverseEngineerOptions { NoPluralize = true }).FindEntityType("NaturalProducts"); + var entityType = _factory.Create(info, new ModelReverseEngineerOptions { NoPluralize = true }) + .FindEntityType("NaturalProducts"); Assert.Collection( entityType.GetProperties(), @@ -307,7 +346,12 @@ 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 { Table = Table, Name = "Col", StoreType = storeType }; + var column = new DatabaseColumn + { + Table = Table, + Name = "Col", + StoreType = storeType + }; var info = new DatabaseModel { @@ -336,7 +380,12 @@ public void Column_type_annotation(string storeType, string expectedColumnType) [ConditionalFact] public void Column_ordinal_annotation() { - var col1 = new DatabaseColumn { Table = Table, Name = "Col1" , StoreType = "nvarchar(max)" }; + var col1 = new DatabaseColumn + { + Table = Table, + Name = "Col1", + StoreType = "nvarchar(max)" + }; var info = new DatabaseModel { Tables = @@ -348,8 +397,18 @@ public void Column_ordinal_annotation() Columns = { col1, - new DatabaseColumn { Table = Table, Name = "Col2" , StoreType = "nvarchar(max)" }, - new DatabaseColumn { Table = Table, Name = "Col3" , StoreType = "nvarchar(max)" } + new DatabaseColumn + { + Table = Table, + Name = "Col2", + StoreType = "nvarchar(max)" + }, + new DatabaseColumn + { + Table = Table, + Name = "Col3", + StoreType = "nvarchar(max)" + } }, PrimaryKey = new DatabasePrimaryKey { @@ -390,12 +449,13 @@ public void Unmappable_column_type(string StoreType) } }; - info.Tables.First().Columns.Add(new DatabaseColumn - { - Table = info.Tables.First(), - Name = "Coli", - StoreType = StoreType - }); + info.Tables.First().Columns.Add( + new DatabaseColumn + { + Table = info.Tables.First(), + Name = "Coli", + StoreType = StoreType + }); Assert.Single(_factory.Create(info, new ModelReverseEngineerOptions()).FindEntityType("E").GetProperties()); Assert.Single(_reporter.Messages, t => t.Contains(DesignStrings.CannotFindTypeMappingForColumn("E.Coli", StoreType))); @@ -420,12 +480,13 @@ public void Primary_key(string[] keyProps, int length) } } }; - foreach (var column in keyProps.Select(k => new DatabaseColumn - { - Table = Table, - Name = k, - StoreType = "int" - })) + foreach (var column in keyProps.Select( + k => new DatabaseColumn + { + Table = Table, + Name = k, + StoreType = "int" + })) { info.Tables[0].Columns.Add(column); info.Tables[0].PrimaryKey.Columns.Add(column); @@ -440,7 +501,12 @@ public void Primary_key(string[] keyProps, int length) [ConditionalFact] public void Unique_constraint() { - var myColumn = new DatabaseColumn { Table = Table, Name = "MyColumn" , StoreType = "int" }; + var myColumn = new DatabaseColumn + { + Table = Table, + Name = "MyColumn", + StoreType = "int" + }; var databaseModel = new DatabaseModel { @@ -476,7 +542,12 @@ public void Unique_constraint() [ConditionalFact] public void Indexes_and_alternate_keys() { - var c1 = new DatabaseColumn { Table = Table, Name = "C1" , StoreType = "int" }; + var c1 = new DatabaseColumn + { + Table = Table, + Name = "C1", + StoreType = "int" + }; var table = new DatabaseTable { Database = Database, @@ -484,8 +555,18 @@ public void Indexes_and_alternate_keys() Columns = { c1, - new DatabaseColumn { Table = Table, Name = "C2" , StoreType = "int" }, - new DatabaseColumn { Table = Table, Name = "C3" , StoreType = "int" } + new DatabaseColumn + { + Table = Table, + Name = "C2", + StoreType = "int" + }, + new DatabaseColumn + { + Table = Table, + Name = "C3", + StoreType = "int" + } }, PrimaryKey = new DatabasePrimaryKey { @@ -523,7 +604,8 @@ public void Indexes_and_alternate_keys() { Table = Table, 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 } }; @@ -621,7 +703,12 @@ public void Foreign_key_from_keyless_table() { var databaseModel = new DatabaseModel(); var masterTable = new DatabaseTable { Database = databaseModel, Name = "Master" }; - var idColumn = new DatabaseColumn { Table = masterTable, Name = "Id" , StoreType = "int" }; + var idColumn = new DatabaseColumn + { + Table = masterTable, + Name = "Id", + StoreType = "int" + }; masterTable.Columns.Add(idColumn); masterTable.PrimaryKey = new DatabasePrimaryKey { @@ -631,7 +718,12 @@ public void Foreign_key_from_keyless_table() }; databaseModel.Tables.Add(masterTable); var detailTable = new DatabaseTable { Database = databaseModel, Name = "Detail" }; - var masterIdColumn = new DatabaseColumn { Table = detailTable, Name = "MasterId" , StoreType = "int" }; + var masterIdColumn = new DatabaseColumn + { + Table = detailTable, + Name = "MasterId", + StoreType = "int" + }; detailTable.Columns.Add(masterIdColumn); detailTable.ForeignKeys.Add( new DatabaseForeignKey @@ -759,8 +851,18 @@ public void Unique_foreign_key() [ConditionalFact] public void Composite_foreign_key() { - var ida = new DatabaseColumn { Table = Table, Name = "Id_A" , StoreType = "int" }; - var idb = new DatabaseColumn { Table = Table, Name = "Id_B" , StoreType = "int" }; + var ida = new DatabaseColumn + { + Table = Table, + Name = "Id_A", + StoreType = "int" + }; + var idb = new DatabaseColumn + { + Table = Table, + Name = "Id_B", + StoreType = "int" + }; var parentTable = new DatabaseTable { Database = Database, @@ -780,8 +882,18 @@ public void Composite_foreign_key() Columns = { IdColumn, - new DatabaseColumn { Table = Table, Name = "ParentId_A" , StoreType = "int" }, - new DatabaseColumn { Table = Table, Name = "ParentId_B" , StoreType = "int" } + new DatabaseColumn + { + Table = Table, + Name = "ParentId_A", + StoreType = "int" + }, + new DatabaseColumn + { + Table = Table, + Name = "ParentId_B", + StoreType = "int" + } }, PrimaryKey = IdPrimaryKey }; @@ -867,14 +979,32 @@ public void It_logs_warning_for_bad_foreign_key() { Database = Database, Name = "Parent", - Columns = { IdColumn, new DatabaseColumn { Table = Table, Name = "NotPkId" , StoreType = "int" } }, + Columns = + { + IdColumn, + new DatabaseColumn + { + Table = Table, + Name = "NotPkId", + StoreType = "int" + } + }, PrimaryKey = IdPrimaryKey }; var childrenTable = new DatabaseTable { Database = Database, Name = "Children", - Columns = { IdColumn, new DatabaseColumn { Table = Table, Name = "ParentId" , StoreType = "int" } }, + Columns = + { + IdColumn, + new DatabaseColumn + { + Table = Table, + Name = "ParentId", + StoreType = "int" + } + }, PrimaryKey = IdPrimaryKey }; childrenTable.ForeignKeys.Add( @@ -1013,8 +1143,18 @@ public void Unique_nullable_index_used_by_foreign_key() [ConditionalFact] public void Unique_index_composite_foreign_key() { - var ida = new DatabaseColumn { Table = Table, Name = "Id_A" , StoreType = "int" }; - var idb = new DatabaseColumn { Table = Table, Name = "Id_B" , StoreType = "int" }; + var ida = new DatabaseColumn + { + Table = Table, + Name = "Id_A", + StoreType = "int" + }; + var idb = new DatabaseColumn + { + Table = Table, + Name = "Id_B", + StoreType = "int" + }; var parentTable = new DatabaseTable { Database = Database, @@ -1034,8 +1174,18 @@ public void Unique_index_composite_foreign_key() Columns = { IdColumn, - new DatabaseColumn { Table = Table, Name = "ParentId_A" , StoreType = "int" }, - new DatabaseColumn { Table = Table, Name = "ParentId_B" , StoreType = "int" } + new DatabaseColumn + { + Table = Table, + Name = "ParentId_A", + StoreType = "int" + }, + new DatabaseColumn + { + Table = Table, + Name = "ParentId_B", + StoreType = "int" + } }, PrimaryKey = IdPrimaryKey }; @@ -1044,7 +1194,8 @@ public void Unique_index_composite_foreign_key() { Table = Table, Name = "IX_Foo", - 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 @@ -1082,8 +1233,18 @@ public void Unique_names() Columns = { IdColumn, - new DatabaseColumn { Table = Table, Name = "San itized", StoreType = "int" }, - new DatabaseColumn { Table = Table, Name = "San+itized", StoreType = "int" } + new DatabaseColumn + { + Table = Table, + Name = "San itized", + StoreType = "int" + }, + new DatabaseColumn + { + Table = Table, + Name = "San+itized", + StoreType = "int" + } }, PrimaryKey = IdPrimaryKey }, @@ -1529,9 +1690,24 @@ public void Nullable_column_with_default_value_sql_does_not_generate_warning() [ConditionalFact] public void Correct_arguments_to_scaffolding_typemapper() { - var principalPkColumn = new DatabaseColumn { Table = Table, Name = "PrimaryKey", StoreType = "nvarchar(450)" }; - var principalAkColumn = new DatabaseColumn { Table = Table, Name = "AlternateKey", StoreType = "nvarchar(450)" }; - var principalIndexColumn = new DatabaseColumn { Table = Table, Name = "Index", StoreType = "nvarchar(450)" }; + var principalPkColumn = new DatabaseColumn + { + Table = Table, + Name = "PrimaryKey", + StoreType = "nvarchar(450)" + }; + var principalAkColumn = new DatabaseColumn + { + Table = Table, + Name = "AlternateKey", + StoreType = "nvarchar(450)" + }; + var principalIndexColumn = new DatabaseColumn + { + Table = Table, + Name = "Index", + StoreType = "nvarchar(450)" + }; var rowversionColumn = new DatabaseColumn { Table = Table, @@ -1552,21 +1728,65 @@ public void Correct_arguments_to_scaffolding_typemapper() principalIndexColumn, rowversionColumn }, - PrimaryKey = new DatabasePrimaryKey { Table = Table, Name = "PK_Foo", Columns = { principalPkColumn } }, - UniqueConstraints = { new DatabaseUniqueConstraint { Table = Table, Name = "AK_Foo", Columns = { principalAkColumn } } }, - Indexes = { new DatabaseIndex { Table = Table, Name = "IX_Foo", Columns = { principalIndexColumn } } } + PrimaryKey = new DatabasePrimaryKey + { + Table = Table, + Name = "PK_Foo", + Columns = { principalPkColumn } + }, + UniqueConstraints = + { + new DatabaseUniqueConstraint + { + Table = Table, + Name = "AK_Foo", + Columns = { principalAkColumn } + } + }, + Indexes = + { + new DatabaseIndex + { + Table = Table, + Name = "IX_Foo", + Columns = { principalIndexColumn } + } + } }; - var dependentIdColumn = new DatabaseColumn { Table = Table, Name = "Id" , StoreType = "int" }; - var dependentFkColumn = new DatabaseColumn { Table = Table, Name = "BlogAlternateKey" , StoreType = "nvarchar(450)" }; + var dependentIdColumn = new DatabaseColumn + { + Table = Table, + Name = "Id", + StoreType = "int" + }; + var dependentFkColumn = new DatabaseColumn + { + Table = Table, + Name = "BlogAlternateKey", + StoreType = "nvarchar(450)" + }; var dependentTable = new DatabaseTable { Database = Database, Name = "Dependent", Columns = { dependentIdColumn, dependentFkColumn }, - PrimaryKey = new DatabasePrimaryKey { Table = Table, Name = "PK_Foo", Columns = { dependentIdColumn } }, - Indexes = { new DatabaseIndex { Table = Table, Name = "IX_Foo", Columns = { dependentFkColumn } } }, + PrimaryKey = new DatabasePrimaryKey + { + Table = Table, + Name = "PK_Foo", + Columns = { dependentIdColumn } + }, + Indexes = + { + new DatabaseIndex + { + Table = Table, + Name = "IX_Foo", + Columns = { dependentFkColumn } + } + }, ForeignKeys = { new DatabaseForeignKey @@ -1594,7 +1814,12 @@ public void Correct_arguments_to_scaffolding_typemapper() [ConditionalFact] public void Unmapped_column_is_ignored() { - var columnWithUnknownType = new DatabaseColumn { Table = Table, Name = "ColumnWithUnknownStoreType" , StoreType = "unknown_type" }; + var columnWithUnknownType = new DatabaseColumn + { + Table = Table, + Name = "ColumnWithUnknownStoreType", + StoreType = "unknown_type" + }; var dbModel = new DatabaseModel { @@ -1676,39 +1901,18 @@ public void UseDatabaseNames_and_NoPluralize_work_together( new DatabaseTable { Name = userTableName, - Columns = - { - new DatabaseColumn - { - Name = "id", - StoreType = "int" - } - }, - PrimaryKey = new DatabasePrimaryKey - { - Columns = { new DatabaseColumnRef("id") } - } + Columns = { new DatabaseColumn { Name = "id", StoreType = "int" } }, + PrimaryKey = new DatabasePrimaryKey { Columns = { new DatabaseColumnRef("id") } } }, new DatabaseTable { Name = postTableName, Columns = { - new DatabaseColumn - { - Name = "id", - StoreType = "int" - }, - new DatabaseColumn - { - Name = "author_id", - StoreType = "int" - } - }, - PrimaryKey = new DatabasePrimaryKey - { - Columns = { new DatabaseColumnRef("id") } + new DatabaseColumn { Name = "id", StoreType = "int" }, + new DatabaseColumn { Name = "author_id", StoreType = "int" } }, + PrimaryKey = new DatabasePrimaryKey { Columns = { new DatabaseColumnRef("id") } }, ForeignKeys = { new DatabaseForeignKey diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineerScaffolderTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineerScaffolderTest.cs index 8be6ae1f49c..73d04cde77b 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineerScaffolderTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineerScaffolderTest.cs @@ -27,15 +27,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( @@ -67,10 +60,7 @@ public void Save_throws_when_existing_files() var scaffoldedModel = new ScaffoldedModel { ContextFile = new ScaffoldedFile { Path = "TestContext.cs", Code = "// TestContext" }, - AdditionalFiles = - { - new ScaffoldedFile { Path = "TestEntity.cs", Code = "// TestEntity" } - } + AdditionalFiles = { new ScaffoldedFile { Path = "TestEntity.cs", Code = "// TestEntity" } } }; var ex = Assert.Throws( @@ -91,10 +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); @@ -172,10 +159,7 @@ public void ScaffoldModel_works_with_named_connection_string() "Name=DefaultConnection", new DatabaseModelFactoryOptions(), new ModelReverseEngineerOptions(), - new ModelCodeGenerationOptions - { - ModelNamespace = "Foo" - }); + new ModelCodeGenerationOptions { ModelNamespace = "Foo" }); Assert.Equal("Data Source=Test", databaseModelFactory.ConnectionString); @@ -205,10 +189,7 @@ public void ScaffoldModel_works_with_overridden_connection_string() "Name=DefaultConnection", new DatabaseModelFactoryOptions(), new ModelReverseEngineerOptions(), - new ModelCodeGenerationOptions - { - ModelNamespace = "Foo" - }); + new ModelCodeGenerationOptions { ModelNamespace = "Foo" }); Assert.Contains("Data Source=ScaffoldedConnectionString", result.ContextFile.Code); Assert.DoesNotContain("Name=DefaultConnection", result.ContextFile.Code); diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs index e6266371a2c..e3ca87a292e 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/ScaffoldingTypeMapperSqlServerTest.cs @@ -41,7 +41,8 @@ public void Maps_default_decimal_column(bool isKeyOrIndex) { var mapping = CreateMapper().FindMapping("decimal(18,2)", isKeyOrIndex, rowVersion: false); - AssertMapping(mapping, inferred: true, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: true, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } [ConditionalTheory] @@ -61,7 +62,8 @@ public void Maps_numeric_column(bool isKeyOrIndex) { var mapping = CreateMapper().FindMapping("numeric(17,4)", isKeyOrIndex, rowVersion: false); - AssertMapping(mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } [ConditionalTheory] @@ -81,7 +83,8 @@ public void Maps_datetime_column(bool isKeyOrIndex) { var mapping = CreateMapper().FindMapping("datetime", isKeyOrIndex, rowVersion: false); - AssertMapping(mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } [ConditionalTheory] @@ -91,7 +94,8 @@ public void Maps_datetime2_column(bool isKeyOrIndex) { var mapping = CreateMapper().FindMapping("datetime2", isKeyOrIndex, rowVersion: false); - AssertMapping(mapping, inferred: true, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: true, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } [ConditionalFact] @@ -123,7 +127,8 @@ public void Maps_key_varbinary_max_column() { var mapping = CreateMapper().FindMapping("varbinary(max)", keyOrIndex: true, rowVersion: false); - AssertMapping(mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } [ConditionalFact] @@ -171,7 +176,8 @@ public void Maps_rowversion_varbinary_max_column() { var mapping = CreateMapper().FindMapping("varbinary(max)", keyOrIndex: false, rowVersion: true); - AssertMapping(mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } [ConditionalFact] @@ -179,7 +185,8 @@ public void Maps_rowversion_varbinary_sized_column() { var mapping = CreateMapper().FindMapping("varbinary(200)", keyOrIndex: false, rowVersion: true); - AssertMapping(mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } [ConditionalFact] @@ -187,7 +194,8 @@ public void Maps_rowversion_varbinary_default_sized_column() { var mapping = CreateMapper().FindMapping("varbinary(8)", keyOrIndex: false, rowVersion: true); - AssertMapping(mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } [ConditionalFact] @@ -195,7 +203,8 @@ public void Maps_rowversion_binary_max_column() { var mapping = CreateMapper().FindMapping("binary(max)", keyOrIndex: false, rowVersion: true); - AssertMapping(mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } [ConditionalFact] @@ -203,7 +212,8 @@ public void Maps_rowversion_binary_sized_column() { var mapping = CreateMapper().FindMapping("binary(200)", keyOrIndex: false, rowVersion: true); - AssertMapping(mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } [ConditionalFact] @@ -211,7 +221,8 @@ public void Maps_rowversion_binary_default_sized_column() { var mapping = CreateMapper().FindMapping("binary(8)", keyOrIndex: false, rowVersion: true); - AssertMapping(mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } [ConditionalFact] @@ -235,7 +246,8 @@ public void Maps_normal_varchar_max_column() { var mapping = CreateMapper().FindMapping("varchar(max)", keyOrIndex: false, rowVersion: false); - AssertMapping(mapping, inferred: true, maxLength: null, unicode: false, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: true, maxLength: null, unicode: false, fixedLength: null, precision: null, scale: null); } [ConditionalFact] @@ -251,7 +263,8 @@ public void Maps_key_nvarchar_max_column() { var mapping = CreateMapper().FindMapping("nvarchar(max)", keyOrIndex: true, rowVersion: false); - AssertMapping(mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } [ConditionalFact] @@ -267,7 +280,8 @@ public void Maps_key_varchar_max_column() { var mapping = CreateMapper().FindMapping("varchar(max)", keyOrIndex: true, rowVersion: false); - AssertMapping(mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } [ConditionalFact] @@ -291,7 +305,8 @@ public void Maps_key_varchar_default_sized_column() { var mapping = CreateMapper().FindMapping("varchar(900)", keyOrIndex: true, rowVersion: false); - AssertMapping(mapping, inferred: true, maxLength: null, unicode: false, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: true, maxLength: null, unicode: false, fixedLength: null, precision: null, scale: null); } [ConditionalFact] @@ -315,7 +330,8 @@ public void Maps_key_nchar_max_column() { var mapping = CreateMapper().FindMapping("nchar(max)", keyOrIndex: true, rowVersion: false); - AssertMapping(mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } [ConditionalFact] @@ -331,7 +347,8 @@ public void Maps_key_char_max_column() { var mapping = CreateMapper().FindMapping("char(max)", keyOrIndex: true, rowVersion: false); - AssertMapping(mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } [ConditionalFact] @@ -355,7 +372,8 @@ public void Maps_key_char_default_sized_column() { var mapping = CreateMapper().FindMapping("char(900)", keyOrIndex: true, rowVersion: false); - AssertMapping(mapping, inferred: true, maxLength: null, unicode: false, fixedLength: true, precision: null, scale: null); + AssertMapping( + mapping, inferred: true, maxLength: null, unicode: false, fixedLength: true, precision: null, scale: null); } [ConditionalFact] @@ -363,12 +381,18 @@ public void Maps_text_column() { var mapping = CreateMapper().FindMapping("text", keyOrIndex: true, rowVersion: false); - AssertMapping(mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); + AssertMapping( + mapping, inferred: false, maxLength: null, unicode: null, fixedLength: null, precision: null, scale: null); } private static void AssertMapping( - TypeScaffoldingInfo mapping, bool inferred, int? maxLength, - bool? unicode, bool? fixedLength, int? precision, int? scale) + TypeScaffoldingInfo mapping, + bool inferred, + int? maxLength, + bool? unicode, + bool? fixedLength, + int? precision, + int? scale) { Assert.Same(typeof(T), mapping.ClrType); Assert.Equal(inferred, mapping.IsInferred); diff --git a/test/EFCore.Design.Tests/TestUtilities/DatabaseColumnRef.cs b/test/EFCore.Design.Tests/TestUtilities/DatabaseColumnRef.cs index 391a79ee73a..9a6651dfa42 100644 --- a/test/EFCore.Design.Tests/TestUtilities/DatabaseColumnRef.cs +++ b/test/EFCore.Design.Tests/TestUtilities/DatabaseColumnRef.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { - class DatabaseColumnRef : DatabaseColumn + internal class DatabaseColumnRef : DatabaseColumn { public DatabaseColumnRef(string name) { diff --git a/test/EFCore.Design.Tests/TestUtilities/DatabaseTableRef.cs b/test/EFCore.Design.Tests/TestUtilities/DatabaseTableRef.cs index 384e8452d4e..40a6a17cbb0 100644 --- a/test/EFCore.Design.Tests/TestUtilities/DatabaseTableRef.cs +++ b/test/EFCore.Design.Tests/TestUtilities/DatabaseTableRef.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { - class DatabaseTableRef : DatabaseTable + internal class DatabaseTableRef : DatabaseTable { public DatabaseTableRef(string name, string schema = null) { @@ -34,15 +34,15 @@ public override DatabasePrimaryKey PrimaryKey } public override IList Columns - => throw new NotImplementedException(); + => throw new NotImplementedException(); public override IList UniqueConstraints - => throw new NotImplementedException(); + => throw new NotImplementedException(); public override IList Indexes - => throw new NotImplementedException(); + => throw new NotImplementedException(); public override IList ForeignKeys - => throw new NotImplementedException(); + => throw new NotImplementedException(); } } diff --git a/test/EFCore.Design.Tests/TestUtilities/TestDatabaseOperations.cs b/test/EFCore.Design.Tests/TestUtilities/TestDatabaseOperations.cs index 1a227d0b7e9..e5bae4356f7 100644 --- a/test/EFCore.Design.Tests/TestUtilities/TestDatabaseOperations.cs +++ b/test/EFCore.Design.Tests/TestUtilities/TestDatabaseOperations.cs @@ -16,7 +16,7 @@ public TestDatabaseOperations( string rootNamespace, string language, string[] args) - : base(reporter, assembly, startupAssembly, projectDir,rootNamespace, language, args) + : base(reporter, assembly, startupAssembly, projectDir, rootNamespace, language, args) { } } diff --git a/test/EFCore.Design.Tests/TestUtilities/TestMigrationsOperations.cs b/test/EFCore.Design.Tests/TestUtilities/TestMigrationsOperations.cs index 16724cf96af..7bd18a945f4 100644 --- a/test/EFCore.Design.Tests/TestUtilities/TestMigrationsOperations.cs +++ b/test/EFCore.Design.Tests/TestUtilities/TestMigrationsOperations.cs @@ -16,7 +16,7 @@ public TestMigrationsOperations( string rootNamespace, string language, string[] args) - : base(reporter, assembly, startupAssembly, projectDir,rootNamespace, language, args) + : base(reporter, assembly, startupAssembly, projectDir, rootNamespace, language, args) { } } diff --git a/test/EFCore.Design.Tests/TestUtilities/TestOperationReporter.cs b/test/EFCore.Design.Tests/TestUtilities/TestOperationReporter.cs index fd3fe84c87a..7e3030d6ca2 100644 --- a/test/EFCore.Design.Tests/TestUtilities/TestOperationReporter.cs +++ b/test/EFCore.Design.Tests/TestUtilities/TestOperationReporter.cs @@ -10,9 +10,11 @@ public class TestOperationReporter : IOperationReporter { private readonly List _messages = new List(); - public IReadOnlyList Messages => _messages; + public IReadOnlyList Messages + => _messages; - public void Clear() => _messages.Clear(); + public void Clear() + => _messages.Clear(); public void WriteInformation(string message) => _messages.Add("info: " + message); diff --git a/test/EFCore.InMemory.FunctionalTests/BuiltInDataTypesInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/BuiltInDataTypesInMemoryTest.cs index 507e60ef174..c738866df75 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 Xunit; // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore @@ -21,21 +20,29 @@ public override void Optional_datetime_reading_null_from_database() public class BuiltInDataTypesInMemoryFixture : BuiltInDataTypesFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; - public override bool StrictEquality => true; + public override bool StrictEquality + => true; - public override bool SupportsAnsi => false; + public override bool SupportsAnsi + => false; - public override bool SupportsUnicodeToAnsiConversion => true; + public override bool SupportsUnicodeToAnsiConversion + => true; - public override bool SupportsLargeStringComparisons => true; + public override bool SupportsLargeStringComparisons + => true; - public override bool SupportsBinaryKeys => false; + public override bool SupportsBinaryKeys + => false; - public override bool SupportsDecimalComparisons => true; + public override bool SupportsDecimalComparisons + => true; - public override DateTime DefaultDateTime => new DateTime(); + public override DateTime DefaultDateTime + => new DateTime(); } } } diff --git a/test/EFCore.InMemory.FunctionalTests/CompositeKeyEndToEndInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/CompositeKeyEndToEndInMemoryTest.cs index 9457dfbc598..122e01c5727 100644 --- a/test/EFCore.InMemory.FunctionalTests/CompositeKeyEndToEndInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/CompositeKeyEndToEndInMemoryTest.cs @@ -15,7 +15,8 @@ public CompositeKeyEndToEndInMemoryTest(CompositeKeyEndToEndInMemoryFixture fixt public class CompositeKeyEndToEndInMemoryFixture : CompositeKeyEndToEndFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } } diff --git a/test/EFCore.InMemory.FunctionalTests/ConvertToProviderTypesInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/ConvertToProviderTypesInMemoryTest.cs index 308fedcb21f..edaf820f597 100644 --- a/test/EFCore.InMemory.FunctionalTests/ConvertToProviderTypesInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ConvertToProviderTypesInMemoryTest.cs @@ -3,7 +3,6 @@ using System; using Microsoft.EntityFrameworkCore.TestUtilities; -using Xunit; namespace Microsoft.EntityFrameworkCore { @@ -21,21 +20,29 @@ public override void Optional_datetime_reading_null_from_database() public class ConvertToProviderTypesInMemoryFixture : ConvertToProviderTypesFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; - public override bool StrictEquality => true; + public override bool StrictEquality + => true; - public override bool SupportsAnsi => false; + public override bool SupportsAnsi + => false; - public override bool SupportsUnicodeToAnsiConversion => true; + public override bool SupportsUnicodeToAnsiConversion + => true; - public override bool SupportsLargeStringComparisons => true; + public override bool SupportsLargeStringComparisons + => true; - public override bool SupportsBinaryKeys => false; + public override bool SupportsBinaryKeys + => false; - public override bool SupportsDecimalComparisons => true; + public override bool SupportsDecimalComparisons + => true; - public override DateTime DefaultDateTime => new DateTime(); + public override DateTime DefaultDateTime + => new DateTime(); } } } diff --git a/test/EFCore.InMemory.FunctionalTests/CustomConvertersInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/CustomConvertersInMemoryTest.cs index b207c7a6f18..8716f9d11b1 100644 --- a/test/EFCore.InMemory.FunctionalTests/CustomConvertersInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/CustomConvertersInMemoryTest.cs @@ -48,21 +48,29 @@ public override void Collection_enum_as_string_Contains() public class CustomConvertersInMemoryFixture : CustomConvertersFixtureBase { - public override bool StrictEquality => true; + public override bool StrictEquality + => true; - public override bool SupportsAnsi => false; + public override bool SupportsAnsi + => false; - public override bool SupportsUnicodeToAnsiConversion => true; + public override bool SupportsUnicodeToAnsiConversion + => true; - public override bool SupportsLargeStringComparisons => true; + public override bool SupportsLargeStringComparisons + => true; - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; - public override bool SupportsBinaryKeys => false; + public override bool SupportsBinaryKeys + => false; - public override bool SupportsDecimalComparisons => true; + public override bool SupportsDecimalComparisons + => true; - public override DateTime DefaultDateTime => new DateTime(); + public override DateTime DefaultDateTime + => new DateTime(); } } } diff --git a/test/EFCore.InMemory.FunctionalTests/CustomValueGeneratorTest.cs b/test/EFCore.InMemory.FunctionalTests/CustomValueGeneratorTest.cs index 78723dd6460..909e712987b 100644 --- a/test/EFCore.InMemory.FunctionalTests/CustomValueGeneratorTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/CustomValueGeneratorTest.cs @@ -235,7 +235,8 @@ private class CustomGuidValueGenerator : ValueGenerator public override Guid Next(EntityEntry entry) => SpecialGuids[Interlocked.Increment(ref _counter)]; - public override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; } private class SomeEntityStringValueGenerator : ValueGenerator @@ -245,7 +246,8 @@ private class SomeEntityStringValueGenerator : ValueGenerator public override string Next(EntityEntry entry) => ((SomeEntity)entry.Entity).Name + " - " + Interlocked.Increment(ref _counter); - public override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; } private class CustomValueGeneratorFactory : ValueGeneratorFactory diff --git a/test/EFCore.InMemory.FunctionalTests/DataAnnotationInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/DataAnnotationInMemoryTest.cs index b20f2126286..51a3a956e24 100644 --- a/test/EFCore.InMemory.FunctionalTests/DataAnnotationInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/DataAnnotationInMemoryTest.cs @@ -55,7 +55,9 @@ public override void TimestampAttribute_throws_if_value_in_database_changed() public class DataAnnotationInMemoryFixture : DataAnnotationFixtureBase { public static readonly string DatabaseName = "DataAnnotations"; - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder).ConfigureWarnings(w => w.Ignore(InMemoryEventId.TransactionIgnoredWarning)); diff --git a/test/EFCore.InMemory.FunctionalTests/DatabaseErrorLogStateTest.cs b/test/EFCore.InMemory.FunctionalTests/DatabaseErrorLogStateTest.cs index ca60ef5cc91..f8f69c2dd3c 100644 --- a/test/EFCore.InMemory.FunctionalTests/DatabaseErrorLogStateTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/DatabaseErrorLogStateTest.cs @@ -173,7 +173,8 @@ public void AddProvider(ILoggerProvider provider) { } - public ILogger CreateLogger(string name) => Logger; + public ILogger CreateLogger(string name) + => Logger; public void Dispose() { @@ -181,7 +182,8 @@ public void Dispose() public class TestLogger : ILogger { - public IDisposable BeginScope(TState state) => NullScope.Instance; + public IDisposable BeginScope(TState state) + => NullScope.Instance; public void Log( LogLevel logLevel, @@ -199,7 +201,8 @@ public void Log( } } - public bool IsEnabled(LogLevel logLevel) => true; + public bool IsEnabled(LogLevel logLevel) + => true; public IReadOnlyList> LastDatabaseErrorState { get; private set; } public Exception LastDatabaseErrorException { get; private set; } diff --git a/test/EFCore.InMemory.FunctionalTests/EndToEndTest.cs b/test/EFCore.InMemory.FunctionalTests/EndToEndTest.cs index 47c2c978e52..c3718e0677c 100644 --- a/test/EFCore.InMemory.FunctionalTests/EndToEndTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/EndToEndTest.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; -using Microsoft.EntityFrameworkCore.InMemory.Metadata.Conventions; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; @@ -12,7 +11,8 @@ namespace Microsoft.EntityFrameworkCore { public class EndToEndInMemoryTest : IClassFixture { - public EndToEndInMemoryTest(InMemoryFixture fixture) => Fixture = fixture; + public EndToEndInMemoryTest(InMemoryFixture fixture) + => Fixture = fixture; protected InMemoryFixture Fixture { get; } diff --git a/test/EFCore.InMemory.FunctionalTests/F1InMemoryFixture.cs b/test/EFCore.InMemory.FunctionalTests/F1InMemoryFixture.cs index c45902ab2f1..2f7ab6982fb 100644 --- a/test/EFCore.InMemory.FunctionalTests/F1InMemoryFixture.cs +++ b/test/EFCore.InMemory.FunctionalTests/F1InMemoryFixture.cs @@ -7,8 +7,10 @@ namespace Microsoft.EntityFrameworkCore { public class F1InMemoryFixture : F1FixtureBase { - public override TestHelpers TestHelpers => InMemoryTestHelpers.Instance; + public override TestHelpers TestHelpers + => InMemoryTestHelpers.Instance; - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } diff --git a/test/EFCore.InMemory.FunctionalTests/FieldMappingInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/FieldMappingInMemoryTest.cs index 52f4a5e859b..271703f5952 100644 --- a/test/EFCore.InMemory.FunctionalTests/FieldMappingInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/FieldMappingInMemoryTest.cs @@ -22,7 +22,8 @@ protected override void Update(string navigation) public class FieldMappingInMemoryFixture : FieldMappingFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder).ConfigureWarnings(w => w.Log(InMemoryEventId.TransactionIgnoredWarning)); diff --git a/test/EFCore.InMemory.FunctionalTests/FindInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/FindInMemoryTest.cs index 2cbc44779f4..0573966a45a 100644 --- a/test/EFCore.InMemory.FunctionalTests/FindInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/FindInMemoryTest.cs @@ -57,7 +57,8 @@ protected override async ValueTask FindAsync(DbContext context public class FindInMemoryFixture : FindFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } } diff --git a/test/EFCore.InMemory.FunctionalTests/GraphUpdates/GraphUpdatesInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/GraphUpdates/GraphUpdatesInMemoryTest.cs index f8447a670e7..f78a9b8778b 100644 --- a/test/EFCore.InMemory.FunctionalTests/GraphUpdates/GraphUpdatesInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/GraphUpdates/GraphUpdatesInMemoryTest.cs @@ -165,7 +165,8 @@ public class InMemoryFixture : GraphUpdatesFixtureBase { protected override string StoreName { get; } = "GraphUpdatesTest"; - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder).ConfigureWarnings(w => w.Log(InMemoryEventId.TransactionIgnoredWarning)); diff --git a/test/EFCore.InMemory.FunctionalTests/GraphUpdates/ProxyGraphUpdatesInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/GraphUpdates/ProxyGraphUpdatesInMemoryTest.cs index 883ef9a2005..b093ec4a8be 100644 --- a/test/EFCore.InMemory.FunctionalTests/GraphUpdates/ProxyGraphUpdatesInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/GraphUpdates/ProxyGraphUpdatesInMemoryTest.cs @@ -107,7 +107,8 @@ protected override void ExecuteWithStrategyInTransaction( public abstract class ProxyGraphUpdatesInMemoryFixtureBase : ProxyGraphUpdatesFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder.ConfigureWarnings(w => w.Ignore(InMemoryEventId.TransactionIgnoredWarning))); @@ -121,8 +122,11 @@ public LazyLoading(ProxyGraphUpdatesWithLazyLoadingInMemoryFixture fixture) { } - protected override bool DoesLazyLoading => true; - protected override bool DoesChangeTracking => false; + protected override bool DoesLazyLoading + => true; + + protected override bool DoesChangeTracking + => false; public class ProxyGraphUpdatesWithLazyLoadingInMemoryFixture : ProxyGraphUpdatesInMemoryFixtureBase { @@ -143,8 +147,11 @@ public ChangeTracking(ProxyGraphUpdatesWithChangeTrackingInMemoryFixture fixture { } - protected override bool DoesLazyLoading => false; - protected override bool DoesChangeTracking => true; + protected override bool DoesLazyLoading + => false; + + protected override bool DoesChangeTracking + => true; public class ProxyGraphUpdatesWithChangeTrackingInMemoryFixture : ProxyGraphUpdatesInMemoryFixtureBase { @@ -158,15 +165,19 @@ protected override IServiceCollection AddServices(IServiceCollection serviceColl } } - public class LazyLoadingAndChangeTracking : ProxyGraphUpdatesInMemoryTestBase + public class LazyLoadingAndChangeTracking : ProxyGraphUpdatesInMemoryTestBase< + LazyLoadingAndChangeTracking.ProxyGraphUpdatesWithChangeTrackingInMemoryFixture> { public LazyLoadingAndChangeTracking(ProxyGraphUpdatesWithChangeTrackingInMemoryFixture fixture) : base(fixture) { } - protected override bool DoesLazyLoading => true; - protected override bool DoesChangeTracking => true; + protected override bool DoesLazyLoading + => true; + + protected override bool DoesChangeTracking + => true; public class ProxyGraphUpdatesWithChangeTrackingInMemoryFixture : ProxyGraphUpdatesInMemoryFixtureBase { diff --git a/test/EFCore.InMemory.FunctionalTests/IntegerValueGeneratorTest.cs b/test/EFCore.InMemory.FunctionalTests/IntegerValueGeneratorTest.cs index f0acdd06a30..b023642fd8e 100644 --- a/test/EFCore.InMemory.FunctionalTests/IntegerValueGeneratorTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/IntegerValueGeneratorTest.cs @@ -439,15 +439,15 @@ private class Cat public int Id { get; set; } } - private class Mac: Cat + private class Mac : Cat { } - private class Smokey: Cat + private class Smokey : Cat { } - private class Alice: Cat + private class Alice : Cat { } } diff --git a/test/EFCore.InMemory.FunctionalTests/InterceptionInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/InterceptionInMemoryTest.cs index 59932446217..4a931e31e05 100644 --- a/test/EFCore.InMemory.FunctionalTests/InterceptionInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/InterceptionInMemoryTest.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; using Xunit; -using Xunit.Sdk; namespace Microsoft.EntityFrameworkCore { @@ -17,13 +16,16 @@ protected SaveChangesInterceptionInMemoryTestBase(InterceptionInMemoryFixtureBas { } - protected override bool SupportsOptimisticConcurrency => false; + protected override bool SupportsOptimisticConcurrency + => false; public abstract class InterceptionInMemoryFixtureBase : InterceptionFixtureBase { - protected override string StoreName => "SaveChangesInterception"; + protected override string StoreName + => "SaveChangesInterception"; - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; protected override IServiceCollection InjectInterceptors( IServiceCollection serviceCollection, @@ -44,7 +46,8 @@ public SaveChangesInterceptionInMemoryTest(InterceptionInMemoryFixture fixture) public class InterceptionInMemoryFixture : InterceptionInMemoryFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => false; + protected override bool ShouldSubscribeToDiagnosticListener + => false; } } @@ -59,7 +62,8 @@ public SaveChangesInterceptionWithDiagnosticsInMemoryTest(InterceptionInMemoryFi public class InterceptionInMemoryFixture : InterceptionInMemoryFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => true; + protected override bool ShouldSubscribeToDiagnosticListener + => true; } } } diff --git a/test/EFCore.InMemory.FunctionalTests/KeysWithConvertersInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/KeysWithConvertersInMemoryTest.cs index bb8a844add2..622ad311717 100644 --- a/test/EFCore.InMemory.FunctionalTests/KeysWithConvertersInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/KeysWithConvertersInMemoryTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore { - public class KeysWithConvertersInMemoryTest : KeysWithConvertersTestBase + public class KeysWithConvertersInMemoryTest : KeysWithConvertersTestBase< + KeysWithConvertersInMemoryTest.KeysWithConvertersInMemoryFixture> { public KeysWithConvertersInMemoryTest(KeysWithConvertersInMemoryFixture fixture) : base(fixture) diff --git a/test/EFCore.InMemory.FunctionalTests/LazyLoadProxyInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/LazyLoadProxyInMemoryTest.cs index 0093e711ee5..05b6863aa77 100644 --- a/test/EFCore.InMemory.FunctionalTests/LazyLoadProxyInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/LazyLoadProxyInMemoryTest.cs @@ -14,7 +14,8 @@ public LazyLoadProxyInMemoryTest(LoadInMemoryFixture fixture) public class LoadInMemoryFixture : LoadFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } } diff --git a/test/EFCore.InMemory.FunctionalTests/LoadInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/LoadInMemoryTest.cs index 00b9aaca5b0..faad1c0967a 100644 --- a/test/EFCore.InMemory.FunctionalTests/LoadInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/LoadInMemoryTest.cs @@ -14,7 +14,8 @@ public LoadInMemoryTest(LoadInMemoryFixture fixture) public class LoadInMemoryFixture : LoadFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } } diff --git a/test/EFCore.InMemory.FunctionalTests/LoggingInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/LoggingInMemoryTest.cs index 45bae7d140e..bda35d5280b 100644 --- a/test/EFCore.InMemory.FunctionalTests/LoggingInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/LoggingInMemoryTest.cs @@ -12,8 +12,10 @@ protected override DbContextOptionsBuilder CreateOptionsBuilder(IServiceCollecti .UseInMemoryDatabase("LoggingInMemoryTest") .UseInternalServiceProvider(services.AddEntityFrameworkInMemoryDatabase().BuildServiceProvider()); - protected override string ProviderName => "Microsoft.EntityFrameworkCore.InMemory"; + protected override string ProviderName + => "Microsoft.EntityFrameworkCore.InMemory"; - protected override string DefaultOptions => "StoreName=LoggingInMemoryTest "; + protected override string DefaultOptions + => "StoreName=LoggingInMemoryTest "; } } diff --git a/test/EFCore.InMemory.FunctionalTests/ManyToManyLoadInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/ManyToManyLoadInMemoryTest.cs index a4163e47389..6fc99554701 100644 --- a/test/EFCore.InMemory.FunctionalTests/ManyToManyLoadInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ManyToManyLoadInMemoryTest.cs @@ -14,7 +14,8 @@ public ManyToManyLoadInMemoryTest(ManyToManyLoadInMemoryFixture fixture) public class ManyToManyLoadInMemoryFixture : ManyToManyLoadFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } } diff --git a/test/EFCore.InMemory.FunctionalTests/ManyToManyTrackingInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/ManyToManyTrackingInMemoryTest.cs index eed666434aa..cf72a45a197 100644 --- a/test/EFCore.InMemory.FunctionalTests/ManyToManyTrackingInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/ManyToManyTrackingInMemoryTest.cs @@ -26,11 +26,13 @@ protected override void ExecuteWithStrategyInTransaction( Fixture.Reseed(); } - protected override bool SupportsDatabaseDefaults => false; + protected override bool SupportsDatabaseDefaults + => false; public class ManyToManyTrackingInMemoryFixture : ManyToManyTrackingFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder) diff --git a/test/EFCore.InMemory.FunctionalTests/MonsterFixupSnapshotInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/MonsterFixupSnapshotInMemoryTest.cs index f04f88df942..540aee47a4c 100644 --- a/test/EFCore.InMemory.FunctionalTests/MonsterFixupSnapshotInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/MonsterFixupSnapshotInMemoryTest.cs @@ -15,7 +15,8 @@ public MonsterFixupSnapshotInMemoryTest(MonsterFixupSnapshotInMemoryFixture fixt public class MonsterFixupSnapshotInMemoryFixture : MonsterFixupSnapshotFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; protected override void OnModelCreating( ModelBuilder builder) diff --git a/test/EFCore.InMemory.FunctionalTests/MusicStoreInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/MusicStoreInMemoryTest.cs index 880d818b090..c4b92bcadda 100644 --- a/test/EFCore.InMemory.FunctionalTests/MusicStoreInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/MusicStoreInMemoryTest.cs @@ -15,15 +15,21 @@ public MusicStoreInMemoryTest(MusicStoreInMemoryFixture fixture) public class MusicStoreInMemoryFixture : MusicStoreFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; - public override IDisposable BeginTransaction(DbContext context) => new InMemoryCleaner(context); + public override IDisposable BeginTransaction(DbContext context) + => new InMemoryCleaner(context); private class InMemoryCleaner : IDisposable { private readonly DbContext _context; - public InMemoryCleaner(DbContext context) => _context = context; - public void Dispose() => _context.Database.EnsureDeleted(); + + public InMemoryCleaner(DbContext context) + => _context = context; + + public void Dispose() + => _context.Database.EnsureDeleted(); } } } diff --git a/test/EFCore.InMemory.FunctionalTests/NotificationEntitiesInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/NotificationEntitiesInMemoryTest.cs index 1bede531cd6..705da37aa1b 100644 --- a/test/EFCore.InMemory.FunctionalTests/NotificationEntitiesInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/NotificationEntitiesInMemoryTest.cs @@ -15,7 +15,8 @@ public NotificationEntitiesInMemoryTest(NotificationEntitiesInMemoryFixture fixt public class NotificationEntitiesInMemoryFixture : NotificationEntitiesFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } } diff --git a/test/EFCore.InMemory.FunctionalTests/OverzealousInitializationInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/OverzealousInitializationInMemoryTest.cs index 035e9858cbd..80c7e3a6128 100644 --- a/test/EFCore.InMemory.FunctionalTests/OverzealousInitializationInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/OverzealousInitializationInMemoryTest.cs @@ -15,7 +15,8 @@ public OverzealousInitializationInMemoryTest(OverzealousInitializationInMemoryFi public class OverzealousInitializationInMemoryFixture : OverzealousInitializationFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } } diff --git a/test/EFCore.InMemory.FunctionalTests/PropertyValuesInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/PropertyValuesInMemoryTest.cs index a4e64af2a37..84f50f80b10 100644 --- a/test/EFCore.InMemory.FunctionalTests/PropertyValuesInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/PropertyValuesInMemoryTest.cs @@ -14,7 +14,8 @@ public PropertyValuesInMemoryTest(PropertyValuesInMemoryFixture fixture) public class PropertyValuesInMemoryFixture : PropertyValuesFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryFixture.cs b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryFixture.cs index a88b7a3b152..0133ef43374 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryFixture.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class ComplexNavigationsQueryInMemoryFixture : ComplexNavigationsQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryFixture.cs b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryFixture.cs index 8338a25929f..ea161caa181 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryFixture.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class ComplexNavigationsWeakQueryInMemoryFixture : ComplexNavigationsWeakQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryTest.cs index 6c99a4389db..02fb3d129da 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryTest.cs @@ -12,7 +12,8 @@ public class ComplexNavigationsWeakQueryInMemoryTest : { // ReSharper disable once UnusedParameter.Local public ComplexNavigationsWeakQueryInMemoryTest( - ComplexNavigationsWeakQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + ComplexNavigationsWeakQueryInMemoryFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { //TestLoggerFactory.TestOutputHelper = testOutputHelper; diff --git a/test/EFCore.InMemory.FunctionalTests/Query/FiltersInheritanceQueryInMemoryFixture.cs b/test/EFCore.InMemory.FunctionalTests/Query/FiltersInheritanceQueryInMemoryFixture.cs index 700828343ad..3692253a826 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/FiltersInheritanceQueryInMemoryFixture.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/FiltersInheritanceQueryInMemoryFixture.cs @@ -5,6 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class FiltersInheritanceQueryInMemoryFixture : InheritanceQueryInMemoryFixture { - protected override bool EnableFilters => true; + protected override bool EnableFilters + => true; } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryFixture.cs b/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryFixture.cs index 1315124f8fd..83b876e4c8e 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryFixture.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class GearsOfWarQueryInMemoryFixture : GearsOfWarQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs index 30358998b28..6ea8401ca47 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/GearsOfWarQueryInMemoryTest.cs @@ -44,8 +44,10 @@ public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesc => base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2(); [ConditionalTheory(Skip = "issue #17540")] - public override Task Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) - => base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(async); + public override Task + Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) + => base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex( + async); [ConditionalTheory(Skip = "issue #18284")] public override Task GroupBy_with_boolean_groupin_key_thru_navigation_access(bool async) diff --git a/test/EFCore.InMemory.FunctionalTests/Query/IncludeOneToOneInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/IncludeOneToOneInMemoryTest.cs index 71cb7973490..012e5fb63e2 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/IncludeOneToOneInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/IncludeOneToOneInMemoryTest.cs @@ -14,7 +14,8 @@ public IncludeOneToOneInMemoryTest(OneToOneQueryInMemoryFixture fixture) public class OneToOneQueryInMemoryFixture : OneToOneQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/IncompleteMappingInheritanceQueryInMemoryFixture.cs b/test/EFCore.InMemory.FunctionalTests/Query/IncompleteMappingInheritanceQueryInMemoryFixture.cs index b0d2b5845f9..634c62dac9d 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/IncompleteMappingInheritanceQueryInMemoryFixture.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/IncompleteMappingInheritanceQueryInMemoryFixture.cs @@ -5,6 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class IncompleteMappingInheritanceQueryInMemoryFixture : InheritanceQueryInMemoryFixture { - protected override bool IsDiscriminatorMappingComplete => false; + protected override bool IsDiscriminatorMappingComplete + => false; } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/IncompleteMappingInheritanceQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/IncompleteMappingInheritanceQueryInMemoryTest.cs index 7c9699316b7..3e082a251ba 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/IncompleteMappingInheritanceQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/IncompleteMappingInheritanceQueryInMemoryTest.cs @@ -29,6 +29,7 @@ public override async Task Can_query_all_animal_views(bool async) ignoreLineEndingDifferences: true); } - protected override bool EnforcesFkConstraints => false; + protected override bool EnforcesFkConstraints + => false; } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/InheritanceQueryInMemoryFixture.cs b/test/EFCore.InMemory.FunctionalTests/Query/InheritanceQueryInMemoryFixture.cs index 9241b804dae..b4791515aee 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/InheritanceQueryInMemoryFixture.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/InheritanceQueryInMemoryFixture.cs @@ -11,7 +11,8 @@ namespace Microsoft.EntityFrameworkCore.Query { public class InheritanceQueryInMemoryFixture : InheritanceQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder).ConfigureWarnings( diff --git a/test/EFCore.InMemory.FunctionalTests/Query/InheritanceQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/InheritanceQueryInMemoryTest.cs index ab00d72d334..2197e2f604a 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/InheritanceQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/InheritanceQueryInMemoryTest.cs @@ -31,6 +31,7 @@ public override async Task Can_query_all_animal_views(bool async) ignoreLineEndingDifferences: true); } - protected override bool EnforcesFkConstraints => false; + protected override bool EnforcesFkConstraints + => false; } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/InheritanceRelationshipsQueryInMemoryFixture.cs b/test/EFCore.InMemory.FunctionalTests/Query/InheritanceRelationshipsQueryInMemoryFixture.cs index 696ef44f652..74cd1d75089 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/InheritanceRelationshipsQueryInMemoryFixture.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/InheritanceRelationshipsQueryInMemoryFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class InheritanceRelationshipsQueryInMemoryFixture : InheritanceRelationshipsQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/ManyToManyQueryInMemoryFixture.cs b/test/EFCore.InMemory.FunctionalTests/Query/ManyToManyQueryInMemoryFixture.cs index a2c1282bb62..b06d36ccc3b 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/ManyToManyQueryInMemoryFixture.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/ManyToManyQueryInMemoryFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class ManyToManyQueryInMemoryFixture : ManyToManyQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/ManyToManyQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/ManyToManyQueryInMemoryTest.cs index 5fbd874e291..181094b1e5a 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/ManyToManyQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/ManyToManyQueryInMemoryTest.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.Threading.Tasks; using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAggregateOperatorsQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAggregateOperatorsQueryInMemoryTest.cs index 9ab2f975946..3c221e49f73 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAggregateOperatorsQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAggregateOperatorsQueryInMemoryTest.cs @@ -10,7 +10,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindAggregateOperatorsQueryInMemoryTest : NorthwindAggregateOperatorsQueryTestBase> + public class NorthwindAggregateOperatorsQueryInMemoryTest : NorthwindAggregateOperatorsQueryTestBase< + NorthwindQueryInMemoryFixture> { public NorthwindAggregateOperatorsQueryInMemoryTest( NorthwindQueryInMemoryFixture fixture, diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsNoTrackingQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsNoTrackingQueryInMemoryTest.cs index 6a70fb8c485..806fa48781f 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsNoTrackingQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsNoTrackingQueryInMemoryTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindAsNoTrackingQueryInMemoryTest : NorthwindAsNoTrackingQueryTestBase> + public class NorthwindAsNoTrackingQueryInMemoryTest : NorthwindAsNoTrackingQueryTestBase< + NorthwindQueryInMemoryFixture> { public NorthwindAsNoTrackingQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) : base(fixture) diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsyncSimpleQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsyncSimpleQueryInMemoryTest.cs index 25729c53f1a..a8a8987b26e 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsyncSimpleQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindAsyncSimpleQueryInMemoryTest.cs @@ -8,7 +8,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindAsyncSimpleQueryInMemoryTest : NorthwindAsyncSimpleQueryTestBase> + public class NorthwindAsyncSimpleQueryInMemoryTest : NorthwindAsyncSimpleQueryTestBase< + NorthwindQueryInMemoryFixture> { public NorthwindAsyncSimpleQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) : base(fixture) diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindChangeTrackingQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindChangeTrackingQueryInMemoryTest.cs index 7a40d9bdcfc..1b95b6b1781 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindChangeTrackingQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindChangeTrackingQueryInMemoryTest.cs @@ -7,9 +7,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindChangeTrackingQueryInMemoryTest : NorthwindChangeTrackingQueryTestBase> + public class NorthwindChangeTrackingQueryInMemoryTest : NorthwindChangeTrackingQueryTestBase< + NorthwindQueryInMemoryFixture> { - public NorthwindChangeTrackingQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindChangeTrackingQueryInMemoryTest( + NorthwindQueryInMemoryFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { //TestLoggerFactory.TestOutputHelper = testOutputHelper; diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindCompiledQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindCompiledQueryInMemoryTest.cs index cb8179dd939..73feae4827a 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindCompiledQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindCompiledQueryInMemoryTest.cs @@ -20,6 +20,7 @@ public override void Query_with_array_parameter() } [ConditionalFact(Skip = "See issue #17386")] - public override Task Query_with_array_parameter_async() => null; + public override Task Query_with_array_parameter_async() + => null; } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindDbFunctionsQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindDbFunctionsQueryInMemoryTest.cs index b9e691000ba..7f51399d6c9 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindDbFunctionsQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindDbFunctionsQueryInMemoryTest.cs @@ -6,9 +6,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindDbFunctionsQueryInMemoryTest : NorthwindDbFunctionsQueryTestBase> + public class NorthwindDbFunctionsQueryInMemoryTest : NorthwindDbFunctionsQueryTestBase< + NorthwindQueryInMemoryFixture> { - public NorthwindDbFunctionsQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindDbFunctionsQueryInMemoryTest( + NorthwindQueryInMemoryFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { //TestSqlLoggerFactory.CaptureOutput(testOutputHelper); diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindInMemoryContext.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindInMemoryContext.cs index 457b7226393..a80064659b7 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindInMemoryContext.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindInMemoryContext.cs @@ -33,13 +33,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().ToInMemoryQuery( () => Products.Where(p => !p.Discontinued) - .Select( - p => new ProductQuery - { - ProductID = p.ProductID, - ProductName = p.ProductName, - CategoryName = "Food" - })); + .Select( + p => new ProductQuery + { + ProductID = p.ProductID, + ProductName = p.ProductName, + CategoryName = "Food" + })); modelBuilder.Entity().ToInMemoryQuery( () => Customers.Select( diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeNoTrackingQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeNoTrackingQueryInMemoryTest.cs index 03fd85c7ece..c69efd1e10c 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeNoTrackingQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeNoTrackingQueryInMemoryTest.cs @@ -6,9 +6,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindIncludeNoTrackingQueryInMemoryTest : NorthwindIncludeNoTrackingQueryTestBase> + public class NorthwindIncludeNoTrackingQueryInMemoryTest : NorthwindIncludeNoTrackingQueryTestBase< + NorthwindQueryInMemoryFixture> { - public NorthwindIncludeNoTrackingQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindIncludeNoTrackingQueryInMemoryTest( + NorthwindQueryInMemoryFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { //TestLoggerFactory.TestOutputHelper = testOutputHelper; diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeQueryInMemoryTest.cs index 9b9a650413b..27af7a0a5fe 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindIncludeQueryInMemoryTest.cs @@ -8,7 +8,9 @@ namespace Microsoft.EntityFrameworkCore.Query { public class NorthwindIncludeQueryInMemoryTest : NorthwindIncludeQueryTestBase> { - public NorthwindIncludeQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindIncludeQueryInMemoryTest( + NorthwindQueryInMemoryFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { //TestLoggerFactory.TestOutputHelper = testOutputHelper; diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindKeylessEntitiesQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindKeylessEntitiesQueryInMemoryTest.cs index 4ae6fb911f6..c51bf7c564f 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindKeylessEntitiesQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindKeylessEntitiesQueryInMemoryTest.cs @@ -9,7 +9,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindKeylessEntitiesQueryInMemoryTest : NorthwindKeylessEntitiesQueryTestBase> + public class NorthwindKeylessEntitiesQueryInMemoryTest : NorthwindKeylessEntitiesQueryTestBase< + NorthwindQueryInMemoryFixture> { public NorthwindKeylessEntitiesQueryInMemoryTest( NorthwindQueryInMemoryFixture fixture, @@ -34,6 +35,5 @@ public override async Task KeylessEntity_with_included_nav(bool async) { await Assert.ThrowsAsync(() => base.KeylessEntity_with_included_nav(async)); } - } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindMiscellaneousQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindMiscellaneousQueryInMemoryTest.cs index fa2cc302a5c..764f46b9b66 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindMiscellaneousQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindMiscellaneousQueryInMemoryTest.cs @@ -11,7 +11,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindMiscellaneousQueryInMemoryTest : NorthwindMiscellaneousQueryTestBase> + public class NorthwindMiscellaneousQueryInMemoryTest : NorthwindMiscellaneousQueryTestBase< + NorthwindQueryInMemoryFixture> { public NorthwindMiscellaneousQueryInMemoryTest( NorthwindQueryInMemoryFixture fixture, diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindNavigationsQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindNavigationsQueryInMemoryTest.cs index b89249e5776..13d1dbc9a25 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindNavigationsQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindNavigationsQueryInMemoryTest.cs @@ -8,10 +8,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindNavigationsQueryInMemoryTest : NorthwindNavigationsQueryTestBase> + public class NorthwindNavigationsQueryInMemoryTest : NorthwindNavigationsQueryTestBase< + NorthwindQueryInMemoryFixture> { public NorthwindNavigationsQueryInMemoryTest( - NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + NorthwindQueryInMemoryFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { //TestLoggerFactory.TestOutputHelper = testOutputHelper; diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryFiltersQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryFiltersQueryInMemoryTest.cs index 6b6375b00f5..c563cc775bf 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryFiltersQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryFiltersQueryInMemoryTest.cs @@ -5,9 +5,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindQueryFiltersQueryInMemoryTest : NorthwindQueryFiltersQueryTestBase> + public class NorthwindQueryFiltersQueryInMemoryTest : NorthwindQueryFiltersQueryTestBase< + NorthwindQueryInMemoryFixture> { - public NorthwindQueryFiltersQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindQueryFiltersQueryInMemoryTest( + NorthwindQueryInMemoryFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { //TestLoggerFactory.TestOutputHelper = testOutputHelper; diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryInMemoryFixture.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryInMemoryFixture.cs index 766ed5d14d4..3ee609d612b 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryInMemoryFixture.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryInMemoryFixture.cs @@ -10,8 +10,10 @@ namespace Microsoft.EntityFrameworkCore.Query public class NorthwindQueryInMemoryFixture : NorthwindQueryFixtureBase where TModelCustomizer : IModelCustomizer, new() { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; - protected override Type ContextType => typeof(NorthwindInMemoryContext); + protected override Type ContextType + => typeof(NorthwindInMemoryContext); } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryTaggingQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryTaggingQueryInMemoryTest.cs index 62159b568e1..280279c1ef7 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryTaggingQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindQueryTaggingQueryInMemoryTest.cs @@ -6,10 +6,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindQueryTaggingQueryInMemoryTest : NorthwindQueryTaggingQueryTestBase> + public class NorthwindQueryTaggingQueryInMemoryTest : NorthwindQueryTaggingQueryTestBase< + NorthwindQueryInMemoryFixture> { public NorthwindQueryTaggingQueryInMemoryTest( - NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + NorthwindQueryInMemoryFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindSetOperationsQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindSetOperationsQueryInMemoryTest.cs index c385b499edc..d6b30375bf3 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindSetOperationsQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindSetOperationsQueryInMemoryTest.cs @@ -6,7 +6,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindSetOperationsQueryInMemoryTest : NorthwindSetOperationsQueryTestBase> + public class NorthwindSetOperationsQueryInMemoryTest : NorthwindSetOperationsQueryTestBase< + NorthwindQueryInMemoryFixture> { public NorthwindSetOperationsQueryInMemoryTest( NorthwindQueryInMemoryFixture fixture, diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindStringIncludeQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindStringIncludeQueryInMemoryTest.cs index 363c7c2185e..a4b8d83ad48 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindStringIncludeQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindStringIncludeQueryInMemoryTest.cs @@ -6,9 +6,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindStringIncludeQueryInMemoryTest : NorthwindStringIncludeQueryTestBase> + public class NorthwindStringIncludeQueryInMemoryTest : NorthwindStringIncludeQueryTestBase< + NorthwindQueryInMemoryFixture> { - public NorthwindStringIncludeQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindStringIncludeQueryInMemoryTest( + NorthwindQueryInMemoryFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { //TestLoggerFactory.TestOutputHelper = testOutputHelper; diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs index 392873074c7..c0c7f4f3472 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs @@ -38,16 +38,18 @@ public override Task Where_equals_on_null_nullable_int_types(bool async) { return base.Where_equals_on_null_nullable_int_types(async); } + public override async Task Where_simple_closure(bool async) { var queryString = await base.Where_simple_closure(async); - Assert.Equal(InMemoryStrings.NoQueryStrings, queryString ); + Assert.Equal(InMemoryStrings.NoQueryStrings, queryString); return null; } // Casting int to object to string is invalid for InMemory - public override Task Like_with_non_string_column_using_double_cast(bool async) => Task.CompletedTask; + public override Task Like_with_non_string_column_using_double_cast(bool async) + => Task.CompletedTask; } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NullKeysInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NullKeysInMemoryTest.cs index fe11040870b..03b1974a566 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NullKeysInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NullKeysInMemoryTest.cs @@ -14,7 +14,8 @@ public NullKeysInMemoryTest(NullKeysInMemoryFixture fixture) public class NullKeysInMemoryFixture : NullKeysFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/OwnedQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/OwnedQueryInMemoryTest.cs index 9ea51a6a553..28e9dd18c8a 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/OwnedQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/OwnedQueryInMemoryTest.cs @@ -16,7 +16,8 @@ public OwnedQueryInMemoryTest(OwnedQueryInMemoryFixture fixture, ITestOutputHelp public class OwnedQueryInMemoryFixture : OwnedQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } } } diff --git a/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs index 174ce6d25a5..dbc0ef915cb 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/QueryBugsInMemoryTest.cs @@ -678,7 +678,8 @@ public virtual void GroupJoin_SelectMany_in_defining_query_is_flattened() var query = context.Set().ToList(); - Assert.Collection(query, + Assert.Collection( + query, t => AssertCustomerView(t, 1, "First", 1, "FirstChild"), t => AssertCustomerView(t, 2, "Second", 2, "SecondChild1"), t => AssertCustomerView(t, 2, "Second", 3, "SecondChild2"), @@ -686,7 +687,11 @@ public virtual void GroupJoin_SelectMany_in_defining_query_is_flattened() } static void AssertCustomerView( - CustomerView19708 actual, int id, string name, int? customerMembershipId, string customerMembershipName) + CustomerView19708 actual, + int id, + string name, + int? customerMembershipId, + string customerMembershipName) { Assert.Equal(id, actual.Id); Assert.Equal(name, actual.Name); @@ -775,17 +780,17 @@ private class CustomerView19708 [ConditionalFact] public virtual void Using_explicit_interface_implementation_as_navigation_works() { - using (CreateScratch((t) => { }, "21768")) + using (CreateScratch(t => { }, "21768")) { using var context = new MyContext21768(); Expression> projection = b => new BookViewModel21768 { FirstPage = b.FrontCover.Illustrations.FirstOrDefault(i => i.State >= IllustrationState21768.Approved) != null - ? new PageViewModel21768 - { - Uri = b.FrontCover.Illustrations.FirstOrDefault(i => i.State >= IllustrationState21768.Approved).Uri - } - : null, + ? new PageViewModel21768 + { + Uri = b.FrontCover.Illustrations.FirstOrDefault(i => i.State >= IllustrationState21768.Approved).Uri + } + : null, }; var result = context.Books.Where(b => b.Id == 1).Select(projection).SingleOrDefault(); @@ -837,15 +842,21 @@ private class Book21768 : IBook21768 public BookCover21768 BackCover { get; set; } public int BackCoverId { get; set; } - IBookCover21768 IBook21768.FrontCover => FrontCover; - IBookCover21768 IBook21768.BackCover => BackCover; + + IBookCover21768 IBook21768.FrontCover + => FrontCover; + + IBookCover21768 IBook21768.BackCover + => BackCover; } private class BookCover21768 : IBookCover21768 { public int Id { get; set; } public ICollection Illustrations { get; set; } - IEnumerable IBookCover21768.Illustrations => Illustrations; + + IEnumerable IBookCover21768.Illustrations + => Illustrations; } private class CoverIllustration21768 : ICoverIllustration21768 @@ -856,7 +867,8 @@ private class CoverIllustration21768 : ICoverIllustration21768 public string Uri { get; set; } public IllustrationState21768 State { get; set; } - IBookCover21768 ICoverIllustration21768.Cover => Cover; + IBookCover21768 ICoverIllustration21768.Cover + => Cover; } private enum IllustrationState21768 @@ -915,7 +927,9 @@ public class AppEntity21803 private readonly List _otherEntities = new List(); public int Id { get; private set; } - public IEnumerable OtherEntities => _otherEntities; + + public IEnumerable OtherEntities + => _otherEntities; } public class OtherEntity21803 diff --git a/test/EFCore.InMemory.FunctionalTests/Query/QueryFilterFuncletizationInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/QueryFilterFuncletizationInMemoryTest.cs index f2ed8b793de..1c0839444cc 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/QueryFilterFuncletizationInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/QueryFilterFuncletizationInMemoryTest.cs @@ -11,14 +11,16 @@ public class QueryFilterFuncletizationInMemoryTest : QueryFilterFuncletizationTestBase { public QueryFilterFuncletizationInMemoryTest( - QueryFilterFuncletizationInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + QueryFilterFuncletizationInMemoryFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { } public class QueryFilterFuncletizationInMemoryFixture : QueryFilterFuncletizationFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; } [ConditionalFact(Skip = "issue #17386")] diff --git a/test/EFCore.InMemory.FunctionalTests/StoreGeneratedFixupInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/StoreGeneratedFixupInMemoryTest.cs index 13e3277586b..3f2eb4f720f 100644 --- a/test/EFCore.InMemory.FunctionalTests/StoreGeneratedFixupInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/StoreGeneratedFixupInMemoryTest.cs @@ -45,11 +45,13 @@ protected override void ExecuteWithStrategyInTransaction(Action testO Fixture.Reseed(); } - protected override bool EnforcesFKs => false; + protected override bool EnforcesFKs + => false; public class StoreGeneratedFixupInMemoryFixture : StoreGeneratedFixupFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder).ConfigureWarnings(w => w.Log(InMemoryEventId.TransactionIgnoredWarning)); diff --git a/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStore.cs b/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStore.cs index 623d18e33f8..6f40b666c86 100644 --- a/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStore.cs +++ b/test/EFCore.InMemory.FunctionalTests/TestUtilities/InMemoryTestStore.cs @@ -28,11 +28,15 @@ public static InMemoryTestStore CreateInitialized(string name) => new InMemoryTestStore(name, shared: false).InitializeInMemory(null, (Func)null, null); public InMemoryTestStore InitializeInMemory( - IServiceProvider serviceProvider, Func createContext, Action seed) + IServiceProvider serviceProvider, + Func createContext, + Action seed) => (InMemoryTestStore)Initialize(serviceProvider, createContext, seed); public InMemoryTestStore InitializeInMemory( - IServiceProvider serviceProvider, Func createContext, Action seed) + IServiceProvider serviceProvider, + Func createContext, + Action seed) => (InMemoryTestStore)Initialize(serviceProvider, () => createContext(this), seed); protected override TestStoreIndex GetTestStoreIndex(IServiceProvider serviceProvider) diff --git a/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryFixtureBase.cs b/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryFixtureBase.cs index 788057a62c8..33a88534d31 100644 --- a/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryFixtureBase.cs +++ b/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryFixtureBase.cs @@ -8,7 +8,8 @@ namespace Microsoft.EntityFrameworkCore { public abstract class UpdatesInMemoryFixtureBase : UpdatesFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder).ConfigureWarnings(w => w.Log(InMemoryEventId.TransactionIgnoredWarning)); diff --git a/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithSensitiveDataLoggingFixture.cs b/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithSensitiveDataLoggingFixture.cs index fa7f576b6b7..4b9d885533f 100644 --- a/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithSensitiveDataLoggingFixture.cs +++ b/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithSensitiveDataLoggingFixture.cs @@ -9,7 +9,8 @@ public class UpdatesInMemoryWithSensitiveDataLoggingFixture : UpdatesInMemoryFix { protected override string StoreName { get; } = "UpdateTestSensitive"; - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder).EnableSensitiveDataLogging(); diff --git a/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithoutSensitiveDataLoggingFixture.cs b/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithoutSensitiveDataLoggingFixture.cs index f98b3773ead..27088d54efe 100644 --- a/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithoutSensitiveDataLoggingFixture.cs +++ b/test/EFCore.InMemory.FunctionalTests/UpdatesInMemoryWithoutSensitiveDataLoggingFixture.cs @@ -9,7 +9,8 @@ public class UpdatesInMemoryWithoutSensitiveDataLoggingFixture : UpdatesInMemory { protected override string StoreName { get; } = "UpdateTestInsensitive"; - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder).EnableSensitiveDataLogging(false); diff --git a/test/EFCore.InMemory.FunctionalTests/WithConstructorsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/WithConstructorsInMemoryTest.cs index 2d189cc3867..e638e6d0be2 100644 --- a/test/EFCore.InMemory.FunctionalTests/WithConstructorsInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/WithConstructorsInMemoryTest.cs @@ -23,7 +23,8 @@ public override void Query_and_update_using_constructors_with_property_parameter public class WithConstructorsInMemoryFixture : WithConstructorsFixtureBase { - protected override ITestStoreFactory TestStoreFactory => InMemoryTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder).ConfigureWarnings(w => w.Log(InMemoryEventId.TransactionIgnoredWarning)); diff --git a/test/EFCore.InMemory.Tests/InMemoryApiConsistencyTest.cs b/test/EFCore.InMemory.Tests/InMemoryApiConsistencyTest.cs index 8b91c904255..a9553d31d1d 100644 --- a/test/EFCore.InMemory.Tests/InMemoryApiConsistencyTest.cs +++ b/test/EFCore.InMemory.Tests/InMemoryApiConsistencyTest.cs @@ -21,7 +21,8 @@ public InMemoryApiConsistencyTest(InMemoryApiConsistencyFixture fixture) protected override void AddServices(ServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkInMemoryDatabase(); - protected override Assembly TargetAssembly => typeof(InMemoryDatabase).Assembly; + protected override Assembly TargetAssembly + => typeof(InMemoryDatabase).Assembly; public class InMemoryApiConsistencyFixture : ApiConsistencyFixtureBase { @@ -32,7 +33,7 @@ public override bool TryGetProviderOptionsDelegate(out Action FluentApiTypes { get; } = new HashSet() + public override HashSet FluentApiTypes { get; } = new HashSet { typeof(InMemoryServiceCollectionExtensions), typeof(InMemoryDbContextOptionsExtensions), diff --git a/test/EFCore.InMemory.Tests/InMemoryDatabaseCreatorTest.cs b/test/EFCore.InMemory.Tests/InMemoryDatabaseCreatorTest.cs index b719fda20ba..cf7ea9199b2 100644 --- a/test/EFCore.InMemory.Tests/InMemoryDatabaseCreatorTest.cs +++ b/test/EFCore.InMemory.Tests/InMemoryDatabaseCreatorTest.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.InMemory.Storage.Internal; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; diff --git a/test/EFCore.InMemory.Tests/InMemoryDatabaseTest.cs b/test/EFCore.InMemory.Tests/InMemoryDatabaseTest.cs index 1059d536188..7a6db15aaf5 100644 --- a/test/EFCore.InMemory.Tests/InMemoryDatabaseTest.cs +++ b/test/EFCore.InMemory.Tests/InMemoryDatabaseTest.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.InMemory.Diagnostics.Internal; using Microsoft.EntityFrameworkCore.InMemory.Internal; -using Microsoft.EntityFrameworkCore.InMemory.Metadata.Conventions; using Microsoft.EntityFrameworkCore.InMemory.Storage.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.TestUtilities; diff --git a/test/EFCore.InMemory.Tests/InMemoryValueGeneratorSelectorTest.cs b/test/EFCore.InMemory.Tests/InMemoryValueGeneratorSelectorTest.cs index c24b41651f0..590c195cc33 100644 --- a/test/EFCore.InMemory.Tests/InMemoryValueGeneratorSelectorTest.cs +++ b/test/EFCore.InMemory.Tests/InMemoryValueGeneratorSelectorTest.cs @@ -140,7 +140,8 @@ public override int Next(EntityEntry entry) throw new NotImplementedException(); } - public override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; } } } diff --git a/test/EFCore.InMemory.Tests/Infrastructure/InMemoryModelValidatorTest.cs b/test/EFCore.InMemory.Tests/Infrastructure/InMemoryModelValidatorTest.cs index 0d287fcd3fc..8bf9034ccc5 100644 --- a/test/EFCore.InMemory.Tests/Infrastructure/InMemoryModelValidatorTest.cs +++ b/test/EFCore.InMemory.Tests/Infrastructure/InMemoryModelValidatorTest.cs @@ -22,6 +22,7 @@ public virtual void Detects_ToQuery_on_derived_keyless_types() modelBuilder.Model); } - protected override TestHelpers TestHelpers => InMemoryTestHelpers.Instance; + protected override TestHelpers TestHelpers + => InMemoryTestHelpers.Instance; } } diff --git a/test/EFCore.Proxies.Tests/ChangeDetectionProxyTests.cs b/test/EFCore.Proxies.Tests/ChangeDetectionProxyTests.cs index 7e1616c0149..6f958f04839 100644 --- a/test/EFCore.Proxies.Tests/ChangeDetectionProxyTests.cs +++ b/test/EFCore.Proxies.Tests/ChangeDetectionProxyTests.cs @@ -269,8 +269,13 @@ private class ChangeContext : TestContext { private readonly Action> _entityBuilderAction; - public ChangeContext(bool useLazyLoading = false, bool checkEquality = true, Action> entityBuilderAction = null) - : base(dbName: "ChangeDetectionContext", useLazyLoading: useLazyLoading, useChangeDetection: true, checkEquality: checkEquality) + public ChangeContext( + bool useLazyLoading = false, + bool checkEquality = true, + Action> entityBuilderAction = null) + : base( + dbName: "ChangeDetectionContext", useLazyLoading: useLazyLoading, useChangeDetection: true, + checkEquality: checkEquality) { _entityBuilderAction = entityBuilderAction; } diff --git a/test/EFCore.Proxies.Tests/ProxiesApiConsistencyTest.cs b/test/EFCore.Proxies.Tests/ProxiesApiConsistencyTest.cs index 931c34ddbf3..546d7924cb7 100644 --- a/test/EFCore.Proxies.Tests/ProxiesApiConsistencyTest.cs +++ b/test/EFCore.Proxies.Tests/ProxiesApiConsistencyTest.cs @@ -19,7 +19,8 @@ public ProxiesApiConsistencyTest(ProxiesApiConsistencyFixture fixture) protected override void AddServices(ServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkProxies(); - protected override Assembly TargetAssembly => typeof(ProxiesExtensions).Assembly; + protected override Assembly TargetAssembly + => typeof(ProxiesExtensions).Assembly; public class ProxiesApiConsistencyFixture : ApiConsistencyFixtureBase { @@ -30,10 +31,7 @@ public override bool TryGetProviderOptionsDelegate(out Action FluentApiTypes { get; } = new HashSet() - { - typeof(ProxiesServiceCollectionExtensions) - }; + public override HashSet FluentApiTypes { get; } = new HashSet { typeof(ProxiesServiceCollectionExtensions) }; } } } diff --git a/test/EFCore.Proxies.Tests/ProxyTests.cs b/test/EFCore.Proxies.Tests/ProxyTests.cs index 33829bea740..823c5a5f530 100644 --- a/test/EFCore.Proxies.Tests/ProxyTests.cs +++ b/test/EFCore.Proxies.Tests/ProxyTests.cs @@ -104,18 +104,18 @@ public void CreateProxy_uses_parameterized_constructor_taking_context() [ConditionalFact] public void Proxies_only_created_if_Use_called() { - using (var context = new NeweyContext(nameof(Proxies_only_created_if_Use_called), false, false)) + using (var context = new NeweyContext(nameof(Proxies_only_created_if_Use_called), false)) { context.Add(new March82GGtp()); context.SaveChanges(); } - using (var context = new NeweyContext(nameof(Proxies_only_created_if_Use_called), false, false)) + using (var context = new NeweyContext(nameof(Proxies_only_created_if_Use_called), false)) { Assert.Same(typeof(March82GGtp), context.Set().Single().GetType()); } - using (var context = new NeweyContext(nameof(Proxies_only_created_if_Use_called), true, false)) + using (var context = new NeweyContext(nameof(Proxies_only_created_if_Use_called))) { Assert.Same(typeof(March82GGtp), context.Set().Single().GetType().BaseType); } @@ -244,7 +244,7 @@ public void Throws_if_attempt_to_add_proxy_type_to_model_builder() () => { var context = new CannotAddProxyTypeToModel(); - context.Set().Add( new ClassToBeProxied { Id = 0 } ); + context.Set().Add(new ClassToBeProxied { Id = 0 }); }).Message); } @@ -303,7 +303,11 @@ public NeweyContext(string dbName = null, bool useLazyLoading = true, bool useCh _useChangeDetectionProxies = useChangeDetection; } - public NeweyContext(IServiceProvider internalServiceProvider, string dbName = null, bool useLazyLoading = true, bool useChangeDetection = false) + public NeweyContext( + IServiceProvider internalServiceProvider, + string dbName = null, + bool useLazyLoading = true, + bool useChangeDetection = false) : this(dbName, useLazyLoading, useChangeDetection) { _internalServiceProvider = internalServiceProvider; diff --git a/test/EFCore.Proxies.Tests/TestUtilities/TestContext.cs b/test/EFCore.Proxies.Tests/TestUtilities/TestContext.cs index db9b087ac1b..5ce7d9ebc48 100644 --- a/test/EFCore.Proxies.Tests/TestUtilities/TestContext.cs +++ b/test/EFCore.Proxies.Tests/TestUtilities/TestContext.cs @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { internal abstract class TestContext : DbContext - where TEntity : class + where TEntity : class { private static readonly InMemoryDatabaseRoot _dbRoot = new InMemoryDatabaseRoot(); diff --git a/test/EFCore.Relational.Specification.Tests/CommandInterceptionTestBase.cs b/test/EFCore.Relational.Specification.Tests/CommandInterceptionTestBase.cs index 917a7af0e2b..7327c5196a6 100644 --- a/test/EFCore.Relational.Specification.Tests/CommandInterceptionTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/CommandInterceptionTestBase.cs @@ -198,7 +198,8 @@ public override ValueTask> ReaderExecutingAsync { base.ReaderExecutingAsync(command, eventData, result, cancellationToken); - return new ValueTask>(InterceptionResult.SuppressWithResult(new FakeDbDataReader())); + return new ValueTask>( + InterceptionResult.SuppressWithResult(new FakeDbDataReader())); } } @@ -875,16 +876,32 @@ public CompositeFakeDbDataReader(DbDataReader firstReader, DbDataReader secondRe _secondReader = secondReader; } - public override int FieldCount => _firstReader.FieldCount; - public override int RecordsAffected => _firstReader.RecordsAffected + _secondReader.RecordsAffected; - public override bool HasRows => _firstReader.HasRows || _secondReader.HasRows; - public override bool IsClosed => _firstReader.IsClosed; - public override int Depth => _firstReader.Depth; + public override int FieldCount + => _firstReader.FieldCount; - public override string GetDataTypeName(int ordinal) => _firstReader.GetDataTypeName(ordinal); - public override Type GetFieldType(int ordinal) => _firstReader.GetFieldType(ordinal); - public override string GetName(int ordinal) => _firstReader.GetName(ordinal); - public override bool NextResult() => _firstReader.NextResult() || _secondReader.NextResult(); + public override int RecordsAffected + => _firstReader.RecordsAffected + _secondReader.RecordsAffected; + + public override bool HasRows + => _firstReader.HasRows || _secondReader.HasRows; + + public override bool IsClosed + => _firstReader.IsClosed; + + public override int Depth + => _firstReader.Depth; + + public override string GetDataTypeName(int ordinal) + => _firstReader.GetDataTypeName(ordinal); + + public override Type GetFieldType(int ordinal) + => _firstReader.GetFieldType(ordinal); + + public override string GetName(int ordinal) + => _firstReader.GetName(ordinal); + + public override bool NextResult() + => _firstReader.NextResult() || _secondReader.NextResult(); public override async Task NextResultAsync(CancellationToken cancellationToken) => await _firstReader.NextResultAsync(cancellationToken) || await _secondReader.NextResultAsync(cancellationToken); @@ -1437,12 +1454,20 @@ private class WrappingDbCommand : DbCommand { private readonly DbCommand _command; - public WrappingDbCommand(DbCommand command) => _command = command; + public WrappingDbCommand(DbCommand command) + => _command = command; + + public override void Cancel() + => _command.Cancel(); + + public override int ExecuteNonQuery() + => _command.ExecuteNonQuery(); - public override void Cancel() => _command.Cancel(); - public override int ExecuteNonQuery() => _command.ExecuteNonQuery(); - public override object ExecuteScalar() => _command.ExecuteScalar(); - public override void Prepare() => _command.Prepare(); + public override object ExecuteScalar() + => _command.ExecuteScalar(); + + public override void Prepare() + => _command.Prepare(); public override string CommandText { @@ -1474,7 +1499,8 @@ protected override DbConnection DbConnection set => _command.Connection = value; } - protected override DbParameterCollection DbParameterCollection => _command.Parameters; + protected override DbParameterCollection DbParameterCollection + => _command.Parameters; protected override DbTransaction DbTransaction { @@ -1488,8 +1514,11 @@ public override bool DesignTimeVisible set => _command.DesignTimeVisible = value; } - protected override DbParameter CreateDbParameter() => _command.CreateParameter(); - protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) => _command.ExecuteReader(); + protected override DbParameter CreateDbParameter() + => _command.CreateParameter(); + + protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) + => _command.ExecuteReader(); } private class FakeDbDataReader : DbDataReader @@ -1517,34 +1546,71 @@ public override bool IsDBNull(int ordinal) public override string GetString(int ordinal) => _strings[_index - 1]; - public override bool GetBoolean(int ordinal) => throw new NotImplementedException(); - public override byte GetByte(int ordinal) => throw new NotImplementedException(); + public override bool GetBoolean(int ordinal) + => throw new NotImplementedException(); + + public override byte GetByte(int ordinal) + => throw new NotImplementedException(); public override long GetBytes(int ordinal, long dataOffset, byte[] buffer, int bufferOffset, int length) => throw new NotImplementedException(); - public override char GetChar(int ordinal) => throw new NotImplementedException(); + public override char GetChar(int ordinal) + => throw new NotImplementedException(); public override long GetChars(int ordinal, long dataOffset, char[] buffer, int bufferOffset, int length) => throw new NotImplementedException(); - public override string GetDataTypeName(int ordinal) => throw new NotImplementedException(); - public override DateTime GetDateTime(int ordinal) => throw new NotImplementedException(); - public override decimal GetDecimal(int ordinal) => throw new NotImplementedException(); - public override double GetDouble(int ordinal) => throw new NotImplementedException(); - public override Type GetFieldType(int ordinal) => throw new NotImplementedException(); - public override float GetFloat(int ordinal) => throw new NotImplementedException(); - public override Guid GetGuid(int ordinal) => throw new NotImplementedException(); - public override short GetInt16(int ordinal) => throw new NotImplementedException(); - public override long GetInt64(int ordinal) => throw new NotImplementedException(); - public override string GetName(int ordinal) => throw new NotImplementedException(); - public override int GetOrdinal(string name) => throw new NotImplementedException(); - public override object GetValue(int ordinal) => throw new NotImplementedException(); - public override int GetValues(object[] values) => throw new NotImplementedException(); - public override object this[int ordinal] => throw new NotImplementedException(); - public override object this[string name] => throw new NotImplementedException(); - public override bool NextResult() => throw new NotImplementedException(); - public override IEnumerator GetEnumerator() => throw new NotImplementedException(); + public override string GetDataTypeName(int ordinal) + => throw new NotImplementedException(); + + public override DateTime GetDateTime(int ordinal) + => throw new NotImplementedException(); + + public override decimal GetDecimal(int ordinal) + => throw new NotImplementedException(); + + public override double GetDouble(int ordinal) + => throw new NotImplementedException(); + + public override Type GetFieldType(int ordinal) + => throw new NotImplementedException(); + + public override float GetFloat(int ordinal) + => throw new NotImplementedException(); + + public override Guid GetGuid(int ordinal) + => throw new NotImplementedException(); + + public override short GetInt16(int ordinal) + => throw new NotImplementedException(); + + public override long GetInt64(int ordinal) + => throw new NotImplementedException(); + + public override string GetName(int ordinal) + => throw new NotImplementedException(); + + public override int GetOrdinal(string name) + => throw new NotImplementedException(); + + public override object GetValue(int ordinal) + => throw new NotImplementedException(); + + public override int GetValues(object[] values) + => throw new NotImplementedException(); + + public override object this[int ordinal] + => throw new NotImplementedException(); + + public override object this[string name] + => throw new NotImplementedException(); + + public override bool NextResult() + => throw new NotImplementedException(); + + public override IEnumerator GetEnumerator() + => throw new NotImplementedException(); } private static void AssertNormalOutcome(DbContext context, CommandInterceptorBase interceptor, bool async) diff --git a/test/EFCore.Relational.Specification.Tests/F1RelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/F1RelationalFixture.cs index d10af433d6e..02d6de5ba59 100644 --- a/test/EFCore.Relational.Specification.Tests/F1RelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/F1RelationalFixture.cs @@ -9,7 +9,8 @@ namespace Microsoft.EntityFrameworkCore { public abstract class F1RelationalFixture : F1FixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder).ConfigureWarnings( diff --git a/test/EFCore.Relational.Specification.Tests/MigrationsInfrastructureTestBase.cs b/test/EFCore.Relational.Specification.Tests/MigrationsInfrastructureTestBase.cs index 427cd9c2719..1217232bdf2 100644 --- a/test/EFCore.Relational.Specification.Tests/MigrationsInfrastructureTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/MigrationsInfrastructureTestBase.cs @@ -228,7 +228,7 @@ public virtual void Can_generate_idempotent_up_scripts_noTransactions() SetSql( migrator.GenerateScript( options: MigrationsSqlGenerationOptions.Idempotent - | MigrationsSqlGenerationOptions.NoTransactions)); + | MigrationsSqlGenerationOptions.NoTransactions)); } [ConditionalFact] @@ -322,13 +322,18 @@ protected virtual void DiffSnapshot(ModelSnapshot snapshot, DbContext context) Assert.Equal(0, operations.Count); } - private void SetSql(string value) => Sql = value.Replace(ProductInfo.GetVersion(), "7.0.0-test"); + private void SetSql(string value) + => Sql = value.Replace(ProductInfo.GetVersion(), "7.0.0-test"); } - public abstract class MigrationsInfrastructureFixtureBase : SharedStoreFixtureBase + public abstract class + MigrationsInfrastructureFixtureBase : SharedStoreFixtureBase { public static string ActiveProvider { get; set; } - public new RelationalTestStore TestStore => (RelationalTestStore)base.TestStore; + + public new RelationalTestStore TestStore + => (RelationalTestStore)base.TestStore; + protected override string StoreName { get; } = "MigrationsTest"; public EmptyMigrationsContext CreateEmptyContext() @@ -341,7 +346,8 @@ public EmptyMigrationsContext CreateEmptyContext() .BuildServiceProvider()) .Options); - public new virtual MigrationsContext CreateContext() => base.CreateContext(); + public new virtual MigrationsContext CreateContext() + => base.CreateContext(); public class EmptyMigrationsContext : DbContext { diff --git a/test/EFCore.Relational.Specification.Tests/MigrationsTestBase.cs b/test/EFCore.Relational.Specification.Tests/MigrationsTestBase.cs index 6b95bd1fed8..15f3f0519a2 100644 --- a/test/EFCore.Relational.Specification.Tests/MigrationsTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/MigrationsTestBase.cs @@ -221,7 +221,8 @@ public virtual Task Create_table_with_computed_column(bool? stored) e.Property("Id"); e.Property("X"); e.Property("Y"); - e.Property("Sum").HasComputedColumnSql($"{DelimitIdentifier("X")} + {DelimitIdentifier("Y")}", + e.Property("Sum").HasComputedColumnSql( + $"{DelimitIdentifier("X")} + {DelimitIdentifier("Y")}", stored); }), model => @@ -762,8 +763,10 @@ public virtual Task Alter_column_change_computed() e.Property("Y"); e.Property("Sum"); }), - builder => builder.Entity("People").Property("Sum").HasComputedColumnSql($"{DelimitIdentifier("X")} + {DelimitIdentifier("Y")}"), - builder => builder.Entity("People").Property("Sum").HasComputedColumnSql($"{DelimitIdentifier("X")} - {DelimitIdentifier("Y")}"), + builder => builder.Entity("People").Property("Sum") + .HasComputedColumnSql($"{DelimitIdentifier("X")} + {DelimitIdentifier("Y")}"), + builder => builder.Entity("People").Property("Sum") + .HasComputedColumnSql($"{DelimitIdentifier("X")} - {DelimitIdentifier("Y")}"), model => { var table = Assert.Single(model.Tables); @@ -781,23 +784,23 @@ public virtual Task Alter_column_change_computed_type() => Test( builder => builder.Entity( "People", e => - { - e.Property("Id"); - e.Property("X"); - e.Property("Y"); - e.Property("Sum"); - }), + { + e.Property("Id"); + e.Property("X"); + e.Property("Y"); + e.Property("Sum"); + }), builder => builder.Entity("People").Property("Sum") .HasComputedColumnSql($"{DelimitIdentifier("X")} + {DelimitIdentifier("Y")}", stored: false), builder => builder.Entity("People").Property("Sum") .HasComputedColumnSql($"{DelimitIdentifier("X")} + {DelimitIdentifier("Y")}", stored: true), model => - { - var table = Assert.Single(model.Tables); - var sumColumn = Assert.Single(table.Columns, c => c.Name == "Sum"); - if (AssertComputedColumns) - Assert.True(sumColumn.IsStored); - }); + { + var table = Assert.Single(model.Tables); + var sumColumn = Assert.Single(table.Columns, c => c.Name == "Sum"); + if (AssertComputedColumns) + Assert.True(sumColumn.IsStored); + }); [ConditionalFact] public virtual Task Alter_column_add_comment() @@ -845,11 +848,11 @@ public virtual Task Alter_column_set_collation() builder => builder.Entity("People").Property("Name") .UseCollation(NonDefaultCollation), model => - { - var nameColumn = Assert.Single(Assert.Single(model.Tables).Columns); - if (AssertCollations) - Assert.Equal(NonDefaultCollation, nameColumn.Collation); - }); + { + var nameColumn = Assert.Single(Assert.Single(model.Tables).Columns); + if (AssertCollations) + Assert.Equal(NonDefaultCollation, nameColumn.Collation); + }); [Fact] public virtual Task Alter_column_reset_collation() @@ -859,10 +862,10 @@ public virtual Task Alter_column_reset_collation() .UseCollation(NonDefaultCollation), builder => { }, model => - { - var nameColumn = Assert.Single(Assert.Single(model.Tables).Columns); - Assert.Null(nameColumn.Collation); - }); + { + var nameColumn = Assert.Single(Assert.Single(model.Tables).Columns); + Assert.Null(nameColumn.Collation); + }); [ConditionalFact] public virtual Task Drop_column() @@ -1551,18 +1554,31 @@ private class Person public int Age { get; set; } } - protected virtual bool AssertSchemaNames => true; - protected virtual bool AssertComments => true; - protected virtual bool AssertComputedColumns => true; - protected virtual bool AssertCollations => true; - protected virtual bool AssertIndexFilters => true; - protected virtual bool AssertConstraintNames => true; + protected virtual bool AssertSchemaNames + => true; + + protected virtual bool AssertComments + => true; + + protected virtual bool AssertComputedColumns + => true; + + protected virtual bool AssertCollations + => true; + + protected virtual bool AssertIndexFilters + => true; + + protected virtual bool AssertConstraintNames + => true; protected abstract string NonDefaultCollation { get; } - protected virtual ReferentialAction Normalize(ReferentialAction value) => value; + protected virtual ReferentialAction Normalize(ReferentialAction value) + => value; - protected virtual DbContext CreateContext() => Fixture.CreateContext(); + protected virtual DbContext CreateContext() + => Fixture.CreateContext(); protected virtual string DelimitIdentifier(string unquotedIdentifier) => _sqlGenerationHelper?.DelimitIdentifier(unquotedIdentifier) @@ -1691,7 +1707,9 @@ protected virtual void AssertSql(params string[] expected) public abstract class MigrationsFixtureBase : SharedStoreFixtureBase { public abstract TestHelpers TestHelpers { get; } - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; } protected virtual ModelBuilder CreateConventionlessModelBuilder(bool sensitiveDataLoggingEnabled = false) diff --git a/test/EFCore.Relational.Specification.Tests/PropertyEntryTestBase.cs b/test/EFCore.Relational.Specification.Tests/PropertyEntryTestBase.cs index 72b4e70dc3a..44ecb4406f4 100644 --- a/test/EFCore.Relational.Specification.Tests/PropertyEntryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/PropertyEntryTestBase.cs @@ -12,7 +12,8 @@ namespace Microsoft.EntityFrameworkCore public abstract class PropertyEntryTestBase : IClassFixture where TFixture : F1FixtureBase, new() { - protected PropertyEntryTestBase(TFixture fixture) => Fixture = fixture; + protected PropertyEntryTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -37,6 +38,7 @@ public virtual void Property_entry_original_value_is_set() }); } - protected F1Context CreateF1Context() => Fixture.CreateContext(); + protected F1Context CreateF1Context() + => Fixture.CreateContext(); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/AsyncFromSqlQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/AsyncFromSqlQueryTestBase.cs index 86956977f7e..c1543f63752 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/AsyncFromSqlQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/AsyncFromSqlQueryTestBase.cs @@ -366,6 +366,7 @@ private string NormalizeDelimitersInRawString(string sql) private FormattableString NormalizeDelimitersInInterpolatedString(FormattableString sql) => Fixture.TestStore.NormalizeDelimitersInInterpolatedString(sql); - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/AsyncGearsOfWarQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/AsyncGearsOfWarQueryRelationalTestBase.cs index 3292319e31e..631e309d4e9 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/AsyncGearsOfWarQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/AsyncGearsOfWarQueryRelationalTestBase.cs @@ -13,9 +13,11 @@ protected AsyncGearsOfWarQueryRelationalTestBase(TFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalFixtureBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalFixtureBase.cs index 234440c588b..9dc9a06eacf 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalFixtureBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalFixtureBase.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public abstract class ComplexNavigationsQueryRelationalFixtureBase : ComplexNavigationsQueryFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalTestBase.cs index 7fccc22d82b..9f7932b2572 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalTestBase.cs @@ -26,7 +26,8 @@ public virtual Task Filtered_include_basic_Where_split(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.Where(l2 => l2.Id > 5)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(l2 => l2.Id > 5)))); @@ -39,7 +40,8 @@ public virtual Task Filtered_include_OrderBy_split(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.OrderBy(x => x.Name)))); @@ -55,7 +57,8 @@ public virtual Task Filtered_ThenInclude_OrderBy_split(bool async) .Include(l1 => l1.OneToMany_Optional1) .ThenInclude(l2 => l2.OneToMany_Optional2.OrderBy(x => x.Name)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToMany_Optional1), new ExpectedFilteredInclude( e => e.OneToMany_Optional2, @@ -73,7 +76,8 @@ public virtual Task Filtered_include_ThenInclude_OrderBy_split(bool async) .Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name)) .ThenInclude(l2 => l2.OneToMany_Optional2.OrderByDescending(x => x.Name)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.OrderBy(x => x.Name)), @@ -90,7 +94,8 @@ public virtual Task Filtered_include_basic_OrderBy_Take_split(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Take(3)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.OrderBy(x => x.Name).Take(3)))); @@ -103,7 +108,8 @@ public virtual Task Filtered_include_basic_OrderBy_Skip_split(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Skip(1)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.OrderBy(x => x.Name).Skip(1)))); @@ -116,7 +122,8 @@ public virtual Task Filtered_include_basic_OrderBy_Skip_Take_split(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Skip(1).Take(3)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.OrderBy(x => x.Name).Skip(1).Take(3)))); @@ -148,7 +155,8 @@ public virtual Task Filtered_include_on_ThenInclude_split(bool async) .Include(l1 => l1.OneToOne_Optional_FK1) .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToOne_Optional_FK1), new ExpectedFilteredInclude( e => e.OneToMany_Optional2, @@ -163,9 +171,11 @@ public virtual Task Filtered_include_after_reference_navigation_split(bool async return AssertQuery( async, ss => ss.Set() - .Include(l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)) + .Include( + l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToOne_Optional_FK1), new ExpectedFilteredInclude( e => e.OneToMany_Optional2, @@ -183,7 +193,8 @@ public virtual Task Filtered_include_after_different_filtered_include_same_level .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)) .Include(l1 => l1.OneToMany_Required1.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)), @@ -202,7 +213,8 @@ public virtual Task Filtered_include_after_different_filtered_include_different_ .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)) .ThenInclude(l2 => l2.OneToMany_Required2.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)), @@ -248,7 +260,8 @@ public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice_sp .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)) .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)))); @@ -261,10 +274,13 @@ public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice_fo return AssertQuery( async, ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)).ThenInclude(l2 => l2.OneToMany_Optional2) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)).ThenInclude(l2 => l2.OneToOne_Required_FK2) + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) + .ThenInclude(l2 => l2.OneToMany_Optional2) + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) + .ThenInclude(l2 => l2.OneToOne_Required_FK2) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)), @@ -274,17 +290,19 @@ public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice_fo [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(bool async) + public virtual Task + Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(bool async) { return AssertQuery( async, ss => ss.Set() .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) - .ThenInclude(l2 => l2.OneToMany_Optional2) + .ThenInclude(l2 => l2.OneToMany_Optional2) .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToOne_Required_FK2) + .ThenInclude(l2 => l2.OneToOne_Required_FK2) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)), @@ -302,7 +320,8 @@ public virtual Task Filtered_include_and_non_filtered_include_on_same_navigation .Include(l1 => l1.OneToMany_Optional1) .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)))); @@ -318,7 +337,8 @@ public virtual Task Filtered_include_and_non_filtered_include_on_same_navigation .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) .Include(l1 => l1.OneToMany_Optional1) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)))); @@ -332,9 +352,11 @@ public virtual Task Filtered_include_and_non_filtered_include_followed_by_then_i async, ss => ss.Set() .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2.OneToMany_Optional3.Where(x => x.Id > 1)) + .Include(l1 => l1.OneToMany_Optional1) + .ThenInclude(l2 => l2.OneToOne_Optional_PK2.OneToMany_Optional3.Where(x => x.Id > 1)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)), @@ -353,13 +375,14 @@ public virtual Task Filtered_include_complex_three_level_with_middle_having_filt async, ss => ss.Set() .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .ThenInclude(l3 => l3.OneToMany_Optional3) + .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) + .ThenInclude(l3 => l3.OneToMany_Optional3) .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .ThenInclude(l3 => l3.OneToMany_Required3) + .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) + .ThenInclude(l3 => l3.OneToMany_Required3) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToMany_Optional1), new ExpectedFilteredInclude( e => e.OneToMany_Optional2, @@ -377,13 +400,14 @@ public virtual Task Filtered_include_complex_three_level_with_middle_having_filt async, ss => ss.Set() .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)). - ThenInclude(l3 => l3.OneToMany_Optional3) + .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) + .ThenInclude(l3 => l3.OneToMany_Optional3) .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2) - .ThenInclude(l3 => l3.OneToMany_Required3) + .ThenInclude(l2 => l2.OneToMany_Optional2) + .ThenInclude(l3 => l3.OneToMany_Required3) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToMany_Optional1), new ExpectedFilteredInclude( e => e.OneToMany_Optional2, @@ -438,12 +462,13 @@ public virtual void Filtered_include_outer_parameter_used_inside_filter_split() { // TODO: needs #18191 for result verification using var ctx = CreateContext(); - var query = ctx.LevelOne.AsSplitQuery().Select(l1 => new - { - l1.Id, - FullInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2).ToList(), - FilteredInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2.Where(x => x.Id != l1.Id)).ToList() - }); + var query = ctx.LevelOne.AsSplitQuery().Select( + l1 => new + { + l1.Id, + FullInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2).ToList(), + FilteredInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2.Where(x => x.Id != l1.Id)).ToList() + }); var result = query.ToList(); } @@ -494,12 +519,8 @@ public virtual async Task Projecting_collection_with_FirstOrDefault_split_throws () => AssertFirstOrDefault( async, ss => ss.Set() - .AsSplitQuery() - .Select(e => new - { - e.Id, - Level2s = e.OneToMany_Optional1.ToList() - }), + .AsSplitQuery() + .Select(e => new { e.Id, Level2s = e.OneToMany_Optional1.ToList() }), predicate: l => l.Id == 1, asserter: (e, a) => { @@ -515,11 +536,7 @@ public virtual Task Projecting_collection_with_FirstOrDefault_without_split_work return AssertFirstOrDefault( async, ss => ss.Set() - .Select(e => new - { - e.Id, - Level2s = e.OneToMany_Optional1.ToList() - }), + .Select(e => new { e.Id, Level2s = e.OneToMany_Optional1.ToList() }), predicate: l => l.Id == 1, asserter: (e, a) => { @@ -528,9 +545,11 @@ public virtual Task Projecting_collection_with_FirstOrDefault_without_split_work }); } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsWeakQueryRelationalFixtureBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsWeakQueryRelationalFixtureBase.cs index 5b7478a8b39..87de2b70043 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsWeakQueryRelationalFixtureBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsWeakQueryRelationalFixtureBase.cs @@ -9,7 +9,8 @@ namespace Microsoft.EntityFrameworkCore.Query { public abstract class ComplexNavigationsWeakQueryRelationalFixtureBase : ComplexNavigationsWeakQueryFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsWeakQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsWeakQueryRelationalTestBase.cs index 5cc5ad81f15..f94cef0c6bf 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsWeakQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsWeakQueryRelationalTestBase.cs @@ -25,7 +25,8 @@ public virtual Task Filtered_include_basic_Where_split(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.Where(l2 => l2.Id > 5)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(l2 => l2.Id > 5)))); @@ -38,7 +39,8 @@ public virtual Task Filtered_include_OrderBy_split(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.OrderBy(x => x.Name)))); @@ -54,7 +56,8 @@ public virtual Task Filtered_ThenInclude_OrderBy_split(bool async) .Include(l1 => l1.OneToMany_Optional1) .ThenInclude(l2 => l2.OneToMany_Optional2.OrderBy(x => x.Name)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToMany_Optional1), new ExpectedFilteredInclude( e => e.OneToMany_Optional2, @@ -72,7 +75,8 @@ public virtual Task Filtered_include_ThenInclude_OrderBy_split(bool async) .Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name)) .ThenInclude(l2 => l2.OneToMany_Optional2.OrderByDescending(x => x.Name)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.OrderBy(x => x.Name)), @@ -89,7 +93,8 @@ public virtual Task Filtered_include_basic_OrderBy_Take_split(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Take(3)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.OrderBy(x => x.Name).Take(3)))); @@ -102,7 +107,8 @@ public virtual Task Filtered_include_basic_OrderBy_Skip_split(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Skip(1)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.OrderBy(x => x.Name).Skip(1)))); @@ -115,7 +121,8 @@ public virtual Task Filtered_include_basic_OrderBy_Skip_Take_split(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Skip(1).Take(3)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.OrderBy(x => x.Name).Skip(1).Take(3)))); @@ -147,7 +154,8 @@ public virtual Task Filtered_include_on_ThenInclude_split(bool async) .Include(l1 => l1.OneToOne_Optional_FK1) .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToOne_Optional_FK1), new ExpectedFilteredInclude( e => e.OneToMany_Optional2, @@ -162,9 +170,11 @@ public virtual Task Filtered_include_after_reference_navigation_split(bool async return AssertQuery( async, ss => ss.Set() - .Include(l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)) + .Include( + l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToOne_Optional_FK1), new ExpectedFilteredInclude( e => e.OneToMany_Optional2, @@ -182,7 +192,8 @@ public virtual Task Filtered_include_after_different_filtered_include_same_level .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)) .Include(l1 => l1.OneToMany_Required1.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)), @@ -201,7 +212,8 @@ public virtual Task Filtered_include_after_different_filtered_include_different_ .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)) .ThenInclude(l2 => l2.OneToMany_Required2.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)), @@ -247,7 +259,8 @@ public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice_sp .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)) .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)))); @@ -260,10 +273,13 @@ public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice_fo return AssertQuery( async, ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)).ThenInclude(l2 => l2.OneToMany_Optional2) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)).ThenInclude(l2 => l2.OneToOne_Required_FK2) + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) + .ThenInclude(l2 => l2.OneToMany_Optional2) + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) + .ThenInclude(l2 => l2.OneToOne_Required_FK2) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)), @@ -273,17 +289,19 @@ public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice_fo [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(bool async) + public virtual Task + Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(bool async) { return AssertQuery( async, ss => ss.Set() .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) - .ThenInclude(l2 => l2.OneToMany_Optional2) + .ThenInclude(l2 => l2.OneToMany_Optional2) .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToOne_Required_FK2) + .ThenInclude(l2 => l2.OneToOne_Required_FK2) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)), @@ -301,7 +319,8 @@ public virtual Task Filtered_include_and_non_filtered_include_on_same_navigation .Include(l1 => l1.OneToMany_Optional1) .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)))); @@ -317,7 +336,8 @@ public virtual Task Filtered_include_and_non_filtered_include_on_same_navigation .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) .Include(l1 => l1.OneToMany_Optional1) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)))); @@ -331,9 +351,11 @@ public virtual Task Filtered_include_and_non_filtered_include_followed_by_then_i async, ss => ss.Set() .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2.OneToMany_Optional3.Where(x => x.Id > 1)) + .Include(l1 => l1.OneToMany_Optional1) + .ThenInclude(l2 => l2.OneToOne_Optional_PK2.OneToMany_Optional3.Where(x => x.Id > 1)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)), @@ -352,13 +374,14 @@ public virtual Task Filtered_include_complex_three_level_with_middle_having_filt async, ss => ss.Set() .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .ThenInclude(l3 => l3.OneToMany_Optional3) + .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) + .ThenInclude(l3 => l3.OneToMany_Optional3) .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .ThenInclude(l3 => l3.OneToMany_Required3) + .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) + .ThenInclude(l3 => l3.OneToMany_Required3) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToMany_Optional1), new ExpectedFilteredInclude( e => e.OneToMany_Optional2, @@ -376,13 +399,14 @@ public virtual Task Filtered_include_complex_three_level_with_middle_having_filt async, ss => ss.Set() .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)). - ThenInclude(l3 => l3.OneToMany_Optional3) + .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) + .ThenInclude(l3 => l3.OneToMany_Optional3) .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2) - .ThenInclude(l3 => l3.OneToMany_Required3) + .ThenInclude(l2 => l2.OneToMany_Optional2) + .ThenInclude(l3 => l3.OneToMany_Required3) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToMany_Optional1), new ExpectedFilteredInclude( e => e.OneToMany_Optional2, @@ -437,12 +461,13 @@ public virtual void Filtered_include_outer_parameter_used_inside_filter_split() { // TODO: needs #18191 for result verification using var ctx = CreateContext(); - var query = ctx.LevelOne.AsSplitQuery().Select(l1 => new - { - l1.Id, - FullInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2).ToList(), - FilteredInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2.Where(x => x.Id != l1.Id)).ToList() - }); + var query = ctx.LevelOne.AsSplitQuery().Select( + l1 => new + { + l1.Id, + FullInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2).ToList(), + FilteredInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2.Where(x => x.Id != l1.Id)).ToList() + }); var result = query.ToList(); } @@ -482,9 +507,11 @@ public virtual async Task Filtered_include_calling_methods_directly_on_parameter .AsSplitQuery()))).Message; } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs index 8b46e6b75f9..c4a95627983 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs @@ -995,6 +995,7 @@ protected FormattableString NormalizeDelimitersInInterpolatedString(FormattableS protected abstract DbParameter CreateDbParameter(string name, object value); - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/FromSqlSprocQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/FromSqlSprocQueryTestBase.cs index 98cfe0ffff4..f8f41ade983 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/FromSqlSprocQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/FromSqlSprocQueryTestBase.cs @@ -15,7 +15,8 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class FromSqlSprocQueryTestBase : IClassFixture where TFixture : NorthwindQueryRelationalFixture, new() { - protected FromSqlSprocQueryTestBase(TFixture fixture) => Fixture = fixture; + protected FromSqlSprocQueryTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -453,7 +454,8 @@ protected virtual object[] GetTenMostExpensiveProductsParameters() protected virtual object[] GetCustomerOrderHistorySprocParameters() => new[] { "ALFKI" }; - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); protected abstract string TenMostExpensiveProductsSproc { get; } diff --git a/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarFromSqlQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarFromSqlQueryTestBase.cs index ca71e0d8e02..f47f4c3f39d 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarFromSqlQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarFromSqlQueryTestBase.cs @@ -12,7 +12,8 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class GearsOfWarFromSqlQueryTestBase : IClassFixture where TFixture : GearsOfWarQueryRelationalFixture, new() { - protected GearsOfWarFromSqlQueryTestBase(TFixture fixture) => Fixture = fixture; + protected GearsOfWarFromSqlQueryTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -39,7 +40,8 @@ private string NormalizeDelimitersInRawString(string sql) private FormattableString NormalizeDelimitersInInterpolatedString(FormattableString sql) => Fixture.TestStore.NormalizeDelimitersInInterpolatedString(sql); - protected GearsOfWarContext CreateContext() => Fixture.CreateContext(); + protected GearsOfWarContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { diff --git a/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs index 192fa104000..76ce6d5cf86 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalFixture.cs @@ -7,9 +7,11 @@ namespace Microsoft.EntityFrameworkCore.Query { public abstract class GearsOfWarQueryRelationalFixture : GearsOfWarQueryFixtureBase { - public new RelationalTestStore TestStore => (RelationalTestStore)base.TestStore; + public new RelationalTestStore TestStore + => (RelationalTestStore)base.TestStore; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; protected override bool ShouldLogCategory(string logCategory) => logCategory == DbLoggerCategory.Query.Name; diff --git a/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalTestBase.cs index bc861a5a56d..20f516316ea 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/GearsOfWarQueryRelationalTestBase.cs @@ -13,9 +13,11 @@ protected GearsOfWarQueryRelationalTestBase(TFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/InheritanceQueryRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/Query/InheritanceQueryRelationalFixture.cs index 0a9df9b8115..118ae147434 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/InheritanceQueryRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/InheritanceQueryRelationalFixture.cs @@ -8,7 +8,8 @@ namespace Microsoft.EntityFrameworkCore.Query { public abstract class InheritanceQueryRelationalFixture : InheritanceQueryFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationalQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationalQueryTestBase.cs index b55262bfac4..cc14ad0d951 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationalQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationalQueryTestBase.cs @@ -53,11 +53,7 @@ private void GetEntityWithAuditHistoryQuery(InheritanceContext context, IQuer var joinQuery = from animal in animalQuery join keylessanimal in queryTypeQuery on animal.Name equals keylessanimal.Name - select new - { - animal, - keylessanimal - }; + select new { animal, keylessanimal }; var result = joinQuery.ToList(); diff --git a/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationshipsQueryRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationshipsQueryRelationalFixture.cs index dea0085639c..491191fdb49 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationshipsQueryRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationshipsQueryRelationalFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public abstract class InheritanceRelationshipsQueryRelationalFixture : InheritanceRelationshipsQueryFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationshipsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationshipsQueryRelationalTestBase.cs index 8ea0d5b0d65..bf4aaa5c1a4 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationshipsQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/InheritanceRelationshipsQueryRelationalTestBase.cs @@ -24,8 +24,9 @@ public virtual Task Include_collection_with_inheritance_split(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.BaseCollectionOnBase).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, - new ExpectedInclude(x => x.BaseCollectionOnBase))); + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedInclude(x => x.BaseCollectionOnBase))); } [ConditionalTheory] @@ -35,8 +36,9 @@ public virtual Task Include_collection_with_inheritance_reverse_split(bool async return AssertQuery( async, ss => ss.Set().Include(e => e.BaseParent).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, - new ExpectedInclude(x => x.BaseParent))); + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedInclude(x => x.BaseParent))); } [ConditionalTheory] @@ -45,8 +47,10 @@ public virtual Task Include_collection_with_inheritance_with_filter_split(bool a { return AssertQuery( async, - ss => ss.Set().Include(e => e.BaseCollectionOnBase).Where(e => e.Name != "Bar").AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + ss => ss.Set().Include(e => e.BaseCollectionOnBase).Where(e => e.Name != "Bar") + .AsSplitQuery(), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseCollectionOnBase))); } @@ -57,7 +61,8 @@ public virtual Task Include_collection_with_inheritance_with_filter_reverse_spli return AssertQuery( async, ss => ss.Set().Include(e => e.BaseParent).Where(e => e.Name != "Bar").AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseParent))); } @@ -68,7 +73,8 @@ public virtual Task Include_collection_without_inheritance_split(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.CollectionOnBase).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.CollectionOnBase))); } @@ -79,7 +85,8 @@ public virtual Task Include_collection_without_inheritance_reverse_split(bool as return AssertQuery( async, ss => ss.Set().Include(e => e.Parent).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.Parent))); } @@ -89,8 +96,10 @@ public virtual Task Include_collection_without_inheritance_with_filter_split(boo { return AssertQuery( async, - ss => ss.Set().Include(e => e.CollectionOnBase).Where(e => e.Name != "Bar").AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + ss => ss.Set().Include(e => e.CollectionOnBase).Where(e => e.Name != "Bar") + .AsSplitQuery(), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.CollectionOnBase))); } @@ -101,7 +110,8 @@ public virtual Task Include_collection_without_inheritance_with_filter_reverse_s return AssertQuery( async, ss => ss.Set().Include(e => e.Parent).Where(e => e.Name != "Bar").AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.Parent))); } @@ -112,7 +122,8 @@ public virtual Task Include_collection_with_inheritance_on_derived1_split(bool a return AssertQuery( async, ss => ss.Set().Include(e => e.BaseCollectionOnBase).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseCollectionOnBase))); } @@ -123,7 +134,8 @@ public virtual Task Include_collection_with_inheritance_on_derived2_split(bool a return AssertQuery( async, ss => ss.Set().Include(e => e.BaseCollectionOnDerived).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseCollectionOnDerived))); } @@ -134,7 +146,8 @@ public virtual Task Include_collection_with_inheritance_on_derived3_split(bool a return AssertQuery( async, ss => ss.Set().Include(e => e.DerivedCollectionOnDerived).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.DerivedCollectionOnDerived))); } @@ -145,7 +158,8 @@ public virtual Task Include_collection_with_inheritance_on_derived_reverse_split return AssertQuery( async, ss => ss.Set().Include(e => e.BaseParent).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseParent))); } @@ -156,7 +170,8 @@ public virtual Task Nested_include_with_inheritance_reference_collection_split(b return AssertQuery( async, ss => ss.Set().Include(e => e.BaseReferenceOnBase.NestedCollection).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseReferenceOnBase), new ExpectedInclude(x => x.NestedCollection))); } @@ -168,7 +183,8 @@ public virtual Task Nested_include_with_inheritance_reference_collection_on_base return AssertQuery( async, ss => ss.Set().Include(e => e.BaseReferenceOnBase.NestedCollection).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseReferenceOnBase), new ExpectedInclude(x => x.NestedCollection))); } @@ -180,7 +196,8 @@ public virtual Task Nested_include_with_inheritance_reference_collection_reverse return AssertQuery( async, ss => ss.Set().Include(e => e.ParentReference.BaseParent).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.ParentReference), new ExpectedInclude(x => x.BaseParent))); } @@ -193,7 +210,8 @@ public virtual Task Nested_include_with_inheritance_collection_reference_split(b async, ss => ss.Set().Include(e => e.BaseCollectionOnBase) .ThenInclude(e => e.NestedReference).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseCollectionOnBase), new ExpectedInclude(x => x.NestedReference))); } @@ -205,7 +223,8 @@ public virtual Task Nested_include_with_inheritance_collection_reference_reverse return AssertQuery( async, ss => ss.Set().Include(e => e.ParentCollection.BaseParent).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.ParentCollection), new ExpectedInclude(x => x.BaseParent))); } @@ -218,7 +237,8 @@ public virtual Task Nested_include_with_inheritance_collection_collection_split( async, ss => ss.Set().Include(e => e.BaseCollectionOnBase) .ThenInclude(e => e.NestedCollection).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseCollectionOnBase), new ExpectedInclude(x => x.NestedCollection))); } @@ -230,7 +250,8 @@ public virtual Task Nested_include_with_inheritance_collection_collection_revers return AssertQuery( async, ss => ss.Set().Include(e => e.ParentCollection.BaseParent).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.ParentCollection), new ExpectedInclude(x => x.BaseParent))); } @@ -242,7 +263,8 @@ public virtual Task Nested_include_collection_reference_on_non_entity_base_split return AssertQuery( async, ss => ss.Set().Include(e => e.Principals).ThenInclude(e => e.Reference).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.Principals), new ExpectedInclude(x => x.Reference))); } @@ -253,12 +275,9 @@ public virtual Task Collection_projection_on_base_type_split(bool async) { return AssertQuery( async, - ss => ss.Set().AsSplitQuery().Select(e => - new - { - e.Id, - e.BaseCollectionOnBase - }), + ss => ss.Set().AsSplitQuery().Select( + e => + new { e.Id, e.BaseCollectionOnBase }), elementSorter: e => e.Id, elementAsserter: (e, a) => { diff --git a/test/EFCore.Relational.Specification.Tests/Query/ManyToManyNoTrackingQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ManyToManyNoTrackingQueryRelationalTestBase.cs index 3bc5c2375bd..be7ca87caa4 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/ManyToManyNoTrackingQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/ManyToManyNoTrackingQueryRelationalTestBase.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.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.ManyToManyModel; @@ -18,7 +17,8 @@ protected ManyToManyNoTrackingQueryRelationalTestBase(TFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -37,7 +37,8 @@ public virtual Task Include_skip_navigation_then_reference_split(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.OneSkip).ThenInclude(e => e.Reference).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.OneSkip), new ExpectedInclude(et => et.Reference, "OneSkip"))); } @@ -49,7 +50,8 @@ public virtual Task Include_skip_navigation_then_include_skip_navigation_split(b return AssertQuery( async, ss => ss.Set().Include(e => e.LeafSkipFull).ThenInclude(e => e.OneSkip).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.LeafSkipFull), new ExpectedInclude(et => et.OneSkip, "LeafSkipFull"))); } @@ -62,7 +64,8 @@ public virtual Task Include_skip_navigation_then_include_reference_and_skip_navi async, ss => ss.Set().Include(e => e.OneSkipPayloadFull).ThenInclude(e => e.Reference) .Include(e => e.OneSkipPayloadFull).ThenInclude(e => e.SelfSkipPayloadRight).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.OneSkipPayloadFull), new ExpectedInclude(et => et.Reference, "OneSkipPayloadFull"), new ExpectedInclude(et => et.SelfSkipPayloadRight, "OneSkipPayloadFull"))); @@ -75,7 +78,8 @@ public virtual Task Include_skip_navigation_and_reference_split(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.OneSkipShared).Include(e => e.Reference).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.OneSkipShared), new ExpectedInclude(et => et.Reference))); } @@ -87,7 +91,8 @@ public virtual Task Filtered_include_skip_navigation_where_split(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.OneSkipPayloadFullShared.Where(i => i.Id < 10)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.OneSkipPayloadFullShared, includeFilter: x => x.Where(i => i.Id < 10)))); } @@ -99,7 +104,8 @@ public virtual Task Filtered_include_skip_navigation_order_by_split(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.TwoSkipFull.OrderBy(i => i.Id)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.TwoSkipFull, includeFilter: x => x.OrderBy(i => i.Id)))); } @@ -111,7 +117,8 @@ public virtual Task Filtered_include_skip_navigation_order_by_skip_split(bool as return AssertQuery( async, ss => ss.Set().Include(e => e.SelfSkipSharedRight.OrderBy(i => i.Id).Skip(2)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.SelfSkipSharedRight, includeFilter: x => x.OrderBy(i => i.Id).Skip(2)))); } @@ -123,7 +130,8 @@ public virtual Task Filtered_include_skip_navigation_order_by_take_split(bool as return AssertQuery( async, ss => ss.Set().Include(e => e.TwoSkipShared.OrderBy(i => i.Id).Take(2)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.TwoSkipShared, includeFilter: x => x.OrderBy(i => i.Id).Take(2)))); } @@ -135,7 +143,8 @@ public virtual Task Filtered_include_skip_navigation_order_by_skip_take_split(bo return AssertQuery( async, ss => ss.Set().Include(e => e.ThreeSkipFull.OrderBy(i => i.Id).Skip(1).Take(2)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.ThreeSkipFull, includeFilter: x => x.OrderBy(i => i.Id).Skip(1).Take(2)))); } @@ -149,7 +158,8 @@ public virtual Task Filtered_then_include_skip_navigation_where_split(bool async ss => ss.Set().Include(e => e.ThreeSkipShared) .ThenInclude(e => e.OneSkipPayloadFullShared.Where(i => i.Id < 10)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.ThreeSkipShared), new ExpectedFilteredInclude( et => et.OneSkipPayloadFullShared, "ThreeSkipShared", includeFilter: x => x.Where(i => i.Id < 10)))); @@ -164,7 +174,8 @@ public virtual Task Filtered_then_include_skip_navigation_order_by_skip_take_spl ss => ss.Set().Include(e => e.CompositeKeySkipShared) .ThenInclude(e => e.ThreeSkipFull.OrderBy(i => i.Id).Skip(1).Take(2)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.CompositeKeySkipShared), new ExpectedFilteredInclude( et => et.ThreeSkipFull, "CompositeKeySkipShared", includeFilter: x => x.OrderBy(i => i.Id).Skip(1).Take(2)))); @@ -178,7 +189,8 @@ public virtual Task Filtered_include_skip_navigation_where_then_include_skip_nav async, ss => ss.Set().Include(e => e.CompositeKeySkipFull.Where(i => i.Key1 < 5)) .ThenInclude(e => e.TwoSkipShared).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.CompositeKeySkipFull, includeFilter: x => x.Where(i => i.Key1 < 5)), new ExpectedInclude(et => et.TwoSkipShared, "CompositeKeySkipFull"))); @@ -193,7 +205,8 @@ public virtual Task Filtered_include_skip_navigation_order_by_skip_take_then_inc ss => ss.Set().Include(e => e.TwoSkip.OrderBy(i => i.Id).Skip(1).Take(2)) .ThenInclude(e => e.ThreeSkipFull.Where(i => i.Id < 10)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.TwoSkip, includeFilter: x => x.OrderBy(i => i.Id).Skip(1).Take(2)), new ExpectedFilteredInclude( @@ -209,7 +222,8 @@ public virtual Task Filtered_include_skip_navigation_where_then_include_skip_nav ss => ss.Set().Include(e => e.TwoSkip.Where(i => i.Id < 10)) .ThenInclude(e => e.ThreeSkipFull.OrderBy(i => i.Id).Skip(1).Take(2)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.TwoSkip, includeFilter: x => x.Where(i => i.Id < 10)), new ExpectedFilteredInclude( @@ -225,7 +239,8 @@ public virtual Task Filter_include_on_skip_navigation_combined_split(bool async) ss => ss.Set().Include(e => e.OneSkip.Where(i => i.Id < 10)).ThenInclude(e => e.Reference) .Include(e => e.OneSkip).ThenInclude(e => e.Collection) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude(et => et.OneSkip, includeFilter: x => x.Where(i => i.Id < 10)), new ExpectedInclude(et => et.Reference, "OneSkip"), new ExpectedInclude(et => et.Collection, "OneSkip"))); @@ -239,14 +254,18 @@ public virtual Task Filter_include_on_skip_navigation_combined_with_filtered_the async, ss => ss.Set() .Include(e => e.OneSkipPayloadFull.Where(i => i.Id < 10)) - .ThenInclude(e => e.TwoSkip.OrderBy(e => e.Id).Skip(1).Take(2)) + .ThenInclude(e => e.TwoSkip.OrderBy(e => e.Id).Skip(1).Take(2)) .Include(e => e.OneSkipPayloadFull) - .ThenInclude(e => e.BranchSkip.Where(e => e.Id < 20)) + .ThenInclude(e => e.BranchSkip.Where(e => e.Id < 20)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, - new ExpectedFilteredInclude(et => et.OneSkipPayloadFull, includeFilter: x => x.Where(i => i.Id < 10)), - new ExpectedFilteredInclude(et => et.TwoSkip, "OneSkipPayloadFull", includeFilter: x => x.OrderBy(e => e.Id).Skip(1).Take(2)), - new ExpectedFilteredInclude(et => et.BranchSkip, "OneSkipPayloadFull", includeFilter: x => x.Where(e => e.Id < 20)))); + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + et => et.OneSkipPayloadFull, includeFilter: x => x.Where(i => i.Id < 10)), + new ExpectedFilteredInclude( + et => et.TwoSkip, "OneSkipPayloadFull", includeFilter: x => x.OrderBy(e => e.Id).Skip(1).Take(2)), + new ExpectedFilteredInclude( + et => et.BranchSkip, "OneSkipPayloadFull", includeFilter: x => x.Where(e => e.Id < 20)))); } [ConditionalTheory] @@ -258,9 +277,12 @@ public virtual Task Filtered_include_on_skip_navigation_then_filtered_include_on ss => ss.Set().Include(e => e.OneSkipPayloadFull.Where(i => i.Id > 15)) .ThenInclude(e => e.Collection.Where(i => i.Id < 5)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, - new ExpectedFilteredInclude(et => et.OneSkipPayloadFull, includeFilter: x => x.Where(i => i.Id > 15)), - new ExpectedFilteredInclude(et => et.Collection, "OneSkipPayloadFull", includeFilter: x => x.Where(i => i.Id < 5)))); + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + et => et.OneSkipPayloadFull, includeFilter: x => x.Where(i => i.Id > 15)), + new ExpectedFilteredInclude( + et => et.Collection, "OneSkipPayloadFull", includeFilter: x => x.Where(i => i.Id < 5)))); } [ConditionalTheory] @@ -272,9 +294,11 @@ public virtual Task Filtered_include_on_navigation_then_filtered_include_on_skip ss => ss.Set().Include(e => e.Collection.Where(i => i.Id > 15)) .ThenInclude(e => e.ThreeSkipFull.Where(i => i.Id < 5)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude(et => et.Collection, includeFilter: x => x.Where(i => i.Id > 15)), - new ExpectedFilteredInclude(et => et.ThreeSkipFull, "Collection", includeFilter: x => x.Where(i => i.Id < 5)))); + new ExpectedFilteredInclude( + et => et.ThreeSkipFull, "Collection", includeFilter: x => x.Where(i => i.Id < 5)))); } protected override QueryAsserter CreateQueryAsserter(TFixture fixture) diff --git a/test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalFixture.cs index 85879b0abbd..d60594aeb12 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public abstract class ManyToManyQueryRelationalFixture : ManyToManyQueryFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalTestBase.cs index 2a0a9fa4ac1..f686aa690bb 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/ManyToManyQueryRelationalTestBase.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.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.ManyToManyModel; @@ -18,7 +17,8 @@ protected ManyToManyQueryRelationalTestBase(TFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -38,7 +38,8 @@ public virtual Task Include_skip_navigation_then_reference_split(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.OneSkip).ThenInclude(e => e.Reference).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.OneSkip), new ExpectedInclude(et => et.Reference, "OneSkip")), entryCount: 151); @@ -51,7 +52,8 @@ public virtual Task Include_skip_navigation_then_include_skip_navigation_split(b return AssertQuery( async, ss => ss.Set().Include(e => e.LeafSkipFull).ThenInclude(e => e.OneSkip).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.LeafSkipFull), new ExpectedInclude(et => et.OneSkip, "LeafSkipFull")), entryCount: 83); @@ -65,7 +67,8 @@ public virtual Task Include_skip_navigation_then_include_reference_and_skip_navi async, ss => ss.Set().Include(e => e.OneSkipPayloadFull).ThenInclude(e => e.Reference) .Include(e => e.OneSkipPayloadFull).ThenInclude(e => e.SelfSkipPayloadRight).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.OneSkipPayloadFull), new ExpectedInclude(et => et.Reference, "OneSkipPayloadFull"), new ExpectedInclude(et => et.SelfSkipPayloadRight, "OneSkipPayloadFull")), @@ -79,7 +82,8 @@ public virtual Task Include_skip_navigation_and_reference_split(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.OneSkipShared).Include(e => e.Reference).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.OneSkipShared), new ExpectedInclude(et => et.Reference)), entryCount: 93); @@ -92,7 +96,8 @@ public virtual Task Filtered_include_skip_navigation_where_split(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.OneSkipPayloadFullShared.Where(i => i.Id < 10)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.OneSkipPayloadFullShared, includeFilter: x => x.Where(i => i.Id < 10))), entryCount: 42); @@ -105,7 +110,8 @@ public virtual Task Filtered_include_skip_navigation_order_by_split(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.TwoSkipFull.OrderBy(i => i.Id)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.TwoSkipFull, includeFilter: x => x.OrderBy(i => i.Id))), entryCount: 91); @@ -118,7 +124,8 @@ public virtual Task Filtered_include_skip_navigation_order_by_skip_split(bool as return AssertQuery( async, ss => ss.Set().Include(e => e.SelfSkipSharedRight.OrderBy(i => i.Id).Skip(2)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.SelfSkipSharedRight, includeFilter: x => x.OrderBy(i => i.Id).Skip(2))), entryCount: 31); @@ -131,7 +138,8 @@ public virtual Task Filtered_include_skip_navigation_order_by_take_split(bool as return AssertQuery( async, ss => ss.Set().Include(e => e.TwoSkipShared.OrderBy(i => i.Id).Take(2)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.TwoSkipShared, includeFilter: x => x.OrderBy(i => i.Id).Take(2))), entryCount: 63); @@ -144,7 +152,8 @@ public virtual Task Filtered_include_skip_navigation_order_by_skip_take_split(bo return AssertQuery( async, ss => ss.Set().Include(e => e.ThreeSkipFull.OrderBy(i => i.Id).Skip(1).Take(2)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.ThreeSkipFull, includeFilter: x => x.OrderBy(i => i.Id).Skip(1).Take(2))), entryCount: 57); @@ -159,7 +168,8 @@ public virtual Task Filtered_then_include_skip_navigation_where_split(bool async ss => ss.Set().Include(e => e.ThreeSkipShared) .ThenInclude(e => e.OneSkipPayloadFullShared.Where(i => i.Id < 10)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.ThreeSkipShared), new ExpectedFilteredInclude( et => et.OneSkipPayloadFullShared, "ThreeSkipShared", includeFilter: x => x.Where(i => i.Id < 10))), @@ -175,7 +185,8 @@ public virtual Task Filtered_then_include_skip_navigation_order_by_skip_take_spl ss => ss.Set().Include(e => e.CompositeKeySkipShared) .ThenInclude(e => e.ThreeSkipFull.OrderBy(i => i.Id).Skip(1).Take(2)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.CompositeKeySkipShared), new ExpectedFilteredInclude( et => et.ThreeSkipFull, "CompositeKeySkipShared", includeFilter: x => x.OrderBy(i => i.Id).Skip(1).Take(2))), @@ -190,7 +201,8 @@ public virtual Task Filtered_include_skip_navigation_where_then_include_skip_nav async, ss => ss.Set().Include(e => e.CompositeKeySkipFull.Where(i => i.Key1 < 5)) .ThenInclude(e => e.TwoSkipShared).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.CompositeKeySkipFull, includeFilter: x => x.Where(i => i.Key1 < 5)), new ExpectedInclude(et => et.TwoSkipShared, "CompositeKeySkipFull")), @@ -206,7 +218,8 @@ public virtual Task Filtered_include_skip_navigation_order_by_skip_take_then_inc ss => ss.Set().Include(e => e.TwoSkip.OrderBy(i => i.Id).Skip(1).Take(2)) .ThenInclude(e => e.ThreeSkipFull.Where(i => i.Id < 10)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.TwoSkip, includeFilter: x => x.OrderBy(i => i.Id).Skip(1).Take(2)), new ExpectedFilteredInclude( @@ -223,7 +236,8 @@ public virtual Task Filtered_include_skip_navigation_where_then_include_skip_nav ss => ss.Set().Include(e => e.TwoSkip.Where(i => i.Id < 10)) .ThenInclude(e => e.ThreeSkipFull.OrderBy(i => i.Id).Skip(1).Take(2)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.TwoSkip, includeFilter: x => x.Where(i => i.Id < 10)), new ExpectedFilteredInclude( @@ -240,7 +254,8 @@ public virtual Task Filter_include_on_skip_navigation_combined_split(bool async) ss => ss.Set().Include(e => e.OneSkip.Where(i => i.Id < 10)).ThenInclude(e => e.Reference) .Include(e => e.OneSkip).ThenInclude(e => e.Collection) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude(et => et.OneSkip, includeFilter: x => x.Where(i => i.Id < 10)), new ExpectedInclude(et => et.Reference, "OneSkip"), new ExpectedInclude(et => et.Collection, "OneSkip")), @@ -255,14 +270,18 @@ public virtual Task Filter_include_on_skip_navigation_combined_with_filtered_the async, ss => ss.Set() .Include(e => e.OneSkipPayloadFull.Where(i => i.Id < 10)) - .ThenInclude(e => e.TwoSkip.OrderBy(e => e.Id).Skip(1).Take(2)) + .ThenInclude(e => e.TwoSkip.OrderBy(e => e.Id).Skip(1).Take(2)) .Include(e => e.OneSkipPayloadFull) - .ThenInclude(e => e.BranchSkip.Where(e => e.Id < 20)) + .ThenInclude(e => e.BranchSkip.Where(e => e.Id < 20)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, - new ExpectedFilteredInclude(et => et.OneSkipPayloadFull, includeFilter: x => x.Where(i => i.Id < 10)), - new ExpectedFilteredInclude(et => et.TwoSkip, "OneSkipPayloadFull", includeFilter: x => x.OrderBy(e => e.Id).Skip(1).Take(2)), - new ExpectedFilteredInclude(et => et.BranchSkip, "OneSkipPayloadFull", includeFilter: x => x.Where(e => e.Id < 20))), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + et => et.OneSkipPayloadFull, includeFilter: x => x.Where(i => i.Id < 10)), + new ExpectedFilteredInclude( + et => et.TwoSkip, "OneSkipPayloadFull", includeFilter: x => x.OrderBy(e => e.Id).Skip(1).Take(2)), + new ExpectedFilteredInclude( + et => et.BranchSkip, "OneSkipPayloadFull", includeFilter: x => x.Where(e => e.Id < 20))), entryCount: 116); } @@ -275,9 +294,12 @@ public virtual Task Filtered_include_on_skip_navigation_then_filtered_include_on ss => ss.Set().Include(e => e.OneSkipPayloadFull.Where(i => i.Id > 15)) .ThenInclude(e => e.Collection.Where(i => i.Id < 5)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, - new ExpectedFilteredInclude(et => et.OneSkipPayloadFull, includeFilter: x => x.Where(i => i.Id > 15)), - new ExpectedFilteredInclude(et => et.Collection, "OneSkipPayloadFull", includeFilter: x => x.Where(i => i.Id < 5))), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + et => et.OneSkipPayloadFull, includeFilter: x => x.Where(i => i.Id > 15)), + new ExpectedFilteredInclude( + et => et.Collection, "OneSkipPayloadFull", includeFilter: x => x.Where(i => i.Id < 5))), entryCount: 61); } @@ -290,9 +312,11 @@ public virtual Task Filtered_include_on_navigation_then_filtered_include_on_skip ss => ss.Set().Include(e => e.Collection.Where(i => i.Id > 15)) .ThenInclude(e => e.ThreeSkipFull.Where(i => i.Id < 5)) .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude(et => et.Collection, includeFilter: x => x.Where(i => i.Id > 15)), - new ExpectedFilteredInclude(et => et.ThreeSkipFull, "Collection", includeFilter: x => x.Where(i => i.Id < 5))), + new ExpectedFilteredInclude( + et => et.ThreeSkipFull, "Collection", includeFilter: x => x.Where(i => i.Id < 5))), entryCount: 29); } diff --git a/test/EFCore.Relational.Specification.Tests/Query/MappingQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/MappingQueryTestBase.cs index 9a078513235..13ffd1f358e 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/MappingQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/MappingQueryTestBase.cs @@ -12,7 +12,8 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class MappingQueryTestBase : IClassFixture where TFixture : MappingQueryTestBase.MappingQueryFixtureBase, new() { - protected MappingQueryTestBase(MappingQueryFixtureBase fixture) => Fixture = fixture; + protected MappingQueryTestBase(MappingQueryFixtureBase fixture) + => Fixture = fixture; protected MappingQueryFixtureBase Fixture { get; } @@ -61,7 +62,8 @@ var orders Assert.Equal(830, orders.Count); } - protected virtual DbContext CreateContext() => Fixture.CreateContext(); + protected virtual DbContext CreateContext() + => Fixture.CreateContext(); protected class MappedCustomer : Customer { @@ -89,7 +91,9 @@ public abstract class MappingQueryFixtureBase : SharedStoreFixtureBase (TestSqlLoggerFactory)ListLoggerFactory; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindAggregateOperatorsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindAggregateOperatorsQueryRelationalTestBase.cs index e55c2e932b3..e2c4381a99f 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindAggregateOperatorsQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindAggregateOperatorsQueryRelationalTestBase.cs @@ -20,21 +20,25 @@ protected NorthwindAggregateOperatorsQueryRelationalTestBase(TFixture fixture) public override async Task Last_when_no_order_by(bool async) { - Assert.Equal(RelationalStrings.LastUsedWithoutOrderBy(nameof(Enumerable.Last)), + Assert.Equal( + RelationalStrings.LastUsedWithoutOrderBy(nameof(Enumerable.Last)), (await Assert.ThrowsAsync( () => base.Last_when_no_order_by(async))).Message); } public override async Task LastOrDefault_when_no_order_by(bool async) { - Assert.Equal(RelationalStrings.LastUsedWithoutOrderBy(nameof(Enumerable.LastOrDefault)), + Assert.Equal( + RelationalStrings.LastUsedWithoutOrderBy(nameof(Enumerable.LastOrDefault)), (await Assert.ThrowsAsync( () => base.LastOrDefault_when_no_order_by(async))).Message); } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindAsyncSimpleQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindAsyncSimpleQueryRelationalTestBase.cs index f30fc44da96..a931ffd8e0a 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindAsyncSimpleQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindAsyncSimpleQueryRelationalTestBase.cs @@ -13,9 +13,11 @@ protected NorthwindAsyncSimpleQueryRelationalTestBase(TFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs index 71edfd71749..0c65ff44a44 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs @@ -13,9 +13,11 @@ protected NorthwindFunctionsQueryRelationalTestBase(TFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindGroupByQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindGroupByQueryRelationalTestBase.cs index 5181fcbfb97..25878619825 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindGroupByQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindGroupByQueryRelationalTestBase.cs @@ -13,9 +13,11 @@ protected NorthwindGroupByQueryRelationalTestBase(TFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindIncludeQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindIncludeQueryRelationalTestBase.cs index 4989ae384b7..de871a5eee8 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindIncludeQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindIncludeQueryRelationalTestBase.cs @@ -26,9 +26,11 @@ public override async Task Include_collection_with_last_no_orderby(bool async) () => base.Include_collection_with_last_no_orderby(async))).Message); } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindJoinQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindJoinQueryRelationalTestBase.cs index 959ecab376b..144a305cca9 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindJoinQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindJoinQueryRelationalTestBase.cs @@ -13,9 +13,11 @@ protected NorthwindJoinQueryRelationalTestBase(TFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindKeylessEntitiesQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindKeylessEntitiesQueryRelationalTestBase.cs index ba4297bf27b..0a3403b922c 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindKeylessEntitiesQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindKeylessEntitiesQueryRelationalTestBase.cs @@ -19,7 +19,8 @@ protected NorthwindKeylessEntitiesQueryRelationalTestBase(TFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -28,17 +29,19 @@ public virtual async Task Projecting_collection_correlated_with_keyless_entity_t var message = (await Assert.ThrowsAsync( () => AssertQuery( async, - ss => ss.Set().Select(cq => new - { - cq.City, - cq.CompanyName, - OrderDetailIds = ss.Set().Where(c => c.City == cq.City).ToList() - }).OrderBy(x => x.City).Take(2)))).Message; + ss => ss.Set().Select( + cq => new + { + cq.City, + cq.CompanyName, + OrderDetailIds = ss.Set().Where(c => c.City == cq.City).ToList() + }).OrderBy(x => x.City).Take(2)))).Message; Assert.Equal(RelationalStrings.ProjectingCollectionOnKeylessEntityNotSupported, message); } protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindMiscellaneousQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindMiscellaneousQueryRelationalTestBase.cs index 4b727bf4378..98472ea4351 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindMiscellaneousQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindMiscellaneousQueryRelationalTestBase.cs @@ -1,11 +1,11 @@ // 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 System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; -using System.Linq; namespace Microsoft.EntityFrameworkCore.Query { @@ -23,7 +23,8 @@ public virtual Task Projecting_collection_split(bool async) { return AssertQuery( async, - ss => ss.Set().Where(c => c.CustomerID.StartsWith("F")).OrderBy(e => e.CustomerID).AsSplitQuery().Select(c => c.Orders), + ss => ss.Set().Where(c => c.CustomerID.StartsWith("F")).OrderBy(e => e.CustomerID).AsSplitQuery() + .Select(c => c.Orders), assertOrder: true, elementAsserter: (e, a) => AssertCollection(e, a), entryCount: 63); @@ -39,14 +40,17 @@ public virtual Task Projecting_collection_then_include_split(bool async) .Include(c => c.Orders).ThenInclude(o => o.OrderDetails) .OrderBy(e => e.CustomerID).AsSplitQuery().Select(c => c.Orders), assertOrder: true, - elementAsserter: (e, a) => AssertCollection(e, a, + elementAsserter: (e, a) => AssertCollection( + e, a, elementAsserter: (eo, ao) => AssertInclude(eo, ao, new ExpectedInclude(o => o.OrderDetails))), entryCount: 227); } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindNavigationsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindNavigationsQueryRelationalTestBase.cs index aa6a77c6058..25efeb79136 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindNavigationsQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindNavigationsQueryRelationalTestBase.cs @@ -13,9 +13,11 @@ protected NorthwindNavigationsQueryRelationalTestBase(TFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindQueryRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindQueryRelationalFixture.cs index b8dab4d69b9..923c76ec4d2 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindQueryRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindQueryRelationalFixture.cs @@ -12,8 +12,11 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class NorthwindQueryRelationalFixture : NorthwindQueryFixtureBase where TModelCustomizer : IModelCustomizer, new() { - public new RelationalTestStore TestStore => (RelationalTestStore)base.TestStore; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public new RelationalTestStore TestStore + => (RelationalTestStore)base.TestStore; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder).ConfigureWarnings( @@ -24,6 +27,7 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build protected override bool ShouldLogCategory(string logCategory) => logCategory == DbLoggerCategory.Query.Name; - protected override Type ContextType => typeof(NorthwindRelationalContext); + protected override Type ContextType + => typeof(NorthwindRelationalContext); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindSelectQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindSelectQueryRelationalTestBase.cs index 812b97a8183..d81b1ab40fd 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindSelectQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindSelectQueryRelationalTestBase.cs @@ -13,9 +13,11 @@ protected NorthwindSelectQueryRelationalTestBase(TFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindSetOperationsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindSetOperationsQueryRelationalTestBase.cs index 05ebd6546f2..21c3ff6face 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindSetOperationsQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindSetOperationsQueryRelationalTestBase.cs @@ -13,9 +13,11 @@ protected NorthwindSetOperationsQueryRelationalTestBase(TFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindSplitIncludeNoTrackingQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindSplitIncludeNoTrackingQueryTestBase.cs index 33a6d419132..3b5ff51619a 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindSplitIncludeNoTrackingQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindSplitIncludeNoTrackingQueryTestBase.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.Data; using System.Linq; using System.Linq.Expressions; using System.Reflection; @@ -109,8 +108,10 @@ public override async Task Include_reference_dependent_already_tracked(bool asyn var orders = async - ? await context.Set().Include(o => o.Customer).AsNoTracking().AsSplitQuery().Where(o => o.CustomerID == "ALFKI").ToListAsync() - : context.Set().Include(o => o.Customer).AsNoTracking().AsSplitQuery().Where(o => o.CustomerID == "ALFKI").ToList(); + ? await context.Set().Include(o => o.Customer).AsNoTracking().AsSplitQuery().Where(o => o.CustomerID == "ALFKI") + .ToListAsync() + : context.Set().Include(o => o.Customer).AsNoTracking().AsSplitQuery().Where(o => o.CustomerID == "ALFKI") + .ToList(); Assert.Equal(6, orders.Count); Assert.True(orders.All(o => !ReferenceEquals(o.Customer, customer))); diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindSplitIncludeQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindSplitIncludeQueryTestBase.cs index f9a0d9d6ff1..6ec8b7aff75 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindSplitIncludeQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindSplitIncludeQueryTestBase.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.Data; using System.Linq; using System.Linq.Expressions; using System.Reflection; diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindWhereQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindWhereQueryRelationalTestBase.cs index 6c04971c80a..0ded5506ddd 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindWhereQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindWhereQueryRelationalTestBase.cs @@ -13,9 +13,11 @@ protected NorthwindWhereQueryRelationalTestBase(TFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryFixtureBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryFixtureBase.cs index 4514bbeca97..de02e5ae1dd 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryFixtureBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryFixtureBase.cs @@ -12,89 +12,93 @@ namespace Microsoft.EntityFrameworkCore.Query { public abstract class NullSemanticsQueryFixtureBase : SharedStoreFixtureBase, IQueryFixtureBase { - public Func GetContextCreator() => () => CreateContext(); + public Func GetContextCreator() + => () => CreateContext(); - public ISetSource GetExpectedData() => new NullSemanticsData(); + public ISetSource GetExpectedData() + => new NullSemanticsData(); public IReadOnlyDictionary GetEntitySorters() => new Dictionary> - { - { typeof(NullSemanticsEntity1), e => ((NullSemanticsEntity1)e)?.Id }, - { typeof(NullSemanticsEntity2), e => ((NullSemanticsEntity2)e)?.Id } - }.ToDictionary(e => e.Key, e => (object)e.Value); + { + { typeof(NullSemanticsEntity1), e => ((NullSemanticsEntity1)e)?.Id }, + { typeof(NullSemanticsEntity2), e => ((NullSemanticsEntity2)e)?.Id } + }.ToDictionary(e => e.Key, e => (object)e.Value); public IReadOnlyDictionary GetEntityAsserters() => new Dictionary> + { { + typeof(NullSemanticsEntity1), (e, a) => { - typeof(NullSemanticsEntity1), (e, a) => + Assert.Equal(e == null, a == null); + if (a != null) { - Assert.Equal(e == null, a == null); - if (a != null) - { - var ee = (NullSemanticsEntity1)e; - var aa = (NullSemanticsEntity1)a; - - Assert.Equal(ee.Id, aa.Id); - Assert.Equal(ee.BoolA, aa.BoolA); - Assert.Equal(ee.BoolB, aa.BoolB); - Assert.Equal(ee.BoolC, aa.BoolC); - Assert.Equal(ee.IntA, aa.IntA); - Assert.Equal(ee.IntB, aa.IntB); - Assert.Equal(ee.IntC, aa.IntC); - Assert.Equal(ee.StringA, aa.StringA); - Assert.Equal(ee.StringB, aa.StringB); - Assert.Equal(ee.StringC, aa.StringC); - Assert.Equal(ee.NullableBoolA, aa.NullableBoolA); - Assert.Equal(ee.NullableBoolB, aa.NullableBoolB); - Assert.Equal(ee.NullableBoolC, aa.NullableBoolC); - Assert.Equal(ee.NullableIntA, aa.NullableIntA); - Assert.Equal(ee.NullableIntB, aa.NullableIntB); - Assert.Equal(ee.NullableIntC, aa.NullableIntC); - Assert.Equal(ee.NullableStringA, aa.NullableStringA); - Assert.Equal(ee.NullableStringB, aa.NullableStringB); - Assert.Equal(ee.NullableStringC, aa.NullableStringC); - } + var ee = (NullSemanticsEntity1)e; + var aa = (NullSemanticsEntity1)a; + + Assert.Equal(ee.Id, aa.Id); + Assert.Equal(ee.BoolA, aa.BoolA); + Assert.Equal(ee.BoolB, aa.BoolB); + Assert.Equal(ee.BoolC, aa.BoolC); + Assert.Equal(ee.IntA, aa.IntA); + Assert.Equal(ee.IntB, aa.IntB); + Assert.Equal(ee.IntC, aa.IntC); + Assert.Equal(ee.StringA, aa.StringA); + Assert.Equal(ee.StringB, aa.StringB); + Assert.Equal(ee.StringC, aa.StringC); + Assert.Equal(ee.NullableBoolA, aa.NullableBoolA); + Assert.Equal(ee.NullableBoolB, aa.NullableBoolB); + Assert.Equal(ee.NullableBoolC, aa.NullableBoolC); + Assert.Equal(ee.NullableIntA, aa.NullableIntA); + Assert.Equal(ee.NullableIntB, aa.NullableIntB); + Assert.Equal(ee.NullableIntC, aa.NullableIntC); + Assert.Equal(ee.NullableStringA, aa.NullableStringA); + Assert.Equal(ee.NullableStringB, aa.NullableStringB); + Assert.Equal(ee.NullableStringC, aa.NullableStringC); } - }, + } + }, + { + typeof(NullSemanticsEntity2), (e, a) => { - typeof(NullSemanticsEntity2), (e, a) => + Assert.Equal(e == null, a == null); + if (a != null) { - Assert.Equal(e == null, a == null); - if (a != null) - { - var ee = (NullSemanticsEntity2)e; - var aa = (NullSemanticsEntity2)a; - - Assert.Equal(ee.Id, aa.Id); - Assert.Equal(ee.BoolA, aa.BoolA); - Assert.Equal(ee.BoolB, aa.BoolB); - Assert.Equal(ee.BoolC, aa.BoolC); - Assert.Equal(ee.IntA, aa.IntA); - Assert.Equal(ee.IntB, aa.IntB); - Assert.Equal(ee.IntC, aa.IntC); - Assert.Equal(ee.StringA, aa.StringA); - Assert.Equal(ee.StringB, aa.StringB); - Assert.Equal(ee.StringC, aa.StringC); - Assert.Equal(ee.NullableBoolA, aa.NullableBoolA); - Assert.Equal(ee.NullableBoolB, aa.NullableBoolB); - Assert.Equal(ee.NullableBoolC, aa.NullableBoolC); - Assert.Equal(ee.NullableIntA, aa.NullableIntA); - Assert.Equal(ee.NullableIntB, aa.NullableIntB); - Assert.Equal(ee.NullableIntC, aa.NullableIntC); - Assert.Equal(ee.NullableStringA, aa.NullableStringA); - Assert.Equal(ee.NullableStringB, aa.NullableStringB); - Assert.Equal(ee.NullableStringC, aa.NullableStringC); - } + var ee = (NullSemanticsEntity2)e; + var aa = (NullSemanticsEntity2)a; + + Assert.Equal(ee.Id, aa.Id); + Assert.Equal(ee.BoolA, aa.BoolA); + Assert.Equal(ee.BoolB, aa.BoolB); + Assert.Equal(ee.BoolC, aa.BoolC); + Assert.Equal(ee.IntA, aa.IntA); + Assert.Equal(ee.IntB, aa.IntB); + Assert.Equal(ee.IntC, aa.IntC); + Assert.Equal(ee.StringA, aa.StringA); + Assert.Equal(ee.StringB, aa.StringB); + Assert.Equal(ee.StringC, aa.StringC); + Assert.Equal(ee.NullableBoolA, aa.NullableBoolA); + Assert.Equal(ee.NullableBoolB, aa.NullableBoolB); + Assert.Equal(ee.NullableBoolC, aa.NullableBoolC); + Assert.Equal(ee.NullableIntA, aa.NullableIntA); + Assert.Equal(ee.NullableIntB, aa.NullableIntB); + Assert.Equal(ee.NullableIntC, aa.NullableIntC); + Assert.Equal(ee.NullableStringA, aa.NullableStringA); + Assert.Equal(ee.NullableStringB, aa.NullableStringB); + Assert.Equal(ee.NullableStringC, aa.NullableStringC); } - }, - }.ToDictionary(e => e.Key, e => (object)e.Value); + } + }, + }.ToDictionary(e => e.Key, e => (object)e.Value); protected override string StoreName { get; } = "NullSemanticsQueryTest"; - public new RelationalTestStore TestStore => (RelationalTestStore)base.TestStore; + public new RelationalTestStore TestStore + => (RelationalTestStore)base.TestStore; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; public override NullSemanticsContext CreateContext() { @@ -103,7 +107,8 @@ public override NullSemanticsContext CreateContext() return context; } - protected override void Seed(NullSemanticsContext context) => NullSemanticsContext.Seed(context); + protected override void Seed(NullSemanticsContext context) + => NullSemanticsContext.Seed(context); protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs index f668c4edd77..06a8391fd96 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NullSemanticsQueryTestBase.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.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -36,7 +35,8 @@ public virtual async Task Compare_bool_with_bool_equal(bool async) await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA == e.BoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA == e.NullableBoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA == e.BoolB).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA == e.NullableBoolB).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => e.NullableBoolA == e.NullableBoolB).Select(e => e.Id)); } [ConditionalTheory] @@ -46,7 +46,8 @@ public virtual async Task Compare_negated_bool_with_bool_equal(bool async) await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.BoolA == e.BoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.BoolA == e.NullableBoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.NullableBoolA == e.BoolB).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.NullableBoolA == e.NullableBoolB).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !e.NullableBoolA == e.NullableBoolB).Select(e => e.Id)); } [ConditionalTheory] @@ -56,7 +57,8 @@ public virtual async Task Compare_bool_with_negated_bool_equal(bool async) await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA == !e.BoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA == !e.NullableBoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA == !e.BoolB).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA == !e.NullableBoolB).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => e.NullableBoolA == !e.NullableBoolB).Select(e => e.Id)); } [ConditionalTheory] @@ -66,7 +68,8 @@ public virtual async Task Compare_negated_bool_with_negated_bool_equal(bool asyn await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.BoolA == !e.BoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.BoolA == !e.NullableBoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.NullableBoolA == !e.BoolB).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.NullableBoolA == !e.NullableBoolB).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !e.NullableBoolA == !e.NullableBoolB).Select(e => e.Id)); } [ConditionalTheory] @@ -74,9 +77,12 @@ public virtual async Task Compare_negated_bool_with_negated_bool_equal(bool asyn public virtual async Task Compare_bool_with_bool_equal_negated(bool async) { await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.BoolA == e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.BoolA == e.NullableBoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.NullableBoolA == e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.NullableBoolA == e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(e.BoolA == e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(e.NullableBoolA == e.BoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(e.NullableBoolA == e.NullableBoolB)).Select(e => e.Id)); } [ConditionalTheory] @@ -84,9 +90,12 @@ public virtual async Task Compare_bool_with_bool_equal_negated(bool async) public virtual async Task Compare_negated_bool_with_bool_equal_negated(bool async) { await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.BoolA == e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.BoolA == e.NullableBoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.NullableBoolA == e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.NullableBoolA == e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(!e.BoolA == e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(!e.NullableBoolA == e.BoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(!e.NullableBoolA == e.NullableBoolB)).Select(e => e.Id)); } [ConditionalTheory] @@ -94,9 +103,12 @@ public virtual async Task Compare_negated_bool_with_bool_equal_negated(bool asyn public virtual async Task Compare_bool_with_negated_bool_equal_negated(bool async) { await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.BoolA == !e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.BoolA == !e.NullableBoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.NullableBoolA == !e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.NullableBoolA == !e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(e.BoolA == !e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(e.NullableBoolA == !e.BoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(e.NullableBoolA == !e.NullableBoolB)).Select(e => e.Id)); } [ConditionalTheory] @@ -104,9 +116,12 @@ public virtual async Task Compare_bool_with_negated_bool_equal_negated(bool asyn public virtual async Task Compare_negated_bool_with_negated_bool_equal_negated(bool async) { await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.BoolA == !e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.BoolA == !e.NullableBoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.NullableBoolA == !e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.NullableBoolA == !e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(!e.BoolA == !e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(!e.NullableBoolA == !e.BoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(!e.NullableBoolA == !e.NullableBoolB)).Select(e => e.Id)); } [ConditionalTheory] @@ -116,7 +131,8 @@ public virtual async Task Compare_bool_with_bool_not_equal(bool async) await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA != e.BoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA != e.NullableBoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA != e.BoolB).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA != e.NullableBoolB).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => e.NullableBoolA != e.NullableBoolB).Select(e => e.Id)); } [ConditionalTheory] @@ -126,7 +142,8 @@ public virtual async Task Compare_negated_bool_with_bool_not_equal(bool async) await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.BoolA != e.BoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.BoolA != e.NullableBoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.NullableBoolA != e.BoolB).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.NullableBoolA != e.NullableBoolB).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !e.NullableBoolA != e.NullableBoolB).Select(e => e.Id)); } [ConditionalTheory] @@ -136,7 +153,8 @@ public virtual async Task Compare_bool_with_negated_bool_not_equal(bool async) await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA != !e.BoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA != !e.NullableBoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA != !e.BoolB).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA != !e.NullableBoolB).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => e.NullableBoolA != !e.NullableBoolB).Select(e => e.Id)); } [ConditionalTheory] @@ -146,7 +164,8 @@ public virtual async Task Compare_negated_bool_with_negated_bool_not_equal(bool await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.BoolA != !e.BoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.BoolA != !e.NullableBoolB).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.NullableBoolA != !e.BoolB).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.NullableBoolA != !e.NullableBoolB).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !e.NullableBoolA != !e.NullableBoolB).Select(e => e.Id)); } [ConditionalTheory] @@ -154,9 +173,12 @@ public virtual async Task Compare_negated_bool_with_negated_bool_not_equal(bool public virtual async Task Compare_bool_with_bool_not_equal_negated(bool async) { await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.BoolA != e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.BoolA != e.NullableBoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.NullableBoolA != e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.NullableBoolA != e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(e.BoolA != e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(e.NullableBoolA != e.BoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(e.NullableBoolA != e.NullableBoolB)).Select(e => e.Id)); } [ConditionalTheory] @@ -164,9 +186,12 @@ public virtual async Task Compare_bool_with_bool_not_equal_negated(bool async) public virtual async Task Compare_negated_bool_with_bool_not_equal_negated(bool async) { await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.BoolA != e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.BoolA != e.NullableBoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.NullableBoolA != e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.NullableBoolA != e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(!e.BoolA != e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(!e.NullableBoolA != e.BoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(!e.NullableBoolA != e.NullableBoolB)).Select(e => e.Id)); } [ConditionalTheory] @@ -174,9 +199,12 @@ public virtual async Task Compare_negated_bool_with_bool_not_equal_negated(bool public virtual async Task Compare_bool_with_negated_bool_not_equal_negated(bool async) { await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.BoolA != !e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.BoolA != !e.NullableBoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.NullableBoolA != !e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(e.NullableBoolA != !e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(e.BoolA != !e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(e.NullableBoolA != !e.BoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(e.NullableBoolA != !e.NullableBoolB)).Select(e => e.Id)); } [ConditionalTheory] @@ -184,9 +212,12 @@ public virtual async Task Compare_bool_with_negated_bool_not_equal_negated(bool public virtual async Task Compare_negated_bool_with_negated_bool_not_equal_negated(bool async) { await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.BoolA != !e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.BoolA != !e.NullableBoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.NullableBoolA != !e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !(!e.NullableBoolA != !e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(!e.BoolA != !e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(!e.NullableBoolA != !e.BoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !(!e.NullableBoolA != !e.NullableBoolB)).Select(e => e.Id)); } [ConditionalTheory] @@ -194,9 +225,12 @@ public virtual async Task Compare_negated_bool_with_negated_bool_not_equal_negat public virtual async Task Compare_equals_method(bool async) { await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA.Equals(e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA.Equals(e.NullableBoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA.Equals(e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA.Equals(e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => e.BoolA.Equals(e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => e.NullableBoolA.Equals(e.BoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => e.NullableBoolA.Equals(e.NullableBoolB)).Select(e => e.Id)); } [ConditionalTheory] @@ -204,9 +238,12 @@ public virtual async Task Compare_equals_method(bool async) public virtual async Task Compare_equals_method_static(bool async) { await AssertQueryScalar(async, ss => ss.Set().Where(e => Equals(e.BoolA, e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => Equals(e.BoolA, e.NullableBoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => Equals(e.NullableBoolA, e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => Equals(e.NullableBoolA, e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => Equals(e.BoolA, e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => Equals(e.NullableBoolA, e.BoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => Equals(e.NullableBoolA, e.NullableBoolB)).Select(e => e.Id)); } [ConditionalTheory] @@ -214,9 +251,12 @@ public virtual async Task Compare_equals_method_static(bool async) public virtual async Task Compare_equals_method_negated(bool async) { await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.BoolA.Equals(e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.BoolA.Equals(e.NullableBoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.NullableBoolA.Equals(e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !e.NullableBoolA.Equals(e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !e.BoolA.Equals(e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !e.NullableBoolA.Equals(e.BoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !e.NullableBoolA.Equals(e.NullableBoolB)).Select(e => e.Id)); } [ConditionalTheory] @@ -224,63 +264,108 @@ public virtual async Task Compare_equals_method_negated(bool async) public virtual async Task Compare_equals_method_negated_static(bool async) { await AssertQueryScalar(async, ss => ss.Set().Where(e => !Equals(e.BoolA, e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !Equals(e.BoolA, e.NullableBoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !Equals(e.NullableBoolA, e.BoolB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !Equals(e.NullableBoolA, e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !Equals(e.BoolA, e.NullableBoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !Equals(e.NullableBoolA, e.BoolB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !Equals(e.NullableBoolA, e.NullableBoolB)).Select(e => e.Id)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Compare_complex_equal_equal_equal(bool async) { - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA == e.BoolB == (e.IntA == e.IntB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA == e.BoolB == (e.IntA == e.NullableIntB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA == e.NullableBoolB == (e.NullableIntA == e.NullableIntB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => e.BoolA == e.BoolB == (e.IntA == e.IntB)).Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => e.NullableBoolA == e.BoolB == (e.IntA == e.NullableIntB)) + .Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => e.NullableBoolA == e.NullableBoolB == (e.NullableIntA == e.NullableIntB)) + .Select(e => e.Id)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Compare_complex_equal_not_equal_equal(bool async) { - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA == e.BoolB != (e.IntA == e.IntB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA == e.BoolB != (e.IntA == e.NullableIntB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA == e.NullableBoolB != (e.NullableIntA == e.NullableIntB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => e.BoolA == e.BoolB != (e.IntA == e.IntB)).Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => e.NullableBoolA == e.BoolB != (e.IntA == e.NullableIntB)) + .Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => e.NullableBoolA == e.NullableBoolB != (e.NullableIntA == e.NullableIntB)) + .Select(e => e.Id)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Compare_complex_not_equal_equal_equal(bool async) { - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA != e.BoolB == (e.IntA == e.IntB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA != e.BoolB == (e.IntA == e.NullableIntB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA != e.NullableBoolB == (e.NullableIntA == e.NullableIntB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => e.BoolA != e.BoolB == (e.IntA == e.IntB)).Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => e.NullableBoolA != e.BoolB == (e.IntA == e.NullableIntB)) + .Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => e.NullableBoolA != e.NullableBoolB == (e.NullableIntA == e.NullableIntB)) + .Select(e => e.Id)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Compare_complex_not_equal_not_equal_equal(bool async) { - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA != e.BoolB != (e.IntA == e.IntB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA != e.BoolB != (e.IntA == e.NullableIntB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA != e.NullableBoolB != (e.NullableIntA == e.NullableIntB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => e.BoolA != e.BoolB != (e.IntA == e.IntB)).Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => e.NullableBoolA != e.BoolB != (e.IntA == e.NullableIntB)) + .Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => e.NullableBoolA != e.NullableBoolB != (e.NullableIntA == e.NullableIntB)) + .Select(e => e.Id)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Compare_complex_not_equal_equal_not_equal(bool async) { - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA != e.BoolB == (e.IntA != e.IntB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA != e.BoolB == (e.IntA != e.NullableIntB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA != e.NullableBoolB == (e.NullableIntA != e.NullableIntB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => e.BoolA != e.BoolB == (e.IntA != e.IntB)).Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => e.NullableBoolA != e.BoolB == (e.IntA != e.NullableIntB)) + .Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => e.NullableBoolA != e.NullableBoolB == (e.NullableIntA != e.NullableIntB)) + .Select(e => e.Id)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Compare_complex_not_equal_not_equal_not_equal(bool async) { - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA != e.BoolB != (e.IntA != e.IntB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA != e.BoolB != (e.IntA != e.NullableIntB)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA != e.NullableBoolB != (e.NullableIntA != e.NullableIntB)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => e.BoolA != e.BoolB != (e.IntA != e.IntB)).Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => e.NullableBoolA != e.BoolB != (e.IntA != e.NullableIntB)) + .Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => e.NullableBoolA != e.NullableBoolB != (e.NullableIntA != e.NullableIntB)) + .Select(e => e.Id)); } [ConditionalTheory] @@ -325,7 +410,8 @@ public virtual Task Contains_with_local_array_closure_with_null(bool async) { string[] ids = { "Foo", null }; - return AssertQueryScalar(async, ss => ss.Set().Where(e => ids.Contains(e.NullableStringA)).Select(e => e.Id)); + return AssertQueryScalar( + async, ss => ss.Set().Where(e => ids.Contains(e.NullableStringA)).Select(e => e.Id)); } [ConditionalTheory] @@ -334,7 +420,8 @@ public virtual Task Contains_with_local_array_closure_with_multiple_nulls(bool a { string[] ids = { null, "Foo", null, null }; - return AssertQueryScalar(async, ss => ss.Set().Where(e => ids.Contains(e.NullableStringA)).Select(e => e.Id)); + return AssertQueryScalar( + async, ss => ss.Set().Where(e => ids.Contains(e.NullableStringA)).Select(e => e.Id)); } [ConditionalTheory] @@ -343,7 +430,8 @@ public virtual Task Contains_with_local_array_closure_false_with_null(bool async { string[] ids = { "Foo", null }; - return AssertQueryScalar(async, ss => ss.Set().Where(e => !ids.Contains(e.NullableStringA)).Select(e => e.Id)); + return AssertQueryScalar( + async, ss => ss.Set().Where(e => !ids.Contains(e.NullableStringA)).Select(e => e.Id)); } [ConditionalTheory] @@ -352,7 +440,8 @@ public virtual Task Contains_with_local_nullable_array_closure_negated(bool asyn { string[] ids = { "Foo" }; - return AssertQueryScalar(async, ss => ss.Set().Where(e => !ids.Contains(e.NullableStringA)).Select(e => e.Id)); + return AssertQueryScalar( + async, ss => ss.Set().Where(e => !ids.Contains(e.NullableStringA)).Select(e => e.Id)); } [ConditionalTheory] @@ -361,7 +450,8 @@ public virtual Task Where_multiple_ors_with_null(bool async) { return AssertQueryScalar( async, - ss => ss.Set().Where(e => e.NullableStringA == "Foo" || e.NullableStringA == "Blah" || e.NullableStringA == null).Select(e => e.Id)); + ss => ss.Set() + .Where(e => e.NullableStringA == "Foo" || e.NullableStringA == "Blah" || e.NullableStringA == null).Select(e => e.Id)); } [ConditionalTheory] @@ -370,7 +460,8 @@ public virtual Task Where_multiple_ands_with_null(bool async) { return AssertQueryScalar( async, - ss => ss.Set().Where(e => e.NullableStringA != "Foo" && e.NullableStringA != "Blah" && e.NullableStringA != null).Select(e => e.Id)); + ss => ss.Set() + .Where(e => e.NullableStringA != "Foo" && e.NullableStringA != "Blah" && e.NullableStringA != null).Select(e => e.Id)); } [ConditionalTheory] @@ -450,7 +541,8 @@ public virtual Task Where_equal_with_coalesce(bool async) { return AssertQueryScalar( async, - ss => ss.Set().Where(e => (e.NullableStringA ?? e.NullableStringB) == e.NullableStringC).Select(e => e.Id)); + ss => ss.Set().Where(e => (e.NullableStringA ?? e.NullableStringB) == e.NullableStringC) + .Select(e => e.Id)); } [ConditionalTheory] @@ -459,7 +551,8 @@ public virtual Task Where_not_equal_with_coalesce(bool async) { return AssertQueryScalar( async, - ss => ss.Set().Where(e => (e.NullableStringA ?? e.NullableStringB) != e.NullableStringC).Select(e => e.Id)); + ss => ss.Set().Where(e => (e.NullableStringA ?? e.NullableStringB) != e.NullableStringC) + .Select(e => e.Id)); } [ConditionalTheory] @@ -468,7 +561,8 @@ public virtual Task Where_equal_with_coalesce_both_sides(bool async) { return AssertQueryScalar( async, - ss => ss.Set().Where(e => (e.NullableStringA ?? e.NullableStringB) == (e.StringA ?? e.StringB)).Select(e => e.Id)); + ss => ss.Set().Where(e => (e.NullableStringA ?? e.NullableStringB) == (e.StringA ?? e.StringB)) + .Select(e => e.Id)); } [ConditionalTheory] @@ -477,7 +571,8 @@ public virtual Task Where_not_equal_with_coalesce_both_sides(bool async) { return AssertQueryScalar( async, - ss => ss.Set().Where(e => (e.NullableIntA ?? e.NullableIntB) != (e.NullableIntC ?? e.NullableIntB)).Select(e => e.Id)); + ss => ss.Set().Where(e => (e.NullableIntA ?? e.NullableIntB) != (e.NullableIntC ?? e.NullableIntB)) + .Select(e => e.Id)); } [ConditionalTheory] @@ -562,7 +657,9 @@ public virtual Task Where_equal_with_and_and_contains(bool async) return AssertQueryScalar( async, ss => ss.Set().Where(e => e.NullableStringA.Contains(e.NullableStringB) && e.BoolA).Select(e => e.Id), - ss => ss.Set().Where(e => e.NullableStringA != null && e.NullableStringA.Contains(e.NullableStringB ?? "Blah") && e.BoolA).Select(e => e.Id)); + ss => ss.Set() + .Where(e => e.NullableStringA != null && e.NullableStringA.Contains(e.NullableStringB ?? "Blah") && e.BoolA) + .Select(e => e.Id)); } [ConditionalTheory] @@ -580,7 +677,8 @@ public virtual Task Null_comparison_in_order_by_with_relational_nulls(bool async { return AssertQuery( async, - ss => ss.Set().OrderBy(e => e.NullableStringA != "Foo").ThenBy(e => e.NullableIntB != 10).Select(e => e), + ss => ss.Set().OrderBy(e => e.NullableStringA != "Foo").ThenBy(e => e.NullableIntB != 10) + .Select(e => e), elementSorter: e => e.Id); } @@ -755,7 +853,8 @@ public virtual Task Where_comparison_null_semantics_optimization_works_with_comp { string prm = null; - return AssertQueryScalar(async, ss => ss.Set().Where(e => null == prm && e.NullableStringA == prm).Select(e => e.Id)); + return AssertQueryScalar( + async, ss => ss.Set().Where(e => null == prm && e.NullableStringA == prm).Select(e => e.Id)); } [ConditionalFact] @@ -896,21 +995,24 @@ public virtual async Task Null_semantics_applied_when_comparing_two_functions_wi { await AssertQueryScalar( async, - ss => ss.Set().Where(e => e.NullableStringA.IndexOf("oo") == e.NullableStringB.IndexOf("ar")).Select(e => e.Id), + ss => ss.Set().Where(e => e.NullableStringA.IndexOf("oo") == e.NullableStringB.IndexOf("ar")) + .Select(e => e.Id), ss => ss.Set().Where( e => e.NullableStringA.MaybeScalar(x => x.IndexOf("oo")) == e.NullableStringB.MaybeScalar(x => x.IndexOf("ar"))).Select(e => e.Id)); await AssertQueryScalar( async, - ss => ss.Set().Where(e => e.NullableStringA.IndexOf("oo") != e.NullableStringB.IndexOf("ar")).Select(e => e.Id), + ss => ss.Set().Where(e => e.NullableStringA.IndexOf("oo") != e.NullableStringB.IndexOf("ar")) + .Select(e => e.Id), ss => ss.Set().Where( e => e.NullableStringA.MaybeScalar(x => x.IndexOf("oo")) != e.NullableStringB.MaybeScalar(x => x.IndexOf("ar"))).Select(e => e.Id)); await AssertQueryScalar( async, - ss => ss.Set().Where(e => e.NullableStringA.IndexOf("oo") != e.NullableStringA.IndexOf("ar")).Select(e => e.Id), + ss => ss.Set().Where(e => e.NullableStringA.IndexOf("oo") != e.NullableStringA.IndexOf("ar")) + .Select(e => e.Id), ss => ss.Set().Where( e => e.NullableStringA.MaybeScalar(x => x.IndexOf("oo")) != e.NullableStringA.MaybeScalar(x => x.IndexOf("ar"))).Select(e => e.Id)); @@ -922,7 +1024,8 @@ public virtual async Task Null_semantics_applied_when_comparing_two_functions_wi { await AssertQueryScalar( async, - ss => ss.Set().Where(e => e.NullableStringA.Replace(e.NullableStringB, e.NullableStringC) == e.NullableStringA).Select(e => e.Id), + ss => ss.Set() + .Where(e => e.NullableStringA.Replace(e.NullableStringB, e.NullableStringC) == e.NullableStringA).Select(e => e.Id), ss => ss.Set().Where( e => (e.NullableStringA == null && (e.NullableStringA == null || e.NullableStringB == null || e.NullableStringC == null)) @@ -933,7 +1036,8 @@ await AssertQueryScalar( await AssertQueryScalar( async, - ss => ss.Set().Where(e => e.NullableStringA.Replace(e.NullableStringB, e.NullableStringC) != e.NullableStringA).Select(e => e.Id), + ss => ss.Set() + .Where(e => e.NullableStringA.Replace(e.NullableStringB, e.NullableStringC) != e.NullableStringA).Select(e => e.Id), ss => ss.Set().Where( e => ((e.NullableStringA == null || e.NullableStringB == null || e.NullableStringC == null) && e.NullableStringA != null) @@ -947,18 +1051,30 @@ await AssertQueryScalar( [MemberData(nameof(IsAsyncData))] public virtual async Task Null_semantics_coalesce(bool async) { - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA == (e.NullableBoolB ?? e.BoolC)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.NullableBoolA == (e.NullableBoolB ?? e.NullableBoolC)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => (e.NullableBoolB ?? e.BoolC) != e.NullableBoolA).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => (e.NullableBoolB ?? e.NullableBoolC) != e.NullableBoolA).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => e.NullableBoolA == (e.NullableBoolB ?? e.BoolC)).Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => e.NullableBoolA == (e.NullableBoolB ?? e.NullableBoolC)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => (e.NullableBoolB ?? e.BoolC) != e.NullableBoolA).Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => (e.NullableBoolB ?? e.NullableBoolC) != e.NullableBoolA).Select(e => e.Id)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Null_semantics_conditional(bool async) { - await AssertQueryScalar(async, ss => ss.Set().Where(e => e.BoolA == (e.BoolB ? e.NullableBoolB : e.NullableBoolC)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => (e.NullableBoolA != e.NullableBoolB ? e.BoolB : e.BoolC) == e.BoolA).Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => e.BoolA == (e.BoolB ? e.NullableBoolB : e.NullableBoolC)) + .Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => (e.NullableBoolA != e.NullableBoolB ? e.BoolB : e.BoolC) == e.BoolA) + .Select(e => e.Id)); await AssertQueryScalar( async, ss => ss.Set().Where( @@ -973,8 +1089,10 @@ public virtual Task Null_semantics_function(bool async) { return AssertQueryScalar( async, - ss => ss.Set().Where(e => e.NullableStringA.Substring(0, e.IntA) != e.NullableStringB).Select(e => e.Id), - ss => ss.Set().Where(e => e.NullableStringA.Maybe(x => x.Substring(0, e.IntA)) != e.NullableStringB).Select(e => e.Id)); + ss => ss.Set().Where(e => e.NullableStringA.Substring(0, e.IntA) != e.NullableStringB) + .Select(e => e.Id), + ss => ss.Set().Where(e => e.NullableStringA.Maybe(x => x.Substring(0, e.IntA)) != e.NullableStringB) + .Select(e => e.Id)); } [ConditionalTheory] @@ -985,18 +1103,18 @@ public virtual Task Null_semantics_join_with_composite_key(bool async) async, ss => from e1 in ss.Set() join e2 in ss.Set() - 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 }, elementSorter: e => (e.e1.Id, e.e2.Id), elementAsserter: (e, a) => @@ -1012,16 +1130,41 @@ public virtual async Task Null_semantics_contains(bool async) { var ids = new List { 1, 2 }; await AssertQueryScalar(async, ss => ss.Set().Where(e => ids.Contains(e.NullableIntA)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !ids.Contains(e.NullableIntA)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !ids.Contains(e.NullableIntA)).Select(e => e.Id)); - var ids2 = new List { 1, 2, null }; - await AssertQueryScalar(async, ss => ss.Set().Where(e => ids2.Contains(e.NullableIntA)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !ids2.Contains(e.NullableIntA)).Select(e => e.Id)); + var ids2 = new List + { + 1, + 2, + null + }; + await AssertQueryScalar( + async, ss => ss.Set().Where(e => ids2.Contains(e.NullableIntA)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !ids2.Contains(e.NullableIntA)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => new List { 1, 2 }.Contains(e.NullableIntA)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !new List { 1, 2 }.Contains(e.NullableIntA)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => new List { 1, 2, null }.Contains(e.NullableIntA)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !new List { 1, 2, null }.Contains(e.NullableIntA)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => new List { 1, 2 }.Contains(e.NullableIntA)).Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => !new List { 1, 2 }.Contains(e.NullableIntA)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where( + e => new List + { + 1, + 2, + null + }.Contains(e.NullableIntA)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where( + e => !new List + { + 1, + 2, + null + }.Contains(e.NullableIntA)).Select(e => e.Id)); } [ConditionalTheory] @@ -1030,27 +1173,43 @@ public virtual async Task Null_semantics_contains_array_with_no_values(bool asyn { var ids = new List(); await AssertQueryScalar(async, ss => ss.Set().Where(e => ids.Contains(e.NullableIntA)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !ids.Contains(e.NullableIntA)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !ids.Contains(e.NullableIntA)).Select(e => e.Id)); var ids2 = new List { null }; - await AssertQueryScalar(async, ss => ss.Set().Where(e => ids2.Contains(e.NullableIntA)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !ids2.Contains(e.NullableIntA)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => ids2.Contains(e.NullableIntA)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !ids2.Contains(e.NullableIntA)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => new List().Contains(e.NullableIntA)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !new List().Contains(e.NullableIntA)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => new List { null }.Contains(e.NullableIntA)).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => !new List { null }.Contains(e.NullableIntA)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => new List().Contains(e.NullableIntA)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => !new List().Contains(e.NullableIntA)).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => new List { null }.Contains(e.NullableIntA)).Select(e => e.Id)); + await AssertQueryScalar( + async, + ss => ss.Set().Where(e => !new List { null }.Contains(e.NullableIntA)).Select(e => e.Id)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Null_semantics_contains_non_nullable_argument(bool async) { - var ids = new List { 1, 2, null }; + var ids = new List + { + 1, + 2, + null + }; await AssertQueryScalar(async, ss => ss.Set().Where(e => ids.Contains(e.IntA)).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => !ids.Contains(e.IntA)).Select(e => e.Id)); - var ids2 = new List { 1, 2, }; + var ids2 = new List + { + 1, 2, + }; await AssertQueryScalar(async, ss => ss.Set().Where(e => ids2.Contains(e.IntA)).Select(e => e.Id)); await AssertQueryScalar(async, ss => ss.Set().Where(e => !ids2.Contains(e.IntA)).Select(e => e.Id)); @@ -1069,11 +1228,13 @@ public virtual async Task Null_semantics_with_null_check_simple(bool async) { await AssertQueryScalar( async, - ss => ss.Set().Where(e => e.NullableIntA != null && e.NullableIntA == e.NullableIntB).Select(e => e.Id)); + ss => ss.Set().Where(e => e.NullableIntA != null && e.NullableIntA == e.NullableIntB) + .Select(e => e.Id)); await AssertQueryScalar( async, - ss => ss.Set().Where(e => e.NullableIntA != null && e.NullableIntA != e.NullableIntB).Select(e => e.Id)); + ss => ss.Set().Where(e => e.NullableIntA != null && e.NullableIntA != e.NullableIntB) + .Select(e => e.Id)); await AssertQueryScalar( async, @@ -1081,11 +1242,13 @@ await AssertQueryScalar( await AssertQueryScalar( async, - ss => ss.Set().Where(e => e.NullableIntA != null && e.NullableIntB != null && e.NullableIntA == e.NullableIntB).Select(e => e.Id)); + ss => ss.Set() + .Where(e => e.NullableIntA != null && e.NullableIntB != null && e.NullableIntA == e.NullableIntB).Select(e => e.Id)); await AssertQueryScalar( async, - ss => ss.Set().Where(e => e.NullableIntA != null && e.NullableIntB != null && e.NullableIntA != e.NullableIntB).Select(e => e.Id)); + ss => ss.Set() + .Where(e => e.NullableIntA != null && e.NullableIntB != null && e.NullableIntA != e.NullableIntB).Select(e => e.Id)); } [ConditionalTheory] @@ -1095,14 +1258,16 @@ public virtual async Task Null_semantics_with_null_check_complex(bool async) await AssertQueryScalar( async, ss => ss.Set() - .Where(e => e.NullableIntA != null - && ((e.NullableIntC != e.NullableIntA) - || (e.NullableIntB != null && e.NullableIntA != e.NullableIntB))).Select(e => e.Id)); + .Where( + e => e.NullableIntA != null + && ((e.NullableIntC != e.NullableIntA) + || (e.NullableIntB != null && e.NullableIntA != e.NullableIntB))).Select(e => e.Id)); await AssertQueryScalar( async, ss => ss.Set() - .Where(e => e.NullableIntA != null && ((e.NullableIntC != e.NullableIntA) || (e.NullableIntA != e.NullableIntB))).Select(e => e.Id)); + .Where(e => e.NullableIntA != null && ((e.NullableIntC != e.NullableIntA) || (e.NullableIntA != e.NullableIntB))) + .Select(e => e.Id)); await AssertQueryScalar( async, @@ -1117,19 +1282,21 @@ public virtual async Task Null_semantics_with_null_check_complex2(bool async) await AssertQueryScalar( async, ss => ss.Set() - .Where(e => ((e.NullableBoolA != null) - && (e.NullableBoolB != null) - && ((e.NullableBoolB != e.NullableBoolA) || (e.NullableBoolC != null)) - && (e.NullableBoolC != e.NullableBoolB)) + .Where( + e => ((e.NullableBoolA != null) + && (e.NullableBoolB != null) + && ((e.NullableBoolB != e.NullableBoolA) || (e.NullableBoolC != null)) + && (e.NullableBoolC != e.NullableBoolB)) || (e.NullableBoolC != e.BoolB)).Select(e => e.Id)); await AssertQueryScalar( async, ss => ss.Set() - .Where(e => ((e.NullableBoolA != null) - && (e.NullableBoolB != null) - && ((e.NullableBoolB != e.NullableBoolA) || (e.NullableBoolC != null)) - && (e.NullableBoolC != e.NullableBoolB)) + .Where( + e => ((e.NullableBoolA != null) + && (e.NullableBoolB != null) + && ((e.NullableBoolB != e.NullableBoolA) || (e.NullableBoolC != null)) + && (e.NullableBoolC != e.NullableBoolB)) || (e.NullableBoolB != e.BoolB)).Select(e => e.Id)); } @@ -1138,9 +1305,12 @@ await AssertQueryScalar( public virtual async Task IsNull_on_complex_expression(bool async) { await AssertQueryScalar(async, ss => ss.Set().Where(e => -e.NullableIntA != null).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => (e.NullableIntA + e.NullableIntB) == null).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => (e.NullableIntA ?? e.NullableIntB) == null).Select(e => e.Id)); - await AssertQueryScalar(async, ss => ss.Set().Where(e => (e.NullableIntA ?? e.NullableIntB) != null).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => (e.NullableIntA + e.NullableIntB) == null).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => (e.NullableIntA ?? e.NullableIntB) == null).Select(e => e.Id)); + await AssertQueryScalar( + async, ss => ss.Set().Where(e => (e.NullableIntA ?? e.NullableIntB) != null).Select(e => e.Id)); } [ConditionalTheory] @@ -1180,7 +1350,9 @@ public virtual Task Nullable_column_info_propagates_inside_binary_AndAlso(bool a { return AssertQueryScalar( async, - ss => ss.Set().Where(e => e.NullableStringA != null && e.NullableStringB != null && e.NullableStringA != e.NullableStringB).Select(e => e.Id)); + ss => ss.Set() + .Where(e => e.NullableStringA != null && e.NullableStringB != null && e.NullableStringA != e.NullableStringB) + .Select(e => e.Id)); } [ConditionalTheory] @@ -1189,7 +1361,9 @@ public virtual Task Nullable_column_info_doesnt_propagate_inside_binary_OrElse(b { return AssertQueryScalar( async, - ss => ss.Set().Where(e => (e.NullableStringA != null || e.NullableStringB != null) && e.NullableStringA != e.NullableStringB).Select(e => e.Id)); + ss => ss.Set().Where( + e => (e.NullableStringA != null || e.NullableStringB != null) && e.NullableStringA != e.NullableStringB) + .Select(e => e.Id)); } [ConditionalTheory] @@ -1198,11 +1372,16 @@ public virtual async Task Nullable_column_info_propagates_inside_binary_OrElse_w { await AssertQueryScalar( async, - ss => ss.Set().Where(e => ((e.NullableStringA != null && e.NullableStringB != null) || (e.NullableStringA != null)) && e.NullableStringA != e.NullableStringB).Select(e => e.Id)); + ss => ss.Set().Where( + e => ((e.NullableStringA != null && e.NullableStringB != null) || (e.NullableStringA != null)) + && e.NullableStringA != e.NullableStringB).Select(e => e.Id)); await AssertQueryScalar( async, - ss => ss.Set().Where(e => ((e.NullableStringA != null && e.NullableStringB != null) || (e.NullableStringB != null && e.NullableStringA != null)) && e.NullableStringA != e.NullableStringB).Select(e => e.Id)); + ss => ss.Set().Where( + e => ((e.NullableStringA != null && e.NullableStringB != null) + || (e.NullableStringB != null && e.NullableStringA != null)) + && e.NullableStringA != e.NullableStringB).Select(e => e.Id)); } [ConditionalTheory] @@ -1220,7 +1399,8 @@ public virtual Task Nullable_column_info_doesnt_propagate_between_projections(bo { return AssertQuery( async, - ss => ss.Set().Select(e => new { Foo = e.NullableStringA != null, Bar = e.NullableStringA != e.StringA }), + ss => ss.Set() + .Select(e => new { Foo = e.NullableStringA != null, Bar = e.NullableStringA != e.StringA }), elementSorter: e => (e.Foo, e.Bar)); } @@ -1242,9 +1422,10 @@ public virtual Task Nullable_column_info_propagation_complex(bool async) { return AssertQueryScalar( async, - ss => ss.Set().Where(e => (e.NullableStringA != null && e.NullableBoolB != null && e.NullableStringC != null) - && ((e.NullableStringA != null || e.NullableBoolC != null) - && e.NullableBoolB != e.NullableBoolC)).Select(e => e.Id)); + ss => ss.Set().Where( + e => (e.NullableStringA != null && e.NullableBoolB != null && e.NullableStringC != null) + && ((e.NullableStringA != null || e.NullableBoolC != null) + && e.NullableBoolB != e.NullableBoolC)).Select(e => e.Id)); } [ConditionalTheory] @@ -1271,7 +1452,8 @@ public virtual Task Empty_subquery_with_contains_returns_false(bool async) { return AssertQuery( async, - ss => ss.Set().Where(e => ss.Set().Where(x => false).Select(x => x.NullableIntA).Contains(e.NullableIntA))); + ss => ss.Set().Where( + e => ss.Set().Where(x => false).Select(x => x.NullableIntA).Contains(e.NullableIntA))); } [ConditionalTheory] @@ -1280,7 +1462,8 @@ public virtual Task Empty_subquery_with_contains_negated_returns_true(bool async { return AssertQuery( async, - ss => ss.Set().Where(e => !ss.Set().Where(x => false).Select(x => x.NullableIntA).Contains(e.NullableIntA))); + ss => ss.Set().Where( + e => !ss.Set().Where(x => false).Select(x => x.NullableIntA).Contains(e.NullableIntA))); } [ConditionalTheory] @@ -1290,8 +1473,9 @@ public virtual Task Nullable_string_FirstOrDefault_compared_to_nullable_string_L return AssertQuery( async, ss => ss.Set().Where(e => e.NullableStringA.FirstOrDefault() == e.NullableStringB.LastOrDefault()), - ss => ss.Set().Where(e => e.NullableStringA.MaybeScalar(x => x.FirstOrDefault()) - == e.NullableStringB.MaybeScalar(x => x.LastOrDefault()))); + ss => ss.Set().Where( + e => e.NullableStringA.MaybeScalar(x => x.FirstOrDefault()) + == e.NullableStringB.MaybeScalar(x => x.LastOrDefault()))); } [ConditionalTheory] diff --git a/test/EFCore.Relational.Specification.Tests/Query/OwnedQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/OwnedQueryRelationalTestBase.cs index 2d945b9c514..48a2475aa8d 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/OwnedQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/OwnedQueryRelationalTestBase.cs @@ -4,7 +4,6 @@ using System; using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; @@ -36,7 +35,6 @@ public virtual Task Query_for_branch_type_loads_all_owned_navs_split(bool async) ss => ss.Set().AsSplitQuery()); } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Query_when_subquery_split(bool async) @@ -136,16 +134,20 @@ protected string NormalizeDelimitersInRawString(string sql) protected FormattableString NormalizeDelimitersInInterpolatedString(FormattableString sql) => Fixture.TestStore.NormalizeDelimitersInInterpolatedString(sql); - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); public abstract class RelationalOwnedQueryFixture : OwnedQueryFixtureBase { - public new RelationalTestStore TestStore => (RelationalTestStore)base.TestStore; + public new RelationalTestStore TestStore + => (RelationalTestStore)base.TestStore; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Relational.Specification.Tests/Query/QueryFilterFuncletizationRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/Query/QueryFilterFuncletizationRelationalFixture.cs index 6b78ce2a5f0..3d7a400b427 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/QueryFilterFuncletizationRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/QueryFilterFuncletizationRelationalFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public abstract class QueryFilterFuncletizationRelationalFixture : QueryFilterFuncletizationFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/QueryNoClientEvalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/QueryNoClientEvalTestBase.cs index 8d7cbfe2a2d..89af630e77b 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/QueryNoClientEvalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/QueryNoClientEvalTestBase.cs @@ -15,7 +15,8 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class QueryNoClientEvalTestBase : IClassFixture where TFixture : NorthwindQueryRelationalFixture, new() { - protected QueryNoClientEvalTestBase(TFixture fixture) => Fixture = fixture; + protected QueryNoClientEvalTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -49,7 +50,8 @@ public virtual void Throws_when_orderby_multiple() CoreStrings.QueryUnableToTranslateMember(nameof(Customer.IsLondon), nameof(Customer))); } - private static object ClientMethod(object o) => o.GetHashCode(); + private static object ClientMethod(object o) + => o.GetHashCode(); [ConditionalFact] public virtual void Throws_when_where_subquery_correlated() @@ -118,7 +120,7 @@ public virtual void Throws_when_select_many() () => (from c1 in context.Customers from i in new[] { 1, 2, 3 } select c1) - .ToList()); + .ToList()); } [ConditionalFact] @@ -206,6 +208,7 @@ private void AssertTranslationFailedWithDetails(Action testCode, string details) CoreStrings.TranslationFailedWithDetails("", details).Substring(21), Assert.Throws(testCode).Message); - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/RelationalNorthwindDbFunctionsQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/RelationalNorthwindDbFunctionsQueryTestBase.cs index e567836a7d2..c28bc347e03 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/RelationalNorthwindDbFunctionsQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/RelationalNorthwindDbFunctionsQueryTestBase.cs @@ -17,10 +17,12 @@ public NorthwindDbFunctionsQueryRelationalTestBase(TFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] diff --git a/test/EFCore.Relational.Specification.Tests/Query/SpatialQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/SpatialQueryRelationalTestBase.cs index 745af1fe3bd..2ad89222624 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/SpatialQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/SpatialQueryRelationalTestBase.cs @@ -13,9 +13,11 @@ protected SpatialQueryRelationalTestBase(TFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(TFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); } } diff --git a/test/EFCore.Relational.Specification.Tests/Query/SqlExecutorTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/SqlExecutorTestBase.cs index 64c76eebe97..59369355d36 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/SqlExecutorTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/SqlExecutorTestBase.cs @@ -19,7 +19,8 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class SqlExecutorTestBase : IClassFixture where TFixture : NorthwindQueryRelationalFixture, new() { - protected SqlExecutorTestBase(TFixture fixture) => Fixture = fixture; + protected SqlExecutorTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -172,7 +173,7 @@ public virtual void Query_with_parameters_interpolated() public virtual void Query_with_DbParameters_interpolated() { var city = CreateDbParameter("city", "London"); - var contactTitle = CreateDbParameter( "contactTitle", "Sales Representative"); + var contactTitle = CreateDbParameter("contactTitle", "Sales Representative"); using var context = CreateContext(); var actual = context.Database @@ -271,7 +272,8 @@ public virtual async Task Query_with_parameters_interpolated_async() Assert.Equal(-1, actual); } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); protected abstract DbParameter CreateDbParameter(string name, object value); diff --git a/test/EFCore.Relational.Specification.Tests/Query/TPTFiltersInheritanceQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/TPTFiltersInheritanceQueryTestBase.cs index 0c87d1a3a26..6a6f113b75b 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/TPTFiltersInheritanceQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/TPTFiltersInheritanceQueryTestBase.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. - // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query diff --git a/test/EFCore.Relational.Specification.Tests/Query/TPTGearsOfWarQueryRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/Query/TPTGearsOfWarQueryRelationalFixture.cs index cc146b9c8b7..a112d41ba65 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/TPTGearsOfWarQueryRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/TPTGearsOfWarQueryRelationalFixture.cs @@ -9,9 +9,12 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class TPTGearsOfWarQueryRelationalFixture : GearsOfWarQueryFixtureBase { protected override string StoreName { get; } = "TPTGearsOfWarQueryTest"; - public new RelationalTestStore TestStore => (RelationalTestStore)base.TestStore; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public new RelationalTestStore TestStore + => (RelationalTestStore)base.TestStore; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; protected override bool ShouldLogCategory(string logCategory) => logCategory == DbLoggerCategory.Query.Name; diff --git a/test/EFCore.Relational.Specification.Tests/Query/TPTInheritanceQueryFixture.cs b/test/EFCore.Relational.Specification.Tests/Query/TPTInheritanceQueryFixture.cs index 0c7b5fc3159..b30299cd4f7 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/TPTInheritanceQueryFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/TPTInheritanceQueryFixture.cs @@ -8,11 +8,14 @@ namespace Microsoft.EntityFrameworkCore.Query { public abstract class TPTInheritanceQueryFixture : InheritanceQueryFixtureBase { - protected override string StoreName => "TPTInheritanceTest"; + protected override string StoreName + => "TPTInheritanceTest"; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; - protected override bool HasDiscriminator => false; + protected override bool HasDiscriminator + => false; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Relational.Specification.Tests/Query/TPTInheritanceQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/TPTInheritanceQueryTestBase.cs index 0b6eab93e46..5581b96339d 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/TPTInheritanceQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/TPTInheritanceQueryTestBase.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. - // ReSharper disable InconsistentNaming + using System; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Diagnostics; @@ -22,19 +22,24 @@ public TPTInheritanceQueryTestBase(TFixture fixture) } // Keyless entities does not have TPT - public override Task Can_query_all_animal_views(bool async) => Task.CompletedTask; + public override Task Can_query_all_animal_views(bool async) + => Task.CompletedTask; // TPT does not have discriminator - public override Task Discriminator_used_when_projection_over_derived_type(bool async) => Task.CompletedTask; + public override Task Discriminator_used_when_projection_over_derived_type(bool async) + => Task.CompletedTask; // TPT does not have discriminator - public override Task Discriminator_used_when_projection_over_derived_type2(bool async) => Task.CompletedTask; + public override Task Discriminator_used_when_projection_over_derived_type2(bool async) + => Task.CompletedTask; // TPT does not have discriminator - public override Task Discriminator_used_when_projection_over_of_type(bool async) => Task.CompletedTask; + public override Task Discriminator_used_when_projection_over_of_type(bool async) + => Task.CompletedTask; // TPT does not have discriminator - public override Task Discriminator_with_cast_in_shadow_property(bool async) => Task.CompletedTask; + public override Task Discriminator_with_cast_in_shadow_property(bool async) + => Task.CompletedTask; [ConditionalFact] public virtual void Using_from_sql_throws() @@ -45,7 +50,8 @@ public virtual void Using_from_sql_throws() Assert.Equal(RelationalStrings.NonTPHOnFromSqlNotSupported("FromSqlRaw", typeof(Bird).Name), message); - message = Assert.Throws(() => context.Set().FromSqlInterpolated($"Select * from Birds")).Message; + message = Assert.Throws(() => context.Set().FromSqlInterpolated($"Select * from Birds")) + .Message; Assert.Equal(RelationalStrings.NonTPHOnFromSqlNotSupported("FromSqlInterpolated", typeof(Bird).Name), message); } diff --git a/test/EFCore.Relational.Specification.Tests/Query/TPTRelationshipsQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/TPTRelationshipsQueryTestBase.cs index 4ffe46099ec..7201871df30 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/TPTRelationshipsQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/TPTRelationshipsQueryTestBase.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // ReSharper disable InconsistentNaming + namespace Microsoft.EntityFrameworkCore.Query { public abstract class TPTRelationshipsQueryTestBase : InheritanceRelationshipsQueryRelationalTestBase diff --git a/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs index 932f59fefca..5f7ba263335 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs @@ -15,11 +15,13 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class UdfDbFunctionTestBase : IClassFixture where TFixture : SharedStoreFixtureBase, new() { - protected UdfDbFunctionTestBase(TFixture fixture) => Fixture = fixture; + protected UdfDbFunctionTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } - protected UDFSqlContext CreateContext() => (UDFSqlContext)Fixture.CreateContext(); + protected UDFSqlContext CreateContext() + => (UDFSqlContext)Fixture.CreateContext(); #region Model @@ -127,59 +129,102 @@ public enum ReportingPeriod } [DbFunction("len", IsBuiltIn = true)] - public static long MyCustomLengthStatic(string s) => throw new Exception(); - public static bool IsDateStatic(string date) => throw new Exception(); - public static int AddOneStatic(int num) => num + 1; - public static int AddFiveStatic(int number) => number + 5; - public static int CustomerOrderCountStatic(int customerId) => throw new NotImplementedException(); + public static long MyCustomLengthStatic(string s) + => throw new Exception(); - public static int CustomerOrderCountWithClientStatic(int customerId) => customerId switch - { - 1 => 3, - 2 => 2, - 3 => 1, - 4 => 0, - _ => throw new Exception() - }; - - public static string StarValueStatic(int starCount, int value) => throw new NotImplementedException(); - public static bool IsTopCustomerStatic(int customerId) => throw new NotImplementedException(); - public static int GetCustomerWithMostOrdersAfterDateStatic(DateTime? startDate) => throw new NotImplementedException(); - public static DateTime? GetReportingPeriodStartDateStatic(ReportingPeriod periodId) => throw new NotImplementedException(); - public static string GetSqlFragmentStatic() => throw new NotImplementedException(); - - public long MyCustomLengthInstance(string s) => throw new Exception(); - public bool IsDateInstance(string date) => throw new Exception(); - public int AddOneInstance(int num) => num + 1; - public int AddFiveInstance(int number) => number + 5; - public int CustomerOrderCountInstance(int customerId) => throw new NotImplementedException(); - - public int CustomerOrderCountWithClientInstance(int customerId) => customerId switch - { - 1 => 3, - 2 => 2, - 3 => 1, - 4 => 0, - _ => throw new Exception() - }; - - public string StarValueInstance(int starCount, int value) => throw new NotImplementedException(); - public bool IsTopCustomerInstance(int customerId) => throw new NotImplementedException(); - public int GetCustomerWithMostOrdersAfterDateInstance(DateTime? startDate) => throw new NotImplementedException(); - public DateTime? GetReportingPeriodStartDateInstance(ReportingPeriod periodId) => throw new NotImplementedException(); - public string DollarValueInstance(int starCount, string value) => throw new NotImplementedException(); + public static bool IsDateStatic(string date) + => throw new Exception(); + + public static int AddOneStatic(int num) + => num + 1; + + public static int AddFiveStatic(int number) + => number + 5; + + public static int CustomerOrderCountStatic(int customerId) + => throw new NotImplementedException(); + + public static int CustomerOrderCountWithClientStatic(int customerId) + => customerId switch + { + 1 => 3, + 2 => 2, + 3 => 1, + 4 => 0, + _ => throw new Exception() + }; + + public static string StarValueStatic(int starCount, int value) + => throw new NotImplementedException(); + + public static bool IsTopCustomerStatic(int customerId) + => throw new NotImplementedException(); + + public static int GetCustomerWithMostOrdersAfterDateStatic(DateTime? startDate) + => throw new NotImplementedException(); + + public static DateTime? GetReportingPeriodStartDateStatic(ReportingPeriod periodId) + => throw new NotImplementedException(); + + public static string GetSqlFragmentStatic() + => throw new NotImplementedException(); + + public long MyCustomLengthInstance(string s) + => throw new Exception(); + + public bool IsDateInstance(string date) + => throw new Exception(); + + public int AddOneInstance(int num) + => num + 1; + + public int AddFiveInstance(int number) + => number + 5; + + public int CustomerOrderCountInstance(int customerId) + => throw new NotImplementedException(); + + public int CustomerOrderCountWithClientInstance(int customerId) + => customerId switch + { + 1 => 3, + 2 => 2, + 3 => 1, + 4 => 0, + _ => throw new Exception() + }; + + public string StarValueInstance(int starCount, int value) + => throw new NotImplementedException(); + + public bool IsTopCustomerInstance(int customerId) + => throw new NotImplementedException(); + + public int GetCustomerWithMostOrdersAfterDateInstance(DateTime? startDate) + => throw new NotImplementedException(); + + public DateTime? GetReportingPeriodStartDateInstance(ReportingPeriod periodId) + => throw new NotImplementedException(); + + public string DollarValueInstance(int starCount, string value) + => throw new NotImplementedException(); [DbFunction(Schema = "dbo")] - public static string IdentityString(string s) => throw new Exception(); + public static string IdentityString(string s) + => throw new Exception(); - public static string IdentityStringPropagateNull(string s) => throw new Exception(); + public static string IdentityStringPropagateNull(string s) + => throw new Exception(); [DbFunction(IsNullable = false)] - public static string IdentityStringNonNullable(string s) => throw new Exception(); + public static string IdentityStringNonNullable(string s) + => throw new Exception(); - public static string IdentityStringNonNullableFluent(string s) => throw new Exception(); + public static string IdentityStringNonNullableFluent(string s) + => throw new Exception(); - public string StringLength(string s) => throw new Exception(); + public string StringLength(string s) + => throw new Exception(); public int AddValues(int a, int b) { @@ -254,7 +299,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.HasDbFunction(typeof(UDFSqlContext).GetMethod(nameof(IdentityStringPropagateNull), new[] { typeof(string) })) .HasParameter("s").PropagatesNullability(); - modelBuilder.HasDbFunction(typeof(UDFSqlContext).GetMethod(nameof(IdentityStringNonNullableFluent), new[] { typeof(string) })) + modelBuilder.HasDbFunction( + typeof(UDFSqlContext).GetMethod(nameof(IdentityStringNonNullableFluent), new[] { typeof(string) })) .IsNullable(false); //Instance @@ -284,7 +330,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) //Table modelBuilder.HasDbFunction(typeof(UDFSqlContext).GetMethod(nameof(GetCustomerOrderCountByYear), new[] { typeof(int) })); - modelBuilder.HasDbFunction(typeof(UDFSqlContext).GetMethod(nameof(GetCustomerOrderCountByYearOnlyFrom2000), new[] { typeof(int), typeof(bool) })); + modelBuilder.HasDbFunction( + typeof(UDFSqlContext).GetMethod(nameof(GetCustomerOrderCountByYearOnlyFrom2000), new[] { typeof(int), typeof(bool) })); modelBuilder.HasDbFunction(typeof(UDFSqlContext).GetMethod(nameof(GetTopTwoSellingProducts))); modelBuilder.HasDbFunction(typeof(UDFSqlContext).GetMethod(nameof(GetTopSellingProductsForCustomer))); modelBuilder.HasDbFunction(typeof(UDFSqlContext).GetMethod(nameof(GetOrdersWithMultipleProducts))); @@ -300,7 +347,8 @@ public abstract class UdfFixtureBase : SharedStoreFixtureBase { protected override Type ContextType { get; } = typeof(UDFSqlContext); - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; protected override bool ShouldLogCategory(string logCategory) => logCategory == DbLoggerCategory.Query.Name; @@ -321,8 +369,7 @@ protected override void Seed(DbContext context) OrderDate = new DateTime(2000, 1, 20), Items = new List { - new LineItem { Quantity = 5, Product = product1}, - new LineItem { Quantity = 15, Product = product3} + new LineItem { Quantity = 5, Product = product1 }, new LineItem { Quantity = 15, Product = product3 } } }; @@ -332,9 +379,9 @@ protected override void Seed(DbContext context) OrderDate = new DateTime(2000, 2, 21), Items = new List { - new LineItem { Quantity = 1, Product = product1}, - new LineItem { Quantity = 6, Product = product2}, - new LineItem { Quantity = 200, Product = product3} + new LineItem { Quantity = 1, Product = product1 }, + new LineItem { Quantity = 6, Product = product2 }, + new LineItem { Quantity = 200, Product = product3 } } }; @@ -342,10 +389,7 @@ protected override void Seed(DbContext context) { Name = "Order13", OrderDate = new DateTime(2001, 3, 20), - Items = new List - { - new LineItem { Quantity = 50, Product = product4}, - } + Items = new List { new LineItem { Quantity = 50, Product = product4 }, } }; var order21 = new Order @@ -354,9 +398,9 @@ protected override void Seed(DbContext context) OrderDate = new DateTime(2000, 4, 21), Items = new List { - new LineItem { Quantity = 1, Product = product1}, - new LineItem { Quantity = 34, Product = product4}, - new LineItem { Quantity = 100, Product = product5} + new LineItem { Quantity = 1, Product = product1 }, + new LineItem { Quantity = 34, Product = product4 }, + new LineItem { Quantity = 100, Product = product5 } } }; @@ -366,8 +410,7 @@ protected override void Seed(DbContext context) OrderDate = new DateTime(2000, 5, 20), Items = new List { - new LineItem { Quantity = 34, Product = product3}, - new LineItem { Quantity = 100, Product = product4} + new LineItem { Quantity = 34, Product = product3 }, new LineItem { Quantity = 100, Product = product4 } } }; @@ -375,26 +418,68 @@ protected override void Seed(DbContext context) { Name = "Order31", OrderDate = new DateTime(2001, 6, 21), - Items = new List - { - new LineItem { Quantity = 5, Product = product5} - } + Items = new List { new LineItem { Quantity = 5, Product = product5 } } }; - var address11 = new Address { Street = "1600 Pennsylvania Avenue", City = "Washington", State = "DC" }; - var address12 = new Address { Street = "742 Evergreen Terrace", City = "SpringField", State = "" }; - var address21 = new Address { Street = "Apartment 5A, 129 West 81st Street", City = "New York", State = "NY" }; - var address31 = new Address { Street = "425 Grove Street, Apt 20", City = "New York", State = "NY" }; - var address32 = new Address { Street = "342 GravelPit Terrace", City = "BedRock", State = "" }; - var address41 = new Address { Street = "4222 Clinton Way", City = "Los Angles", State = "CA" }; - var address42 = new Address { Street = "1060 West Addison Street", City = "Chicago", State = "IL" }; - var address43 = new Address { Street = "112 ½ Beacon Street", City = "Boston", State = "MA" }; + var address11 = new Address + { + Street = "1600 Pennsylvania Avenue", + City = "Washington", + State = "DC" + }; + var address12 = new Address + { + Street = "742 Evergreen Terrace", + City = "SpringField", + State = "" + }; + var address21 = new Address + { + Street = "Apartment 5A, 129 West 81st Street", + City = "New York", + State = "NY" + }; + var address31 = new Address + { + Street = "425 Grove Street, Apt 20", + City = "New York", + State = "NY" + }; + var address32 = new Address + { + Street = "342 GravelPit Terrace", + City = "BedRock", + State = "" + }; + var address41 = new Address + { + Street = "4222 Clinton Way", + City = "Los Angles", + State = "CA" + }; + var address42 = new Address + { + Street = "1060 West Addison Street", + City = "Chicago", + State = "IL" + }; + var address43 = new Address + { + Street = "112 ½ Beacon Street", + City = "Boston", + State = "MA" + }; var customer1 = new Customer { FirstName = "Customer", LastName = "One", - Orders = new List { order11, order12, order13 }, + Orders = new List + { + order11, + order12, + order13 + }, Addresses = new List
{ address11, address12 } }; @@ -418,11 +503,17 @@ protected override void Seed(DbContext context) { FirstName = "Customer", LastName = "Four", - Addresses = new List
{ address41, address42, address43 } + Addresses = new List
+ { + address41, + address42, + address43 + } }; ((UDFSqlContext)context).Products.AddRange(product1, product2, product3, product4, product5); - ((UDFSqlContext)context).Addresses.AddRange(address11, address12, address21, address31, address32, address41, address42, address43); + ((UDFSqlContext)context).Addresses.AddRange( + address11, address12, address21, address31, address32, address41, address42, address43); ((UDFSqlContext)context).Customers.AddRange(customer1, customer2, customer3, customer4); ((UDFSqlContext)context).Orders.AddRange(order11, order12, order13, order21, order22, order31); } @@ -466,8 +557,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()); } @@ -871,8 +961,9 @@ public virtual void Compare_non_nullable_function_to_null_gets_optimized() var result = context.Customers .OrderBy(c => c.Id) - .Where(c => UDFSqlContext.IdentityStringNonNullable(c.FirstName) != null - && UDFSqlContext.IdentityStringNonNullableFluent(c.FirstName) != null) + .Where( + c => UDFSqlContext.IdentityStringNonNullable(c.FirstName) != null + && UDFSqlContext.IdentityStringNonNullableFluent(c.FirstName) != null) .ToList(); Assert.Equal(4, result.Count); @@ -1340,7 +1431,6 @@ public virtual void QF_Anonymous_Collection_No_IQueryable_In_Projection_Throws() var query = (from c in context.Customers select new { c.Id, orders = context.GetCustomerOrderCountByYear(c.Id) }); - //Assert.Contains( // RelationalStrings.DbFunctionCantProjectIQueryable(), // Assert.Throws(() => query.ToList()).Message); @@ -1390,7 +1480,7 @@ public virtual void QF_CrossApply_Correlated_Select_QF_Type() from r in context.GetCustomerOrderCountByYear(c.Id) orderby r.Year select r - ).ToList(); + ).ToList(); Assert.Equal(4, orders.Count); Assert.Equal(2, orders[0].Count); @@ -1444,8 +1534,7 @@ public virtual void QF_Select_Direct_In_Anonymous() var results = (from c in context.Customers select new { - c.Id, - Prods = context.GetTopTwoSellingProducts().ToList(), + c.Id, Prods = context.GetTopTwoSellingProducts().ToList(), }).ToList(); Assert.Equal(4, results.Count); @@ -1463,11 +1552,8 @@ public virtual void QF_Select_Correlated_Direct_With_Function_Query_Parameter_Co { var cust = (from c in context.Customers where c.Id == 1 - select new - { - c.Id, - Orders = context.GetOrdersWithMultipleProducts(context.AddValues(c.Id, 1)).ToList() - }).ToList(); + select new { c.Id, Orders = context.GetOrdersWithMultipleProducts(context.AddValues(c.Id, 1)).ToList() }) + .ToList(); Assert.Single(cust); @@ -1488,7 +1574,8 @@ public virtual void QF_Select_Correlated_Subquery_In_Anonymous() select new { c.Id, - OrderCountYear = context.GetOrdersWithMultipleProducts(c.Id).Where(o => o.OrderDate.Day == 21).ToList() + OrderCountYear = context.GetOrdersWithMultipleProducts(c.Id).Where(o => o.OrderDate.Day == 21) + .ToList() }).ToList(); Assert.Equal(4, results.Count); @@ -1540,11 +1627,12 @@ public virtual void QF_Select_Correlated_Subquery_In_Anonymous_Nested() select new { c.Id, - OrderCountYear = context.GetOrdersWithMultipleProducts(c.Id).Where(o => o.OrderDate.Day == 21).Select(o => new - { - OrderCountYearNested = context.GetOrdersWithMultipleProducts(o.CustomerId).ToList(), - Prods = context.GetTopTwoSellingProducts().ToList(), - }).ToList() + OrderCountYear = context.GetOrdersWithMultipleProducts(c.Id).Where(o => o.OrderDate.Day == 21).Select( + o => new + { + OrderCountYearNested = context.GetOrdersWithMultipleProducts(o.CustomerId).ToList(), + Prods = context.GetTopTwoSellingProducts().ToList(), + }).ToList() }).ToList(); Assert.Equal(4, results.Count); @@ -1572,7 +1660,8 @@ public virtual void QF_Select_Correlated_Subquery_In_Anonymous_MultipleCollectio select new { c.Id, - Prods = context.GetTopTwoSellingProducts().Where(p => p.AmountSold == 249).Select(p => p.ProductId).ToList(), + Prods = context.GetTopTwoSellingProducts().Where(p => p.AmountSold == 249).Select(p => p.ProductId) + .ToList(), Addresses = c.Addresses.Where(a => a.State == "NY").ToList() }).ToList(); @@ -1598,7 +1687,8 @@ public virtual void QF_Select_NonCorrelated_Subquery_In_Anonymous() select new { c.Id, - Prods = context.GetTopTwoSellingProducts().Where(p => p.AmountSold == 249).Select(p => p.ProductId).ToList(), + Prods = context.GetTopTwoSellingProducts().Where(p => p.AmountSold == 249).Select(p => p.ProductId) + .ToList(), }).ToList(); Assert.Equal(4, results.Count); @@ -1620,7 +1710,8 @@ public virtual void QF_Select_NonCorrelated_Subquery_In_Anonymous_Parameter() select new { c.Id, - Prods = context.GetTopTwoSellingProducts().Where(p => p.AmountSold == amount).Select(p => p.ProductId).ToList(), + Prods = context.GetTopTwoSellingProducts().Where(p => p.AmountSold == amount).Select(p => p.ProductId) + .ToList(), }).ToList(); Assert.Equal(4, results.Count); @@ -1944,7 +2035,6 @@ orderby r.Year } } - [ConditionalFact] public virtual void QF_Correlated_Nested_Func_Call() { @@ -1979,12 +2069,13 @@ orderby c.Id select new { c.Id, - Orders = context.GetOrdersWithMultipleProducts(c.Id).Select(mpo => new - { - //how to I setup the PK/FK combo properly for this? Is it even possible? - //OrderName = mpo.Order.Name, - CustomerName = mpo.Customer.LastName - }).ToList() + Orders = context.GetOrdersWithMultipleProducts(c.Id).Select( + mpo => new + { + //how to I setup the PK/FK combo properly for this? Is it even possible? + //OrderName = mpo.Order.Name, + CustomerName = mpo.Customer.LastName + }).ToList() }).ToList(); Assert.Equal(4, cust.Count); @@ -2035,7 +2126,7 @@ public virtual void Udf_with_argument_being_comparison_to_null_parameter() from r in context.GetCustomerOrderCountByYearOnlyFrom2000(c.Id, c.LastName != prm) orderby r.Year select r - ).ToList(); + ).ToList(); Assert.Equal(4, query.Count); Assert.Equal(1, query[0].CustomerId); @@ -2059,10 +2150,16 @@ public virtual void Udf_with_argument_being_comparison_of_nullable_columns() from r in context.Orders.ToList() .Where(x => x.CustomerId == 1 && (a.City != a.State || x.OrderDate.Year == 2000)) .GroupBy(x => new { x.CustomerId, x.OrderDate.Year }) - .Select(x => new OrderByYear { CustomerId = x.Key.CustomerId, Year = x.Key.Year, Count = x.Count() }) + .Select( + x => new OrderByYear + { + CustomerId = x.Key.CustomerId, + Year = x.Key.Year, + Count = x.Count() + }) orderby a.Id, r.Year select r - ).ToList(); + ).ToList(); ClearLog(); @@ -2070,7 +2167,7 @@ select r from r in context.GetCustomerOrderCountByYearOnlyFrom2000(1, a.City == a.State) orderby a.Id, r.Year select r - ).ToList(); + ).ToList(); Assert.Equal(expected.Count, query.Count); for (var i = 0; i < expected.Count; i++) diff --git a/test/EFCore.Relational.Specification.Tests/Query/WarningsTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/WarningsTestBase.cs index 4ff91ef3055..984d5987475 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/WarningsTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/WarningsTestBase.cs @@ -23,7 +23,8 @@ protected WarningsTestBase(TFixture fixture) fixture.ListLoggerFactory.Clear(); } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); [ConditionalFact] public virtual void Does_not_throw_for_top_level_single() diff --git a/test/EFCore.Relational.Specification.Tests/TestModels/Northwind/NorthwindRelationalContext.cs b/test/EFCore.Relational.Specification.Tests/TestModels/Northwind/NorthwindRelationalContext.cs index 3445ea12923..e9a8c11cd60 100644 --- a/test/EFCore.Relational.Specification.Tests/TestModels/Northwind/NorthwindRelationalContext.cs +++ b/test/EFCore.Relational.Specification.Tests/TestModels/Northwind/NorthwindRelationalContext.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.Linq; - namespace Microsoft.EntityFrameworkCore.TestModels.Northwind { public class NorthwindRelationalContext : NorthwindContext @@ -12,7 +10,6 @@ public NorthwindRelationalContext(DbContextOptions options) { } - protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); @@ -26,7 +23,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().HasKey(coh => coh.ProductName); modelBuilder.Entity().HasKey(mep => mep.TenMostExpensiveProducts); - modelBuilder.Entity().ToSqlQuery("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]"); + modelBuilder.Entity().ToSqlQuery( + "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]"); modelBuilder.Entity().ToSqlQuery(@"select * from ""Orders"""); modelBuilder.Entity().ToView("Alphabetical list of products"); diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalDatabaseCleaner.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalDatabaseCleaner.cs index 709f36b83fb..0809f5a3242 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalDatabaseCleaner.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalDatabaseCleaner.cs @@ -19,19 +19,26 @@ public abstract class RelationalDatabaseCleaner { protected abstract IDatabaseModelFactory CreateDatabaseModelFactory(ILoggerFactory loggerFactory); - protected virtual bool AcceptTable(DatabaseTable table) => true; + protected virtual bool AcceptTable(DatabaseTable table) + => true; - protected virtual bool AcceptForeignKey(DatabaseForeignKey foreignKey) => true; + protected virtual bool AcceptForeignKey(DatabaseForeignKey foreignKey) + => true; - protected virtual bool AcceptIndex(DatabaseIndex index) => true; + protected virtual bool AcceptIndex(DatabaseIndex index) + => true; - protected virtual bool AcceptSequence(DatabaseSequence sequence) => true; + protected virtual bool AcceptSequence(DatabaseSequence sequence) + => true; - protected virtual string BuildCustomSql(DatabaseModel databaseModel) => null; + protected virtual string BuildCustomSql(DatabaseModel databaseModel) + => null; - protected virtual string BuildCustomEndingSql(DatabaseModel databaseModel) => null; + protected virtual string BuildCustomEndingSql(DatabaseModel databaseModel) + => null; - protected virtual void OpenConnection(IRelationalConnection connection) => connection.Open(); + protected virtual void OpenConnection(IRelationalConnection connection) + => connection.Open(); public virtual void Clean(DatabaseFacade facade) { diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalTestStore.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalTestStore.cs index eceb4d9a564..50d79039d51 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalTestStore.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/RelationalTestStore.cs @@ -11,11 +11,21 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities public abstract class RelationalTestStore : TestStore { public virtual string ConnectionString { get; protected set; } - public ConnectionState ConnectionState => Connection.State; - public void CloseConnection() => Connection.Close(); - public virtual void OpenConnection() => Connection.Open(); - public virtual Task OpenConnectionAsync() => Connection.OpenAsync(); - public DbTransaction BeginTransaction() => Connection.BeginTransaction(); + + public ConnectionState ConnectionState + => Connection.State; + + public void CloseConnection() + => Connection.Close(); + + public virtual void OpenConnection() + => Connection.Open(); + + public virtual Task OpenConnectionAsync() + => Connection.OpenAsync(); + + public DbTransaction BeginTransaction() + => Connection.BeginTransaction(); protected virtual DbConnection Connection { get; set; } @@ -25,7 +35,10 @@ protected RelationalTestStore(string name, bool shared) } public override TestStore Initialize( - IServiceProvider serviceProvider, Func createContext, Action seed = null, Action clean = null) + IServiceProvider serviceProvider, + Func createContext, + Action seed = null, + Action clean = null) { base.Initialize(serviceProvider, createContext, seed, clean); @@ -49,8 +62,10 @@ public virtual string NormalizeDelimitersInRawString(string sql) public virtual FormattableString NormalizeDelimitersInInterpolatedString(FormattableString sql) => new TestFormattableString(NormalizeDelimitersInRawString(sql.Format), sql.GetArguments()); - protected virtual string OpenDelimiter => "\""; + protected virtual string OpenDelimiter + => "\""; - protected virtual string CloseDelimiter => "\""; + protected virtual string CloseDelimiter + => "\""; } } diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs index 9a3ada9e6c7..65b4c068e84 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs @@ -31,9 +31,14 @@ public TestSqlLoggerFactory(Func shouldLogCategory) Logger = new TestSqlLogger(shouldLogCategory(DbLoggerCategory.Database.Command.Name)); } - public IReadOnlyList SqlStatements => ((TestSqlLogger)Logger).SqlStatements; - public IReadOnlyList Parameters => ((TestSqlLogger)Logger).Parameters; - public string Sql => string.Join(_eol + _eol, SqlStatements); + public IReadOnlyList SqlStatements + => ((TestSqlLogger)Logger).SqlStatements; + + public IReadOnlyList Parameters + => ((TestSqlLogger)Logger).Parameters; + + public string Sql + => string.Join(_eol + _eol, SqlStatements); public void AssertBaseline(string[] expected, bool assertOrder = true) { @@ -110,7 +115,8 @@ protected class TestSqlLogger : ListLogger { private readonly bool _shouldLogCommands; - public TestSqlLogger(bool shouldLogCommands) => _shouldLogCommands = shouldLogCommands; + public TestSqlLogger(bool shouldLogCommands) + => _shouldLogCommands = shouldLogCommands; public List SqlStatements { get; } = new List(); public List Parameters { get; } = new List(); @@ -124,7 +130,11 @@ protected override void UnsafeClear() } protected override void UnsafeLog( - LogLevel logLevel, EventId eventId, string message, TState state, Exception exception) + LogLevel logLevel, + EventId eventId, + string message, + TState state, + Exception exception) { if ((eventId.Id == RelationalEventId.CommandExecuted.Id || eventId.Id == RelationalEventId.CommandError.Id diff --git a/test/EFCore.Relational.Specification.Tests/TransactionInterceptionTestBase.cs b/test/EFCore.Relational.Specification.Tests/TransactionInterceptionTestBase.cs index d8c22d05fbb..e961b516a82 100644 --- a/test/EFCore.Relational.Specification.Tests/TransactionInterceptionTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/TransactionInterceptionTestBase.cs @@ -423,6 +423,7 @@ public virtual async Task Intercept_RollbackToSavepoint(bool async) { contextTransaction.CreateSavepoint("dummy"); } + interceptor.Reset(); using var listener = Fixture.SubscribeToDiagnosticListener(context.ContextId); @@ -460,6 +461,7 @@ public virtual async Task Intercept_ReleaseSavepoint(bool async) { contextTransaction.CreateSavepoint("dummy"); } + interceptor.Reset(); using var listener = Fixture.SubscribeToDiagnosticListener(context.ContextId); @@ -615,11 +617,20 @@ public WrappedDbTransaction(DbTransaction transaction) _transaction = transaction; } - public override void Commit() => _transaction.Commit(); - public override void Rollback() => _transaction.Rollback(); - protected override DbConnection DbConnection => _transaction.Connection; - public override IsolationLevel IsolationLevel => _transaction.IsolationLevel; - protected override void Dispose(bool disposing) => _transaction.Dispose(); + public override void Commit() + => _transaction.Commit(); + + public override void Rollback() + => _transaction.Rollback(); + + protected override DbConnection DbConnection + => _transaction.Connection; + + public override IsolationLevel IsolationLevel + => _transaction.IsolationLevel; + + protected override void Dispose(bool disposing) + => _transaction.Dispose(); } private class FakeDbTransaction : DbTransaction diff --git a/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs b/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs index dd9bde34bae..c6624a7babc 100644 --- a/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/TransactionTestBase.cs @@ -427,6 +427,7 @@ public virtual void SaveChanges_allows_nested_ambient_transactions() TestStore.CloseConnection(); } } + Assert.Equal( new List { @@ -474,12 +475,9 @@ public virtual void SaveChanges_allows_independent_ambient_transaction_commits() TestStore.CloseConnection(); } } + Assert.Equal( - new List - { - 1, - 2 - }, + new List { 1, 2 }, context.Set().OrderBy(c => c.Id).Select(e => e.Id).ToList()); Assert.Equal( new List @@ -608,7 +606,9 @@ public virtual async Task SaveChanges_uses_explicit_transaction_without_committi [InlineData(true, false)] [InlineData(false, true)] [InlineData(false, false)] - public virtual async Task SaveChanges_false_uses_explicit_transaction_without_committing_or_accepting_changes(bool async, bool autoTransaction) + public virtual async Task SaveChanges_false_uses_explicit_transaction_without_committing_or_accepting_changes( + bool async, + bool autoTransaction) { using (var context = CreateContext()) { @@ -1215,17 +1215,22 @@ protected virtual void AssertStoreInitialState() Assert.Equal(Customers, context.Set().OrderBy(c => c.Id)); } - protected RelationalTestStore TestStore => (RelationalTestStore)Fixture.TestStore; + protected RelationalTestStore TestStore + => (RelationalTestStore)Fixture.TestStore; protected abstract bool SnapshotSupported { get; } - protected virtual bool AmbientTransactionsSupported => false; + protected virtual bool AmbientTransactionsSupported + => false; - protected virtual bool DirtyReadsOccur => true; + protected virtual bool DirtyReadsOccur + => true; - protected virtual bool SavepointsSupported => true; + protected virtual bool SavepointsSupported + => true; - protected DbContext CreateContext() => Fixture.CreateContext(); + protected DbContext CreateContext() + => Fixture.CreateContext(); protected abstract DbContext CreateContextWithConnectionString(); @@ -1275,6 +1280,7 @@ protected abstract class TransactionEntity { public int Id { get; set; } public string Name { get; set; } + public override bool Equals(object obj) { return !(obj is TransactionCustomer otherCustomer) @@ -1283,13 +1289,19 @@ public override bool Equals(object obj) && Name == otherCustomer.Name; } - public override string ToString() => "Id = " + Id + ", Name = " + Name; + public override string ToString() + => "Id = " + Id + ", Name = " + Name; - public override int GetHashCode() => HashCode.Combine(Id, Name); + public override int GetHashCode() + => HashCode.Combine(Id, Name); + } + protected class TransactionCustomer : TransactionEntity + { } - protected class TransactionCustomer : TransactionEntity { } - protected class TransactionOrder : TransactionEntity { } + protected class TransactionOrder : TransactionEntity + { + } } } diff --git a/test/EFCore.Relational.Specification.Tests/TwoDatabasesTestBase.cs b/test/EFCore.Relational.Specification.Tests/TwoDatabasesTestBase.cs index 7db65bc3b76..36f627b5610 100644 --- a/test/EFCore.Relational.Specification.Tests/TwoDatabasesTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/TwoDatabasesTestBase.cs @@ -89,8 +89,9 @@ public virtual void Can_set_connection_string_in_interceptor() using (var context = new TwoDatabasesContext( CreateTestOptions(new DbContextOptionsBuilder(), withConnectionString: true) - .AddInterceptors(new ConnectionStringConnectionInterceptor( - connectionString1, DummyConnectionString)) + .AddInterceptors( + new ConnectionStringConnectionInterceptor( + connectionString1, DummyConnectionString)) .Options)) { var data = context.Foos.ToList(); @@ -114,7 +115,10 @@ public ConnectionStringConnectionInterceptor(string goodConnectionString, string _dummyConnectionString = dummyConnectionString; } - public override InterceptionResult ConnectionOpening(DbConnection connection, ConnectionEventData eventData, InterceptionResult result) + public override InterceptionResult ConnectionOpening( + DbConnection connection, + ConnectionEventData eventData, + InterceptionResult result) { Assert.Equal(_dummyConnectionString, eventData.Context.Database.GetConnectionString()); eventData.Context.Database.SetConnectionString(_goodConnectionString); @@ -130,11 +134,12 @@ public override void ConnectionClosed(DbConnection connection, ConnectionEndEven } protected abstract DbContextOptionsBuilder CreateTestOptions( - DbContextOptionsBuilder optionsBuilder, bool withConnectionString = false); + DbContextOptionsBuilder optionsBuilder, + bool withConnectionString = false); protected abstract TwoDatabasesWithDataContext CreateBackingContext(string databaseName); - protected abstract string DummyConnectionString { get; } + protected abstract string DummyConnectionString { get; } protected class TwoDatabasesContext : DbContext { @@ -148,7 +153,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity(); } - public IQueryable Foos => this.Set().OrderBy(e => e.Id); + public IQueryable Foos + => Set().OrderBy(e => e.Id); } protected class TwoDatabasesWithDataContext : TwoDatabasesContext @@ -174,6 +180,7 @@ protected class Foo { [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } + public string Bar { get; set; } } } diff --git a/test/EFCore.Relational.Specification.Tests/UpdatesRelationalFixture.cs b/test/EFCore.Relational.Specification.Tests/UpdatesRelationalFixture.cs index a5ed1b63705..e459f3d53a7 100644 --- a/test/EFCore.Relational.Specification.Tests/UpdatesRelationalFixture.cs +++ b/test/EFCore.Relational.Specification.Tests/UpdatesRelationalFixture.cs @@ -8,7 +8,8 @@ namespace Microsoft.EntityFrameworkCore { public abstract class UpdatesRelationalFixture : UpdatesFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Relational.Specification.Tests/UpdatesRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/UpdatesRelationalTestBase.cs index d8096f743f4..1d673f93210 100644 --- a/test/EFCore.Relational.Specification.Tests/UpdatesRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/UpdatesRelationalTestBase.cs @@ -73,7 +73,8 @@ public virtual void SaveChanges_throws_for_entities_only_mapped_to_view() DependentId = category.Id }); - Assert.Equal(RelationalStrings.ReadonlyEntitySaved(nameof(ProductTableView)), + Assert.Equal( + RelationalStrings.ReadonlyEntitySaved(nameof(ProductTableView)), Assert.Throws(() => context.SaveChanges()).Message); }); } diff --git a/test/EFCore.Relational.Tests/Design/AnnotationCodeGeneratorTest.cs b/test/EFCore.Relational.Tests/Design/AnnotationCodeGeneratorTest.cs index 3952fb64d09..e4d4c3f74fc 100644 --- a/test/EFCore.Relational.Tests/Design/AnnotationCodeGeneratorTest.cs +++ b/test/EFCore.Relational.Tests/Design/AnnotationCodeGeneratorTest.cs @@ -24,12 +24,14 @@ public void IsTableExcludedFromMigrations_false_is_handled_by_convention() Assert.DoesNotContain(RelationalAnnotationNames.IsTableExcludedFromMigrations, annotations.Keys); } - private ModelBuilder CreateModelBuilder() => RelationalTestHelpers.Instance.CreateConventionBuilder(); + private ModelBuilder CreateModelBuilder() + => RelationalTestHelpers.Instance.CreateConventionBuilder(); - private AnnotationCodeGenerator CreateGenerator() => new AnnotationCodeGenerator( - new AnnotationCodeGeneratorDependencies( - new TestRelationalTypeMappingSource( - TestServiceFactory.Instance.Create(), - TestServiceFactory.Instance.Create()))); + private AnnotationCodeGenerator CreateGenerator() + => new AnnotationCodeGenerator( + new AnnotationCodeGeneratorDependencies( + new TestRelationalTypeMappingSource( + TestServiceFactory.Instance.Create(), + TestServiceFactory.Instance.Create()))); } } diff --git a/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs b/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs index 540fbb853d7..b4cc522ddd0 100644 --- a/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs +++ b/test/EFCore.Relational.Tests/Infrastructure/RelationalModelValidatorTest.cs @@ -1269,7 +1269,8 @@ public virtual void Detects_TPT_with_discriminator() modelBuilder.Entity().HasDiscriminator("Discriminator"); modelBuilder.Entity().ToTable("Cat"); - VerifyError(RelationalStrings.TPHTableMismatch(nameof(Cat), nameof(Cat), nameof(Animal), nameof(Animal)), + VerifyError( + RelationalStrings.TPHTableMismatch(nameof(Cat), nameof(Cat), nameof(Animal), nameof(Animal)), modelBuilder.Model); } @@ -1280,7 +1281,8 @@ public virtual void Detects_view_TPT_with_discriminator() modelBuilder.Entity().ToView("Animal").HasDiscriminator("Discriminator"); modelBuilder.Entity().ToView("Cat"); - VerifyError(RelationalStrings.TPHViewMismatch(nameof(Cat), nameof(Cat), nameof(Animal), nameof(Animal)), + VerifyError( + RelationalStrings.TPHViewMismatch(nameof(Cat), nameof(Cat), nameof(Animal), nameof(Animal)), modelBuilder.Model); } @@ -1313,11 +1315,11 @@ public virtual void Detects_linking_relationship_on_derived_type_in_TPT() .Ignore(a => a.FavoritePerson); modelBuilder.Entity( - x => - { - x.ToTable("Cat"); - x.HasOne(c => c.FavoritePerson).WithOne().HasForeignKey(c => c.Id); - }); + x => + { + x.ToTable("Cat"); + x.HasOne(c => c.FavoritePerson).WithOne().HasForeignKey(c => c.Id); + }); modelBuilder.Entity().ToTable("Cat"); @@ -1337,11 +1339,11 @@ public virtual void Detects_linking_relationship_on_derived_type_in_TPT_views() .ToView("Animal"); modelBuilder.Entity( - x => - { - x.ToView("Cat"); - x.HasOne(c => c.FavoritePerson).WithOne().HasForeignKey(c => c.Id); - }); + x => + { + x.ToView("Cat"); + x.HasOne(c => c.FavoritePerson).WithOne().HasForeignKey(c => c.Id); + }); modelBuilder.Entity().ToView("Cat"); @@ -1369,7 +1371,8 @@ public virtual void Detects_invalid_table_overrides() var property = modelBuilder.Entity().Property(a => a.Name).GetInfrastructure(); property.HasColumnName("DogName", StoreObjectIdentifier.Table("Dog", null)); - VerifyError(RelationalStrings.TableOverrideMismatch("Animal.Name", "Dog"), + VerifyError( + RelationalStrings.TableOverrideMismatch("Animal.Name", "Dog"), modelBuilder.Model); } @@ -1391,7 +1394,8 @@ public virtual void Detects_invalid_view_overrides() var property = modelBuilder.Entity().Property(a => a.Name).GetInfrastructure(); property.HasColumnName("DogName", StoreObjectIdentifier.View("Dog", null)); - VerifyError(RelationalStrings.ViewOverrideMismatch("Animal.Name", "Dog"), + VerifyError( + RelationalStrings.ViewOverrideMismatch("Animal.Name", "Dog"), modelBuilder.Model); } @@ -1402,7 +1406,8 @@ public virtual void Detects_invalid_sql_query_overrides() var property = modelBuilder.Entity().Property(a => a.Name).GetInfrastructure(); property.HasColumnName("DogName", StoreObjectIdentifier.SqlQuery("Dog")); - VerifyError(RelationalStrings.SqlQueryOverrideMismatch("Animal.Name", "Dog"), + VerifyError( + RelationalStrings.SqlQueryOverrideMismatch("Animal.Name", "Dog"), modelBuilder.Model); } @@ -1413,7 +1418,8 @@ public virtual void Detects_invalid_function_overrides() var property = modelBuilder.Entity().Property(a => a.Name).GetInfrastructure(); property.HasColumnName("DogName", StoreObjectIdentifier.DbFunction("Dog")); - VerifyError(RelationalStrings.FunctionOverrideMismatch("Animal.Name", "Dog"), + VerifyError( + RelationalStrings.FunctionOverrideMismatch("Animal.Name", "Dog"), modelBuilder.Model); } @@ -1559,12 +1565,13 @@ public void Detects_multiple_entity_types_mapped_to_the_same_function() var function = modelBuilder.HasDbFunction(TestMethods.MethodAMi).Metadata; - modelBuilder.Entity(db => - { - db.HasBaseType((string)null); - db.OwnsOne(d => d.SomeTestMethods).ToFunction(function.ModelName); - db.OwnsOne(d => d.OtherTestMethods).ToFunction(function.ModelName); - }); + modelBuilder.Entity( + db => + { + db.HasBaseType((string)null); + db.OwnsOne(d => d.SomeTestMethods).ToFunction(function.ModelName); + db.OwnsOne(d => d.OtherTestMethods).ToFunction(function.ModelName); + }); VerifyError( RelationalStrings.DbFunctionInvalidIQueryableOwnedReturnType( @@ -1690,8 +1697,9 @@ public void Passes_for_index_properties_mapped_to_same_table_in_TPT_hierarchy() Validate(modelBuilder.Model); - Assert.Empty(LoggerFactory.Log - .Where(l => l.Level != LogLevel.Trace && l.Level != LogLevel.Debug)); + Assert.Empty( + LoggerFactory.Log + .Where(l => l.Level != LogLevel.Trace && l.Level != LogLevel.Debug)); } [ConditionalFact] @@ -1759,12 +1767,14 @@ public virtual void Non_TPH_as_a_result_of_DbFunction_throws() modelBuilder.HasDbFunction(TestMethods.MethodFMi); - VerifyError(RelationalStrings.TableValuedFunctionNonTPH( - TestMethods.MethodFMi.DeclaringType.FullName + "." + TestMethods.MethodFMi.Name + "()", "C"), modelBuilder.Model); + VerifyError( + RelationalStrings.TableValuedFunctionNonTPH( + TestMethods.MethodFMi.DeclaringType.FullName + "." + TestMethods.MethodFMi.Name + "()", "C"), modelBuilder.Model); } private static void GenerateMapping(IMutableProperty property) - => property.SetTypeMapping(new TestRelationalTypeMappingSource( + => property.SetTypeMapping( + new TestRelationalTypeMappingSource( TestServiceFactory.Instance.Create(), TestServiceFactory.Instance.Create()) .FindMapping(property)); @@ -1852,19 +1862,30 @@ private class DerivedTestMethods : TestMethods private class TestMethods : BaseTestMethods { - public static readonly MethodInfo MethodAMi = typeof(TestMethods).GetTypeInfo().GetDeclaredMethod(nameof(TestMethods.MethodA)); - public static readonly MethodInfo MethodBMi = typeof(TestMethods).GetTypeInfo().GetDeclaredMethod(nameof(TestMethods.MethodB)); - public static readonly MethodInfo MethodCMi = typeof(TestMethods).GetTypeInfo().GetDeclaredMethod(nameof(TestMethods.MethodC)); - public static readonly MethodInfo MethodDMi = typeof(TestMethods).GetTypeInfo().GetDeclaredMethod(nameof(TestMethods.MethodD)); - public static readonly MethodInfo MethodEMi = typeof(TestMethods).GetTypeInfo().GetDeclaredMethod(nameof(TestMethods.MethodE)); - public static readonly MethodInfo MethodFMi = typeof(TestMethods).GetTypeInfo().GetDeclaredMethod(nameof(TestMethods.MethodF)); + public static readonly MethodInfo MethodAMi = typeof(TestMethods).GetTypeInfo().GetDeclaredMethod(nameof(MethodA)); + public static readonly MethodInfo MethodBMi = typeof(TestMethods).GetTypeInfo().GetDeclaredMethod(nameof(MethodB)); + public static readonly MethodInfo MethodCMi = typeof(TestMethods).GetTypeInfo().GetDeclaredMethod(nameof(MethodC)); + public static readonly MethodInfo MethodDMi = typeof(TestMethods).GetTypeInfo().GetDeclaredMethod(nameof(MethodD)); + public static readonly MethodInfo MethodEMi = typeof(TestMethods).GetTypeInfo().GetDeclaredMethod(nameof(MethodE)); + public static readonly MethodInfo MethodFMi = typeof(TestMethods).GetTypeInfo().GetDeclaredMethod(nameof(MethodF)); + + public static IQueryable MethodA() + => throw new NotImplementedException(); + + public static IQueryable MethodB(int id) + => throw new NotImplementedException(); + + public static TestMethods MethodC() + => throw new NotImplementedException(); + + public static int MethodD(TestMethods methods) + => throw new NotImplementedException(); + + public static int MethodE() + => throw new NotImplementedException(); - public static IQueryable MethodA() => throw new NotImplementedException(); - public static IQueryable MethodB(int id) => throw new NotImplementedException(); - public static TestMethods MethodC() => throw new NotImplementedException(); - public static int MethodD(TestMethods methods) => throw new NotImplementedException(); - public static int MethodE() => throw new NotImplementedException(); - public static IQueryable MethodF() => throw new NotImplementedException(); + public static IQueryable MethodF() + => throw new NotImplementedException(); } protected virtual ModelBuilder CreateModelBuilderWithoutConvention( @@ -1880,6 +1901,7 @@ protected virtual ModelBuilder CreateModelBuilderWithoutConvention( return new ModelBuilder(conventionSet); } - protected override TestHelpers TestHelpers => RelationalTestHelpers.Instance; + protected override TestHelpers TestHelpers + => RelationalTestHelpers.Instance; } } diff --git a/test/EFCore.Relational.Tests/Metadata/Conventions/Internal/RelationalPropertyMappingValidationConventionTest.cs b/test/EFCore.Relational.Tests/Metadata/Conventions/Internal/RelationalPropertyMappingValidationConventionTest.cs index 3d187654265..56ae9e337f3 100644 --- a/test/EFCore.Relational.Tests/Metadata/Conventions/Internal/RelationalPropertyMappingValidationConventionTest.cs +++ b/test/EFCore.Relational.Tests/Metadata/Conventions/Internal/RelationalPropertyMappingValidationConventionTest.cs @@ -43,7 +43,8 @@ public void Throws_when_added_property_is_not_mapped_to_store_even_if_configured Assert.Throws(() => CreatePropertyMappingValidator()(modelBuilder.Metadata)).Message); } - protected override TestHelpers TestHelpers => RelationalTestHelpers.Instance; + protected override TestHelpers TestHelpers + => RelationalTestHelpers.Instance; protected override IModelValidator CreateModelValidator() { diff --git a/test/EFCore.Relational.Tests/Metadata/Conventions/Internal/TableValuedDbFunctionConventionTest.cs b/test/EFCore.Relational.Tests/Metadata/Conventions/Internal/TableValuedDbFunctionConventionTest.cs index 45df1fafc85..98d1ceb0287 100644 --- a/test/EFCore.Relational.Tests/Metadata/Conventions/Internal/TableValuedDbFunctionConventionTest.cs +++ b/test/EFCore.Relational.Tests/Metadata/Conventions/Internal/TableValuedDbFunctionConventionTest.cs @@ -19,9 +19,10 @@ public class TableValuedDbFunctionConventionTest public void Configures_return_entity_as_not_mapped() { var modelBuilder = CreateModelBuilder(); - modelBuilder.HasDbFunction(typeof(TableValuedDbFunctionConventionTest).GetMethod( - nameof(GetKeylessEntities), - BindingFlags.NonPublic | BindingFlags.Static)); + modelBuilder.HasDbFunction( + typeof(TableValuedDbFunctionConventionTest).GetMethod( + nameof(GetKeylessEntities), + BindingFlags.NonPublic | BindingFlags.Static)); modelBuilder.Entity().HasNoKey(); @@ -38,9 +39,10 @@ public void Finds_existing_entity_type() { var modelBuilder = CreateModelBuilder(); modelBuilder.Entity().ToTable("TestTable").HasKey(e => e.Name); - modelBuilder.HasDbFunction(typeof(TableValuedDbFunctionConventionTest).GetMethod( - nameof(GetEntities), - BindingFlags.NonPublic | BindingFlags.Static)); + modelBuilder.HasDbFunction( + typeof(TableValuedDbFunctionConventionTest).GetMethod( + nameof(GetEntities), + BindingFlags.NonPublic | BindingFlags.Static)); var model = modelBuilder.FinalizeModel(); @@ -55,9 +57,10 @@ public void Throws_when_adding_a_function_returning_an_owned_type() { var modelBuilder = CreateModelBuilder(); modelBuilder.Owned(); - modelBuilder.HasDbFunction(typeof(TableValuedDbFunctionConventionTest).GetMethod( - nameof(GetKeylessEntities), - BindingFlags.NonPublic | BindingFlags.Static)); + modelBuilder.HasDbFunction( + typeof(TableValuedDbFunctionConventionTest).GetMethod( + nameof(GetKeylessEntities), + BindingFlags.NonPublic | BindingFlags.Static)); Assert.Equal( RelationalStrings.DbFunctionInvalidIQueryableOwnedReturnType( @@ -71,9 +74,10 @@ public void Throws_when_adding_a_function_returning_an_existing_owned_type() { var modelBuilder = CreateModelBuilder(); modelBuilder.Entity().OwnsOne(e => e.KeylessEntity); - modelBuilder.HasDbFunction(typeof(TableValuedDbFunctionConventionTest).GetMethod( - nameof(GetKeylessEntities), - BindingFlags.NonPublic | BindingFlags.Static)); + modelBuilder.HasDbFunction( + typeof(TableValuedDbFunctionConventionTest).GetMethod( + nameof(GetKeylessEntities), + BindingFlags.NonPublic | BindingFlags.Static)); Assert.Equal( RelationalStrings.DbFunctionInvalidIQueryableOwnedReturnType( @@ -86,9 +90,10 @@ public void Throws_when_adding_a_function_returning_an_existing_owned_type() public void Throws_when_adding_a_function_returning_a_scalar() { var modelBuilder = CreateModelBuilder(); - modelBuilder.HasDbFunction(typeof(TableValuedDbFunctionConventionTest).GetMethod( - nameof(GetScalars), - BindingFlags.NonPublic | BindingFlags.Static)); + modelBuilder.HasDbFunction( + typeof(TableValuedDbFunctionConventionTest).GetMethod( + nameof(GetScalars), + BindingFlags.NonPublic | BindingFlags.Static)); Assert.Equal( RelationalStrings.DbFunctionInvalidIQueryableReturnType( @@ -97,7 +102,8 @@ public void Throws_when_adding_a_function_returning_a_scalar() Assert.Throws(() => modelBuilder.FinalizeModel()).Message); } - private static ModelBuilder CreateModelBuilder() => RelationalTestHelpers.Instance.CreateConventionBuilder(); + private static ModelBuilder CreateModelBuilder() + => RelationalTestHelpers.Instance.CreateConventionBuilder(); private static IQueryable GetEntities(int id) => throw new NotImplementedException(); diff --git a/test/EFCore.Relational.Tests/Metadata/Conventions/SequenceUniquificationConventionTest.cs b/test/EFCore.Relational.Tests/Metadata/Conventions/SequenceUniquificationConventionTest.cs index 9cc85ee33e5..7c308cdc464 100644 --- a/test/EFCore.Relational.Tests/Metadata/Conventions/SequenceUniquificationConventionTest.cs +++ b/test/EFCore.Relational.Tests/Metadata/Conventions/SequenceUniquificationConventionTest.cs @@ -18,19 +18,20 @@ public virtual void Sequence_names_are_truncated_and_uniquified() { var modelBuilder = GetModelBuilder(); modelBuilder.GetInfrastructure().HasMaxIdentifierLength(10); - modelBuilder.HasSequence("UniquifyMeToo", (string)null); + modelBuilder.HasSequence("UniquifyMeToo"); modelBuilder.HasSequence("UniquifyMeToo", "TestSchema"); - modelBuilder.HasSequence("UniquifyM!Too", (string)null); + modelBuilder.HasSequence("UniquifyM!Too"); modelBuilder.HasSequence("UniquifyM!Too", "TestSchema"); // the below ensure we deal with clashes with existing // sequence names that look like candidate uniquified names - modelBuilder.HasSequence("UniquifyM~", (string)null); + modelBuilder.HasSequence("UniquifyM~"); modelBuilder.HasSequence("UniquifyM~", "TestSchema"); var model = modelBuilder.Model; model.FinalizeModel(); - Assert.Collection(model.GetSequences(), + Assert.Collection( + model.GetSequences(), s0 => { Assert.Equal("Uniquify~1", s0.Name); diff --git a/test/EFCore.Relational.Tests/Metadata/Conventions/TableSharingConcurrencyTokenConventionTest.cs b/test/EFCore.Relational.Tests/Metadata/Conventions/TableSharingConcurrencyTokenConventionTest.cs index 1efe238cce8..9e69fd29cc9 100644 --- a/test/EFCore.Relational.Tests/Metadata/Conventions/TableSharingConcurrencyTokenConventionTest.cs +++ b/test/EFCore.Relational.Tests/Metadata/Conventions/TableSharingConcurrencyTokenConventionTest.cs @@ -4,7 +4,6 @@ using System.ComponentModel.DataAnnotations.Schema; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -101,7 +100,7 @@ public virtual void Missing_concurrency_token_properties_are_created_on_the_base var modelBuilder = GetModelBuilder(); modelBuilder.Entity().HasKey(a => a.Id); modelBuilder.Entity().ToTable(nameof(Animal)).Property("Version") - .HasColumnName("Version").ValueGeneratedOnUpdate().IsConcurrencyToken(true); + .HasColumnName("Version").ValueGeneratedOnUpdate().IsConcurrencyToken(); modelBuilder.Entity().HasKey(a => a.Id); modelBuilder.Entity().HasOne(a => a.FavoritePerson).WithOne().HasForeignKey(p => p.Id); modelBuilder.Entity().HasOne(a => a.Dwelling).WithOne().HasForeignKey(p => p.Id); diff --git a/test/EFCore.Relational.Tests/Metadata/DbFunctionMetadataTests.cs b/test/EFCore.Relational.Tests/Metadata/DbFunctionMetadataTests.cs index d1ac189cc74..d39a5c10108 100644 --- a/test/EFCore.Relational.Tests/Metadata/DbFunctionMetadataTests.cs +++ b/test/EFCore.Relational.Tests/Metadata/DbFunctionMetadataTests.cs @@ -70,37 +70,48 @@ private static void Skip() } [DbFunction] - public static int StaticPublicBase() => throw new Exception(); + public static int StaticPublicBase() + => throw new Exception(); [DbFunction] - protected static int StaticProtectedBase() => throw new Exception(); + protected static int StaticProtectedBase() + => throw new Exception(); [DbFunction] - private static int StaticPrivateBase() => throw new Exception(); + private static int StaticPrivateBase() + => throw new Exception(); [DbFunction] - internal static int StaticInternalBase() => throw new Exception(); + internal static int StaticInternalBase() + => throw new Exception(); [DbFunction] - protected internal static int StaticProtectedInternalBase() => throw new Exception(); + protected internal static int StaticProtectedInternalBase() + => throw new Exception(); [DbFunction] - public int InstancePublicBase() => throw new Exception(); + public int InstancePublicBase() + => throw new Exception(); [DbFunction] - protected int InstanceProtectedBase() => throw new Exception(); + protected int InstanceProtectedBase() + => throw new Exception(); [DbFunction] - private int InstancePrivateBase() => throw new Exception(); + private int InstancePrivateBase() + => throw new Exception(); [DbFunction] - internal int InstanceInternalBase() => throw new Exception(); + internal int InstanceInternalBase() + => throw new Exception(); [DbFunction] - protected internal int InstanceProtectedInternalBase() => throw new Exception(); + protected internal int InstanceProtectedInternalBase() + => throw new Exception(); [DbFunction] - public virtual int VirtualBase() => throw new Exception(); + public virtual int VirtualBase() + => throw new Exception(); } public class MyDerivedContext : MyBaseContext @@ -137,52 +148,69 @@ public static int DuplicateNameTest() } [DbFunction] - public static int StaticPublicDerived() => throw new Exception(); + public static int StaticPublicDerived() + => throw new Exception(); [DbFunction] - protected static int StaticProtectedDerived() => throw new Exception(); + protected static int StaticProtectedDerived() + => throw new Exception(); [DbFunction] - private static int StaticPrivateDerived() => throw new Exception(); + private static int StaticPrivateDerived() + => throw new Exception(); [DbFunction] - internal static int StaticInternalDerived() => throw new Exception(); + internal static int StaticInternalDerived() + => throw new Exception(); [DbFunction] - protected internal static int StaticProtectedInternalDerived() => throw new Exception(); + protected internal static int StaticProtectedInternalDerived() + => throw new Exception(); [DbFunction] - public int InstancePublicDerived() => throw new Exception(); + public int InstancePublicDerived() + => throw new Exception(); [DbFunction] - protected int InstanceProtectedDerived() => throw new Exception(); + protected int InstanceProtectedDerived() + => throw new Exception(); [DbFunction] - private int InstancePrivateDerived() => throw new Exception(); + private int InstancePrivateDerived() + => throw new Exception(); [DbFunction] - internal int InstanceInternalDerived() => throw new Exception(); + internal int InstanceInternalDerived() + => throw new Exception(); [DbFunction] - protected internal int InstanceProtectedInternalDerived() => throw new Exception(); + protected internal int InstanceProtectedInternalDerived() + => throw new Exception(); [DbFunction] - public override int VirtualBase() => throw new Exception(); + public override int VirtualBase() + => throw new Exception(); [DbFunction] - public IQueryable QueryableNoParams() => throw new Exception(); + public IQueryable QueryableNoParams() + => throw new Exception(); [DbFunction] - public IQueryable QueryableSingleParam(int i) => throw new Exception(); + public IQueryable QueryableSingleParam(int i) + => throw new Exception(); - public IQueryable QueryableSingleParam(Expression> i) => throw new Exception(); + public IQueryable QueryableSingleParam(Expression> i) + => throw new Exception(); [DbFunction] - public IQueryable QueryableMultiParam(int i, double j) => throw new Exception(); + public IQueryable QueryableMultiParam(int i, double j) + => throw new Exception(); - public IQueryable QueryableMultiParam(Expression> i, double j) => throw new Exception(); + public IQueryable QueryableMultiParam(Expression> i, double j) + => throw new Exception(); - public IQueryable QueryableMultiParam(Expression> i, Expression> j) => throw new Exception(); + public IQueryable QueryableMultiParam(Expression> i, Expression> j) + => throw new Exception(); } private static readonly MethodInfo MethodAmi = typeof(TestMethods).GetRuntimeMethod( @@ -200,7 +228,8 @@ public static int DuplicateNameTest() private class TestMethods { - public static int Foo => 1; + public static int Foo + => 1; public static int MethodA(string a, int b) { @@ -765,8 +794,9 @@ public void DbFunction_Queryable_custom_translation() var methodInfo = typeof(TestMethods).GetMethod(nameof(TestMethods.MethodJ)); var dbFunctionBuilder = modelBuilder.HasDbFunction(methodInfo); - Assert.False(dbFunctionBuilder.GetInfrastructure() - .CanSetTranslation(args => new SqlFragmentExpression("Empty"), fromDataAnnotation: true)); + Assert.False( + dbFunctionBuilder.GetInfrastructure() + .CanSetTranslation(args => new SqlFragmentExpression("Empty"), fromDataAnnotation: true)); Assert.Null(dbFunctionBuilder.Metadata.Translation); dbFunctionBuilder.GetInfrastructure().HasTranslation(args => new SqlFragmentExpression("Empty")); @@ -776,22 +806,26 @@ public void DbFunction_Queryable_custom_translation() .HasTranslation(args => new SqlFragmentExpression("Empty"), fromDataAnnotation: true); Assert.Null(dbFunctionBuilder.Metadata.Translation); - Assert.Equal(RelationalStrings.DbFunctionTableValuedCustomTranslation(methodInfo.DisplayName()), + Assert.Equal( + RelationalStrings.DbFunctionTableValuedCustomTranslation(methodInfo.DisplayName()), Assert.Throws( () => dbFunctionBuilder.HasTranslation(args => new SqlFragmentExpression("Empty"))).Message); var dbFunction = dbFunctionBuilder.Metadata; - Assert.Equal(RelationalStrings.DbFunctionTableValuedCustomTranslation(methodInfo.DisplayName()), + Assert.Equal( + RelationalStrings.DbFunctionTableValuedCustomTranslation(methodInfo.DisplayName()), Assert.Throws( () => ((IConventionDbFunction)dbFunction).SetTranslation(args => new SqlFragmentExpression("Empty"))).Message); - Assert.Equal(RelationalStrings.DbFunctionTableValuedCustomTranslation(methodInfo.DisplayName()), + Assert.Equal( + RelationalStrings.DbFunctionTableValuedCustomTranslation(methodInfo.DisplayName()), Assert.Throws( () => ((IConventionDbFunction)dbFunction) .SetTranslation(args => new SqlFragmentExpression("Empty"), fromDataAnnotation: true)).Message); - Assert.Equal(RelationalStrings.DbFunctionTableValuedCustomTranslation(methodInfo.DisplayName()), + Assert.Equal( + RelationalStrings.DbFunctionTableValuedCustomTranslation(methodInfo.DisplayName()), Assert.Throws( () => dbFunction.Translation = args => new SqlFragmentExpression("Empty")).Message); } diff --git a/test/EFCore.Relational.Tests/Metadata/RelationalBuilderExtensionsTest.cs b/test/EFCore.Relational.Tests/Metadata/RelationalBuilderExtensionsTest.cs index f2e4f188236..c2b25130b01 100644 --- a/test/EFCore.Relational.Tests/Metadata/RelationalBuilderExtensionsTest.cs +++ b/test/EFCore.Relational.Tests/Metadata/RelationalBuilderExtensionsTest.cs @@ -1221,7 +1221,8 @@ private void AssertIsGeneric(ReferenceReferenceBuilder _) { } - protected virtual ModelBuilder CreateConventionModelBuilder() => RelationalTestHelpers.Instance.CreateConventionBuilder(); + protected virtual ModelBuilder CreateConventionModelBuilder() + => RelationalTestHelpers.Instance.CreateConventionBuilder(); private static void ValidateSchemaNamedSpecificSequence(ISequence sequence) { diff --git a/test/EFCore.Relational.Tests/Metadata/RelationalIndexTest.cs b/test/EFCore.Relational.Tests/Metadata/RelationalIndexTest.cs index 5adf646b1f2..608c2eb6bd9 100644 --- a/test/EFCore.Relational.Tests/Metadata/RelationalIndexTest.cs +++ b/test/EFCore.Relational.Tests/Metadata/RelationalIndexTest.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.Linq; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -29,30 +28,33 @@ public void IndexAttribute_database_name_can_be_overriden_using_fluent_api() modelBuilder.Model.FinalizeModel(); - var index0 = (Internal.Index)entityBuilder.Metadata.GetIndexes().First(); + var index0 = (Index)entityBuilder.Metadata.GetIndexes().First(); Assert.Equal(ConfigurationSource.DataAnnotation, index0.GetConfigurationSource()); Assert.Equal("IndexOnAAndB", index0.Name); Assert.Equal("MyIndexOnAAndB", index0.GetDatabaseName()); Assert.Equal(ConfigurationSource.Explicit, index0.GetDatabaseNameConfigurationSource()); Assert.True(index0.IsUnique); Assert.Equal(ConfigurationSource.DataAnnotation, index0.GetIsUniqueConfigurationSource()); - Assert.Collection(index0.Properties, + Assert.Collection( + index0.Properties, prop0 => Assert.Equal("A", prop0.Name), prop1 => Assert.Equal("B", prop1.Name)); - var index1 = (Internal.Index)entityBuilder.Metadata.GetIndexes().Skip(1).First(); + var index1 = (Index)entityBuilder.Metadata.GetIndexes().Skip(1).First(); Assert.Equal(ConfigurationSource.DataAnnotation, index1.GetConfigurationSource()); Assert.Equal("IndexOnBAndC", index1.Name); Assert.Equal("MyIndexOnBAndC", index1.GetDatabaseName()); Assert.Equal(ConfigurationSource.Explicit, index1.GetDatabaseNameConfigurationSource()); Assert.False(index1.IsUnique); Assert.Null(index1.GetIsUniqueConfigurationSource()); - Assert.Collection(index1.Properties, + Assert.Collection( + index1.Properties, prop0 => Assert.Equal("B", prop0.Name), prop1 => Assert.Equal("C", prop1.Name)); } - protected virtual ModelBuilder CreateConventionModelBuilder() => RelationalTestHelpers.Instance.CreateConventionBuilder(); + protected virtual ModelBuilder CreateConventionModelBuilder() + => RelationalTestHelpers.Instance.CreateConventionBuilder(); [Index(nameof(A), nameof(B), Name = "IndexOnAAndB", IsUnique = true)] [Index(nameof(B), nameof(C), Name = "IndexOnBAndC")] diff --git a/test/EFCore.Relational.Tests/Metadata/RelationalMetadataExtensionsTest.cs b/test/EFCore.Relational.Tests/Metadata/RelationalMetadataExtensionsTest.cs index 349716d7de7..be764228ae1 100644 --- a/test/EFCore.Relational.Tests/Metadata/RelationalMetadataExtensionsTest.cs +++ b/test/EFCore.Relational.Tests/Metadata/RelationalMetadataExtensionsTest.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Xunit; namespace Microsoft.EntityFrameworkCore.Metadata diff --git a/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs b/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs index 17d00cb0351..88edc94b8b5 100644 --- a/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs +++ b/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs @@ -77,12 +77,8 @@ private static void AssertDefaultMappings(IRelationalModel model) var ordersTable = orderMapping.Table; Assert.Equal(new[] { nameof(Order) }, ordersTable.EntityTypeMappings.Select(m => m.EntityType.DisplayName())); - Assert.Equal(new[] { - nameof(Order.AlternateId), - nameof(Order.CustomerId), - "OrderDate", - nameof(Order.OrderId) - }, + Assert.Equal( + new[] { nameof(Order.AlternateId), nameof(Order.CustomerId), "OrderDate", nameof(Order.OrderId) }, ordersTable.Columns.Select(m => m.Name)); Assert.Equal("Order", ordersTable.Name); Assert.Null(ordersTable.Schema); @@ -149,9 +145,14 @@ private static void AssertViews(IRelationalModel model, Mapping mapping) var ordersView = orderMapping.View; Assert.Same(ordersView, model.FindView(ordersView.Name, ordersView.Schema)); Assert.Equal( - new[] { nameof(Order), "OrderDetails.BillingAddress#Address", "OrderDetails.ShippingAddress#Address", nameof(OrderDetails) }, + new[] + { + nameof(Order), "OrderDetails.BillingAddress#Address", "OrderDetails.ShippingAddress#Address", nameof(OrderDetails) + }, ordersView.EntityTypeMappings.Select(m => m.EntityType.DisplayName())); - Assert.Equal(new[] { + Assert.Equal( + new[] + { nameof(Order.AlternateId), nameof(Order.CustomerId), "Details_BillingAddress_City", @@ -160,7 +161,7 @@ private static void AssertViews(IRelationalModel model, Mapping mapping) "Details_ShippingAddress_Street", "OrderDate", nameof(Order.OrderId) - }, + }, ordersView.Columns.Select(m => m.Name)); Assert.Equal("OrderView", ordersView.Name); Assert.Equal("viewSchema", ordersView.Schema); @@ -176,7 +177,8 @@ private static void AssertViews(IRelationalModel model, Mapping mapping) var orderDetailsOwnership = orderType.FindNavigation(nameof(Order.Details)).ForeignKey; var orderDetailsType = orderDetailsOwnership.DeclaringEntityType; Assert.Same(ordersView, orderDetailsType.GetViewMappings().Single().View); - Assert.Equal(ordersView.GetReferencingRowInternalForeignKeys(orderType), ordersView.GetRowInternalForeignKeys(orderDetailsType)); + Assert.Equal( + ordersView.GetReferencingRowInternalForeignKeys(orderType), ordersView.GetRowInternalForeignKeys(orderDetailsType)); Assert.False(ordersView.IsOptional(orderType)); Assert.True(ordersView.IsOptional(orderDetailsType)); @@ -208,7 +210,8 @@ private static void AssertViews(IRelationalModel model, Mapping mapping) Assert.True(specialCustomerType.GetViewMappings().Last().IsSplitEntityTypePrincipal); Assert.True(specialCustomerType.GetViewMappings().Last().IncludesDerivedTypes); - var specialCustomerView = specialCustomerType.GetViewMappings().Select(t => t.Table).First(t => t.Name == "SpecialCustomerView"); + var specialCustomerView = specialCustomerType.GetViewMappings().Select(t => t.Table) + .First(t => t.Name == "SpecialCustomerView"); Assert.Null(specialCustomerView.Schema); Assert.Equal(4, specialCustomerView.Columns.Count()); @@ -252,9 +255,14 @@ private static void AssertTables(IRelationalModel model, Mapping mapping) var ordersTable = orderMapping.Table; Assert.Same(ordersTable, model.FindTable(ordersTable.Name, ordersTable.Schema)); Assert.Equal( - new[] { nameof(Order), "OrderDetails.BillingAddress#Address", "OrderDetails.ShippingAddress#Address", nameof(OrderDetails) }, + new[] + { + nameof(Order), "OrderDetails.BillingAddress#Address", "OrderDetails.ShippingAddress#Address", nameof(OrderDetails) + }, ordersTable.EntityTypeMappings.Select(m => m.EntityType.DisplayName())); - Assert.Equal(new[] { + Assert.Equal( + new[] + { nameof(Order.OrderId), nameof(Order.AlternateId), nameof(Order.CustomerId), @@ -263,7 +271,7 @@ private static void AssertTables(IRelationalModel model, Mapping mapping) "Details_ShippingAddress_City", "Details_ShippingAddress_Street", nameof(Order.OrderDate) - }, + }, ordersTable.Columns.Select(m => m.Name)); Assert.Equal("Order", ordersTable.Name); Assert.Null(ordersTable.Schema); @@ -350,18 +358,25 @@ private static void AssertTables(IRelationalModel model, Mapping mapping) var orderDetailsOwnership = orderType.FindNavigation(nameof(Order.Details)).ForeignKey; var orderDetailsType = orderDetailsOwnership.DeclaringEntityType; Assert.Same(ordersTable, orderDetailsType.GetTableMappings().Single().Table); - Assert.Equal(ordersTable.GetReferencingRowInternalForeignKeys(orderType), ordersTable.GetRowInternalForeignKeys(orderDetailsType)); - Assert.Equal(RelationalStrings.TableNotMappedEntityType(nameof(SpecialCustomer), ordersTable.Name), - Assert.Throws(() => - ordersTable.GetReferencingRowInternalForeignKeys(specialCustomerType)).Message); - Assert.Equal(RelationalStrings.TableNotMappedEntityType(nameof(SpecialCustomer), ordersTable.Name), - Assert.Throws(() => - ordersTable.GetRowInternalForeignKeys(specialCustomerType)).Message); + Assert.Equal( + ordersTable.GetReferencingRowInternalForeignKeys(orderType), ordersTable.GetRowInternalForeignKeys(orderDetailsType)); + Assert.Equal( + RelationalStrings.TableNotMappedEntityType(nameof(SpecialCustomer), ordersTable.Name), + Assert.Throws( + () => + ordersTable.GetReferencingRowInternalForeignKeys(specialCustomerType)).Message); + Assert.Equal( + RelationalStrings.TableNotMappedEntityType(nameof(SpecialCustomer), ordersTable.Name), + Assert.Throws( + () => + ordersTable.GetRowInternalForeignKeys(specialCustomerType)).Message); Assert.False(ordersTable.IsOptional(orderType)); Assert.True(ordersTable.IsOptional(orderDetailsType)); - Assert.Equal(RelationalStrings.TableNotMappedEntityType(nameof(SpecialCustomer), ordersTable.Name), - Assert.Throws(() => - ordersTable.IsOptional(specialCustomerType)).Message); + Assert.Equal( + RelationalStrings.TableNotMappedEntityType(nameof(SpecialCustomer), ordersTable.Name), + Assert.Throws( + () => + ordersTable.IsOptional(specialCustomerType)).Message); Assert.Empty(orderDetailsOwnership.GetMappedConstraints()); Assert.Equal(2, orderDetailsType.GetForeignKeys().Count()); @@ -412,7 +427,8 @@ private static void AssertTables(IRelationalModel model, Mapping mapping) Assert.True(specialCustomerType.GetTableMappings().Last().IsSplitEntityTypePrincipal); Assert.True(specialCustomerType.GetTableMappings().Last().IncludesDerivedTypes); - var specialCustomerTable = specialCustomerType.GetTableMappings().Select(t => t.Table).First(t => t.Name == "SpecialCustomer"); + var specialCustomerTable = + specialCustomerType.GetTableMappings().Select(t => t.Table).First(t => t.Name == "SpecialCustomer"); Assert.Equal("SpecialSchema", specialCustomerTable.Schema); Assert.Equal(4, specialCustomerTable.Columns.Count()); @@ -513,99 +529,104 @@ private static void AssertTables(IRelationalModel model, Mapping mapping) private IRelationalModel CreateTestModel(bool mapToTables = false, bool mapToViews = false, Mapping mapping = Mapping.TPH) { var modelBuilder = CreateConventionModelBuilder(); - modelBuilder.Entity(cb => - { - if (mapToViews) + modelBuilder.Entity( + cb => { - cb.ToView("CustomerView", "viewSchema"); - } - - if (mapToTables) - { - cb.ToTable("Customer"); - } - - cb.Property("SpecialityAk"); - }); - - modelBuilder.Entity(cb => - { - if (mapToViews - && mapping == Mapping.TPT) - { - cb.ToView("SpecialCustomerView"); - } - - if (mapToTables - && mapping == Mapping.TPT) - { - cb.ToTable("SpecialCustomer", "SpecialSchema"); - } - - cb.Property(s => s.Speciality).IsRequired(); - - cb.HasOne(c => c.RelatedCustomer).WithOne() - .HasForeignKey(c => c.RelatedCustomerSpeciality) - .HasPrincipalKey("SpecialityAk"); // TODO: Use the derived one, #2611 + if (mapToViews) + { + cb.ToView("CustomerView", "viewSchema"); + } - cb.HasOne().WithOne() - .HasForeignKey("AnotherRelatedCustomerId"); - }); + if (mapToTables) + { + cb.ToTable("Customer"); + } - modelBuilder.Entity(ob => - { - ob.Property(o => o.OrderDate).HasColumnName("OrderDate"); - ob.Property(o => o.AlternateId).HasColumnName("AlternateId"); - - ob.HasAlternateKey(o => o.AlternateId).HasName("AK_AlternateId"); - ob.HasOne(o => o.DateDetails).WithOne() - .HasForeignKey(o => o.OrderDate).HasPrincipalKey(o => o.Date) - .HasConstraintName("FK_DateDetails"); - - // Note: the below is resetting the name of the anonymous index - // created in HasForeignKey() above, not creating a new index. - ob.HasIndex(o => o.OrderDate).HasDatabaseName("IX_OrderDate"); + cb.Property("SpecialityAk"); + }); - ob.OwnsOne(o => o.Details, odb => + modelBuilder.Entity( + cb => { - odb.Property(od => od.OrderDate).HasColumnName("OrderDate"); - var alternateId = odb.Property(o => o.AlternateId).HasColumnName("AlternateId").Metadata; - - odb.OwnedEntityType.AddKey(new[] { alternateId }); - // Issue #20948 - //odb.HasAlternateKey(o => o.AlternateId); - odb.HasOne(od => od.DateDetails).WithOne() - .HasForeignKey(o => o.OrderDate).HasPrincipalKey(o => o.Date); - - odb.OwnsOne(od => od.BillingAddress); - odb.OwnsOne(od => od.ShippingAddress); + if (mapToViews + && mapping == Mapping.TPT) + { + cb.ToView("SpecialCustomerView"); + } + + if (mapToTables + && mapping == Mapping.TPT) + { + cb.ToTable("SpecialCustomer", "SpecialSchema"); + } + + cb.Property(s => s.Speciality).IsRequired(); + + cb.HasOne(c => c.RelatedCustomer).WithOne() + .HasForeignKey(c => c.RelatedCustomerSpeciality) + .HasPrincipalKey("SpecialityAk"); // TODO: Use the derived one, #2611 + + cb.HasOne().WithOne() + .HasForeignKey("AnotherRelatedCustomerId"); }); - if (mapToViews) + modelBuilder.Entity( + ob => { - ob.ToView("OrderView", "viewSchema"); - } + ob.Property(o => o.OrderDate).HasColumnName("OrderDate"); + ob.Property(o => o.AlternateId).HasColumnName("AlternateId"); + + ob.HasAlternateKey(o => o.AlternateId).HasName("AK_AlternateId"); + ob.HasOne(o => o.DateDetails).WithOne() + .HasForeignKey(o => o.OrderDate).HasPrincipalKey(o => o.Date) + .HasConstraintName("FK_DateDetails"); + + // Note: the below is resetting the name of the anonymous index + // created in HasForeignKey() above, not creating a new index. + ob.HasIndex(o => o.OrderDate).HasDatabaseName("IX_OrderDate"); + + ob.OwnsOne( + o => o.Details, odb => + { + odb.Property(od => od.OrderDate).HasColumnName("OrderDate"); + var alternateId = odb.Property(o => o.AlternateId).HasColumnName("AlternateId").Metadata; + + odb.OwnedEntityType.AddKey(new[] { alternateId }); + // Issue #20948 + //odb.HasAlternateKey(o => o.AlternateId); + odb.HasOne(od => od.DateDetails).WithOne() + .HasForeignKey(o => o.OrderDate).HasPrincipalKey(o => o.Date); + + odb.OwnsOne(od => od.BillingAddress); + odb.OwnsOne(od => od.ShippingAddress); + }); + + if (mapToViews) + { + ob.ToView("OrderView", "viewSchema"); + } + + if (mapToTables) + { + ob.ToTable("Order"); + } + }); - if (mapToTables) + modelBuilder.Entity( + db => { - ob.ToTable("Order"); - } - }); + db.HasKey(d => d.Date); - modelBuilder.Entity(db => - { - db.HasKey(d => d.Date); - - if (mapToViews) - { - db.ToView("DateDetailsView", "viewSchema"); - } + if (mapToViews) + { + db.ToView("DateDetailsView", "viewSchema"); + } - if (mapToTables) - { - db.ToTable("DateDetails"); - } - }); + if (mapToTables) + { + db.ToTable("DateDetails"); + } + }); return modelBuilder.FinalizeModel().GetRelationalModel(); } @@ -615,16 +636,18 @@ public void Can_use_relational_model_with_keyless_TPH() { var modelBuilder = CreateConventionModelBuilder(); - modelBuilder.Entity(cb => - { - cb.Ignore(c => c.Orders); - cb.ToView("CustomerView"); - }); + modelBuilder.Entity( + cb => + { + cb.Ignore(c => c.Orders); + cb.ToView("CustomerView"); + }); - modelBuilder.Entity(cb => - { - cb.Property(s => s.Speciality).IsRequired(); - }); + modelBuilder.Entity( + cb => + { + cb.Property(s => s.Speciality).IsRequired(); + }); var model = modelBuilder.FinalizeModel().GetRelationalModel(); @@ -658,16 +681,17 @@ public void Can_use_relational_model_with_keyless_TPH() public void Can_use_relational_model_with_SQL_queries() { var modelBuilder = CreateConventionModelBuilder(); - modelBuilder.Entity(cb => - { - cb.ToSqlQuery("GetOrders()"); - cb.Ignore(c => c.Customer); - cb.Ignore(c => c.Details); - cb.Ignore(c => c.DateDetails); + modelBuilder.Entity( + cb => + { + cb.ToSqlQuery("GetOrders()"); + cb.Ignore(c => c.Customer); + cb.Ignore(c => c.Details); + cb.Ignore(c => c.DateDetails); - cb.Property(c => c.AlternateId).HasColumnName("SomeName"); - cb.HasNoKey(); - }); + cb.Property(c => c.AlternateId).HasColumnName("SomeName"); + cb.HasNoKey(); + }); var model = modelBuilder.FinalizeModel().GetRelationalModel(); @@ -693,12 +717,8 @@ public void Can_use_relational_model_with_SQL_queries() Assert.Equal( new[] { orderType }, ordersQuery.EntityTypeMappings.Select(m => m.EntityType)); - Assert.Equal(new[] { - nameof(Order.CustomerId), - nameof(Order.OrderDate), - nameof(Order.OrderId), - "SomeName" - }, + Assert.Equal( + new[] { nameof(Order.CustomerId), nameof(Order.OrderDate), nameof(Order.OrderId), "SomeName" }, ordersQuery.Columns.Select(m => m.Name)); Assert.Equal("Microsoft.EntityFrameworkCore.Metadata.RelationalModelTest+Order.MappedSqlQuery", ordersQuery.Name); Assert.Null(ordersQuery.Schema); @@ -732,19 +752,21 @@ private static IQueryable GetOrdersForCustomer(int id) public void Can_use_relational_model_with_functions() { var modelBuilder = CreateConventionModelBuilder(); - modelBuilder.Entity(cb => - { - cb.ToFunction("GetOrders"); - cb.Ignore(c => c.Customer); - cb.Ignore(c => c.Details); - cb.Ignore(c => c.DateDetails); + modelBuilder.Entity( + cb => + { + cb.ToFunction("GetOrders"); + cb.Ignore(c => c.Customer); + cb.Ignore(c => c.Details); + cb.Ignore(c => c.DateDetails); - cb.Property(c => c.AlternateId).HasColumnName("SomeName"); - cb.HasNoKey(); - }); + cb.Property(c => c.AlternateId).HasColumnName("SomeName"); + cb.HasNoKey(); + }); - modelBuilder.HasDbFunction(typeof(RelationalModelTest).GetMethod( - nameof(GetOrdersForCustomer), BindingFlags.NonPublic | BindingFlags.Static)); + modelBuilder.HasDbFunction( + typeof(RelationalModelTest).GetMethod( + nameof(GetOrdersForCustomer), BindingFlags.NonPublic | BindingFlags.Static)); var model = modelBuilder.FinalizeModel().GetRelationalModel(); @@ -777,12 +799,8 @@ public void Can_use_relational_model_with_functions() Assert.Equal( new[] { orderType }, ordersFunction.EntityTypeMappings.Select(m => m.EntityType)); - Assert.Equal(new[] { - nameof(Order.CustomerId), - nameof(Order.OrderDate), - nameof(Order.OrderId), - "SomeName" - }, + Assert.Equal( + new[] { nameof(Order.CustomerId), nameof(Order.OrderDate), nameof(Order.OrderId), "SomeName" }, ordersFunction.Columns.Select(m => m.Name)); Assert.Equal("GetOrders", ordersFunction.Name); Assert.Null(ordersFunction.Schema); @@ -825,7 +843,8 @@ public void Can_use_relational_model_with_functions() Assert.Same(tvfDbFunction.Parameters.Single(), tvfFunction.Parameters.Single().DbFunctionParameters.Single()); } - protected virtual ModelBuilder CreateConventionModelBuilder() => RelationalTestHelpers.Instance.CreateConventionBuilder(); + protected virtual ModelBuilder CreateConventionModelBuilder() + => RelationalTestHelpers.Instance.CreateConventionBuilder(); public enum Mapping { diff --git a/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs b/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs index 6537804e70a..af795243810 100644 --- a/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs +++ b/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTest.cs @@ -7,6 +7,7 @@ using System.Reflection; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations.Operations; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.EntityFrameworkCore.TestUtilities.FakeProvider; @@ -1764,35 +1765,37 @@ public void Rename_property_and_column_when_snapshot() public void Add_table_sharing_to_TPT() { Execute( - common => { + common => + { common.Entity( - "Order", - x => - { - x.ToTable("Order"); - x.Property("Id"); - }); + "Order", + x => + { + x.ToTable("Order"); + x.Property("Id"); + }); common.Entity( - "DetailedOrder", - x => - { - x.ToTable("DetailedOrder"); - x.HasBaseType("Order"); - x.Property("Description").HasColumnName("Description"); - }); + "DetailedOrder", + x => + { + x.ToTable("DetailedOrder"); + x.HasBaseType("Order"); + x.Property("Description").HasColumnName("Description"); + }); }, _ => { }, - target => { + target => + { target.Entity( - "OrderDetails", - x => - { - x.ToTable("DetailedOrder"); - x.Property("Id"); - x.Property("Description").HasColumnName("Description"); - x.Property("OrderDate"); - x.HasOne("DetailedOrder", null).WithOne().HasForeignKey("OrderDetails", "Id"); - }); + "OrderDetails", + x => + { + x.ToTable("DetailedOrder"); + x.Property("Id"); + x.Property("Description").HasColumnName("Description"); + x.Property("OrderDate"); + x.HasOne("DetailedOrder", null).WithOne().HasForeignKey("OrderDetails", "Id"); + }); }, operations => { @@ -1809,50 +1812,58 @@ public void Add_table_sharing_to_TPT() public void Rename_column_in_TPT_with_table_sharing_and_seed_data() { Execute( - common => { + common => + { common.Entity( - "Order", - x => - { - x.ToTable("Order"); - x.Property("Id"); - }); + "Order", + x => + { + x.ToTable("Order"); + x.Property("Id"); + }); common.Entity( - "DetailedOrder", - x => - { - x.ToTable("DetailedOrder"); - x.HasBaseType("Order"); - x.Property("Description").HasColumnName("Description"); - x.HasData(new { Id = 42, Description = "Order 1" }); - }); + "DetailedOrder", + x => + { + x.ToTable("DetailedOrder"); + x.HasBaseType("Order"); + x.Property("Description").HasColumnName("Description"); + x.HasData(new { Id = 42, Description = "Order 1" }); + }); common.Entity( - "OrderDetails", - x => - { - x.ToTable("DetailedOrder"); - x.Property("Id"); - x.Property("Description").HasColumnName("Description"); - x.Property("OrderDate"); - x.HasOne("DetailedOrder", null).WithOne().HasForeignKey("OrderDetails", "Id"); - x.HasData(new { Id = 42, Description = "Order 1", OrderDate = DateTime.MinValue }); - }); + "OrderDetails", + x => + { + x.ToTable("DetailedOrder"); + x.Property("Id"); + x.Property("Description").HasColumnName("Description"); + x.Property("OrderDate"); + x.HasOne("DetailedOrder", null).WithOne().HasForeignKey("OrderDetails", "Id"); + x.HasData( + new + { + Id = 42, + Description = "Order 1", + OrderDate = DateTime.MinValue + }); + }); }, _ => { }, - target => { + target => + { target.Entity( - "DetailedOrder", - x => - { - x.Property("Description").HasColumnName("OrderDescription"); - }); + "DetailedOrder", + x => + { + x.Property("Description").HasColumnName("OrderDescription"); + }); target.Entity( - "OrderDetails", - x => - { - x.Property("Description").HasColumnName("OrderDescription"); - }); - }, + "OrderDetails", + x => + { + x.Property("Description").HasColumnName("OrderDescription"); + }); + }, operations => { Assert.Equal(1, operations.Count); @@ -1921,7 +1932,8 @@ public override string Next(EntityEntry entry) throw new NotImplementedException(); } - public override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; } [ConditionalFact] @@ -3620,7 +3632,7 @@ public void Alter_index_columns() x.Property("Id"); x.Property("Value"); x.Property("MuleValue"); - x.HasIndex(new[] { "MuleValue" },"IX_Muel_Value"); + x.HasIndex(new[] { "MuleValue" }, "IX_Muel_Value"); }), operations => { @@ -5269,11 +5281,12 @@ public void Change_TPH_to_TPT_with_FKs_and_seed_data() new { Id = 31 }); }); }, - source => { + source => + { source.Entity( "Animal", x => { - x.Property("Discriminator").Metadata.SetAfterSaveBehavior(Metadata.PropertySaveBehavior.Save); + x.Property("Discriminator").Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Save); }); source.Entity( "Cat", x => @@ -5376,7 +5389,8 @@ public void Change_TPH_to_TPT_with_FKs_and_seed_data() { var operation = Assert.IsType(o); Assert.Equal("Cats", operation.Name); - Assert.Collection(operation.Columns, + Assert.Collection( + operation.Columns, c => { Assert.Equal("Id", c.Name); @@ -5421,8 +5435,10 @@ public void Change_TPH_to_TPT_with_FKs_and_seed_data() Assert.Equal("Cats", pk.Table); Assert.Equal(new[] { "Id" }, pk.Columns); - Assert.Collection(operation.ForeignKeys, - fk => { + Assert.Collection( + operation.ForeignKeys, + fk => + { Assert.Equal("FK_Cats_Animal_Id", fk.Name); Assert.Equal("Cats", fk.Table); Assert.Equal("Animal", fk.PrincipalTable); @@ -5448,7 +5464,8 @@ public void Change_TPH_to_TPT_with_FKs_and_seed_data() { var operation = Assert.IsType(o); Assert.Equal("Mice", operation.Name); - Assert.Collection(operation.Columns, + Assert.Collection( + operation.Columns, c => { Assert.Equal("Id", c.Name); @@ -5873,12 +5890,12 @@ public void Change_TPH_to_TPT_with_FKs_and_seed_data_readonly_discriminator() { modelBuilder.Entity( "Animal", x => - { - x.Property("Id"); - x.Property("MouseId"); + { + x.Property("Id"); + x.Property("MouseId"); - x.HasOne("Mouse").WithMany().HasForeignKey("MouseId"); - }); + x.HasOne("Mouse").WithMany().HasForeignKey("MouseId"); + }); modelBuilder.Entity( "Cat", x => { @@ -5908,7 +5925,8 @@ public void Change_TPH_to_TPT_with_FKs_and_seed_data_readonly_discriminator() new { Id = 31 }); }); }, - source => { + source => + { source.Entity( "Cat", x => { @@ -6008,7 +6026,8 @@ public void Change_TPH_to_TPT_with_FKs_and_seed_data_readonly_discriminator() { var operation = Assert.IsType(o); Assert.Equal("Cats", operation.Name); - Assert.Collection(operation.Columns, + Assert.Collection( + operation.Columns, c => { Assert.Equal("Id", c.Name); @@ -6053,8 +6072,10 @@ public void Change_TPH_to_TPT_with_FKs_and_seed_data_readonly_discriminator() Assert.Equal("Cats", pk.Table); Assert.Equal(new[] { "Id" }, pk.Columns); - Assert.Collection(operation.ForeignKeys, - fk => { + Assert.Collection( + operation.ForeignKeys, + fk => + { Assert.Equal("FK_Cats_Animal_Id", fk.Name); Assert.Equal("Cats", fk.Table); Assert.Equal("Animal", fk.PrincipalTable); @@ -6080,7 +6101,8 @@ public void Change_TPH_to_TPT_with_FKs_and_seed_data_readonly_discriminator() { var operation = Assert.IsType(o); Assert.Equal("Mice", operation.Name); - Assert.Collection(operation.Columns, + Assert.Collection( + operation.Columns, c => { Assert.Equal("Id", c.Name); @@ -6172,7 +6194,7 @@ public void Change_TPH_to_TPT_with_FKs_and_seed_data_readonly_discriminator() }, o => { - var operation = Assert.IsType (o); + var operation = Assert.IsType(o); Assert.Equal("Dogs", operation.Table); Assert.Equal(new[] { "Id", "PreyId" }, operation.Columns); @@ -6496,7 +6518,7 @@ public void Change_TPH_to_TPT_with_FKs_and_seed_data_readonly_discriminator() { var operation = Assert.IsType(o); Assert.Equal("Animal", operation.Table); - Assert.Equal(new[] { "Id" , "Discriminator", "MouseId", "PreyId" }, operation.Columns); + Assert.Equal(new[] { "Id", "Discriminator", "MouseId", "PreyId" }, operation.Columns); Assert.Null(operation.ColumnTypes); AssertMultidimensionalArray( operation.Values, @@ -10108,13 +10130,15 @@ public void Model_differ_does_not_detect_table_valued_function_result_type() Execute( _ => { }, modelBuilder => - modelBuilder.HasDbFunction(typeof(MigrationsModelDifferTest).GetMethod( - nameof(GetCountByYear), - BindingFlags.NonPublic | BindingFlags.Static)), + modelBuilder.HasDbFunction( + typeof(MigrationsModelDifferTest).GetMethod( + nameof(GetCountByYear), + BindingFlags.NonPublic | BindingFlags.Static)), result => Assert.Equal(0, result.Count), skipSourceConventions: true); } - protected override TestHelpers TestHelpers => RelationalTestHelpers.Instance; + protected override TestHelpers TestHelpers + => RelationalTestHelpers.Instance; } } diff --git a/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTestBase.cs b/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTestBase.cs index 50762900d19..73e4369382a 100644 --- a/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTestBase.cs +++ b/test/EFCore.Relational.Tests/Migrations/Internal/MigrationsModelDifferTestBase.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations.Operations; @@ -152,7 +151,8 @@ private ConventionSet CreateEmptyConventionSet() var relationalConventionSetDependencies = TestHelpers.CreateContextServices() .GetRequiredService(); conventions.ModelFinalizingConventions.Add(new TypeMappingConvention(conventionSetDependencies)); - conventions.ModelFinalizedConventions.Add(new RelationalModelConvention(conventionSetDependencies, relationalConventionSetDependencies)); + conventions.ModelFinalizedConventions.Add( + new RelationalModelConvention(conventionSetDependencies, relationalConventionSetDependencies)); return conventions; } diff --git a/test/EFCore.Relational.Tests/Migrations/MigrationsSqlGeneratorTestBase.cs b/test/EFCore.Relational.Tests/Migrations/MigrationsSqlGeneratorTestBase.cs index 84677ca01dc..1880931c468 100644 --- a/test/EFCore.Relational.Tests/Migrations/MigrationsSqlGeneratorTestBase.cs +++ b/test/EFCore.Relational.Tests/Migrations/MigrationsSqlGeneratorTestBase.cs @@ -20,7 +20,8 @@ namespace Microsoft.EntityFrameworkCore.Migrations { public abstract class MigrationsSqlGeneratorTestBase { - protected static string EOL => Environment.NewLine; + protected static string EOL + => Environment.NewLine; protected virtual string Sql { get; set; } @@ -31,7 +32,9 @@ public void All_tests_must_be_overriden() .Where(method => method.IsVirtual && !method.IsFinal && method.DeclaringType == typeof(MigrationsSqlGeneratorTestBase)) .ToList(); - Assert.True(baseTests.Count == 0, $"{GetType().ShortDisplayName()} should override the following methods to assert the generated SQL:" + EOL + Assert.True( + baseTests.Count == 0, $"{GetType().ShortDisplayName()} should override the following methods to assert the generated SQL:" + + EOL + string.Join(EOL, baseTests.Select(m => m.Name))); } @@ -194,8 +197,7 @@ public virtual void SqlOperation() }; private static readonly MultiPoint _multiPoint = new MultiPoint( - new[] { 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( @@ -214,12 +216,10 @@ public virtual void SqlOperation() private static readonly Point _point1 = new Point(1.1, 2.2, 3.3) { SRID = 4326 }; private static readonly MultiLineString _multiLineString = new MultiLineString( - new[] { _lineString1, _lineString2 }) - { SRID = 4326 }; + new[] { _lineString1, _lineString2 }) { SRID = 4326 }; private static readonly MultiPolygon _multiPolygon = new MultiPolygon( - new[] { _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 }) @@ -286,83 +286,95 @@ public virtual void InsertDataOperation_required_args_multiple_rows() [ConditionalFact] public void InsertDataOperation_throws_for_missing_column_types() - => Assert.Equal(RelationalStrings.InsertDataOperationNoModel("dbo.People"), - Assert.Throws(() => - Generate( - new InsertDataOperation - { - Table = "People", - Schema = "dbo", - Columns = new[] { "First Name" }, - Values = new object[,] { { "John" } } - })).Message); + => Assert.Equal( + RelationalStrings.InsertDataOperationNoModel("dbo.People"), + Assert.Throws( + () => + Generate( + new InsertDataOperation + { + Table = "People", + Schema = "dbo", + Columns = new[] { "First Name" }, + Values = new object[,] { { "John" } } + })).Message); [ConditionalFact] public virtual void InsertDataOperation_throws_for_unsupported_column_types() - => Assert.Equal(RelationalStrings.UnsupportedDataOperationStoreType("char[]", "dbo.People.First Name"), - Assert.Throws(() => - Generate( - new InsertDataOperation - { - Table = "People", - Schema = "dbo", - Columns = new[] { "First Name" }, - ColumnTypes = new[] { "char[]" }, - Values = new object[,] { { null } } - })).Message); + => Assert.Equal( + RelationalStrings.UnsupportedDataOperationStoreType("char[]", "dbo.People.First Name"), + Assert.Throws( + () => + Generate( + new InsertDataOperation + { + Table = "People", + Schema = "dbo", + Columns = new[] { "First Name" }, + ColumnTypes = new[] { "char[]" }, + Values = new object[,] { { null } } + })).Message); [ConditionalFact] public void InsertDataOperation_throws_for_values_count_mismatch() - => Assert.Equal(RelationalStrings.InsertDataOperationValuesCountMismatch(1, 2, "People"), - Assert.Throws(() => - Generate( - CreateGotModel, - new InsertDataOperation - { - Table = "People", - Columns = new[] { "First Name", "Last Name" }, - Values = new object[,] { { "John" } } - })).Message); + => Assert.Equal( + RelationalStrings.InsertDataOperationValuesCountMismatch(1, 2, "People"), + Assert.Throws( + () => + Generate( + CreateGotModel, + new InsertDataOperation + { + Table = "People", + Columns = new[] { "First Name", "Last Name" }, + Values = new object[,] { { "John" } } + })).Message); [ConditionalFact] public void InsertDataOperation_throws_for_types_count_mismatch() - => Assert.Equal(RelationalStrings.InsertDataOperationTypesCountMismatch(2, 1, "People"), - Assert.Throws(() => - Generate( - new InsertDataOperation - { - Table = "People", - Columns = new[] { "First Name" }, - ColumnTypes = new[] { "string", "string" }, - Values = new object[,] { { "John" } } - })).Message); + => Assert.Equal( + RelationalStrings.InsertDataOperationTypesCountMismatch(2, 1, "People"), + Assert.Throws( + () => + Generate( + new InsertDataOperation + { + Table = "People", + Columns = new[] { "First Name" }, + ColumnTypes = new[] { "string", "string" }, + Values = new object[,] { { "John" } } + })).Message); [ConditionalFact] public void InsertDataOperation_throws_for_missing_entity_type() - => Assert.Equal(RelationalStrings.DataOperationNoTable("dbo.People"), - Assert.Throws(() => - Generate( - CreateGotModel, - new InsertDataOperation - { - Table = "People", - Schema = "dbo", - Columns = new[] { "First Name" }, - Values = new object[,] { { "John" } } - })).Message); + => Assert.Equal( + RelationalStrings.DataOperationNoTable("dbo.People"), + Assert.Throws( + () => + Generate( + CreateGotModel, + new InsertDataOperation + { + Table = "People", + Schema = "dbo", + Columns = new[] { "First Name" }, + Values = new object[,] { { "John" } } + })).Message); [ConditionalFact] public void InsertDataOperation_throws_for_missing_property() - => Assert.Equal(RelationalStrings.DataOperationNoProperty("People", "Name"), - Assert.Throws(() => - Generate( - CreateGotModel, - new InsertDataOperation - { - Table = "People", - Columns = new[] { "Name" }, - Values = new object[,] { { "John" } } - })).Message); + => Assert.Equal( + RelationalStrings.DataOperationNoProperty("People", "Name"), + Assert.Throws( + () => + Generate( + CreateGotModel, + new InsertDataOperation + { + Table = "People", + Columns = new[] { "Name" }, + Values = new object[,] { { "John" } } + })).Message); [ConditionalFact] public virtual void DeleteDataOperation_all_args() @@ -413,42 +425,47 @@ public virtual void DeleteDataOperation_required_args_composite() [ConditionalFact] public void DeleteDataOperation_throws_for_missing_column_types() - => Assert.Equal(RelationalStrings.DeleteDataOperationNoModel("People"), - Assert.Throws(() => - Generate( - new DeleteDataOperation - { - Table = "People", - KeyColumns = new[] { "First Name" }, - KeyValues = new object[,] { { "John" } } - })).Message); + => Assert.Equal( + RelationalStrings.DeleteDataOperationNoModel("People"), + Assert.Throws( + () => + Generate( + new DeleteDataOperation + { + Table = "People", + KeyColumns = new[] { "First Name" }, + KeyValues = new object[,] { { "John" } } + })).Message); [ConditionalFact] public void DeleteDataOperation_throws_for_values_count_mismatch() - => Assert.Equal(RelationalStrings.DeleteDataOperationValuesCountMismatch(1, 2, "People"), - Assert.Throws(() => - Generate( - CreateGotModel, - new DeleteDataOperation - { - Table = "People", - KeyColumns = new[] { "First Name", "Last Name" }, - KeyValues = new object[,] { { "John" } } - })).Message); + => Assert.Equal( + RelationalStrings.DeleteDataOperationValuesCountMismatch(1, 2, "People"), + Assert.Throws( + () => + Generate( + CreateGotModel, + new DeleteDataOperation + { + Table = "People", + KeyColumns = new[] { "First Name", "Last Name" }, + KeyValues = new object[,] { { "John" } } + })).Message); [ConditionalFact] public void DeleteDataOperation_throws_for_types_count_mismatch() - => Assert.Equal(RelationalStrings.DeleteDataOperationTypesCountMismatch(2, 1, "People"), - Assert.Throws(() => - Generate( - new DeleteDataOperation - { - Table = "People", - KeyColumns = new[] { "First Name" }, - KeyColumnTypes = new[] { "string", "string" }, - KeyValues = new object[,] { { "John" } } - })).Message); - + => Assert.Equal( + RelationalStrings.DeleteDataOperationTypesCountMismatch(2, 1, "People"), + Assert.Throws( + () => + Generate( + new DeleteDataOperation + { + Table = "People", + KeyColumns = new[] { "First Name" }, + KeyColumnTypes = new[] { "string", "string" }, + KeyValues = new object[,] { { "John" } } + })).Message); [ConditionalFact] public virtual void UpdateDataOperation_all_args() @@ -569,93 +586,105 @@ public virtual void UpdateDataOperation_required_args_multi() [ConditionalFact] public void UpdateDataOperation_throws_for_missing_column_types() - => Assert.Equal(RelationalStrings.UpdateDataOperationNoModel("People"), - Assert.Throws(() => - Generate( - new UpdateDataOperation - { - Table = "People", - KeyColumns = new[] { "First Name" }, - KeyValues = new object[,] { { "Daenerys" } }, - Columns = new[] { "House Allegiance" }, - Values = new object[,] { { "Targaryen" } } - })).Message); + => Assert.Equal( + RelationalStrings.UpdateDataOperationNoModel("People"), + Assert.Throws( + () => + Generate( + new UpdateDataOperation + { + Table = "People", + KeyColumns = new[] { "First Name" }, + KeyValues = new object[,] { { "Daenerys" } }, + Columns = new[] { "House Allegiance" }, + Values = new object[,] { { "Targaryen" } } + })).Message); [ConditionalFact] public void UpdateDataOperation_throws_for_row_count_mismatch() - => Assert.Equal(RelationalStrings.UpdateDataOperationRowCountMismatch(1, 2, "People"), - Assert.Throws(() => - Generate( - CreateGotModel, - new UpdateDataOperation - { - Table = "People", - KeyColumns = new[] { "First Name" }, - KeyColumnTypes = new[] { "string" }, - KeyValues = new object[,] { { "Daenerys" }, { "John" } }, - Columns = new[] { "House Allegiance" }, - Values = new object[,] { { "Targaryen" } } - })).Message); + => Assert.Equal( + RelationalStrings.UpdateDataOperationRowCountMismatch(1, 2, "People"), + Assert.Throws( + () => + Generate( + CreateGotModel, + new UpdateDataOperation + { + Table = "People", + KeyColumns = new[] { "First Name" }, + KeyColumnTypes = new[] { "string" }, + KeyValues = new object[,] { { "Daenerys" }, { "John" } }, + Columns = new[] { "House Allegiance" }, + Values = new object[,] { { "Targaryen" } } + })).Message); [ConditionalFact] public void UpdateDataOperation_throws_for_key_values_count_mismatch() - => Assert.Equal(RelationalStrings.UpdateDataOperationKeyValuesCountMismatch(1, 2, "People"), - Assert.Throws(() => - Generate( - CreateGotModel, - new UpdateDataOperation - { - Table = "People", - KeyColumns = new[] { "First Name", "Last Name" }, - KeyValues = new object[,] { { "Daenerys" } }, - Columns = new[] { "House Allegiance" }, - Values = new object[,] { { "Targaryen" } } - })).Message); + => Assert.Equal( + RelationalStrings.UpdateDataOperationKeyValuesCountMismatch(1, 2, "People"), + Assert.Throws( + () => + Generate( + CreateGotModel, + new UpdateDataOperation + { + Table = "People", + KeyColumns = new[] { "First Name", "Last Name" }, + KeyValues = new object[,] { { "Daenerys" } }, + Columns = new[] { "House Allegiance" }, + Values = new object[,] { { "Targaryen" } } + })).Message); [ConditionalFact] public void UpdateDataOperation_throws_for_key_types_count_mismatch() - => Assert.Equal(RelationalStrings.UpdateDataOperationKeyTypesCountMismatch(2, 1, "People"), - Assert.Throws(() => - Generate( - new UpdateDataOperation - { - Table = "People", - KeyColumns = new[] { "First Name" }, - KeyColumnTypes = new[] { "string", "string" }, - KeyValues = new object[,] { { "Daenerys" } }, - Columns = new[] { "House Allegiance" }, - Values = new object[,] { { "Targaryen" } } - })).Message); + => Assert.Equal( + RelationalStrings.UpdateDataOperationKeyTypesCountMismatch(2, 1, "People"), + Assert.Throws( + () => + Generate( + new UpdateDataOperation + { + Table = "People", + KeyColumns = new[] { "First Name" }, + KeyColumnTypes = new[] { "string", "string" }, + KeyValues = new object[,] { { "Daenerys" } }, + Columns = new[] { "House Allegiance" }, + Values = new object[,] { { "Targaryen" } } + })).Message); [ConditionalFact] public void UpdateDataOperation_throws_for_values_count_mismatch() - => Assert.Equal(RelationalStrings.UpdateDataOperationValuesCountMismatch(1, 2, "People"), - Assert.Throws(() => - Generate( - CreateGotModel, - new UpdateDataOperation - { - Table = "People", - KeyColumns = new[] { "First Name" }, - KeyValues = new object[,] { { "Daenerys" } }, - Columns = new[] { "House Allegiance", "Culture" }, - Values = new object[,] { { "Targaryen" } } - })).Message); + => Assert.Equal( + RelationalStrings.UpdateDataOperationValuesCountMismatch(1, 2, "People"), + Assert.Throws( + () => + Generate( + CreateGotModel, + new UpdateDataOperation + { + Table = "People", + KeyColumns = new[] { "First Name" }, + KeyValues = new object[,] { { "Daenerys" } }, + Columns = new[] { "House Allegiance", "Culture" }, + Values = new object[,] { { "Targaryen" } } + })).Message); [ConditionalFact] public void UpdateDataOperation_throws_for_types_count_mismatch() - => Assert.Equal(RelationalStrings.UpdateDataOperationTypesCountMismatch(2, 1, "People"), - Assert.Throws(() => - Generate( - new UpdateDataOperation - { - Table = "People", - KeyColumns = new[] { "First Name" }, - KeyValues = new object[,] { { "Daenerys" } }, - Columns = new[] { "House Allegiance" }, - ColumnTypes = new[] { "string", "string" }, - Values = new object[,] { { "Targaryen" } } - })).Message); + => Assert.Equal( + RelationalStrings.UpdateDataOperationTypesCountMismatch(2, 1, "People"), + Assert.Throws( + () => + Generate( + new UpdateDataOperation + { + Table = "People", + KeyColumns = new[] { "First Name" }, + KeyValues = new object[,] { { "Daenerys" } }, + Columns = new[] { "House Allegiance" }, + ColumnTypes = new[] { "string", "string" }, + Values = new object[,] { { "Targaryen" } } + })).Message); [ConditionalTheory] [InlineData(false)] @@ -680,19 +709,19 @@ public virtual void DefaultValue_with_line_breaks(bool isUnicode) } }); - private static void CreateGotModel(ModelBuilder b) { - b.Entity("Person", pb => - { - pb.ToTable("People"); - pb.Property("FirstName").HasColumnName("First Name"); - pb.Property("LastName").HasColumnName("Last Name"); - pb.Property("Birthplace").HasColumnName("Birthplace"); - pb.Property("Allegiance").HasColumnName("House Allegiance"); - pb.Property("Culture").HasColumnName("Culture"); - pb.HasKey("FirstName", "LastName"); - }); + b.Entity( + "Person", pb => + { + pb.ToTable("People"); + pb.Property("FirstName").HasColumnName("First Name"); + pb.Property("LastName").HasColumnName("Last Name"); + pb.Property("Birthplace").HasColumnName("Birthplace"); + pb.Property("Allegiance").HasColumnName("House Allegiance"); + pb.Property("Culture").HasColumnName("Culture"); + pb.HasKey("FirstName", "LastName"); + }); } protected TestHelpers TestHelpers { get; } @@ -700,7 +729,9 @@ private static void CreateGotModel(ModelBuilder b) protected IServiceCollection CustomServices { get; } protected MigrationsSqlGeneratorTestBase( - TestHelpers testHelpers, IServiceCollection customServices = null, DbContextOptions options = null) + TestHelpers testHelpers, + IServiceCollection customServices = null, + DbContextOptions options = null) { TestHelpers = testHelpers; CustomServices = customServices; @@ -725,7 +756,9 @@ protected virtual void Generate(Action buildAction, params Migrati => Generate(buildAction, operation, MigrationsSqlGenerationOptions.Default); protected virtual void Generate( - Action buildAction, MigrationOperation[] operation, MigrationsSqlGenerationOptions options) + Action buildAction, + MigrationOperation[] operation, + MigrationsSqlGenerationOptions options) { var services = ContextOptions != null ? TestHelpers.CreateContextServices(CustomServices, ContextOptions) diff --git a/test/EFCore.Relational.Tests/ModelBuilding/RelationalTestModelBuilderExtensions.cs b/test/EFCore.Relational.Tests/ModelBuilding/RelationalTestModelBuilderExtensions.cs index 0eed8d5eb25..d93bf3aefa6 100644 --- a/test/EFCore.Relational.Tests/ModelBuilding/RelationalTestModelBuilderExtensions.cs +++ b/test/EFCore.Relational.Tests/ModelBuilding/RelationalTestModelBuilderExtensions.cs @@ -9,7 +9,8 @@ namespace Microsoft.EntityFrameworkCore.ModelBuilding public static class RelationalTestModelBuilderExtensions { public static ModelBuilderTest.TestPropertyBuilder HasColumnName( - this ModelBuilderTest.TestPropertyBuilder builder, string name) + this ModelBuilderTest.TestPropertyBuilder builder, + string name) { switch (builder) { @@ -25,7 +26,8 @@ public static ModelBuilderTest.TestPropertyBuilder HasColumnName HasColumnType( - this ModelBuilderTest.TestPropertyBuilder builder, string typeName) + this ModelBuilderTest.TestPropertyBuilder builder, + string typeName) { switch (builder) { @@ -41,7 +43,8 @@ public static ModelBuilderTest.TestPropertyBuilder HasColumnType HasDefaultValueSql( - this ModelBuilderTest.TestPropertyBuilder builder, string sql) + this ModelBuilderTest.TestPropertyBuilder builder, + string sql) { switch (builder) { @@ -57,7 +60,8 @@ public static ModelBuilderTest.TestPropertyBuilder HasDefaultValueSql } public static ModelBuilderTest.TestPropertyBuilder HasComputedColumnSql( - this ModelBuilderTest.TestPropertyBuilder builder, string sql) + this ModelBuilderTest.TestPropertyBuilder builder, + string sql) { switch (builder) { @@ -73,7 +77,8 @@ public static ModelBuilderTest.TestPropertyBuilder HasComputedColumnS } public static ModelBuilderTest.TestPropertyBuilder HasDefaultValue( - this ModelBuilderTest.TestPropertyBuilder builder, object value) + this ModelBuilderTest.TestPropertyBuilder builder, + object value) { switch (builder) { @@ -89,7 +94,8 @@ public static ModelBuilderTest.TestPropertyBuilder HasDefaultValue IsFixedLength( - this ModelBuilderTest.TestPropertyBuilder builder, bool fixedLength = true) + this ModelBuilderTest.TestPropertyBuilder builder, + bool fixedLength = true) { switch (builder) { @@ -105,7 +111,8 @@ public static ModelBuilderTest.TestPropertyBuilder IsFixedLength ToTable( - this ModelBuilderTest.TestEntityTypeBuilder builder, string name) + this ModelBuilderTest.TestEntityTypeBuilder builder, + string name) where TEntity : class { switch (builder) @@ -122,7 +129,9 @@ public static ModelBuilderTest.TestEntityTypeBuilder ToTable( } public static ModelBuilderTest.TestEntityTypeBuilder ToTable( - this ModelBuilderTest.TestEntityTypeBuilder builder, string name, string schema) + this ModelBuilderTest.TestEntityTypeBuilder builder, + string name, + string schema) where TEntity : class { switch (builder) @@ -139,7 +148,8 @@ public static ModelBuilderTest.TestEntityTypeBuilder ToTable( } public static ModelBuilderTest.TestOwnedNavigationBuilder ToTable( - this ModelBuilderTest.TestOwnedNavigationBuilder builder, string name) + this ModelBuilderTest.TestOwnedNavigationBuilder builder, + string name) where TEntity : class where TRelatedEntity : class { @@ -157,7 +167,9 @@ public static ModelBuilderTest.TestOwnedNavigationBuilder ToTable( - this ModelBuilderTest.TestOwnedNavigationBuilder builder, string name, string schema) + this ModelBuilderTest.TestOwnedNavigationBuilder builder, + string name, + string schema) where TEntity : class where TRelatedEntity : class { @@ -232,7 +244,8 @@ public static ModelBuilderTest.TestReferenceCollectionBuilder HasFilter( - this ModelBuilderTest.TestIndexBuilder builder, string filterExpression) + this ModelBuilderTest.TestIndexBuilder builder, + string filterExpression) { switch (builder) { @@ -248,7 +261,8 @@ public static ModelBuilderTest.TestIndexBuilder HasFilter( } public static ModelBuilderTest.TestIndexBuilder HasName( - this ModelBuilderTest.TestIndexBuilder builder, string name) + this ModelBuilderTest.TestIndexBuilder builder, + string name) { switch (builder) { @@ -264,7 +278,8 @@ public static ModelBuilderTest.TestIndexBuilder HasName( } public static ModelBuilderTest.TestKeyBuilder HasName( - this ModelBuilderTest.TestKeyBuilder builder, string name) + this ModelBuilderTest.TestKeyBuilder builder, + string name) { switch (builder) { diff --git a/test/EFCore.Relational.Tests/Query/Internal/BufferedDataReaderTest.cs b/test/EFCore.Relational.Tests/Query/Internal/BufferedDataReaderTest.cs index a962b5e8ce6..2638e0bac61 100644 --- a/test/EFCore.Relational.Tests/Query/Internal/BufferedDataReaderTest.cs +++ b/test/EFCore.Relational.Tests/Query/Internal/BufferedDataReaderTest.cs @@ -51,7 +51,8 @@ public async Task Manipulation_methods_perform_expected_actions(bool async) new List> { new[] { new object[] { 1, "a" } }, new object[0][] }); var columns = new ReaderColumn[] { - new ReaderColumn(false, null, (r, _) => r.GetInt32(0)), new ReaderColumn(true, null, (r, _) => r.GetValue(1)) + new ReaderColumn(false, null, (r, _) => r.GetInt32(0)), + new ReaderColumn(true, null, (r, _) => r.GetValue(1)) }; var bufferedDataReader = new BufferedDataReader(reader); @@ -172,7 +173,9 @@ await Assert.ThrowsAsync( } private async Task Verify_method_result( - Func method, bool async, T expectedResult, + Func method, + bool async, + T expectedResult, params object[][] dataReaderContents) { var reader = new FakeDbDataReader(new[] { "name" }, dataReaderContents); @@ -212,6 +215,7 @@ private Task Verify_get_method_returns_supplied_value(T value, bool async) r => (T)readerMethod.Invoke(r, new object[] { 0 }), async, value, new object[] { value }); } - private static MethodInfo GetReaderMethod(Type type) => RelationalTypeMapping.GetDataReaderMethod(type); + private static MethodInfo GetReaderMethod(Type type) + => RelationalTypeMapping.GetDataReaderMethod(type); } } diff --git a/test/EFCore.Relational.Tests/Query/Internal/QuerySqlGeneratorTest.cs b/test/EFCore.Relational.Tests/Query/Internal/QuerySqlGeneratorTest.cs index 32c370fc6b4..04b46486aae 100644 --- a/test/EFCore.Relational.Tests/Query/Internal/QuerySqlGeneratorTest.cs +++ b/test/EFCore.Relational.Tests/Query/Internal/QuerySqlGeneratorTest.cs @@ -50,7 +50,7 @@ private DummyQuerySqlGenerator CreateDummyQuerySqlGenerator() new RelationalSqlGenerationHelper( new RelationalSqlGenerationHelperDependencies()))); - class DummyQuerySqlGenerator : QuerySqlGenerator + private class DummyQuerySqlGenerator : QuerySqlGenerator { public DummyQuerySqlGenerator([NotNull] QuerySqlGeneratorDependencies dependencies) : base(dependencies) diff --git a/test/EFCore.Relational.Tests/RelationalApiConsistencyTest.cs b/test/EFCore.Relational.Tests/RelationalApiConsistencyTest.cs index 905e37c1e09..a91de4c6d4c 100644 --- a/test/EFCore.Relational.Tests/RelationalApiConsistencyTest.cs +++ b/test/EFCore.Relational.Tests/RelationalApiConsistencyTest.cs @@ -28,16 +28,17 @@ public RelationalApiConsistencyTest(RelationalApiConsistencyFixture fixture) protected override void AddServices(ServiceCollection serviceCollection) => new EntityFrameworkRelationalServicesBuilder(serviceCollection).TryAddCoreServices(); - protected override Assembly TargetAssembly => typeof(RelationalDatabase).Assembly; + protected override Assembly TargetAssembly + => typeof(RelationalDatabase).Assembly; [ConditionalFact] public void Readonly_relational_metadata_methods_have_expected_name() { var errors = Fixture.RelationalMetadataMethods - .SelectMany(m => m.Select(ValidateMethodName)) - .Where(e => e != null) - .ToList(); + .SelectMany(m => m.Select(ValidateMethodName)) + .Where(e => e != null) + .ToList(); Assert.False( errors.Count > 0, @@ -55,8 +56,15 @@ public override bool TryGetProviderOptionsDelegate(out Action _metadataTypes => new Dictionary { - { typeof(IDbFunction), (typeof(IMutableDbFunction), typeof(IConventionDbFunction), typeof(IConventionDbFunctionBuilder)) }, - { typeof(IDbFunctionParameter), (typeof(IMutableDbFunctionParameter), typeof(IConventionDbFunctionParameter), typeof(IConventionDbFunctionParameterBuilder)) }, + { + typeof(IDbFunction), + (typeof(IMutableDbFunction), typeof(IConventionDbFunction), typeof(IConventionDbFunctionBuilder)) + }, + { + typeof(IDbFunctionParameter), + (typeof(IMutableDbFunctionParameter), typeof(IConventionDbFunctionParameter), + typeof(IConventionDbFunctionParameterBuilder)) + }, { typeof(ISequence), (typeof(IMutableSequence), typeof(IConventionSequence), typeof(IConventionSequenceBuilder)) }, { typeof(ICheckConstraint), (typeof(IMutableCheckConstraint), typeof(IConventionCheckConstraint), null) } }; @@ -81,7 +89,7 @@ public override bool TryGetProviderOptionsDelegate(out Action FluentApiTypes { get; } = new HashSet() + public override HashSet FluentApiTypes { get; } = new HashSet { typeof(RelationalForeignKeyBuilderExtensions), typeof(RelationalPropertyBuilderExtensions), @@ -101,15 +109,23 @@ public override bool TryGetProviderOptionsDelegate(out Action) }; - public override List<(Type Type, Type ReadonlyExtensions, Type MutableExtensions, Type ConventionExtensions, Type ConventionBuilderExtensions)> MetadataExtensionTypes { get; } - = new List<(Type, Type, Type, Type, Type)> + public override + List<(Type Type, Type ReadonlyExtensions, Type MutableExtensions, Type ConventionExtensions, Type + ConventionBuilderExtensions)> MetadataExtensionTypes { get; } + = new List<(Type, Type, Type, Type, Type)> { - { (typeof(IModel), typeof(RelationalModelExtensions), typeof(RelationalModelExtensions), typeof(RelationalModelExtensions), typeof(RelationalModelBuilderExtensions)) }, - { (typeof(IEntityType), typeof(RelationalEntityTypeExtensions), typeof(RelationalEntityTypeExtensions), typeof(RelationalEntityTypeExtensions), typeof(RelationalEntityTypeBuilderExtensions)) }, - { (typeof(IKey),typeof(RelationalKeyExtensions), typeof(RelationalKeyExtensions), typeof(RelationalKeyExtensions), typeof(RelationalKeyBuilderExtensions)) }, - { (typeof(IForeignKey), typeof(RelationalForeignKeyExtensions), typeof(RelationalForeignKeyExtensions), typeof(RelationalForeignKeyExtensions), typeof(RelationalForeignKeyBuilderExtensions)) }, - { (typeof(IProperty), typeof(RelationalPropertyExtensions), typeof(RelationalPropertyExtensions), typeof(RelationalPropertyExtensions), typeof(RelationalPropertyBuilderExtensions)) }, - { (typeof(IIndex), typeof(RelationalIndexExtensions), typeof(RelationalIndexExtensions), typeof(RelationalIndexExtensions), typeof(RelationalIndexBuilderExtensions)) } + (typeof(IModel), typeof(RelationalModelExtensions), typeof(RelationalModelExtensions), + typeof(RelationalModelExtensions), typeof(RelationalModelBuilderExtensions)), + (typeof(IEntityType), typeof(RelationalEntityTypeExtensions), typeof(RelationalEntityTypeExtensions), + typeof(RelationalEntityTypeExtensions), typeof(RelationalEntityTypeBuilderExtensions)), + (typeof(IKey), typeof(RelationalKeyExtensions), typeof(RelationalKeyExtensions), typeof(RelationalKeyExtensions), + typeof(RelationalKeyBuilderExtensions)), + (typeof(IForeignKey), typeof(RelationalForeignKeyExtensions), typeof(RelationalForeignKeyExtensions), + typeof(RelationalForeignKeyExtensions), typeof(RelationalForeignKeyBuilderExtensions)), + (typeof(IProperty), typeof(RelationalPropertyExtensions), typeof(RelationalPropertyExtensions), + typeof(RelationalPropertyExtensions), typeof(RelationalPropertyBuilderExtensions)), + (typeof(IIndex), typeof(RelationalIndexExtensions), typeof(RelationalIndexExtensions), + typeof(RelationalIndexExtensions), typeof(RelationalIndexBuilderExtensions)) }; public override HashSet NonVirtualMethods { get; } @@ -127,7 +143,8 @@ public override bool TryGetProviderOptionsDelegate(out Action AsyncMethodExceptions { get; } = new HashSet diff --git a/test/EFCore.Relational.Tests/RelationalConnectionTest.cs b/test/EFCore.Relational.Tests/RelationalConnectionTest.cs index c0571207c5c..83eaae52ecf 100644 --- a/test/EFCore.Relational.Tests/RelationalConnectionTest.cs +++ b/test/EFCore.Relational.Tests/RelationalConnectionTest.cs @@ -511,7 +511,6 @@ public void Existing_connection_can_be_changed_and_reset() Assert.Same(dbConnection, connection.DbConnection); Assert.Equal(0, connection.DbConnections.Count); Assert.Equal("Database=MerryLives", connection.ConnectionString); - } [ConditionalFact] diff --git a/test/EFCore.Relational.Tests/RelationalDatabaseFacadeExtensionsTest.cs b/test/EFCore.Relational.Tests/RelationalDatabaseFacadeExtensionsTest.cs index 063bcd3b655..a45d7f2e784 100644 --- a/test/EFCore.Relational.Tests/RelationalDatabaseFacadeExtensionsTest.cs +++ b/test/EFCore.Relational.Tests/RelationalDatabaseFacadeExtensionsTest.cs @@ -167,7 +167,8 @@ public void ResetState() { } - public Task ResetStateAsync(CancellationToken cancellationToken = default) => Task.CompletedTask; + public Task ResetStateAsync(CancellationToken cancellationToken = default) + => Task.CompletedTask; public IDbContextTransaction BeginTransaction() { @@ -234,8 +235,12 @@ private class FakeIMigrationsAssembly : IMigrationsAssembly public IReadOnlyDictionary Migrations { get; set; } public ModelSnapshot ModelSnapshot { get; } public Assembly Assembly { get; } - public string FindMigrationId(string nameOrId) => throw new NotImplementedException(); - public Migration CreateMigration(TypeInfo migrationClass, string activeProvider) => throw new NotImplementedException(); + + public string FindMigrationId(string nameOrId) + => throw new NotImplementedException(); + + public Migration CreateMigration(TypeInfo migrationClass, string activeProvider) + => throw new NotImplementedException(); } [ConditionalTheory] @@ -270,15 +275,32 @@ public IReadOnlyList GetAppliedMigrations() public Task> GetAppliedMigrationsAsync(CancellationToken cancellationToken = default) => Task.FromResult>(AppliedMigrations); - public bool Exists() => throw new NotImplementedException(); - public Task ExistsAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException(); - public string GetCreateScript() => throw new NotImplementedException(); - public string GetCreateIfNotExistsScript() => throw new NotImplementedException(); - public string GetInsertScript(HistoryRow row) => throw new NotImplementedException(); - public string GetDeleteScript(string migrationId) => throw new NotImplementedException(); - public string GetBeginIfNotExistsScript(string migrationId) => throw new NotImplementedException(); - public string GetBeginIfExistsScript(string migrationId) => throw new NotImplementedException(); - public string GetEndIfScript() => throw new NotImplementedException(); + public bool Exists() + => throw new NotImplementedException(); + + public Task ExistsAsync(CancellationToken cancellationToken = default) + => throw new NotImplementedException(); + + public string GetCreateScript() + => throw new NotImplementedException(); + + public string GetCreateIfNotExistsScript() + => throw new NotImplementedException(); + + public string GetInsertScript(HistoryRow row) + => throw new NotImplementedException(); + + public string GetDeleteScript(string migrationId) + => throw new NotImplementedException(); + + public string GetBeginIfNotExistsScript(string migrationId) + => throw new NotImplementedException(); + + public string GetBeginIfExistsScript(string migrationId) + => throw new NotImplementedException(); + + public string GetEndIfScript() + => throw new NotImplementedException(); } [ConditionalTheory] diff --git a/test/EFCore.Relational.Tests/RelationalEventIdTest.cs b/test/EFCore.Relational.Tests/RelationalEventIdTest.cs index 16cf9f712bb..c86d7730355 100644 --- a/test/EFCore.Relational.Tests/RelationalEventIdTest.cs +++ b/test/EFCore.Relational.Tests/RelationalEventIdTest.cs @@ -16,7 +16,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Query; @@ -27,6 +26,7 @@ using Microsoft.EntityFrameworkCore.Update; using Microsoft.Extensions.DependencyInjection; using Xunit; +using Index = Microsoft.EntityFrameworkCore.Metadata.Internal.Index; using IsolationLevel = System.Data.IsolationLevel; // ReSharper disable InconsistentNaming @@ -43,7 +43,7 @@ public void Every_eventId_has_a_logger_method_and_logs_when_level_enabled() var property = new Property( "A", typeof(int), null, null, entityType, ConfigurationSource.Convention, ConfigurationSource.Convention); var contextServices = RelationalTestHelpers.Instance.CreateContextServices(model.FinalizeModel()); - var index = new Metadata.Internal.Index(new List { property }, "IndexName", entityType, ConfigurationSource.Convention); + var index = new Index(new List { property }, "IndexName", entityType, ConfigurationSource.Convention); var fakeFactories = new Dictionary> { @@ -119,7 +119,8 @@ private class FakeDbContext : DbContext private class FakeMigration : Migration { - protected override void Up(MigrationBuilder migrationBuilder) => throw new NotImplementedException(); + protected override void Up(MigrationBuilder migrationBuilder) + => throw new NotImplementedException(); } private class FakeSqlExpression : SqlExpression @@ -129,89 +130,163 @@ public FakeSqlExpression() { } - protected override void Print([NotNull] ExpressionPrinter expressionPrinter) => expressionPrinter.Append("FakeSqlExpression"); + protected override void Print([NotNull] ExpressionPrinter expressionPrinter) + => expressionPrinter.Append("FakeSqlExpression"); } private class FakeMigrator : IMigrator { - public void Migrate(string targetMigration = null) => throw new NotImplementedException(); + public void Migrate(string targetMigration = null) + => throw new NotImplementedException(); - public Task MigrateAsync(string targetMigration = null, CancellationToken cancellationToken = new CancellationToken()) => - throw new NotImplementedException(); + public Task MigrateAsync(string targetMigration = null, CancellationToken cancellationToken = new CancellationToken()) + => throw new NotImplementedException(); - public string GenerateScript(string fromMigration = null, string toMigration = null, MigrationsSqlGenerationOptions options = MigrationsSqlGenerationOptions.Default) => - throw new NotImplementedException(); + public string GenerateScript( + string fromMigration = null, + string toMigration = null, + MigrationsSqlGenerationOptions options = MigrationsSqlGenerationOptions.Default) + => throw new NotImplementedException(); } private class FakeMigrationsAssembly : IMigrationsAssembly { - public IReadOnlyDictionary Migrations => throw new NotImplementedException(); - public ModelSnapshot ModelSnapshot => throw new NotImplementedException(); - public Assembly Assembly => typeof(FakeMigrationsAssembly).Assembly; - public Migration CreateMigration(TypeInfo migrationClass, string activeProvider) => throw new NotImplementedException(); - public string FindMigrationId(string nameOrId) => throw new NotImplementedException(); + public IReadOnlyDictionary Migrations + => throw new NotImplementedException(); + + public ModelSnapshot ModelSnapshot + => throw new NotImplementedException(); + + public Assembly Assembly + => typeof(FakeMigrationsAssembly).Assembly; + + public Migration CreateMigration(TypeInfo migrationClass, string activeProvider) + => throw new NotImplementedException(); + + public string FindMigrationId(string nameOrId) + => throw new NotImplementedException(); } private class FakeRelationalConnection : IRelationalConnection { - public string ConnectionString => throw new NotImplementedException(); - public DbConnection DbConnection => new FakeDbConnection(); - public DbContext Context => null; - public Guid ConnectionId => Guid.NewGuid(); + public string ConnectionString + => throw new NotImplementedException(); + + public DbConnection DbConnection + => new FakeDbConnection(); + + public DbContext Context + => null; + + public Guid ConnectionId + => Guid.NewGuid(); + public int? CommandTimeout { get; set; } - public Task CloseAsync() => throw new NotImplementedException(); - public IDbContextTransaction CurrentTransaction => throw new NotImplementedException(); - public SemaphoreSlim Semaphore => throw new NotImplementedException(); - public IDbContextTransaction BeginTransaction(IsolationLevel isolationLevel) => throw new NotImplementedException(); - public IDbContextTransaction BeginTransaction() => throw new NotImplementedException(); + + public Task CloseAsync() + => throw new NotImplementedException(); + + public IDbContextTransaction CurrentTransaction + => throw new NotImplementedException(); + + public SemaphoreSlim Semaphore + => throw new NotImplementedException(); + + public IDbContextTransaction BeginTransaction(IsolationLevel isolationLevel) + => throw new NotImplementedException(); + + public IDbContextTransaction BeginTransaction() + => throw new NotImplementedException(); public Task BeginTransactionAsync( - 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(); + + public bool Close() + => throw new NotImplementedException(); + + public void CommitTransaction() + => throw new NotImplementedException(); + + public Task CommitTransactionAsync(CancellationToken cancellationToken = default) + => throw new NotImplementedException(); - public Task BeginTransactionAsync(CancellationToken cancellationToken = default) => - throw new NotImplementedException(); + public void Dispose() + => throw new NotImplementedException(); - public bool Close() => throw new NotImplementedException(); - public void CommitTransaction() => throw new NotImplementedException(); - public Task CommitTransactionAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException(); - public void Dispose() => throw new NotImplementedException(); - public bool Open(bool errorsExpected = false) => throw new NotImplementedException(); + public bool Open(bool errorsExpected = false) + => throw new NotImplementedException(); - public Task OpenAsync(CancellationToken cancellationToken, bool errorsExpected = false) => - throw new NotImplementedException(); + public Task OpenAsync(CancellationToken cancellationToken, bool errorsExpected = false) + => throw new NotImplementedException(); - public void ResetState() => throw new NotImplementedException(); - public Task ResetStateAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException(); + public void ResetState() + => throw new NotImplementedException(); - public void RollbackTransaction() => throw new NotImplementedException(); - public Task RollbackTransactionAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException(); + public Task ResetStateAsync(CancellationToken cancellationToken = default) + => throw new NotImplementedException(); - public IDbContextTransaction UseTransaction(DbTransaction transaction) => throw new NotImplementedException(); + public void RollbackTransaction() + => throw new NotImplementedException(); - public IDbContextTransaction UseTransaction(DbTransaction transaction, Guid transactionId) => - throw new NotImplementedException(); + public Task RollbackTransactionAsync(CancellationToken cancellationToken = default) + => throw new NotImplementedException(); + + public IDbContextTransaction UseTransaction(DbTransaction transaction) + => throw new NotImplementedException(); + + public IDbContextTransaction UseTransaction(DbTransaction transaction, Guid transactionId) + => throw new NotImplementedException(); public Task UseTransactionAsync( - DbTransaction transaction, CancellationToken cancellationToken = default) => throw new NotImplementedException(); + DbTransaction transaction, + CancellationToken cancellationToken = default) + => throw new NotImplementedException(); public Task UseTransactionAsync( - DbTransaction transaction, Guid transactionId, CancellationToken cancellationToken = default) => throw new NotImplementedException(); + DbTransaction transaction, + Guid transactionId, + CancellationToken cancellationToken = default) + => throw new NotImplementedException(); - public ValueTask DisposeAsync() => throw new NotImplementedException(); + public ValueTask DisposeAsync() + => throw new NotImplementedException(); } private class FakeDbConnection : DbConnection { public override string ConnectionString { get; set; } - public override string Database => "Database"; - public override string DataSource => "DataSource"; - public override string ServerVersion => throw new NotImplementedException(); - public override ConnectionState State => throw new NotImplementedException(); - 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(IsolationLevel isolationLevel) => throw new NotImplementedException(); - protected override DbCommand CreateDbCommand() => throw new NotImplementedException(); + + public override string Database + => "Database"; + + public override string DataSource + => "DataSource"; + + public override string ServerVersion + => throw new NotImplementedException(); + + public override ConnectionState State + => throw new NotImplementedException(); + + 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(IsolationLevel isolationLevel) + => throw new NotImplementedException(); + + protected override DbCommand CreateDbCommand() + => throw new NotImplementedException(); } private class FakeDbCommand : DbCommand @@ -227,86 +302,200 @@ public override string CommandText public override bool DesignTimeVisible { get; set; } public override UpdateRowSource UpdatedRowSource { get; set; } protected override DbConnection DbConnection { get; set; } - protected override DbParameterCollection DbParameterCollection => new FakeDbParameterCollection(); + + protected override DbParameterCollection DbParameterCollection + => new FakeDbParameterCollection(); + protected override DbTransaction DbTransaction { get; set; } - public override void Cancel() => throw new NotImplementedException(); - public override int ExecuteNonQuery() => throw new NotImplementedException(); - public override object ExecuteScalar() => throw new NotImplementedException(); - public override void Prepare() => throw new NotImplementedException(); - protected override DbParameter CreateDbParameter() => throw new NotImplementedException(); - protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) => throw new NotImplementedException(); + + public override void Cancel() + => throw new NotImplementedException(); + + public override int ExecuteNonQuery() + => throw new NotImplementedException(); + + public override object ExecuteScalar() + => throw new NotImplementedException(); + + public override void Prepare() + => throw new NotImplementedException(); + + protected override DbParameter CreateDbParameter() + => throw new NotImplementedException(); + + protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) + => throw new NotImplementedException(); } private class FakeDbParameterCollection : DbParameterCollection { - public override int Count => 0; - public override object SyncRoot => throw new NotImplementedException(); - public override int Add(object value) => throw new NotImplementedException(); - public override void AddRange(Array values) => throw new NotImplementedException(); - public override void Clear() => throw new NotImplementedException(); - public override bool Contains(object value) => throw new NotImplementedException(); - public override bool Contains(string value) => throw new NotImplementedException(); - public override void CopyTo(Array array, int index) => throw new NotImplementedException(); - public override IEnumerator GetEnumerator() => new List().GetEnumerator(); - public override int IndexOf(object value) => throw new NotImplementedException(); - public override int IndexOf(string parameterName) => throw new NotImplementedException(); - public override void Insert(int index, object value) => throw new NotImplementedException(); - public override void Remove(object value) => throw new NotImplementedException(); - public override void RemoveAt(int index) => throw new NotImplementedException(); - public override void RemoveAt(string parameterName) => throw new NotImplementedException(); - protected override DbParameter GetParameter(int index) => throw new NotImplementedException(); - protected override DbParameter GetParameter(string parameterName) => throw new NotImplementedException(); - protected override void SetParameter(int index, DbParameter value) => throw new NotImplementedException(); - protected override void SetParameter(string parameterName, DbParameter value) => throw new NotImplementedException(); + public override int Count + => 0; + + public override object SyncRoot + => throw new NotImplementedException(); + + public override int Add(object value) + => throw new NotImplementedException(); + + public override void AddRange(Array values) + => throw new NotImplementedException(); + + public override void Clear() + => throw new NotImplementedException(); + + public override bool Contains(object value) + => throw new NotImplementedException(); + + public override bool Contains(string value) + => throw new NotImplementedException(); + + public override void CopyTo(Array array, int index) + => throw new NotImplementedException(); + + public override IEnumerator GetEnumerator() + => new List().GetEnumerator(); + + public override int IndexOf(object value) + => throw new NotImplementedException(); + + public override int IndexOf(string parameterName) + => throw new NotImplementedException(); + + public override void Insert(int index, object value) + => throw new NotImplementedException(); + + public override void Remove(object value) + => throw new NotImplementedException(); + + public override void RemoveAt(int index) + => throw new NotImplementedException(); + + public override void RemoveAt(string parameterName) + => throw new NotImplementedException(); + + protected override DbParameter GetParameter(int index) + => throw new NotImplementedException(); + + protected override DbParameter GetParameter(string parameterName) + => throw new NotImplementedException(); + + protected override void SetParameter(int index, DbParameter value) + => throw new NotImplementedException(); + + protected override void SetParameter(string parameterName, DbParameter value) + => throw new NotImplementedException(); } private class FakeDbTransaction : DbTransaction { - 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(); + 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(); } private class FakeDbDataReader : DbDataReader { - public override bool GetBoolean(int ordinal) => throw new NotImplementedException(); - public override byte GetByte(int ordinal) => throw new NotImplementedException(); - - public override long GetBytes(int ordinal, long dataOffset, byte[] buffer, int bufferOffset, int length) => - throw new NotImplementedException(); - - public override char GetChar(int ordinal) => throw new NotImplementedException(); - - public override long GetChars(int ordinal, long dataOffset, char[] buffer, int bufferOffset, int length) => - throw new NotImplementedException(); - - public override string GetDataTypeName(int ordinal) => throw new NotImplementedException(); - public override DateTime GetDateTime(int ordinal) => throw new NotImplementedException(); - public override decimal GetDecimal(int ordinal) => throw new NotImplementedException(); - public override double GetDouble(int ordinal) => throw new NotImplementedException(); - public override Type GetFieldType(int ordinal) => throw new NotImplementedException(); - public override float GetFloat(int ordinal) => throw new NotImplementedException(); - public override Guid GetGuid(int ordinal) => throw new NotImplementedException(); - public override short GetInt16(int ordinal) => throw new NotImplementedException(); - public override int GetInt32(int ordinal) => throw new NotImplementedException(); - public override long GetInt64(int ordinal) => throw new NotImplementedException(); - public override string GetName(int ordinal) => throw new NotImplementedException(); - public override int GetOrdinal(string name) => throw new NotImplementedException(); - public override string GetString(int ordinal) => throw new NotImplementedException(); - public override object GetValue(int ordinal) => throw new NotImplementedException(); - public override int GetValues(object[] values) => throw new NotImplementedException(); - public override bool IsDBNull(int ordinal) => throw new NotImplementedException(); - public override int FieldCount => throw new NotImplementedException(); - public override object this[int ordinal] => throw new NotImplementedException(); - public override object this[string name] => throw new NotImplementedException(); - public override int RecordsAffected => throw new NotImplementedException(); - public override bool HasRows => throw new NotImplementedException(); - public override bool IsClosed => throw new NotImplementedException(); - public override bool NextResult() => throw new NotImplementedException(); - public override bool Read() => throw new NotImplementedException(); - public override int Depth => throw new NotImplementedException(); - public override IEnumerator GetEnumerator() => throw new NotImplementedException(); + public override bool GetBoolean(int ordinal) + => throw new NotImplementedException(); + + public override byte GetByte(int ordinal) + => throw new NotImplementedException(); + + public override long GetBytes(int ordinal, long dataOffset, byte[] buffer, int bufferOffset, int length) + => throw new NotImplementedException(); + + public override char GetChar(int ordinal) + => throw new NotImplementedException(); + + public override long GetChars(int ordinal, long dataOffset, char[] buffer, int bufferOffset, int length) + => throw new NotImplementedException(); + + public override string GetDataTypeName(int ordinal) + => throw new NotImplementedException(); + + public override DateTime GetDateTime(int ordinal) + => throw new NotImplementedException(); + + public override decimal GetDecimal(int ordinal) + => throw new NotImplementedException(); + + public override double GetDouble(int ordinal) + => throw new NotImplementedException(); + + public override Type GetFieldType(int ordinal) + => throw new NotImplementedException(); + + public override float GetFloat(int ordinal) + => throw new NotImplementedException(); + + public override Guid GetGuid(int ordinal) + => throw new NotImplementedException(); + + public override short GetInt16(int ordinal) + => throw new NotImplementedException(); + + public override int GetInt32(int ordinal) + => throw new NotImplementedException(); + + public override long GetInt64(int ordinal) + => throw new NotImplementedException(); + + public override string GetName(int ordinal) + => throw new NotImplementedException(); + + public override int GetOrdinal(string name) + => throw new NotImplementedException(); + + public override string GetString(int ordinal) + => throw new NotImplementedException(); + + public override object GetValue(int ordinal) + => throw new NotImplementedException(); + + public override int GetValues(object[] values) + => throw new NotImplementedException(); + + public override bool IsDBNull(int ordinal) + => throw new NotImplementedException(); + + public override int FieldCount + => throw new NotImplementedException(); + + public override object this[int ordinal] + => throw new NotImplementedException(); + + public override object this[string name] + => throw new NotImplementedException(); + + public override int RecordsAffected + => throw new NotImplementedException(); + + public override bool HasRows + => throw new NotImplementedException(); + + public override bool IsClosed + => throw new NotImplementedException(); + + public override bool NextResult() + => throw new NotImplementedException(); + + public override bool Read() + => throw new NotImplementedException(); + + public override int Depth + => throw new NotImplementedException(); + + public override IEnumerator GetEnumerator() + => throw new NotImplementedException(); } } } diff --git a/test/EFCore.Relational.Tests/Storage/NamedConnectionStringResolverTest.cs b/test/EFCore.Relational.Tests/Storage/NamedConnectionStringResolverTest.cs index e9094d3426f..664bc516718 100644 --- a/test/EFCore.Relational.Tests/Storage/NamedConnectionStringResolverTest.cs +++ b/test/EFCore.Relational.Tests/Storage/NamedConnectionStringResolverTest.cs @@ -104,7 +104,8 @@ public FakeOptions(IConfiguration configuration, bool useServiceProvider = true) } } - public IEnumerable Extensions => null; + public IEnumerable Extensions + => null; public TExtension FindExtension() where TExtension : class, IDbContextOptionsExtension diff --git a/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs b/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs index 73719bec03a..0dcbe320302 100644 --- a/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs +++ b/test/EFCore.Relational.Tests/Storage/RelationalCommandTest.cs @@ -1207,7 +1207,9 @@ public void Validate(IDbContextOptions options) public bool IsSensitiveDataLoggingEnabled { get; } public bool IsSensitiveDataLoggingWarned { get; set; } - public WarningsConfiguration WarningsConfiguration => null; + + public WarningsConfiguration WarningsConfiguration + => null; } private IRelationalCommand CreateRelationalCommand( diff --git a/test/EFCore.Relational.Tests/Storage/RelationalDatabaseFacadeExtensionsTest.cs b/test/EFCore.Relational.Tests/Storage/RelationalDatabaseFacadeExtensionsTest.cs index eaf845300f7..57c98093655 100644 --- a/test/EFCore.Relational.Tests/Storage/RelationalDatabaseFacadeExtensionsTest.cs +++ b/test/EFCore.Relational.Tests/Storage/RelationalDatabaseFacadeExtensionsTest.cs @@ -283,7 +283,8 @@ public TestRawSqlCommandBuilder( public string Sql { get; private set; } public IEnumerable Parameters { get; private set; } - public IRelationalCommand Build(string sql) => throw new NotImplementedException(); + public IRelationalCommand Build(string sql) + => throw new NotImplementedException(); public RawSqlCommand Build(string sql, IEnumerable parameters) { diff --git a/test/EFCore.Relational.Tests/Storage/RelationalGeometryTypeMappingTest.cs b/test/EFCore.Relational.Tests/Storage/RelationalGeometryTypeMappingTest.cs index 4ca3925bcb0..d142db977c0 100644 --- a/test/EFCore.Relational.Tests/Storage/RelationalGeometryTypeMappingTest.cs +++ b/test/EFCore.Relational.Tests/Storage/RelationalGeometryTypeMappingTest.cs @@ -13,16 +13,8 @@ public class RelationalGeometryTypeMappingTest [ConditionalFact] public void Comparer_uses_exact_comparison() { - var geometry1 = new GeometryCollection(new[] - { - new Point(1, 2), - new Point(3, 4) - }); - var geometry2 = new GeometryCollection(new[] - { - new Point(3, 4), - new Point(1, 2) - }); + var geometry1 = new GeometryCollection(new[] { new Point(1, 2), new Point(3, 4) }); + var geometry2 = new GeometryCollection(new[] { new Point(3, 4), new Point(1, 2) }); var comparer = new FakeRelationalGeometryTypeMapping().Comparer; Assert.False(comparer.Equals(geometry1, geometry2)); @@ -44,14 +36,20 @@ protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters p => new FakeRelationalGeometryTypeMapping(parameters); protected override Type WKTReaderType { get; } - protected override string AsText(object value) => throw new NotImplementedException(); - protected override int GetSrid(object value) => throw new NotImplementedException(); - class NullValueConverter : ValueConverter + protected override string AsText(object value) + => throw new NotImplementedException(); + + protected override int GetSrid(object value) + => throw new NotImplementedException(); + + private class NullValueConverter : ValueConverter { - public NullValueConverter() : base(t => t, t => t) {} + public NullValueConverter() + : base(t => t, t => t) + { + } } } - } } diff --git a/test/EFCore.Relational.Tests/Storage/RelationalTransactionExtensionsTest.cs b/test/EFCore.Relational.Tests/Storage/RelationalTransactionExtensionsTest.cs index 6456ee783b8..1b25fa4ea0f 100644 --- a/test/EFCore.Relational.Tests/Storage/RelationalTransactionExtensionsTest.cs +++ b/test/EFCore.Relational.Tests/Storage/RelationalTransactionExtensionsTest.cs @@ -59,12 +59,23 @@ private class NonRelationalTransaction : IDbContextTransaction { public Guid TransactionId { get; } = Guid.NewGuid(); - public void Commit() => throw new NotImplementedException(); - public void Dispose() => throw new NotImplementedException(); - public void Rollback() => throw new NotImplementedException(); - public Task CommitAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException(); - public Task RollbackAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException(); - public ValueTask DisposeAsync() => throw new NotImplementedException(); + public void Commit() + => throw new NotImplementedException(); + + public void Dispose() + => throw new NotImplementedException(); + + public void Rollback() + => throw new NotImplementedException(); + + public Task CommitAsync(CancellationToken cancellationToken = default) + => throw new NotImplementedException(); + + public Task RollbackAsync(CancellationToken cancellationToken = default) + => throw new NotImplementedException(); + + public ValueTask DisposeAsync() + => throw new NotImplementedException(); } private const string ConnectionString = "Fake Connection String"; diff --git a/test/EFCore.Relational.Tests/Storage/RelationalTypeMapperTest.cs b/test/EFCore.Relational.Tests/Storage/RelationalTypeMapperTest.cs index 396717ed0e5..89b09da618f 100644 --- a/test/EFCore.Relational.Tests/Storage/RelationalTypeMapperTest.cs +++ b/test/EFCore.Relational.Tests/Storage/RelationalTypeMapperTest.cs @@ -301,6 +301,7 @@ public static RelationalTypeMapping GetMapping( IProperty property) => typeMappingSource.FindMapping(property); - protected override ModelBuilder CreateModelBuilder() => RelationalTestHelpers.Instance.CreateConventionBuilder(); + protected override ModelBuilder CreateModelBuilder() + => RelationalTestHelpers.Instance.CreateConventionBuilder(); } } diff --git a/test/EFCore.Relational.Tests/Storage/RelationalTypeMappingTest.cs b/test/EFCore.Relational.Tests/Storage/RelationalTypeMappingTest.cs index 7ba4084749e..ec7616efa04 100644 --- a/test/EFCore.Relational.Tests/Storage/RelationalTypeMappingTest.cs +++ b/test/EFCore.Relational.Tests/Storage/RelationalTypeMappingTest.cs @@ -349,7 +349,9 @@ public void Can_create_string_parameter() } protected virtual void Test_GenerateSqlLiteral_helper( - RelationalTypeMapping typeMapping, object value, string literalValue) + RelationalTypeMapping typeMapping, + object value, + string literalValue) { Assert.Equal(literalValue, typeMapping.GenerateSqlLiteral(value)); } diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeDiagnosticsLogger.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeDiagnosticsLogger.cs index d1158c0c452..1d29ea02038 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeDiagnosticsLogger.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeDiagnosticsLogger.cs @@ -15,9 +15,11 @@ public class FakeDiagnosticsLogger : IDiagnosticsLogger, ILogger { public ILoggingOptions Options { get; } = new LoggingOptions(); - public bool ShouldLogSensitiveData() => false; + public bool ShouldLogSensitiveData() + => false; - public ILogger Logger => this; + public ILogger Logger + => this; public DiagnosticSource DiagnosticSource { get; } = new DiagnosticListener("Fake"); @@ -32,11 +34,14 @@ public void Log( { } - public bool IsEnabled(LogLevel logLevel) => true; + public bool IsEnabled(LogLevel logLevel) + => true; - public bool IsEnabled(EventId eventId, LogLevel logLevel) => true; + public bool IsEnabled(EventId eventId, LogLevel logLevel) + => true; - public IDisposable BeginScope(TState state) => null; + public IDisposable BeginScope(TState state) + => null; public virtual LoggingDefinitions Definitions { get; } = new TestRelationalLoggingDefinitions(); diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeCommandExecutor.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeCommandExecutor.cs index 0ab8d0b16f1..a970542fe79 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeCommandExecutor.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeCommandExecutor.cs @@ -45,9 +45,11 @@ public FakeCommandExecutor( ?? ((c, ct, b) => Task.FromResult(new FakeDbDataReader())); } - public virtual int ExecuteNonQuery(FakeDbCommand command) => _executeNonQuery(command); + public virtual int ExecuteNonQuery(FakeDbCommand command) + => _executeNonQuery(command); - public virtual object ExecuteScalar(FakeDbCommand command) => _executeScalar(command); + public virtual object ExecuteScalar(FakeDbCommand command) + => _executeScalar(command); public virtual DbDataReader ExecuteReader(FakeDbCommand command, CommandBehavior behavior) => _executeReader(command, behavior); diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbConnection.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbConnection.cs index 5e8d0e7de75..6010c39ba01 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbConnection.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbConnection.cs @@ -31,9 +31,11 @@ public FakeDbConnection( public void SetState(ConnectionState state) => _state = state; - public override ConnectionState State => _state; + public override ConnectionState State + => _state; - public IReadOnlyList DbCommands => _dbCommands; + public IReadOnlyList DbCommands + => _dbCommands; public override string ConnectionString { get; set; } @@ -41,7 +43,8 @@ public void SetState(ConnectionState state) public override string DataSource { get; } = "Fake DataSource"; - public override string ServerVersion => throw new NotImplementedException(); + public override string ServerVersion + => throw new NotImplementedException(); public override void ChangeDatabase(string databaseName) { @@ -81,7 +84,8 @@ protected override DbCommand CreateDbCommand() return command; } - public IReadOnlyList DbTransactions => _dbTransactions; + public IReadOnlyList DbTransactions + => _dbTransactions; public FakeDbTransaction ActiveTransaction { get; set; } diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbDataReader.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbDataReader.cs index 48957c7523f..fb0f8a14a36 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbDataReader.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbDataReader.cs @@ -80,13 +80,17 @@ protected override void Dispose(bool disposing) _closed = true; } - public override int FieldCount => _columnNames.Length; + public override int FieldCount + => _columnNames.Length; - public override string GetName(int ordinal) => _columnNames[ordinal]; + public override string GetName(int ordinal) + => _columnNames[ordinal]; - public override bool IsDBNull(int ordinal) => _currentRow[ordinal] == DBNull.Value; + public override bool IsDBNull(int ordinal) + => _currentRow[ordinal] == DBNull.Value; - public override object GetValue(int ordinal) => _currentRow[ordinal]; + public override object GetValue(int ordinal) + => _currentRow[ordinal]; public int GetInt32Count { get; private set; } @@ -97,41 +101,54 @@ public override int GetInt32(int ordinal) return (int)_currentRow[ordinal]; } - public override object this[string name] => throw new NotImplementedException(); + public override object this[string name] + => throw new NotImplementedException(); - public override object this[int ordinal] => throw new NotImplementedException(); + public override object this[int ordinal] + => throw new NotImplementedException(); - public override int Depth => throw new NotImplementedException(); + public override int Depth + => throw new NotImplementedException(); - public override bool HasRows => _results.Count != 0; + public override bool HasRows + => _results.Count != 0; - public override bool IsClosed => _closed; + public override bool IsClosed + => _closed; - public override int RecordsAffected => _resultSets.Aggregate(0, (a, r) => a + r.Count); + public override int RecordsAffected + => _resultSets.Aggregate(0, (a, r) => a + r.Count); - public override bool GetBoolean(int ordinal) => (bool)_currentRow[ordinal]; + public override bool GetBoolean(int ordinal) + => (bool)_currentRow[ordinal]; - public override byte GetByte(int ordinal) => (byte)_currentRow[ordinal]; + public override byte GetByte(int ordinal) + => (byte)_currentRow[ordinal]; public override long GetBytes(int ordinal, long dataOffset, byte[] buffer, int bufferOffset, int length) { throw new NotImplementedException(); } - public override char GetChar(int ordinal) => (char)_currentRow[ordinal]; + public override char GetChar(int ordinal) + => (char)_currentRow[ordinal]; public override long GetChars(int ordinal, long dataOffset, char[] buffer, int bufferOffset, int length) { throw new NotImplementedException(); } - public override string GetDataTypeName(int ordinal) => GetFieldType(ordinal).Name; + public override string GetDataTypeName(int ordinal) + => GetFieldType(ordinal).Name; - public override DateTime GetDateTime(int ordinal) => (DateTime)_currentRow[ordinal]; + public override DateTime GetDateTime(int ordinal) + => (DateTime)_currentRow[ordinal]; - public override decimal GetDecimal(int ordinal) => (decimal)_currentRow[ordinal]; + public override decimal GetDecimal(int ordinal) + => (decimal)_currentRow[ordinal]; - public override double GetDouble(int ordinal) => (double)_currentRow[ordinal]; + public override double GetDouble(int ordinal) + => (double)_currentRow[ordinal]; public override IEnumerator GetEnumerator() { @@ -143,20 +160,25 @@ public override Type GetFieldType(int ordinal) ? _results[0][ordinal]?.GetType() ?? typeof(object) : typeof(object); - public override float GetFloat(int ordinal) => (float)_currentRow[ordinal]; + public override float GetFloat(int ordinal) + => (float)_currentRow[ordinal]; - public override Guid GetGuid(int ordinal) => (Guid)_currentRow[ordinal]; + public override Guid GetGuid(int ordinal) + => (Guid)_currentRow[ordinal]; - public override short GetInt16(int ordinal) => (short)_currentRow[ordinal]; + public override short GetInt16(int ordinal) + => (short)_currentRow[ordinal]; - public override long GetInt64(int ordinal) => (long)_currentRow[ordinal]; + public override long GetInt64(int ordinal) + => (long)_currentRow[ordinal]; public override int GetOrdinal(string name) { throw new NotImplementedException(); } - public override string GetString(int ordinal) => (string)_currentRow[ordinal]; + public override string GetString(int ordinal) + => (string)_currentRow[ordinal]; public override int GetValues(object[] values) { diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbParameterCollection.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbParameterCollection.cs index 79ab92634ff..99f44d082da 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbParameterCollection.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeDbParameterCollection.cs @@ -12,7 +12,8 @@ public class FakeDbParameterCollection : DbParameterCollection { private readonly List _parameters = new List(); - public override int Count => _parameters.Count; + public override int Count + => _parameters.Count; public override int Add(object value) { @@ -27,9 +28,11 @@ protected override DbParameter GetParameter(int index) public override IEnumerator GetEnumerator() => _parameters.GetEnumerator(); - public override object SyncRoot => throw new NotImplementedException(); + public override object SyncRoot + => throw new NotImplementedException(); - public override void AddRange(Array values) => throw new NotImplementedException(); + public override void AddRange(Array values) + => throw new NotImplementedException(); public override void Clear() { diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalConnection.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalConnection.cs index 91c8788b435..ea3fe740fb2 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalConnection.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalConnection.cs @@ -55,11 +55,14 @@ private static IDbContextOptions CreateOptions() return optionsBuilder.Options; } - public void UseConnection(DbConnection connection) => _connection = connection; + public void UseConnection(DbConnection connection) + => _connection = connection; - public override DbConnection DbConnection => _connection ?? base.DbConnection; + public override DbConnection DbConnection + => _connection ?? base.DbConnection; - public IReadOnlyList DbConnections => _dbConnections; + public IReadOnlyList DbConnections + => _dbConnections; protected override DbConnection CreateDbConnection() { diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalDatabaseCreator.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalDatabaseCreator.cs index 7898056a16a..4449676bcc1 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalDatabaseCreator.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeRelationalDatabaseCreator.cs @@ -10,28 +10,55 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities.FakeProvider { public class FakeRelationalDatabaseCreator : IRelationalDatabaseCreator { - public bool EnsureDeleted() => throw new NotImplementedException(); - - public Task EnsureDeletedAsync(CancellationToken cancellationToken = new CancellationToken()) => - throw new NotImplementedException(); - - public bool EnsureCreated() => throw new NotImplementedException(); - - public Task EnsureCreatedAsync(CancellationToken cancellationToken = new CancellationToken()) => - throw new NotImplementedException(); - - public bool CanConnect() => throw new NotImplementedException(); - public Task CanConnectAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException(); - public bool Exists() => throw new NotImplementedException(); - public Task ExistsAsync(CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); - public bool HasTables() => throw new NotImplementedException(); - public Task HasTablesAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException(); - public void Create() => throw new NotImplementedException(); - public Task CreateAsync(CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); - public void Delete() => throw new NotImplementedException(); - public Task DeleteAsync(CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); - public void CreateTables() => throw new NotImplementedException(); - public Task CreateTablesAsync(CancellationToken cancellationToken = new CancellationToken()) => throw new NotImplementedException(); - public string GenerateCreateScript() => throw new NotImplementedException(); + public bool EnsureDeleted() + => throw new NotImplementedException(); + + public Task EnsureDeletedAsync(CancellationToken cancellationToken = new CancellationToken()) + => throw new NotImplementedException(); + + public bool EnsureCreated() + => throw new NotImplementedException(); + + public Task EnsureCreatedAsync(CancellationToken cancellationToken = new CancellationToken()) + => throw new NotImplementedException(); + + public bool CanConnect() + => throw new NotImplementedException(); + + public Task CanConnectAsync(CancellationToken cancellationToken = default) + => throw new NotImplementedException(); + + public bool Exists() + => throw new NotImplementedException(); + + public Task ExistsAsync(CancellationToken cancellationToken = new CancellationToken()) + => throw new NotImplementedException(); + + public bool HasTables() + => throw new NotImplementedException(); + + public Task HasTablesAsync(CancellationToken cancellationToken = default) + => throw new NotImplementedException(); + + public void Create() + => throw new NotImplementedException(); + + public Task CreateAsync(CancellationToken cancellationToken = new CancellationToken()) + => throw new NotImplementedException(); + + public void Delete() + => throw new NotImplementedException(); + + public Task DeleteAsync(CancellationToken cancellationToken = new CancellationToken()) + => throw new NotImplementedException(); + + public void CreateTables() + => throw new NotImplementedException(); + + public Task CreateTablesAsync(CancellationToken cancellationToken = new CancellationToken()) + => throw new NotImplementedException(); + + public string GenerateCreateScript() + => throw new NotImplementedException(); } } diff --git a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeSqlGenerator.cs b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeSqlGenerator.cs index 4f4de86ca58..9ec9841deb2 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeSqlGenerator.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/FakeProvider/FakeSqlGenerator.cs @@ -15,21 +15,27 @@ public FakeSqlGenerator(UpdateSqlGeneratorDependencies dependencies) } public override ResultSetMapping AppendInsertOperation( - StringBuilder commandStringBuilder, ModificationCommand command, int commandPosition) + StringBuilder commandStringBuilder, + ModificationCommand command, + int commandPosition) { AppendInsertOperationCalls++; return base.AppendInsertOperation(commandStringBuilder, command, commandPosition); } public override ResultSetMapping AppendUpdateOperation( - StringBuilder commandStringBuilder, ModificationCommand command, int commandPosition) + StringBuilder commandStringBuilder, + ModificationCommand command, + int commandPosition) { AppendUpdateOperationCalls++; return base.AppendUpdateOperation(commandStringBuilder, command, commandPosition); } public override ResultSetMapping AppendDeleteOperation( - StringBuilder commandStringBuilder, ModificationCommand command, int commandPosition) + StringBuilder commandStringBuilder, + ModificationCommand command, + int commandPosition) { AppendDeleteOperationCalls++; return base.AppendDeleteOperation(commandStringBuilder, command, commandPosition); @@ -53,7 +59,10 @@ protected override void AppendIdentityWhereCondition(StringBuilder commandString .Append("provider_specific_identity()"); protected override ResultSetMapping AppendSelectAffectedCountCommand( - StringBuilder commandStringBuilder, string name, string schema, int commandPosition) + StringBuilder commandStringBuilder, + string name, + string schema, + int commandPosition) { commandStringBuilder .Append("SELECT provider_specific_rowcount();").Append(Environment.NewLine).Append(Environment.NewLine); diff --git a/test/EFCore.Relational.Tests/TestUtilities/ListDiagnosticSource.cs b/test/EFCore.Relational.Tests/TestUtilities/ListDiagnosticSource.cs index 9f9d4865e33..5f5bd852356 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/ListDiagnosticSource.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/ListDiagnosticSource.cs @@ -19,6 +19,7 @@ public ListDiagnosticSource(List> diagnosticList) public override void Write(string diagnosticName, object parameters) => DiagnosticList?.Add(new Tuple(diagnosticName, parameters)); - public override bool IsEnabled(string diagnosticName) => true; + public override bool IsEnabled(string diagnosticName) + => true; } } diff --git a/test/EFCore.Relational.Tests/TestUtilities/TestRelationalMigrationSqlGenerator.cs b/test/EFCore.Relational.Tests/TestUtilities/TestRelationalMigrationSqlGenerator.cs index 9ed2518d655..5f100480a12 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/TestRelationalMigrationSqlGenerator.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/TestRelationalMigrationSqlGenerator.cs @@ -19,7 +19,10 @@ protected override void Generate(RenameTableOperation operation, IModel model, M } protected override void Generate( - DropIndexOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true) + DropIndexOperation operation, + IModel model, + MigrationCommandListBuilder builder, + bool terminate = true) { } diff --git a/test/EFCore.Relational.Tests/TestUtilities/TestRelationalTypeMappingSource.cs b/test/EFCore.Relational.Tests/TestUtilities/TestRelationalTypeMappingSource.cs index de3ba9c2600..5aeb843d910 100644 --- a/test/EFCore.Relational.Tests/TestUtilities/TestRelationalTypeMappingSource.cs +++ b/test/EFCore.Relational.Tests/TestUtilities/TestRelationalTypeMappingSource.cs @@ -191,7 +191,8 @@ protected override RelationalTypeMapping FindMapping(in RelationalTypeMappingInf var isFixedLength = mappingInfo.IsFixedLength == true; return new ByteArrayTypeMapping( - storeTypeName ?? (isFixedLength ? "just_binary_fixed(" : "just_binary(") + (size == null ? "max" : size.ToString()) + ")", + storeTypeName + ?? (isFixedLength ? "just_binary_fixed(" : "just_binary(") + (size == null ? "max" : size.ToString()) + ")", DbType.Binary, size); } diff --git a/test/EFCore.Relational.Tests/Update/ReaderModificationCommandBatchTest.cs b/test/EFCore.Relational.Tests/Update/ReaderModificationCommandBatchTest.cs index 38ef384d232..ef99384cb82 100644 --- a/test/EFCore.Relational.Tests/Update/ReaderModificationCommandBatchTest.cs +++ b/test/EFCore.Relational.Tests/Update/ReaderModificationCommandBatchTest.cs @@ -11,7 +11,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.EntityFrameworkCore.TestUtilities.FakeProvider; @@ -507,7 +506,7 @@ private class T1 private static IModel BuildModel(bool generateKeyValues, bool computeNonKeyValue) { - var modelBuilder = RelationalTestHelpers.Instance.CreateConventionBuilder(); + var modelBuilder = RelationalTestHelpers.Instance.CreateConventionBuilder(); var entityType = modelBuilder.Entity(); entityType.Property(t => t.Id).HasColumnName("Col1"); @@ -581,15 +580,18 @@ private static ModificationCommandBatchFactoryDependencies CreateDependencies( logger); } - public string CommandText => GetCommandText(); + public string CommandText + => GetCommandText(); public bool ShouldAddCommand { get; set; } - protected override bool CanAddCommand(ModificationCommand modificationCommand) => ShouldAddCommand; + protected override bool CanAddCommand(ModificationCommand modificationCommand) + => ShouldAddCommand; public bool ShouldValidateSql { get; set; } - protected override bool IsCommandTextValid() => ShouldValidateSql; + protected override bool IsCommandTextValid() + => ShouldValidateSql; protected override void UpdateCachedCommandText(int commandIndex) { @@ -597,7 +599,8 @@ protected override void UpdateCachedCommandText(int commandIndex) CachedCommandText.Append("."); } - public void UpdateCachedCommandTextBase(int commandIndex) => base.UpdateCachedCommandText(commandIndex); + public void UpdateCachedCommandTextBase(int commandIndex) + => base.UpdateCachedCommandText(commandIndex); public RawSqlCommand CreateStoreCommandBase() => CreateStoreCommand(); diff --git a/test/EFCore.Relational.Tests/Update/UpdateSqlGeneratorTest.cs b/test/EFCore.Relational.Tests/Update/UpdateSqlGeneratorTest.cs index 3c2a06c13c7..64e5e1e0f7f 100644 --- a/test/EFCore.Relational.Tests/Update/UpdateSqlGeneratorTest.cs +++ b/test/EFCore.Relational.Tests/Update/UpdateSqlGeneratorTest.cs @@ -18,10 +18,13 @@ protected override IUpdateSqlGenerator CreateSqlGenerator() TestServiceFactory.Instance.Create(), TestServiceFactory.Instance.Create()))); - protected override TestHelpers TestHelpers => RelationalTestHelpers.Instance; + protected override TestHelpers TestHelpers + => RelationalTestHelpers.Instance; - protected override string RowsAffected => "provider_specific_rowcount()"; + protected override string RowsAffected + => "provider_specific_rowcount()"; - protected override string Identity => "provider_specific_identity()"; + protected override string Identity + => "provider_specific_identity()"; } } diff --git a/test/EFCore.Relational.Tests/Update/UpdateSqlGeneratorTestBase.cs b/test/EFCore.Relational.Tests/Update/UpdateSqlGeneratorTestBase.cs index db1b77ea237..8fe6bdbd756 100644 --- a/test/EFCore.Relational.Tests/Update/UpdateSqlGeneratorTestBase.cs +++ b/test/EFCore.Relational.Tests/Update/UpdateSqlGeneratorTestBase.cs @@ -25,9 +25,24 @@ public virtual void AppendDeleteOperation_creates_full_delete_command_text() CreateSqlGenerator().AppendDeleteOperation(stringBuilder, command, 0); Assert.Equal( - "DELETE FROM " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + "" + Environment.NewLine + - "WHERE " + OpenDelimiter + "Id" + CloseDelimiter + " = @p0;" + Environment.NewLine + - "SELECT " + RowsAffected + ";" + Environment.NewLine + Environment.NewLine, + "DELETE FROM " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + "" + + Environment.NewLine + + "WHERE " + + OpenDelimiter + + "Id" + + CloseDelimiter + + " = @p0;" + + Environment.NewLine + + "SELECT " + + RowsAffected + + ";" + + Environment.NewLine + + Environment.NewLine, stringBuilder.ToString()); } @@ -40,10 +55,28 @@ public virtual void AppendDeleteOperation_creates_full_delete_command_text_with_ CreateSqlGenerator().AppendDeleteOperation(stringBuilder, command, 0); Assert.Equal( - "DELETE FROM " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + "" + Environment.NewLine + - "WHERE " + OpenDelimiter + "Id" + CloseDelimiter + " = @p0 AND " + OpenDelimiter + "ConcurrencyToken" + CloseDelimiter - + " IS NULL;" + Environment.NewLine + - "SELECT " + RowsAffected + ";" + Environment.NewLine + Environment.NewLine, + "DELETE FROM " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + "" + + Environment.NewLine + + "WHERE " + + OpenDelimiter + + "Id" + + CloseDelimiter + + " = @p0 AND " + + OpenDelimiter + + "ConcurrencyToken" + + CloseDelimiter + + " IS NULL;" + + Environment.NewLine + + "SELECT " + + RowsAffected + + ";" + + Environment.NewLine + + Environment.NewLine, stringBuilder.ToString()); } @@ -62,14 +95,50 @@ protected virtual void AppendInsertOperation_appends_insert_and_select_and_where StringBuilder stringBuilder) { Assert.Equal( - "INSERT INTO " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + " (" + OpenDelimiter + "Name" + CloseDelimiter - + ", " + OpenDelimiter + "Quacks" + CloseDelimiter + ", " + OpenDelimiter + "ConcurrencyToken" + CloseDelimiter + ")" - + Environment.NewLine + - "VALUES (@p0, @p1, @p2);" + Environment.NewLine + - "SELECT " + OpenDelimiter + "Id" + CloseDelimiter + ", " + OpenDelimiter + "Computed" + CloseDelimiter + "" - + Environment.NewLine + - "FROM " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + "" + Environment.NewLine + - "WHERE " + RowsAffected + " = 1 AND " + GetIdentityWhereCondition("Id") + ";" + Environment.NewLine + "INSERT INTO " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + " (" + + OpenDelimiter + + "Name" + + CloseDelimiter + + ", " + + OpenDelimiter + + "Quacks" + + CloseDelimiter + + ", " + + OpenDelimiter + + "ConcurrencyToken" + + CloseDelimiter + + ")" + + Environment.NewLine + + "VALUES (@p0, @p1, @p2);" + + Environment.NewLine + + "SELECT " + + OpenDelimiter + + "Id" + + CloseDelimiter + + ", " + + OpenDelimiter + + "Computed" + + CloseDelimiter + + "" + + Environment.NewLine + + "FROM " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + "" + + Environment.NewLine + + "WHERE " + + RowsAffected + + " = 1 AND " + + GetIdentityWhereCondition("Id") + + ";" + + Environment.NewLine + Environment.NewLine, stringBuilder.ToString()); } @@ -84,10 +153,31 @@ public virtual void CreateSqlGenerator().AppendInsertOperation(stringBuilder, command, 0); Assert.Equal( - "INSERT INTO " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + " (" + - OpenDelimiter + "Id" + CloseDelimiter + ", " + OpenDelimiter + "Name" + CloseDelimiter + ", " + OpenDelimiter + "Quacks" - + CloseDelimiter + ", " + OpenDelimiter + "ConcurrencyToken" + CloseDelimiter + ")" + Environment.NewLine + - "VALUES (@p0, @p1, @p2, @p3);" + Environment.NewLine, + "INSERT INTO " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + " (" + + OpenDelimiter + + "Id" + + CloseDelimiter + + ", " + + OpenDelimiter + + "Name" + + CloseDelimiter + + ", " + + OpenDelimiter + + "Quacks" + + CloseDelimiter + + ", " + + OpenDelimiter + + "ConcurrencyToken" + + CloseDelimiter + + ")" + + Environment.NewLine + + "VALUES (@p0, @p1, @p2, @p3);" + + Environment.NewLine, stringBuilder.ToString()); } @@ -106,14 +196,52 @@ protected virtual void AppendInsertOperation_appends_insert_and_select_store_gen StringBuilder stringBuilder) { Assert.Equal( - "INSERT INTO " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + " (" + OpenDelimiter + "Id" + - CloseDelimiter + ", " + OpenDelimiter + "Name" + CloseDelimiter + ", " + OpenDelimiter + "Quacks" + CloseDelimiter + ", " - + OpenDelimiter + - "ConcurrencyToken" + CloseDelimiter + ")" + Environment.NewLine + - "VALUES (@p0, @p1, @p2, @p3);" + Environment.NewLine + - "SELECT " + OpenDelimiter + "Computed" + CloseDelimiter + "" + Environment.NewLine + - "FROM " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + "" + Environment.NewLine + - "WHERE " + RowsAffected + " = 1 AND " + OpenDelimiter + "Id" + CloseDelimiter + " = @p0;" + Environment.NewLine + "INSERT INTO " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + " (" + + OpenDelimiter + + "Id" + + CloseDelimiter + + ", " + + OpenDelimiter + + "Name" + + CloseDelimiter + + ", " + + OpenDelimiter + + "Quacks" + + CloseDelimiter + + ", " + + OpenDelimiter + + "ConcurrencyToken" + + CloseDelimiter + + ")" + + Environment.NewLine + + "VALUES (@p0, @p1, @p2, @p3);" + + Environment.NewLine + + "SELECT " + + OpenDelimiter + + "Computed" + + CloseDelimiter + + "" + + Environment.NewLine + + "FROM " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + "" + + Environment.NewLine + + "WHERE " + + RowsAffected + + " = 1 AND " + + OpenDelimiter + + "Id" + + CloseDelimiter + + " = @p0;" + + Environment.NewLine + Environment.NewLine, stringBuilder.ToString()); } @@ -132,13 +260,46 @@ public virtual void AppendInsertOperation_appends_insert_and_select_for_only_ide protected virtual void AppendInsertOperation_appends_insert_and_select_for_only_identity_verification(StringBuilder stringBuilder) { Assert.Equal( - "INSERT INTO " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + " (" + OpenDelimiter + "Name" + - CloseDelimiter + ", " + OpenDelimiter + "Quacks" + CloseDelimiter + ", " + OpenDelimiter + "ConcurrencyToken" - + CloseDelimiter + ")" + Environment.NewLine + - "VALUES (@p0, @p1, @p2);" + Environment.NewLine + - "SELECT " + OpenDelimiter + "Id" + CloseDelimiter + "" + Environment.NewLine + - "FROM " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + "" + Environment.NewLine + - "WHERE " + RowsAffected + " = 1 AND " + GetIdentityWhereCondition("Id") + ";" + Environment.NewLine + "INSERT INTO " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + " (" + + OpenDelimiter + + "Name" + + CloseDelimiter + + ", " + + OpenDelimiter + + "Quacks" + + CloseDelimiter + + ", " + + OpenDelimiter + + "ConcurrencyToken" + + CloseDelimiter + + ")" + + Environment.NewLine + + "VALUES (@p0, @p1, @p2);" + + Environment.NewLine + + "SELECT " + + OpenDelimiter + + "Id" + + CloseDelimiter + + "" + + Environment.NewLine + + "FROM " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + "" + + Environment.NewLine + + "WHERE " + + RowsAffected + + " = 1 AND " + + GetIdentityWhereCondition("Id") + + ";" + + Environment.NewLine + Environment.NewLine, stringBuilder.ToString()); } @@ -158,12 +319,38 @@ protected virtual void AppendInsertOperation_appends_insert_and_select_for_all_s StringBuilder stringBuilder) { Assert.Equal( - "INSERT INTO " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + "" + Environment.NewLine + - "DEFAULT VALUES;" + Environment.NewLine + - "SELECT " + OpenDelimiter + "Id" + CloseDelimiter + ", " + OpenDelimiter + "Computed" + CloseDelimiter + "" - + Environment.NewLine + - "FROM " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + "" + Environment.NewLine + - "WHERE " + RowsAffected + " = 1 AND " + GetIdentityWhereCondition("Id") + ";" + Environment.NewLine + "INSERT INTO " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + "" + + Environment.NewLine + + "DEFAULT VALUES;" + + Environment.NewLine + + "SELECT " + + OpenDelimiter + + "Id" + + CloseDelimiter + + ", " + + OpenDelimiter + + "Computed" + + CloseDelimiter + + "" + + Environment.NewLine + + "FROM " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + "" + + Environment.NewLine + + "WHERE " + + RowsAffected + + " = 1 AND " + + GetIdentityWhereCondition("Id") + + ";" + + Environment.NewLine + Environment.NewLine, stringBuilder.ToString()); } @@ -183,11 +370,34 @@ protected virtual void AppendInsertOperation_appends_insert_and_select_for_only_ StringBuilder stringBuilder) { Assert.Equal( - "INSERT INTO " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + "" + Environment.NewLine + - "DEFAULT VALUES;" + Environment.NewLine + - "SELECT " + OpenDelimiter + "Id" + CloseDelimiter + "" + Environment.NewLine + - "FROM " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + "" + Environment.NewLine + - "WHERE " + RowsAffected + " = 1 AND " + GetIdentityWhereCondition("Id") + ";" + Environment.NewLine + "INSERT INTO " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + "" + + Environment.NewLine + + "DEFAULT VALUES;" + + Environment.NewLine + + "SELECT " + + OpenDelimiter + + "Id" + + CloseDelimiter + + "" + + Environment.NewLine + + "FROM " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + "" + + Environment.NewLine + + "WHERE " + + RowsAffected + + " = 1 AND " + + GetIdentityWhereCondition("Id") + + ";" + + Environment.NewLine + Environment.NewLine, stringBuilder.ToString()); } @@ -207,14 +417,56 @@ protected virtual void AppendUpdateOperation_appends_update_and_select_if_store_ StringBuilder stringBuilder) { Assert.Equal( - "UPDATE " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + " SET " + OpenDelimiter + "Name" + CloseDelimiter + - " = @p0, " + OpenDelimiter + "Quacks" + CloseDelimiter + " = @p1, " + OpenDelimiter + "ConcurrencyToken" + CloseDelimiter - + " = @p2" + Environment.NewLine + - "WHERE " + OpenDelimiter + "Id" + CloseDelimiter + " = @p3 AND " + OpenDelimiter + "ConcurrencyToken" + CloseDelimiter - + " IS NULL;" + Environment.NewLine + - "SELECT " + OpenDelimiter + "Computed" + CloseDelimiter + "" + Environment.NewLine + - "FROM " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + "" + Environment.NewLine + - "WHERE " + RowsAffected + " = 1 AND " + OpenDelimiter + "Id" + CloseDelimiter + " = @p3;" + Environment.NewLine + "UPDATE " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + " SET " + + OpenDelimiter + + "Name" + + CloseDelimiter + + " = @p0, " + + OpenDelimiter + + "Quacks" + + CloseDelimiter + + " = @p1, " + + OpenDelimiter + + "ConcurrencyToken" + + CloseDelimiter + + " = @p2" + + Environment.NewLine + + "WHERE " + + OpenDelimiter + + "Id" + + CloseDelimiter + + " = @p3 AND " + + OpenDelimiter + + "ConcurrencyToken" + + CloseDelimiter + + " IS NULL;" + + Environment.NewLine + + "SELECT " + + OpenDelimiter + + "Computed" + + CloseDelimiter + + "" + + Environment.NewLine + + "FROM " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + "" + + Environment.NewLine + + "WHERE " + + RowsAffected + + " = 1 AND " + + OpenDelimiter + + "Id" + + CloseDelimiter + + " = @p3;" + + Environment.NewLine + Environment.NewLine, stringBuilder.ToString()); } @@ -228,11 +480,36 @@ public virtual void AppendUpdateOperation_appends_update_and_select_rowcount_if_ CreateSqlGenerator().AppendUpdateOperation(stringBuilder, command, 0); Assert.Equal( - "UPDATE " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + " SET " + - OpenDelimiter + "Name" + CloseDelimiter + " = @p0, " + OpenDelimiter + "Quacks" + CloseDelimiter + " = @p1, " + - OpenDelimiter + "ConcurrencyToken" + CloseDelimiter + " = @p2" + Environment.NewLine + - "WHERE " + OpenDelimiter + "Id" + CloseDelimiter + " = @p3;" + Environment.NewLine + - "SELECT " + RowsAffected + ";" + Environment.NewLine + Environment.NewLine, + "UPDATE " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + " SET " + + OpenDelimiter + + "Name" + + CloseDelimiter + + " = @p0, " + + OpenDelimiter + + "Quacks" + + CloseDelimiter + + " = @p1, " + + OpenDelimiter + + "ConcurrencyToken" + + CloseDelimiter + + " = @p2" + + Environment.NewLine + + "WHERE " + + OpenDelimiter + + "Id" + + CloseDelimiter + + " = @p3;" + + Environment.NewLine + + "SELECT " + + RowsAffected + + ";" + + Environment.NewLine + + Environment.NewLine, stringBuilder.ToString()); } @@ -245,12 +522,40 @@ public virtual void AppendUpdateOperation_appends_where_for_concurrency_token() CreateSqlGenerator().AppendUpdateOperation(stringBuilder, command, 0); Assert.Equal( - "UPDATE " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + " SET " + - OpenDelimiter + "Name" + CloseDelimiter + " = @p0, " + OpenDelimiter + "Quacks" + CloseDelimiter + " = @p1, " + - OpenDelimiter + "ConcurrencyToken" + CloseDelimiter + " = @p2" + Environment.NewLine + - "WHERE " + OpenDelimiter + "Id" + CloseDelimiter + " = @p3 AND " + OpenDelimiter + "ConcurrencyToken" + CloseDelimiter - + " IS NULL;" + Environment.NewLine + - "SELECT " + RowsAffected + ";" + Environment.NewLine + Environment.NewLine, + "UPDATE " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + " SET " + + OpenDelimiter + + "Name" + + CloseDelimiter + + " = @p0, " + + OpenDelimiter + + "Quacks" + + CloseDelimiter + + " = @p1, " + + OpenDelimiter + + "ConcurrencyToken" + + CloseDelimiter + + " = @p2" + + Environment.NewLine + + "WHERE " + + OpenDelimiter + + "Id" + + CloseDelimiter + + " = @p3 AND " + + OpenDelimiter + + "ConcurrencyToken" + + CloseDelimiter + + " IS NULL;" + + Environment.NewLine + + "SELECT " + + RowsAffected + + ";" + + Environment.NewLine + + Environment.NewLine, stringBuilder.ToString()); } @@ -268,13 +573,52 @@ public virtual void AppendUpdateOperation_appends_select_for_computed_property() protected virtual void AppendUpdateOperation_appends_select_for_computed_property_verification(StringBuilder stringBuilder) { Assert.Equal( - "UPDATE " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + " SET " + - OpenDelimiter + "Name" + CloseDelimiter + " = @p0, " + OpenDelimiter + "Quacks" + CloseDelimiter + " = @p1, " + - OpenDelimiter + "ConcurrencyToken" + CloseDelimiter + " = @p2" + Environment.NewLine + - "WHERE " + OpenDelimiter + "Id" + CloseDelimiter + " = @p3;" + Environment.NewLine + - "SELECT " + OpenDelimiter + "Computed" + CloseDelimiter + "" + Environment.NewLine + - "FROM " + SchemaPrefix + OpenDelimiter + "Ducks" + CloseDelimiter + "" + Environment.NewLine + - "WHERE " + RowsAffected + " = 1 AND " + OpenDelimiter + "Id" + CloseDelimiter + " = @p3;" + Environment.NewLine + "UPDATE " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + " SET " + + OpenDelimiter + + "Name" + + CloseDelimiter + + " = @p0, " + + OpenDelimiter + + "Quacks" + + CloseDelimiter + + " = @p1, " + + OpenDelimiter + + "ConcurrencyToken" + + CloseDelimiter + + " = @p2" + + Environment.NewLine + + "WHERE " + + OpenDelimiter + + "Id" + + CloseDelimiter + + " = @p3;" + + Environment.NewLine + + "SELECT " + + OpenDelimiter + + "Computed" + + CloseDelimiter + + "" + + Environment.NewLine + + "FROM " + + SchemaPrefix + + OpenDelimiter + + "Ducks" + + CloseDelimiter + + "" + + Environment.NewLine + + "WHERE " + + RowsAffected + + " = 1 AND " + + OpenDelimiter + + "Id" + + CloseDelimiter + + " = @p3;" + + Environment.NewLine + Environment.NewLine, stringBuilder.ToString()); } @@ -303,16 +647,20 @@ public virtual void GenerateNextSequenceValueOperation_correctly_handles_schemas protected abstract string RowsAffected { get; } - protected virtual string Identity => throw new NotImplementedException(); + protected virtual string Identity + => throw new NotImplementedException(); - protected virtual string OpenDelimiter => "\""; + protected virtual string OpenDelimiter + => "\""; - protected virtual string CloseDelimiter => "\""; + protected virtual string CloseDelimiter + => "\""; - protected virtual string Schema => "dbo"; + protected virtual string Schema + => "dbo"; - protected virtual string SchemaPrefix => - string.IsNullOrEmpty(Schema) ? string.Empty : OpenDelimiter + Schema + CloseDelimiter + "."; + protected virtual string SchemaPrefix + => string.IsNullOrEmpty(Schema) ? string.Empty : OpenDelimiter + Schema + CloseDelimiter + "."; protected virtual string GetIdentityWhereCondition(string columnName) => OpenDelimiter + columnName + CloseDelimiter + " = " + Identity; diff --git a/test/EFCore.Specification.Tests/BuiltInDataTypesTestBase.cs b/test/EFCore.Specification.Tests/BuiltInDataTypesTestBase.cs index f7d284e2427..13ed70e687f 100644 --- a/test/EFCore.Specification.Tests/BuiltInDataTypesTestBase.cs +++ b/test/EFCore.Specification.Tests/BuiltInDataTypesTestBase.cs @@ -19,11 +19,13 @@ namespace Microsoft.EntityFrameworkCore public abstract class BuiltInDataTypesTestBase : IClassFixture where TFixture : BuiltInDataTypesTestBase.BuiltInDataTypesFixtureBase, new() { - protected BuiltInDataTypesTestBase(TFixture fixture) => Fixture = fixture; + protected BuiltInDataTypesTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } - protected DbContext CreateContext() => Fixture.CreateContext(); + protected DbContext CreateContext() + => Fixture.CreateContext(); [ConditionalTheory] [InlineData(false)] @@ -2026,43 +2028,45 @@ public virtual void Object_to_string_conversion() var expected = context.Set() .Where(e => e.Id == 13) .AsEnumerable() - .Select(b => new - { - Sbyte = b.TestSignedByte.ToString(), - Byte = b.TestByte.ToString(), - Short = b.TestInt16.ToString(), - Ushort = b.TestUnsignedInt16.ToString(), - Int = b.TestInt32.ToString(), - Uint = b.TestUnsignedInt32.ToString(), - Long = b.TestInt64.ToString(), - Ulong = b.TestUnsignedInt64.ToString(), - Decimal = b.TestDecimal.ToString(), - Char = b.TestCharacter.ToString() - }) + .Select( + b => new + { + Sbyte = b.TestSignedByte.ToString(), + Byte = b.TestByte.ToString(), + Short = b.TestInt16.ToString(), + Ushort = b.TestUnsignedInt16.ToString(), + Int = b.TestInt32.ToString(), + Uint = b.TestUnsignedInt32.ToString(), + Long = b.TestInt64.ToString(), + Ulong = b.TestUnsignedInt64.ToString(), + Decimal = b.TestDecimal.ToString(), + Char = b.TestCharacter.ToString() + }) .First(); Fixture.ListLoggerFactory.Clear(); var query = context.Set() .Where(e => e.Id == 13) - .Select(b => new - { - Sbyte = b.TestSignedByte.ToString(), - Byte = b.TestByte.ToString(), - Short = b.TestInt16.ToString(), - Ushort = b.TestUnsignedInt16.ToString(), - Int = b.TestInt32.ToString(), - Uint = b.TestUnsignedInt32.ToString(), - Long = b.TestInt64.ToString(), - Ulong = b.TestUnsignedInt64.ToString(), - Float = b.TestSingle.ToString(), - Double = b.TestDouble.ToString(), - Decimal = b.TestDecimal.ToString(), - Char = b.TestCharacter.ToString(), - DateTime = b.TestDateTime.ToString(), - DateTimeOffset = b.TestDateTimeOffset.ToString(), - TimeSpan = b.TestTimeSpan.ToString() - }) + .Select( + b => new + { + Sbyte = b.TestSignedByte.ToString(), + Byte = b.TestByte.ToString(), + Short = b.TestInt16.ToString(), + Ushort = b.TestUnsignedInt16.ToString(), + Int = b.TestInt32.ToString(), + Uint = b.TestUnsignedInt32.ToString(), + Long = b.TestInt64.ToString(), + Ulong = b.TestUnsignedInt64.ToString(), + Float = b.TestSingle.ToString(), + Double = b.TestDouble.ToString(), + Decimal = b.TestDecimal.ToString(), + Char = b.TestCharacter.ToString(), + DateTime = b.TestDateTime.ToString(), + DateTimeOffset = b.TestDateTimeOffset.ToString(), + TimeSpan = b.TestTimeSpan.ToString() + }) .ToList(); var actual = Assert.Single(query); @@ -2098,7 +2102,8 @@ public abstract class BuiltInDataTypesFixtureBase : SharedStoreFixtureBase 9000; + public virtual int LongStringLength + => 9000; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { @@ -2353,15 +2358,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con modelBuilder.Entity() .HasData( - new DateTimeEnclosure - { - Id = 1, - DateTimeOffset = new DateTimeOffset(2020, 3, 12, 1, 1, 1, new TimeSpan(3, 0, 0)) - }, - new DateTimeEnclosure - { - Id = 2 - }); + new DateTimeEnclosure { Id = 1, DateTimeOffset = new DateTimeOffset(2020, 3, 12, 1, 1, 1, new TimeSpan(3, 0, 0)) }, + new DateTimeEnclosure { Id = 2 }); } protected static void MakeRequired(ModelBuilder modelBuilder) @@ -2375,7 +2373,8 @@ protected static void MakeRequired(ModelBuilder modelBuilder) public abstract bool StrictEquality { get; } - public virtual int IntegerPrecision => 19; + public virtual int IntegerPrecision + => 19; public abstract bool SupportsAnsi { get; } diff --git a/test/EFCore.Specification.Tests/CompositeKeyEndToEndTestBase.cs b/test/EFCore.Specification.Tests/CompositeKeyEndToEndTestBase.cs index 4ce672640f9..890e433748c 100644 --- a/test/EFCore.Specification.Tests/CompositeKeyEndToEndTestBase.cs +++ b/test/EFCore.Specification.Tests/CompositeKeyEndToEndTestBase.cs @@ -14,7 +14,8 @@ namespace Microsoft.EntityFrameworkCore public abstract class CompositeKeyEndToEndTestBase : IClassFixture where TFixture : CompositeKeyEndToEndTestBase.CompositeKeyEndToEndFixtureBase { - protected CompositeKeyEndToEndTestBase(TFixture fixture) => Fixture = fixture; + protected CompositeKeyEndToEndTestBase(TFixture fixture) + => Fixture = fixture; private TFixture Fixture { get; } @@ -185,7 +186,8 @@ public virtual async Task Only_one_part_of_a_composite_key_needs_to_vary_for_uni } } - protected BronieContext CreateContext() => (BronieContext)Fixture.CreateContext(); + protected BronieContext CreateContext() + => (BronieContext)Fixture.CreateContext(); public abstract class CompositeKeyEndToEndFixtureBase : SharedStoreFixtureBase { diff --git a/test/EFCore.Specification.Tests/ConcurrencyDetectorTestBase.cs b/test/EFCore.Specification.Tests/ConcurrencyDetectorTestBase.cs index f768d496ffe..7526d439560 100644 --- a/test/EFCore.Specification.Tests/ConcurrencyDetectorTestBase.cs +++ b/test/EFCore.Specification.Tests/ConcurrencyDetectorTestBase.cs @@ -18,7 +18,8 @@ namespace Microsoft.EntityFrameworkCore public abstract class ConcurrencyDetectorTestBase : IClassFixture where TFixture : NorthwindQueryFixtureBase, new() { - protected ConcurrencyDetectorTestBase(TFixture fixture) => Fixture = fixture; + protected ConcurrencyDetectorTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -177,6 +178,7 @@ protected virtual async Task ConcurrencyDetectorTest(Func Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); } } diff --git a/test/EFCore.Specification.Tests/ConferencePlannerTestBase.cs b/test/EFCore.Specification.Tests/ConferencePlannerTestBase.cs index d03ea9dd182..ea5038c14f0 100644 --- a/test/EFCore.Specification.Tests/ConferencePlannerTestBase.cs +++ b/test/EFCore.Specification.Tests/ConferencePlannerTestBase.cs @@ -368,7 +368,9 @@ public async Task RemoveSession(string username, int sessionId) [InlineData("Scott", 1, 0)] [InlineData("C#", 3, 3)] public virtual async Task SearchController_Search( - string searchTerm, int totalCount, int sessionCount) + string searchTerm, + int totalCount, + int sessionCount) { await ExecuteWithStrategyInTransactionAsync( async context => @@ -757,7 +759,8 @@ public async Task GetSpeaker(int id) protected TFixture Fixture { get; } - protected ApplicationDbContext CreateContext() => Fixture.CreateContext(); + protected ApplicationDbContext CreateContext() + => Fixture.CreateContext(); protected virtual Task ExecuteWithStrategyInTransactionAsync( Func testOperation, @@ -780,7 +783,8 @@ public abstract class ConferencePlannerFixtureBase : SharedStoreFixtureBase false; + protected override bool UsePooling + => false; protected override void Seed(ApplicationDbContext context) { diff --git a/test/EFCore.Specification.Tests/ConvertToProviderTypesTestBase.cs b/test/EFCore.Specification.Tests/ConvertToProviderTypesTestBase.cs index c17d410873b..72564c85460 100644 --- a/test/EFCore.Specification.Tests/ConvertToProviderTypesTestBase.cs +++ b/test/EFCore.Specification.Tests/ConvertToProviderTypesTestBase.cs @@ -34,7 +34,7 @@ public virtual void Object_equals_method_over_enum_works() Assert.Empty(query); } - public override void Object_to_string_conversion() {} + public override void Object_to_string_conversion() { } public abstract class ConvertToProviderTypesFixtureBase : BuiltInDataTypesFixtureBase { diff --git a/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs b/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs index 590964176fa..ca7f16a0c3c 100644 --- a/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs +++ b/test/EFCore.Specification.Tests/CustomConvertersTestBase.cs @@ -121,8 +121,7 @@ public virtual void Can_query_and_update_with_nullable_converter_on_primary_key( var principal = context.Add( new NullablePrincipal { - Id = 1, - Dependents = new List { new NonNullableDependent { Id = 1 } } + Id = 1, Dependents = new List { new NonNullableDependent { Id = 1 } } }) .Entity; @@ -210,11 +209,15 @@ public User(Email email) protected class Email { private readonly string _value; - private Email(string value) => _value = value; - public static Email Create(string value) => new Email(value); + private Email(string value) + => _value = value; - public static implicit operator string(Email email) => email._value; + public static Email Create(string value) + => new Email(value); + + public static implicit operator string(Email email) + => email._value; } [ConditionalFact] @@ -246,7 +249,9 @@ protected class Load protected struct Fuel { - public Fuel(double volume) => Volume = volume; + public Fuel(double volume) + => Volume = volume; + public double Volume { get; } } @@ -364,7 +369,8 @@ public static OrderId Parse(string stringValue) return new OrderId(stringValue); } - public static explicit operator string(OrderId orderId) => orderId.StringValue; + public static explicit operator string(OrderId orderId) + => orderId.StringValue; } [ConditionalTheory] @@ -486,7 +492,7 @@ public virtual void Where_bool_gets_converted_to_equality_when_value_conversion_ public virtual void Where_bool_with_value_conversion_inside_comparison_doesnt_get_converted_twice() { using var context = CreateContext(); - var query1 = context.Set().Where(b => b.IsVisible == true).ToList(); + var query1 = context.Set().Where(b => b.IsVisible).ToList(); var query2 = context.Set().Where(b => b.IsVisible != true).ToList(); var result1 = Assert.Single(query1); @@ -619,7 +625,7 @@ public virtual void Collection_property_as_scalar_Any() Assert.Contains( @"Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.", Assert.Throws( - () => context.Set().Where(e => e.Tags.Any()).ToList()) + () => context.Set().Where(e => e.Tags.Any()).ToList()) .Message.Replace("\r", "").Replace("\n", "")); } @@ -631,7 +637,7 @@ public virtual void Collection_property_as_scalar_Count_member() CoreStrings.TranslationFailed( @"DbSet() .Where(c => c.Tags.Count == 2)"), Assert.Throws( - () => context.Set().Where(e => e.Tags.Count == 2).ToList()) + () => context.Set().Where(e => e.Tags.Count == 2).ToList()) .Message.Replace("\r", "").Replace("\n", "")); } @@ -649,7 +655,7 @@ public virtual void Collection_enum_as_string_Contains() Assert.Contains( @"Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.", Assert.Throws( - () => context.Set().Where(e => e.Roles.Contains(sameRole)).ToList()) + () => context.Set().Where(e => e.Roles.Contains(sameRole)).ToList()) .Message.Replace("\r", "").Replace("\n", "")); } @@ -665,7 +671,7 @@ protected enum Roles Seller } - public override void Object_to_string_conversion() {} + public override void Object_to_string_conversion() { } [ConditionalFact] public virtual void Optional_owned_with_converter_reading_non_nullable_column() @@ -687,6 +693,7 @@ protected class OwnedWithConverter { public int Value { get; set; } } + public abstract class CustomConvertersFixtureBase : BuiltInDataTypesFixtureBase { protected override string StoreName { get; } = "CustomConverters"; @@ -1127,25 +1134,27 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con s => s.Split(',', StringSplitOptions.None).ToList(), new ValueComparer>(favorStructuralComparisons: true)); - b.HasData(new CollectionScalar - { - Id = 1, - Tags = new List { "A", "B", "C" } - }); + b.HasData( + new CollectionScalar + { + Id = 1, + Tags = new List + { + "A", + "B", + "C" + } + }); }); modelBuilder.Entity( b => { b.Property(e => e.Roles).HasConversion( - new RolesToStringConveter(), - new ValueComparer>(favorStructuralComparisons: true)); + new RolesToStringConveter(), + new ValueComparer>(favorStructuralComparisons: true)); - b.HasData(new CollectionEnum - { - Id = 1, - Roles = new List { Roles.Seller } - }); + b.HasData(new CollectionEnum { Id = 1, Roles = new List { Roles.Seller } }); }); modelBuilder.Entity( @@ -1214,11 +1223,13 @@ public UrlSchemeRemover() private class RolesToStringConveter : ValueConverter, string> { public RolesToStringConveter() - : base(v => string.Join(";", v.Select(f => f.ToString())), - v => v.Length > 0 + : base( + v => string.Join(";", v.Select(f => f.ToString())), + v => v.Length > 0 ? v.Split(new[] { ';' }).Select(f => (Roles)Enum.Parse(typeof(Roles), f)).ToList() - : new List()) - { } + : new List()) + { + } } } } diff --git a/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs b/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs index 3c3c1608671..8f7f95f598f 100644 --- a/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs +++ b/test/EFCore.Specification.Tests/DataAnnotationTestBase.cs @@ -33,7 +33,8 @@ protected DataAnnotationTestBase(TFixture fixture) protected TFixture Fixture { get; } - protected DbContext CreateContext() => Fixture.CreateContext(); + protected DbContext CreateContext() + => Fixture.CreateContext(); protected virtual void ExecuteWithStrategyInTransaction(Action testOperation) => TestHelpers.ExecuteWithStrategyInTransaction(CreateContext, UseTransaction, testOperation); @@ -45,7 +46,8 @@ protected virtual void UseTransaction(DatabaseFacade facade, IDbContextTransacti public virtual ModelBuilder CreateModelBuilder() { var context = CreateContext(); - return new ModelBuilder(context.GetService().CreateConventionSet(), + return new ModelBuilder( + context.GetService().CreateConventionSet(), context.GetService()); } diff --git a/test/EFCore.Specification.Tests/DatabindingTestBase.cs b/test/EFCore.Specification.Tests/DatabindingTestBase.cs index a6d7d17571c..f8beeac7c06 100644 --- a/test/EFCore.Specification.Tests/DatabindingTestBase.cs +++ b/test/EFCore.Specification.Tests/DatabindingTestBase.cs @@ -15,7 +15,8 @@ namespace Microsoft.EntityFrameworkCore public abstract class DatabindingTestBase : IClassFixture where TFixture : F1FixtureBase, new() { - protected DatabindingTestBase(TFixture fixture) => Fixture = fixture; + protected DatabindingTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } diff --git a/test/EFCore.Specification.Tests/F1FixtureBase.cs b/test/EFCore.Specification.Tests/F1FixtureBase.cs index 4b60010a23a..c2e95c3cfd1 100644 --- a/test/EFCore.Specification.Tests/F1FixtureBase.cs +++ b/test/EFCore.Specification.Tests/F1FixtureBase.cs @@ -12,7 +12,8 @@ public abstract class F1FixtureBase : SharedStoreFixtureBase { protected override string StoreName { get; } = "F1Test"; - protected override bool UsePooling => true; + protected override bool UsePooling + => true; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder) @@ -36,7 +37,8 @@ private IModel CreateModelExternal() public abstract TestHelpers TestHelpers { get; } - public ModelBuilder CreateModelBuilder() => TestHelpers.CreateConventionBuilder(); + public ModelBuilder CreateModelBuilder() + => TestHelpers.CreateConventionBuilder(); protected virtual void BuildModelExternal(ModelBuilder modelBuilder) { @@ -90,6 +92,7 @@ protected virtual void BuildModelExternal(ModelBuilder modelBuilder) .HasKey(ts => new { ts.SponsorId, ts.TeamId }); } - protected override void Seed(F1Context context) => F1Context.Seed(context); + protected override void Seed(F1Context context) + => F1Context.Seed(context); } } diff --git a/test/EFCore.Specification.Tests/FieldMappingTestBase.cs b/test/EFCore.Specification.Tests/FieldMappingTestBase.cs index 11f804408ea..0590db820b7 100644 --- a/test/EFCore.Specification.Tests/FieldMappingTestBase.cs +++ b/test/EFCore.Specification.Tests/FieldMappingTestBase.cs @@ -8,7 +8,6 @@ using System.Linq; using System.Threading; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; @@ -22,7 +21,8 @@ namespace Microsoft.EntityFrameworkCore public abstract class FieldMappingTestBase : IClassFixture where TFixture : FieldMappingTestBase.FieldMappingFixtureBase, new() { - protected FieldMappingTestBase(TFixture fixture) => Fixture = fixture; + protected FieldMappingTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -174,7 +174,12 @@ public virtual void Can_define_a_backing_field_for_a_navigation_and_query_and_up using (var context = CreateContext()) { var principal = context.Set().OrderBy(e => e.Id).First(); - var dependent1 = new NavDependent { Id = 1, Name = "FirstName", OneToOneFieldNavPrincipal = principal }; + var dependent1 = new NavDependent + { + Id = 1, + Name = "FirstName", + OneToOneFieldNavPrincipal = principal + }; context.Set().Add(dependent1); context.SaveChanges(); @@ -184,7 +189,12 @@ public virtual void Can_define_a_backing_field_for_a_navigation_and_query_and_up Assert.Equal("FirstName", dependentName); // use the backing field directly - var dependent2 = new NavDependent { Id = 2, Name = "SecondName", OneToOneFieldNavPrincipal = principal }; + var dependent2 = new NavDependent + { + Id = 2, + Name = "SecondName", + OneToOneFieldNavPrincipal = principal + }; principal._unconventionalDependent = dependent2; context.SaveChanges(); @@ -1297,11 +1307,14 @@ protected class BlogReadOnly : IBlogAccessor private ObservableCollection _posts; [DatabaseGenerated(DatabaseGeneratedOption.None)] - public int Id => _id; + public int Id + => _id; - public string Title => _title; + public string Title + => _title; - public IEnumerable Posts => _posts; + public IEnumerable Posts + => _posts; int IBlogAccessor.AccessId { @@ -1330,13 +1343,17 @@ protected class PostReadOnly : IPostAccessor private BlogReadOnly _blog; [DatabaseGenerated(DatabaseGeneratedOption.None)] - public int Id => _id; + public int Id + => _id; - public string Title => _title; + public string Title + => _title; - public int BlogId => _blogId; + public int BlogId + => _blogId; - public BlogReadOnly Blog => _blog; + public BlogReadOnly Blog + => _blog; int IPostAccessor.AccessId { @@ -1370,11 +1387,14 @@ protected class BlogWithReadOnlyCollection : IBlogAccessor private ICollection _posts; [DatabaseGenerated(DatabaseGeneratedOption.None)] - public int Id => _id; + public int Id + => _id; - public string Title => _title; + public string Title + => _title; - public IReadOnlyCollection Posts => (IReadOnlyCollection)_posts; + public IReadOnlyCollection Posts + => (IReadOnlyCollection)_posts; int IBlogAccessor.AccessId { @@ -1403,13 +1423,17 @@ protected class PostWithReadOnlyCollection : IPostAccessor private BlogWithReadOnlyCollection _blog; [DatabaseGenerated(DatabaseGeneratedOption.None)] - public int Id => _id; + public int Id + => _id; - public string Title => _title; + public string Title + => _title; - public int BlogId => _blogId; + public int BlogId + => _blogId; - public BlogWithReadOnlyCollection Blog => _blog; + public BlogWithReadOnlyCollection Blog + => _blog; int IPostAccessor.AccessId { @@ -1443,11 +1467,14 @@ protected class BlogReadOnlyExplicit : IBlogAccessor private Collection _myposts; [DatabaseGenerated(DatabaseGeneratedOption.None)] - public int Id => _myid; + public int Id + => _myid; - public string Title => _mytitle; + public string Title + => _mytitle; - public IEnumerable Posts => _myposts; + public IEnumerable Posts + => _myposts; int IBlogAccessor.AccessId { @@ -1476,13 +1503,17 @@ protected class PostReadOnlyExplicit : IPostAccessor private BlogReadOnlyExplicit _myblog; [DatabaseGenerated(DatabaseGeneratedOption.None)] - public int Id => _myid; + public int Id + => _myid; - public string Title => _mytitle; + public string Title + => _mytitle; - public int BlogId => _myblogId; + public int BlogId + => _myblogId; - public BlogReadOnlyExplicit Blog => _myblog; + public BlogReadOnlyExplicit Blog + => _myblog; int IPostAccessor.AccessId { @@ -1931,9 +1962,11 @@ protected class OneToOneFieldNavPrincipal { [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } + public string Name { get; set; } public NavDependent _unconventionalDependent; // won't be picked up by convention + public NavDependent Dependent { get => throw new NotImplementedException("Invalid attempt to access Dependent getter"); @@ -1945,12 +1978,14 @@ protected class NavDependent { [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } + public string Name { get; set; } public OneToOneFieldNavPrincipal OneToOneFieldNavPrincipal { get; set; } } - protected DbContext CreateContext() => Fixture.CreateContext(); + protected DbContext CreateContext() + => Fixture.CreateContext(); public abstract class FieldMappingFixtureBase : SharedStoreFixtureBase { @@ -2152,7 +2187,9 @@ protected override void Seed(PoolableDbContext context) context.Add(CreateBlogAndPosts(new ObservableCollection())); context.AddRange(CreatePostsAndBlog()); - context.Add(CreateBlogAndPosts(new ObservableCollection())); + context.Add( + CreateBlogAndPosts( + new ObservableCollection())); context.AddRange(CreatePostsAndBlog()); context.Add(CreateBlogAndPosts(new Collection())); diff --git a/test/EFCore.Specification.Tests/FindTestBase.cs b/test/EFCore.Specification.Tests/FindTestBase.cs index 4b233bb186e..1ddcbf0ee56 100644 --- a/test/EFCore.Specification.Tests/FindTestBase.cs +++ b/test/EFCore.Specification.Tests/FindTestBase.cs @@ -14,7 +14,8 @@ namespace Microsoft.EntityFrameworkCore public abstract class FindTestBase : IClassFixture where TFixture : FindTestBase.FindFixtureBase { - protected FindTestBase(TFixture fixture) => Fixture = fixture; + protected FindTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -627,7 +628,8 @@ protected class ShadowKey public string Foo { get; set; } } - protected DbContext CreateContext() => Fixture.CreateContext(); + protected DbContext CreateContext() + => Fixture.CreateContext(); public abstract class FindFixtureBase : SharedStoreFixtureBase { diff --git a/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBase.cs b/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBase.cs index 4e4de902207..69c9399f743 100644 --- a/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBase.cs +++ b/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBase.cs @@ -22,17 +22,22 @@ namespace Microsoft.EntityFrameworkCore { public abstract partial class GraphUpdatesTestBase : IClassFixture - where TFixture : GraphUpdatesTestBase.GraphUpdatesFixtureBase, new() + where TFixture : GraphUpdatesTestBase.GraphUpdatesFixtureBase, new() { - protected GraphUpdatesTestBase(TFixture fixture) => Fixture = fixture; + protected GraphUpdatesTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } public abstract class GraphUpdatesFixtureBase : SharedStoreFixtureBase { public readonly Guid RootAK = Guid.NewGuid(); - public virtual bool ForceClientNoAction => false; - public virtual bool NoStoreCascades => false; + + public virtual bool ForceClientNoAction + => false; + + public virtual bool NoStoreCascades + => false; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { @@ -547,18 +552,20 @@ protected virtual object CreateFullGraph() new RequiredComposite1 { Id = 1, - CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) - { - new OptionalOverlapping2 { Id = 1 }, new OptionalOverlapping2 { Id = 2 } - } + CompositeChildren = + new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) + { + new OptionalOverlapping2 { Id = 1 }, new OptionalOverlapping2 { Id = 2 } + } }, new RequiredComposite1 { Id = 2, - CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) - { - new OptionalOverlapping2 { Id = 3 }, new OptionalOverlapping2 { Id = 4 } - } + CompositeChildren = + new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) + { + new OptionalOverlapping2 { Id = 3 }, new OptionalOverlapping2 { Id = 4 } + } } } }; @@ -595,9 +602,11 @@ public virtual EntityState DetermineState(EntityEntry entry) } } - protected static void Add(IEnumerable collection, T item) => ((ICollection)collection).Add(item); + protected static void Add(IEnumerable collection, T item) + => ((ICollection)collection).Add(item); - protected static void Remove(IEnumerable collection, T item) => ((ICollection)collection).Remove(item); + protected static void Remove(IEnumerable collection, T item) + => ((ICollection)collection).Remove(item); [Flags] public enum ChangeMechanism @@ -607,9 +616,11 @@ public enum ChangeMechanism Fk = 4 } - protected Expression> IsTheRoot => r => r.AlternateId == Fixture.RootAK; + protected Expression> IsTheRoot + => r => r.AlternateId == Fixture.RootAK; - protected virtual IQueryable ModifyQueryRoot(IQueryable query) => query; + protected virtual IQueryable ModifyQueryRoot(IQueryable query) + => query; protected Root LoadRequiredGraph(DbContext context) { @@ -1001,8 +1012,13 @@ protected class Root : NotifyingEntity private OptionalSingle1 _optionalSingle; private OptionalSingle1Derived _optionalSingleDerived; private OptionalSingle1MoreDerived _optionalSingleMoreDerived; - private IEnumerable _requiredChildrenAk = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance); - private IEnumerable _optionalChildrenAk = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance); + + private IEnumerable _requiredChildrenAk = + new ObservableHashSet(LegacyReferenceEqualityComparer.Instance); + + private IEnumerable _optionalChildrenAk = + new ObservableHashSet(LegacyReferenceEqualityComparer.Instance); + private RequiredSingleAk1 _requiredSingleAk; private RequiredNonPkSingleAk1 _requiredNonPkSingleAk; private RequiredNonPkSingleAk1Derived _requiredNonPkSingleAkDerived; @@ -1146,7 +1162,8 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class Required1 : NotifyingEntity @@ -1186,21 +1203,26 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class Required1Derived : Required1 { - public override bool Equals(object obj) => base.Equals(obj as Required1Derived); + public override bool Equals(object obj) + => base.Equals(obj as Required1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class Required1MoreDerived : Required1Derived { - public override bool Equals(object obj) => base.Equals(obj as Required1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as Required1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class Required2 : NotifyingEntity @@ -1233,21 +1255,26 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class Required2Derived : Required2 { - public override bool Equals(object obj) => base.Equals(obj as Required2Derived); + public override bool Equals(object obj) + => base.Equals(obj as Required2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class Required2MoreDerived : Required2Derived { - public override bool Equals(object obj) => base.Equals(obj as Required2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as Required2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class Optional1 : NotifyingEntity @@ -1296,21 +1323,26 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class Optional1Derived : Optional1 { - public override bool Equals(object obj) => base.Equals(obj as Optional1Derived); + public override bool Equals(object obj) + => base.Equals(obj as Optional1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class Optional1MoreDerived : Optional1Derived { - public override bool Equals(object obj) => base.Equals(obj as Optional1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as Optional1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class Optional2 : NotifyingEntity @@ -1343,21 +1375,26 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class Optional2Derived : Optional2 { - public override bool Equals(object obj) => base.Equals(obj as Optional2Derived); + public override bool Equals(object obj) + => base.Equals(obj as Optional2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class Optional2MoreDerived : Optional2Derived { - public override bool Equals(object obj) => base.Equals(obj as Optional2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as Optional2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class RequiredSingle1 : NotifyingEntity @@ -1390,7 +1427,8 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class RequiredSingle2 : NotifyingEntity @@ -1416,7 +1454,8 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class RequiredNonPkSingle1 : NotifyingEntity @@ -1456,7 +1495,8 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class RequiredNonPkSingle1Derived : RequiredNonPkSingle1 @@ -1476,9 +1516,11 @@ public Root DerivedRoot set => SetWithNotify(value, ref _derivedRoot); } - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingle1Derived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingle1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class RequiredNonPkSingle1MoreDerived : RequiredNonPkSingle1Derived @@ -1498,9 +1540,11 @@ public Root MoreDerivedRoot set => SetWithNotify(value, ref _moreDerivedRoot); } - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingle1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingle1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class RequiredNonPkSingle2 : NotifyingEntity @@ -1533,21 +1577,26 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class RequiredNonPkSingle2Derived : RequiredNonPkSingle2 { - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingle2Derived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingle2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class RequiredNonPkSingle2MoreDerived : RequiredNonPkSingle2Derived { - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingle2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingle2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class OptionalSingle1 : NotifyingEntity @@ -1587,7 +1636,8 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class OptionalSingle1Derived : OptionalSingle1 @@ -1607,9 +1657,11 @@ public Root DerivedRoot set => SetWithNotify(value, ref _derivedRoot); } - public override bool Equals(object obj) => base.Equals(obj as OptionalSingle1Derived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingle1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class OptionalSingle1MoreDerived : OptionalSingle1Derived @@ -1629,9 +1681,11 @@ public Root MoreDerivedRoot set => SetWithNotify(value, ref _moreDerivedRoot); } - public override bool Equals(object obj) => base.Equals(obj as OptionalSingle1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingle1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class OptionalSingle2 : NotifyingEntity @@ -1664,21 +1718,26 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class OptionalSingle2Derived : OptionalSingle2 { - public override bool Equals(object obj) => base.Equals(obj as OptionalSingle2Derived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingle2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class OptionalSingle2MoreDerived : OptionalSingle2Derived { - public override bool Equals(object obj) => base.Equals(obj as OptionalSingle2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingle2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class RequiredAk1 : NotifyingEntity @@ -1734,21 +1793,26 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class RequiredAk1Derived : RequiredAk1 { - public override bool Equals(object obj) => base.Equals(obj as RequiredAk1Derived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredAk1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class RequiredAk1MoreDerived : RequiredAk1Derived { - public override bool Equals(object obj) => base.Equals(obj as RequiredAk1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredAk1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class RequiredAk2 : NotifyingEntity @@ -1788,7 +1852,8 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class RequiredComposite1 : NotifyingEntity @@ -1830,7 +1895,8 @@ public ICollection CompositeChildren set => SetWithNotify(value, ref _compositeChildren); } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class OptionalOverlapping2 : NotifyingEntity @@ -1877,7 +1943,8 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class RequiredComposite2 : NotifyingEntity @@ -1917,21 +1984,26 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class RequiredAk2Derived : RequiredAk2 { - public override bool Equals(object obj) => base.Equals(obj as RequiredAk2Derived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredAk2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class RequiredAk2MoreDerived : RequiredAk2Derived { - public override bool Equals(object obj) => base.Equals(obj as RequiredAk2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredAk2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class OptionalAk1 : NotifyingEntity @@ -1987,21 +2059,26 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class OptionalAk1Derived : OptionalAk1 { - public override bool Equals(object obj) => base.Equals(obj as OptionalAk1Derived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalAk1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class OptionalAk1MoreDerived : OptionalAk1Derived { - public override bool Equals(object obj) => base.Equals(obj as OptionalAk1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalAk1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class OptionalAk2 : NotifyingEntity @@ -2041,7 +2118,8 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class OptionalComposite2 : NotifyingEntity @@ -2095,21 +2173,26 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class OptionalAk2Derived : OptionalAk2 { - public override bool Equals(object obj) => base.Equals(obj as OptionalAk2Derived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalAk2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class OptionalAk2MoreDerived : OptionalAk2Derived { - public override bool Equals(object obj) => base.Equals(obj as OptionalAk2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalAk2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class RequiredSingleAk1 : NotifyingEntity @@ -2163,7 +2246,8 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class RequiredSingleAk2 : NotifyingEntity @@ -2203,7 +2287,8 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class RequiredSingleComposite2 : NotifyingEntity @@ -2243,7 +2328,8 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class RequiredNonPkSingleAk1 : NotifyingEntity @@ -2290,7 +2376,8 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class RequiredNonPkSingleAk1Derived : RequiredNonPkSingleAk1 @@ -2310,9 +2397,11 @@ public Root DerivedRoot set => SetWithNotify(value, ref _derivedRoot); } - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingleAk1Derived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingleAk1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class RequiredNonPkSingleAk1MoreDerived : RequiredNonPkSingleAk1Derived @@ -2332,9 +2421,11 @@ public Root MoreDerivedRoot set => SetWithNotify(value, ref _moreDerivedRoot); } - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingleAk1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingleAk1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class RequiredNonPkSingleAk2 : NotifyingEntity @@ -2374,21 +2465,26 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class RequiredNonPkSingleAk2Derived : RequiredNonPkSingleAk2 { - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingleAk2Derived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingleAk2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class RequiredNonPkSingleAk2MoreDerived : RequiredNonPkSingleAk2Derived { - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingleAk2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingleAk2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class OptionalSingleAk1 : NotifyingEntity @@ -2442,7 +2538,8 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class OptionalSingleAk1Derived : OptionalSingleAk1 @@ -2462,9 +2559,11 @@ public Root DerivedRoot set => SetWithNotify(value, ref _derivedRoot); } - public override bool Equals(object obj) => base.Equals(obj as OptionalSingleAk1Derived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingleAk1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class OptionalSingleAk1MoreDerived : OptionalSingleAk1Derived @@ -2484,9 +2583,11 @@ public Root MoreDerivedRoot set => SetWithNotify(value, ref _moreDerivedRoot); } - public override bool Equals(object obj) => base.Equals(obj as OptionalSingleAk1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingleAk1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class OptionalSingleAk2 : NotifyingEntity @@ -2526,7 +2627,8 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class OptionalSingleComposite2 : NotifyingEntity @@ -2566,21 +2668,26 @@ public override bool Equals(object obj) return _id == other?.Id; } - public override int GetHashCode() => _id; + public override int GetHashCode() + => _id; } protected class OptionalSingleAk2Derived : OptionalSingleAk2 { - public override bool Equals(object obj) => base.Equals(obj as OptionalSingleAk2Derived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingleAk2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class OptionalSingleAk2MoreDerived : OptionalSingleAk2Derived { - public override bool Equals(object obj) => base.Equals(obj as OptionalSingleAk2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingleAk2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } protected class BadCustomer : NotifyingEntity @@ -2818,7 +2925,8 @@ private void NotifyChanging(string propertyName) => PropertyChanging?.Invoke(this, new PropertyChangingEventArgs(propertyName)); } - protected DbContext CreateContext() => Fixture.CreateContext(); + protected DbContext CreateContext() + => Fixture.CreateContext(); protected virtual void ExecuteWithStrategyInTransaction( Action testOperation, diff --git a/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBaseOneToManyAk.cs b/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBaseOneToManyAk.cs index 14883cfc3df..778fad6dcfb 100644 --- a/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBaseOneToManyAk.cs +++ b/test/EFCore.Specification.Tests/GraphUpdates/GraphUpdatesTestBaseOneToManyAk.cs @@ -1376,6 +1376,5 @@ public virtual void Required_many_to_one_dependents_with_alternate_key_are_casca } }); } - } } diff --git a/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesFixtureBase.cs b/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesFixtureBase.cs index a128df9a134..21465859e3b 100644 --- a/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesFixtureBase.cs +++ b/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesFixtureBase.cs @@ -17,7 +17,8 @@ namespace Microsoft.EntityFrameworkCore public abstract partial class ProxyGraphUpdatesTestBase : IClassFixture where TFixture : ProxyGraphUpdatesTestBase.ProxyGraphUpdatesFixtureBase, new() { - protected ProxyGraphUpdatesTestBase(TFixture fixture) => Fixture = fixture; + protected ProxyGraphUpdatesTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -28,7 +29,8 @@ public abstract class ProxyGraphUpdatesFixtureBase : SharedStoreFixtureBase false; + protected override bool UsePooling + => false; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { @@ -385,7 +387,8 @@ protected virtual object CreateFullGraph(DbContext context) context.Set().CreateProxy(), context.Set().CreateProxy() }; - e.CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance); + e.CompositeChildren = + new ObservableHashSet(LegacyReferenceEqualityComparer.Instance); }), context.Set().CreateProxy( e => @@ -395,7 +398,8 @@ protected virtual object CreateFullGraph(DbContext context) context.Set().CreateProxy(), context.Set().CreateProxy() }; - e.CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance); + e.CompositeChildren = + new ObservableHashSet(LegacyReferenceEqualityComparer.Instance); }) }; @@ -442,10 +446,12 @@ protected virtual object CreateFullGraph(DbContext context) context.Set().CreateProxy(e => e.AlternateId = Guid.NewGuid()) }; - e.CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) - { - context.Set().CreateProxy(), context.Set().CreateProxy() - }; + e.CompositeChildren = + new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) + { + context.Set().CreateProxy(), + context.Set().CreateProxy() + }; }), context.Set().CreateProxy( e => @@ -458,10 +464,12 @@ protected virtual object CreateFullGraph(DbContext context) context.Set().CreateProxy(e => e.AlternateId = Guid.NewGuid()) }; - e.CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) - { - context.Set().CreateProxy(), context.Set().CreateProxy() - }; + e.CompositeChildren = + new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) + { + context.Set().CreateProxy(), + context.Set().CreateProxy() + }; }) }; @@ -565,22 +573,24 @@ protected virtual object CreateFullGraph(DbContext context) { e.Id = 1; - e.CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) - { - context.CreateProxy(e => e.Id = 1), - context.CreateProxy(e => e.Id = 2) - }; + e.CompositeChildren = + new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) + { + context.CreateProxy(e => e.Id = 1), + context.CreateProxy(e => e.Id = 2) + }; }), context.Set().CreateProxy( e => { e.Id = 2; - e.CompositeChildren = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) - { - context.CreateProxy(e => e.Id = 3), - context.CreateProxy(e => e.Id = 4) - }; + e.CompositeChildren = + new ObservableHashSet(LegacyReferenceEqualityComparer.Instance) + { + context.CreateProxy(e => e.Id = 3), + context.CreateProxy(e => e.Id = 4) + }; }) }; }); @@ -607,9 +617,11 @@ public virtual EntityState DetermineState(EntityEntry entry) } } - private static void Add(IEnumerable collection, T item) => ((ICollection)collection).Add(item); + private static void Add(IEnumerable collection, T item) + => ((ICollection)collection).Add(item); - private static void Remove(IEnumerable collection, T item) => ((ICollection)collection).Remove(item); + private static void Remove(IEnumerable collection, T item) + => ((ICollection)collection).Remove(item); [Flags] public enum ChangeMechanism @@ -619,7 +631,8 @@ public enum ChangeMechanism Fk = 4 } - protected Expression> IsTheRoot => r => r.AlternateId == Fixture.RootAK; + protected Expression> IsTheRoot + => r => r.AlternateId == Fixture.RootAK; protected Root LoadRoot(DbContext context) => context.Set().Single(IsTheRoot); @@ -683,7 +696,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class Required1 @@ -707,7 +721,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class Required1Derived : Required1 @@ -716,9 +731,11 @@ protected Required1Derived() { } - public override bool Equals(object obj) => base.Equals(obj as Required1Derived); + public override bool Equals(object obj) + => base.Equals(obj as Required1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class Required1MoreDerived : Required1Derived @@ -727,9 +744,11 @@ protected Required1MoreDerived() { } - public override bool Equals(object obj) => base.Equals(obj as Required1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as Required1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class Required2 @@ -750,7 +769,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class Required2Derived : Required2 @@ -759,9 +779,11 @@ protected Required2Derived() { } - public override bool Equals(object obj) => base.Equals(obj as Required2Derived); + public override bool Equals(object obj) + => base.Equals(obj as Required2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class Required2MoreDerived : Required2Derived @@ -770,9 +792,11 @@ protected Required2MoreDerived() { } - public override bool Equals(object obj) => base.Equals(obj as Required2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as Required2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class Optional1 @@ -799,7 +823,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class Optional1Derived : Optional1 @@ -808,9 +833,11 @@ protected Optional1Derived() { } - public override bool Equals(object obj) => base.Equals(obj as Optional1Derived); + public override bool Equals(object obj) + => base.Equals(obj as Optional1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class Optional1MoreDerived : Optional1Derived @@ -819,9 +846,11 @@ protected Optional1MoreDerived() { } - public override bool Equals(object obj) => base.Equals(obj as Optional1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as Optional1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class Optional2 @@ -842,7 +871,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class Optional2Derived : Optional2 @@ -851,9 +881,11 @@ protected Optional2Derived() { } - public override bool Equals(object obj) => base.Equals(obj as Optional2Derived); + public override bool Equals(object obj) + => base.Equals(obj as Optional2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class Optional2MoreDerived : Optional2Derived @@ -862,9 +894,11 @@ protected Optional2MoreDerived() { } - public override bool Equals(object obj) => base.Equals(obj as Optional2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as Optional2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class RequiredSingle1 @@ -885,7 +919,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class RequiredSingle2 @@ -904,7 +939,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class RequiredNonPkSingle1 @@ -927,7 +963,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class RequiredNonPkSingle1Derived : RequiredNonPkSingle1 @@ -940,9 +977,11 @@ protected RequiredNonPkSingle1Derived() public virtual Root DerivedRoot { get; set; } - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingle1Derived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingle1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class RequiredNonPkSingle1MoreDerived : RequiredNonPkSingle1Derived @@ -955,9 +994,11 @@ protected RequiredNonPkSingle1MoreDerived() public virtual Root MoreDerivedRoot { get; set; } - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingle1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingle1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class RequiredNonPkSingle2 @@ -978,7 +1019,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class RequiredNonPkSingle2Derived : RequiredNonPkSingle2 @@ -987,9 +1029,11 @@ protected RequiredNonPkSingle2Derived() { } - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingle2Derived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingle2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class RequiredNonPkSingle2MoreDerived : RequiredNonPkSingle2Derived @@ -998,9 +1042,11 @@ protected RequiredNonPkSingle2MoreDerived() { } - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingle2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingle2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class OptionalSingle1 @@ -1023,7 +1069,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class OptionalSingle1Derived : OptionalSingle1 @@ -1036,9 +1083,11 @@ protected OptionalSingle1Derived() public virtual Root DerivedRoot { get; set; } - public override bool Equals(object obj) => base.Equals(obj as OptionalSingle1Derived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingle1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class OptionalSingle1MoreDerived : OptionalSingle1Derived @@ -1051,9 +1100,11 @@ protected OptionalSingle1MoreDerived() public virtual Root MoreDerivedRoot { get; set; } - public override bool Equals(object obj) => base.Equals(obj as OptionalSingle1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingle1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class OptionalSingle2 @@ -1074,7 +1125,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class OptionalSingle2Derived : OptionalSingle2 @@ -1083,9 +1135,11 @@ protected OptionalSingle2Derived() { } - public override bool Equals(object obj) => base.Equals(obj as OptionalSingle2Derived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingle2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class OptionalSingle2MoreDerived : OptionalSingle2Derived @@ -1094,9 +1148,11 @@ protected OptionalSingle2MoreDerived() { } - public override bool Equals(object obj) => base.Equals(obj as OptionalSingle2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingle2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class RequiredAk1 @@ -1125,7 +1181,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class RequiredAk1Derived : RequiredAk1 @@ -1134,9 +1191,11 @@ protected RequiredAk1Derived() { } - public override bool Equals(object obj) => base.Equals(obj as RequiredAk1Derived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredAk1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class RequiredAk1MoreDerived : RequiredAk1Derived @@ -1145,9 +1204,11 @@ protected RequiredAk1MoreDerived() { } - public override bool Equals(object obj) => base.Equals(obj as RequiredAk1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredAk1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class RequiredAk2 @@ -1170,7 +1231,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class RequiredComposite1 @@ -1194,7 +1256,8 @@ public override bool Equals(object obj) public virtual ICollection CompositeChildren { get; set; } = new ObservableHashSet(LegacyReferenceEqualityComparer.Instance); - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class OptionalOverlapping2 @@ -1219,7 +1282,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class RequiredComposite2 @@ -1242,7 +1306,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class RequiredAk2Derived : RequiredAk2 @@ -1251,9 +1316,11 @@ protected RequiredAk2Derived() { } - public override bool Equals(object obj) => base.Equals(obj as RequiredAk2Derived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredAk2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class RequiredAk2MoreDerived : RequiredAk2Derived @@ -1262,9 +1329,11 @@ protected RequiredAk2MoreDerived() { } - public override bool Equals(object obj) => base.Equals(obj as RequiredAk2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredAk2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class OptionalAk1 @@ -1293,7 +1362,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class OptionalAk1Derived : OptionalAk1 @@ -1302,9 +1372,11 @@ protected OptionalAk1Derived() { } - public override bool Equals(object obj) => base.Equals(obj as OptionalAk1Derived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalAk1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class OptionalAk1MoreDerived : OptionalAk1Derived @@ -1313,9 +1385,11 @@ protected OptionalAk1MoreDerived() { } - public override bool Equals(object obj) => base.Equals(obj as OptionalAk1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalAk1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class OptionalAk2 @@ -1338,7 +1412,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class OptionalComposite2 @@ -1365,7 +1440,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class OptionalAk2Derived : OptionalAk2 @@ -1374,9 +1450,11 @@ protected OptionalAk2Derived() { } - public override bool Equals(object obj) => base.Equals(obj as OptionalAk2Derived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalAk2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class OptionalAk2MoreDerived : OptionalAk2Derived @@ -1385,9 +1463,11 @@ protected OptionalAk2MoreDerived() { } - public override bool Equals(object obj) => base.Equals(obj as OptionalAk2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalAk2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class RequiredSingleAk1 @@ -1414,7 +1494,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class RequiredSingleAk2 @@ -1437,7 +1518,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class RequiredSingleComposite2 @@ -1460,7 +1542,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class RequiredNonPkSingleAk1 @@ -1485,7 +1568,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class RequiredNonPkSingleAk1Derived : RequiredNonPkSingleAk1 @@ -1498,9 +1582,11 @@ protected RequiredNonPkSingleAk1Derived() public virtual Root DerivedRoot { get; set; } - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingleAk1Derived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingleAk1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class RequiredNonPkSingleAk1MoreDerived : RequiredNonPkSingleAk1Derived @@ -1513,9 +1599,11 @@ protected RequiredNonPkSingleAk1MoreDerived() public virtual Root MoreDerivedRoot { get; set; } - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingleAk1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingleAk1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class RequiredNonPkSingleAk2 @@ -1538,7 +1626,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class RequiredNonPkSingleAk2Derived : RequiredNonPkSingleAk2 @@ -1547,9 +1636,11 @@ protected RequiredNonPkSingleAk2Derived() { } - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingleAk2Derived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingleAk2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class RequiredNonPkSingleAk2MoreDerived : RequiredNonPkSingleAk2Derived @@ -1558,9 +1649,11 @@ protected RequiredNonPkSingleAk2MoreDerived() { } - public override bool Equals(object obj) => base.Equals(obj as RequiredNonPkSingleAk2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as RequiredNonPkSingleAk2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class OptionalSingleAk1 @@ -1587,7 +1680,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class OptionalSingleAk1Derived : OptionalSingleAk1 @@ -1600,9 +1694,11 @@ protected OptionalSingleAk1Derived() public virtual Root DerivedRoot { get; set; } - public override bool Equals(object obj) => base.Equals(obj as OptionalSingleAk1Derived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingleAk1Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class OptionalSingleAk1MoreDerived : OptionalSingleAk1Derived @@ -1615,9 +1711,11 @@ protected OptionalSingleAk1MoreDerived() public virtual Root MoreDerivedRoot { get; set; } - public override bool Equals(object obj) => base.Equals(obj as OptionalSingleAk1MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingleAk1MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class OptionalSingleAk2 @@ -1640,7 +1738,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class OptionalSingleComposite2 @@ -1663,7 +1762,8 @@ public override bool Equals(object obj) return Id == other?.Id; } - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; } public class OptionalSingleAk2Derived : OptionalSingleAk2 @@ -1672,9 +1772,11 @@ protected OptionalSingleAk2Derived() { } - public override bool Equals(object obj) => base.Equals(obj as OptionalSingleAk2Derived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingleAk2Derived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class OptionalSingleAk2MoreDerived : OptionalSingleAk2Derived @@ -1683,9 +1785,11 @@ protected OptionalSingleAk2MoreDerived() { } - public override bool Equals(object obj) => base.Equals(obj as OptionalSingleAk2MoreDerived); + public override bool Equals(object obj) + => base.Equals(obj as OptionalSingleAk2MoreDerived); - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } public class BadCustomer @@ -1715,7 +1819,8 @@ protected BadOrder() public virtual BadCustomer BadCustomer { get; set; } } - protected DbContext CreateContext() => Fixture.CreateContext(); + protected DbContext CreateContext() + => Fixture.CreateContext(); protected virtual void ExecuteWithStrategyInTransaction( Action testOperation, diff --git a/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesTestBaseOneToManyAk.cs b/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesTestBaseOneToManyAk.cs index 2e5ecb7e85b..962c78e3916 100644 --- a/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesTestBaseOneToManyAk.cs +++ b/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesTestBaseOneToManyAk.cs @@ -31,7 +31,8 @@ public abstract partial class ProxyGraphUpdatesTestBase : IClassFixtur [InlineData((int)(ChangeMechanism.Principal | ChangeMechanism.Dependent | ChangeMechanism.Fk), false)] [InlineData((int)(ChangeMechanism.Principal | ChangeMechanism.Dependent | ChangeMechanism.Fk), true)] public virtual void Save_optional_many_to_one_dependents_with_alternate_key( - ChangeMechanism changeMechanism, bool useExistingEntities) + ChangeMechanism changeMechanism, + bool useExistingEntities) { OptionalAk1 new1 = null; OptionalAk1Derived new1d = null; @@ -187,7 +188,8 @@ public virtual void Save_optional_many_to_one_dependents_with_alternate_key( [InlineData((int)(ChangeMechanism.Principal | ChangeMechanism.Dependent | ChangeMechanism.Fk), false)] [InlineData((int)(ChangeMechanism.Principal | ChangeMechanism.Dependent | ChangeMechanism.Fk), true)] public virtual void Save_required_many_to_one_dependents_with_alternate_key( - ChangeMechanism changeMechanism, bool useExistingEntities) + ChangeMechanism changeMechanism, + bool useExistingEntities) { Root newRoot; RequiredAk1 new1 = null; @@ -204,43 +206,50 @@ public virtual void Save_required_many_to_one_dependents_with_alternate_key( context => { newRoot = context.CreateProxy(e => e.AlternateId = Guid.NewGuid()); - new1 = context.CreateProxy(e => - { - e.AlternateId = Guid.NewGuid(); - e.Parent = newRoot; - }); - new1d = context.CreateProxy(e => - { - e.AlternateId = Guid.NewGuid(); - e.Parent = newRoot; - }); - new1dd = context.CreateProxy(e => - { - e.AlternateId = Guid.NewGuid(); - e.Parent = newRoot; - }); - new2a = context.CreateProxy(e => - { - e.AlternateId = Guid.NewGuid(); - e.Parent = new1; - }); - new2b = context.CreateProxy(e => - { - e.AlternateId = Guid.NewGuid(); - e.Parent = new1; - }); + new1 = context.CreateProxy( + e => + { + e.AlternateId = Guid.NewGuid(); + e.Parent = newRoot; + }); + new1d = context.CreateProxy( + e => + { + e.AlternateId = Guid.NewGuid(); + e.Parent = newRoot; + }); + new1dd = context.CreateProxy( + e => + { + e.AlternateId = Guid.NewGuid(); + e.Parent = newRoot; + }); + new2a = context.CreateProxy( + e => + { + e.AlternateId = Guid.NewGuid(); + e.Parent = new1; + }); + new2b = context.CreateProxy( + e => + { + e.AlternateId = Guid.NewGuid(); + e.Parent = new1; + }); new2ca = context.CreateProxy(e => e.Parent = new1); new2cb = context.CreateProxy(e => e.Parent = new1); - new2d = context.CreateProxy(e => - { - e.AlternateId = Guid.NewGuid(); - e.Parent = new1; - }); - new2dd = context.CreateProxy(e => - { - e.AlternateId = Guid.NewGuid(); - e.Parent = new1; - }); + new2d = context.CreateProxy( + e => + { + e.AlternateId = Guid.NewGuid(); + e.Parent = new1; + }); + new2dd = context.CreateProxy( + e => + { + e.AlternateId = Guid.NewGuid(); + e.Parent = new1; + }); if (useExistingEntities) { @@ -530,7 +539,6 @@ public virtual void Save_removed_required_many_to_one_dependents_with_alternate_ }); } - [ConditionalTheory] [InlineData(CascadeTiming.OnSaveChanges, CascadeTiming.OnSaveChanges)] [InlineData(CascadeTiming.OnSaveChanges, CascadeTiming.Immediate)] diff --git a/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesTestBaseOneToOne.cs b/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesTestBaseOneToOne.cs index a1ebd0673c5..cb423c2d159 100644 --- a/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesTestBaseOneToOne.cs +++ b/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesTestBaseOneToOne.cs @@ -278,7 +278,6 @@ public virtual void Save_required_one_to_one_changed_by_reference(ChangeMechanis new1 = context.CreateProxy(e => e.Single = new2); }); - ExecuteWithStrategyInTransaction( context => { diff --git a/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesTestBaseOneToOneAk.cs b/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesTestBaseOneToOneAk.cs index 4f1673eff57..32e35b0c62b 100644 --- a/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesTestBaseOneToOneAk.cs +++ b/test/EFCore.Specification.Tests/GraphUpdates/ProxyGraphUpdatesTestBaseOneToOneAk.cs @@ -414,11 +414,13 @@ public virtual void Save_changed_optional_one_to_one_with_alternate_key_in_store [InlineData((int)(ChangeMechanism.Principal | ChangeMechanism.Dependent), false)] [InlineData((int)(ChangeMechanism.Principal | ChangeMechanism.Dependent), true)] public virtual void Save_required_one_to_one_changed_by_reference_with_alternate_key( - ChangeMechanism changeMechanism, bool useExistingEntities) + ChangeMechanism changeMechanism, + bool useExistingEntities) { RequiredSingleAk2 new2 = null; RequiredSingleComposite2 new2c = null; - RequiredSingleAk1 new1 = null;; + RequiredSingleAk1 new1 = null; + ; Root newRoot; RequiredSingleAk1 old1 = null; RequiredSingleAk2 old2 = null; @@ -433,14 +435,15 @@ public virtual void Save_required_one_to_one_changed_by_reference_with_alternate e => { e.AlternateId = Guid.NewGuid(); - e.Single = new2; - e.SingleComposite = new2c; - }); - newRoot = context.CreateProxy(e => - { - e.AlternateId = Guid.NewGuid(); - e.RequiredSingleAk = new1; - }); + e.Single = new2; + e.SingleComposite = new2c; + }); + newRoot = context.CreateProxy( + e => + { + e.AlternateId = Guid.NewGuid(); + e.RequiredSingleAk = new1; + }); if (useExistingEntities) { @@ -541,7 +544,8 @@ public virtual void Save_required_one_to_one_changed_by_reference_with_alternate [InlineData((int)(ChangeMechanism.Principal | ChangeMechanism.Dependent | ChangeMechanism.Fk), false)] [InlineData((int)(ChangeMechanism.Principal | ChangeMechanism.Dependent | ChangeMechanism.Fk), true)] public virtual void Save_required_non_PK_one_to_one_changed_by_reference_with_alternate_key( - ChangeMechanism changeMechanism, bool useExistingEntities) + ChangeMechanism changeMechanism, + bool useExistingEntities) { RequiredNonPkSingleAk2 new2 = null; RequiredNonPkSingleAk2Derived new2d = null; @@ -563,11 +567,12 @@ public virtual void Save_required_non_PK_one_to_one_changed_by_reference_with_al new2 = context.CreateProxy(e => e.AlternateId = Guid.NewGuid()); new2d = context.CreateProxy(e => e.AlternateId = Guid.NewGuid()); new2dd = context.CreateProxy(e => e.AlternateId = Guid.NewGuid()); - new1 = context.CreateProxy(e => - { - e.AlternateId = Guid.NewGuid(); - e.Single = new2; - }); + new1 = context.CreateProxy( + e => + { + e.AlternateId = Guid.NewGuid(); + e.Single = new2; + }); new1d = context.CreateProxy( e => { @@ -576,7 +581,7 @@ public virtual void Save_required_non_PK_one_to_one_changed_by_reference_with_al e.Root = context.CreateProxy(); }); new1dd = context.CreateProxy( - e => + e => { e.AlternateId = Guid.NewGuid(); e.Single = new2dd; diff --git a/test/EFCore.Specification.Tests/KeysWithConvertersTestBase.cs b/test/EFCore.Specification.Tests/KeysWithConvertersTestBase.cs index 2f807d843fc..79d88f4ed85 100644 --- a/test/EFCore.Specification.Tests/KeysWithConvertersTestBase.cs +++ b/test/EFCore.Specification.Tests/KeysWithConvertersTestBase.cs @@ -15,11 +15,13 @@ namespace Microsoft.EntityFrameworkCore public abstract class KeysWithConvertersTestBase : IClassFixture where TFixture : KeysWithConvertersTestBase.KeysWithConvertersFixtureBase, new() { - protected KeysWithConvertersTestBase(TFixture fixture) => Fixture = fixture; + protected KeysWithConvertersTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } - protected DbContext CreateContext() => Fixture.CreateContext(); + protected DbContext CreateContext() + => Fixture.CreateContext(); [ConditionalFact] public virtual void Can_insert_and_read_back_with_struct_key_and_optional_dependents() @@ -70,10 +72,13 @@ void RunQueries( principals = new[] { - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new IntStructKey { Id = 1 })), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new IntStructKey { Id = two })), + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(new IntStructKey { Id = 1 })), + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(new IntStructKey { Id = two })), context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(three)), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new IntStructKey { Id = 4 })) + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(new IntStructKey { Id = 4 })) }; var oneOhTwo = 102; @@ -97,7 +102,7 @@ void RunQueries( Assert.Same(dependents[3], context.Find(typeof(IntStructKeyOptionalDependent), new IntStructKey { Id = 104 })); Assert.Same(dependents[4], context.Find(typeof(IntStructKeyOptionalDependent), new IntStructKey { Id = oneOhFive })); Assert.Same(dependents[5], context.Find(typeof(IntStructKeyOptionalDependent), oneOhSix)); - } + } void Validate( IntStructKeyPrincipal[] principals, @@ -164,10 +169,13 @@ void RunQueries( principals = new[] { - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new ComparableIntStructKey { Id = 1 })), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new ComparableIntStructKey { Id = two })), + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(new ComparableIntStructKey { Id = 1 })), + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(new ComparableIntStructKey { Id = two })), context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(three)), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new ComparableIntStructKey { Id = 4 })) + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(new ComparableIntStructKey { Id = 4 })) }; var oneOhTwo = 102; @@ -177,21 +185,31 @@ void RunQueries( dependents = new[] { - context.Set().Single(e => e.Id.Equals(new ComparableIntStructKey { Id = 101 })), - context.Set().Single(e => e.Id.Equals(new ComparableIntStructKey { Id = oneOhTwo })), + context.Set() + .Single(e => e.Id.Equals(new ComparableIntStructKey { Id = 101 })), + context.Set() + .Single(e => e.Id.Equals(new ComparableIntStructKey { Id = oneOhTwo })), context.Set().Single(e => e.Id.Equals(oneOhThree)), - context.Set().Single(e => e.Id.Equals(new ComparableIntStructKey { Id = 104 })), - context.Set().Single(e => e.Id.Equals(new ComparableIntStructKey { Id = oneOhFive })), + context.Set() + .Single(e => e.Id.Equals(new ComparableIntStructKey { Id = 104 })), + context.Set() + .Single(e => e.Id.Equals(new ComparableIntStructKey { Id = oneOhFive })), context.Set().Single(e => e.Id.Equals(oneOhSix)) }; - Assert.Same(dependents[0], context.Set().Find(new ComparableIntStructKey { Id = 101 })); - Assert.Same(dependents[1], context.Set().Find(new ComparableIntStructKey { Id = oneOhTwo })); + Assert.Same( + dependents[0], context.Set().Find(new ComparableIntStructKey { Id = 101 })); + Assert.Same( + dependents[1], + context.Set().Find(new ComparableIntStructKey { Id = oneOhTwo })); Assert.Same(dependents[2], context.Set().Find(oneOhThree)); - Assert.Same(dependents[3], context.Find(typeof(ComparableIntStructKeyOptionalDependent), new ComparableIntStructKey { Id = 104 })); - Assert.Same(dependents[4], context.Find(typeof(ComparableIntStructKeyOptionalDependent), new ComparableIntStructKey { Id = oneOhFive })); + Assert.Same( + dependents[3], context.Find(typeof(ComparableIntStructKeyOptionalDependent), new ComparableIntStructKey { Id = 104 })); + Assert.Same( + dependents[4], + context.Find(typeof(ComparableIntStructKeyOptionalDependent), new ComparableIntStructKey { Id = oneOhFive })); Assert.Same(dependents[5], context.Find(typeof(ComparableIntStructKeyOptionalDependent), oneOhSix)); - } + } void Validate( ComparableIntStructKeyPrincipal[] principals, @@ -258,10 +276,14 @@ void RunQueries( principals = new[] { - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 1 })), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = two })), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(three)), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 4 })) + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 1 })), + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = two })), + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(three)), + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 4 })) }; var oneOhTwo = 102; @@ -271,21 +293,35 @@ void RunQueries( dependents = new[] { - context.Set().Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 101 })), - context.Set().Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = oneOhTwo })), + context.Set() + .Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 101 })), + context.Set() + .Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = oneOhTwo })), context.Set().Single(e => e.Id.Equals(oneOhThree)), - context.Set().Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 104 })), - context.Set().Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = oneOhFive })), + context.Set() + .Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 104 })), + context.Set() + .Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = oneOhFive })), context.Set().Single(e => e.Id.Equals(oneOhSix)) }; - Assert.Same(dependents[0], context.Set().Find(new GenericComparableIntStructKey { Id = 101 })); - Assert.Same(dependents[1], context.Set().Find(new GenericComparableIntStructKey { Id = oneOhTwo })); + Assert.Same( + dependents[0], + context.Set().Find(new GenericComparableIntStructKey { Id = 101 })); + Assert.Same( + dependents[1], + context.Set() + .Find(new GenericComparableIntStructKey { Id = oneOhTwo })); Assert.Same(dependents[2], context.Set().Find(oneOhThree)); - Assert.Same(dependents[3], context.Find(typeof(GenericComparableIntStructKeyOptionalDependent), new GenericComparableIntStructKey { Id = 104 })); - Assert.Same(dependents[4], context.Find(typeof(GenericComparableIntStructKeyOptionalDependent), new GenericComparableIntStructKey { Id = oneOhFive })); + Assert.Same( + dependents[3], + context.Find(typeof(GenericComparableIntStructKeyOptionalDependent), new GenericComparableIntStructKey { Id = 104 })); + Assert.Same( + dependents[4], + context.Find( + typeof(GenericComparableIntStructKeyOptionalDependent), new GenericComparableIntStructKey { Id = oneOhFive })); Assert.Same(dependents[5], context.Find(typeof(GenericComparableIntStructKeyOptionalDependent), oneOhSix)); - } + } void Validate( GenericComparableIntStructKeyPrincipal[] principals, @@ -352,10 +388,13 @@ void RunQueries( principals = new[] { - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new IntStructKey { Id = 11 })), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new IntStructKey { Id = twelve })), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(new IntStructKey { Id = 11 })), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(new IntStructKey { Id = twelve })), context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(thirteen)), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new IntStructKey { Id = 14 })) + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(new IntStructKey { Id = 14 })) }; var oneTwelve = 112; @@ -369,7 +408,8 @@ void RunQueries( context.Set().FirstOrDefault(e => e.Id.Equals(new IntStructKey { Id = oneTwelve })), context.Set().FirstOrDefault(e => e.Id.Equals(oneThirteen)), context.Set().FirstOrDefault(e => e.Id.Equals(new IntStructKey { Id = 114 })), - context.Set().FirstOrDefault(e => e.Id.Equals(new IntStructKey { Id = oneFifteeen })), + context.Set() + .FirstOrDefault(e => e.Id.Equals(new IntStructKey { Id = oneFifteeen })), context.Set().FirstOrDefault(e => e.Id.Equals(oneSixteen)) }; @@ -379,7 +419,7 @@ void RunQueries( Assert.Same(dependents[3], context.Find(typeof(IntStructKeyRequiredDependent), new IntStructKey { Id = 114 })); Assert.Same(dependents[4], context.Find(typeof(IntStructKeyRequiredDependent), new IntStructKey { Id = oneFifteeen })); Assert.Same(dependents[5], context.Find(typeof(IntStructKeyRequiredDependent), oneSixteen)); - } + } void Validate( IntStructKeyPrincipal[] principals, @@ -446,10 +486,14 @@ void RunQueries( principals = new[] { - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new ComparableIntStructKey { Id = 11 })), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new ComparableIntStructKey { Id = twelve })), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(thirteen)), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new ComparableIntStructKey { Id = 14 })) + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(new ComparableIntStructKey { Id = 11 })), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(new ComparableIntStructKey { Id = twelve })), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(thirteen)), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(new ComparableIntStructKey { Id = 14 })) }; var oneTwelve = 112; @@ -459,21 +503,31 @@ void RunQueries( dependents = new[] { - context.Set().FirstOrDefault(e => e.Id.Equals(new ComparableIntStructKey { Id = 111 })), - context.Set().FirstOrDefault(e => e.Id.Equals(new ComparableIntStructKey { Id = oneTwelve })), + context.Set() + .FirstOrDefault(e => e.Id.Equals(new ComparableIntStructKey { Id = 111 })), + context.Set() + .FirstOrDefault(e => e.Id.Equals(new ComparableIntStructKey { Id = oneTwelve })), context.Set().FirstOrDefault(e => e.Id.Equals(oneThirteen)), - context.Set().FirstOrDefault(e => e.Id.Equals(new ComparableIntStructKey { Id = 114 })), - context.Set().FirstOrDefault(e => e.Id.Equals(new ComparableIntStructKey { Id = oneFifteeen })), + context.Set() + .FirstOrDefault(e => e.Id.Equals(new ComparableIntStructKey { Id = 114 })), + context.Set() + .FirstOrDefault(e => e.Id.Equals(new ComparableIntStructKey { Id = oneFifteeen })), context.Set().FirstOrDefault(e => e.Id.Equals(oneSixteen)) }; - Assert.Same(dependents[0], context.Set().Find(new ComparableIntStructKey { Id = 111 })); - Assert.Same(dependents[1], context.Set().Find(new ComparableIntStructKey { Id = oneTwelve })); + Assert.Same( + dependents[0], context.Set().Find(new ComparableIntStructKey { Id = 111 })); + Assert.Same( + dependents[1], + context.Set().Find(new ComparableIntStructKey { Id = oneTwelve })); Assert.Same(dependents[2], context.Set().Find(oneThirteen)); - Assert.Same(dependents[3], context.Find(typeof(ComparableIntStructKeyRequiredDependent), new ComparableIntStructKey { Id = 114 })); - Assert.Same(dependents[4], context.Find(typeof(ComparableIntStructKeyRequiredDependent), new ComparableIntStructKey { Id = oneFifteeen })); + Assert.Same( + dependents[3], context.Find(typeof(ComparableIntStructKeyRequiredDependent), new ComparableIntStructKey { Id = 114 })); + Assert.Same( + dependents[4], + context.Find(typeof(ComparableIntStructKeyRequiredDependent), new ComparableIntStructKey { Id = oneFifteeen })); Assert.Same(dependents[5], context.Find(typeof(ComparableIntStructKeyRequiredDependent), oneSixteen)); - } + } void Validate( ComparableIntStructKeyPrincipal[] principals, @@ -540,10 +594,14 @@ void RunQueries( principals = new[] { - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 11 })), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = twelve })), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(thirteen)), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 14 })) + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 11 })), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = twelve })), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(thirteen)), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 14 })) }; var oneTwelve = 112; @@ -553,21 +611,35 @@ void RunQueries( dependents = new[] { - context.Set().FirstOrDefault(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 111 })), - context.Set().FirstOrDefault(e => e.Id.Equals(new GenericComparableIntStructKey { Id = oneTwelve })), + context.Set() + .FirstOrDefault(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 111 })), + context.Set().FirstOrDefault( + e => e.Id.Equals(new GenericComparableIntStructKey { Id = oneTwelve })), context.Set().FirstOrDefault(e => e.Id.Equals(oneThirteen)), - context.Set().FirstOrDefault(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 114 })), - context.Set().FirstOrDefault(e => e.Id.Equals(new GenericComparableIntStructKey { Id = oneFifteeen })), + context.Set() + .FirstOrDefault(e => e.Id.Equals(new GenericComparableIntStructKey { Id = 114 })), + context.Set().FirstOrDefault( + e => e.Id.Equals(new GenericComparableIntStructKey { Id = oneFifteeen })), context.Set().FirstOrDefault(e => e.Id.Equals(oneSixteen)) }; - Assert.Same(dependents[0], context.Set().Find(new GenericComparableIntStructKey { Id = 111 })); - Assert.Same(dependents[1], context.Set().Find(new GenericComparableIntStructKey { Id = oneTwelve })); + Assert.Same( + dependents[0], + context.Set().Find(new GenericComparableIntStructKey { Id = 111 })); + Assert.Same( + dependents[1], + context.Set() + .Find(new GenericComparableIntStructKey { Id = oneTwelve })); Assert.Same(dependents[2], context.Set().Find(oneThirteen)); - Assert.Same(dependents[3], context.Find(typeof(GenericComparableIntStructKeyRequiredDependent), new GenericComparableIntStructKey { Id = 114 })); - Assert.Same(dependents[4], context.Find(typeof(GenericComparableIntStructKeyRequiredDependent), new GenericComparableIntStructKey { Id = oneFifteeen })); + Assert.Same( + dependents[3], + context.Find(typeof(GenericComparableIntStructKeyRequiredDependent), new GenericComparableIntStructKey { Id = 114 })); + Assert.Same( + dependents[4], + context.Find( + typeof(GenericComparableIntStructKeyRequiredDependent), new GenericComparableIntStructKey { Id = oneFifteeen })); Assert.Same(dependents[5], context.Find(typeof(GenericComparableIntStructKeyRequiredDependent), oneSixteen)); - } + } void Validate( GenericComparableIntStructKeyPrincipal[] principals, @@ -747,19 +819,25 @@ void RunQueries( dependents = new[] { - context.Set().Single(e => e.Id.Equals(new ComparableIntClassKey { Id = 101 })), - context.Set().Single(e => e.Id.Equals(new ComparableIntClassKey { Id = oneOhTwo })), + context.Set() + .Single(e => e.Id.Equals(new ComparableIntClassKey { Id = 101 })), + context.Set() + .Single(e => e.Id.Equals(new ComparableIntClassKey { Id = oneOhTwo })), context.Set().Single(e => e.Id.Equals(oneOhThree)), context.Set().Single(e => e.Id == new ComparableIntClassKey { Id = 104 }), - context.Set().Single(e => e.Id == new ComparableIntClassKey { Id = oneOhFive }), + context.Set() + .Single(e => e.Id == new ComparableIntClassKey { Id = oneOhFive }), context.Set().Single(e => e.Id == oneOhSix) }; - Assert.Same(dependents[0], context.Set().Find(new ComparableIntClassKey { Id = 101 })); - Assert.Same(dependents[1], context.Set().Find(new ComparableIntClassKey { Id = oneOhTwo })); + Assert.Same( + dependents[0], context.Set().Find(new ComparableIntClassKey { Id = 101 })); + Assert.Same( + dependents[1], context.Set().Find(new ComparableIntClassKey { Id = oneOhTwo })); Assert.Same(dependents[2], context.Set().Find(oneOhThree)); Assert.Same(dependents[3], context.Find(new ComparableIntClassKey { Id = 104 })); - Assert.Same(dependents[4], context.Find(new ComparableIntClassKey { Id = oneOhFive })); + Assert.Same( + dependents[4], context.Find(new ComparableIntClassKey { Id = oneOhFive })); Assert.Same(dependents[5], context.Find(oneOhSix)); } @@ -828,10 +906,14 @@ void RunQueries( principals = new[] { - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 1 } })), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new BytesStructKey { Id = two })), - context.Set().Include(e => e.OptionalDependents).Where(e => e.Id.Equals(three)).ToList().Single(), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 4, 4, 4, 4 } })) + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 1 } })), + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(new BytesStructKey { Id = two })), + context.Set().Include(e => e.OptionalDependents).Where(e => e.Id.Equals(three)).ToList() + .Single(), + context.Set().Include(e => e.OptionalDependents).Single( + e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 4, 4, 4, 4 } })) }; var oneOhTwo = new byte[] { 102 }; @@ -841,21 +923,25 @@ void RunQueries( dependents = new[] { - context.Set().Single(e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 101 } })), + context.Set() + .Single(e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 101 } })), context.Set().Single(e => e.Id.Equals(new BytesStructKey { Id = oneOhTwo })), context.Set().Single(e => e.Id.Equals(oneOhThree)), - context.Set().Single(e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 104 } })), + context.Set() + .Single(e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 104 } })), context.Set().Single(e => e.Id.Equals(new BytesStructKey { Id = oneOhFive })), context.Set().Single(e => e.Id.Equals(oneOhSix)) }; - Assert.Same(dependents[0], context.Set().Find(new BytesStructKey { Id = new byte[] { 101 } })); + Assert.Same( + dependents[0], context.Set().Find(new BytesStructKey { Id = new byte[] { 101 } })); Assert.Same(dependents[1], context.Set().Find(new BytesStructKey { Id = oneOhTwo })); Assert.Same(dependents[2], context.Set().Find(oneOhThree)); - Assert.Same(dependents[3], context.Find(typeof(BytesStructKeyOptionalDependent), new BytesStructKey { Id = new byte[] { 104 } })); + Assert.Same( + dependents[3], context.Find(typeof(BytesStructKeyOptionalDependent), new BytesStructKey { Id = new byte[] { 104 } })); Assert.Same(dependents[4], context.Find(typeof(BytesStructKeyOptionalDependent), new BytesStructKey { Id = oneOhFive })); Assert.Same(dependents[5], context.Find(typeof(BytesStructKeyOptionalDependent), oneOhSix)); - } + } void Validate( BytesStructKeyPrincipal[] principals, @@ -922,10 +1008,14 @@ void RunQueries( principals = new[] { - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 1 } })), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = two })), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(three)), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 4, 4, 4, 4 } })) + context.Set().Include(e => e.OptionalDependents).Single( + e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 1 } })), + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = two })), + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(three)), + context.Set().Include(e => e.OptionalDependents).Single( + e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 4, 4, 4, 4 } })) }; var oneOhTwo = new byte[] { 102 }; @@ -935,21 +1025,39 @@ void RunQueries( dependents = new[] { - context.Set().Single(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 101 } })), - context.Set().Single(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = oneOhTwo })), + context.Set().Single( + e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 101 } })), + context.Set().Single( + e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = oneOhTwo })), context.Set().Single(e => e.Id.Equals(oneOhThree)), - context.Set().Single(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 104 } })), - context.Set().Single(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = oneOhFive })), + context.Set().Single( + e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 104 } })), + context.Set().Single( + e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = oneOhFive })), context.Set().Single(e => e.Id.Equals(oneOhSix)) }; - Assert.Same(dependents[0], context.Set().Find(new StructuralComparableBytesStructKey { Id = new byte[] { 101 } })); - Assert.Same(dependents[1], context.Set().Find(new StructuralComparableBytesStructKey { Id = oneOhTwo })); + Assert.Same( + dependents[0], + context.Set() + .Find(new StructuralComparableBytesStructKey { Id = new byte[] { 101 } })); + Assert.Same( + dependents[1], + context.Set() + .Find(new StructuralComparableBytesStructKey { Id = oneOhTwo })); Assert.Same(dependents[2], context.Set().Find(oneOhThree)); - Assert.Same(dependents[3], context.Find(typeof(StructuralComparableBytesStructKeyOptionalDependent), new StructuralComparableBytesStructKey { Id = new byte[] { 104 } })); - Assert.Same(dependents[4], context.Find(typeof(StructuralComparableBytesStructKeyOptionalDependent), new StructuralComparableBytesStructKey { Id = oneOhFive })); + Assert.Same( + dependents[3], + context.Find( + typeof(StructuralComparableBytesStructKeyOptionalDependent), + new StructuralComparableBytesStructKey { Id = new byte[] { 104 } })); + Assert.Same( + dependents[4], + context.Find( + typeof(StructuralComparableBytesStructKeyOptionalDependent), + new StructuralComparableBytesStructKey { Id = oneOhFive })); Assert.Same(dependents[5], context.Find(typeof(StructuralComparableBytesStructKeyOptionalDependent), oneOhSix)); - } + } void Validate( StructuralComparableBytesStructKeyPrincipal[] principals, @@ -962,7 +1070,8 @@ void Validate( dependents, expectedPrincipalToDependents, expectedDependentToPrincipals, - p => ((StructuralComparableBytesStructKeyPrincipal)p).OptionalDependents.Select(d => (IBytesOptionalDependent)d).ToList(), + p => ((StructuralComparableBytesStructKeyPrincipal)p).OptionalDependents.Select(d => (IBytesOptionalDependent)d) + .ToList(), d => ((StructuralComparableBytesStructKeyOptionalDependent)d).Principal); } } @@ -1016,10 +1125,14 @@ void RunQueries( principals = new[] { - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 1 } })), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new ComparableBytesStructKey { Id = two })), - context.Set().Include(e => e.OptionalDependents).ToList().Where(e => e.Id.Equals(three)).ToList().Single(), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 4, 4, 4, 4 } })) + context.Set().Include(e => e.OptionalDependents).Single( + e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 1 } })), + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(new ComparableBytesStructKey { Id = two })), + context.Set().Include(e => e.OptionalDependents).ToList() + .Where(e => e.Id.Equals(three)).ToList().Single(), + context.Set().Include(e => e.OptionalDependents).Single( + e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 4, 4, 4, 4 } })) }; var oneOhTwo = new byte[] { 102 }; @@ -1029,21 +1142,35 @@ void RunQueries( dependents = new[] { - context.Set().Single(e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 101 } })), - context.Set().Single(e => e.Id.Equals(new ComparableBytesStructKey { Id = oneOhTwo })), + context.Set().Single( + e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 101 } })), + context.Set() + .Single(e => e.Id.Equals(new ComparableBytesStructKey { Id = oneOhTwo })), context.Set().Single(e => e.Id.Equals(oneOhThree)), - context.Set().Single(e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 104 } })), - context.Set().Single(e => e.Id.Equals(new ComparableBytesStructKey { Id = oneOhFive })), + context.Set().Single( + e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 104 } })), + context.Set() + .Single(e => e.Id.Equals(new ComparableBytesStructKey { Id = oneOhFive })), context.Set().Single(e => e.Id.Equals(oneOhSix)) }; - Assert.Same(dependents[0], context.Set().Find(new ComparableBytesStructKey { Id = new byte[] { 101 } })); - Assert.Same(dependents[1], context.Set().Find(new ComparableBytesStructKey { Id = oneOhTwo })); + Assert.Same( + dependents[0], + context.Set() + .Find(new ComparableBytesStructKey { Id = new byte[] { 101 } })); + Assert.Same( + dependents[1], + context.Set().Find(new ComparableBytesStructKey { Id = oneOhTwo })); Assert.Same(dependents[2], context.Set().Find(oneOhThree)); - Assert.Same(dependents[3], context.Find(typeof(ComparableBytesStructKeyOptionalDependent), new ComparableBytesStructKey { Id = new byte[] { 104 } })); - Assert.Same(dependents[4], context.Find(typeof(ComparableBytesStructKeyOptionalDependent), new ComparableBytesStructKey { Id = oneOhFive })); + Assert.Same( + dependents[3], + context.Find( + typeof(ComparableBytesStructKeyOptionalDependent), new ComparableBytesStructKey { Id = new byte[] { 104 } })); + Assert.Same( + dependents[4], + context.Find(typeof(ComparableBytesStructKeyOptionalDependent), new ComparableBytesStructKey { Id = oneOhFive })); Assert.Same(dependents[5], context.Find(typeof(ComparableBytesStructKeyOptionalDependent), oneOhSix)); - } + } void Validate( ComparableBytesStructKeyPrincipal[] principals, @@ -1110,10 +1237,14 @@ void RunQueries( principals = new[] { - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 1 } })), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = two })), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(three)), - context.Set().Include(e => e.OptionalDependents).Single(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 4, 4, 4, 4 } })) + context.Set().Include(e => e.OptionalDependents).Single( + e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 1 } })), + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = two })), + context.Set().Include(e => e.OptionalDependents) + .Single(e => e.Id.Equals(three)), + context.Set().Include(e => e.OptionalDependents).Single( + e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 4, 4, 4, 4 } })) }; var oneOhTwo = new byte[] { 102 }; @@ -1123,21 +1254,38 @@ void RunQueries( dependents = new[] { - context.Set().Single(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 101 } })), - context.Set().Single(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = oneOhTwo })), + context.Set().Single( + e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 101 } })), + context.Set().Single( + e => e.Id.Equals(new GenericComparableBytesStructKey { Id = oneOhTwo })), context.Set().Single(e => e.Id.Equals(oneOhThree)), - context.Set().Single(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 104 } })), - context.Set().Single(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = oneOhFive })), + context.Set().Single( + e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 104 } })), + context.Set().Single( + e => e.Id.Equals(new GenericComparableBytesStructKey { Id = oneOhFive })), context.Set().Single(e => e.Id.Equals(oneOhSix)) }; - Assert.Same(dependents[0], context.Set().Find(new GenericComparableBytesStructKey { Id = new byte[] { 101 } })); - Assert.Same(dependents[1], context.Set().Find(new GenericComparableBytesStructKey { Id = oneOhTwo })); + Assert.Same( + dependents[0], + context.Set() + .Find(new GenericComparableBytesStructKey { Id = new byte[] { 101 } })); + Assert.Same( + dependents[1], + context.Set() + .Find(new GenericComparableBytesStructKey { Id = oneOhTwo })); Assert.Same(dependents[2], context.Set().Find(oneOhThree)); - Assert.Same(dependents[3], context.Find(typeof(GenericComparableBytesStructKeyOptionalDependent), new GenericComparableBytesStructKey { Id = new byte[] { 104 } })); - Assert.Same(dependents[4], context.Find(typeof(GenericComparableBytesStructKeyOptionalDependent), new GenericComparableBytesStructKey { Id = oneOhFive })); + Assert.Same( + dependents[3], + context.Find( + typeof(GenericComparableBytesStructKeyOptionalDependent), + new GenericComparableBytesStructKey { Id = new byte[] { 104 } })); + Assert.Same( + dependents[4], + context.Find( + typeof(GenericComparableBytesStructKeyOptionalDependent), new GenericComparableBytesStructKey { Id = oneOhFive })); Assert.Same(dependents[5], context.Find(typeof(GenericComparableBytesStructKeyOptionalDependent), oneOhSix)); - } + } void Validate( GenericComparableBytesStructKeyPrincipal[] principals, @@ -1204,10 +1352,13 @@ void RunQueries( principals = new[] { - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 11 } })), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new BytesStructKey { Id = twelve })), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 11 } })), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(new BytesStructKey { Id = twelve })), context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(thirteen)), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 14, 14, 14, 14 } })) + context.Set().Include(e => e.RequiredDependents).Single( + e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 14, 14, 14, 14 } })) }; var oneTwelve = new byte[] { 112 }; @@ -1217,21 +1368,27 @@ void RunQueries( dependents = new[] { - context.Set().FirstOrDefault(e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 111 } })), - context.Set().FirstOrDefault(e => e.Id.Equals(new BytesStructKey { Id = oneTwelve })), + context.Set() + .FirstOrDefault(e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 111 } })), + context.Set() + .FirstOrDefault(e => e.Id.Equals(new BytesStructKey { Id = oneTwelve })), context.Set().FirstOrDefault(e => e.Id.Equals(oneThirteen)), - context.Set().FirstOrDefault(e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 114 } })), - context.Set().FirstOrDefault(e => e.Id.Equals(new BytesStructKey { Id = oneFifteeen })), + context.Set() + .FirstOrDefault(e => e.Id.Equals(new BytesStructKey { Id = new byte[] { 114 } })), + context.Set() + .FirstOrDefault(e => e.Id.Equals(new BytesStructKey { Id = oneFifteeen })), context.Set().FirstOrDefault(e => e.Id.Equals(oneSixteen)) }; - Assert.Same(dependents[0], context.Set().Find(new BytesStructKey { Id = new byte[] { 111 } })); + Assert.Same( + dependents[0], context.Set().Find(new BytesStructKey { Id = new byte[] { 111 } })); Assert.Same(dependents[1], context.Set().Find(new BytesStructKey { Id = oneTwelve })); Assert.Same(dependents[2], context.Set().Find(oneThirteen)); - Assert.Same(dependents[3], context.Find(typeof(BytesStructKeyRequiredDependent), new BytesStructKey { Id = new byte[] { 114 } })); + Assert.Same( + dependents[3], context.Find(typeof(BytesStructKeyRequiredDependent), new BytesStructKey { Id = new byte[] { 114 } })); Assert.Same(dependents[4], context.Find(typeof(BytesStructKeyRequiredDependent), new BytesStructKey { Id = oneFifteeen })); Assert.Same(dependents[5], context.Find(typeof(BytesStructKeyRequiredDependent), oneSixteen)); - } + } void Validate( BytesStructKeyPrincipal[] principals, @@ -1298,10 +1455,14 @@ void RunQueries( principals = new[] { - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 11 } })), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new ComparableBytesStructKey { Id = twelve })), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(thirteen)), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 14, 14, 14, 14 } })) + context.Set().Include(e => e.RequiredDependents).Single( + e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 11 } })), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(new ComparableBytesStructKey { Id = twelve })), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(thirteen)), + context.Set().Include(e => e.RequiredDependents).Single( + e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 14, 14, 14, 14 } })) }; var oneTwelve = new byte[] { 112 }; @@ -1311,21 +1472,35 @@ void RunQueries( dependents = new[] { - context.Set().FirstOrDefault(e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 111 } })), - context.Set().FirstOrDefault(e => e.Id.Equals(new ComparableBytesStructKey { Id = oneTwelve })), + context.Set().FirstOrDefault( + e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 111 } })), + context.Set() + .FirstOrDefault(e => e.Id.Equals(new ComparableBytesStructKey { Id = oneTwelve })), context.Set().FirstOrDefault(e => e.Id.Equals(oneThirteen)), - context.Set().FirstOrDefault(e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 114 } })), - context.Set().FirstOrDefault(e => e.Id.Equals(new ComparableBytesStructKey { Id = oneFifteeen })), + context.Set().FirstOrDefault( + e => e.Id.Equals(new ComparableBytesStructKey { Id = new byte[] { 114 } })), + context.Set() + .FirstOrDefault(e => e.Id.Equals(new ComparableBytesStructKey { Id = oneFifteeen })), context.Set().FirstOrDefault(e => e.Id.Equals(oneSixteen)) }; - Assert.Same(dependents[0], context.Set().Find(new ComparableBytesStructKey { Id = new byte[] { 111 } })); - Assert.Same(dependents[1], context.Set().Find(new ComparableBytesStructKey { Id = oneTwelve })); + Assert.Same( + dependents[0], + context.Set() + .Find(new ComparableBytesStructKey { Id = new byte[] { 111 } })); + Assert.Same( + dependents[1], + context.Set().Find(new ComparableBytesStructKey { Id = oneTwelve })); Assert.Same(dependents[2], context.Set().Find(oneThirteen)); - Assert.Same(dependents[3], context.Find(typeof(ComparableBytesStructKeyRequiredDependent), new ComparableBytesStructKey { Id = new byte[] { 114 } })); - Assert.Same(dependents[4], context.Find(typeof(ComparableBytesStructKeyRequiredDependent), new ComparableBytesStructKey { Id = oneFifteeen })); + Assert.Same( + dependents[3], + context.Find( + typeof(ComparableBytesStructKeyRequiredDependent), new ComparableBytesStructKey { Id = new byte[] { 114 } })); + Assert.Same( + dependents[4], + context.Find(typeof(ComparableBytesStructKeyRequiredDependent), new ComparableBytesStructKey { Id = oneFifteeen })); Assert.Same(dependents[5], context.Find(typeof(ComparableBytesStructKeyRequiredDependent), oneSixteen)); - } + } void Validate( ComparableBytesStructKeyPrincipal[] principals, @@ -1392,10 +1567,14 @@ void RunQueries( principals = new[] { - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 11 } })), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = twelve })), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(thirteen)), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 14, 14, 14, 14 } })) + context.Set().Include(e => e.RequiredDependents).Single( + e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 11 } })), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = twelve })), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(thirteen)), + context.Set().Include(e => e.RequiredDependents).Single( + e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 14, 14, 14, 14 } })) }; var oneTwelve = new byte[] { 112 }; @@ -1405,21 +1584,39 @@ void RunQueries( dependents = new[] { - context.Set().FirstOrDefault(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 111 } })), - context.Set().FirstOrDefault(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = oneTwelve })), + context.Set().FirstOrDefault( + e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 111 } })), + context.Set().FirstOrDefault( + e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = oneTwelve })), context.Set().FirstOrDefault(e => e.Id.Equals(oneThirteen)), - context.Set().FirstOrDefault(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 114 } })), - context.Set().FirstOrDefault(e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = oneFifteeen })), + context.Set().FirstOrDefault( + e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = new byte[] { 114 } })), + context.Set().FirstOrDefault( + e => e.Id.Equals(new StructuralComparableBytesStructKey { Id = oneFifteeen })), context.Set().FirstOrDefault(e => e.Id.Equals(oneSixteen)) }; - Assert.Same(dependents[0], context.Set().Find(new StructuralComparableBytesStructKey { Id = new byte[] { 111 } })); - Assert.Same(dependents[1], context.Set().Find(new StructuralComparableBytesStructKey { Id = oneTwelve })); + Assert.Same( + dependents[0], + context.Set() + .Find(new StructuralComparableBytesStructKey { Id = new byte[] { 111 } })); + Assert.Same( + dependents[1], + context.Set() + .Find(new StructuralComparableBytesStructKey { Id = oneTwelve })); Assert.Same(dependents[2], context.Set().Find(oneThirteen)); - Assert.Same(dependents[3], context.Find(typeof(StructuralComparableBytesStructKeyRequiredDependent), new StructuralComparableBytesStructKey { Id = new byte[] { 114 } })); - Assert.Same(dependents[4], context.Find(typeof(StructuralComparableBytesStructKeyRequiredDependent), new StructuralComparableBytesStructKey { Id = oneFifteeen })); + Assert.Same( + dependents[3], + context.Find( + typeof(StructuralComparableBytesStructKeyRequiredDependent), + new StructuralComparableBytesStructKey { Id = new byte[] { 114 } })); + Assert.Same( + dependents[4], + context.Find( + typeof(StructuralComparableBytesStructKeyRequiredDependent), + new StructuralComparableBytesStructKey { Id = oneFifteeen })); Assert.Same(dependents[5], context.Find(typeof(StructuralComparableBytesStructKeyRequiredDependent), oneSixteen)); - } + } void Validate( StructuralComparableBytesStructKeyPrincipal[] principals, @@ -1432,7 +1629,8 @@ void Validate( dependents, expectedPrincipalToDependents, expectedDependentToPrincipals, - p => ((StructuralComparableBytesStructKeyPrincipal)p).RequiredDependents.Select(d => (IBytesRequiredDependent)d).ToList(), + p => ((StructuralComparableBytesStructKeyPrincipal)p).RequiredDependents.Select(d => (IBytesRequiredDependent)d) + .ToList(), d => ((StructuralComparableBytesStructKeyRequiredDependent)d).Principal); } } @@ -1486,10 +1684,14 @@ void RunQueries( principals = new[] { - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 11 } })), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = twelve })), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(thirteen)), - context.Set().Include(e => e.RequiredDependents).Single(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 14, 14, 14, 14 } })) + context.Set().Include(e => e.RequiredDependents).Single( + e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 11 } })), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = twelve })), + context.Set().Include(e => e.RequiredDependents) + .Single(e => e.Id.Equals(thirteen)), + context.Set().Include(e => e.RequiredDependents).Single( + e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 14, 14, 14, 14 } })) }; var oneTwelve = new byte[] { 112 }; @@ -1499,21 +1701,39 @@ void RunQueries( dependents = new[] { - context.Set().FirstOrDefault(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 111 } })), - context.Set().FirstOrDefault(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = oneTwelve })), + context.Set().FirstOrDefault( + e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 111 } })), + context.Set().FirstOrDefault( + e => e.Id.Equals(new GenericComparableBytesStructKey { Id = oneTwelve })), context.Set().FirstOrDefault(e => e.Id.Equals(oneThirteen)), - context.Set().FirstOrDefault(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 114 } })), - context.Set().FirstOrDefault(e => e.Id.Equals(new GenericComparableBytesStructKey { Id = oneFifteeen })), + context.Set().FirstOrDefault( + e => e.Id.Equals(new GenericComparableBytesStructKey { Id = new byte[] { 114 } })), + context.Set().FirstOrDefault( + e => e.Id.Equals(new GenericComparableBytesStructKey { Id = oneFifteeen })), context.Set().FirstOrDefault(e => e.Id.Equals(oneSixteen)) }; - Assert.Same(dependents[0], context.Set().Find(new GenericComparableBytesStructKey { Id = new byte[] { 111 } })); - Assert.Same(dependents[1], context.Set().Find(new GenericComparableBytesStructKey { Id = oneTwelve })); + Assert.Same( + dependents[0], + context.Set() + .Find(new GenericComparableBytesStructKey { Id = new byte[] { 111 } })); + Assert.Same( + dependents[1], + context.Set() + .Find(new GenericComparableBytesStructKey { Id = oneTwelve })); Assert.Same(dependents[2], context.Set().Find(oneThirteen)); - Assert.Same(dependents[3], context.Find(typeof(GenericComparableBytesStructKeyRequiredDependent), new GenericComparableBytesStructKey { Id = new byte[] { 114 } })); - Assert.Same(dependents[4], context.Find(typeof(GenericComparableBytesStructKeyRequiredDependent), new GenericComparableBytesStructKey { Id = oneFifteeen })); + Assert.Same( + dependents[3], + context.Find( + typeof(GenericComparableBytesStructKeyRequiredDependent), + new GenericComparableBytesStructKey { Id = new byte[] { 114 } })); + Assert.Same( + dependents[4], + context.Find( + typeof(GenericComparableBytesStructKeyRequiredDependent), + new GenericComparableBytesStructKey { Id = oneFifteeen })); Assert.Same(dependents[5], context.Find(typeof(GenericComparableBytesStructKeyRequiredDependent), oneSixteen)); - } + } void Validate( GenericComparableBytesStructKeyPrincipal[] principals, @@ -1585,41 +1805,41 @@ protected void ValidateOptional( Func> getDependents, Func getPrincipal) { - Assert.Equal(4, principals.Count); - for (var i = 0; i < 4; i++) - { - Assert.Equal(i + 1, principals[i].BackingId); - } + Assert.Equal(4, principals.Count); + for (var i = 0; i < 4; i++) + { + Assert.Equal(i + 1, principals[i].BackingId); + } + + Assert.Equal(6, dependents.Count); + for (var i = 0; i < 6; i++) + { + Assert.Equal(i + 101, dependents[i].BackingId); + } - Assert.Equal(6, dependents.Count); - for (var i = 0; i < 6; i++) + foreach (var (dependentIndex, principalIndex) in expectedDependentToPrincipals) + { + if (principalIndex.HasValue) { - Assert.Equal(i + 101, dependents[i].BackingId); + Assert.Same(principals[principalIndex.Value], getPrincipal(dependents[dependentIndex])); + Assert.Equal(principals[principalIndex.Value].BackingId, dependents[dependentIndex].BackingPrincipalId); } - - foreach (var (dependentIndex, principalIndex) in expectedDependentToPrincipals) + else { - if (principalIndex.HasValue) - { - Assert.Same(principals[principalIndex.Value], getPrincipal(dependents[dependentIndex])); - Assert.Equal(principals[principalIndex.Value].BackingId, dependents[dependentIndex].BackingPrincipalId); - } - else - { - Assert.Null(getPrincipal(dependents[dependentIndex])); - Assert.Null(dependents[dependentIndex].BackingPrincipalId); - } + Assert.Null(getPrincipal(dependents[dependentIndex])); + Assert.Null(dependents[dependentIndex].BackingPrincipalId); } + } - foreach (var (principalIndex, dependentIndexes) in expectedPrincipalToDependents) + foreach (var (principalIndex, dependentIndexes) in expectedPrincipalToDependents) + { + Assert.Equal(dependentIndexes.Length, getDependents(principals[principalIndex]).Count); + foreach (var dependentIndex in dependentIndexes) { - Assert.Equal(dependentIndexes.Length, getDependents(principals[principalIndex]).Count); - foreach (var dependentIndex in dependentIndexes) - { - Assert.Same(principals[principalIndex], getPrincipal(dependents[dependentIndex])); - Assert.Equal(principals[principalIndex].BackingId, dependents[dependentIndex].BackingPrincipalId); - } + Assert.Same(principals[principalIndex], getPrincipal(dependents[dependentIndex])); + Assert.Equal(principals[principalIndex].BackingId, dependents[dependentIndex].BackingPrincipalId); } + } } protected void ValidateRequired( @@ -1630,36 +1850,36 @@ protected void ValidateRequired( Func> getDependents, Func getPrincipal) { - Assert.Equal(4, principals.Count); - for (var i = 0; i < 4; i++) - { - Assert.Equal(i + 11, principals[i].BackingId); - } + Assert.Equal(4, principals.Count); + for (var i = 0; i < 4; i++) + { + Assert.Equal(i + 11, principals[i].BackingId); + } - Assert.Equal(6, dependents.Count); - for (var i = 0; i < 6; i++) + Assert.Equal(6, dependents.Count); + for (var i = 0; i < 6; i++) + { + if (dependents[i] != null) { - if (dependents[i] != null) - { - Assert.Equal(i + 111, dependents[i].BackingId); - } + Assert.Equal(i + 111, dependents[i].BackingId); } + } + + foreach (var (dependentIndex, principalIndex) in expectedDependentToPrincipals) + { + Assert.Same(principals[principalIndex], getPrincipal(dependents[dependentIndex])); + Assert.Equal(principals[principalIndex].BackingId, dependents[dependentIndex].BackingPrincipalId); + } - foreach (var (dependentIndex, principalIndex) in expectedDependentToPrincipals) + foreach (var (principalIndex, dependentIndexes) in expectedPrincipalToDependents) + { + Assert.Equal(dependentIndexes.Length, getDependents(principals[principalIndex]).Count); + foreach (var dependentIndex in dependentIndexes) { Assert.Same(principals[principalIndex], getPrincipal(dependents[dependentIndex])); Assert.Equal(principals[principalIndex].BackingId, dependents[dependentIndex].BackingPrincipalId); } - - foreach (var (principalIndex, dependentIndexes) in expectedPrincipalToDependents) - { - Assert.Equal(dependentIndexes.Length, getDependents(principals[principalIndex]).Count); - foreach (var dependentIndex in dependentIndexes) - { - Assert.Same(principals[principalIndex], getPrincipal(dependents[dependentIndex])); - Assert.Equal(principals[principalIndex].BackingId, dependents[dependentIndex].BackingPrincipalId); - } - } + } } private void InsertOptionalBytesGraph() @@ -1714,43 +1934,43 @@ protected void ValidateOptionalBytes( Func> getDependents, Func getPrincipal) { - Assert.Equal(4, principals.Count); - Assert.Equal(new byte[] { 1 }, principals[0].BackingId); - Assert.Equal(new byte[] { 2, 2 }, principals[1].BackingId); - Assert.Equal(new byte[] { 3, 3, 3 }, principals[2].BackingId); - Assert.Equal(new byte[] { 4, 4, 4, 4 }, principals[3].BackingId); - - Assert.Equal(6, dependents.Count); - Assert.Equal(new byte[] { 101 }, dependents[0].BackingId); - Assert.Equal(new byte[] { 102 }, dependents[1].BackingId); - Assert.Equal(new byte[] { 103 }, dependents[2].BackingId); - Assert.Equal(new byte[] { 104 }, dependents[3].BackingId); - Assert.Equal(new byte[] { 105 }, dependents[4].BackingId); - Assert.Equal(new byte[] { 106 }, dependents[5].BackingId); - - foreach (var (dependentIndex, principalIndex) in expectedDependentToPrincipals) + Assert.Equal(4, principals.Count); + Assert.Equal(new byte[] { 1 }, principals[0].BackingId); + Assert.Equal(new byte[] { 2, 2 }, principals[1].BackingId); + Assert.Equal(new byte[] { 3, 3, 3 }, principals[2].BackingId); + Assert.Equal(new byte[] { 4, 4, 4, 4 }, principals[3].BackingId); + + Assert.Equal(6, dependents.Count); + Assert.Equal(new byte[] { 101 }, dependents[0].BackingId); + Assert.Equal(new byte[] { 102 }, dependents[1].BackingId); + Assert.Equal(new byte[] { 103 }, dependents[2].BackingId); + Assert.Equal(new byte[] { 104 }, dependents[3].BackingId); + Assert.Equal(new byte[] { 105 }, dependents[4].BackingId); + Assert.Equal(new byte[] { 106 }, dependents[5].BackingId); + + foreach (var (dependentIndex, principalIndex) in expectedDependentToPrincipals) + { + if (principalIndex.HasValue) { - if (principalIndex.HasValue) - { - Assert.Same(principals[principalIndex.Value], getPrincipal(dependents[dependentIndex])); - Assert.Equal(principals[principalIndex.Value].BackingId, dependents[dependentIndex].BackingPrincipalId); - } - else - { - Assert.Null(getPrincipal(dependents[dependentIndex])); - Assert.Null(dependents[dependentIndex].BackingPrincipalId); - } + Assert.Same(principals[principalIndex.Value], getPrincipal(dependents[dependentIndex])); + Assert.Equal(principals[principalIndex.Value].BackingId, dependents[dependentIndex].BackingPrincipalId); + } + else + { + Assert.Null(getPrincipal(dependents[dependentIndex])); + Assert.Null(dependents[dependentIndex].BackingPrincipalId); } + } - foreach (var (principalIndex, dependentIndexes) in expectedPrincipalToDependents) + foreach (var (principalIndex, dependentIndexes) in expectedPrincipalToDependents) + { + Assert.Equal(dependentIndexes.Length, getDependents(principals[principalIndex]).Count); + foreach (var dependentIndex in dependentIndexes) { - Assert.Equal(dependentIndexes.Length, getDependents(principals[principalIndex]).Count); - foreach (var dependentIndex in dependentIndexes) - { - Assert.Same(principals[principalIndex], getPrincipal(dependents[dependentIndex])); - Assert.Equal(principals[principalIndex].BackingId, dependents[dependentIndex].BackingPrincipalId); - } + Assert.Same(principals[principalIndex], getPrincipal(dependents[dependentIndex])); + Assert.Equal(principals[principalIndex].BackingId, dependents[dependentIndex].BackingPrincipalId); } + } } protected void ValidateRequiredBytes( @@ -1773,12 +1993,14 @@ protected void ValidateRequiredBytes( { Assert.Equal(new byte[] { 112 }, dependents[1].BackingId); } + Assert.Equal(new byte[] { 113 }, dependents[2].BackingId); Assert.Equal(new byte[] { 114 }, dependents[3].BackingId); if (dependents[4] != null) { Assert.Equal(new byte[] { 115 }, dependents[4].BackingId); } + Assert.Equal(new byte[] { 116 }, dependents[5].BackingId); foreach (var (dependentIndex, principalIndex) in expectedDependentToPrincipals) @@ -1896,7 +2118,8 @@ public int CompareTo(GenericComparableIntStructKey other) protected struct GenericComparableBytesStructKey : IComparable { public static ValueConverter Converter - = new ValueConverter(v => v.Id, v => new GenericComparableBytesStructKey { Id = v }); + = new ValueConverter( + v => v.Id, v => new GenericComparableBytesStructKey { Id = v }); public byte[] Id { get; set; } @@ -1933,7 +2156,8 @@ public int CompareTo(GenericComparableBytesStructKey other) protected struct StructuralComparableBytesStructKey : IStructuralComparable { public static ValueConverter Converter - = new ValueConverter(v => v.Id, v => new StructuralComparableBytesStructKey { Id = v }); + = new ValueConverter( + v => v.Id, v => new StructuralComparableBytesStructKey { Id = v }); public byte[] Id { get; set; } @@ -1987,7 +2211,8 @@ public override bool Equals(object obj) || obj?.GetType() == GetType() && Equals((IntClassKey)obj); - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; public int Id { get; set; } } @@ -2007,7 +2232,9 @@ public override bool Equals(object obj) || obj?.GetType() == GetType() && Equals((ComparableIntClassKey)obj); - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; + public int CompareTo(object other) => Id - ((ComparableIntClassKey)other).Id; } @@ -2027,7 +2254,9 @@ public override bool Equals(object obj) || obj?.GetType() == GetType() && Equals((GenericComparableIntClassKey)obj); - public override int GetHashCode() => Id; + public override int GetHashCode() + => Id; + public int CompareTo(GenericComparableIntClassKey other) => Id - other.Id; } @@ -2328,7 +2557,10 @@ public int BackingId public int? BackingPrincipalId { get => PrincipalId?.Id; - set => PrincipalId = value.HasValue ? new GenericComparableIntStructKey { Id = value.Value } : (GenericComparableIntStructKey?)null; + set + => PrincipalId = value.HasValue + ? new GenericComparableIntStructKey { Id = value.Value } + : (GenericComparableIntStructKey?)null; } } @@ -2385,7 +2617,10 @@ public byte[] BackingId public byte[] BackingPrincipalId { get => PrincipalId?.Id; - set => PrincipalId = value != null ? new GenericComparableBytesStructKey { Id = value } : (GenericComparableBytesStructKey?)null; + set + => PrincipalId = value != null + ? new GenericComparableBytesStructKey { Id = value } + : (GenericComparableBytesStructKey?)null; } } @@ -2442,7 +2677,10 @@ public byte[] BackingId public byte[] BackingPrincipalId { get => PrincipalId?.Id; - set => PrincipalId = value != null ? new StructuralComparableBytesStructKey { Id = value } : (StructuralComparableBytesStructKey?)null; + set + => PrincipalId = value != null + ? new StructuralComparableBytesStructKey { Id = value } + : (StructuralComparableBytesStructKey?)null; } } diff --git a/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs b/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs index ad6ea197d1f..ae999e07e9e 100644 --- a/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs +++ b/test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs @@ -4,10 +4,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; -using System.IO; using System.Linq; -using System.Text.Json; -using System.Text.Json.Serialization; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; @@ -16,6 +13,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; +using Newtonsoft.Json; using Xunit; // ReSharper disable InconsistentNaming @@ -24,7 +22,8 @@ namespace Microsoft.EntityFrameworkCore public abstract class LazyLoadProxyTestBase : IClassFixture where TFixture : LazyLoadProxyTestBase.LoadFixtureBase { - protected LazyLoadProxyTestBase(TFixture fixture) => Fixture = fixture; + protected LazyLoadProxyTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -1127,7 +1126,8 @@ public virtual void Lazy_load_collection_already_loaded(EntityState state, Casca [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) + EntityState state, + CascadeTiming cascadeDeleteTiming) { using var context = CreateContext(lazyLoadingEnabled: true); context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; @@ -1212,7 +1212,8 @@ public virtual void Lazy_load_one_to_one_reference_to_principal_already_loaded(E [InlineData(EntityState.Modified, CascadeTiming.Never)] [InlineData(EntityState.Deleted, CascadeTiming.Never)] public virtual void Lazy_load_one_to_one_reference_to_dependent_already_loaded( - EntityState state, CascadeTiming cascadeDeleteTiming) + EntityState state, + CascadeTiming cascadeDeleteTiming) { using var context = CreateContext(lazyLoadingEnabled: true); context.ChangeTracker.CascadeDeleteTiming = cascadeDeleteTiming; @@ -2046,14 +2047,12 @@ public virtual void Can_serialize_proxies_to_JSON() Assert.IsNotType(blog); } - var serialized = Newtonsoft.Json.JsonConvert.SerializeObject( - blogs, new Newtonsoft.Json.JsonSerializerSettings - { - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore, - Formatting = Newtonsoft.Json.Formatting.Indented - }); + var serialized = JsonConvert.SerializeObject( + blogs, + new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore, Formatting = Formatting.Indented }); - Assert.Equal(@"[ + Assert.Equal( + @"[ { ""Writer"": { ""FirstName"": ""firstNameWriter0"", @@ -2098,7 +2097,7 @@ public virtual void Can_serialize_proxies_to_JSON() } ]", serialized, ignoreLineEndingDifferences: true); - var newBlogs = Newtonsoft.Json.JsonConvert.DeserializeObject>(serialized); + var newBlogs = JsonConvert.DeserializeObject>(serialized); VerifyBlogs(newBlogs); foreach (var blog in newBlogs) @@ -2226,7 +2225,8 @@ public virtual void Lazy_loading_finds_correct_entity_type_with_opaque_predicate using var context = CreateContext(lazyLoadingEnabled: true); // ReSharper disable once ConvertToLocalFunction - bool opaquePredicate(Blog _) => true; + bool opaquePredicate(Blog _) + => true; var blogs = context.Set().Where(opaquePredicate); @@ -2499,6 +2499,7 @@ public int IdLoadedFromParent set => _backing = value; } } + public class Child { [DatabaseGenerated(DatabaseGeneratedOption.None)] @@ -2766,7 +2767,8 @@ protected override IServiceCollection AddServices(IServiceCollection serviceColl .AddEntityFrameworkProxies()); // By-design. Lazy loaders are not disposed when using pooling - protected override bool UsePooling => false; + protected override bool UsePooling + => false; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { @@ -2946,10 +2948,8 @@ protected override void Seed(DbContext context) 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 } - }, + ChildrenCompositeKey = + new List { new ChildCompositeKey { Id = 51 }, new ChildCompositeKey { Id = 52 } }, SingleCompositeKey = new SingleCompositeKey { Id = 62 }, WithRecursiveProperty = new WithRecursiveProperty { Id = 8086 } }); @@ -3014,25 +3014,17 @@ protected override void Seed(DbContext context) context.Add( new NonVirtualOneToOneOwner { - Id = 100, - Address = new OwnedAddress { Street = "Paradise Alley", PostalCode = "WEEEEEE" } + Id = 100, Address = new OwnedAddress { Street = "Paradise Alley", PostalCode = "WEEEEEE" } }); context.Add( - new VirtualOneToOneOwner - { - Id = 200, - Address = new OwnedAddress { Street = "Dead End", PostalCode = "N0 WA1R" } - }); + new VirtualOneToOneOwner { Id = 200, Address = new OwnedAddress { Street = "Dead End", PostalCode = "N0 WA1R" } }); context.Add( new NonVirtualOneToManyOwner { Id = 300, - Addresses = new List - { - new OwnedAddress { Street = "4 Privet Drive", PostalCode = "SURREY" } - } + Addresses = new List { new OwnedAddress { Street = "4 Privet Drive", PostalCode = "SURREY" } } }); context.Add( @@ -3040,21 +3032,18 @@ protected override void Seed(DbContext context) { Id = 400, Addresses = new List - { - new OwnedAddress { Street = "The Ministry", PostalCode = "MAG1C" }, - new OwnedAddress { Street = "Diagon Alley", PostalCode = "WC2H 0AW" }, - new OwnedAddress { Street = "Shell Cottage", PostalCode = "THE SEA" } - } + { + new OwnedAddress { Street = "The Ministry", PostalCode = "MAG1C" }, + new OwnedAddress { Street = "Diagon Alley", PostalCode = "WC2H 0AW" }, + new OwnedAddress { Street = "Shell Cottage", PostalCode = "THE SEA" } + } }); context.Add( new ExplicitLazyLoadNonVirtualOneToManyOwner { Id = 500, - Addresses = new List - { - new OwnedAddress { Street = "Spinner's End", PostalCode = "BE WA1R" } - } + Addresses = new List { new OwnedAddress { Street = "Spinner's End", PostalCode = "BE WA1R" } } }); context.Add( @@ -3062,9 +3051,9 @@ protected override void Seed(DbContext context) { Id = 600, Addresses = new List - { - new OwnedAddress { Street = "12 Grimmauld Place", PostalCode = "L0N D0N" } - } + { + new OwnedAddress { Street = "12 Grimmauld Place", PostalCode = "L0N D0N" } + } }); context.SaveChanges(); diff --git a/test/EFCore.Specification.Tests/LoadTestBase.cs b/test/EFCore.Specification.Tests/LoadTestBase.cs index b15edfcb0af..d72b95e9b91 100644 --- a/test/EFCore.Specification.Tests/LoadTestBase.cs +++ b/test/EFCore.Specification.Tests/LoadTestBase.cs @@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Diagnostics.Internal; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.EntityFrameworkCore.TestUtilities; +using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -22,7 +22,8 @@ namespace Microsoft.EntityFrameworkCore public abstract class LoadTestBase : IClassFixture where TFixture : LoadTestBase.LoadFixtureBase { - protected LoadTestBase(TFixture fixture) => Fixture = fixture; + protected LoadTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -131,10 +132,7 @@ public virtual void Attached_collections_are_not_marked_as_loaded(EntityState st Children = new List { new Child { Id = 11 }, new Child { Id = 12 } }, ChildrenAk = new List { new ChildAk { Id = 31 }, new ChildAk { Id = 32 } }, ChildrenShadowFk = new List { new ChildShadowFk { Id = 51 }, new ChildShadowFk { Id = 52 } }, - ChildrenCompositeKey = new List - { - new ChildCompositeKey { Id = 51 }, new ChildCompositeKey { Id = 52 } - } + ChildrenCompositeKey = new List { new ChildCompositeKey { Id = 51 }, new ChildCompositeKey { Id = 52 } } }; context.Attach(parent); @@ -2526,7 +2524,9 @@ public virtual async Task Load_many_to_one_reference_to_principal_already_loaded [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) + EntityState state, + bool async, + CascadeTiming deleteOrphansTiming) { using var context = CreateContext(); context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; @@ -2576,7 +2576,9 @@ public virtual async Task Load_one_to_one_reference_to_principal_already_loaded( [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) + EntityState state, + bool async, + CascadeTiming deleteOrphansTiming) { using var context = CreateContext(); context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; @@ -2717,7 +2719,9 @@ public virtual async Task Load_one_to_one_PK_to_PK_reference_to_dependent_alread [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) + EntityState state, + bool async, + CascadeTiming deleteOrphansTiming) { using var context = CreateContext(); context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; @@ -2832,7 +2836,9 @@ public virtual async Task Load_one_to_one_reference_to_principal_using_Query_alr [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) + EntityState state, + bool async, + CascadeTiming deleteOrphansTiming) { using var context = CreateContext(); context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; @@ -3689,7 +3695,9 @@ public virtual async Task Load_one_to_one_reference_to_principal_already_loaded_ [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) + EntityState state, + bool async, + CascadeTiming deleteOrphansTiming) { using var context = CreateContext(); context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; @@ -3748,7 +3756,9 @@ public virtual async Task Load_one_to_one_reference_to_dependent_already_loaded_ [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) + EntityState state, + bool async, + CascadeTiming deleteOrphansTiming) { using var context = CreateContext(); context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; @@ -3866,7 +3876,9 @@ public virtual async Task Load_one_to_one_reference_to_principal_using_Query_alr [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) + EntityState state, + bool async, + CascadeTiming deleteOrphansTiming) { using var context = CreateContext(); context.ChangeTracker.DeleteOrphansTiming = deleteOrphansTiming; diff --git a/test/EFCore.Specification.Tests/LoggingTestBase.cs b/test/EFCore.Specification.Tests/LoggingTestBase.cs index 4f61c3d2682..11795a680f9 100644 --- a/test/EFCore.Specification.Tests/LoggingTestBase.cs +++ b/test/EFCore.Specification.Tests/LoggingTestBase.cs @@ -49,7 +49,8 @@ protected virtual string ExpectedMessage(string optionsFragment) protected abstract string ProviderName { get; } - protected virtual string DefaultOptions => null; + protected virtual string DefaultOptions + => null; protected virtual string ActualMessage(Func optionsActions) { diff --git a/test/EFCore.Specification.Tests/ManyToManyLoadTestBase.cs b/test/EFCore.Specification.Tests/ManyToManyLoadTestBase.cs index 4ac37d95bc4..3409e5a41f9 100644 --- a/test/EFCore.Specification.Tests/ManyToManyLoadTestBase.cs +++ b/test/EFCore.Specification.Tests/ManyToManyLoadTestBase.cs @@ -17,7 +17,8 @@ namespace Microsoft.EntityFrameworkCore public abstract class ManyToManyLoadTestBase : IClassFixture where TFixture : ManyToManyLoadTestBase.ManyToManyLoadFixtureBase { - protected ManyToManyLoadTestBase(TFixture fixture) => Fixture = fixture; + protected ManyToManyLoadTestBase(TFixture fixture) + => Fixture = fixture; [ConditionalTheory] [InlineData(EntityState.Unchanged, QueryTrackingBehavior.TrackAll, true)] @@ -180,7 +181,6 @@ public virtual void Attached_collections_are_not_marked_as_loaded(EntityState st } context.Entry(left).State = state; - } context.ChangeTracker.LazyLoadingEnabled = true; @@ -539,7 +539,9 @@ public virtual async Task Load_collection_already_loaded_untyped(EntityState sta [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) + EntityState state, + bool async, + CascadeTiming deleteOrphansTiming) { using var context = Fixture.CreateContext(); @@ -736,7 +738,8 @@ protected virtual void RecordLog() protected TFixture Fixture { get; } - protected virtual bool ExpectLazyLoading => false; + protected virtual bool ExpectLazyLoading + => false; public abstract class ManyToManyLoadFixtureBase : ManyToManyQueryFixtureBase { diff --git a/test/EFCore.Specification.Tests/ManyToManyTrackingTestBase.cs b/test/EFCore.Specification.Tests/ManyToManyTrackingTestBase.cs index 56ecf807aa9..d81c8e86e02 100644 --- a/test/EFCore.Specification.Tests/ManyToManyTrackingTestBase.cs +++ b/test/EFCore.Specification.Tests/ManyToManyTrackingTestBase.cs @@ -125,24 +125,30 @@ public virtual void Can_update_many_to_many_composite_with_navs() leftEntities[0].LeafSkipFull.Add(context.Set().CreateInstance(e => e.Id = 7722)); leftEntities[0].LeafSkipFull.Add(context.Set().CreateInstance(e => e.Id = 7723)); - rightEntities[0].CompositeKeySkipFull.Add(context.EntityCompositeKeys.CreateInstance(e => - { - e.Key1 = 7711; - e.Key2 = "7711"; - e.Key3 = new DateTime(7711, 1, 1); - })); - rightEntities[0].CompositeKeySkipFull.Add(context.EntityCompositeKeys.CreateInstance(e => - { - e.Key1 = 7712; - e.Key2 = "7712"; - e.Key3 = new DateTime(7712, 1, 1); - })); - rightEntities[0].CompositeKeySkipFull.Add(context.EntityCompositeKeys.CreateInstance(e => - { - e.Key1 = 7713; - e.Key2 = "7713"; - e.Key3 = new DateTime(7713, 1, 1); - })); + rightEntities[0].CompositeKeySkipFull.Add( + context.EntityCompositeKeys.CreateInstance( + e => + { + e.Key1 = 7711; + e.Key2 = "7711"; + e.Key3 = new DateTime(7711, 1, 1); + })); + rightEntities[0].CompositeKeySkipFull.Add( + context.EntityCompositeKeys.CreateInstance( + e => + { + e.Key1 = 7712; + e.Key2 = "7712"; + e.Key3 = new DateTime(7712, 1, 1); + })); + rightEntities[0].CompositeKeySkipFull.Add( + context.EntityCompositeKeys.CreateInstance( + e => + { + e.Key1 = 7713; + e.Key2 = "7713"; + e.Key3 = new DateTime(7713, 1, 1); + })); leftEntities[0].LeafSkipFull.Remove(leftEntities[0].LeafSkipFull.Single(e => e.Id == 21)); rightEntities[1].CompositeKeySkipFull.Remove(rightEntities[1].CompositeKeySkipFull.Single(e => e.Key2 == "3_1")); @@ -151,12 +157,14 @@ public virtual void Can_update_many_to_many_composite_with_navs() leftEntities[2].LeafSkipFull.Add(context.Set().CreateInstance(e => e.Id = 7724)); rightEntities[2].CompositeKeySkipFull.Remove(rightEntities[2].CompositeKeySkipFull.Single(e => e.Key2 == "8_3")); - rightEntities[2].CompositeKeySkipFull.Add(context.EntityCompositeKeys.CreateInstance(e => - { - e.Key1 = 7714; - e.Key2 = "7714"; - e.Key3 = new DateTime(7714, 1, 1); - })); + rightEntities[2].CompositeKeySkipFull.Add( + context.EntityCompositeKeys.CreateInstance( + e => + { + e.Key1 = 7714; + e.Key2 = "7714"; + e.Key3 = new DateTime(7714, 1, 1); + })); if (RequiresDetectChanges) { @@ -481,6 +489,7 @@ static void ValidateFixup(DbContext context, IList leftEntit Assert.Single(rightEntities[2].CompositeKeySkipShared); } } + [ConditionalFact] public virtual void Can_update_many_to_many_composite_shared_with_navs() { @@ -494,24 +503,30 @@ public virtual void Can_update_many_to_many_composite_shared_with_navs() leftEntities[0].RootSkipShared.Add(context.Set().CreateInstance(e => e.Id = 7722)); leftEntities[0].RootSkipShared.Add(context.Set().CreateInstance(e => e.Id = 7723)); - rightEntities[0].CompositeKeySkipShared.Add(context.EntityCompositeKeys.CreateInstance(e => - { - e.Key1 = 7711; - e.Key2 = "7711"; - e.Key3 = new DateTime(7711, 1, 1); - })); - rightEntities[0].CompositeKeySkipShared.Add(context.EntityCompositeKeys.CreateInstance(e => - { - e.Key1 = 7712; - e.Key2 = "7712"; - e.Key3 = new DateTime(7712, 1, 1); - })); - rightEntities[0].CompositeKeySkipShared.Add(context.EntityCompositeKeys.CreateInstance(e => - { - e.Key1 = 7713; - e.Key2 = "7713"; - e.Key3 = new DateTime(7713, 1, 1); - })); + rightEntities[0].CompositeKeySkipShared.Add( + context.EntityCompositeKeys.CreateInstance( + e => + { + e.Key1 = 7711; + e.Key2 = "7711"; + e.Key3 = new DateTime(7711, 1, 1); + })); + rightEntities[0].CompositeKeySkipShared.Add( + context.EntityCompositeKeys.CreateInstance( + e => + { + e.Key1 = 7712; + e.Key2 = "7712"; + e.Key3 = new DateTime(7712, 1, 1); + })); + rightEntities[0].CompositeKeySkipShared.Add( + context.EntityCompositeKeys.CreateInstance( + e => + { + e.Key1 = 7713; + e.Key2 = "7713"; + e.Key3 = new DateTime(7713, 1, 1); + })); leftEntities[0].RootSkipShared.Remove(leftEntities[0].RootSkipShared.Single(e => e.Id == 9)); rightEntities[1].CompositeKeySkipShared.Remove(rightEntities[1].CompositeKeySkipShared.Single(e => e.Key2 == "8_3")); @@ -520,12 +535,14 @@ public virtual void Can_update_many_to_many_composite_shared_with_navs() leftEntities[2].RootSkipShared.Add(context.Set().CreateInstance(e => e.Id = 7724)); rightEntities[2].CompositeKeySkipShared.Remove(rightEntities[2].CompositeKeySkipShared.Single(e => e.Key2 == "8_2")); - rightEntities[2].CompositeKeySkipShared.Add(context.EntityCompositeKeys.CreateInstance(e => - { - e.Key1 = 7714; - e.Key2 = "7714"; - e.Key3 = new DateTime(7714, 1, 1); - })); + rightEntities[2].CompositeKeySkipShared.Add( + context.EntityCompositeKeys.CreateInstance( + e => + { + e.Key1 = 7714; + e.Key2 = "7714"; + e.Key3 = new DateTime(7714, 1, 1); + })); if (RequiresDetectChanges) { @@ -811,24 +828,30 @@ public virtual void Can_update_many_to_many_composite_additional_pk_with_navs() leftEntities[0].ThreeSkipFull.Add(context.Set().CreateInstance(e => e.Id = 7722)); leftEntities[0].ThreeSkipFull.Add(context.Set().CreateInstance(e => e.Id = 7723)); - rightEntities[0].CompositeKeySkipFull.Add(context.EntityCompositeKeys.CreateInstance(e => - { - e.Key1 = 7711; - e.Key2 = "7711"; - e.Key3 = new DateTime(7711, 1, 1); - })); - rightEntities[0].CompositeKeySkipFull.Add(context.EntityCompositeKeys.CreateInstance(e => - { - e.Key1 = 7712; - e.Key2 = "7712"; - e.Key3 = new DateTime(7712, 1, 1); - })); - rightEntities[0].CompositeKeySkipFull.Add(context.EntityCompositeKeys.CreateInstance(e => - { - e.Key1 = 7713; - e.Key2 = "7713"; - e.Key3 = new DateTime(7713, 1, 1); - })); + rightEntities[0].CompositeKeySkipFull.Add( + context.EntityCompositeKeys.CreateInstance( + e => + { + e.Key1 = 7711; + e.Key2 = "7711"; + e.Key3 = new DateTime(7711, 1, 1); + })); + rightEntities[0].CompositeKeySkipFull.Add( + context.EntityCompositeKeys.CreateInstance( + e => + { + e.Key1 = 7712; + e.Key2 = "7712"; + e.Key3 = new DateTime(7712, 1, 1); + })); + rightEntities[0].CompositeKeySkipFull.Add( + context.EntityCompositeKeys.CreateInstance( + e => + { + e.Key1 = 7713; + e.Key2 = "7713"; + e.Key3 = new DateTime(7713, 1, 1); + })); leftEntities[0].ThreeSkipFull.Remove(leftEntities[0].ThreeSkipFull.Single(e => e.Id == 2)); rightEntities[1].CompositeKeySkipFull.Remove(rightEntities[1].CompositeKeySkipFull.Single(e => e.Key2 == "9_2")); @@ -837,12 +860,14 @@ public virtual void Can_update_many_to_many_composite_additional_pk_with_navs() leftEntities[3].ThreeSkipFull.Add(context.Set().CreateInstance(e => e.Id = 7724)); rightEntities[2].CompositeKeySkipFull.Remove(rightEntities[2].CompositeKeySkipFull.Single(e => e.Key2 == "6_1")); - rightEntities[2].CompositeKeySkipFull.Add(context.EntityCompositeKeys.CreateInstance(e => - { - e.Key1 = 7714; - e.Key2 = "7714"; - e.Key3 = new DateTime(7714, 1, 1); - })); + rightEntities[2].CompositeKeySkipFull.Add( + context.EntityCompositeKeys.CreateInstance( + e => + { + e.Key1 = 7714; + e.Key2 = "7714"; + e.Key3 = new DateTime(7714, 1, 1); + })); if (RequiresDetectChanges) { @@ -2530,15 +2555,15 @@ public virtual void Can_insert_many_to_many() { var leftEntities = new[] { - context.EntityOnes.CreateInstance(e => e.Id = 7711 ), - context.EntityOnes.CreateInstance(e => e.Id = 7712 ), - context.EntityOnes.CreateInstance(e => e.Id = 7713 ) + context.EntityOnes.CreateInstance(e => e.Id = 7711), + context.EntityOnes.CreateInstance(e => e.Id = 7712), + context.EntityOnes.CreateInstance(e => e.Id = 7713) }; var rightEntities = new[] { - context.EntityTwos.CreateInstance(e => e.Id = 7721 ), - context.EntityTwos.CreateInstance(e => e.Id = 7722 ), - context.EntityTwos.CreateInstance(e => e.Id = 7723 ) + context.EntityTwos.CreateInstance(e => e.Id = 7721), + context.EntityTwos.CreateInstance(e => e.Id = 7722), + context.EntityTwos.CreateInstance(e => e.Id = 7723) }; leftEntities[0].TwoSkip.Add(rightEntities[0]); // 11 - 21 @@ -2819,8 +2844,10 @@ public virtual void Can_insert_many_to_many_fully_by_convention() Assert.Equal(3, context.ChangeTracker.Entries().Count()); Assert.Equal(5, context.ChangeTracker.Entries>().Count()); - var leftEntities = context.ChangeTracker.Entries().Select(e => e.Entity).OrderBy(e => e.Id).ToList(); - var rightEntities = context.ChangeTracker.Entries().Select(e => e.Entity).OrderBy(e => e.Id).ToList(); + var leftEntities = context.ChangeTracker.Entries().Select(e => e.Entity).OrderBy(e => e.Id) + .ToList(); + var rightEntities = context.ChangeTracker.Entries().Select(e => e.Entity).OrderBy(e => e.Id) + .ToList(); Assert.Equal(3, leftEntities[0].Bs.Count); Assert.Single(leftEntities[1].Bs); @@ -2884,8 +2911,10 @@ public virtual void Initial_tracking_uses_skip_navigations() var results = context.Set().Where(e => e.Id > 7700).Include(e => e.Bs).ToList(); Assert.Equal(3, results.Count); - var leftEntities = context.ChangeTracker.Entries().Select(e => e.Entity).OrderBy(e => e.Id).ToList(); - var rightEntities = context.ChangeTracker.Entries().Select(e => e.Entity).OrderBy(e => e.Id).ToList(); + var leftEntities = context.ChangeTracker.Entries().Select(e => e.Entity).OrderBy(e => e.Id) + .ToList(); + var rightEntities = context.ChangeTracker.Entries().Select(e => e.Entity).OrderBy(e => e.Id) + .ToList(); ValidateFixup(context, leftEntities, rightEntities); }); @@ -2922,6 +2951,7 @@ public virtual void Can_load_entities_in_any_order(int[] order) { (i switch { + // ReSharper disable once RedundantCast 1 => (IQueryable)context.Set(), 2 => context.Set(), 3 => context.Set(), @@ -2980,7 +3010,7 @@ public void Can_insert_update_delete_shared_type_entity_type() context => { var entity = context.Set>("JoinOneToThreePayloadFullShared") - .Single(e => (int)e["OneId"] == 1 && (int)e["ThreeId"] == 1); + .Single(e => (int)e["OneId"] == 1 && (int)e["ThreeId"] == 1); Assert.Equal("NewlyAdded", (string)entity["Payload"]); @@ -2993,7 +3023,7 @@ public void Can_insert_update_delete_shared_type_entity_type() context => { var entity = context.Set>("JoinOneToThreePayloadFullShared") - .Single(e => (int)e["OneId"] == 1 && (int)e["ThreeId"] == 1); + .Single(e => (int)e["OneId"] == 1 && (int)e["ThreeId"] == 1); Assert.Equal("AlreadyUpdated", (string)entity["Payload"]); @@ -3001,12 +3031,14 @@ public void Can_insert_update_delete_shared_type_entity_type() context.SaveChanges(); - Assert.False(context.Set>("JoinOneToThreePayloadFullShared") + Assert.False( + context.Set>("JoinOneToThreePayloadFullShared") .Any(e => (int)e["OneId"] == 1 && (int)e["ThreeId"] == 1)); }); } - protected ManyToManyTrackingTestBase(TFixture fixture) => Fixture = fixture; + protected ManyToManyTrackingTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -3023,11 +3055,14 @@ protected virtual void UseTransaction(DatabaseFacade facade, IDbContextTransacti { } - protected ManyToManyContext CreateContext() => Fixture.CreateContext(); + protected ManyToManyContext CreateContext() + => Fixture.CreateContext(); - protected virtual bool SupportsDatabaseDefaults => true; + protected virtual bool SupportsDatabaseDefaults + => true; - protected virtual bool RequiresDetectChanges => true; + protected virtual bool RequiresDetectChanges + => true; public abstract class ManyToManyTrackingFixtureBase : ManyToManyQueryFixtureBase { diff --git a/test/EFCore.Specification.Tests/MonsterFixupTestBase.cs b/test/EFCore.Specification.Tests/MonsterFixupTestBase.cs index 449dd828847..a93f88c6629 100644 --- a/test/EFCore.Specification.Tests/MonsterFixupTestBase.cs +++ b/test/EFCore.Specification.Tests/MonsterFixupTestBase.cs @@ -1371,21 +1371,25 @@ protected void NavigationVerification() Assert.Same(license2, driver2.License); } - protected bool UseDetectChanges => Fixture.UseDetectChanges; + protected bool UseDetectChanges + => Fixture.UseDetectChanges; protected void CreateAndSeedDatabase(Action seed) => TestStore.Initialize(Fixture.ServiceProvider, CreateContext, c => seed((MonsterContext)c)); - protected MonsterContext CreateContext() => Fixture.CreateContext(Options); + protected MonsterContext CreateContext() + => Fixture.CreateContext(Options); - public virtual void Dispose() => TestStore.Dispose(); + public virtual void Dispose() + => TestStore.Dispose(); public abstract class MonsterFixupFixtureBase : ServiceProviderFixtureBase { public abstract string StoreName { get; } public abstract bool UseDetectChanges { get; } - public TestStore CreateTestStore() => TestStoreFactory.Create(StoreName); + public TestStore CreateTestStore() + => TestStoreFactory.Create(StoreName); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder); @@ -1406,8 +1410,11 @@ protected virtual void OnModelCreating "MonsterSnapshot"; - public override bool UseDetectChanges => true; + public override string StoreName + => "MonsterSnapshot"; + + public override bool UseDetectChanges + => true; public override MonsterContext CreateContext(DbContextOptions options) => new SnapshotMonsterContext(options); @@ -1427,8 +1434,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con public abstract class MonsterFixupChangedOnlyFixtureBase : MonsterFixupFixtureBase { - public override string StoreName => "MonsterChangedOnly"; - public override bool UseDetectChanges => false; + public override string StoreName + => "MonsterChangedOnly"; + + public override bool UseDetectChanges + => false; public override MonsterContext CreateContext(DbContextOptions options) => new ChangedOnlyMonsterContext(options); @@ -1448,8 +1458,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con public abstract class MonsterFixupChangedChangingFixtureBase : MonsterFixupFixtureBase { - public override string StoreName => "MonsterFullNotify"; - public override bool UseDetectChanges => false; + public override string StoreName + => "MonsterFullNotify"; + + public override bool UseDetectChanges + => false; public override MonsterContext CreateContext(DbContextOptions options) => new ChangedChangingMonsterContext(options); diff --git a/test/EFCore.Specification.Tests/MusicStoreTestBase.cs b/test/EFCore.Specification.Tests/MusicStoreTestBase.cs index 22e4b9fe5cb..6482dc0a8c8 100644 --- a/test/EFCore.Specification.Tests/MusicStoreTestBase.cs +++ b/test/EFCore.Specification.Tests/MusicStoreTestBase.cs @@ -487,13 +487,14 @@ public virtual async Task Custom_projection_FirstOrDefault_works(bool async) var shoppingCartId = "CartId_A"; var id = 1; var query = context.CartItems - .Select(ci => new CartItem - { - CartId = ci.CartId, - CartItemId = ci.CartItemId, - Count = ci.Count, - Album = new Album { Title = ci.Album.Title } - }); + .Select( + ci => new CartItem + { + CartId = ci.CartId, + CartItemId = ci.CartItemId, + Count = ci.Count, + Album = new Album { Title = ci.Album.Title } + }); var cartItem = async ? await query.FirstOrDefaultAsync(ci => ci.CartId == shoppingCartId && ci.CartItemId == id) @@ -762,15 +763,18 @@ public async Task Details(int id) protected TFixture Fixture { get; } - protected MusicStoreContext CreateContext() => Fixture.CreateContext(); + protected MusicStoreContext CreateContext() + => Fixture.CreateContext(); public abstract class MusicStoreFixtureBase : SharedStoreFixtureBase { - public virtual IDisposable BeginTransaction(DbContext context) => context.Database.BeginTransaction(); + public virtual IDisposable BeginTransaction(DbContext context) + => context.Database.BeginTransaction(); protected override string StoreName { get; } = "MusicStore"; - protected override bool UsePooling => false; + protected override bool UsePooling + => false; } } } diff --git a/test/EFCore.Specification.Tests/NotificationEntitiesTestBase.cs b/test/EFCore.Specification.Tests/NotificationEntitiesTestBase.cs index 659f93432cb..e150fa93eb5 100644 --- a/test/EFCore.Specification.Tests/NotificationEntitiesTestBase.cs +++ b/test/EFCore.Specification.Tests/NotificationEntitiesTestBase.cs @@ -15,7 +15,8 @@ namespace Microsoft.EntityFrameworkCore public abstract class NotificationEntitiesTestBase : IClassFixture where TFixture : NotificationEntitiesTestBase.NotificationEntitiesFixtureBase, new() { - protected NotificationEntitiesTestBase(TFixture fixture) => Fixture = fixture; + protected NotificationEntitiesTestBase(TFixture fixture) + => Fixture = fixture; protected virtual TFixture Fixture { get; } @@ -106,7 +107,8 @@ protected void SetWithNotify(T value, ref T field, [CallerMemberName] string } } - protected DbContext CreateContext() => Fixture.CreateContext(); + protected DbContext CreateContext() + => Fixture.CreateContext(); public abstract class NotificationEntitiesFixtureBase : SharedStoreFixtureBase { diff --git a/test/EFCore.Specification.Tests/OptimisticConcurrencyTestBase.cs b/test/EFCore.Specification.Tests/OptimisticConcurrencyTestBase.cs index 094d13492df..b41cf1feec7 100644 --- a/test/EFCore.Specification.Tests/OptimisticConcurrencyTestBase.cs +++ b/test/EFCore.Specification.Tests/OptimisticConcurrencyTestBase.cs @@ -673,7 +673,8 @@ protected virtual void ResolveConcurrencyTokens(EntityEntry entry) // default do nothing. Allow provider-specific entry reset } - protected F1Context CreateF1Context() => Fixture.CreateContext(); + protected F1Context CreateF1Context() + => Fixture.CreateContext(); private Task ConcurrencyTestAsync(int expectedPodiums, Action resolver) => ConcurrencyTestAsync( @@ -691,8 +692,10 @@ private Task ConcurrencyTestAsync(int expectedPodiums, Action private Task ConcurrencyTestAsync( - Action change, Action resolver, - Action validator) => ConcurrencyTestAsync(change, change, resolver, validator); + Action change, + Action resolver, + Action validator) + => ConcurrencyTestAsync(change, change, resolver, validator); /// /// Runs the two actions with two different contexts and calling @@ -703,8 +706,10 @@ private Task ConcurrencyTestAsync( /// the database at the end of the process can be validated. /// protected virtual async Task ConcurrencyTestAsync( - Action storeChange, Action clientChange, - Action resolver, Action validator) + Action storeChange, + Action clientChange, + Action resolver, + Action validator) { using var c = CreateF1Context(); await c.Database.CreateExecutionStrategy().ExecuteAsync( diff --git a/test/EFCore.Specification.Tests/OverzealousInitializationTestBase.cs b/test/EFCore.Specification.Tests/OverzealousInitializationTestBase.cs index 1962f5684a4..dd1cf360c38 100644 --- a/test/EFCore.Specification.Tests/OverzealousInitializationTestBase.cs +++ b/test/EFCore.Specification.Tests/OverzealousInitializationTestBase.cs @@ -13,7 +13,8 @@ namespace Microsoft.EntityFrameworkCore public abstract class OverzealousInitializationTestBase : IClassFixture where TFixture : OverzealousInitializationTestBase.OverzealousInitializationFixtureBase, new() { - protected OverzealousInitializationTestBase(TFixture fixture) => Fixture = fixture; + protected OverzealousInitializationTestBase(TFixture fixture) + => Fixture = fixture; [ConditionalFact] public virtual void Fixup_does_not_ignore_eagerly_initialized_reference_navs() @@ -33,10 +34,11 @@ public virtual void Fixup_does_not_ignore_eagerly_initialized_reference_navs() } } - protected class Album + protected class Album { [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } + public int ArtistId { get; set; } public virtual Artist Artist { get; set; } @@ -53,6 +55,7 @@ protected class Artist { [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } + public string Name { get; set; } } @@ -60,6 +63,7 @@ public class Track { [DatabaseGenerated(DatabaseGeneratedOption.None)] public int Id { get; set; } + public int AlbumId { get; set; } } @@ -80,11 +84,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) protected TFixture Fixture { get; } - protected AlbumViewerContext CreateContext() => Fixture.CreateContext(); + protected AlbumViewerContext CreateContext() + => Fixture.CreateContext(); public abstract class OverzealousInitializationFixtureBase : SharedStoreFixtureBase { - public virtual IDisposable BeginTransaction(DbContext context) => context.Database.BeginTransaction(); + public virtual IDisposable BeginTransaction(DbContext context) + => context.Database.BeginTransaction(); protected override string StoreName { get; } = "OverzealousInitialization"; @@ -93,22 +99,19 @@ protected override void Seed(AlbumViewerContext context) var artists = new[] { new Artist { Id = 1, Name = "Freddie" }, - new Artist { Id = 2, Name = "Kendrick"}, + new Artist { Id = 2, Name = "Kendrick" }, new Artist { Id = 3, Name = "Jarvis" } }; for (var i = 1; i <= 10; i++) { - context.Add(new Album - { - Id = i, - Artist = artists[i % 3], - Tracks = new List + context.Add( + new Album { - new Track { Id = i * 2 }, - new Track { Id = i * 2 + 1} - } - }); + Id = i, + Artist = artists[i % 3], + Tracks = new List { new Track { Id = i * 2 }, new Track { Id = i * 2 + 1 } } + }); } context.SaveChanges(); diff --git a/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs b/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs index 00af8790b8d..c333e8a9a05 100644 --- a/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs +++ b/test/EFCore.Specification.Tests/PropertyValuesTestBase.cs @@ -2161,9 +2161,11 @@ public string NoGetter set => _noGetter = value; } - public string GetNoGetterValue() => _noGetter; + public string GetNoGetterValue() + => _noGetter; - public string NoSetter => "NoSetter"; + public string NoSetter + => "NoSetter"; } protected class BuildingDto @@ -2183,9 +2185,11 @@ public string NoGetter set => _noGetter = value; } - public string GetNoGetterValue() => _noGetter; + public string GetNoGetterValue() + => _noGetter; - public string NoSetter => "NoSetter"; + public string NoSetter + => "NoSetter"; public int Shadow1 { get; set; } } diff --git a/test/EFCore.Specification.Tests/Query/AsyncGearsOfWarQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/AsyncGearsOfWarQueryTestBase.cs index 3269fa8c562..7d66607882e 100644 --- a/test/EFCore.Specification.Tests/Query/AsyncGearsOfWarQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/AsyncGearsOfWarQueryTestBase.cs @@ -18,7 +18,8 @@ protected AsyncGearsOfWarQueryTestBase(TFixture fixture) { } - protected GearsOfWarContext CreateContext() => Fixture.CreateContext(); + protected GearsOfWarContext CreateContext() + => Fixture.CreateContext(); [ConditionalFact] public virtual async Task Cast_to_derived_type_causes_client_eval() diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryFixtureBase.cs index 51c8daa4db3..9553a3c38c9 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryFixtureBase.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestModels.ComplexNavigationsModel; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -16,9 +15,11 @@ public abstract class ComplexNavigationsQueryFixtureBase : SharedStoreFixtureBas { protected override string StoreName { get; } = "ComplexNavigations"; - public Func GetContextCreator() => () => CreateContext(); + public Func GetContextCreator() + => () => CreateContext(); - public virtual ISetSource GetExpectedData() => new ComplexNavigationsDefaultData(); + public virtual ISetSource GetExpectedData() + => new ComplexNavigationsDefaultData(); public IReadOnlyDictionary GetEntitySorters() => new Dictionary> @@ -305,7 +306,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con modelBuilder.Entity().HasOne(g => g.Language); } - protected override void Seed(ComplexNavigationsContext context) => ComplexNavigationsData.Seed(context); + protected override void Seed(ComplexNavigationsContext context) + => ComplexNavigationsData.Seed(context); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder).ConfigureWarnings( diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs index 7a87d48e530..515f9e0741b 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Linq.Expressions; using System.Reflection; -using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.ComplexNavigationsModel; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -31,7 +30,8 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class ComplexNavigationsQueryTestBase : QueryTestBase where TFixture : ComplexNavigationsQueryFixtureBase, new() { - protected ComplexNavigationsContext CreateContext() => Fixture.CreateContext(); + protected ComplexNavigationsContext CreateContext() + => Fixture.CreateContext(); protected ComplexNavigationsQueryTestBase(TFixture fixture) : base(fixture) @@ -45,71 +45,40 @@ private MemberInfo GetMemberInfo(Type sourceType, string name) => sourceType.GetMember(name).Single(); private ExpectedQueryRewritingVisitor CreateExpectedQueryRewritingVisitor() - => new ExpectedQueryRewritingVisitor(new Dictionary<(Type, string), MemberInfo[]> + => new ExpectedQueryRewritingVisitor( + new Dictionary<(Type, string), MemberInfo[]> { { (typeof(Level1), "OneToMany_Optional_Self_Inverse1Id"), - new [] - { - GetMemberInfo(typeof(Level1), "OneToMany_Optional_Self_Inverse1"), - GetMemberInfo(typeof(Level1), "Id") - } + new[] { GetMemberInfo(typeof(Level1), "OneToMany_Optional_Self_Inverse1"), GetMemberInfo(typeof(Level1), "Id") } }, { (typeof(Level1), "OneToOne_Optional_Self1Id"), - new [] - { - GetMemberInfo(typeof(Level1), "OneToOne_Optional_Self1"), - GetMemberInfo(typeof(Level1), "Id") - } + new[] { GetMemberInfo(typeof(Level1), "OneToOne_Optional_Self1"), GetMemberInfo(typeof(Level1), "Id") } }, { (typeof(Level2), "OneToMany_Optional_Self_Inverse2Id"), - new [] - { - GetMemberInfo(typeof(Level2), "OneToMany_Optional_Self_Inverse2"), - GetMemberInfo(typeof(Level2), "Id") - } + new[] { GetMemberInfo(typeof(Level2), "OneToMany_Optional_Self_Inverse2"), GetMemberInfo(typeof(Level2), "Id") } }, { (typeof(Level2), "OneToOne_Optional_Self2Id"), - new [] - { - GetMemberInfo(typeof(Level2), "OneToOne_Optional_Self2"), - GetMemberInfo(typeof(Level2), "Id") - } + new[] { GetMemberInfo(typeof(Level2), "OneToOne_Optional_Self2"), GetMemberInfo(typeof(Level2), "Id") } }, { (typeof(Level3), "OneToMany_Optional_Self_Inverse3Id"), - new [] - { - GetMemberInfo(typeof(Level3), "OneToMany_Optional_Self_Inverse3"), - GetMemberInfo(typeof(Level3), "Id") - } + new[] { GetMemberInfo(typeof(Level3), "OneToMany_Optional_Self_Inverse3"), GetMemberInfo(typeof(Level3), "Id") } }, { (typeof(Level3), "OneToOne_Optional_Self3Id"), - new [] - { - GetMemberInfo(typeof(Level3), "OneToOne_Optional_Self3"), - GetMemberInfo(typeof(Level3), "Id") - } + new[] { GetMemberInfo(typeof(Level3), "OneToOne_Optional_Self3"), GetMemberInfo(typeof(Level3), "Id") } }, { (typeof(Level4), "OneToMany_Optional_Self_Inverse4Id"), - new [] - { - GetMemberInfo(typeof(Level4), "OneToMany_Optional_Self_Inverse4"), - GetMemberInfo(typeof(Level4), "Id") - } + new[] { GetMemberInfo(typeof(Level4), "OneToMany_Optional_Self_Inverse4"), GetMemberInfo(typeof(Level4), "Id") } }, { (typeof(Level4), "OneToOne_Optional_Self4Id"), - new [] - { - GetMemberInfo(typeof(Level4), "OneToOne_Optional_Self4"), - GetMemberInfo(typeof(Level4), "Id") - } + new[] { GetMemberInfo(typeof(Level4), "OneToOne_Optional_Self4"), GetMemberInfo(typeof(Level4), "Id") } }, }); @@ -259,7 +228,8 @@ public virtual Task Multi_level_include_correct_PK_is_chosen_as_the_join_predica new ExpectedInclude(l1 => l1.OneToMany_Optional1), new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToMany_Optional1"), new ExpectedInclude(l3 => l3.OneToMany_Required_Inverse3, "OneToMany_Optional1.OneToMany_Optional2"), - new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToMany_Optional1.OneToMany_Optional2.OneToMany_Required_Inverse3") + new ExpectedInclude( + l2 => l2.OneToMany_Optional2, "OneToMany_Optional1.OneToMany_Optional2.OneToMany_Required_Inverse3") }; return AssertQuery( @@ -1155,8 +1125,9 @@ public virtual Task Complex_navigations_with_predicate_projected_into_anonymous_ return AssertQuery( async, ss => ss.Set() - .Where(e => e.OneToOne_Required_FK1.OneToOne_Required_FK2 == e.OneToOne_Required_FK1.OneToOne_Optional_FK2 - && e.OneToOne_Required_FK1.OneToOne_Optional_FK2.Id != 7) + .Where( + 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 }), elementSorter: e => (e.Name, e.Id)); } @@ -1449,7 +1420,8 @@ public virtual Task SelectMany_nested_navigation_property_optional_and_projectio return AssertQuery( async, ss => ss.Set().SelectMany(l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2).Select(e => e.Name), - ss => ss.Set().SelectMany(l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2 ?? new List()).Select(e => e.Name)); + ss => ss.Set().SelectMany(l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2 ?? new List()) + .Select(e => e.Name)); } [ConditionalTheory] @@ -1856,8 +1828,7 @@ public virtual Task Multiple_SelectMany_with_Include(bool async) { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(l3 => l3.OneToOne_Required_FK3), - new ExpectedInclude(l3 => l3.OneToMany_Optional3) + new ExpectedInclude(l3 => l3.OneToOne_Required_FK3), new ExpectedInclude(l3 => l3.OneToMany_Optional3) }; return AssertQuery( @@ -1953,7 +1924,7 @@ public virtual Task Multiple_required_navigations_with_Include(bool async) ss => ss.Set() .Select(l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Required_FK_Inverse3) .Include(l2 => l2.OneToOne_Optional_FK2), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2))); + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2))); } [ConditionalTheory(Skip = "Issue#16752")] @@ -2182,14 +2153,14 @@ public virtual Task SelectMany_with_nested_required_navigation_filter_and_explic { return AssertQuery( async, - ss => from l1 in ss.Set() - from l3 in l1.OneToOne_Required_FK1.OneToMany_Required2.Where(l => l.Id > 5).DefaultIfEmpty() - where l3 != null - select l1, - ss => from l1 in ss.Set().Where(l => l.OneToOne_Required_FK1 != null) - from l3 in l1.OneToOne_Required_FK1.OneToMany_Required2.Where(l => l.Id > 5).DefaultIfEmpty() - where l3 != null - select l1); + ss => from l1 in ss.Set() + from l3 in l1.OneToOne_Required_FK1.OneToMany_Required2.Where(l => l.Id > 5).DefaultIfEmpty() + where l3 != null + select l1, + ss => from l1 in ss.Set().Where(l => l.OneToOne_Required_FK1 != null) + from l3 in l1.OneToOne_Required_FK1.OneToMany_Required2.Where(l => l.Id > 5).DefaultIfEmpty() + where l3 != null + select l1); } [ConditionalTheory] @@ -2205,7 +2176,8 @@ equals l2.Level1_Optional_Id select new { l1, l2 }, ss => from l1 in ss.Set() join l2 in ss.Set().SelectMany( - l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Optional_FK_Inverse3.OneToMany_Required_Self2 ?? new List()) on l1.Id + l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Optional_FK_Inverse3.OneToMany_Required_Self2 + ?? new List()) on l1.Id equals l2.Level1_Optional_Id select new { l1, l2 }, elementSorter: e => (e.l1.Id, e.l2.Id), @@ -2239,7 +2211,8 @@ on l1.Id equals l2.Level1_Optional_Id [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany2(bool async) + public virtual Task SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany2( + bool async) { return AssertQuery( async, @@ -2257,7 +2230,8 @@ join l1 in ss.Set() on l2.Level1_Optional_Id equals l1.Id [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany3(bool async) + public virtual Task SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany3( + bool async) { return AssertQuery( async, @@ -2316,7 +2290,9 @@ on l4.Id equals l2.Id [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_followed_by_Select_required_navigation_using_same_navs(bool async) + public virtual Task + SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_followed_by_Select_required_navigation_using_same_navs( + bool async) { return AssertQuery( async, @@ -2457,7 +2433,8 @@ public virtual Task Contains_with_subquery_optional_navigation_and_constant_item async, ss => ss.Set().Where(l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.Distinct().Select(l3 => l3.Id).Contains(1)), ss => ss.Set().Where( - l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.MaybeScalar(x => x.Distinct().Select(l3 => l3.Id).Contains(1)) == true)); + l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.MaybeScalar(x => x.Distinct().Select(l3 => l3.Id).Contains(1)) + == true)); } [ConditionalTheory] @@ -2466,8 +2443,12 @@ public virtual Task Contains_with_subquery_optional_navigation_scalar_distinct_a { return AssertQuery( async, - ss => ss.Set().Where(l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.Select(l3 => l3.Name.Length).Distinct().Contains(1)), - ss => ss.Set().Where(l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.MaybeScalar(x => x.Select(l3 => l3.Name.Length).Distinct().Contains(1)) == true)); + ss => ss.Set().Where( + l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.Select(l3 => l3.Name.Length).Distinct().Contains(1)), + ss => ss.Set().Where( + l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.MaybeScalar( + x => x.Select(l3 => l3.Name.Length).Distinct().Contains(1)) + == true)); } [ConditionalTheory] @@ -2525,8 +2506,10 @@ public virtual Task Required_navigation_on_a_subquery_with_First_in_predicate(bo async, ss => ss.Set() .Where(l2o => l2o.Id == 7) - .Where(l1 => EF.Property( - ss.Set().OrderBy(l2i => l2i.Id).First().OneToOne_Required_FK_Inverse2, "Name") == "L1 02")); + .Where( + l1 => EF.Property( + ss.Set().OrderBy(l2i => l2i.Id).First().OneToOne_Required_FK_Inverse2, "Name") + == "L1 02")); } [ConditionalTheory] @@ -2562,7 +2545,8 @@ public virtual Task Optional_navigation_propagates_nullability_to_manually_creat return AssertQuery( async, ss => from l3 in ss.Set() - join l2_nav in ss.Set().Select(ll => ll.OneToOne_Optional_FK1) on l3.Level2_Required_Id equals l2_nav.Id into grouping + join l2_nav in ss.Set().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 }, elementSorter: e => (e.Name1, e.Name2)); @@ -3210,7 +3194,8 @@ where l2.OneToOne_Required_FK2.OneToMany_Optional3 select l2.Name, ss => from l2 in ss.Set() where l2.OneToOne_Required_FK2.OneToMany_Optional3.MaybeScalar( - x => x.Select(i => i.OneToOne_Optional_PK_Inverse4 == l2.OneToOne_Required_FK2).Any()) == true + x => x.Select(i => i.OneToOne_Optional_PK_Inverse4 == l2.OneToOne_Required_FK2).Any()) + == true select l2.Name); } @@ -3226,7 +3211,8 @@ where l2.OneToOne_Required_FK2.OneToMany_Optional3 select l2.Name, ss => from l2 in ss.Set() where l2.OneToOne_Required_FK2.OneToMany_Optional3.MaybeScalar( - x => x.Select(i => i.OneToOne_Optional_PK_Inverse4 == l2.OneToOne_Optional_PK2).Any()) == true + x => x.Select(i => i.OneToOne_Optional_PK_Inverse4 == l2.OneToOne_Optional_PK2).Any()) + == true select l2.Name); } @@ -3796,7 +3782,8 @@ public virtual Task Include_reference_collection_order_by_reference_navigation(b ss => ss.Set() .Include(l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2) .OrderBy(l1 => (int?)l1.OneToOne_Optional_FK1.Id), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToOne_Optional_FK1), new ExpectedInclude(e => e.OneToMany_Optional2, "OneToOne_Optional_FK1")), assertOrder: true); @@ -4007,8 +3994,7 @@ public virtual Task Include2(bool async) { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) }; return AssertQuery( @@ -4023,8 +4009,7 @@ public virtual Task Include3(bool async) { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), - new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1) + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1) }; return AssertQuery( @@ -4069,10 +4054,7 @@ public virtual Task Include5(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Include6(bool async) { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2) - }; + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2) }; return AssertQuery( async, @@ -4086,17 +4068,15 @@ public virtual Task Include7(bool async) { return AssertQuery( async, - ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2).Select(l1 => l1.OneToOne_Optional_PK1)); + ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2) + .Select(l1 => l1.OneToOne_Optional_PK1)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Include8(bool async) { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK_Inverse2) - }; + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l2 => l2.OneToOne_Optional_FK_Inverse2) }; return AssertQuery( async, @@ -4110,10 +4090,7 @@ public virtual Task Include8(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Include9(bool async) { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK_Inverse2) - }; + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l2 => l2.OneToOne_Optional_FK_Inverse2) }; return AssertQuery( async, @@ -4177,10 +4154,7 @@ public virtual Task Include11(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Include12(bool async) { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2) - }; + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2) }; return AssertQuery( async, @@ -4194,10 +4168,7 @@ public virtual Task Include12(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Include13(bool async) { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) - }; + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) }; return AssertQuery( async, @@ -4276,10 +4247,7 @@ public virtual void Include17() [MemberData(nameof(IsAsyncData))] public virtual Task Include18_1(bool async) { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) - }; + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) }; return AssertQuery( async, @@ -4291,10 +4259,7 @@ public virtual Task Include18_1(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Include18_1_1(bool async) { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) - }; + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) }; return AssertQuery( async, @@ -4306,10 +4271,7 @@ public virtual Task Include18_1_1(bool async) [MemberData(nameof(IsAsyncData))] public virtual Task Include18_2(bool async) { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) - }; + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) }; return AssertQuery( async, @@ -4360,10 +4322,7 @@ public virtual void Include18_3_2() [MemberData(nameof(IsAsyncData))] public virtual Task Include18_3_3(bool async) { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK2) - }; + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK2) }; return AssertQuery( async, @@ -4642,8 +4601,9 @@ public virtual Task Member_pushdown_with_multiple_collections(bool async) l1 => l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).FirstOrDefault().OneToMany_Optional2.OrderBy(l3 => l3.Id) .FirstOrDefault().Name), ss => ss.Set().Select( - l1 => l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).FirstOrDefault().Maybe(x => x.OneToMany_Optional2.OrderBy(l3 => l3.Id) - .FirstOrDefault().Maybe(xx => xx.Name)))); + l1 => l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).FirstOrDefault().Maybe( + x => x.OneToMany_Optional2.OrderBy(l3 => l3.Id) + .FirstOrDefault().Maybe(xx => xx.Name)))); } [ConditionalTheory] @@ -4653,7 +4613,8 @@ public virtual Task Include_multiple_collections_on_same_level(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1).Include(l1 => l1.OneToMany_Required1), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(l1 => l1.OneToMany_Optional1), new ExpectedInclude(l1 => l1.OneToMany_Required1)), assertOrder: true); @@ -4706,16 +4667,18 @@ public virtual Task Union_over_entities_with_different_nullability(bool async) ss => ss.Set() .GroupJoin(ss.Set(), l1 => l1.Id, l2 => l2.Level1_Optional_Id, (l1, l2s) => new { l1, l2s }) .SelectMany(g => g.l2s.DefaultIfEmpty(), (g, l2) => new { g.l1, l2 }) - .Concat(ss.Set().GroupJoin(ss.Set(), l2 => l2.Level1_Optional_Id, l1 => l1.Id, (l2, l1s) => new { l2, l1s }) - .SelectMany(g => g.l1s.DefaultIfEmpty(), (g, l1) => new { l1, g.l2 }) - .Where(e => e.l1.Equals(null))) + .Concat( + ss.Set().GroupJoin(ss.Set(), l2 => l2.Level1_Optional_Id, l1 => l1.Id, (l2, l1s) => new { l2, l1s }) + .SelectMany(g => g.l1s.DefaultIfEmpty(), (g, l1) => new { l1, g.l2 }) + .Where(e => e.l1.Equals(null))) .Select(e => (int?)e.l1.Id), ss => ss.Set() .GroupJoin(ss.Set(), l1 => l1.Id, l2 => l2.Level1_Optional_Id, (l1, l2s) => new { l1, l2s }) .SelectMany(g => g.l2s.DefaultIfEmpty(), (g, l2) => new { g.l1, l2 }) - .Concat(ss.Set().GroupJoin(ss.Set(), l2 => l2.Level1_Optional_Id, l1 => l1.Id, (l2, l1s) => new { l2, l1s }) - .SelectMany(g => g.l1s.DefaultIfEmpty(), (g, l1) => new { l1, g.l2 }) - .Where(e => e.l1 == null)) + .Concat( + ss.Set().GroupJoin(ss.Set(), l2 => l2.Level1_Optional_Id, l1 => l1.Id, (l2, l1s) => new { l2, l1s }) + .SelectMany(g => g.l1s.DefaultIfEmpty(), (g, l1) => new { l1, g.l2 }) + .Where(e => e.l1 == null)) .Select(e => e.l1.MaybeScalar(x => x.Id))); } @@ -4751,13 +4714,14 @@ public virtual Task Including_reference_navigation_and_projecting_collection_nav async, ss => ss.Set() .Include(e => e.OneToOne_Required_FK1) - .ThenInclude(e => e.OneToOne_Optional_FK2) - .Select(e => new Level1 - { - Id = e.Id, - OneToOne_Required_FK1 = e.OneToOne_Required_FK1, - OneToMany_Required1 = e.OneToMany_Required1 - })); + .ThenInclude(e => e.OneToOne_Optional_FK2) + .Select( + e => new Level1 + { + Id = e.Id, + OneToOne_Required_FK1 = e.OneToOne_Required_FK1, + OneToMany_Required1 = e.OneToMany_Required1 + })); } [ConditionalTheory] @@ -4769,11 +4733,7 @@ public virtual Task Including_reference_navigation_and_projecting_collection_nav ss => ss.Set() .Include(e => e.OneToOne_Required_FK1) .Include(e => e.OneToMany_Required1) - .Select(e => new - { - e, - First = e.OneToMany_Required1.OrderByDescending(e => e.Id).FirstOrDefault() - })); + .Select(e => new { e, First = e.OneToMany_Required1.OrderByDescending(e => e.Id).FirstOrDefault() })); } [ConditionalTheory] @@ -4812,11 +4772,7 @@ public virtual Task LeftJoin_with_Any_on_outer_source_and_projecting_collection_ join l2 in ss.Set() on l1.Id equals l2.Level1_Required_Id into l2s from l2 in l2s.DefaultIfEmpty() - select new Level2 - { - Id = l2 == null ? 0 : l2.Id, - OneToMany_Required2 = l2 == null ? null : l2.OneToMany_Required2 - }); + select new Level2 { Id = l2 == null ? 0 : l2.Id, OneToMany_Required2 = l2 == null ? null : l2.OneToMany_Required2 }); } [ConditionalTheory] @@ -4852,13 +4808,13 @@ public virtual Task Select_subquery_single_nested_subquery(bool async) { return AssertQuery( async, - ss => ss.Set().OrderBy(l1 => l1.Id).Select(l1 => new - { - Level2 = l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).Select(l2 => new + ss => ss.Set().OrderBy(l1 => l1.Id).Select( + l1 => new { - Level3s = l2.OneToMany_Optional2.OrderBy(l3 => l3.Id).Select(l3 => new { l3.Id }).ToList() - }).FirstOrDefault() - }), + Level2 = l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).Select( + l2 => new { Level3s = l2.OneToMany_Optional2.OrderBy(l3 => l3.Id).Select(l3 => new { l3.Id }).ToList() }) + .FirstOrDefault() + }), assertOrder: true, elementAsserter: (e, a) => { @@ -4871,7 +4827,6 @@ public virtual Task Select_subquery_single_nested_subquery(bool async) AssertCollection(e.Level2.Level3s, a.Level2.Level3s, ordered: true); } }); - } [ConditionalTheory] @@ -4880,20 +4835,25 @@ public virtual Task Select_subquery_single_nested_subquery2(bool async) { return AssertQuery( async, - ss => ss.Set().OrderBy(l1 => l1.Id).Select(l1 => new - { - Level2s = l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).Select(l2 => new + ss => ss.Set().OrderBy(l1 => l1.Id).Select( + l1 => new { - Level3 = l2.OneToMany_Optional2.OrderBy(l3 => l3.Id).Select(l3 => new - { - Level4s = l3.OneToMany_Optional3.OrderBy(l4 => l4.Id).Select(l4 => new { l4.Id }).ToList() - }).FirstOrDefault() - }) - }), + Level2s = l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).Select( + l2 => new + { + Level3 = l2.OneToMany_Optional2.OrderBy(l3 => l3.Id).Select( + l3 => new + { + Level4s = l3.OneToMany_Optional3.OrderBy(l4 => l4.Id).Select(l4 => new { l4.Id }) + .ToList() + }).FirstOrDefault() + }) + }), assertOrder: true, elementAsserter: (e, a) => { - AssertCollection(e.Level2s, a.Level2s, ordered: true, elementAsserter: + AssertCollection( + e.Level2s, a.Level2s, ordered: true, elementAsserter: (e2, a2) => { if (e2.Level3 == null) @@ -4929,9 +4889,15 @@ public virtual Task Nested_SelectMany_correlated_with_join_table_correctly_trans return AssertQuery( async, ss => ss.Set().SelectMany( - l1 => l1.OneToMany_Optional1.DefaultIfEmpty().SelectMany( - l2 => l2.OneToOne_Required_PK2.OneToMany_Optional3.DefaultIfEmpty() - .Select(l4 => new { l1Name = l1.Name, l2Name = l2.OneToOne_Required_PK2.Name, l3Name = l4.OneToOne_Optional_PK_Inverse4.Name })))); + l1 => l1.OneToMany_Optional1.DefaultIfEmpty().SelectMany( + l2 => l2.OneToOne_Required_PK2.OneToMany_Optional3.DefaultIfEmpty() + .Select( + l4 => new + { + l1Name = l1.Name, + l2Name = l2.OneToOne_Required_PK2.Name, + l3Name = l4.OneToOne_Optional_PK_Inverse4.Name + })))); } [ConditionalFact] @@ -4960,12 +4926,13 @@ public virtual Task Contains_over_optional_navigation_with_null_column(bool asyn { return AssertQuery( async, - ss => ss.Set().Select(l1 => new - { - l1.Name, - OptionalName = l1.OneToOne_Optional_FK1.Name, - Contains = ss.Set().Select(x => x.OneToOne_Optional_FK1.Name).Contains(l1.OneToOne_Optional_FK1.Name) - }), + ss => ss.Set().Select( + l1 => new + { + l1.Name, + OptionalName = l1.OneToOne_Optional_FK1.Name, + Contains = ss.Set().Select(x => x.OneToOne_Optional_FK1.Name).Contains(l1.OneToOne_Optional_FK1.Name) + }), elementSorter: e => (e.Name, e.OptionalName, e.Contains)); } @@ -4975,12 +4942,13 @@ public virtual Task Contains_over_optional_navigation_with_null_entity_reference { return AssertQuery( async, - ss => ss.Set().Select(l1 => new - { - l1.Name, - OptionalName = l1.OneToOne_Optional_FK1.Name, - Contains = ss.Set().Select(x => x.OneToOne_Optional_FK1).Contains(l1.OneToOne_Optional_PK1) - }), + ss => ss.Set().Select( + l1 => new + { + l1.Name, + OptionalName = l1.OneToOne_Optional_FK1.Name, + Contains = ss.Set().Select(x => x.OneToOne_Optional_FK1).Contains(l1.OneToOne_Optional_PK1) + }), elementSorter: e => (e.Name, e.OptionalName, e.Contains)); } @@ -4991,7 +4959,8 @@ public virtual Task Filtered_include_basic_Where(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.Where(l2 => l2.Id > 5)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(l2 => l2.Id > 5)))); @@ -5004,7 +4973,8 @@ public virtual Task Filtered_include_OrderBy(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.OrderBy(x => x.Name), @@ -5018,7 +4988,8 @@ public virtual Task Filtered_ThenInclude_OrderBy(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToMany_Optional2.OrderBy(x => x.Name)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToMany_Optional1), new ExpectedFilteredInclude( e => e.OneToMany_Optional2, @@ -5036,7 +5007,8 @@ public virtual Task Filtered_include_ThenInclude_OrderBy(bool async) ss => ss.Set() .Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name)) .ThenInclude(l2 => l2.OneToMany_Optional2.OrderByDescending(x => x.Name)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.OrderBy(x => x.Name), @@ -5055,7 +5027,8 @@ public virtual Task Filtered_include_basic_OrderBy_Take(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Take(3)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.OrderBy(x => x.Name).Take(3), @@ -5069,7 +5042,8 @@ public virtual Task Filtered_include_basic_OrderBy_Skip(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Skip(1)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.OrderBy(x => x.Name).Skip(1), @@ -5083,7 +5057,8 @@ public virtual Task Filtered_include_basic_OrderBy_Skip_Take(bool async) return AssertQuery( async, ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Skip(1).Take(3)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.OrderBy(x => x.Name).Skip(1).Take(3), @@ -5115,7 +5090,8 @@ public virtual Task Filtered_include_on_ThenInclude(bool async) ss => ss.Set() .Include(l1 => l1.OneToOne_Optional_FK1) .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToOne_Optional_FK1), new ExpectedFilteredInclude( e => e.OneToMany_Optional2, @@ -5131,8 +5107,11 @@ public virtual Task Filtered_include_after_reference_navigation(bool async) return AssertQuery( async, ss => ss.Set() - .Include(l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)), - elementAsserter: (e, a) => AssertInclude(e, a, + .Include( + l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1) + .Take(3)), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToOne_Optional_FK1), new ExpectedFilteredInclude( e => e.OneToMany_Optional2, @@ -5150,7 +5129,8 @@ public virtual Task Filtered_include_after_different_filtered_include_same_level ss => ss.Set() .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)) .Include(l1 => l1.OneToMany_Required1.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3), @@ -5170,7 +5150,8 @@ public virtual Task Filtered_include_after_different_filtered_include_different_ ss => ss.Set() .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)) .ThenInclude(l2 => l2.OneToMany_Required2.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3), @@ -5187,11 +5168,12 @@ public virtual Task Filtered_include_after_different_filtered_include_different_ public virtual async Task Filtered_include_different_filter_set_on_same_navigation_twice(bool async) { var message = (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Take(3))))).Message; + () => AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Take(3))))) + .Message; } [ConditionalTheory] @@ -5199,11 +5181,13 @@ public virtual async Task Filtered_include_different_filter_set_on_same_navigati public virtual async Task Filtered_include_different_filter_set_on_same_navigation_twice_multi_level(bool async) { var message = (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo")).ThenInclude(l2 => l2.OneToMany_Optional2) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Bar")).ThenInclude(l2 => l2.OneToOne_Required_FK2)))).Message; + () => AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo")).ThenInclude(l2 => l2.OneToMany_Optional2) + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Bar")) + .ThenInclude(l2 => l2.OneToOne_Required_FK2)))) + .Message; } [ConditionalTheory] @@ -5215,7 +5199,8 @@ public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice(bo ss => ss.Set() .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)) .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2), @@ -5229,9 +5214,12 @@ public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice_fo return AssertQuery( async, ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)).ThenInclude(l2 => l2.OneToMany_Optional2) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)).ThenInclude(l2 => l2.OneToOne_Required_FK2), - elementAsserter: (e, a) => AssertInclude(e, a, + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) + .ThenInclude(l2 => l2.OneToMany_Optional2) + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) + .ThenInclude(l2 => l2.OneToOne_Required_FK2), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2), @@ -5242,14 +5230,17 @@ public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice_fo [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async) + public virtual Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only( + bool async) { return AssertQuery( async, ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)).ThenInclude(l2 => l2.OneToMany_Optional2) + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) + .ThenInclude(l2 => l2.OneToMany_Optional2) .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Required_FK2), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2), @@ -5267,7 +5258,8 @@ public virtual Task Filtered_include_and_non_filtered_include_on_same_navigation ss => ss.Set() .Include(l1 => l1.OneToMany_Optional1) .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3), @@ -5283,7 +5275,8 @@ public virtual Task Filtered_include_and_non_filtered_include_on_same_navigation ss => ss.Set() .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) .Include(l1 => l1.OneToMany_Optional1), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3), @@ -5298,8 +5291,10 @@ public virtual Task Filtered_include_and_non_filtered_include_followed_by_then_i async, ss => ss.Set() .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2.OneToMany_Optional3.Where(x => x.Id > 1)), - elementAsserter: (e, a) => AssertInclude(e, a, + .Include(l1 => l1.OneToMany_Optional1) + .ThenInclude(l2 => l2.OneToOne_Optional_PK2.OneToMany_Optional3.Where(x => x.Id > 1)), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( e => e.OneToMany_Optional1, includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1), @@ -5318,9 +5313,14 @@ public virtual Task Filtered_include_complex_three_level_with_middle_having_filt return AssertQuery( async, ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)).ThenInclude(l3 => l3.OneToMany_Optional3) - .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)).ThenInclude(l3 => l3.OneToMany_Required3), - elementAsserter: (e, a) => AssertInclude(e, a, + .Include(l1 => l1.OneToMany_Optional1) + .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) + .ThenInclude(l3 => l3.OneToMany_Optional3) + .Include(l1 => l1.OneToMany_Optional1) + .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) + .ThenInclude(l3 => l3.OneToMany_Required3), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToMany_Optional1), new ExpectedFilteredInclude( e => e.OneToMany_Optional2, @@ -5338,9 +5338,13 @@ public virtual Task Filtered_include_complex_three_level_with_middle_having_filt return AssertQuery( async, ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)).ThenInclude(l3 => l3.OneToMany_Optional3) - .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToMany_Optional2).ThenInclude(l3 => l3.OneToMany_Required3), - elementAsserter: (e, a) => AssertInclude(e, a, + .Include(l1 => l1.OneToMany_Optional1) + .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) + .ThenInclude(l3 => l3.OneToMany_Optional3) + .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToMany_Optional2) + .ThenInclude(l3 => l3.OneToMany_Required3), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneToMany_Optional1), new ExpectedFilteredInclude( e => e.OneToMany_Optional2, @@ -5395,12 +5399,13 @@ public virtual void Filtered_include_outer_parameter_used_inside_filter() { // TODO: needs #18191 for result verification using var ctx = CreateContext(); - var query = ctx.LevelOne.Select(l1 => new - { - l1.Id, - FullInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2).ToList(), - FilteredInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2.Where(x => x.Id != l1.Id)).ToList() - }); + var query = ctx.LevelOne.Select( + l1 => new + { + l1.Id, + FullInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2).ToList(), + FilteredInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2.Where(x => x.Id != l1.Id)).ToList() + }); var result = query.ToList(); } @@ -5446,13 +5451,10 @@ public virtual Task Element_selector_with_coalesce_repeated_in_aggregate(bool as return AssertQueryScalar( async, ss => ss.Set().GroupBy( - l1 => l1.OneToOne_Required_PK1.OneToOne_Required_PK2.Name, - l1 => new - { - Id = ((int?)l1.OneToOne_Required_PK1.Id ?? 0) - }) - .Where(g => g.Min(l1 => l1.Id + l1.Id) > 0) - .Select(g => g.Count())); + l1 => l1.OneToOne_Required_PK1.OneToOne_Required_PK2.Name, + l1 => new { Id = ((int?)l1.OneToOne_Required_PK1.Id ?? 0) }) + .Where(g => g.Min(l1 => l1.Id + l1.Id) > 0) + .Select(g => g.Count())); } [ConditionalTheory] @@ -5462,36 +5464,38 @@ public virtual Task Nested_object_constructed_from_group_key_properties(bool asy return AssertQuery( async, ss => ss.Set() - .Where(l1 => l1.OneToOne_Optional_FK1 != null) - .GroupBy(l1 => new - { - l1.Id, - l1.Date, - l1.Name, - InnerId = l1.OneToOne_Optional_FK1.Id, - InnerDate = l1.OneToOne_Optional_FK1.Date, - InnerOptionalId = l1.OneToOne_Optional_FK1.Level1_Optional_Id, - InnerRequiredId = l1.OneToOne_Optional_FK1.Level1_Required_Id, - InnerName = l1.OneToOne_Required_FK1.Name - }) - .Select(g => new - { - NestedEntity = new Level1 - { - Id = g.Key.Id, - Name = g.Key.Name, - Date = g.Key.Date, - OneToOne_Optional_FK1 = new Level2 + .Where(l1 => l1.OneToOne_Optional_FK1 != null) + .GroupBy( + l1 => new { - Id = g.Key.InnerId, - Name = g.Key.InnerName, - Date = g.Key.InnerDate, - Level1_Optional_Id = g.Key.InnerOptionalId, - Level1_Required_Id = g.Key.InnerRequiredId - } - }, - Aggregate = g.Sum(x => x.Name.Length) - })); + l1.Id, + l1.Date, + l1.Name, + InnerId = l1.OneToOne_Optional_FK1.Id, + InnerDate = l1.OneToOne_Optional_FK1.Date, + InnerOptionalId = l1.OneToOne_Optional_FK1.Level1_Optional_Id, + InnerRequiredId = l1.OneToOne_Optional_FK1.Level1_Required_Id, + InnerName = l1.OneToOne_Required_FK1.Name + }) + .Select( + g => new + { + NestedEntity = new Level1 + { + Id = g.Key.Id, + Name = g.Key.Name, + Date = g.Key.Date, + OneToOne_Optional_FK1 = new Level2 + { + Id = g.Key.InnerId, + Name = g.Key.InnerName, + Date = g.Key.InnerDate, + Level1_Optional_Id = g.Key.InnerOptionalId, + Level1_Required_Id = g.Key.InnerRequiredId + } + }, + Aggregate = g.Sum(x => x.Name.Length) + })); } [ConditionalTheory] @@ -5501,9 +5505,9 @@ public virtual Task GroupBy_aggregate_where_required_relationship(bool async) return AssertQuery( async, ss => ss.Set() - .GroupBy(l2 => l2.OneToMany_Required_Inverse2.Id) - .Select(g => new { g.Key, Max = g.Max(e => e.Id) }) - .Where(x => x.Max != 2)); + .GroupBy(l2 => l2.OneToMany_Required_Inverse2.Id) + .Select(g => new { g.Key, Max = g.Max(e => e.Id) }) + .Where(x => x.Max != 2)); } [ConditionalTheory] @@ -5513,9 +5517,9 @@ public virtual Task GroupBy_aggregate_where_required_relationship_2(bool async) return AssertQuery( async, ss => ss.Set() - .GroupBy(l2 => l2.OneToMany_Required_Inverse2.Id) - .Select(g => new { g.Key, Max = g.Max(e => e.Id) }) - .Where(x => x.Max < 2 || x.Max > 2)); + .GroupBy(l2 => l2.OneToMany_Required_Inverse2.Id) + .Select(g => new { g.Key, Max = g.Max(e => e.Id) }) + .Where(x => x.Max < 2 || x.Max > 2)); } [ConditionalTheory] @@ -5525,7 +5529,8 @@ public virtual Task Member_over_null_check_ternary_and_nested_dto_type(bool asyn return AssertQuery( async, ss => ss.Set() - .Select(l1 => new Level1Dto + .Select( + l1 => new Level1Dto { Id = l1.Id, Name = l1.Name, @@ -5533,12 +5538,11 @@ public virtual Task Member_over_null_check_ternary_and_nested_dto_type(bool asyn ? null : new Level2Dto { - Id = l1.OneToOne_Optional_FK1.Id, - Name = l1.OneToOne_Optional_FK1.Name, + Id = l1.OneToOne_Optional_FK1.Id, Name = l1.OneToOne_Optional_FK1.Name, } }) - .OrderBy(e => e.Level2.Name) - .ThenBy(e => e.Id), + .OrderBy(e => e.Level2.Name) + .ThenBy(e => e.Id), assertOrder: true, elementAsserter: (e, a) => { @@ -5577,7 +5581,8 @@ public virtual Task Member_over_null_check_ternary_and_nested_anonymous_type(boo return AssertQuery( async, ss => ss.Set() - .Select(l1 => new + .Select( + l1 => new { l1.Id, l1.Name, @@ -5585,8 +5590,8 @@ public virtual Task Member_over_null_check_ternary_and_nested_anonymous_type(boo ? null : new { - Id = l1.OneToOne_Optional_FK1.Id, - Name = l1.OneToOne_Optional_FK1.Name, + l1.OneToOne_Optional_FK1.Id, + l1.OneToOne_Optional_FK1.Name, Level3 = l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2 == null ? null : new @@ -5596,7 +5601,7 @@ public virtual Task Member_over_null_check_ternary_and_nested_anonymous_type(boo } } }) - .Where(e => e.Level2.Level3.Name != "L"), + .Where(e => e.Level2.Level3.Name != "L"), elementSorter: e => e.Id, elementAsserter: (e, a) => { diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryFixtureBase.cs index cea40202ae0..64d5facf7a0 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryFixtureBase.cs @@ -15,7 +15,8 @@ public abstract class ComplexNavigationsWeakQueryFixtureBase : ComplexNavigation { protected override string StoreName { get; } = "ComplexNavigationsOwned"; - public override ISetSource GetExpectedData() => new ComplexNavigationsWeakData(); + public override ISetSource GetExpectedData() + => new ComplexNavigationsWeakData(); Func IQueryFixtureBase.GetSetSourceCreator() => context => new ComplexNavigationsWeakSetExtractor(context); diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryTestBase.cs index 6b299d24906..fcb7b5ec1f8 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsWeakQueryTestBase.cs @@ -168,7 +168,8 @@ public override void Member_pushdown_with_collection_navigation_in_the_middle() { } - public override Task Union_over_entities_with_different_nullability(bool async) => Task.CompletedTask; + public override Task Union_over_entities_with_different_nullability(bool async) + => Task.CompletedTask; [ConditionalTheory(Skip = "Issue#16752")] public override Task Include_inside_subquery(bool async) diff --git a/test/EFCore.Specification.Tests/Query/FiltersInheritanceQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/FiltersInheritanceQueryTestBase.cs index 09eefb2d13e..dc1cdc33be2 100644 --- a/test/EFCore.Specification.Tests/Query/FiltersInheritanceQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/FiltersInheritanceQueryTestBase.cs @@ -14,7 +14,8 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class FiltersInheritanceQueryTestBase : IClassFixture where TFixture : InheritanceQueryFixtureBase, new() { - protected FiltersInheritanceQueryTestBase(TFixture fixture) => Fixture = fixture; + protected FiltersInheritanceQueryTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -142,7 +143,8 @@ public virtual void Can_use_IgnoreQueryFilters_and_GetDatabaseValues() Assert.NotNull(context.Entry(eagle).GetDatabaseValues()); } - protected InheritanceContext CreateContext() => Fixture.CreateContext(); + protected InheritanceContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { diff --git a/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs index d7e1afe4029..1cdf85230e2 100644 --- a/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/FunkyDataQueryTestBase.cs @@ -137,6 +137,7 @@ public virtual Task String_contains_on_argument_with_wildcard_column(bool async) Assert.Equal(e.ln, a.ln); }); } + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task String_contains_on_argument_with_wildcard_column_negated(bool async) @@ -230,7 +231,8 @@ await AssertQuery( await AssertQuery( async, ss => ss.Set().Where(c => !c.FirstName.StartsWith(prm6)).Select(c => c.FirstName), - ss => ss.Set().Where(c => !c.FirstName.MaybeScalar(x => x.StartsWith(prm6)) == true).Select(c => c.FirstName)); + ss => ss.Set().Where(c => !c.FirstName.MaybeScalar(x => x.StartsWith(prm6)) == true) + .Select(c => c.FirstName)); var prm7 = ""; await AssertQuery( @@ -344,7 +346,8 @@ await AssertQuery( await AssertQuery( async, ss => ss.Set().Where(c => !c.FirstName.EndsWith("%B%a%r")).Select(c => c.FirstName), - ss => ss.Set().Where(c => !c.FirstName.MaybeScalar(x => x.EndsWith("%B%a%r")) == true).Select(c => c.FirstName)); + ss => ss.Set().Where(c => !c.FirstName.MaybeScalar(x => x.EndsWith("%B%a%r")) == true) + .Select(c => c.FirstName)); await AssertQuery( async, @@ -516,17 +519,13 @@ public virtual Task String_FirstOrDefault_and_LastOrDefault(bool async) { return AssertQuery( async, - ss => ss.Set().OrderBy(e => e.Id).Select(e => new - { - first = (char?)e.FirstName.FirstOrDefault(), - last = (char?)e.FirstName.LastOrDefault() - }), - ss => ss.Set().OrderBy(e => e.Id).Select(e => new - { - first = e.FirstName.MaybeScalar(x => x.FirstOrDefault()), - last = e.FirstName.MaybeScalar(x => x.LastOrDefault()) - - }), + ss => ss.Set().OrderBy(e => e.Id).Select( + e => new { first = (char?)e.FirstName.FirstOrDefault(), last = (char?)e.FirstName.LastOrDefault() }), + ss => ss.Set().OrderBy(e => e.Id).Select( + e => new + { + first = e.FirstName.MaybeScalar(x => x.FirstOrDefault()), last = e.FirstName.MaybeScalar(x => x.LastOrDefault()) + }), assertOrder: true, elementAsserter: (e, a) => { @@ -535,7 +534,8 @@ public virtual Task String_FirstOrDefault_and_LastOrDefault(bool async) }); } - protected FunkyDataContext CreateContext() => Fixture.CreateContext(); + protected FunkyDataContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { @@ -543,9 +543,11 @@ protected virtual void ClearLog() public abstract class FunkyDataQueryFixtureBase : SharedStoreFixtureBase, IQueryFixtureBase { - public Func GetContextCreator() => () => CreateContext(); + public Func GetContextCreator() + => () => CreateContext(); - public ISetSource GetExpectedData() => new FunkyDataData(); + public ISetSource GetExpectedData() + => new FunkyDataData(); public IReadOnlyDictionary GetEntitySorters() => new Dictionary> { { typeof(FunkyCustomer), e => ((FunkyCustomer)e)?.Id } } @@ -581,7 +583,8 @@ public override FunkyDataContext CreateContext() return context; } - protected override void Seed(FunkyDataContext context) => FunkyDataContext.Seed(context); + protected override void Seed(FunkyDataContext context) + => FunkyDataContext.Seed(context); } } } diff --git a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs index 0df6325a622..107c59d47bc 100644 --- a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryFixtureBase.cs @@ -15,9 +15,11 @@ public abstract class GearsOfWarQueryFixtureBase : SharedStoreFixtureBase GetContextCreator() => () => CreateContext(); + public Func GetContextCreator() + => () => CreateContext(); - public ISetSource GetExpectedData() => new GearsOfWarData(); + public ISetSource GetExpectedData() + => new GearsOfWarData(); public IReadOnlyDictionary GetEntitySorters() => new Dictionary> @@ -230,12 +232,13 @@ public IReadOnlyDictionary GetEntityAsserters() Assert.Equal(ee.Banner == null, aa.Banner == null); if (ee.Banner != null) { - Assert.True(Enumerable.SequenceEqual(ee.Banner, aa.Banner)); + Assert.True(ee.Banner.SequenceEqual(aa.Banner)); } + Assert.Equal(ee.Banner5 == null, aa.Banner5 == null); if (ee.Banner5 != null) { - Assert.True(Enumerable.SequenceEqual(ee.Banner5, aa.Banner5)); + Assert.True(ee.Banner5.SequenceEqual(aa.Banner5)); } } } @@ -343,11 +346,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con modelBuilder.Entity().Property(l => l.Id).ValueGeneratedNever(); } - protected override void Seed(GearsOfWarContext context) => GearsOfWarContext.Seed(context); + protected override void Seed(GearsOfWarContext context) + => GearsOfWarContext.Seed(context); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) - => base.AddOptions(builder).ConfigureWarnings(w => - w.Log(CoreEventId.RowLimitingOperationWithoutOrderByWarning)); + => base.AddOptions(builder).ConfigureWarnings( + w => + w.Log(CoreEventId.RowLimitingOperationWithoutOrderByWarning)); public override GearsOfWarContext CreateContext() { diff --git a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs index e5680e06a4d..a8efc03c05c 100644 --- a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs @@ -247,8 +247,7 @@ public virtual Task Include_with_join_reference1(bool async) { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(g => g.CityOfBirth), - new ExpectedInclude(o => o.CityOfBirth) + new ExpectedInclude(g => g.CityOfBirth), new ExpectedInclude(o => o.CityOfBirth) }; return AssertQuery( @@ -267,8 +266,7 @@ public virtual Task Include_with_join_reference2(bool async) { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(g => g.CityOfBirth), - new ExpectedInclude(o => o.CityOfBirth) + new ExpectedInclude(g => g.CityOfBirth), new ExpectedInclude(o => o.CityOfBirth) }; return AssertQuery( @@ -752,8 +750,7 @@ public virtual Task Select_enum_has_flag(bool async) .Select( b => new { - hasFlagTrue = b.Rank.HasFlag(MilitaryRank.Corporal), - hasFlagFalse = b.Rank.HasFlag(MilitaryRank.Sergeant) + hasFlagTrue = b.Rank.HasFlag(MilitaryRank.Corporal), hasFlagFalse = b.Rank.HasFlag(MilitaryRank.Sergeant) })); } @@ -1133,7 +1130,8 @@ public virtual Task Select_null_propagation_negative9(bool async) { return AssertQueryScalar( async, - ss => ss.Set().Select(g => g.LeaderNickname != null + ss => ss.Set().Select( + g => g.LeaderNickname != null ? (bool?)(g.Nickname.Length == 5) ?? default : (bool?)null)); } @@ -1240,11 +1238,11 @@ public virtual Task Where_compare_anonymous_types(bool async) ss => from g in ss.Set() from o in ss.Set().OfType() where new - { - Name = g.LeaderNickname, - Squad = g.LeaderSquadId, - Five = 5 - } + { + Name = g.LeaderNickname, + Squad = g.LeaderSquadId, + Five = 5 + } == new { Name = o.Nickname, @@ -3122,8 +3120,7 @@ where f is LocustHorde orderby f.Name select new { - Name = EF.Property(horde, "Name"), - Eradicated = EF.Property((LocustHorde)f, "Eradicated") + Name = EF.Property(horde, "Name"), Eradicated = EF.Property((LocustHorde)f, "Eradicated") }, assertOrder: true); } @@ -3223,8 +3220,7 @@ public virtual Task Include_on_derived_entity_using_OfType(bool async) { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(e => e.Commander), - new ExpectedInclude(e => e.Leaders) + new ExpectedInclude(e => e.Commander), new ExpectedInclude(e => e.Leaders) }; return AssertQuery( @@ -3283,7 +3279,7 @@ public virtual Task Comparing_two_collection_navigations_composite_key(bool asyn async, ss => from g1 in ss.Set() from g2 in ss.Set() - // ReSharper disable once PossibleUnintendedReferenceComparison + // ReSharper disable once PossibleUnintendedReferenceComparison where g1.Weapons == g2.Weapons orderby g1.Nickname select new { Nickname1 = g1.Nickname, Nickname2 = g2.Nickname }, @@ -3406,8 +3402,7 @@ public virtual Task Project_collection_navigation_with_inheritance3(bool async) .Select( f => new { - f.Id, - Gears = EF.Property>((Officer)((LocustHorde)f).Commander.DefeatedBy, "Reports") + f.Id, Gears = EF.Property>((Officer)((LocustHorde)f).Commander.DefeatedBy, "Reports") }), elementSorter: e => e.Id, elementAsserter: (e, a) => @@ -3433,8 +3428,7 @@ public virtual Task Include_reference_on_derived_type_using_string_nested1(bool { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(lc => lc.DefeatedBy), - new ExpectedInclude(g => g.Squad, "DefeatedBy") + new ExpectedInclude(lc => lc.DefeatedBy), new ExpectedInclude(g => g.Squad, "DefeatedBy") }; return AssertQuery( @@ -3574,8 +3568,7 @@ public virtual Task ThenInclude_collection_on_derived_after_derived_collection(b { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(e => e.Reports), - new ExpectedInclude(e => e.Reports, "Reports") + new ExpectedInclude(e => e.Reports), new ExpectedInclude(e => e.Reports, "Reports") }; return AssertQuery( @@ -3590,8 +3583,7 @@ public virtual Task ThenInclude_reference_on_derived_after_derived_collection(bo { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(e => e.Leaders), - new ExpectedInclude(e => e.DefeatedBy, "Leaders") + new ExpectedInclude(e => e.Leaders), new ExpectedInclude(e => e.DefeatedBy, "Leaders") }; return AssertQuery( @@ -3643,8 +3635,9 @@ public virtual async Task Include_collection_and_invalid_navigation_using_string async, ss => ss.Set().Include("Reports.Foo")))).Message; - Assert.Contains(CoreResources.LogInvalidIncludePath(new TestLogger()) - .GenerateMessage("Reports.Foo", "Foo"), message); + Assert.Contains( + CoreResources.LogInvalidIncludePath(new TestLogger()) + .GenerateMessage("Reports.Foo", "Foo"), message); } [ConditionalTheory] @@ -4795,8 +4788,7 @@ public virtual Task Include_on_derived_type_with_order_by_and_paging(bool async) { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(e => e.DefeatedBy), - new ExpectedInclude(e => e.Weapons, "DefeatedBy") + new ExpectedInclude(e => e.DefeatedBy), new ExpectedInclude(e => e.Weapons, "DefeatedBy") }; return AssertQuery( @@ -5089,22 +5081,23 @@ from w in grouping.DefaultIfEmpty() [MemberData(nameof(IsAsyncData))] public virtual Task Join_with_complex_key_selector(bool async) { - return AssertTranslationFailed(() => AssertQuery( - async, - ss => ss.Set() - .Join(ss.Set().Where(t => t.Note == "Marcus' Tag"), o => true, i => true, (o, i) => new { o, i }) - .GroupJoin( - ss.Set(), - oo => oo.o.Members.FirstOrDefault(v => v.Tag == oo.i), - ii => ii, - (k, g) => new - { - k.o, - k.i, - value = g.OrderBy(gg => gg.FullName).FirstOrDefault() - }) - .Select(r => new { r.o.Id, TagId = r.i.Id }), - elementSorter: e => (e.Id, e.TagId))); + return AssertTranslationFailed( + () => AssertQuery( + async, + ss => ss.Set() + .Join(ss.Set().Where(t => t.Note == "Marcus' Tag"), o => true, i => true, (o, i) => new { o, i }) + .GroupJoin( + ss.Set(), + oo => oo.o.Members.FirstOrDefault(v => v.Tag == oo.i), + ii => ii, + (k, g) => new + { + k.o, + k.i, + value = g.OrderBy(gg => gg.FullName).FirstOrDefault() + }) + .Select(r => new { r.o.Id, TagId = r.i.Id }), + elementSorter: e => (e.Id, e.TagId))); } [ConditionalTheory] @@ -5118,11 +5111,11 @@ public virtual async Task Streaming_correlated_collection_issue_11403_returning_ .OrderBy(w => w.Id)", typeof(IOrderedEnumerable).ShortDisplayName()), (await Assert.ThrowsAsync( () => AssertFirstOrDefault( - async, - ss => ss.Set() - .OrderBy(g => g.Nickname) - .Select(g => g.Weapons.Where(w => !w.IsAutomatic).OrderBy(w => w.Id)), - asserter: (e, a) => AssertCollection(e, a, ordered: true)))).Message, + async, + ss => ss.Set() + .OrderBy(g => g.Nickname) + .Select(g => g.Weapons.Where(w => !w.IsAutomatic).OrderBy(w => w.Id)), + asserter: (e, a) => AssertCollection(e, a, ordered: true)))).Message, ignoreLineEndingDifferences: true); } @@ -5168,12 +5161,14 @@ public virtual Task Project_one_value_type_with_client_projection_from_empty_col s => new { s.Name, - SquadId = s.Members.Where(m => m.HasSoulPatch).Select(m => ClientFunction(m.SquadId, m.LeaderSquadId)).FirstOrDefault() + SquadId = s.Members.Where(m => m.HasSoulPatch).Select(m => ClientFunction(m.SquadId, m.LeaderSquadId)) + .FirstOrDefault() }), elementSorter: s => s.Name); } - private static int ClientFunction(int a, int b) => a + b + 1; + private static int ClientFunction(int a, int b) + => a + b + 1; [ConditionalTheory(Skip = "issue #15864")] [MemberData(nameof(IsAsyncData))] @@ -5222,11 +5217,7 @@ public virtual Task Select_subquery_projecting_single_constant_inside_anonymous( return AssertQuery( async, ss => ss.Set().Select( - s => new - { - s.Name, - Gear = s.Members.Where(g => g.HasSoulPatch).Select(g => new { One = 1 }).FirstOrDefault() - })); + s => new { s.Name, Gear = s.Members.Where(g => g.HasSoulPatch).Select(g => new { One = 1 }).FirstOrDefault() })); } [ConditionalTheory] @@ -5720,7 +5711,8 @@ public virtual Task String_concat_nullable_expressions_are_coalesced(bool async) return AssertQuery( async, ss => ss.Set().Select(w => w.FullName + null + w.LeaderNickname + nullableParam), - ss => ss.Set().Select(w => w.FullName + string.Empty + w.LeaderNickname ?? string.Empty + nullableParam ?? string.Empty)); + ss => ss.Set().Select( + w => w.FullName + string.Empty + w.LeaderNickname ?? string.Empty + nullableParam ?? string.Empty)); } [ConditionalTheory(Skip = "issue #14205")] @@ -5895,8 +5887,7 @@ public virtual Task Include_with_group_by_and_FirstOrDefault_gets_properly_appli { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(e => e.CityOfBirth), - new ExpectedInclude(e => e.CityOfBirth) + new ExpectedInclude(e => e.CityOfBirth), new ExpectedInclude(e => e.CityOfBirth) }; return AssertQuery( @@ -5957,7 +5948,8 @@ public virtual Task Multiple_includes_with_client_method_around_entity_and_also_ return Task.CompletedTask; } - public static TEntity Client(TEntity entity) => entity; + public static TEntity Client(TEntity entity) + => entity; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -6574,8 +6566,9 @@ public virtual Task Reference_include_chain_loads_correctly_when_middle_is_null( return AssertQuery( async, ss => ss.Set().AsTracking().OrderBy(t => t.Note).Include(t => t.Gear).ThenInclude(g => g.Squad), - elementAsserter: (e, a) => AssertInclude(e, a, - new ExpectedInclude(t => t.Gear), new ExpectedInclude(t => t.Squad, "Gear")), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedInclude(t => t.Gear), new ExpectedInclude(t => t.Squad, "Gear")), entryCount: 13); } @@ -6838,11 +6831,7 @@ public virtual Task GroupBy_with_boolean_groupin_key_thru_navigation_access(bool .Select(g => new { g.Key.HasSoulPatch, Name = g.Key.Name.ToLower() }), ss => ss.Set() .GroupBy( - t => new - { - HasSoulPatch = t.Gear.MaybeScalar(x => x.HasSoulPatch), - Name = t.Gear.Squad.Name - }) + t => new { HasSoulPatch = t.Gear.MaybeScalar(x => x.HasSoulPatch), t.Gear.Squad.Name }) .Select(g => new { g.Key.HasSoulPatch, Name = g.Key.Name.Maybe(x => x.ToLower()) }), elementSorter: e => (e.HasSoulPatch, e.Name)); } @@ -7007,12 +6996,12 @@ public virtual Task Conditional_expression_with_test_being_simplified_to_constan return AssertQuery( isAsync, - ss => ss.Set().Where(g => g.HasSoulPatch == prm - ? true - : g.CityOfBirthName == prm2)); + ss => ss.Set().Where( + g => g.HasSoulPatch == prm + ? true + : g.CityOfBirthName == prm2)); } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Conditional_expression_with_test_being_simplified_to_constant_complex(bool isAsync) @@ -7023,9 +7012,10 @@ public virtual Task Conditional_expression_with_test_being_simplified_to_constan return AssertQuery( isAsync, - ss => ss.Set().Where(g => g.HasSoulPatch == prm - ? ss.Set().Where(w => w.Id == g.SquadId).Single().Name == prm2 - : g.CityOfBirthName == prm3)); + ss => ss.Set().Where( + g => g.HasSoulPatch == prm + ? ss.Set().Where(w => w.Id == g.SquadId).Single().Name == prm2 + : g.CityOfBirthName == prm3)); } [ConditionalTheory] @@ -7111,8 +7101,14 @@ public virtual Task Join_inner_source_custom_projection_followed_by_filter(bool async, ss => from ll in ss.Set() join h in ss.Set().OfType() - .Select(f => new { IsEradicated = f.Name == "Locust" ? (bool?)true : null, f.CommanderName, f.Name }) - on ll.Name equals h.CommanderName + .Select( + f => new + { + IsEradicated = f.Name == "Locust" ? (bool?)true : null, + f.CommanderName, + f.Name + }) + on ll.Name equals h.CommanderName where h.IsEradicated != true select h); } @@ -7300,11 +7296,12 @@ public virtual Task Checked_context_throws_on_client_evaluation(bool isAsync) () => AssertQueryScalar( isAsync, ss => ss.Set().Select(w => w.ThreatLevel >= (byte)GetThreatLevel())) - ); + ); } } - private int GetThreatLevel() => 256; + private int GetThreatLevel() + => 256; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -7392,7 +7389,8 @@ public virtual Task Contains_on_collection_of_byte_subquery(bool async) { return AssertQuery( async, - ss => ss.Set().Where(l => ss.Set().Select(ll => ll.ThreatLevelByte).Contains(l.ThreatLevelByte))); + ss => ss.Set() + .Where(l => ss.Set().Select(ll => ll.ThreatLevelByte).Contains(l.ThreatLevelByte))); } [ConditionalTheory] @@ -7401,7 +7399,8 @@ public virtual Task Contains_on_collection_of_nullable_byte_subquery(bool async) { return AssertQuery( async, - ss => ss.Set().Where(l => ss.Set().Select(ll => ll.ThreatLevelNullableByte).Contains(l.ThreatLevelNullableByte))); + ss => ss.Set().Where( + l => ss.Set().Select(ll => ll.ThreatLevelNullableByte).Contains(l.ThreatLevelNullableByte))); } [ConditionalTheory] @@ -7449,23 +7448,24 @@ public virtual Task Subquery_projecting_non_nullable_scalar_contains_non_nullabl return AssertQuery( async, ss => ss.Set() - .SelectMany(l => ss.Set() - .Where(g => ss.Set().Select(x => x.ThreatLevelByte).Contains(l.ThreatLevelByte)))); + .SelectMany( + l => ss.Set() + .Where(g => ss.Set().Select(x => x.ThreatLevelByte).Contains(l.ThreatLevelByte)))); } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(bool async) + public virtual Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated( + bool async) { return AssertQuery( async, ss => ss.Set() - .SelectMany(l => ss.Set() - .Where(g => !ss.Set().Select(x => x.ThreatLevelByte).Contains(l.ThreatLevelByte)))); + .SelectMany( + l => ss.Set() + .Where(g => !ss.Set().Select(x => x.ThreatLevelByte).Contains(l.ThreatLevelByte)))); } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async) @@ -7473,8 +7473,10 @@ public virtual Task Subquery_projecting_nullable_scalar_contains_nullable_value_ return AssertQuery( async, ss => ss.Set() - .SelectMany(l => ss.Set() - .Where(g => ss.Set().Select(x => x.ThreatLevelNullableByte).Contains(l.ThreatLevelNullableByte)))); + .SelectMany( + l => ss.Set() + .Where( + g => ss.Set().Select(x => x.ThreatLevelNullableByte).Contains(l.ThreatLevelNullableByte)))); } [ConditionalTheory] @@ -7484,8 +7486,10 @@ public virtual Task Subquery_projecting_nullable_scalar_contains_nullable_value_ return AssertQuery( async, ss => ss.Set() - .SelectMany(l => ss.Set() - .Where(g => !ss.Set().Select(x => x.ThreatLevelNullableByte).Contains(l.ThreatLevelNullableByte)))); + .SelectMany( + l => ss.Set() + .Where( + g => !ss.Set().Select(x => x.ThreatLevelNullableByte).Contains(l.ThreatLevelNullableByte)))); } [ConditionalTheory] @@ -7599,8 +7603,8 @@ public virtual Task Trying_to_access_unmapped_property_inside_aggregate(bool asy { return AssertTranslationFailedWithDetails( () => AssertQuery( - async, - ss => ss.Set().Where(c => c.BornGears.Count(g => g.IsMarcus) > 0)), + async, + ss => ss.Set().Where(c => c.BornGears.Count(g => g.IsMarcus) > 0)), CoreStrings.QueryUnableToTranslateMember(nameof(Gear.IsMarcus), nameof(Gear))); } @@ -7610,8 +7614,9 @@ public virtual Task Trying_to_access_unmapped_property_inside_subquery(bool asyn { return AssertTranslationFailedWithDetails( () => AssertQuery( - async, - ss => ss.Set().Where(c => ss.Set().Where(g => g.IsMarcus).Select(g => g.Nickname).FirstOrDefault() == "Marcus")), + async, + ss => ss.Set().Where( + c => ss.Set().Where(g => g.IsMarcus).Select(g => g.Nickname).FirstOrDefault() == "Marcus")), CoreStrings.QueryUnableToTranslateMember(nameof(Gear.IsMarcus), nameof(Gear))); } @@ -7621,11 +7626,11 @@ public virtual Task Trying_to_access_unmapped_property_inside_join_key_selector( { return AssertTranslationFailedWithDetails( () => AssertQuery( - async, - ss => from w in ss.Set() - join g in ss.Set() on w.IsAutomatic equals g.IsMarcus into grouping - from g in grouping.DefaultIfEmpty() - select new { w, g }), + async, + ss => from w in ss.Set() + join g in ss.Set() on w.IsAutomatic equals g.IsMarcus into grouping + from g in grouping.DefaultIfEmpty() + select new { w, g }), CoreStrings.QueryUnableToTranslateMember(nameof(Gear.IsMarcus), nameof(Gear))); } @@ -7649,7 +7654,8 @@ public virtual Task Client_member_and_unsupported_string_Equals_in_the_same_quer async, ss => ss.Set().Where(g => g.FullName.Equals(g.Nickname, StringComparison.InvariantCulture) || g.IsMarcus)), CoreStrings.QueryUnableToTranslateStringEqualsWithStringComparison - + Environment.NewLine + CoreStrings.QueryUnableToTranslateMember(nameof(Gear.IsMarcus), nameof(Gear))); + + Environment.NewLine + + CoreStrings.QueryUnableToTranslateMember(nameof(Gear.IsMarcus), nameof(Gear))); } [ConditionalTheory] @@ -7678,7 +7684,13 @@ public virtual Task Groupby_anonymous_type_with_navigations_followed_up_by_anony async, ss => ss.Set() .GroupBy(w => new { w.Owner.CityOfBirth.Name, w.Owner.CityOfBirth.Location }) - .Select(x => new { x.Key.Name, x.Key.Location, Count = x.Count() }) + .Select( + x => new + { + x.Key.Name, + x.Key.Location, + Count = x.Count() + }) .OrderBy(x => x.Location), assertOrder: true); } @@ -7721,7 +7733,8 @@ from w in ss.Set().Where(x => x.OwnerFullName != g.FullName).DefaultIfEm [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(bool async) + public virtual Task SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join( + bool async) { return AssertQuery( async, @@ -7801,7 +7814,8 @@ from w in ss.Set().Where(x => x.OwnerFullName != g.FullName).OrderBy(x = }); } - protected GearsOfWarContext CreateContext() => Fixture.CreateContext(); + protected GearsOfWarContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { diff --git a/test/EFCore.Specification.Tests/Query/IQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/IQueryFixtureBase.cs index c7b91790236..fdd604393a7 100644 --- a/test/EFCore.Specification.Tests/Query/IQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/IQueryFixtureBase.cs @@ -12,7 +12,8 @@ public interface IQueryFixtureBase { Func GetContextCreator(); - Func GetSetSourceCreator() => context => new DefaultSetSource(context); + Func GetSetSourceCreator() + => context => new DefaultSetSource(context); ISetSource GetExpectedData(); diff --git a/test/EFCore.Specification.Tests/Query/IncludeOneToOneTestBase.cs b/test/EFCore.Specification.Tests/Query/IncludeOneToOneTestBase.cs index 9af1e4265d5..3821429ac17 100644 --- a/test/EFCore.Specification.Tests/Query/IncludeOneToOneTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/IncludeOneToOneTestBase.cs @@ -12,7 +12,8 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class IncludeOneToOneTestBase : IClassFixture where TFixture : IncludeOneToOneTestBase.OneToOneQueryFixtureBase, new() { - protected IncludeOneToOneTestBase(TFixture fixture) => Fixture = fixture; + protected IncludeOneToOneTestBase(TFixture fixture) + => Fixture = fixture; public TFixture Fixture { get; } @@ -140,7 +141,8 @@ var addresses Assert.Equal(3 + 3, context.ChangeTracker.Entries().Count()); } - protected virtual DbContext CreateContext() => Fixture.CreateContext(); + protected virtual DbContext CreateContext() + => Fixture.CreateContext(); public abstract class OneToOneQueryFixtureBase : SharedStoreFixtureBase { diff --git a/test/EFCore.Specification.Tests/Query/InheritanceQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/InheritanceQueryFixtureBase.cs index 53b6b22fb9c..3782bf9303f 100644 --- a/test/EFCore.Specification.Tests/Query/InheritanceQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/InheritanceQueryFixtureBase.cs @@ -13,13 +13,21 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class InheritanceQueryFixtureBase : SharedStoreFixtureBase, IQueryFixtureBase { protected override string StoreName { get; } = "InheritanceTest"; - protected virtual bool EnableFilters => false; - protected virtual bool IsDiscriminatorMappingComplete => true; - protected virtual bool HasDiscriminator => true; - public Func GetContextCreator() => () => CreateContext(); + protected virtual bool EnableFilters + => false; - public ISetSource GetExpectedData() => new InheritanceData(); + protected virtual bool IsDiscriminatorMappingComplete + => true; + + protected virtual bool HasDiscriminator + => true; + + public Func GetContextCreator() + => () => CreateContext(); + + public ISetSource GetExpectedData() + => new InheritanceData(); public IReadOnlyDictionary GetEntitySorters() => new Dictionary> @@ -294,7 +302,6 @@ public IReadOnlyDictionary GetEntityAsserters() Assert.Equal(ee.SugarGrams, aa.SugarGrams); Assert.Equal(ee.CaffeineGrams, aa.CaffeineGrams); Assert.Equal(ee.Carbonation, aa.Carbonation); - } } }, @@ -311,7 +318,6 @@ public IReadOnlyDictionary GetEntityAsserters() Assert.Equal(ee.Id, aa.Id); Assert.Equal(ee.SugarGrams, aa.SugarGrams); Assert.Equal(ee.Carbonation, aa.Carbonation); - } } }, @@ -369,7 +375,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con modelBuilder.Entity(); } - protected override void Seed(InheritanceContext context) => InheritanceContext.Seed(context); + protected override void Seed(InheritanceContext context) + => InheritanceContext.Seed(context); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder); diff --git a/test/EFCore.Specification.Tests/Query/InheritanceQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/InheritanceQueryTestBase.cs index d1612980537..bca4483d48f 100644 --- a/test/EFCore.Specification.Tests/Query/InheritanceQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/InheritanceQueryTestBase.cs @@ -43,7 +43,6 @@ await AssertSingle( entryCount: 1); } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Can_query_all_types_when_shared_column(bool async) @@ -510,11 +509,11 @@ public virtual void Member_access_on_intermediate_type_works() var parameter = Expression.Parameter(query.ElementType, "p"); var property = Expression.Property(parameter, "Name"); - var getProperty = Expression.Lambda(property, new[] { parameter }); + var getProperty = Expression.Lambda(property, parameter); - var expression = Expression.Call(typeof(Queryable), nameof(Queryable.OrderBy), - new[] { query.ElementType, typeof(string) }, - new[] { query.Expression, Expression.Quote(getProperty) }); + var expression = Expression.Call( + typeof(Queryable), nameof(Queryable.OrderBy), + new[] { query.ElementType, typeof(string) }, query.Expression, Expression.Quote(getProperty)); query = query.Provider.CreateQuery(expression); @@ -557,13 +556,15 @@ public virtual Task Selecting_only_base_properties_on_derived_type(bool async) elementSorter: e => e.Name); } - protected InheritanceContext CreateContext() => Fixture.CreateContext(); + protected InheritanceContext CreateContext() + => Fixture.CreateContext(); protected virtual void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) { } - protected virtual bool EnforcesFkConstraints => true; + protected virtual bool EnforcesFkConstraints + => true; protected virtual void ClearLog() { diff --git a/test/EFCore.Specification.Tests/Query/InheritanceRelationshipsQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/InheritanceRelationshipsQueryFixtureBase.cs index 5b708577d6b..491bb65db00 100644 --- a/test/EFCore.Specification.Tests/Query/InheritanceRelationshipsQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/InheritanceRelationshipsQueryFixtureBase.cs @@ -10,51 +10,43 @@ namespace Microsoft.EntityFrameworkCore.Query { - public abstract class InheritanceRelationshipsQueryFixtureBase : SharedStoreFixtureBase, IQueryFixtureBase + public abstract class InheritanceRelationshipsQueryFixtureBase : SharedStoreFixtureBase, + IQueryFixtureBase { protected override string StoreName { get; } = "InheritanceRelationships"; - public Func GetContextCreator() => () => CreateContext(); + public Func GetContextCreator() + => () => CreateContext(); - public ISetSource GetExpectedData() => new InheritanceRelationshipsData(); + public ISetSource GetExpectedData() + => new InheritanceRelationshipsData(); public IReadOnlyDictionary GetEntitySorters() => new Dictionary> { { typeof(BaseCollectionOnBase), e => ((BaseCollectionOnBase)e)?.Id }, { typeof(DerivedCollectionOnBase), e => ((DerivedCollectionOnBase)e)?.Id }, - { typeof(BaseCollectionOnDerived), e => ((BaseCollectionOnDerived)e)?.Id }, { typeof(DerivedCollectionOnDerived), e => ((DerivedCollectionOnDerived)e)?.Id }, - { typeof(BaseInheritanceRelationshipEntity), e => ((BaseInheritanceRelationshipEntity)e)?.Id }, { typeof(DerivedInheritanceRelationshipEntity), e => ((DerivedInheritanceRelationshipEntity)e)?.Id }, - { typeof(BaseReferenceOnBase), e => ((BaseReferenceOnBase)e)?.Id }, { typeof(DerivedReferenceOnBase), e => ((DerivedReferenceOnBase)e)?.Id }, - { typeof(BaseReferenceOnDerived), e => ((BaseReferenceOnDerived)e)?.Id }, { typeof(DerivedReferenceOnDerived), e => ((DerivedReferenceOnDerived)e)?.Id }, - { typeof(CollectionOnBase), e => ((CollectionOnBase)e)?.Id }, { typeof(CollectionOnDerived), e => ((CollectionOnDerived)e)?.Id }, - { typeof(NestedCollectionBase), e => ((NestedCollectionBase)e)?.Id }, { typeof(NestedCollectionDerived), e => ((NestedCollectionDerived)e)?.Id }, - { typeof(NestedReferenceBase), e => ((NestedReferenceBase)e)?.Id }, - { typeof(NonEntityBase), e => ((NonEntityBase)e)?.Id }, { typeof(PrincipalEntity), e => ((PrincipalEntity)e)?.Id }, - { typeof(OwnedEntity), e => ((OwnedEntity)e)?.Id }, { typeof(ReferencedEntity), e => ((ReferencedEntity)e)?.Id }, - { typeof(ReferenceOnBase), e => ((ReferenceOnBase)e)?.Id }, { typeof(ReferenceOnDerived), e => ((ReferenceOnDerived)e)?.Id }, }.ToDictionary(e => e.Key, e => (object)e.Value); - public IReadOnlyDictionary GetEntityAsserters() => new Dictionary> { @@ -88,7 +80,6 @@ public IReadOnlyDictionary GetEntityAsserters() Assert.Equal(ee.Name, aa.Name); Assert.Equal(ee.BaseParentId, aa.BaseParentId); Assert.Equal(ee.DerivedProperty, aa.DerivedProperty); - } } }, @@ -105,7 +96,6 @@ public IReadOnlyDictionary GetEntityAsserters() Assert.Equal(ee.Id, aa.Id); Assert.Equal(ee.Name, aa.Name); Assert.Equal(ee.ParentId, aa.ParentId); - } } }, @@ -122,7 +112,6 @@ public IReadOnlyDictionary GetEntityAsserters() Assert.Equal(ee.Id, aa.Id); Assert.Equal(ee.Name, aa.Name); Assert.Equal(ee.ParentId, aa.ParentId); - } } }, @@ -424,7 +413,6 @@ public IReadOnlyDictionary GetEntityAsserters() //{ typeof(OwnedEntity), e => ((OwnedEntity)e)?.Id }, }.ToDictionary(e => e.Key, e => (object)e.Value); - protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { modelBuilder.Owned(); @@ -435,7 +423,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con modelBuilder.Entity(); modelBuilder.Entity(); - modelBuilder.Entity().Property(e => e.Id).ValueGeneratedNever(); modelBuilder.Entity().Property(e => e.Id).ValueGeneratedNever(); modelBuilder.Entity().Property(e => e.Id).ValueGeneratedNever(); diff --git a/test/EFCore.Specification.Tests/Query/InheritanceRelationshipsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/InheritanceRelationshipsQueryTestBase.cs index 3aac06616a6..7c3b31eee91 100644 --- a/test/EFCore.Specification.Tests/Query/InheritanceRelationshipsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/InheritanceRelationshipsQueryTestBase.cs @@ -68,7 +68,8 @@ public virtual void Entity_can_make_separate_relationships_with_base_type_and_de Assert.Equal(nameof(BaseReferenceOnDerived.BaseParent), fkOnBase.DependentToPrincipal.Name); Assert.Equal(nameof(DerivedInheritanceRelationshipEntity.BaseReferenceOnDerived), fkOnBase.PrincipalToDependent.Name); - var fkOnDerived = derivedDependentEntityType.GetDeclaredForeignKeys().Single(fk => fk.PrincipalEntityType != dependentEntityType); + var fkOnDerived = derivedDependentEntityType.GetDeclaredForeignKeys() + .Single(fk => fk.PrincipalEntityType != dependentEntityType); Assert.NotSame(fkOnBase, fkOnDerived); Assert.Equal(principalEntityType, fkOnDerived.PrincipalEntityType); Assert.Equal(derivedDependentEntityType, fkOnDerived.DeclaringEntityType); @@ -83,7 +84,8 @@ public virtual Task Include_reference_with_inheritance(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.BaseReferenceOnBase), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseReferenceOnBase))); } @@ -94,7 +96,8 @@ public virtual Task Include_reference_with_inheritance_reverse(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.BaseParent), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseParent))); } @@ -105,7 +108,8 @@ public virtual Task Include_self_reference_with_inheritance(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.DerivedSefReferenceOnBase), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.DerivedSefReferenceOnBase))); } @@ -116,7 +120,8 @@ public virtual Task Include_self_reference_with_inheritance_reverse(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.BaseSelfReferenceOnDerived), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseSelfReferenceOnDerived))); } @@ -127,7 +132,8 @@ public virtual Task Include_reference_with_inheritance_with_filter(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.BaseReferenceOnBase).Where(e => e.Name != "Bar"), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseReferenceOnBase))); } @@ -138,7 +144,8 @@ public virtual Task Include_reference_with_inheritance_with_filter_reverse(bool return AssertQuery( async, ss => ss.Set().Include(e => e.BaseParent).Where(e => e.Name != "Bar"), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseParent))); } @@ -149,7 +156,8 @@ public virtual Task Include_reference_without_inheritance(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.ReferenceOnBase), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.ReferenceOnBase))); } @@ -160,7 +168,8 @@ public virtual Task Include_reference_without_inheritance_reverse(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.Parent), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.Parent))); } @@ -171,7 +180,8 @@ public virtual Task Include_reference_without_inheritance_with_filter(bool async return AssertQuery( async, ss => ss.Set().Include(e => e.ReferenceOnBase).Where(e => e.Name != "Bar"), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.ReferenceOnBase))); } @@ -182,7 +192,8 @@ public virtual Task Include_reference_without_inheritance_with_filter_reverse(bo return AssertQuery( async, ss => ss.Set().Include(e => e.Parent).Where(e => e.Name != "Bar"), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.Parent))); } @@ -193,7 +204,8 @@ public virtual Task Include_collection_with_inheritance(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.BaseCollectionOnBase), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseCollectionOnBase))); } @@ -217,7 +229,8 @@ public virtual Task Include_collection_with_inheritance_with_filter(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.BaseCollectionOnBase).Where(e => e.Name != "Bar"), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseCollectionOnBase))); } @@ -228,7 +241,8 @@ public virtual Task Include_collection_with_inheritance_with_filter_reverse(bool return AssertQuery( async, ss => ss.Set().Include(e => e.BaseParent).Where(e => e.Name != "Bar"), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseParent))); } @@ -239,7 +253,8 @@ public virtual Task Include_collection_without_inheritance(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.CollectionOnBase), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.CollectionOnBase))); } @@ -250,7 +265,8 @@ public virtual Task Include_collection_without_inheritance_reverse(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.Parent), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.Parent))); } @@ -261,7 +277,8 @@ public virtual Task Include_collection_without_inheritance_with_filter(bool asyn return AssertQuery( async, ss => ss.Set().Include(e => e.CollectionOnBase).Where(e => e.Name != "Bar"), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.CollectionOnBase))); } @@ -272,7 +289,8 @@ public virtual Task Include_collection_without_inheritance_with_filter_reverse(b return AssertQuery( async, ss => ss.Set().Include(e => e.Parent).Where(e => e.Name != "Bar"), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.Parent))); } @@ -283,7 +301,8 @@ public virtual Task Include_reference_with_inheritance_on_derived1(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.BaseReferenceOnBase), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseReferenceOnBase))); } @@ -294,7 +313,8 @@ public virtual Task Include_reference_with_inheritance_on_derived2(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.BaseReferenceOnDerived), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseReferenceOnDerived))); } @@ -305,7 +325,8 @@ public virtual Task Include_reference_with_inheritance_on_derived4(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.DerivedReferenceOnDerived), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.DerivedReferenceOnDerived))); } @@ -316,7 +337,8 @@ public virtual Task Include_reference_with_inheritance_on_derived_reverse(bool a return AssertQuery( async, ss => ss.Set().Include(e => e.BaseParent), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseParent))); } @@ -327,7 +349,8 @@ public virtual Task Include_reference_with_inheritance_on_derived_with_filter1(b return AssertQuery( async, ss => ss.Set().Include(e => e.BaseReferenceOnBase).Where(e => e.Name != "Bar"), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseReferenceOnBase))); } @@ -338,7 +361,8 @@ public virtual Task Include_reference_with_inheritance_on_derived_with_filter2(b return AssertQuery( async, ss => ss.Set().Include(e => e.BaseReferenceOnDerived).Where(e => e.Name != "Bar"), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseReferenceOnDerived))); } @@ -349,7 +373,8 @@ public virtual Task Include_reference_with_inheritance_on_derived_with_filter4(b return AssertQuery( async, ss => ss.Set().Include(e => e.DerivedReferenceOnDerived).Where(e => e.Name != "Bar"), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.DerivedReferenceOnDerived))); } @@ -360,7 +385,8 @@ public virtual Task Include_reference_with_inheritance_on_derived_with_filter_re return AssertQuery( async, ss => ss.Set().Include(e => e.BaseParent).Where(e => e.Name != "Bar"), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseParent))); } @@ -371,7 +397,8 @@ public virtual Task Include_reference_without_inheritance_on_derived1(bool async return AssertQuery( async, ss => ss.Set().Include(e => e.ReferenceOnBase), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.ReferenceOnBase))); } @@ -382,7 +409,8 @@ public virtual Task Include_reference_without_inheritance_on_derived2(bool async return AssertQuery( async, ss => ss.Set().Include(e => e.ReferenceOnDerived), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.ReferenceOnDerived))); } @@ -393,7 +421,8 @@ public virtual Task Include_reference_without_inheritance_on_derived_reverse(boo return AssertQuery( async, ss => ss.Set().Include(e => e.Parent), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.Parent))); } @@ -404,7 +433,8 @@ public virtual Task Include_collection_with_inheritance_on_derived1(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.BaseCollectionOnBase), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseCollectionOnBase))); } @@ -415,7 +445,8 @@ public virtual Task Include_collection_with_inheritance_on_derived2(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.BaseCollectionOnDerived), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseCollectionOnDerived))); } @@ -426,7 +457,8 @@ public virtual Task Include_collection_with_inheritance_on_derived3(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.DerivedCollectionOnDerived), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.DerivedCollectionOnDerived))); } @@ -437,7 +469,8 @@ public virtual Task Include_collection_with_inheritance_on_derived_reverse(bool return AssertQuery( async, ss => ss.Set().Include(e => e.BaseParent), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseParent))); } @@ -448,7 +481,8 @@ public virtual Task Nested_include_with_inheritance_reference_reference(bool asy return AssertQuery( async, ss => ss.Set().Include(e => e.BaseReferenceOnBase.NestedReference), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseReferenceOnBase), new ExpectedInclude(x => x.NestedReference))); } @@ -460,7 +494,8 @@ public virtual Task Nested_include_with_inheritance_reference_reference_on_base( return AssertQuery( async, ss => ss.Set().Include(e => e.BaseReferenceOnBase.NestedReference), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseReferenceOnBase), new ExpectedInclude(x => x.NestedReference))); } @@ -472,7 +507,8 @@ public virtual Task Nested_include_with_inheritance_reference_reference_reverse( return AssertQuery( async, ss => ss.Set().Include(e => e.ParentReference.BaseParent), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.ParentReference), new ExpectedInclude(x => x.BaseParent))); } @@ -484,7 +520,8 @@ public virtual Task Nested_include_with_inheritance_reference_collection(bool as return AssertQuery( async, ss => ss.Set().Include(e => e.BaseReferenceOnBase.NestedCollection), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseReferenceOnBase), new ExpectedInclude(x => x.NestedCollection))); } @@ -496,7 +533,8 @@ public virtual Task Nested_include_with_inheritance_reference_collection_on_base return AssertQuery( async, ss => ss.Set().Include(e => e.BaseReferenceOnBase.NestedCollection), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseReferenceOnBase), new ExpectedInclude(x => x.NestedCollection))); } @@ -508,7 +546,8 @@ public virtual Task Nested_include_with_inheritance_reference_collection_reverse return AssertQuery( async, ss => ss.Set().Include(e => e.ParentReference.BaseParent), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.ParentReference), new ExpectedInclude(x => x.BaseParent))); } @@ -520,7 +559,8 @@ public virtual Task Nested_include_with_inheritance_collection_reference(bool as return AssertQuery( async, ss => ss.Set().Include(e => e.BaseCollectionOnBase).ThenInclude(e => e.NestedReference), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseCollectionOnBase), new ExpectedInclude(x => x.NestedReference))); } @@ -532,7 +572,8 @@ public virtual Task Nested_include_with_inheritance_collection_reference_reverse return AssertQuery( async, ss => ss.Set().Include(e => e.ParentCollection.BaseParent), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.ParentCollection), new ExpectedInclude(x => x.BaseParent))); } @@ -544,7 +585,8 @@ public virtual Task Nested_include_with_inheritance_collection_collection(bool a return AssertQuery( async, ss => ss.Set().Include(e => e.BaseCollectionOnBase).ThenInclude(e => e.NestedCollection), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.BaseCollectionOnBase), new ExpectedInclude(x => x.NestedCollection))); } @@ -556,7 +598,8 @@ public virtual Task Nested_include_with_inheritance_collection_collection_revers return AssertQuery( async, ss => ss.Set().Include(e => e.ParentCollection.BaseParent), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.ParentCollection), new ExpectedInclude(x => x.BaseParent))); } @@ -568,7 +611,8 @@ public virtual Task Nested_include_collection_reference_on_non_entity_base(bool return AssertQuery( async, ss => ss.Set().Include(e => e.Principals).ThenInclude(e => e.Reference), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(x => x.Principals), new ExpectedInclude(x => x.Reference))); } @@ -579,12 +623,9 @@ public virtual Task Collection_projection_on_base_type(bool async) { return AssertQuery( async, - ss => ss.Set().Select(e => - new - { - e.Id, - e.BaseCollectionOnBase - }), + ss => ss.Set().Select( + e => + new { e.Id, e.BaseCollectionOnBase }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -593,7 +634,8 @@ public virtual Task Collection_projection_on_base_type(bool async) }); } - protected InheritanceRelationshipsContext CreateContext() => Fixture.CreateContext(); + protected InheritanceRelationshipsContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { diff --git a/test/EFCore.Specification.Tests/Query/ManyToManyNoTrackingQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ManyToManyNoTrackingQueryTestBase.cs index 03c3311f8b3..5a3b1514f1b 100644 --- a/test/EFCore.Specification.Tests/Query/ManyToManyNoTrackingQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ManyToManyNoTrackingQueryTestBase.cs @@ -17,15 +17,16 @@ public abstract class ManyToManyNoTrackingQueryTestBase : ManyToManyQu where TFixture : ManyToManyQueryFixtureBase, new() { private static readonly MethodInfo _asNoTrackingMethodInfo - = typeof(EntityFrameworkQueryableExtensions) - .GetTypeInfo().GetDeclaredMethod(nameof(EntityFrameworkQueryableExtensions.AsNoTracking)); + = typeof(EntityFrameworkQueryableExtensions) + .GetTypeInfo().GetDeclaredMethod(nameof(EntityFrameworkQueryableExtensions.AsNoTracking)); protected ManyToManyNoTrackingQueryTestBase(TFixture fixture) : base(fixture) { } - protected override bool IgnoreEntryCount => true; + protected override bool IgnoreEntryCount + => true; protected override Expression RewriteServerQueryExpression(Expression serverQueryExpression) { @@ -39,7 +40,7 @@ protected override Expression RewriteServerQueryExpression(Expression serverQuer { return methodCallExpression.Update( null, new[] { ApplyNoTracking(methodCallExpression.Arguments[0]) } - .Concat(methodCallExpression.Arguments.Skip(1))); + .Concat(methodCallExpression.Arguments.Skip(1))); } return ApplyNoTracking(serverQueryExpression); @@ -47,8 +48,8 @@ protected override Expression RewriteServerQueryExpression(Expression serverQuer static Expression ApplyNoTracking(Expression source) { return Expression.Call( - _asNoTrackingMethodInfo.MakeGenericMethod(source.Type.TryGetSequenceType()), - source); + _asNoTrackingMethodInfo.MakeGenericMethod(source.Type.TryGetSequenceType()), + source); } } @@ -61,12 +62,15 @@ public virtual async Task Include_skip_navigation_then_include_inverse_throws_in (await Assert.ThrowsAsync( () => AssertQuery( async, - ss => ss.Set().AsNoTracking().Include(e => e.OneSkipPayloadFullShared).ThenInclude(e => e.ThreeSkipPayloadFullShared), - elementAsserter: (e, a) => AssertInclude(e, a, + ss => ss.Set().AsNoTracking().Include(e => e.OneSkipPayloadFullShared) + .ThenInclude(e => e.ThreeSkipPayloadFullShared), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.OneSkipPayloadFullShared), new ExpectedInclude(et => et.ThreeSkipPayloadFullShared, "OneSkipPayloadFullShared"))))).Message); } - public override Task Include_skip_navigation_then_include_inverse_works_for_tracking_query(bool async) => Task.CompletedTask; + public override Task Include_skip_navigation_then_include_inverse_works_for_tracking_query(bool async) + => Task.CompletedTask; } } diff --git a/test/EFCore.Specification.Tests/Query/ManyToManyQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/ManyToManyQueryFixtureBase.cs index a8f6591beff..c62fb5f1dc9 100644 --- a/test/EFCore.Specification.Tests/Query/ManyToManyQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/ManyToManyQueryFixtureBase.cs @@ -14,9 +14,11 @@ public abstract class ManyToManyQueryFixtureBase : SharedStoreFixtureBase GetContextCreator() => () => CreateContext(); + public Func GetContextCreator() + => () => CreateContext(); - public ISetSource GetExpectedData() => new ManyToManyData(); + public ISetSource GetExpectedData() + => new ManyToManyData(); public IReadOnlyDictionary GetEntitySorters() => new Dictionary> @@ -24,7 +26,10 @@ public IReadOnlyDictionary GetEntitySorters() { typeof(EntityOne), e => ((EntityOne)e)?.Id }, { typeof(EntityTwo), e => ((EntityTwo)e)?.Id }, { typeof(EntityThree), e => ((EntityThree)e)?.Id }, - { typeof(EntityCompositeKey), e => (((EntityCompositeKey)e)?.Key1,((EntityCompositeKey)e)?.Key2 ,((EntityCompositeKey)e)?.Key3 ) }, + { + typeof(EntityCompositeKey), + e => (((EntityCompositeKey)e)?.Key1, ((EntityCompositeKey)e)?.Key2, ((EntityCompositeKey)e)?.Key3) + }, { typeof(EntityRoot), e => ((EntityRoot)e)?.Id }, { typeof(EntityBranch), e => ((EntityBranch)e)?.Id }, { typeof(EntityLeaf), e => ((EntityLeaf)e)?.Id }, @@ -150,7 +155,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con modelBuilder.Entity().Property(e => e.Id).ValueGeneratedNever(); modelBuilder.Entity().Property(e => e.Id).ValueGeneratedNever(); modelBuilder.Entity().Property(e => e.Id).ValueGeneratedNever(); - modelBuilder.Entity().HasKey(e => new { e.Key1, e.Key2, e.Key3 }); + modelBuilder.Entity().HasKey( + e => new + { + e.Key1, + e.Key2, + e.Key3 + }); modelBuilder.Entity().Property(e => e.Id).ValueGeneratedNever(); modelBuilder.Entity().HasBaseType(); modelBuilder.Entity().HasBaseType(); @@ -260,7 +271,13 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con .HasMany(e => e.CompositeKeySkipFull) .WithMany(e => e.ThreeSkipFull) .UsingEntity( - l => l.HasOne(x => x.Composite).WithMany(x => x.JoinThreeFull).HasForeignKey(e => new { e.CompositeId1, e.CompositeId2, e.CompositeId3 }).IsRequired(), + l => l.HasOne(x => x.Composite).WithMany(x => x.JoinThreeFull).HasForeignKey( + e => new + { + e.CompositeId1, + e.CompositeId2, + e.CompositeId3 + }).IsRequired(), r => r.HasOne(x => x.Three).WithMany(x => x.JoinCompositeKeyFull).IsRequired()); // Nav:2 Payload:No Join:Shared Extra:Inheritance @@ -288,11 +305,24 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con .WithMany(e => e.CompositeKeySkipFull) .UsingEntity( r => r.HasOne(x => x.Leaf).WithMany(x => x.JoinCompositeKeyFull), - l => l.HasOne(x => x.Composite).WithMany(x => x.JoinLeafFull).HasForeignKey(e => new { e.CompositeId1, e.CompositeId2, e.CompositeId3 })) - .HasKey(e => new { e.CompositeId1, e.CompositeId2, e.CompositeId3, e.LeafId }); + l => l.HasOne(x => x.Composite).WithMany(x => x.JoinLeafFull).HasForeignKey( + e => new + { + e.CompositeId1, + e.CompositeId2, + e.CompositeId3 + })) + .HasKey( + e => new + { + e.CompositeId1, + e.CompositeId2, + e.CompositeId3, + e.LeafId + }); } - protected override void Seed(ManyToManyContext context) => ManyToManyContext.Seed(context); + protected override void Seed(ManyToManyContext context) + => ManyToManyContext.Seed(context); } } - diff --git a/test/EFCore.Specification.Tests/Query/ManyToManyQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ManyToManyQueryTestBase.cs index 714c23b9c6a..cf716b625f8 100644 --- a/test/EFCore.Specification.Tests/Query/ManyToManyQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ManyToManyQueryTestBase.cs @@ -98,7 +98,8 @@ public virtual Task Skip_navigation_long_count_with_predicate(bool async) { return AssertQuery( async, - ss => ss.Set().OrderByDescending(e => e.SelfSkipSharedLeft.LongCount(e => e.Name.StartsWith("L"))).ThenBy(e => e.Id), + ss => ss.Set().OrderByDescending(e => e.SelfSkipSharedLeft.LongCount(e => e.Name.StartsWith("L"))) + .ThenBy(e => e.Id), assertOrder: true, entryCount: 20); } @@ -249,7 +250,7 @@ public virtual Task Join_with_skip_navigation(bool async) async, ss => from t in ss.Set() join s in ss.Set() - on t.Id equals s.SelfSkipSharedRight.OrderBy(e => e.Id).FirstOrDefault().Id + on t.Id equals s.SelfSkipSharedRight.OrderBy(e => e.Id).FirstOrDefault().Id select new { t, s }, elementSorter: e => (e.t.Id, e.s.Id), elementAsserter: (e, a) => @@ -268,13 +269,15 @@ public virtual Task Left_join_with_skip_navigation(bool async) async, ss => from t in ss.Set() join s in ss.Set() - on t.TwoSkipShared.OrderBy(e => e.Id).FirstOrDefault().Id equals s.ThreeSkipFull.OrderBy(e => e.Id).FirstOrDefault().Id into grouping + on t.TwoSkipShared.OrderBy(e => e.Id).FirstOrDefault().Id equals s.ThreeSkipFull.OrderBy(e => e.Id) + .FirstOrDefault().Id into grouping from s in grouping.DefaultIfEmpty() orderby t.Key1, s.Key1, t.Key2, s.Key2 select new { t, s }, ss => from t in ss.Set() join s in ss.Set() - on t.TwoSkipShared.OrderBy(e => e.Id).FirstOrDefault().MaybeScalar(e => e.Id) equals s.ThreeSkipFull.OrderBy(e => e.Id).FirstOrDefault().MaybeScalar(e => e.Id) into grouping + on t.TwoSkipShared.OrderBy(e => e.Id).FirstOrDefault().MaybeScalar(e => e.Id) equals s.ThreeSkipFull + .OrderBy(e => e.Id).FirstOrDefault().MaybeScalar(e => e.Id) into grouping from s in grouping.DefaultIfEmpty() orderby t.Key1, s.MaybeScalar(e => e.Key1), t.Key2, s.Key2 select new { t, s }, @@ -440,7 +443,8 @@ public virtual Task Include_skip_navigation_then_reference(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.OneSkip).ThenInclude(e => e.Reference), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.OneSkip), new ExpectedInclude(et => et.Reference, "OneSkip")), entryCount: 151); @@ -453,7 +457,8 @@ public virtual Task Include_skip_navigation_then_include_skip_navigation(bool as return AssertQuery( async, ss => ss.Set().Include(e => e.LeafSkipFull).ThenInclude(e => e.OneSkip), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.LeafSkipFull), new ExpectedInclude(et => et.OneSkip, "LeafSkipFull")), entryCount: 83); @@ -467,7 +472,8 @@ public virtual Task Include_skip_navigation_then_include_reference_and_skip_navi async, ss => ss.Set().Include(e => e.OneSkipPayloadFull).ThenInclude(e => e.Reference) .Include(e => e.OneSkipPayloadFull).ThenInclude(e => e.SelfSkipPayloadRight), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.OneSkipPayloadFull), new ExpectedInclude(et => et.Reference, "OneSkipPayloadFull"), new ExpectedInclude(et => et.SelfSkipPayloadRight, "OneSkipPayloadFull")), @@ -481,7 +487,8 @@ public virtual Task Include_skip_navigation_and_reference(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.OneSkipShared).Include(e => e.Reference), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.OneSkipShared), new ExpectedInclude(et => et.Reference)), entryCount: 93); @@ -495,7 +502,8 @@ public virtual Task Include_skip_navigation_then_include_inverse_works_for_track async, ss => ss.Set().Include(e => e.OneSkipPayloadFullShared).ThenInclude(e => e.ThreeSkipPayloadFullShared), entryCount: 76, - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.OneSkipPayloadFullShared), new ExpectedInclude(et => et.ThreeSkipPayloadFullShared, "OneSkipPayloadFullShared"))); } @@ -507,7 +515,8 @@ public virtual Task Filtered_include_skip_navigation_where(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.OneSkipPayloadFullShared.Where(i => i.Id < 10)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.OneSkipPayloadFullShared, includeFilter: x => x.Where(i => i.Id < 10))), entryCount: 42); @@ -520,7 +529,8 @@ public virtual Task Filtered_include_skip_navigation_order_by(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.TwoSkipFull.OrderBy(i => i.Id)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.TwoSkipFull, includeFilter: x => x.OrderBy(i => i.Id))), entryCount: 91); @@ -533,7 +543,8 @@ public virtual Task Filtered_include_skip_navigation_order_by_skip(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.SelfSkipSharedRight.OrderBy(i => i.Id).Skip(2)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.SelfSkipSharedRight, includeFilter: x => x.OrderBy(i => i.Id).Skip(2))), entryCount: 31); @@ -546,7 +557,8 @@ public virtual Task Filtered_include_skip_navigation_order_by_take(bool async) return AssertQuery( async, ss => ss.Set().Include(e => e.TwoSkipShared.OrderBy(i => i.Id).Take(2)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.TwoSkipShared, includeFilter: x => x.OrderBy(i => i.Id).Take(2))), entryCount: 63); @@ -559,7 +571,8 @@ public virtual Task Filtered_include_skip_navigation_order_by_skip_take(bool asy return AssertQuery( async, ss => ss.Set().Include(e => e.ThreeSkipFull.OrderBy(i => i.Id).Skip(1).Take(2)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.ThreeSkipFull, includeFilter: x => x.OrderBy(i => i.Id).Skip(1).Take(2))), entryCount: 57); @@ -571,8 +584,10 @@ public virtual Task Filtered_then_include_skip_navigation_where(bool async) { return AssertQuery( async, - ss => ss.Set().Include(e => e.ThreeSkipShared).ThenInclude(e => e.OneSkipPayloadFullShared.Where(i => i.Id < 10)), - elementAsserter: (e, a) => AssertInclude(e, a, + ss => ss.Set().Include(e => e.ThreeSkipShared) + .ThenInclude(e => e.OneSkipPayloadFullShared.Where(i => i.Id < 10)), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.ThreeSkipShared), new ExpectedFilteredInclude( et => et.OneSkipPayloadFullShared, "ThreeSkipShared", includeFilter: x => x.Where(i => i.Id < 10))), @@ -585,8 +600,10 @@ public virtual Task Filtered_then_include_skip_navigation_order_by_skip_take(boo { return AssertQuery( async, - ss => ss.Set().Include(e => e.CompositeKeySkipShared).ThenInclude(e => e.ThreeSkipFull.OrderBy(i => i.Id).Skip(1).Take(2)), - elementAsserter: (e, a) => AssertInclude(e, a, + ss => ss.Set().Include(e => e.CompositeKeySkipShared) + .ThenInclude(e => e.ThreeSkipFull.OrderBy(i => i.Id).Skip(1).Take(2)), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(et => et.CompositeKeySkipShared), new ExpectedFilteredInclude( et => et.ThreeSkipFull, "CompositeKeySkipShared", includeFilter: x => x.OrderBy(i => i.Id).Skip(1).Take(2))), @@ -600,7 +617,8 @@ public virtual Task Filtered_include_skip_navigation_where_then_include_skip_nav return AssertQuery( async, ss => ss.Set().Include(e => e.CompositeKeySkipFull.Where(i => i.Key1 < 5)).ThenInclude(e => e.TwoSkipShared), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.CompositeKeySkipFull, includeFilter: x => x.Where(i => i.Key1 < 5)), new ExpectedInclude(et => et.TwoSkipShared, "CompositeKeySkipFull")), @@ -615,7 +633,8 @@ public virtual Task Filtered_include_skip_navigation_order_by_skip_take_then_inc async, ss => ss.Set().Include(e => e.TwoSkip.OrderBy(i => i.Id).Skip(1).Take(2)) .ThenInclude(e => e.ThreeSkipFull.Where(i => i.Id < 10)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.TwoSkip, includeFilter: x => x.OrderBy(i => i.Id).Skip(1).Take(2)), new ExpectedFilteredInclude( @@ -631,7 +650,8 @@ public virtual Task Filtered_include_skip_navigation_where_then_include_skip_nav async, ss => ss.Set().Include(e => e.TwoSkip.Where(i => i.Id < 10)) .ThenInclude(e => e.ThreeSkipFull.OrderBy(i => i.Id).Skip(1).Take(2)), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude( et => et.TwoSkip, includeFilter: x => x.Where(i => i.Id < 10)), new ExpectedFilteredInclude( @@ -647,7 +667,8 @@ public virtual Task Filter_include_on_skip_navigation_combined(bool async) async, ss => ss.Set().Include(e => e.OneSkip.Where(i => i.Id < 10)).ThenInclude(e => e.Reference) .Include(e => e.OneSkip).ThenInclude(e => e.Collection), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude(et => et.OneSkip, includeFilter: x => x.Where(i => i.Id < 10)), new ExpectedInclude(et => et.Reference, "OneSkip"), new ExpectedInclude(et => et.Collection, "OneSkip")), @@ -660,12 +681,17 @@ public virtual Task Filter_include_on_skip_navigation_combined_with_filtered_the { return AssertQuery( async, - ss => ss.Set().Include(e => e.OneSkipPayloadFull.Where(i => i.Id < 10)).ThenInclude(e => e.TwoSkip.OrderBy(e => e.Id).Skip(1).Take(2)) + ss => ss.Set().Include(e => e.OneSkipPayloadFull.Where(i => i.Id < 10)) + .ThenInclude(e => e.TwoSkip.OrderBy(e => e.Id).Skip(1).Take(2)) .Include(e => e.OneSkipPayloadFull).ThenInclude(e => e.BranchSkip.Where(e => e.Id < 20)), - elementAsserter: (e, a) => AssertInclude(e, a, - new ExpectedFilteredInclude(et => et.OneSkipPayloadFull, includeFilter: x => x.Where(i => i.Id < 10)), - new ExpectedFilteredInclude(et => et.TwoSkip, "OneSkipPayloadFull", includeFilter: x => x.OrderBy(e => e.Id).Skip(1).Take(2)), - new ExpectedFilteredInclude(et => et.BranchSkip, "OneSkipPayloadFull", includeFilter: x => x.Where(e => e.Id < 20))), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + et => et.OneSkipPayloadFull, includeFilter: x => x.Where(i => i.Id < 10)), + new ExpectedFilteredInclude( + et => et.TwoSkip, "OneSkipPayloadFull", includeFilter: x => x.OrderBy(e => e.Id).Skip(1).Take(2)), + new ExpectedFilteredInclude( + et => et.BranchSkip, "OneSkipPayloadFull", includeFilter: x => x.Where(e => e.Id < 20))), entryCount: 116); } @@ -674,14 +700,15 @@ public virtual Task Filter_include_on_skip_navigation_combined_with_filtered_the public virtual async Task Throws_when_different_filtered_include(bool async) { Assert.Equal( - CoreStrings.MultipleFilteredIncludesOnSameNavigation("navigation .Where(i => i.Id < 20)", "navigation .Where(i => i.Id < 10)") + CoreStrings.MultipleFilteredIncludesOnSameNavigation( + "navigation .Where(i => i.Id < 20)", "navigation .Where(i => i.Id < 10)") .Replace("\r", "").Replace("\n", ""), (await Assert.ThrowsAsync( () => AssertQuery( async, ss => ss.Set().Include(e => e.OneSkip.Where(i => i.Id < 10)).ThenInclude(e => e.BranchSkip) .Include(e => e.OneSkip.Where(i => i.Id < 20)).ThenInclude(e => e.ThreeSkipPayloadFull)))).Message - .Replace("\r", "").Replace("\n", "")); + .Replace("\r", "").Replace("\n", "")); } [ConditionalTheory] @@ -689,17 +716,18 @@ public virtual async Task Throws_when_different_filtered_include(bool async) public virtual async Task Throws_when_different_filtered_then_include(bool async) { Assert.Equal( - CoreStrings.MultipleFilteredIncludesOnSameNavigation("navigation .Where(i => i.Id < 20)", "navigation .Where(i => i.Id < 10)") + CoreStrings.MultipleFilteredIncludesOnSameNavigation( + "navigation .Where(i => i.Id < 20)", "navigation .Where(i => i.Id < 10)") .Replace("\r", "").Replace("\n", ""), (await Assert.ThrowsAsync( () => AssertQuery( async, ss => ss.Set() .Include(e => e.TwoSkipShared) - .ThenInclude(e => e.OneSkip.Where(i => i.Id < 10)).ThenInclude(e => e.BranchSkip) + .ThenInclude(e => e.OneSkip.Where(i => i.Id < 10)).ThenInclude(e => e.BranchSkip) .Include(e => e.TwoSkipShared) - .ThenInclude(e => e.OneSkip.Where(i => i.Id < 20)).ThenInclude(e => e.ThreeSkipPayloadFull)))).Message - .Replace("\r", "").Replace("\n", "")); + .ThenInclude(e => e.OneSkip.Where(i => i.Id < 20)).ThenInclude(e => e.ThreeSkipPayloadFull)))).Message + .Replace("\r", "").Replace("\n", "")); } [ConditionalTheory] @@ -708,10 +736,14 @@ public virtual Task Filtered_include_on_skip_navigation_then_filtered_include_on { return AssertQuery( async, - ss => ss.Set().Include(e => e.OneSkipPayloadFull.Where(i => i.Id > 15)).ThenInclude(e => e.Collection.Where(i => i.Id < 5)), - elementAsserter: (e, a) => AssertInclude(e, a, - new ExpectedFilteredInclude(et => et.OneSkipPayloadFull, includeFilter: x => x.Where(i => i.Id > 15)), - new ExpectedFilteredInclude(et => et.Collection, "OneSkipPayloadFull", includeFilter: x => x.Where(i => i.Id < 5))), + ss => ss.Set().Include(e => e.OneSkipPayloadFull.Where(i => i.Id > 15)) + .ThenInclude(e => e.Collection.Where(i => i.Id < 5)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + et => et.OneSkipPayloadFull, includeFilter: x => x.Where(i => i.Id > 15)), + new ExpectedFilteredInclude( + et => et.Collection, "OneSkipPayloadFull", includeFilter: x => x.Where(i => i.Id < 5))), entryCount: 61); } @@ -721,10 +753,13 @@ public virtual Task Filtered_include_on_navigation_then_filtered_include_on_skip { return AssertQuery( async, - ss => ss.Set().Include(e => e.Collection.Where(i => i.Id > 15)).ThenInclude(e => e.ThreeSkipFull.Where(i => i.Id < 5)), - elementAsserter: (e, a) => AssertInclude(e, a, + ss => ss.Set().Include(e => e.Collection.Where(i => i.Id > 15)) + .ThenInclude(e => e.ThreeSkipFull.Where(i => i.Id < 5)), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedFilteredInclude(et => et.Collection, includeFilter: x => x.Where(i => i.Id > 15)), - new ExpectedFilteredInclude(et => et.ThreeSkipFull, "Collection", includeFilter: x => x.Where(i => i.Id < 5))), + new ExpectedFilteredInclude( + et => et.ThreeSkipFull, "Collection", includeFilter: x => x.Where(i => i.Id < 5))), entryCount: 29); } @@ -736,7 +771,8 @@ public virtual Task Includes_accessed_via_different_path_are_merged(bool async) async, ss => ss.Set().Include(e => e.ThreeSkipPayloadFull).ThenInclude(e => e.CollectionInverse) .Include(e => e.JoinThreePayloadFull).ThenInclude(e => e.Three).ThenInclude(e => e.ReferenceInverse), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.ThreeSkipPayloadFull), new ExpectedInclude(e => e.CollectionInverse, "ThreeSkipPayloadFull"), new ExpectedInclude(e => e.JoinThreePayloadFull), @@ -754,13 +790,17 @@ public virtual Task Filered_includes_accessed_via_different_path_are_merged(bool return AssertQuery( async, ss => ss.Set().Include(e => e.OneSkipPayloadFull).ThenInclude(e => e.Collection.Where(i => i.Id < 5)) - .Include(e => e.JoinOnePayloadFull).ThenInclude(e => e.One).ThenInclude(e => e.Collection).ThenInclude(e => e.Reference), - elementAsserter: (e, a) => AssertInclude(e, a, + .Include(e => e.JoinOnePayloadFull).ThenInclude(e => e.One).ThenInclude(e => e.Collection) + .ThenInclude(e => e.Reference), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(e => e.OneSkipPayloadFull), - new ExpectedFilteredInclude(e => e.Collection, "OneSkipPayloadFull", includeFilter: x => x.Where(i => i.Id < 5)), + new ExpectedFilteredInclude( + e => e.Collection, "OneSkipPayloadFull", includeFilter: x => x.Where(i => i.Id < 5)), new ExpectedInclude(e => e.JoinOnePayloadFull), new ExpectedInclude(e => e.One, "JoinOnePayloadFull"), - new ExpectedFilteredInclude(e => e.Collection, "JoinOnePayloadFull.One", includeFilter: x => x.Where(i => i.Id < 5)), + new ExpectedFilteredInclude( + e => e.Collection, "JoinOnePayloadFull.One", includeFilter: x => x.Where(i => i.Id < 5)), new ExpectedInclude(e => e.Reference, "OneSkipPayloadFull.Collection"), new ExpectedInclude(e => e.Reference, "JoinOnePayloadFull.One.Collection")), entryCount: 0); @@ -771,18 +811,19 @@ public virtual Task Filered_includes_accessed_via_different_path_are_merged(bool public virtual async Task Throws_when_different_filtered_then_include_via_different_paths(bool async) { Assert.Equal( - CoreStrings.MultipleFilteredIncludesOnSameNavigation("navigation .Where(i => i.Id < 20)", "navigation .Where(i => i.Id < 10)") + CoreStrings.MultipleFilteredIncludesOnSameNavigation( + "navigation .Where(i => i.Id < 20)", "navigation .Where(i => i.Id < 10)") .Replace("\r", "").Replace("\n", ""), (await Assert.ThrowsAsync( () => AssertQuery( async, ss => ss.Set() .Include(e => e.OneSkipPayloadFull) - .ThenInclude(e => e.Collection.Where(i => i.Id < 20)) + .ThenInclude(e => e.Collection.Where(i => i.Id < 20)) .Include(e => e.JoinOnePayloadFull) - .ThenInclude(e => e.One) - .ThenInclude(e => e.Collection.Where(i => i.Id < 10))))).Message - .Replace("\r", "").Replace("\n", "")); + .ThenInclude(e => e.One) + .ThenInclude(e => e.Collection.Where(i => i.Id < 10))))).Message + .Replace("\r", "").Replace("\n", "")); } [ConditionalTheory] @@ -800,7 +841,8 @@ from t in r.TwoSkip.Where(x => x.Id != r.Id).DefaultIfEmpty() // When adding include test here always add a tracking version and a split version in relational layer. // Keep this line at the bottom for next dev writing tests to see. - protected ManyToManyContext CreateContext() => Fixture.CreateContext(); + protected ManyToManyContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { diff --git a/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs index 9a1e0c38631..d57d06760f9 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs @@ -24,7 +24,8 @@ protected NorthwindAggregateOperatorsQueryTestBase(TFixture fixture) { } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { @@ -48,7 +49,8 @@ private class ProjectedType public int Order { get; set; } public string Customer { get; set; } - private bool Equals(ProjectedType other) => Equals(Order, other.Order); + private bool Equals(ProjectedType other) + => Equals(Order, other.Order); public override bool Equals(object obj) { @@ -63,7 +65,8 @@ public override bool Equals(object obj) && Equals((ProjectedType)obj); } - public override int GetHashCode() => Order.GetHashCode(); + public override int GetHashCode() + => Order.GetHashCode(); } [ConditionalTheory] @@ -712,9 +715,11 @@ public virtual Task OrderBy_client_Take(bool async) entryCount: 9); } - protected static bool ClientEvalPredicate(Order order) => order.OrderID > 10000; + protected static bool ClientEvalPredicate(Order order) + => order.OrderID > 10000; - private static int ClientEvalSelectorStateless() => 42; + private static int ClientEvalSelectorStateless() + => 42; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -1537,7 +1542,7 @@ public virtual Task ImmutableHashSet_Contains_with_parameter(bool async) entryCount: 1); } - private static readonly IEnumerable _customers = new string[] { "ALFKI", "WRONG" }; + private static readonly IEnumerable _customers = new[] { "ALFKI", "WRONG" }; [ConditionalTheory(Skip = "Issue#18658")] [MemberData(nameof(IsAsyncData))] @@ -1581,7 +1586,8 @@ public virtual Task Contains_over_scalar_with_null_should_rewrite_to_identity_eq { return AssertQuery( async, - ss => ss.Set().Where(o => ss.Set().Where(o => o.CustomerID == "VINET").Select(o => o.CustomerID).Contains(null))); + ss => ss.Set().Where( + o => ss.Set().Where(o => o.CustomerID == "VINET").Select(o => o.CustomerID).Contains(null))); } [ConditionalTheory] @@ -1590,7 +1596,8 @@ public virtual Task Contains_over_entityType_with_null_should_rewrite_to_identit { return AssertQuery( async, - ss => ss.Set().Where(o => !ss.Set().Where(o => o.CustomerID == "VINET").Select(o => o.CustomerID).Contains(null)), + ss => ss.Set().Where( + o => !ss.Set().Where(o => o.CustomerID == "VINET").Select(o => o.CustomerID).Contains(null)), entryCount: 830); } @@ -1600,9 +1607,11 @@ public virtual Task Contains_over_entityType_with_null_should_rewrite_to_identit { return AssertQuery( async, - ss => ss.Set().Where(o => ss.Set().Where(o => o.CustomerID == "VINET").Select(o => o.CustomerID) - .Contains(null) == ss.Set().Where(o => o.CustomerID != "VINET").Select(o => o.CustomerID) - .Contains(null)), + ss => ss.Set().Where( + o => ss.Set().Where(o => o.CustomerID == "VINET").Select(o => o.CustomerID) + .Contains(null) + == ss.Set().Where(o => o.CustomerID != "VINET").Select(o => o.CustomerID) + .Contains(null)), entryCount: 830); } @@ -1612,7 +1621,8 @@ public virtual Task Contains_over_nullable_scalar_with_null_in_subquery_translat { return AssertQueryScalar( async, - ss => ss.Set().Select(o => ss.Set().Where(o => o.CustomerID == "VINET").Select(o => o.CustomerID).Contains(null))); + ss => ss.Set().Select( + o => ss.Set().Where(o => o.CustomerID == "VINET").Select(o => o.CustomerID).Contains(null))); } [ConditionalTheory] @@ -1621,7 +1631,8 @@ public virtual Task Contains_over_non_nullable_scalar_with_null_in_subquery_simp { return AssertQueryScalar( async, - ss => ss.Set().Select(o => ss.Set().Where(o => o.CustomerID != "VINET").Select(o => o.CustomerID).Contains(null))); + ss => ss.Set().Select( + o => ss.Set().Where(o => o.CustomerID != "VINET").Select(o => o.CustomerID).Contains(null))); } [ConditionalTheory] @@ -1900,13 +1911,14 @@ public virtual Task Average_with_unmapped_property_access_throws_meaningful_exce { return AssertTranslationFailedWithDetails( () => AssertAverage( - async, - ss => ss.Set(), - selector: c => c.ShipVia), + async, + ss => ss.Set(), + selector: c => c.ShipVia), CoreStrings.QueryUnableToTranslateMember(nameof(Order.ShipVia), nameof(Order))); } - private static string CodeFormat(int str) => str.ToString(); + private static string CodeFormat(int str) + => str.ToString(); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] diff --git a/test/EFCore.Specification.Tests/Query/NorthwindAsNoTrackingQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindAsNoTrackingQueryTestBase.cs index 203c89ba461..46105758fc1 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindAsNoTrackingQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindAsNoTrackingQueryTestBase.cs @@ -14,7 +14,8 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class NorthwindAsNoTrackingQueryTestBase : IClassFixture where TFixture : NorthwindQueryFixtureBase, new() { - protected NorthwindAsNoTrackingQueryTestBase(TFixture fixture) => Fixture = fixture; + protected NorthwindAsNoTrackingQueryTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -189,6 +190,7 @@ from c in context.Set() Assert.Equal(819, results.Count); } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); } } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindAsTrackingQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindAsTrackingQueryTestBase.cs index b654342008d..0242070ae3b 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindAsTrackingQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindAsTrackingQueryTestBase.cs @@ -12,7 +12,8 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class NorthwindAsTrackingQueryTestBase : IClassFixture where TFixture : NorthwindQueryFixtureBase, new() { - protected NorthwindAsTrackingQueryTestBase(TFixture fixture) => Fixture = fixture; + protected NorthwindAsTrackingQueryTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindAsyncSimpleQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindAsyncSimpleQueryTestBase.cs index ee28d55c07e..03939df6666 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindAsyncSimpleQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindAsyncSimpleQueryTestBase.cs @@ -27,7 +27,8 @@ protected NorthwindAsyncSimpleQueryTestBase(TFixture fixture) { } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); [ConditionalFact] public virtual async Task Query_backed_by_database_view() diff --git a/test/EFCore.Specification.Tests/Query/NorthwindChangeTrackingQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindChangeTrackingQueryTestBase.cs index 70d6774ffab..8599c0a924f 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindChangeTrackingQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindChangeTrackingQueryTestBase.cs @@ -12,7 +12,8 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class NorthwindChangeTrackingQueryTestBase : IClassFixture where TFixture : NorthwindQueryFixtureBase, new() { - protected NorthwindChangeTrackingQueryTestBase(TFixture fixture) => Fixture = fixture; + protected NorthwindChangeTrackingQueryTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -396,7 +397,8 @@ on c.CustomerID equals o.CustomerID Assert.Empty(context.ChangeTracker.Entries()); } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); protected virtual NorthwindContext CreateNoTrackingContext() => new NorthwindContext( diff --git a/test/EFCore.Specification.Tests/Query/NorthwindCompiledQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindCompiledQueryTestBase.cs index e8e074187e2..925020239ee 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindCompiledQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindCompiledQueryTestBase.cs @@ -5,11 +5,11 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Utilities; +using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; +using Microsoft.EntityFrameworkCore.Utilities; using Xunit; -using Microsoft.EntityFrameworkCore.Diagnostics; // ReSharper disable AccessToModifiedClosure // ReSharper disable InconsistentNaming @@ -19,7 +19,8 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class NorthwindCompiledQueryTestBase : IClassFixture where TFixture : NorthwindQueryFixtureBase, new() { - protected NorthwindCompiledQueryTestBase(TFixture fixture) => Fixture = fixture; + protected NorthwindCompiledQueryTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -479,7 +480,7 @@ public virtual async Task Query_with_array_parameter_async() Assert.Equal( CoreStrings.TranslationFailed("DbSet() .Where(c => c.CustomerID == __args[0])"), (await Assert.ThrowsAsync( - () => query(context, new[] { "ALFKI" }).ToListAsync())).Message.Replace("\r", "").Replace("\n","")); + () => query(context, new[] { "ALFKI" }).ToListAsync())).Message.Replace("\r", "").Replace("\n", "")); } using (var context = CreateContext()) @@ -562,91 +563,307 @@ public virtual void Compiled_query_when_using_member_on_context() public virtual async Task Compiled_query_with_max_parameters() { var syncEnumerableQuery = EF.CompileQuery( - (NorthwindContext context, string s1, string s2, string s3, string s4, string s5, string s6, string s7, string s8, - string s9, string s10, string s11, string s12, string s13, string s14, string s15) - => context.Set() - .Where(c => c.CustomerID == s1 || c.CustomerID == s2 || c.CustomerID == s3 || c.CustomerID == s4 || c.CustomerID == s5 - || c.CustomerID == s6 || c.CustomerID == s7 || c.CustomerID == s8 || c.CustomerID == s9 || c.CustomerID == s10 - || c.CustomerID == s11 || c.CustomerID == s12 || c.CustomerID == s13 || c.CustomerID == s14 || c.CustomerID == s15)); + ( + NorthwindContext context, + string s1, + string s2, + string s3, + string s4, + string s5, + string s6, + string s7, + string s8, + string s9, + string s10, + string s11, + string s12, + string s13, + string s14, + string s15) + => context.Set() + .Where( + c => c.CustomerID == s1 + || c.CustomerID == s2 + || c.CustomerID == s3 + || c.CustomerID == s4 + || c.CustomerID == s5 + || c.CustomerID == s6 + || c.CustomerID == s7 + || c.CustomerID == s8 + || c.CustomerID == s9 + || c.CustomerID == s10 + || c.CustomerID == s11 + || c.CustomerID == s12 + || c.CustomerID == s13 + || c.CustomerID == s14 + || c.CustomerID == s15)); var syncIncludeEnumerableQuery = EF.CompileQuery( - (NorthwindContext context, string s1, string s2, string s3, string s4, string s5, string s6, string s7, string s8, - string s9, string s10, string s11, string s12, string s13, string s14, string s15) - => context.Set() - .Where(c => c.CustomerID == s1 || c.CustomerID == s2 || c.CustomerID == s3 || c.CustomerID == s4 || c.CustomerID == s5 - || c.CustomerID == s6 || c.CustomerID == s7 || c.CustomerID == s8 || c.CustomerID == s9 || c.CustomerID == s10 - || c.CustomerID == s11 || c.CustomerID == s12 || c.CustomerID == s13 || c.CustomerID == s14 || c.CustomerID == s15) - .Include(c => c.Orders)); + ( + NorthwindContext context, + string s1, + string s2, + string s3, + string s4, + string s5, + string s6, + string s7, + string s8, + string s9, + string s10, + string s11, + string s12, + string s13, + string s14, + string s15) + => context.Set() + .Where( + c => c.CustomerID == s1 + || c.CustomerID == s2 + || c.CustomerID == s3 + || c.CustomerID == s4 + || c.CustomerID == s5 + || c.CustomerID == s6 + || c.CustomerID == s7 + || c.CustomerID == s8 + || c.CustomerID == s9 + || c.CustomerID == s10 + || c.CustomerID == s11 + || c.CustomerID == s12 + || c.CustomerID == s13 + || c.CustomerID == s14 + || c.CustomerID == s15) + .Include(c => c.Orders)); var syncSingleResultQuery = EF.CompileQuery( - (NorthwindContext context, string s1, string s2, string s3, string s4, string s5, string s6, string s7, string s8, - string s9, string s10, string s11, string s12, string s13, string s14, string s15) - => context.Set() - .Count(c => c.CustomerID == s1 || c.CustomerID == s2 || c.CustomerID == s3 || c.CustomerID == s4 || c.CustomerID == s5 - || c.CustomerID == s6 || c.CustomerID == s7 || c.CustomerID == s8 || c.CustomerID == s9 || c.CustomerID == s10 - || c.CustomerID == s11 || c.CustomerID == s12 || c.CustomerID == s13 || c.CustomerID == s14 || c.CustomerID == s15)); + ( + NorthwindContext context, + string s1, + string s2, + string s3, + string s4, + string s5, + string s6, + string s7, + string s8, + string s9, + string s10, + string s11, + string s12, + string s13, + string s14, + string s15) + => context.Set() + .Count( + c => c.CustomerID == s1 + || c.CustomerID == s2 + || c.CustomerID == s3 + || c.CustomerID == s4 + || c.CustomerID == s5 + || c.CustomerID == s6 + || c.CustomerID == s7 + || c.CustomerID == s8 + || c.CustomerID == s9 + || c.CustomerID == s10 + || c.CustomerID == s11 + || c.CustomerID == s12 + || c.CustomerID == s13 + || c.CustomerID == s14 + || c.CustomerID == s15)); var asyncEnumerableQuery = EF.CompileAsyncQuery( - (NorthwindContext context, string s1, string s2, string s3, string s4, string s5, string s6, string s7, string s8, - string s9, string s10, string s11, string s12, string s13, string s14, string s15) - => context.Set() - .Where(c => c.CustomerID == s1 || c.CustomerID == s2 || c.CustomerID == s3 || c.CustomerID == s4 || c.CustomerID == s5 - || c.CustomerID == s6 || c.CustomerID == s7 || c.CustomerID == s8 || c.CustomerID == s9 || c.CustomerID == s10 - || c.CustomerID == s11 || c.CustomerID == s12 || c.CustomerID == s13 || c.CustomerID == s14 || c.CustomerID == s15)); + ( + NorthwindContext context, + string s1, + string s2, + string s3, + string s4, + string s5, + string s6, + string s7, + string s8, + string s9, + string s10, + string s11, + string s12, + string s13, + string s14, + string s15) + => context.Set() + .Where( + c => c.CustomerID == s1 + || c.CustomerID == s2 + || c.CustomerID == s3 + || c.CustomerID == s4 + || c.CustomerID == s5 + || c.CustomerID == s6 + || c.CustomerID == s7 + || c.CustomerID == s8 + || c.CustomerID == s9 + || c.CustomerID == s10 + || c.CustomerID == s11 + || c.CustomerID == s12 + || c.CustomerID == s13 + || c.CustomerID == s14 + || c.CustomerID == s15)); var asyncIncludeEnumerableQuery = EF.CompileAsyncQuery( - (NorthwindContext context, string s1, string s2, string s3, string s4, string s5, string s6, string s7, string s8, - string s9, string s10, string s11, string s12, string s13, string s14, string s15) - => context.Set() - .Where(c => c.CustomerID == s1 || c.CustomerID == s2 || c.CustomerID == s3 || c.CustomerID == s4 || c.CustomerID == s5 - || c.CustomerID == s6 || c.CustomerID == s7 || c.CustomerID == s8 || c.CustomerID == s9 || c.CustomerID == s10 - || c.CustomerID == s11 || c.CustomerID == s12 || c.CustomerID == s13 || c.CustomerID == s14 || c.CustomerID == s15) - .Include(c => c.Orders)); + ( + NorthwindContext context, + string s1, + string s2, + string s3, + string s4, + string s5, + string s6, + string s7, + string s8, + string s9, + string s10, + string s11, + string s12, + string s13, + string s14, + string s15) + => context.Set() + .Where( + c => c.CustomerID == s1 + || c.CustomerID == s2 + || c.CustomerID == s3 + || c.CustomerID == s4 + || c.CustomerID == s5 + || c.CustomerID == s6 + || c.CustomerID == s7 + || c.CustomerID == s8 + || c.CustomerID == s9 + || c.CustomerID == s10 + || c.CustomerID == s11 + || c.CustomerID == s12 + || c.CustomerID == s13 + || c.CustomerID == s14 + || c.CustomerID == s15) + .Include(c => c.Orders)); var asyncSingleResultQuery = EF.CompileAsyncQuery( - (NorthwindContext context, string s1, string s2, string s3, string s4, string s5, string s6, string s7, string s8, - string s9, string s10, string s11, string s12, string s13, string s14, string s15) - => context.Set() - .Count(c => c.CustomerID == s1 || c.CustomerID == s2 || c.CustomerID == s3 || c.CustomerID == s4 || c.CustomerID == s5 - || c.CustomerID == s6 || c.CustomerID == s7 || c.CustomerID == s8 || c.CustomerID == s9 || c.CustomerID == s10 - || c.CustomerID == s11 || c.CustomerID == s12 || c.CustomerID == s13 || c.CustomerID == s14 || c.CustomerID == s15)); + ( + NorthwindContext context, + string s1, + string s2, + string s3, + string s4, + string s5, + string s6, + string s7, + string s8, + string s9, + string s10, + string s11, + string s12, + string s13, + string s14, + string s15) + => context.Set() + .Count( + c => c.CustomerID == s1 + || c.CustomerID == s2 + || c.CustomerID == s3 + || c.CustomerID == s4 + || c.CustomerID == s5 + || c.CustomerID == s6 + || c.CustomerID == s7 + || c.CustomerID == s8 + || c.CustomerID == s9 + || c.CustomerID == s10 + || c.CustomerID == s11 + || c.CustomerID == s12 + || c.CustomerID == s13 + || c.CustomerID == s14 + || c.CustomerID == s15)); var asyncSingleResultQueryWithCancellationToken = EF.CompileAsyncQuery( - (NorthwindContext context, string s1, string s2, string s3, string s4, string s5, string s6, string s7, string s8, - string s9, string s10, string s11, string s12, string s13, string s14, CancellationToken ct) - => context.Set() - .Count(c => c.CustomerID == s1 || c.CustomerID == s2 || c.CustomerID == s3 || c.CustomerID == s4 || c.CustomerID == s5 - || c.CustomerID == s6 || c.CustomerID == s7 || c.CustomerID == s8 || c.CustomerID == s9 || c.CustomerID == s10 - || c.CustomerID == s11 || c.CustomerID == s12 || c.CustomerID == s13 || c.CustomerID == s14)); + ( + NorthwindContext context, + string s1, + string s2, + string s3, + string s4, + string s5, + string s6, + string s7, + string s8, + string s9, + string s10, + string s11, + string s12, + string s13, + string s14, + CancellationToken ct) + => context.Set() + .Count( + c => c.CustomerID == s1 + || c.CustomerID == s2 + || c.CustomerID == s3 + || c.CustomerID == s4 + || c.CustomerID == s5 + || c.CustomerID == s6 + || c.CustomerID == s7 + || c.CustomerID == s8 + || c.CustomerID == s9 + || c.CustomerID == s10 + || c.CustomerID == s11 + || c.CustomerID == s12 + || c.CustomerID == s13 + || c.CustomerID == s14)); using var context = CreateContext(); - var syncEnumerableResult = syncEnumerableQuery(context, "ALFKI", "ANATR", "ANTON", "AROUT", "BERGS", "BLAUS", "BLONP", "BOLID", "BONAP", "BSBEV", "CACTU", "CENTC", "CHOPS", "CONSH", "RANDM").ToList(); + var syncEnumerableResult = syncEnumerableQuery( + context, "ALFKI", "ANATR", "ANTON", "AROUT", "BERGS", "BLAUS", "BLONP", "BOLID", "BONAP", "BSBEV", "CACTU", "CENTC", + "CHOPS", "CONSH", "RANDM").ToList(); Assert.Equal(14, syncEnumerableResult.Count); - var syncIncludeEnumerableResult = syncIncludeEnumerableQuery(context, "ALFKI", "ANATR", "ANTON", "AROUT", "BERGS", "BLAUS", "BLONP", "BOLID", "BONAP", "BSBEV", "CACTU", "CENTC", "CHOPS", "CONSH", "RANDM").ToList(); + var syncIncludeEnumerableResult = syncIncludeEnumerableQuery( + context, "ALFKI", "ANATR", "ANTON", "AROUT", "BERGS", "BLAUS", "BLONP", "BOLID", "BONAP", "BSBEV", "CACTU", "CENTC", + "CHOPS", "CONSH", "RANDM").ToList(); Assert.Equal(14, syncIncludeEnumerableResult.Count); Assert.All(syncIncludeEnumerableResult, t => Assert.NotNull(t.Orders)); - Assert.Equal(14, syncSingleResultQuery(context, "ALFKI", "ANATR", "ANTON", "AROUT", "BERGS", "BLAUS", "BLONP", "BOLID", "BONAP", "BSBEV", "CACTU", "CENTC", "CHOPS", "CONSH", "RANDM")); + Assert.Equal( + 14, + syncSingleResultQuery( + context, "ALFKI", "ANATR", "ANTON", "AROUT", "BERGS", "BLAUS", "BLONP", "BOLID", "BONAP", "BSBEV", "CACTU", "CENTC", + "CHOPS", "CONSH", "RANDM")); - var asyncEnumerableResult = await asyncEnumerableQuery(context, "ALFKI", "ANATR", "ANTON", "AROUT", "BERGS", "BLAUS", "BLONP", "BOLID", "BONAP", "BSBEV", "CACTU", "CENTC", "CHOPS", "CONSH", "RANDM").ToListAsync(); + var asyncEnumerableResult = await asyncEnumerableQuery( + context, "ALFKI", "ANATR", "ANTON", "AROUT", "BERGS", "BLAUS", "BLONP", "BOLID", "BONAP", "BSBEV", "CACTU", "CENTC", + "CHOPS", "CONSH", "RANDM").ToListAsync(); Assert.Equal(14, asyncEnumerableResult.Count); - var asyncIncludeEnumerableResult = await asyncIncludeEnumerableQuery(context, "ALFKI", "ANATR", "ANTON", "AROUT", "BERGS", "BLAUS", "BLONP", "BOLID", "BONAP", "BSBEV", "CACTU", "CENTC", "CHOPS", "CONSH", "RANDM").ToListAsync(); + var asyncIncludeEnumerableResult = await asyncIncludeEnumerableQuery( + context, "ALFKI", "ANATR", "ANTON", "AROUT", "BERGS", "BLAUS", "BLONP", "BOLID", "BONAP", "BSBEV", "CACTU", "CENTC", + "CHOPS", "CONSH", "RANDM").ToListAsync(); Assert.Equal(14, asyncIncludeEnumerableResult.Count); Assert.All(asyncIncludeEnumerableResult, t => Assert.NotNull(t.Orders)); - Assert.Equal(14, await asyncSingleResultQuery(context, "ALFKI", "ANATR", "ANTON", "AROUT", "BERGS", "BLAUS", "BLONP", "BOLID", "BONAP", "BSBEV", "CACTU", "CENTC", "CHOPS", "CONSH", "RANDM")); + Assert.Equal( + 14, + await asyncSingleResultQuery( + context, "ALFKI", "ANATR", "ANTON", "AROUT", "BERGS", "BLAUS", "BLONP", "BOLID", "BONAP", "BSBEV", "CACTU", "CENTC", + "CHOPS", "CONSH", "RANDM")); - Assert.Equal(14, await asyncSingleResultQueryWithCancellationToken(context, "ALFKI", "ANATR", "ANTON", "AROUT", "BERGS", "BLAUS", "BLONP", "BOLID", "BONAP", "BSBEV", "CACTU", "CENTC", "CHOPS", "CONSH", default)); + Assert.Equal( + 14, + await asyncSingleResultQueryWithCancellationToken( + context, "ALFKI", "ANATR", "ANTON", "AROUT", "BERGS", "BLAUS", "BLONP", "BOLID", "BONAP", "BSBEV", "CACTU", "CENTC", + "CHOPS", "CONSH", default)); } [ConditionalFact] public virtual void MakeBinary_does_not_throw_for_unsupported_operator() { - var query = EF.CompileQuery((NorthwindContext context, object[] parameters) - => context.Customers.Where(c => c.CustomerID == (string)parameters[0])); + var query = EF.CompileQuery( + (NorthwindContext context, object[] parameters) + => context.Customers.Where(c => c.CustomerID == (string)parameters[0])); using var context = CreateContext(); @@ -655,6 +872,7 @@ public virtual void MakeBinary_does_not_throw_for_unsupported_operator() Assert.Single(result); } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); } } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindDbFunctionsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindDbFunctionsQueryTestBase.cs index 89895c8bb56..ad8d8afbcc3 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindDbFunctionsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindDbFunctionsQueryTestBase.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.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -48,6 +47,7 @@ public virtual Task Like_literal_with_escape(bool async) c => EF.Functions.Like(c.ContactName, "!%", "!"), c => c.ContactName.Contains("%")); - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); } } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs index f763117b764..57363aa0101 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs @@ -31,7 +31,8 @@ protected NorthwindFunctionsQueryTestBase(TFixture fixture) { } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { @@ -735,8 +736,11 @@ await AssertQuery( entryCount: 3); } - protected static string LocalMethod1() => "M"; - protected static string LocalMethod2() => "m"; + protected static string LocalMethod1() + => "M"; + + protected static string LocalMethod2() + => "m"; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] diff --git a/test/EFCore.Specification.Tests/Query/NorthwindGroupByQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindGroupByQueryTestBase.cs index a074cb63c87..d34e79efc46 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindGroupByQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindGroupByQueryTestBase.cs @@ -18,7 +18,8 @@ protected NorthwindGroupByQueryTestBase(TFixture fixture) { } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { @@ -392,14 +393,21 @@ await AssertQuery( async, ss => ss.Set() .Where(o => o.CustomerID.StartsWith("A")) - .Select(o => new { o.CustomerID, Age = 2020 - o.OrderDate.Value.Year, o.OrderID }) + .Select( + o => new + { + o.CustomerID, + Age = 2020 - o.OrderDate.Value.Year, + o.OrderID + }) .GroupBy(x => x.CustomerID) - .Select(x => new - { - x.Key, - Sum1 = x.Sum(y => y.Age <= 30 ? y.OrderID : 0), - Sum2 = x.Sum(y => y.Age > 30 && y.Age <= 60 ? y.OrderID : 0) - })); + .Select( + x => new + { + x.Key, + Sum1 = x.Sum(y => y.Age <= 30 ? y.OrderID : 0), + Sum2 = x.Sum(y => y.Age > 30 && y.Age <= 60 ? y.OrderID : 0) + })); } [ConditionalTheory] @@ -421,13 +429,9 @@ public virtual Task Key_plus_key_in_projection(bool async) join c in ss.Set() on o.CustomerID equals c.CustomerID into grouping from c in grouping.DefaultIfEmpty() select o) - .GroupBy(o => o.OrderID) - .Select( - g => new - { - Value = g.Key + g.Key, - Average = g.Average(o => o.OrderID) - })); + .GroupBy(o => o.OrderID) + .Select( + g => new { Value = g.Key + g.Key, Average = g.Average(o => o.OrderID) })); } #endregion @@ -781,7 +785,8 @@ public override bool Equals(object obj) ? true : obj.GetType() == GetType() && Equals((NominalType)obj); - public override int GetHashCode() => 0; + public override int GetHashCode() + => 0; private bool Equals(NominalType other) => string.Equals(CustomerID, other.CustomerID) @@ -821,7 +826,8 @@ protected class CompositeDto public override bool Equals(object obj) => obj != null && (ReferenceEquals(this, obj) || (obj is CompositeDto dto && Equals(dto))); - public override int GetHashCode() => 0; + public override int GetHashCode() + => 0; private bool Equals(CompositeDto other) => Sum == other.Sum @@ -1073,7 +1079,8 @@ public virtual Task Join_groupby_anonymous_orderby_anonymous_projection(bool asy async, ss => from c in ss.Set() join o in ss.Set() on c.CustomerID equals o.CustomerID - group new { c, o } by new { c.CustomerID, o.OrderDate } into grouping + group new { c, o } by new { c.CustomerID, o.OrderDate } + into grouping orderby grouping.Key.OrderDate select new { grouping.Key.CustomerID, grouping.Key.OrderDate }); } @@ -1281,20 +1288,12 @@ public virtual Task Element_selector_with_case_block_repeated_inside_another_cas async, ss => from order in ss.Set() group new - { - IsAlfki = order.CustomerID == "ALFKI", - OrderId = order.OrderID > 1000 ? order.OrderID : -order.OrderID - } by - new - { - order.OrderID - } + { + IsAlfki = order.CustomerID == "ALFKI", OrderId = order.OrderID > 1000 ? order.OrderID : -order.OrderID + } by + new { order.OrderID } into g - select new - { - g.Key.OrderID, - Aggregate = g.Sum(s => s.IsAlfki ? s.OrderId : -s.OrderId) - }); + select new { g.Key.OrderID, Aggregate = g.Sum(s => s.IsAlfki ? s.OrderId : -s.OrderId) }); } #endregion @@ -1889,11 +1888,7 @@ join a in ss.Set().GroupBy(o => o.CustomerID) g => new { CustomerID = g.Key, LastOrderID = g.Max(o => o.OrderID) }) on c.CustomerID equals a.CustomerID into grouping from g in grouping.DefaultIfEmpty() - select new - { - c, - LastOrderID = (int?)g.LastOrderID - }, + select new { c, LastOrderID = (int?)g.LastOrderID }, ss => from c in ss.Set().Where(c => c.CustomerID.StartsWith("A")) join a in ss.Set().GroupBy(o => o.CustomerID) @@ -1902,11 +1897,7 @@ join a in ss.Set().GroupBy(o => o.CustomerID) g => new { CustomerID = g.Key, LastOrderID = g.Max(o => o.OrderID) }) on c.CustomerID equals a.CustomerID into grouping from g in grouping.DefaultIfEmpty() - select new - { - c, - LastOrderID = g != null ? g.LastOrderID : (int?)null - }, + select new { c, LastOrderID = g != null ? g.LastOrderID : (int?)null }, elementSorter: r => r.c.CustomerID, entryCount: 4); } @@ -2036,7 +2027,8 @@ private class ProjectedType public int Order { get; set; } public string Customer { get; set; } - private bool Equals(ProjectedType other) => Equals(Order, other.Order); + private bool Equals(ProjectedType other) + => Equals(Order, other.Order); public override bool Equals(object obj) => obj is null @@ -2047,7 +2039,8 @@ public override bool Equals(object obj) && Equals((ProjectedType)obj); // ReSharper disable once NonReadonlyMemberInGetHashCode - public override int GetHashCode() => Order.GetHashCode(); + public override int GetHashCode() + => Order.GetHashCode(); } [ConditionalTheory] @@ -2166,11 +2159,7 @@ public virtual Task GroupBy_orderby_projection_with_coalesce_operation(bool asyn .GroupBy(c => c.City) .OrderByDescending(x => x.Count()) .ThenBy(x => x.Key) - .Select(x => new - { - Locality = x.Key ?? "Unknown", - Count = x.Count() - })); + .Select(x => new { Locality = x.Key ?? "Unknown", Count = x.Count() })); } [ConditionalTheory(Skip = "issue #18923")] @@ -2184,11 +2173,7 @@ public virtual Task GroupBy_let_orderby_projection_with_coalesce_operation(bool .Select(g => new { citiesCount = g.Count(), g }) .OrderByDescending(x => x.citiesCount) .ThenBy(x => x.g.Key) - .Select(x => new - { - Locality = x.g.Key ?? "Unknown", - Count = x.citiesCount - })); + .Select(x => new { Locality = x.g.Key ?? "Unknown", Count = x.citiesCount })); } [ConditionalTheory] @@ -2223,11 +2208,7 @@ public virtual Task GroupBy_aggregate_over_a_subquery(bool async) async, ss => ss.Set() .GroupBy(o => o.CustomerID) - .Select(g => new - { - g.Key, - Count = (from c in ss.Set() where c.CustomerID == g.Key select c).Count() - })); + .Select(g => new { g.Key, Count = (from c in ss.Set() where c.CustomerID == g.Key select c).Count() })); } [ConditionalTheory] @@ -2270,12 +2251,12 @@ public virtual Task GroupBy_aggregate_from_right_side_of_join(bool async) async, ss => (from c in ss.Set() join o in ss.Set().GroupBy(i => i.CustomerID).Select(e => new { e.Key, Max = e.Max(i => i.OrderDate) }) - on c.CustomerID equals o.Key + on c.CustomerID equals o.Key select new { c, o.Max }) - .OrderBy(e => e.Max) - .ThenBy(c => c.c.CustomerID) - .Skip(10) - .Take(10), + .OrderBy(e => e.Max) + .ThenBy(c => c.c.CustomerID) + .Skip(10) + .Take(10), assertOrder: true, elementAsserter: (e, a) => { @@ -2292,15 +2273,20 @@ public virtual Task GroupBy_aggregate_join_another_GroupBy_aggregate(bool async) return AssertQuery( async, ss => ss.Set() - .GroupBy(o => o.CustomerID) - .Select(g => new { g.Key, Total = g.Count() }) - .Join( - ss.Set().Where(o => o.OrderDate.Value.Year == 1997) - .GroupBy(o => o.CustomerID) - .Select(g => new { g.Key, ThatYear = g.Count() }), - o => o.Key, - i => i.Key, - (o, i) => new { o.Key, o.Total, i.ThatYear }), + .GroupBy(o => o.CustomerID) + .Select(g => new { g.Key, Total = g.Count() }) + .Join( + ss.Set().Where(o => o.OrderDate.Value.Year == 1997) + .GroupBy(o => o.CustomerID) + .Select(g => new { g.Key, ThatYear = g.Count() }), + o => o.Key, + i => i.Key, + (o, i) => new + { + o.Key, + o.Total, + i.ThatYear + }), elementSorter: o => o.Key); } @@ -2413,7 +2399,8 @@ public virtual Task GroupBy_Where_Select_Where_Count(bool async) ss => from o in ss.Set() group o by new { o.CustomerID } into g - select g.Where(e => e.OrderID < 10300).Select(e => e.OrderDate).Where(e => e.HasValue && e.Value.Year == 1997).Count()); + select g.Where(e => e.OrderID < 10300).Select(e => e.OrderDate).Where(e => e.HasValue && e.Value.Year == 1997) + .Count()); } [ConditionalTheory] @@ -2426,9 +2413,9 @@ public virtual Task GroupBy_Where_Select_Where_Select_Min(bool async) group o by new { o.CustomerID } into g select g.Where(e => e.OrderID < 10300) - .Select(e => new { e.OrderID, e.OrderDate }) - .Where(e => e.OrderDate.HasValue && e.OrderDate.Value.Year == 1997) - .Select(e => (int?)e.OrderID).Min()); + .Select(e => new { e.OrderID, e.OrderDate }) + .Where(e => e.OrderDate.HasValue && e.OrderDate.Value.Year == 1997) + .Select(e => (int?)e.OrderID).Min()); } [ConditionalTheory] @@ -2472,18 +2459,19 @@ public virtual Task GroupBy_Select_Distinct_aggregate(bool async) return AssertQuery( async, ss => ss.Set() - .GroupBy(o => o.CustomerID) - .Select(g => - new - { - g.Key, - Average = g.Select(e => e.OrderID).Distinct().Average(), - Count = g.Select(e => e.EmployeeID).Distinct().Count(), - LongCount = g.Select(e => e.EmployeeID).Distinct().LongCount(), - Max = g.Select(e => e.OrderDate).Distinct().Max(), - Min = g.Select(e => e.OrderDate).Distinct().Min(), - Sum = g.Select(e => e.OrderID).Distinct().Sum(), - }), + .GroupBy(o => o.CustomerID) + .Select( + g => + new + { + g.Key, + Average = g.Select(e => e.OrderID).Distinct().Average(), + Count = g.Select(e => e.EmployeeID).Distinct().Count(), + LongCount = g.Select(e => e.EmployeeID).Distinct().LongCount(), + Max = g.Select(e => e.OrderDate).Distinct().Max(), + Min = g.Select(e => e.OrderDate).Distinct().Min(), + Sum = g.Select(e => e.OrderID).Distinct().Sum(), + }), elementSorter: e => e.Key); } @@ -2494,13 +2482,13 @@ public virtual Task GroupBy_group_Distinct_Select_Distinct_aggregate(bool async) return AssertQuery( async, ss => ss.Set() - .GroupBy(o => o.CustomerID) - .Select(g => - new - { - g.Key, - Max = g.Distinct().Select(e => e.OrderDate).Distinct().Max(), - }), + .GroupBy(o => o.CustomerID) + .Select( + g => + new + { + g.Key, Max = g.Distinct().Select(e => e.OrderDate).Distinct().Max(), + }), elementSorter: e => e.Key); } @@ -2511,13 +2499,13 @@ public virtual Task GroupBy_group_Where_Select_Distinct_aggregate(bool async) return AssertQuery( async, ss => ss.Set() - .GroupBy(o => o.CustomerID) - .Select(g => - new - { - g.Key, - Max = g.Where(e => e.OrderDate.HasValue).Select(e => e.OrderDate).Distinct().Max(), - }), + .GroupBy(o => o.CustomerID) + .Select( + g => + new + { + g.Key, Max = g.Where(e => e.OrderDate.HasValue).Select(e => e.OrderDate).Distinct().Max(), + }), elementSorter: e => e.Key); } @@ -2938,16 +2926,13 @@ public virtual Task GroupBy_scalar_subquery(bool async) return AssertQuery( async, ss => ss.Set() - .GroupBy(o => ss.Set() - .Where(c => c.CustomerID == o.CustomerID) - .Select(c => c.ContactName) - .FirstOrDefault()) + .GroupBy( + o => ss.Set() + .Where(c => c.CustomerID == o.CustomerID) + .Select(c => c.ContactName) + .FirstOrDefault()) .Select( - g => new - { - g.Key, - Count = g.Count() - }), + g => new { g.Key, Count = g.Count() }), elementSorter: e => e.Key); } @@ -2960,13 +2945,10 @@ public virtual Task GroupBy_scalar_aggregate_in_set_operation(bool async) ss => ss.Set() .Where(c => c.CustomerID.StartsWith("F")) .Select(c => new { c.CustomerID, Sequence = 0 }) - .Union(ss.Set() - .GroupBy(o => o.CustomerID) - .Select(g => new - { - CustomerID = g.Key, - Sequence = 1 - })), + .Union( + ss.Set() + .GroupBy(o => o.CustomerID) + .Select(g => new { CustomerID = g.Key, Sequence = 1 })), elementSorter: e => (e.CustomerID, e.Sequence)); } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindIncludeNoTrackingQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindIncludeNoTrackingQueryTestBase.cs index bf86c9dc7de..1eb890cf5bd 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindIncludeNoTrackingQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindIncludeNoTrackingQueryTestBase.cs @@ -211,9 +211,11 @@ var orders Assert.Single(context.ChangeTracker.Entries()); } - public override Task Include_with_cycle_does_not_throw_when_AsNoTrackingWithIdentityResolution(bool async) => Task.CompletedTask; + public override Task Include_with_cycle_does_not_throw_when_AsNoTrackingWithIdentityResolution(bool async) + => Task.CompletedTask; - protected override bool IgnoreEntryCount => true; + protected override bool IgnoreEntryCount + => true; protected override Expression RewriteServerQueryExpression(Expression serverQueryExpression) { diff --git a/test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs index 0a0d10fd6c4..f2bb23e5dbe 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs @@ -33,7 +33,8 @@ public virtual Task Include_reference_and_collection_order_by(bool async) return AssertQuery( async, ss => ss.Set().Include(o => o.Customer.Orders).OrderBy(o => o.OrderID), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(o => o.Customer), new ExpectedInclude(c => c.Orders, "Customer")), assertOrder: true, entryCount: 919); @@ -46,7 +47,8 @@ public virtual async Task Include_references_then_include_collection(bool async) await AssertQuery( async, ss => ss.Set().Include(o => o.Customer).ThenInclude(c => c.Orders), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(o => o.Customer), new ExpectedInclude(c => c.Orders, "Customer")), entryCount: 919); @@ -93,11 +95,12 @@ public virtual Task Then_include_collection_order_by_collection_column(bool asyn return AssertFirstOrDefault( async, ss => ss.Set() - .Include(c => c.Orders) - .ThenInclude(o => o.OrderDetails) - .Where(c => c.CustomerID.StartsWith("W")) - .OrderByDescending(c => c.Orders.OrderByDescending(oo => oo.OrderDate).FirstOrDefault().OrderDate), - asserter: (e, a) => AssertInclude(e, a, + .Include(c => c.Orders) + .ThenInclude(o => o.OrderDetails) + .Where(c => c.CustomerID.StartsWith("W")) + .OrderByDescending(c => c.Orders.OrderByDescending(oo => oo.OrderDate).FirstOrDefault().OrderDate), + asserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(c => c.Orders), new ExpectedInclude(o => o.OrderDetails, "Orders")), entryCount: 55); @@ -159,7 +162,8 @@ public virtual Task Include_collection_then_reference(bool async) return AssertQuery( async, ss => ss.Set().Include(p => p.OrderDetails).ThenInclude(od => od.Order), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(p => p.OrderDetails), new ExpectedInclude(od => od.Order, "OrderDetails")), entryCount: 3062); @@ -226,7 +230,8 @@ public virtual Task Include_list(bool async) return AssertQuery( async, ss => ss.Set().Include(p => p.OrderDetails).ThenInclude(od => od.Order), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(p => p.OrderDetails), new ExpectedInclude(od => od.Order, "OrderDetails")), entryCount: 3062); @@ -250,7 +255,8 @@ public virtual Task Include_collection_and_reference(bool async) return AssertQuery( async, ss => ss.Set().Include(o => o.OrderDetails).Include(o => o.Customer), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(o => o.OrderDetails), new ExpectedInclude(o => o.Customer)), entryCount: 3074); } @@ -334,13 +340,13 @@ public virtual Task Include_where_skip_take_projection(bool async) return AssertQuery( async, ss => ss.Set() - .Include(od => od.Order) - .Where(od => od.Quantity == 10) - .OrderBy(od => od.OrderID) - .ThenBy(od => od.ProductID) - .Skip(1) - .Take(2) - .Select(od => new { od.Order.CustomerID })); + .Include(od => od.Order) + .Where(od => od.Quantity == 10) + .OrderBy(od => od.OrderID) + .ThenBy(od => od.ProductID) + .Skip(1) + .Take(2) + .Select(od => new { od.Order.CustomerID })); } [ConditionalTheory] @@ -408,7 +414,7 @@ public virtual Task Include_collection_with_outer_apply_with_filter(bool async) async, ss => from c in ss.Set().Include(c => c.Orders) from o in ss.Set().Where(o => o.CustomerID == c.CustomerID) - .OrderBy(o => c.CustomerID).Take(5).DefaultIfEmpty() + .OrderBy(o => c.CustomerID).Take(5).DefaultIfEmpty() where c.CustomerID.StartsWith("F") select c, elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(c => c.Orders)), @@ -423,7 +429,7 @@ public virtual Task Include_collection_with_outer_apply_with_filter_non_equality async, ss => from c in ss.Set().Include(c => c.Orders) from o in ss.Set().Where(o => o.CustomerID != c.CustomerID) - .OrderBy(o => c.CustomerID).Take(5).DefaultIfEmpty() + .OrderBy(o => c.CustomerID).Take(5).DefaultIfEmpty() where c.CustomerID.StartsWith("F") select c, elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(c => c.Orders)), @@ -453,9 +459,9 @@ public virtual Task Include_collection_order_by_collection_column(bool async) return AssertFirstOrDefault( async, ss => ss.Set() - .Include(c => c.Orders) - .Where(c => c.CustomerID.StartsWith("W")) - .OrderByDescending(c => c.Orders.OrderByDescending(oo => oo.OrderDate).FirstOrDefault().OrderDate), + .Include(c => c.Orders) + .Where(c => c.CustomerID.StartsWith("W")) + .OrderByDescending(c => c.Orders.OrderByDescending(oo => oo.OrderDate).FirstOrDefault().OrderDate), asserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(c => c.Orders)), entryCount: 15); } @@ -524,9 +530,9 @@ public virtual Task Include_collection_order_by_subquery(bool async) return AssertFirstOrDefault( async, ss => ss.Set() - .Include(c => c.Orders) - .Where(c => c.CustomerID == "ALFKI") - .OrderBy(c => c.Orders.OrderBy(o => o.EmployeeID).Select(o => o.OrderDate).FirstOrDefault()), + .Include(c => c.Orders) + .Where(c => c.CustomerID == "ALFKI") + .OrderBy(c => c.Orders.OrderBy(o => o.EmployeeID).Select(o => o.OrderDate).FirstOrDefault()), asserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(c => c.Orders)), entryCount: 7); } @@ -711,11 +717,11 @@ public virtual async Task Include_collection_with_client_filter(bool async) CoreStrings.TranslationFailedWithDetails( "", CoreStrings.QueryUnableToTranslateMember(nameof(Customer.IsLondon), nameof(Customer))).Substring(21), - (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set().Include(c => c.Orders).Where(c => c.IsLondon)))) - .Message.Replace("\r", "").Replace("\n", "")); + (await Assert.ThrowsAsync( + () => AssertQuery( + async, + ss => ss.Set().Include(c => c.Orders).Where(c => c.IsLondon)))) + .Message.Replace("\r", "").Replace("\n", "")); } [ConditionalTheory] @@ -726,7 +732,8 @@ public virtual Task Include_multi_level_reference_and_collection_predicate(bool async, ss => ss.Set().Include(o => o.Customer.Orders), o => o.OrderID == 10248, - asserter: (e, a) => AssertInclude(e, a, + asserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(o => o.Customer), new ExpectedInclude(c => c.Orders, "Customer")), entryCount: 6); @@ -740,7 +747,8 @@ public virtual Task Include_multi_level_collection_and_then_include_reference_pr async, ss => ss.Set().Include(o => o.OrderDetails).ThenInclude(od => od.Product), o => o.OrderID == 10248, - asserter: (e, a) => AssertInclude(e, a, + asserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(o => o.OrderDetails), new ExpectedInclude(od => od.Product, "OrderDetails")), entryCount: 7); @@ -753,7 +761,8 @@ public virtual Task Include_multiple_references(bool async) return AssertQuery( async, ss => ss.Set().Include(o => o.Order).Include(o => o.Product), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(od => od.Order), new ExpectedInclude(od => od.Product)), entryCount: 3062); @@ -766,7 +775,8 @@ public virtual Task Include_multiple_references_and_collection_multi_level(bool return AssertQuery( async, ss => ss.Set().Include(od => od.Order.Customer.Orders).Include(od => od.Product), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(od => od.Order), new ExpectedInclude(o => o.Customer, "Order"), new ExpectedInclude(c => c.Orders, "Order.Customer"), @@ -781,7 +791,8 @@ public virtual Task Include_multiple_references_and_collection_multi_level_rever return AssertQuery( async, ss => ss.Set().Include(od => od.Product).Include(od => od.Order.Customer.Orders), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(od => od.Order), new ExpectedInclude(o => o.Customer, "Order"), new ExpectedInclude(c => c.Orders, "Order.Customer"), @@ -796,7 +807,8 @@ public virtual Task Include_multiple_references_multi_level(bool async) return AssertQuery( async, ss => ss.Set().Include(o => o.Order.Customer).Include(o => o.Product), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(od => od.Order), new ExpectedInclude(o => o.Customer, "Order"), new ExpectedInclude(od => od.Product)), @@ -810,7 +822,8 @@ public virtual Task Include_multiple_references_multi_level_reverse(bool async) return AssertQuery( async, ss => ss.Set().Include(o => o.Product).Include(o => o.Order.Customer), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(od => od.Order), new ExpectedInclude(o => o.Customer, "Order"), new ExpectedInclude(od => od.Product)), @@ -846,7 +859,8 @@ public virtual Task Include_reference_and_collection(bool async) return AssertQuery( async, ss => ss.Set().Include(o => o.Customer).Include(o => o.OrderDetails), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(o => o.Customer), new ExpectedInclude(o => o.OrderDetails)), entryCount: 3074); @@ -948,7 +962,8 @@ public virtual Task Include_references_and_collection_multi_level(bool async) return AssertQuery( async, ss => ss.Set().Include(o => o.Order.Customer.Orders), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(od => od.Order), new ExpectedInclude(o => o.Customer, "Order"), new ExpectedInclude(c => c.Orders, "Order.Customer")), @@ -962,7 +977,8 @@ public virtual Task Include_collection_then_include_collection(bool async) return AssertQuery( async, ss => ss.Set().Include(c => c.Orders).ThenInclude(o => o.OrderDetails), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(c => c.Orders), new ExpectedInclude(o => o.OrderDetails, "Orders")), entryCount: 3076); @@ -975,7 +991,8 @@ public virtual Task Include_collection_then_include_collection_then_include_refe return AssertQuery( async, ss => ss.Set().Include(c => c.Orders).ThenInclude(o => o.OrderDetails).ThenInclude(od => od.Product), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(c => c.Orders), new ExpectedInclude(o => o.OrderDetails, "Orders"), new ExpectedInclude(od => od.Product, "Orders.OrderDetails")), @@ -990,7 +1007,8 @@ public virtual Task Include_collection_then_include_collection_predicate(bool as async, ss => ss.Set().Include(c => c.Orders).ThenInclude(o => o.OrderDetails), c => c.CustomerID == "ALFKI", - asserter: (e, a) => AssertInclude(e, a, + asserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(c => c.Orders), new ExpectedInclude(o => o.OrderDetails, "Orders")), entryCount: 19); @@ -1003,7 +1021,8 @@ public virtual Task Include_references_and_collection_multi_level_predicate(bool return AssertQuery( async, ss => ss.Set().Include(od => od.Order.Customer.Orders).Where(od => od.OrderID == 10248), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(od => od.Order), new ExpectedInclude(o => o.Customer, "Order"), new ExpectedInclude(c => c.Orders, "Order.Customer")), @@ -1017,7 +1036,8 @@ public virtual Task Include_references_multi_level(bool async) return AssertQuery( async, ss => ss.Set().Include(o => o.Order.Customer), - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(od => od.Order), new ExpectedInclude(o => o.Customer, "Order")), entryCount: 3074); @@ -1031,7 +1051,8 @@ public virtual Task Include_multi_level_reference_then_include_collection_predic async, ss => ss.Set().Include(o => o.Customer).ThenInclude(c => c.Orders), o => o.OrderID == 10248, - asserter: (e, a) => AssertInclude(e, a, + asserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(o => o.Customer), new ExpectedInclude(c => c.Orders, "Customer")), entryCount: 6); @@ -1044,9 +1065,10 @@ public virtual Task Include_multiple_references_then_include_collection_multi_le return AssertQuery( async, ss => ss.Set() - .Include(od => od.Order).ThenInclude(o => o.Customer).ThenInclude(c => c.Orders) - .Include(od => od.Product), - elementAsserter: (e, a) => AssertInclude(e, a, + .Include(od => od.Order).ThenInclude(o => o.Customer).ThenInclude(c => c.Orders) + .Include(od => od.Product), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(od => od.Order), new ExpectedInclude(o => o.Customer, "Order"), new ExpectedInclude(c => c.Orders, "Order.Customer"), @@ -1061,9 +1083,10 @@ public virtual Task Include_multiple_references_then_include_collection_multi_le return AssertQuery( async, ss => ss.Set() - .Include(od => od.Product) - .Include(od => od.Order).ThenInclude(o => o.Customer).ThenInclude(c => c.Orders), - elementAsserter: (e, a) => AssertInclude(e, a, + .Include(od => od.Product) + .Include(od => od.Order).ThenInclude(o => o.Customer).ThenInclude(c => c.Orders), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(od => od.Order), new ExpectedInclude(o => o.Customer, "Order"), new ExpectedInclude(c => c.Orders, "Order.Customer"), @@ -1078,9 +1101,10 @@ public virtual Task Include_multiple_references_then_include_multi_level(bool as return AssertQuery( async, ss => ss.Set() - .Include(od => od.Order).ThenInclude(o => o.Customer) - .Include(od => od.Product), - elementAsserter: (e, a) => AssertInclude(e, a, + .Include(od => od.Order).ThenInclude(o => o.Customer) + .Include(od => od.Product), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(od => od.Order), new ExpectedInclude(o => o.Customer, "Order"), new ExpectedInclude(od => od.Product)), @@ -1094,9 +1118,10 @@ public virtual Task Include_multiple_references_then_include_multi_level_reverse return AssertQuery( async, ss => ss.Set() - .Include(od => od.Product) - .Include(od => od.Order).ThenInclude(o => o.Customer), - elementAsserter: (e, a) => AssertInclude(e, a, + .Include(od => od.Product) + .Include(od => od.Order).ThenInclude(o => o.Customer), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(od => od.Order), new ExpectedInclude(o => o.Customer, "Order"), new ExpectedInclude(od => od.Product)), @@ -1110,8 +1135,9 @@ public virtual Task Include_references_then_include_collection_multi_level(bool return AssertQuery( async, ss => ss.Set() - .Include(od => od.Order).ThenInclude(o => o.Customer).ThenInclude(c => c.Orders), - elementAsserter: (e, a) => AssertInclude(e, a, + .Include(od => od.Order).ThenInclude(o => o.Customer).ThenInclude(c => c.Orders), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(od => od.Order), new ExpectedInclude(o => o.Customer, "Order"), new ExpectedInclude(c => c.Orders, "Order.Customer")), @@ -1125,9 +1151,10 @@ public virtual Task Include_references_then_include_collection_multi_level_predi return AssertQuery( async, ss => ss.Set() - .Include(od => od.Order).ThenInclude(o => o.Customer).ThenInclude(c => c.Orders) - .Where(od => od.OrderID == 10248), - elementAsserter: (e, a) => AssertInclude(e, a, + .Include(od => od.Order).ThenInclude(o => o.Customer).ThenInclude(c => c.Orders) + .Where(od => od.OrderID == 10248), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(od => od.Order), new ExpectedInclude(o => o.Customer, "Order"), new ExpectedInclude(c => c.Orders, "Order.Customer")), @@ -1141,8 +1168,9 @@ public virtual Task Include_references_then_include_multi_level(bool async) return AssertQuery( async, ss => ss.Set() - .Include(od => od.Order).ThenInclude(o => o.Customer), - elementAsserter: (e, a) => AssertInclude(e, a, + .Include(od => od.Order).ThenInclude(o => o.Customer), + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(od => od.Order), new ExpectedInclude(o => o.Customer, "Order")), entryCount: 3074); @@ -1166,7 +1194,7 @@ public virtual Task Include_with_complex_projection_does_not_change_ordering_of_ async, ss => (from c in ss.Set().Include(c => c.Orders).Where(c => c.ContactTitle == "Owner").OrderBy(c => c.CustomerID) select new { Id = c.CustomerID, TotalOrders = c.Orders.Count }) - .Where(e => e.TotalOrders > 2)); + .Where(e => e.TotalOrders > 2)); } [ConditionalTheory] @@ -1198,10 +1226,10 @@ public virtual Task Include_collection_with_multiple_conditional_order_by(bool a return AssertQuery( async, ss => ss.Set() - .Include(c => c.OrderDetails) - .OrderBy(o => o.OrderID > 0) - .ThenBy(o => o.Customer != null ? o.Customer.City : string.Empty) - .Take(5), + .Include(c => c.OrderDetails) + .OrderBy(o => o.OrderID > 0) + .ThenBy(o => o.Customer != null ? o.Customer.City : string.Empty) + .Take(5), elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(o => o.OrderDetails)), entryCount: 14); } @@ -1237,10 +1265,10 @@ public virtual Task Include_collection_GroupBy_Select(bool async) return AssertQuery( async, ss => ss.Set() - .Where(o => o.OrderID == 10248) - .Include(o => o.OrderDetails) - .GroupBy(e => e.OrderID) - .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); + .Where(o => o.OrderID == 10248) + .Include(o => o.OrderDetails) + .GroupBy(e => e.OrderID) + .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); } [ConditionalTheory(Skip = "Issue #12088")] @@ -1250,10 +1278,10 @@ public virtual Task Include_reference_GroupBy_Select(bool async) return AssertQuery( async, ss => ss.Set() - .Where(o => o.OrderID == 10248) - .Include(o => o.Customer) - .GroupBy(e => e.OrderID) - .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); + .Where(o => o.OrderID == 10248) + .Include(o => o.Customer) + .GroupBy(e => e.OrderID) + .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); } [ConditionalTheory(Skip = "Issue #12088")] @@ -1263,15 +1291,15 @@ public virtual Task Include_collection_Join_GroupBy_Select(bool async) return AssertQuery( async, ss => ss.Set() - .Where(o => o.OrderID == 10248) - .Include(o => o.OrderDetails) - .Join( - ss.Set(), - o => o.OrderID, - od => od.OrderID, - (o, od) => o) - .GroupBy(e => e.OrderID) - .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); + .Where(o => o.OrderID == 10248) + .Include(o => o.OrderDetails) + .Join( + ss.Set(), + o => o.OrderID, + od => od.OrderID, + (o, od) => o) + .GroupBy(e => e.OrderID) + .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); } [ConditionalTheory(Skip = "Issue #12088")] @@ -1281,15 +1309,15 @@ public virtual Task Include_reference_Join_GroupBy_Select(bool async) return AssertQuery( async, ss => ss.Set() - .Where(o => o.OrderID == 10248) - .Include(o => o.Customer) - .Join( - ss.Set(), - o => o.OrderID, - od => od.OrderID, - (o, od) => o) - .GroupBy(e => e.OrderID) - .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); + .Where(o => o.OrderID == 10248) + .Include(o => o.Customer) + .Join( + ss.Set(), + o => o.OrderID, + od => od.OrderID, + (o, od) => o) + .GroupBy(e => e.OrderID) + .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); } [ConditionalTheory(Skip = "Issue #12088")] @@ -1299,14 +1327,14 @@ public virtual Task Join_Include_collection_GroupBy_Select(bool async) return AssertQuery( async, ss => ss.Set() - .Where(od => od.OrderID == 10248) - .Join( - ss.Set().Include(o => o.OrderDetails), - od => od.OrderID, - o => o.OrderID, - (od, o) => o) - .GroupBy(e => e.OrderID) - .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); + .Where(od => od.OrderID == 10248) + .Join( + ss.Set().Include(o => o.OrderDetails), + od => od.OrderID, + o => o.OrderID, + (od, o) => o) + .GroupBy(e => e.OrderID) + .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); } [ConditionalTheory(Skip = "Issue #12088")] @@ -1316,13 +1344,13 @@ public virtual Task Join_Include_reference_GroupBy_Select(bool async) return AssertQuery( async, ss => ss.Set() - .Join( - ss.Set().Include(o => o.Customer), - od => od.OrderID, - o => o.OrderID, - (od, o) => o) - .GroupBy(e => e.OrderID) - .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); + .Join( + ss.Set().Include(o => o.Customer), + od => od.OrderID, + o => o.OrderID, + (od, o) => o) + .GroupBy(e => e.OrderID) + .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); } [ConditionalTheory(Skip = "Issue #12088")] @@ -1334,8 +1362,8 @@ public virtual Task Include_collection_SelectMany_GroupBy_Select(bool async) ss => (from o in ss.Set().Include(o => o.OrderDetails).Where(o => o.OrderID == 10248) from od in ss.Set() select o) - .GroupBy(e => e.OrderID) - .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); + .GroupBy(e => e.OrderID) + .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); } [ConditionalTheory(Skip = "Issue #12088")] @@ -1347,8 +1375,8 @@ public virtual Task Include_reference_SelectMany_GroupBy_Select(bool async) ss => (from o in ss.Set().Include(o => o.Customer).Where(o => o.OrderID == 10248) from od in ss.Set() select o) - .GroupBy(e => e.OrderID) - .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); + .GroupBy(e => e.OrderID) + .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); } [ConditionalTheory(Skip = "Issue #12088")] @@ -1360,8 +1388,8 @@ public virtual Task SelectMany_Include_collection_GroupBy_Select(bool async) ss => (from od in ss.Set().Where(od => od.OrderID == 10248) from o in ss.Set().Include(o => o.OrderDetails) select o) - .GroupBy(e => e.OrderID) - .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); + .GroupBy(e => e.OrderID) + .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); } [ConditionalTheory(Skip = "Issue #12088")] @@ -1373,8 +1401,8 @@ public virtual Task SelectMany_Include_reference_GroupBy_Select(bool async) ss => (from od in ss.Set().Where(od => od.OrderID == 10248) from o in ss.Set().Include(o => o.Customer) select o) - .GroupBy(e => e.OrderID) - .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); + .GroupBy(e => e.OrderID) + .Select(e => e.OrderBy(o => o.OrderID).FirstOrDefault())); } [ConditionalTheory] @@ -1395,9 +1423,9 @@ public virtual Task Include_collection_distinct_is_server_evaluated(bool async) return AssertQuery( async, ss => ss.Set() - .Where(c => c.CustomerID.StartsWith("A")) - .Include(o => o.Orders) - .Distinct(), + .Where(c => c.CustomerID.StartsWith("A")) + .Include(o => o.Orders) + .Distinct(), elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(c => c.Orders)), entryCount: 34); } @@ -1409,9 +1437,9 @@ public virtual Task Include_collection_OrderBy_object(bool async) return AssertQuery( async, ss => ss.Set() - .Where(o => o.OrderID < 10250) - .Include(o => o.OrderDetails) - .OrderBy(c => c.OrderID), + .Where(o => o.OrderID < 10250) + .Include(o => o.OrderDetails) + .OrderBy(c => c.OrderID), elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(o => o.OrderDetails)), assertOrder: true, entryCount: 7); @@ -1425,10 +1453,10 @@ public virtual Task Include_collection_OrderBy_empty_list_contains(bool async) return AssertQuery( async, ss => ss.Set() - .Include(c => c.Orders) - .Where(c => c.CustomerID.StartsWith("A")) - .OrderBy(c => list.Contains(c.CustomerID)) - .Skip(1), + .Include(c => c.Orders) + .Where(c => c.CustomerID.StartsWith("A")) + .OrderBy(c => list.Contains(c.CustomerID)) + .Skip(1), elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(c => c.Orders))); } @@ -1440,10 +1468,10 @@ public virtual Task Include_collection_OrderBy_empty_list_does_not_contains(bool return AssertQuery( async, ss => ss.Set() - .Include(c => c.Orders) - .Where(c => c.CustomerID.StartsWith("A")) - .OrderBy(c => !list.Contains(c.CustomerID)) - .Skip(1), + .Include(c => c.Orders) + .Where(c => c.CustomerID.StartsWith("A")) + .OrderBy(c => !list.Contains(c.CustomerID)) + .Skip(1), elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(c => c.Orders))); } @@ -1455,10 +1483,10 @@ public virtual Task Include_collection_OrderBy_list_contains(bool async) return AssertQuery( async, ss => ss.Set() - .Include(c => c.Orders) - .Where(c => c.CustomerID.StartsWith("A")) - .OrderBy(c => list.Contains(c.CustomerID)) - .Skip(1), + .Include(c => c.Orders) + .Where(c => c.CustomerID.StartsWith("A")) + .OrderBy(c => list.Contains(c.CustomerID)) + .Skip(1), elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(c => c.Orders)), entryCount: 29); } @@ -1471,10 +1499,10 @@ public virtual Task Include_collection_OrderBy_list_does_not_contains(bool async return AssertQuery( async, ss => ss.Set() - .Include(c => c.Orders) - .Where(c => c.CustomerID.StartsWith("A")) - .OrderBy(c => !list.Contains(c.CustomerID)) - .Skip(1), + .Include(c => c.Orders) + .Where(c => c.CustomerID.StartsWith("A")) + .OrderBy(c => !list.Contains(c.CustomerID)) + .Skip(1), elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(c => c.Orders)), entryCount: 27); } @@ -1521,7 +1549,8 @@ orderby c.CustomerID asserter: (e, a) => { AssertEqual(e.CustomerID, a.CustomerID); - AssertCollection(e.Orders, a.Orders, + AssertCollection( + e.Orders, a.Orders, elementAsserter: (eo, ao) => AssertInclude(eo, ao, new ExpectedInclude(o => o.OrderDetails))); }, entryCount: 14); @@ -1540,7 +1569,8 @@ orderby c.CustomerID asserter: (e, a) => { AssertEqual(e.CustomerID, a.CustomerID); - AssertCollection(e.Orders, a.Orders, + AssertCollection( + e.Orders, a.Orders, elementAsserter: (eo, ao) => AssertInclude(eo, ao, new ExpectedInclude(o => o.OrderDetails))); }, entryCount: 18); @@ -1559,7 +1589,8 @@ orderby c.CustomerID asserter: (e, a) => { AssertEqual(e.CustomerID, a.CustomerID); - AssertCollection(e.Orders, a.Orders, + AssertCollection( + e.Orders, a.Orders, elementAsserter: (eo, ao) => AssertInclude(eo, ao, new ExpectedInclude(o => o.OrderDetails))); }, entryCount: 14); @@ -1572,9 +1603,11 @@ public virtual Task Filtered_include_with_multiple_ordering(bool async) return AssertQuery( async, ss => ss.Set().Where(c => c.CustomerID.StartsWith("F")) - .Include(c => c.Orders.OrderBy(o => o.OrderID).Skip(1).OrderByDescending(o => o.OrderDate)), - elementAsserter: (e, a) => AssertInclude(e, a, - new ExpectedFilteredInclude(c => c.Orders, + .Include(c => c.Orders.OrderBy(o => o.OrderID).Skip(1).OrderByDescending(o => o.OrderDate)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + c => c.Orders, includeFilter: os => os.OrderBy(o => o.OrderID).Skip(1).OrderByDescending(o => o.OrderDate), assertOrder: true)), entryCount: 64); @@ -1589,7 +1622,7 @@ public virtual Task Include_with_cycle_does_not_throw_when_AsNoTrackingWithIdent ss => (from i in ss.Set().Include(o => o.Customer.Orders) where i.OrderID < 10800 select i) - .AsNoTrackingWithIdentityResolution()); + .AsNoTrackingWithIdentityResolution()); } [ConditionalTheory] @@ -1600,7 +1633,7 @@ public virtual Task Outer_idenfier_correctly_determined_when_doing_include_on_ri async, ss => from cust in ss.Set() join order in ss.Set().Include(f => f.OrderDetails) - on cust.CustomerID equals order.CustomerID into group1 + on cust.CustomerID equals order.CustomerID into group1 from order in group1.DefaultIfEmpty() where cust.City == "Seattle" select new { cust, order }, @@ -1613,11 +1646,11 @@ from order in group1.DefaultIfEmpty() entryCount: 55); } - protected virtual void ClearLog() { } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); } } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindJoinQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindJoinQueryTestBase.cs index 462171d329f..c5290205555 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindJoinQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindJoinQueryTestBase.cs @@ -19,7 +19,8 @@ protected NorthwindJoinQueryTestBase(TFixture fixture) { } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { @@ -104,7 +105,8 @@ from e3 in ss.Set().OrderBy(e => e.EmployeeID).Skip(6).Take(2) entryCount: 4); } - private static uint GetEmployeeID(Employee employee) => employee.EmployeeID; + private static uint GetEmployeeID(Employee employee) + => employee.EmployeeID; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -751,7 +753,14 @@ public virtual Task SelectMany_with_client_eval_with_collection_shaper(bool asyn return AssertQuery( async, ss => ss.Set().Where(c => c.CustomerID.StartsWith("F")) - .SelectMany(c => c.Orders.Select(o => new { OrderProperty = ClientMethod(o), o.OrderDetails, CustomerProperty = c.ContactName })), + .SelectMany( + c => c.Orders.Select( + o => new + { + OrderProperty = ClientMethod(o), + o.OrderDetails, + CustomerProperty = c.ContactName + })), elementSorter: e => e.OrderProperty, elementAsserter: (e, a) => { @@ -769,13 +778,21 @@ public virtual Task SelectMany_with_client_eval_with_collection_shaper_ignored(b return AssertQuery( async, ss => ss.Set().Where(c => c.CustomerID.StartsWith("F")) - .SelectMany(c => c.Orders.Select(o => new { OrderProperty = ClientMethod(o), o.OrderDetails, CustomerProperty = c.ContactName })) + .SelectMany( + c => c.Orders.Select( + o => new + { + OrderProperty = ClientMethod(o), + o.OrderDetails, + CustomerProperty = c.ContactName + })) .Select(e => new { e.OrderProperty, e.CustomerProperty }), elementSorter: e => e.OrderProperty, entryCount: 63); } - private static int ClientMethod(Order order) => order.OrderID; + private static int ClientMethod(Order order) + => order.OrderID; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -786,12 +803,14 @@ public virtual Task SelectMany_with_client_eval_with_constructor(bool async) ss => ss.Set() .Where(c => c.CustomerID.StartsWith("A")) .OrderBy(c => c.CustomerID) - .Select(c => new CustomerViewModel( - c.CustomerID, c.City, - c.Orders.SelectMany(o => o.OrderDetails - .Where(od => od.OrderID < 11000) - .Select(od => new OrderDetailViewModel(od.OrderID, od.ProductID))) - .ToArray())), + .Select( + c => new CustomerViewModel( + c.CustomerID, c.City, + c.Orders.SelectMany( + o => o.OrderDetails + .Where(od => od.OrderID < 11000) + .Select(od => new OrderDetailViewModel(od.OrderID, od.ProductID))) + .ToArray())), assertOrder: true); } @@ -817,7 +836,7 @@ public override bool Equals(object obj) return ReferenceEquals(this, obj) || obj.GetType() == GetType() - && Equals((CustomerViewModel)obj); + && Equals((CustomerViewModel)obj); } private bool Equals(CustomerViewModel customerViewModel) @@ -825,7 +844,8 @@ private bool Equals(CustomerViewModel customerViewModel) && _city == customerViewModel._city && _views.SequenceEqual(customerViewModel._views); - public override int GetHashCode() => HashCode.Combine(_customerID, _city); + public override int GetHashCode() + => HashCode.Combine(_customerID, _city); } private class OrderDetailViewModel @@ -848,14 +868,15 @@ public override bool Equals(object obj) return ReferenceEquals(this, obj) || obj.GetType() == GetType() - && Equals((OrderDetailViewModel)obj); + && Equals((OrderDetailViewModel)obj); } private bool Equals(OrderDetailViewModel orderDetailViewModel) => _orderID == orderDetailViewModel._orderID && _productID == orderDetailViewModel._productID; - public override int GetHashCode() => HashCode.Combine(_orderID, _productID); + public override int GetHashCode() + => HashCode.Combine(_orderID, _productID); } } } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindKeylessEntitiesQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindKeylessEntitiesQueryTestBase.cs index e94a0a5b9da..ae0541ba87a 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindKeylessEntitiesQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindKeylessEntitiesQueryTestBase.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.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; @@ -19,7 +18,8 @@ protected NorthwindKeylessEntitiesQueryTestBase(TFixture fixture) { } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { @@ -131,7 +131,8 @@ public virtual Task KeylessEntity_with_included_navs_multi_level(bool async) ss => from ov in ss.Set().Include(ov => ov.Customer.Orders) where ov.CustomerID == "ALFKI" select ov, - elementAsserter: (e, a) => AssertInclude(e, a, + elementAsserter: (e, a) => AssertInclude( + e, a, new ExpectedInclude(ov => ov.Customer), new ExpectedInclude(c => c.Orders, "Customer")), entryCount: 1); @@ -167,7 +168,13 @@ public virtual Task KeylessEntity_groupby(bool async) async, ss => ss.Set() .GroupBy(cv => cv.City) - .Select(g => new { g.Key, Count = g.Count(), Sum = g.Sum(e => e.Address.Length) }), + .Select( + g => new + { + g.Key, + Count = g.Count(), + Sum = g.Sum(e => e.Address.Length) + }), elementSorter: e => (e.Key, e.Count, e.Sum)); } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs index 2c27d70a6ff..22252b9fc89 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindMiscellaneousQueryTestBase.cs @@ -13,9 +13,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.Utilities; using Xunit; -using Xunit.Sdk; #pragma warning disable RCS1202 // Avoid NullReferenceException. @@ -30,7 +28,8 @@ protected NorthwindMiscellaneousQueryTestBase(TFixture fixture) { } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { @@ -85,10 +84,10 @@ public virtual void Multiple_context_instances_parameter() using var context1 = CreateContext(); using var context2 = CreateContext(); - Customer query(NorthwindContext c2) => - (from c in context1.Customers - from o in c2.Orders - select c).First(); + Customer query(NorthwindContext c2) + => (from c in context1.Customers + from o in c2.Orders + select c).First(); Assert.Equal( CoreStrings.ErrorInvalidQueryable, @@ -436,8 +435,12 @@ public virtual Task Entity_equality_through_DTO_projection(bool async) private class CustomerWrapper { public Customer Customer { get; set; } - public override bool Equals(object obj) => obj is CustomerWrapper other && other.Customer.Equals(Customer); - public override int GetHashCode() => Customer.GetHashCode(); + + public override bool Equals(object obj) + => obj is CustomerWrapper other && other.Customer.Equals(Customer); + + public override int GetHashCode() + => Customer.GetHashCode(); } [ConditionalTheory] @@ -791,8 +794,7 @@ public virtual Task Ternary_should_not_evaluate_both_sides_with_parameter(bool a o => new { // ReSharper disable SimplifyConditionalTernaryExpression - Data1 = param != null ? o.OrderDate == param.Value : true, - Data2 = param == null ? true : o.OrderDate == param.Value + Data1 = param != null ? o.OrderDate == param.Value : true, Data2 = param == null ? true : o.OrderDate == param.Value // ReSharper restore SimplifyConditionalTernaryExpression })); } @@ -806,11 +808,7 @@ public virtual Task Null_Coalesce_Short_Circuit(bool async) return AssertQuery( async, - ss => ss.Set().Distinct().Select(c => new - { - Customer = c, - Test = test ?? values.Contains(1) - }), + ss => ss.Set().Distinct().Select(c => new { Customer = c, Test = test ?? values.Contains(1) }), entryCount: 91); } @@ -823,10 +821,7 @@ public virtual Task Null_Coalesce_Short_Circuit_with_server_correlated_leftover( return AssertQuery( async, - ss => ss.Set().Select(c => new - { - Result = test ?? values.Select(c2 => c2.CustomerID).Contains(c.CustomerID) - })); + ss => ss.Set().Select(c => new { Result = test ?? values.Select(c2 => c2.CustomerID).Contains(c.CustomerID) })); } [ConditionalTheory] @@ -1582,7 +1577,8 @@ private bool Equals(OrderCountDTO other) return string.Equals(Id, other.Id) && Count == other.Count; } - public override int GetHashCode() => HashCode.Combine(Id, Count); + public override int GetHashCode() + => HashCode.Combine(Id, Count); } [ConditionalTheory] @@ -1595,14 +1591,14 @@ public virtual async Task Select_correlated_subquery_filtered_returning_queryabl .Where(o => o.CustomerID == c.CustomerID)", typeof(IQueryable).ShortDisplayName()), (await Assert.ThrowsAsync( () => AssertQuery( - async, - ss => - from c in ss.Set() - where c.CustomerID.StartsWith("A") - orderby c.CustomerID - select ss.Set().Where(o => o.CustomerID == c.CustomerID), - assertOrder: true, - elementAsserter: (e, a) => AssertCollection(e, a)))).Message, + async, + ss => + from c in ss.Set() + where c.CustomerID.StartsWith("A") + orderby c.CustomerID + select ss.Set().Where(o => o.CustomerID == c.CustomerID), + assertOrder: true, + elementAsserter: (e, a) => AssertCollection(e, a)))).Message, ignoreLineEndingDifferences: true); } @@ -1619,12 +1615,12 @@ public virtual async Task Select_correlated_subquery_ordered_returning_queryable .Take(2)", typeof(IQueryable).ShortDisplayName()), (await Assert.ThrowsAsync( () => AssertQuery( - async, - ss => - from c in ss.Set().OrderBy(c => c.CustomerID).Take(3) - select ss.Set().OrderBy(o => o.OrderID).ThenBy(o => c.CustomerID).Skip(100).Take(2), - elementSorter: e => e.Count(), - elementAsserter: (e, a) => AssertCollection(e, a, ordered: true)))).Message, + async, + ss => + from c in ss.Set().OrderBy(c => c.CustomerID).Take(3) + select ss.Set().OrderBy(o => o.OrderID).ThenBy(o => c.CustomerID).Skip(100).Take(2), + elementSorter: e => e.Count(), + elementAsserter: (e, a) => AssertCollection(e, a, ordered: true)))).Message, ignoreLineEndingDifferences: true); } @@ -1641,13 +1637,13 @@ public virtual async Task Select_correlated_subquery_ordered_returning_queryable .Take(2)", typeof(IQueryable).ShortDisplayName()), (await Assert.ThrowsAsync( () => AssertQuery( - async, - ss => - from c in ss.Set().OrderBy(c => c.CustomerID).Take(3) - select new QueryableDto - { - Orders = ss.Set().OrderBy(o => o.OrderID).ThenBy(o => c.CustomerID).Skip(100).Take(2) - }))).Message, + async, + ss => + from c in ss.Set().OrderBy(c => c.CustomerID).Take(3) + select new QueryableDto + { + Orders = ss.Set().OrderBy(o => o.OrderID).ThenBy(o => c.CustomerID).Skip(100).Take(2) + }))).Message, ignoreLineEndingDifferences: true); } @@ -1698,28 +1694,28 @@ public virtual async Task Select_nested_collection_in_anonymous_type_returning_o .OrderBy(o => o)", typeof(IOrderedQueryable).ShortDisplayName()), (await Assert.ThrowsAsync( () => AssertQuery( - async, - ss => - from c in ss.Set() - where c.CustomerID == "ALFKI" - select new - { - CustomerId = c.CustomerID, - OrderIds - = ss.Set().Where( - o => o.CustomerID == c.CustomerID - && o.OrderDate.Value.Year == 1997) - .Select(o => o.OrderID) - .OrderBy(o => o), - Customer = c - }, - elementAsserter: (e, a) => + async, + ss => + from c in ss.Set() + where c.CustomerID == "ALFKI" + select new { - Assert.Equal(e.CustomerId, a.CustomerId); - AssertCollection(e.OrderIds, a.OrderIds); - AssertEqual(e.Customer, a.Customer); + CustomerId = c.CustomerID, + OrderIds + = ss.Set().Where( + o => o.CustomerID == c.CustomerID + && o.OrderDate.Value.Year == 1997) + .Select(o => o.OrderID) + .OrderBy(o => o), + Customer = c }, - entryCount: 1))).Message, + elementAsserter: (e, a) => + { + Assert.Equal(e.CustomerId, a.CustomerId); + AssertCollection(e.OrderIds, a.OrderIds); + AssertEqual(e.Customer, a.Customer); + }, + entryCount: 1))).Message, ignoreLineEndingDifferences: true); } @@ -1734,18 +1730,18 @@ public virtual async Task Select_subquery_recursive_trivial_returning_queryable( .OrderBy(e3 => e3.EmployeeID))", typeof(IQueryable>).ShortDisplayName()), (await Assert.ThrowsAsync( () => AssertQuery( - async, - ss => from e1 in ss.Set() - select (from e2 in ss.Set() - select (from e3 in ss.Set() - orderby e3.EmployeeID - select e3)), - elementSorter: e => e.Count(), - elementAsserter: (e, a) => AssertCollection( - e, - a, - elementSorter: ee => ee.Count(), - elementAsserter: (ee, aa) => AssertCollection(ee, aa, ordered: true))))).Message, + async, + ss => from e1 in ss.Set() + select (from e2 in ss.Set() + select (from e3 in ss.Set() + orderby e3.EmployeeID + select e3)), + elementSorter: e => e.Count(), + elementAsserter: (e, a) => AssertCollection( + e, + a, + elementSorter: ee => ee.Count(), + elementAsserter: (ee, aa) => AssertCollection(ee, aa, ordered: true))))).Message, ignoreLineEndingDifferences: true); } @@ -2091,7 +2087,7 @@ from c3 in ss.Set().OrderBy(c => c.IsLondon).ThenBy(c => c.CustomerID) select new { c3 }).First().c3.City select c1, entryCount: 1), - CoreStrings.QueryUnableToTranslateMember(nameof(Customer.IsLondon), nameof(Customer))); + CoreStrings.QueryUnableToTranslateMember(nameof(Customer.IsLondon), nameof(Customer))); } [ConditionalTheory] @@ -2105,7 +2101,7 @@ public virtual Task Where_query_composition5(bool async) where c1.IsLondon == ss.Set().OrderBy(c => c.CustomerID).First().IsLondon select c1, entryCount: 85), - CoreStrings.QueryUnableToTranslateMember(nameof(Customer.IsLondon), nameof(Customer))); + CoreStrings.QueryUnableToTranslateMember(nameof(Customer.IsLondon), nameof(Customer))); } [ConditionalTheory] @@ -2122,7 +2118,7 @@ where c1.IsLondon .First().Foo.IsLondon select c1, entryCount: 85), - CoreStrings.QueryUnableToTranslateMember(nameof(Customer.IsLondon), nameof(Customer))); + CoreStrings.QueryUnableToTranslateMember(nameof(Customer.IsLondon), nameof(Customer))); } [ConditionalTheory] @@ -2158,19 +2154,19 @@ public virtual Task OrderBy_scalar_primitive(bool async) public virtual Task SelectMany_mixed(bool async) { return AssertTranslationFailed( - () => AssertQuery( - async, - ss => from e1 in ss.Set().OrderBy(e => e.EmployeeID).Take(2) - from s in new[] { "a", "b" } - from c in ss.Set().OrderBy(c => c.CustomerID).Take(2) - select new - { - e1, - s, - c - }, - e => (e.e1.EmployeeID, e.c.CustomerID), - entryCount: 4)); + () => AssertQuery( + async, + ss => from e1 in ss.Set().OrderBy(e => e.EmployeeID).Take(2) + from s in new[] { "a", "b" } + from c in ss.Set().OrderBy(c => c.CustomerID).Take(2) + select new + { + e1, + s, + c + }, + e => (e.e1.EmployeeID, e.c.CustomerID), + entryCount: 4)); } [ConditionalTheory] @@ -2593,7 +2589,6 @@ public virtual Task Default_if_empty_top_level_arg(bool async) ss => from e in ss.Set().Where(c => c.EmployeeID == NonExistentID).DefaultIfEmpty(new Employee()) select e, entryCount: 1)); - } [ConditionalTheory] @@ -3446,7 +3441,7 @@ public virtual void Select_Where_Subquery_Equality() using var context = CreateContext(); 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 @@ -4295,7 +4290,6 @@ from o2 in ss.Set().Where(o => o.OrderID <= c.CustomerID.Length).DefaultI e => (e.CustomerID, e.OrderID)); } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task OrderBy_skip_take(bool async) @@ -4626,7 +4620,8 @@ public virtual Task Anonymous_complex_distinct_result(bool async) syncQuery: ss => ss.Set().Select(c => new { A = c.CustomerID + c.City }).Distinct() .Count(n => n.A.StartsWith("A")), asyncQuery: ss - => ss.Set().Select(c => new { A = c.CustomerID + c.City }).Distinct().CountAsync(n => n.A.StartsWith("A"), default)); + => ss.Set().Select(c => new { A = c.CustomerID + c.City }).Distinct() + .CountAsync(n => n.A.StartsWith("A"), default)); } [ConditionalTheory] @@ -4745,7 +4740,8 @@ public virtual Task DTO_complex_distinct_result(bool async) syncQuery: ss => ss.Set().Select( c => new DTO { Property = c.CustomerID + c.City }).Distinct().Count(n => n.Property.StartsWith("A")), asyncQuery: ss => ss.Set().Select( - c => new DTO { Property = c.CustomerID + c.City }).Distinct().CountAsync(n => n.Property.StartsWith("A"), default)); + c => new DTO { Property = c.CustomerID + c.City }).Distinct() + .CountAsync(n => n.Property.StartsWith("A"), default)); } [ConditionalTheory] @@ -5350,7 +5346,8 @@ 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() }).ToList()) + c => new { c.CustomerID, Orders = context.Orders.Where(o => o.Customer.CustomerID == c.CustomerID).ToList() }) + .ToList()) .Select( x => new { @@ -5506,9 +5503,11 @@ select g.OrderByDescending(x => x.OrderID).ToList(), elementAsserter: (e, a) => AssertCollection(e, a, ordered: true))); } - protected static bool ClientEvalPredicate(Order order) => order.OrderID > 10000; + protected static bool ClientEvalPredicate(Order order) + => order.OrderID > 10000; - protected internal uint ClientEvalSelector(Order order) => order.EmployeeID % 10 ?? 0; + protected internal uint ClientEvalSelector(Order order) + => order.EmployeeID % 10 ?? 0; [ConditionalTheory(Skip = "Issue#20445")] [MemberData(nameof(IsAsyncData))] @@ -5584,7 +5583,8 @@ public virtual void Client_code_using_instance_method_throws() () => context.Customers.Select(c => InstanceMethod(c)).ToList()).Message); } - private string InstanceMethod(Customer c) => c.City; + private string InstanceMethod(Customer c) + => c.City; [ConditionalFact] public virtual void Client_code_using_instance_in_static_method() @@ -5598,7 +5598,8 @@ public virtual void Client_code_using_instance_in_static_method() () => context.Customers.Select(c => StaticMethod(this, c)).ToList()).Message); } - private static string StaticMethod(NorthwindMiscellaneousQueryTestBase containingClass, Customer c) => c.City; + private static string StaticMethod(NorthwindMiscellaneousQueryTestBase containingClass, Customer c) + => c.City; [ConditionalFact] public virtual void Client_code_using_instance_in_anonymous_type() @@ -5627,7 +5628,8 @@ public virtual Task Client_code_unknown_method(bool async) nameof(UnknownMethod))); } - public static string UnknownMethod(string foo) => foo; + public static string UnknownMethod(string foo) + => foo; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -5698,7 +5700,8 @@ public virtual Task AsQueryable_in_query_server_evals(bool async) elementAsserter: (e, a) => AssertCollection(e, a, ordered: true)); } - private static Expression> ValidYear => a => a.OrderDate.Value.Year == 1998; + private static Expression> ValidYear + => a => a.OrderDate.Value.Year == 1998; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -5707,9 +5710,9 @@ public virtual Task Subquery_DefaultIfEmpty_Any(bool async) return AssertAny( async, ss => (from e in ss.Set() - .Where(e => e.EmployeeID == NonExistentID) - .Select(e => e.EmployeeID) - .DefaultIfEmpty() + .Where(e => e.EmployeeID == NonExistentID) + .Select(e => e.EmployeeID) + .DefaultIfEmpty() select e)); } @@ -5725,11 +5728,7 @@ public virtual Task Projection_skip_collection_projection(bool async) .OrderBy(o => o.OrderID) .Select(o => new { Item = o }) .Skip(5) - .Select(e => new - { - e.Item.OrderID, - ProductIds = e.Item.OrderDetails.Select(od => od.ProductID).ToList() - }), + .Select(e => new { e.Item.OrderID, ProductIds = e.Item.OrderDetails.Select(od => od.ProductID).ToList() }), assertOrder: true, elementAsserter: (e, a) => { @@ -5749,11 +5748,7 @@ public virtual Task Projection_take_collection_projection(bool async) .OrderBy(o => o.OrderID) .Select(o => new { Item = o }) .Take(10) - .Select(e => new - { - e.Item.OrderID, - ProductIds = e.Item.OrderDetails.Select(od => od.ProductID).ToList() - }), + .Select(e => new { e.Item.OrderID, ProductIds = e.Item.OrderDetails.Select(od => od.ProductID).ToList() }), assertOrder: true, elementAsserter: (e, a) => { @@ -5774,11 +5769,7 @@ public virtual Task Projection_skip_take_collection_projection(bool async) .Select(o => new { Item = o }) .Skip(5) .Take(10) - .Select(e => new - { - e.Item.OrderID, - ProductIds = e.Item.OrderDetails.Select(od => od.ProductID).ToList() - }), + .Select(e => new { e.Item.OrderID, ProductIds = e.Item.OrderDetails.Select(od => od.ProductID).ToList() }), assertOrder: true, elementAsserter: (e, a) => { @@ -5840,15 +5831,15 @@ public virtual Task Collection_projection_skip(bool async) ss => ss.Set() .Where(o => o.OrderID < 10300) .OrderBy(o => o.OrderID) - .Select(o => new - { - Order = o, - o.OrderDetails - }) + .Select(o => new { Order = o, o.OrderDetails }) .Skip(5), entryCount: 173, assertOrder: true, - elementAsserter: (e, a) => { AssertEqual(e.Order, a.Order); AssertCollection(e.OrderDetails, a.OrderDetails); }); + elementAsserter: (e, a) => + { + AssertEqual(e.Order, a.Order); + AssertCollection(e.OrderDetails, a.OrderDetails); + }); } [ConditionalTheory] @@ -5860,15 +5851,15 @@ public virtual Task Collection_projection_take(bool async) ss => ss.Set() .Where(o => o.OrderID < 10300) .OrderBy(o => o.OrderID) - .Select(o => new - { - Order = o, - o.OrderDetails - }) + .Select(o => new { Order = o, o.OrderDetails }) .Take(10), entryCount: 39, assertOrder: true, - elementAsserter: (e, a) => { AssertEqual(e.Order, a.Order); AssertCollection(e.OrderDetails, a.OrderDetails); }); + elementAsserter: (e, a) => + { + AssertEqual(e.Order, a.Order); + AssertCollection(e.OrderDetails, a.OrderDetails); + }); } [ConditionalTheory] @@ -5880,16 +5871,16 @@ public virtual Task Collection_projection_skip_take(bool async) ss => ss.Set() .Where(o => o.OrderID < 10300) .OrderBy(o => o.OrderID) - .Select(o => new - { - Order = o, - o.OrderDetails - }) + .Select(o => new { Order = o, o.OrderDetails }) .Skip(5) .Take(10), entryCount: 39, assertOrder: true, - elementAsserter: (e, a) => { AssertEqual(e.Order, a.Order); AssertCollection(e.OrderDetails, a.OrderDetails); }); + elementAsserter: (e, a) => + { + AssertEqual(e.Order, a.Order); + AssertCollection(e.OrderDetails, a.OrderDetails); + }); } [ConditionalTheory] @@ -5941,8 +5932,8 @@ public virtual Task Checked_context_with_arithmetic_does_not_fail(bool isAsync) return AssertQuery( isAsync, ss => ss.Set() - .Where(w => w.Quantity + 1 == 5 && w.Quantity - 1 == 3 && w.Quantity * 1 == w.Quantity) - .OrderBy(o => o.OrderID), + .Where(w => w.Quantity + 1 == 5 && w.Quantity - 1 == 3 && w.Quantity * 1 == w.Quantity) + .OrderBy(o => o.OrderID), entryCount: 55, assertOrder: true, elementAsserter: (e, a) => { AssertEqual(e, a); }); @@ -5953,16 +5944,13 @@ public virtual Task Checked_context_with_arithmetic_does_not_fail(bool isAsync) [MemberData(nameof(IsAsyncData))] public virtual Task Checked_context_with_case_to_same_nullable_type_does_not_fail(bool isAsync) { - checked - { - return AssertMax( - isAsync, - ss => ss.Set(), - ss => ss.Set(), - detail => (short?)detail.Quantity, - detail => (short?)detail.Quantity - ); - } + return AssertMax( + isAsync, + ss => ss.Set(), + ss => ss.Set(), + detail => (short?)detail.Quantity, + detail => (short?)detail.Quantity + ); } [ConditionalTheory] @@ -5998,11 +5986,7 @@ public virtual Task MemberInitExpression_NewExpression_is_funcletized_even_when_ return AssertQuery( async, ss => ss.Set().Where(c => c.CustomerID.StartsWith("A")) - .Select(c => new Dto(randomString) - { - CustomerID = c.CustomerID, - NestedDto = new Dto(randomString) - }), + .Select(c => new Dto(randomString) { CustomerID = c.CustomerID, NestedDto = new Dto(randomString) }), elementSorter: e => e.CustomerID, elementAsserter: (e, a) => Assert.Equal(e.CustomerID, a.CustomerID)); } @@ -6082,7 +6066,7 @@ public virtual async Task Perform_identity_resolution_reuses_same_instances_acro join o in context.Orders.Where(o => o.OrderID < 10500).Include(o => o.Customer) on c.CustomerID equals o.CustomerID select new { c, o }) - .AsNoTrackingWithIdentityResolution(); + .AsNoTrackingWithIdentityResolution(); var result = async ? await query.ToListAsync() @@ -6136,7 +6120,7 @@ public virtual Task Select_distinct_Select_with_client_bindings(bool async) return AssertQuery( async, ss => ss.Set().Where(o => o.OrderID < 10000).Select(o => o.OrderDate.Value.Year).Distinct() - .Select(e => new DTO { Property = ClientMethod(e) })); + .Select(e => new DTO { Property = ClientMethod(e) })); } [ConditionalTheory] @@ -6172,7 +6156,8 @@ public virtual Task AsEnumerable_over_string(bool async) elementAsserter: (e, a) => Assert.True(e.Property.SequenceEqual(a.Property))); } - private static int ClientMethod(int s) => s; + private static int ClientMethod(int s) + => s; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -6202,21 +6187,25 @@ public virtual async Task Max_on_empty_sequence_throws(bool async) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Pending_selector_in_cardinality_reducing_method_is_applied_before_expanding_collection_navigation_member(bool async) + public virtual Task Pending_selector_in_cardinality_reducing_method_is_applied_before_expanding_collection_navigation_member( + bool async) { return AssertQuery( async, ss => ss.Set() - .Where(c => c.CustomerID.StartsWith("F")) - .OrderBy(c => c.CustomerID) - .Select(c => new + .Where(c => c.CustomerID.StartsWith("F")) + .OrderBy(c => c.CustomerID) + .Select( + c => new { - Complex = (bool?)c.Orders.OrderBy(e => e.OrderDate).FirstOrDefault().Customer.Orders.Any(e => e.OrderID < 11000) + Complex = (bool?)c.Orders.OrderBy(e => e.OrderDate).FirstOrDefault().Customer.Orders + .Any(e => e.OrderID < 11000) }), ss => ss.Set() - .Where(c => c.CustomerID.StartsWith("F")) - .OrderBy(c => c.CustomerID) - .Select(c => new + .Where(c => c.CustomerID.StartsWith("F")) + .OrderBy(c => c.CustomerID) + .Select( + c => new { Complex = c.Orders.OrderBy(e => e.OrderDate).FirstOrDefault() != null ? c.Orders.OrderBy(e => e.OrderDate).FirstOrDefault().Customer.Orders.Any(e => e.OrderID < 11000) @@ -6233,12 +6222,12 @@ public virtual Task Distinct_followed_by_ordering_on_condition(bool async) return AssertQuery( async, ss => ss.Set() - .Where(c => c.CustomerID != "VAFFE" && c.CustomerID != "DRACD") - .Select(e => e.City) - .Distinct() - .OrderBy(x => x.IndexOf(searchTerm)) - .ThenBy(x => x) - .Take(5), + .Where(c => c.CustomerID != "VAFFE" && c.CustomerID != "DRACD") + .Select(e => e.City) + .Distinct() + .OrderBy(x => x.IndexOf(searchTerm)) + .ThenBy(x => x) + .Take(5), assertOrder: true); } @@ -6249,11 +6238,7 @@ public virtual Task DefaultIfEmpty_Sum_over_collection_navigation(bool async) return AssertQuery( async, ss => ss.Set() - .Select(c => new - { - c.CustomerID, - Sum = c.Orders.Select(o => o.OrderID).DefaultIfEmpty().Sum() - }), + .Select(c => new { c.CustomerID, Sum = c.Orders.Select(o => o.OrderID).DefaultIfEmpty().Sum() }), elementSorter: c => c.CustomerID); } } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs index 2e6d6c9954c..2e9f466d84d 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs @@ -22,7 +22,8 @@ protected NorthwindNavigationsQueryTestBase(TFixture fixture) { } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { @@ -71,9 +72,15 @@ join od in ss.Set().OrderBy(od => ClientOrderBy(od, od.Product)) on } private static readonly Random _randomGenerator = new Random(); - private static T ClientProjection(T t, object _) => t; - private static bool ClientPredicate(T t, object _) => true; - private static int ClientOrderBy(T t, object _) => _randomGenerator.Next(0, 20); + + private static T ClientProjection(T t, object _) + => t; + + private static bool ClientPredicate(T t, object _) + => true; + + private static int ClientOrderBy(T t, object _) + => _randomGenerator.Next(0, 20); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -225,7 +232,8 @@ public virtual Task Select_collection_FirstOrDefault_project_anonymous_type_clie assertOrder: true); } - private static int ClientFunction(int a, int b) => a + b + 1; + private static int ClientFunction(int a, int b) + => a + b + 1; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -321,8 +329,7 @@ public virtual Task Include_with_multiple_optional_navigations(bool async) { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(od => od.Order), - new ExpectedInclude(o => o.Customer, "Order") + new ExpectedInclude(od => od.Order), new ExpectedInclude(o => o.Customer, "Order") }; return AssertQuery( @@ -978,14 +985,15 @@ where c.Orders.Select(o => o.OrderID).Contains( } // ReSharper disable once MemberCanBeMadeStatic.Local - private static int ClientMethod(int argument) => argument; + private static int ClientMethod(int argument) + => argument; [ConditionalFact] public virtual void Navigation_in_subquery_referencing_outer_query() { using var context = CreateContext(); var query = from o in context.Orders - // ReSharper disable once UseMethodAny.0 + // ReSharper disable once UseMethodAny.0 where (from od in context.OrderDetails where o.Customer.Country == od.Order.Customer.Country select od).Count() diff --git a/test/EFCore.Specification.Tests/Query/NorthwindQueryFiltersQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindQueryFiltersQueryTestBase.cs index 97ba3f15aab..46fff720565 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindQueryFiltersQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindQueryFiltersQueryTestBase.cs @@ -174,9 +174,11 @@ public virtual void Entity_Equality() Assert.Equal(80, results.Count); } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); - public void Dispose() => _context.Dispose(); + public void Dispose() + => _context.Dispose(); private string RemoveNewLines(string message) => message.Replace("\n", "").Replace("\r", ""); diff --git a/test/EFCore.Specification.Tests/Query/NorthwindQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindQueryFixtureBase.cs index bd62f5ef24e..1eee282f740 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindQueryFixtureBase.cs @@ -15,9 +15,11 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class NorthwindQueryFixtureBase : SharedStoreFixtureBase, IQueryFixtureBase where TModelCustomizer : IModelCustomizer, new() { - public Func GetContextCreator() => () => CreateContext(); + public Func GetContextCreator() + => () => CreateContext(); - public ISetSource GetExpectedData() => new NorthwindData(); + public ISetSource GetExpectedData() + => new NorthwindData(); public IReadOnlyDictionary GetEntitySorters() => new Dictionary> @@ -32,18 +34,22 @@ public IReadOnlyDictionary GetEntitySorters() { typeof(OrderDetail), e => (((OrderDetail)e)?.OrderID.ToString(), ((OrderDetail)e)?.ProductID.ToString()) } }.ToDictionary(e => e.Key, e => (object)e.Value); - public IReadOnlyDictionary GetEntityAsserters() => null; + public IReadOnlyDictionary GetEntityAsserters() + => null; protected override string StoreName { get; } = "Northwind"; - protected override bool UsePooling => typeof(TModelCustomizer) == typeof(NoopModelCustomizer); + protected override bool UsePooling + => typeof(TModelCustomizer) == typeof(NoopModelCustomizer); protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) => new TModelCustomizer().Customize(modelBuilder, context); - protected override void Seed(NorthwindContext context) => NorthwindData.Seed(context); + protected override void Seed(NorthwindContext context) + => NorthwindData.Seed(context); - protected override Task SeedAsync(NorthwindContext context) => NorthwindData.SeedAsync(context); + protected override Task SeedAsync(NorthwindContext context) + => NorthwindData.SeedAsync(context); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder).ConfigureWarnings( diff --git a/test/EFCore.Specification.Tests/Query/NorthwindQueryTaggingQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindQueryTaggingQueryTestBase.cs index af8b88b197b..30610eb25f1 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindQueryTaggingQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindQueryTaggingQueryTestBase.cs @@ -13,7 +13,8 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class NorthwindQueryTaggingQueryTestBase : IClassFixture where TFixture : NorthwindQueryFixtureBase, new() { - protected NorthwindQueryTaggingQueryTestBase(TFixture fixture) => Fixture = fixture; + protected NorthwindQueryTaggingQueryTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -153,6 +154,7 @@ var customer Assert.NotNull(customer); } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); } } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs index 7b08a5392b8..38e5dc9832c 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.TestUtilities.QueryTestGeneration; using Xunit; #pragma warning disable RCS1202 // Avoid NullReferenceException. @@ -23,7 +22,8 @@ protected NorthwindSelectQueryTestBase(TFixture fixture) { } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { @@ -828,29 +828,29 @@ public virtual Task Select_over_10_nested_ternary_condition(bool isAsync) isAsync, os => from c in os.Set() select - c.CustomerID == "1" - ? "01" - : c.CustomerID == "2" - ? "02" - : c.CustomerID == "3" - ? "03" - : c.CustomerID == "4" - ? "04" - : c.CustomerID == "5" - ? "05" - : c.CustomerID == "6" - ? "06" - : c.CustomerID == "7" - ? "07" - : c.CustomerID == "8" - ? "08" - : c.CustomerID == "9" - ? "09" - : c.CustomerID == "10" - ? "10" - : c.CustomerID == "11" - ? "11" - : null); + c.CustomerID == "1" + ? "01" + : c.CustomerID == "2" + ? "02" + : c.CustomerID == "3" + ? "03" + : c.CustomerID == "4" + ? "04" + : c.CustomerID == "5" + ? "05" + : c.CustomerID == "6" + ? "06" + : c.CustomerID == "7" + ? "07" + : c.CustomerID == "8" + ? "08" + : c.CustomerID == "9" + ? "09" + : c.CustomerID == "10" + ? "10" + : c.CustomerID == "11" + ? "11" + : null); } [ConditionalTheory] @@ -1248,7 +1248,8 @@ public virtual Task Client_method_in_projection_requiring_materialization_2(bool entryCount: 4); } - private static string ClientMethod(Customer c) => c.CustomerID; + private static string ClientMethod(Customer c) + => c.CustomerID; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -1449,7 +1450,8 @@ public virtual Task Project_non_nullable_value_after_FirstOrDefault_on_empty_col ss => ss.Set().Select( c => (int?)ss.Set().Where(o => o.CustomerID == "John Doe").Select(o => o.CustomerID).FirstOrDefault().Length), ss => ss.Set().Select( - c => (int?)ss.Set().Where(o => o.CustomerID == "John Doe").Select(o => o.CustomerID).FirstOrDefault().MaybeScalar(e => e.Length))); + c => ss.Set().Where(o => o.CustomerID == "John Doe").Select(o => o.CustomerID).FirstOrDefault() + .MaybeScalar(e => e.Length))); } [ConditionalTheory] @@ -1480,7 +1482,8 @@ public override bool Equals(object obj) && Id == customerListItem.Id && City == customerListItem.City); - public override int GetHashCode() => HashCode.Combine(Id, City); + public override int GetHashCode() + => HashCode.Combine(Id, City); } [ConditionalTheory] @@ -1692,13 +1695,9 @@ public virtual Task Collection_projection_AsNoTracking_OrderBy(bool async) return AssertQuery( async, ss => (from c in ss.Set() - select new - { - c.CustomerID, - Orders = c.Orders.Select(o => o.OrderDate).ToList() - }) - .AsNoTracking() - .OrderBy(a => a.CustomerID), + select new { c.CustomerID, Orders = c.Orders.Select(o => o.OrderDate).ToList() }) + .AsNoTracking() + .OrderBy(a => a.CustomerID), assertOrder: true, elementAsserter: (e, a) => { @@ -1743,11 +1742,11 @@ public virtual Task Projection_AsEnumerable_projection(bool async) return AssertQuery( async, ss => ss.Set() - .Where(c => c.CustomerID.StartsWith("A")) - .OrderBy(c => c.CustomerID) - .Select(c => ss.Set().Where(o => o.CustomerID == c.CustomerID).AsEnumerable()) - .Where(e => e.Where(o => o.OrderID < 11000).Count() > 0) - .Select(e => e.Where(o => o.OrderID < 10750)), + .Where(c => c.CustomerID.StartsWith("A")) + .OrderBy(c => c.CustomerID) + .Select(c => ss.Set().Where(o => o.CustomerID == c.CustomerID).AsEnumerable()) + .Where(e => e.Where(o => o.OrderID < 11000).Count() > 0) + .Select(e => e.Where(o => o.OrderID < 10750)), assertOrder: true, entryCount: 18); } @@ -1760,11 +1759,16 @@ public virtual Task Projection_custom_type_in_both_sides_of_ternary(bool async) async, ss => ss.Set() .OrderBy(c => c.CustomerID) - .Select(c => c.City == "Seattle" - ? new IdName { Id = "PAY", Name = "Pay" } - : new IdName { Id = "REC", Name = "Receive" }), + .Select( + c => c.City == "Seattle" + ? new IdName { Id = "PAY", Name = "Pay" } + : new IdName { Id = "REC", Name = "Receive" }), assertOrder: true, - elementAsserter: (e, a) => { Assert.Equal(e.Id, a.Id); Assert.Equal(e.Name, a.Name); }); + elementAsserter: (e, a) => + { + Assert.Equal(e.Id, a.Id); + Assert.Equal(e.Name, a.Name); + }); } private class IdName @@ -1780,11 +1784,7 @@ public virtual Task Projecting_multiple_collection_with_same_constant_works(bool return AssertQuery( async, ss => ss.Set().Where(c => c.CustomerID == "ALFKI") - .Select(c => new - { - O1 = c.Orders.Select(e => new { Value = 1 }), - O2 = c.Orders.Select(e => new { AnotherValue = 1 }) - }), + .Select(c => new { O1 = c.Orders.Select(e => new { Value = 1 }), O2 = c.Orders.Select(e => new { AnotherValue = 1 }) }), assertOrder: true, //single element elementAsserter: (e, a) => { @@ -1804,16 +1804,19 @@ public virtual Task Projecting_after_navigation_and_distinct_works_correctly(boo ss => ss.Set() .Select(o => o.Customer) .Distinct() - .Select(c => new - { - c.CustomerID, - Orders = c.Orders.Where(x => filteredOrderIds.Contains(x.OrderID)).OrderBy(x => x.OrderID).Select(x => new + .Select( + c => new { c.CustomerID, - x.OrderID, - x.OrderDate - }) - }), + Orders = c.Orders.Where(x => filteredOrderIds.Contains(x.OrderID)).OrderBy(x => x.OrderID) + .Select( + x => new + { + c.CustomerID, + x.OrderID, + x.OrderDate + }) + }), elementSorter: e => e.CustomerID, elementAsserter: (e, a) => { @@ -1829,16 +1832,13 @@ public virtual Task Custom_projection_reference_navigation_PK_to_FK_optimization return AssertQuery( async, ss => ss.Set() - .Select(o => new Order - { - OrderID = o.OrderID, - Customer = new Customer + .Select( + o => new Order { - CustomerID = o.Customer.CustomerID, - City = o.Customer.City - }, - OrderDate = o.OrderDate - }), + OrderID = o.OrderID, + Customer = new Customer { CustomerID = o.Customer.CustomerID, City = o.Customer.City }, + OrderDate = o.OrderDate + }), elementAsserter: (e, a) => { AssertEqual(e, a); diff --git a/test/EFCore.Specification.Tests/Query/NorthwindSetOperationsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindSetOperationsQueryTestBase.cs index 3c803aac9bc..128bdd59b68 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindSetOperationsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindSetOperationsQueryTestBase.cs @@ -20,7 +20,8 @@ protected NorthwindSetOperationsQueryTestBase(TFixture fixture) { } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { @@ -336,7 +337,8 @@ public override bool Equals(object obj) && string.Equals(Id, ((CustomerDeets)obj).Id); } - public override int GetHashCode() => Id != null ? Id.GetHashCode() : 0; + public override int GetHashCode() + => Id != null ? Id.GetHashCode() : 0; } [ConditionalTheory] @@ -476,7 +478,8 @@ public virtual Task Client_eval_Union_FirstOrDefault(bool async) .Select(c => ClientSideMethod(c)) .Union(ss.Set())); - private static Customer ClientSideMethod(Customer c) => c; + private static Customer ClientSideMethod(Customer c) + => c; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] diff --git a/test/EFCore.Specification.Tests/Query/NorthwindStringIncludeQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindStringIncludeQueryTestBase.cs index 793f0aacd20..9a4e2ddd7e3 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindStringIncludeQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindStringIncludeQueryTestBase.cs @@ -7,12 +7,11 @@ using System.Linq.Expressions; using System.Reflection; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.TestUtilities; +using Microsoft.EntityFrameworkCore.Diagnostics.Internal; +using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; -using Microsoft.EntityFrameworkCore.Internal; -using Microsoft.EntityFrameworkCore.Diagnostics.Internal; // ReSharper disable InconsistentNaming // ReSharper disable StringStartsWithIsCultureSpecific @@ -24,7 +23,9 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class NorthwindStringIncludeQueryTestBase : NorthwindIncludeQueryTestBase where TFixture : NorthwindQueryFixtureBase, new() { - private static readonly IncludeRewritingExpressionVisitor _includeRewritingExpressionVisitor = new IncludeRewritingExpressionVisitor(); + private static readonly IncludeRewritingExpressionVisitor _includeRewritingExpressionVisitor = + new IncludeRewritingExpressionVisitor(); + protected NorthwindStringIncludeQueryTestBase(TFixture fixture) : base(fixture) { @@ -66,10 +67,12 @@ public override async Task Include_property_after_navigation(bool async) } // Property expression cannot be converted to string include - public override Task Include_property_expression_invalid(bool async) => Task.CompletedTask; + public override Task Include_property_expression_invalid(bool async) + => Task.CompletedTask; // Property expression cannot be converted to string include - public override Task Then_include_property_expression_invalid(bool async) => Task.CompletedTask; + public override Task Then_include_property_expression_invalid(bool async) + => Task.CompletedTask; public override async Task Include_closes_reader(bool async) { @@ -145,7 +148,8 @@ var orders } // Filtered include does not work for string based API. - public override Task Filtered_include_with_multiple_ordering(bool async) => Task.CompletedTask; + public override Task Filtered_include_with_multiple_ordering(bool async) + => Task.CompletedTask; protected override Expression RewriteServerQueryExpression(Expression serverQueryExpression) { @@ -157,13 +161,13 @@ protected override Expression RewriteServerQueryExpression(Expression serverQuer private class IncludeRewritingExpressionVisitor : ExpressionVisitor { private static readonly MethodInfo _includeMethodInfo - = typeof(EntityFrameworkQueryableExtensions) - .GetTypeInfo().GetDeclaredMethods(nameof(EntityFrameworkQueryableExtensions.Include)) - .Single( - mi => - mi.GetGenericArguments().Count() == 2 - && mi.GetParameters().Any( - pi => pi.Name == "navigationPropertyPath" && pi.ParameterType != typeof(string))); + = typeof(EntityFrameworkQueryableExtensions) + .GetTypeInfo().GetDeclaredMethods(nameof(EntityFrameworkQueryableExtensions.Include)) + .Single( + mi => + mi.GetGenericArguments().Count() == 2 + && mi.GetParameters().Any( + pi => pi.Name == "navigationPropertyPath" && pi.ParameterType != typeof(string))); private static readonly MethodInfo _stringIncludeMethodInfo = typeof(EntityFrameworkQueryableExtensions) @@ -240,7 +244,7 @@ private static string GetPath(Expression expression) return $"{GetPath(memberExpression.Expression)}.{memberExpression.Member.Name}"; case UnaryExpression unaryExpression - when unaryExpression.NodeType == ExpressionType.Convert + when unaryExpression.NodeType == ExpressionType.Convert || unaryExpression.NodeType == ExpressionType.Convert || unaryExpression.NodeType == ExpressionType.TypeAs: return GetPath(unaryExpression.Operand); diff --git a/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs index 9794859c710..cfda11cfbb5 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs @@ -23,7 +23,8 @@ protected NorthwindWhereQueryTestBase(TFixture fixture) { } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); protected virtual void ClearLog() { @@ -1192,7 +1193,7 @@ public virtual Task Where_select_many_and(bool async) ss => from c in ss.Set() from e in ss.Set() - // 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") @@ -1794,7 +1795,7 @@ public virtual Task Where_compare_with_both_cast_to_object(bool async) { return AssertQuery( async, - ss => ss.Set().Where(c => (object)c.City == (object)(object)"London"), + ss => ss.Set().Where(c => (object)c.City == (object)"London"), entryCount: 6); } @@ -1996,7 +1997,10 @@ public virtual Task Generic_Ilist_contains_translates_to_server(bool async) } private int SettableProperty { get; set; } - private int ReadOnlyProperty => 5; + + private int ReadOnlyProperty + => 5; + private const int ConstantProperty = 1; [ConditionalTheory] @@ -2124,7 +2128,12 @@ public virtual Task Where_Queryable_AsEnumerable_Contains_negated(bool async) return AssertQuery( async, ss => ss.Set() - .Select(c => new { c.CustomerID, Subquery = ss.Set().Where(o => o.CustomerID == c.CustomerID).Select(o => o.CustomerID).AsEnumerable() }) + .Select( + c => new + { + c.CustomerID, + Subquery = ss.Set().Where(o => o.CustomerID == c.CustomerID).Select(o => o.CustomerID).AsEnumerable() + }) .Where(e => !e.Subquery.Contains("ALFKI")), elementSorter: e => e.CustomerID, elementAsserter: (e, a) => AssertCollection(e.Subquery, a.Subquery)); @@ -2303,7 +2312,8 @@ public virtual Task Multiple_OrElse_on_same_column_converted_to_in_with_overlap( { return AssertQuery( async, - ss => ss.Set().Where(c => c.CustomerID == "ALFKI" || c.CustomerID == "ANATR" || c.CustomerID == "ANTON" || c.CustomerID == "ANATR"), + ss => ss.Set().Where( + c => c.CustomerID == "ALFKI" || c.CustomerID == "ANATR" || c.CustomerID == "ANTON" || c.CustomerID == "ANATR"), entryCount: 3); } @@ -2333,7 +2343,8 @@ public virtual Task Constant_array_Contains_OrElse_comparison_with_constant_gets { return AssertQuery( async, - ss => ss.Set().Where(c => c.CustomerID == "ANTON" || new[] { "ALFKI", "ANATR" }.Contains(c.CustomerID) || c.CustomerID == "ALFKI"), + ss => ss.Set().Where( + c => c.CustomerID == "ANTON" || new[] { "ALFKI", "ANATR" }.Contains(c.CustomerID) || c.CustomerID == "ALFKI"), entryCount: 3); } @@ -2343,7 +2354,8 @@ public virtual Task Constant_array_Contains_OrElse_another_Contains_gets_combine { return AssertQuery( async, - ss => ss.Set().Where(c => new[] { "ALFKI", "ANATR" }.Contains(c.CustomerID) || new[] { "ALFKI", "ANTON" }.Contains(c.CustomerID)), + ss => ss.Set().Where( + c => new[] { "ALFKI", "ANATR" }.Contains(c.CustomerID) || new[] { "ALFKI", "ANTON" }.Contains(c.CustomerID)), entryCount: 3); } @@ -2353,7 +2365,8 @@ public virtual Task Constant_array_Contains_AndAlso_another_Contains_gets_combin { return AssertQuery( async, - ss => ss.Set().Where(c => !new[] { "ALFKI", "ANATR" }.Contains(c.CustomerID) && !new[] { "ALFKI", "ANTON" }.Contains(c.CustomerID)), + ss => ss.Set().Where( + c => !new[] { "ALFKI", "ANATR" }.Contains(c.CustomerID) && !new[] { "ALFKI", "ANTON" }.Contains(c.CustomerID)), entryCount: 88); } @@ -2384,7 +2397,6 @@ public virtual Task Array_of_parameters_Contains_OrElse_comparison_with_constant entryCount: 3); } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Multiple_OrElse_on_same_column_with_null_parameter_comparison_converted_to_in(bool async) @@ -2429,20 +2441,20 @@ public virtual Task Two_sets_of_comparison_combine_correctly(bool async) { return AssertQuery( async, - ss => ss.Set().Where(c => new string[] { "ALFKI", "ANATR" }.Contains(c.CustomerID) && (c.CustomerID == "ANATR" || c.CustomerID == "ANTON")), + ss => ss.Set().Where( + c => new[] { "ALFKI", "ANATR" }.Contains(c.CustomerID) && (c.CustomerID == "ANATR" || c.CustomerID == "ANTON")), entryCount: 1); } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Two_sets_of_comparison_combine_correctly2(bool async) { return AssertQuery( async, - ss => ss.Set().Where(c => (c.Region != "WA" && c.Region != "OR" && c.Region != null) || (c.Region != "WA" && c.Region != null)), + ss => ss.Set().Where( + c => (c.Region != "WA" && c.Region != "OR" && c.Region != null) || (c.Region != "WA" && c.Region != null)), entryCount: 28); } - } } diff --git a/test/EFCore.Specification.Tests/Query/NullKeysTestBase.cs b/test/EFCore.Specification.Tests/Query/NullKeysTestBase.cs index 4be1b742c85..7056eac9660 100644 --- a/test/EFCore.Specification.Tests/Query/NullKeysTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NullKeysTestBase.cs @@ -12,11 +12,13 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class NullKeysTestBase : IClassFixture where TFixture : NullKeysTestBase.NullKeysFixtureBase, new() { - protected NullKeysTestBase(TFixture fixture) => Fixture = fixture; + protected NullKeysTestBase(TFixture fixture) + => Fixture = fixture; protected virtual TFixture Fixture { get; } - protected DbContext CreateContext() => Fixture.CreateContext(); + protected DbContext CreateContext() + => Fixture.CreateContext(); [ConditionalFact] // Issue #1093 public virtual void Include_with_null_FKs_and_nullable_PK() diff --git a/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs index a4575596f53..50b0b35bbc3 100644 --- a/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs @@ -456,7 +456,8 @@ public virtual Task Client_method_skip_take_loads_owned_navigations(bool async) ss => ss.Set().OrderBy(e => e.Id).Select(e => Map(e)).Skip(1).Take(2)); } - private static string Map(OwnedPerson person) => person.PersonAddress.Country.Name; + private static string Map(OwnedPerson person) + => person.PersonAddress.Country.Name; // Issue#18734 [ConditionalTheory] @@ -486,7 +487,8 @@ public virtual Task Client_method_skip_take_loads_owned_navigations_variation_2( ss => ss.Set().OrderBy(e => e.Id).Select(e => Identity(e)).Skip(1).Take(2)); } - private static OwnedPerson Identity(OwnedPerson person) => person; + private static OwnedPerson Identity(OwnedPerson person) + => person; [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -762,8 +764,8 @@ public virtual async Task NoTracking_Include_with_cycles_throws(bool async) Assert.Equal( CoreStrings.IncludeWithCycle("Client", "Orders"), async - ? (await Assert.ThrowsAsync(() => query.ToListAsync())).Message - : Assert.Throws(() => query.ToList()).Message); + ? (await Assert.ThrowsAsync(() => query.ToListAsync())).Message + : Assert.Throws(() => query.ToList()).Message); } [ConditionalTheory] @@ -802,12 +804,13 @@ public virtual Task GroupBy_with_multiple_aggregates_on_owned_navigation_propert { return AssertQuery( async, - ss => ss.Set().GroupBy(e => 1, x => x.PersonAddress.Country.Planet.Star).Select(e => new - { - p1 = e.Average(x => x.Id), - p2 = e.Sum(x => x.Id), - p3 = e.Max(x => x.Name.Length), - })); + ss => ss.Set().GroupBy(e => 1, x => x.PersonAddress.Country.Planet.Star).Select( + e => new + { + p1 = e.Average(x => x.Id), + p2 = e.Sum(x => x.Id), + p3 = e.Max(x => x.Name.Length), + })); } [ConditionalTheory] @@ -824,7 +827,6 @@ public virtual async Task Non_nullable_property_through_optional_navigation(bool [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Ordering_by_identifying_projection(bool async) { return AssertQuery( @@ -835,7 +837,6 @@ public virtual Task Ordering_by_identifying_projection(bool async) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task Query_on_collection_entry_works_for_owned_collection(bool async) { using var context = CreateContext(); @@ -857,7 +858,8 @@ public virtual async Task Query_on_collection_entry_works_for_owned_collection(b } } - protected virtual DbContext CreateContext() => Fixture.CreateContext(); + protected virtual DbContext CreateContext() + => Fixture.CreateContext(); public abstract class OwnedQueryFixtureBase : SharedStoreFixtureBase, IQueryFixtureBase { @@ -884,9 +886,11 @@ private static void AssertOrders(ICollection expectedOrders, ICollection< } } - public Func GetContextCreator() => () => CreateContext(); + public Func GetContextCreator() + => () => CreateContext(); - public ISetSource GetExpectedData() => new OwnedQueryData(); + public ISetSource GetExpectedData() + => new OwnedQueryData(); public IReadOnlyDictionary GetEntitySorters() => new Dictionary> @@ -1150,10 +1154,34 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con ab.IndexerProperty("AddressLine"); ab.IndexerProperty(typeof(int), "ZipCode"); ab.HasData( - new { OwnedPersonId = 1, PlaceType = "Land", AddressLine = "804 S. Lakeshore Road", ZipCode = 38654 }, - new { OwnedPersonId = 2, PlaceType = "Land", AddressLine = "7 Church Dr.", ZipCode = 28655 }, - new { OwnedPersonId = 3, PlaceType = "Land", AddressLine = "72 Hickory Rd.", ZipCode = 07728 }, - new { OwnedPersonId = 4, PlaceType = "Land", AddressLine = "28 Strawberry St.", ZipCode = 19053 }); + new + { + OwnedPersonId = 1, + PlaceType = "Land", + AddressLine = "804 S. Lakeshore Road", + ZipCode = 38654 + }, + new + { + OwnedPersonId = 2, + PlaceType = "Land", + AddressLine = "7 Church Dr.", + ZipCode = 28655 + }, + new + { + OwnedPersonId = 3, + PlaceType = "Land", + AddressLine = "72 Hickory Rd.", + ZipCode = 07728 + }, + new + { + OwnedPersonId = 4, + PlaceType = "Land", + AddressLine = "28 Strawberry St.", + ZipCode = 19053 + }); ab.OwnsOne( a => a.Country, cb => @@ -1194,11 +1222,36 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con { ob.IndexerProperty("OrderDate"); ob.HasData( - new { Id = -10, ClientId = 1, OrderDate = Convert.ToDateTime("2018-07-11 10:01:41") }, - new { Id = -11, ClientId = 1, OrderDate = Convert.ToDateTime("2015-03-03 04:37:59") }, - new { Id = -20, ClientId = 2, OrderDate = Convert.ToDateTime("2015-05-25 20:35:48") }, - new { Id = -30, ClientId = 3, OrderDate = Convert.ToDateTime("2014-11-10 04:32:42") }, - new { Id = -40, ClientId = 4, OrderDate = Convert.ToDateTime("2016-04-25 19:23:56") } + new + { + Id = -10, + ClientId = 1, + OrderDate = Convert.ToDateTime("2018-07-11 10:01:41") + }, + new + { + Id = -11, + ClientId = 1, + OrderDate = Convert.ToDateTime("2015-03-03 04:37:59") + }, + new + { + Id = -20, + ClientId = 2, + OrderDate = Convert.ToDateTime("2015-05-25 20:35:48") + }, + new + { + Id = -30, + ClientId = 3, + OrderDate = Convert.ToDateTime("2014-11-10 04:32:42") + }, + new + { + Id = -40, + ClientId = 4, + OrderDate = Convert.ToDateTime("2016-04-25 19:23:56") + } ); }); }); @@ -1213,8 +1266,18 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con { ab.IndexerProperty("BranchName"); ab.HasData( - new { BranchId = 2, PlaceType = "Land", BranchName = "BranchA" }, - new { BranchId = 3, PlaceType = "Land", BranchName = "BranchB" }); + new + { + BranchId = 2, + PlaceType = "Land", + BranchName = "BranchA" + }, + new + { + BranchId = 3, + PlaceType = "Land", + BranchName = "BranchB" + }); ab.OwnsOne( a => a.Country, cb => @@ -1249,7 +1312,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con ab.IndexerProperty("LeafType"); ab.HasData( - new { LeafAId = 3, PlaceType = "Land", LeafType = 1 }); + new + { + LeafAId = 3, + PlaceType = "Land", + LeafType = 1 + }); ab.OwnsOne( a => a.Country, cb => @@ -1280,7 +1348,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con { ab.IndexerProperty("LeafBType"); ab.HasData( - new { LeafBId = 4, PlaceType = "Land", LeafBType = "Green" }); + new + { + LeafBId = 4, + PlaceType = "Land", + LeafBType = "Green" + }); ab.OwnsOne( a => a.Country, cb => @@ -1339,7 +1412,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con { b.OwnsOne( e => e.Throned, b => b.HasData( - new { BartonId = 1, Property = "Property", Value = 42 })); + new + { + BartonId = 1, + Property = "Property", + Value = 42 + })); b.HasData( new Barton { Id = 1, Simple = "Simple" }, new Barton { Id = 2, Simple = "Not" }); @@ -1471,11 +1549,7 @@ private static IReadOnlyList CreateOwnedPeople() var personAddress1 = new OwnedAddress { PlaceType = "Land", Country = new OwnedCountry { Name = "USA", PlanetId = 1 } }; personAddress1["AddressLine"] = "804 S. Lakeshore Road"; personAddress1["ZipCode"] = 38654; - var ownedPerson1 = new OwnedPerson - { - Id = 1, - PersonAddress = personAddress1 - }; + var ownedPerson1 = new OwnedPerson { Id = 1, PersonAddress = personAddress1 }; ownedPerson1["Name"] = "Mona Cy"; var personAddress2 = new OwnedAddress { PlaceType = "Land", Country = new OwnedCountry { Name = "USA", PlanetId = 1 } }; @@ -1562,8 +1636,7 @@ private static IReadOnlyList CreateBartons() }, new Barton { - Id = 2, - Simple = "Not", + Id = 2, Simple = "Not", } }; @@ -1608,17 +1681,20 @@ protected class OwnedAddress public string PlaceType { get; set; } public OwnedCountry Country { get; set; } + public object this[string name] { - get => name switch - { - "AddressLine" => _addressLine, - "ZipCode" => _zipCode, - "BranchName" => _branchName, - "LeafType" => _leafAType, - "LeafBType" => _leafBType, - _ => throw new InvalidOperationException($"Indexer property with key {name} is not defined on {nameof(OwnedPerson)}."), - }; + get + => name switch + { + "AddressLine" => _addressLine, + "ZipCode" => _zipCode, + "BranchName" => _branchName, + "LeafType" => _leafAType, + "LeafBType" => _leafBType, + _ => throw new InvalidOperationException( + $"Indexer property with key {name} is not defined on {nameof(OwnedPerson)}."), + }; set { @@ -1645,7 +1721,8 @@ public object this[string name] break; default: - throw new InvalidOperationException($"Indexer property with key {name} is not defined on {nameof(OwnedPerson)}."); + throw new InvalidOperationException( + $"Indexer property with key {name} is not defined on {nameof(OwnedPerson)}."); } } } @@ -1691,7 +1768,9 @@ public object this[string name] } public OwnedAddress PersonAddress { get; set; } - public int ReadOnlyProperty => 10; + + public int ReadOnlyProperty + => 10; public ICollection Orders { get; set; } } diff --git a/test/EFCore.Specification.Tests/Query/QueryFilterFuncletizationFixtureBase.cs b/test/EFCore.Specification.Tests/Query/QueryFilterFuncletizationFixtureBase.cs index 3b0b9755b87..18d281a7679 100644 --- a/test/EFCore.Specification.Tests/Query/QueryFilterFuncletizationFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/QueryFilterFuncletizationFixtureBase.cs @@ -7,7 +7,8 @@ public abstract class QueryFilterFuncletizationFixtureBase : SharedStoreFixtureB { protected override string StoreName { get; } = "QueryFilterFuncletizationTest"; - protected override bool UsePooling => false; + protected override bool UsePooling + => false; protected override void Seed(QueryFilterFuncletizationContext context) => QueryFilterFuncletizationContext.SeedData(context); diff --git a/test/EFCore.Specification.Tests/Query/QueryFilterFuncletizationTestBase.cs b/test/EFCore.Specification.Tests/Query/QueryFilterFuncletizationTestBase.cs index 25a292784ee..e2b05dff44f 100644 --- a/test/EFCore.Specification.Tests/Query/QueryFilterFuncletizationTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/QueryFilterFuncletizationTestBase.cs @@ -15,11 +15,13 @@ namespace Microsoft.EntityFrameworkCore.Query public abstract class QueryFilterFuncletizationTestBase : IClassFixture where TFixture : QueryFilterFuncletizationFixtureBase, new() { - protected QueryFilterFuncletizationTestBase(TFixture fixture) => Fixture = fixture; + protected QueryFilterFuncletizationTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } - protected QueryFilterFuncletizationContext CreateContext() => Fixture.CreateContext(); + protected QueryFilterFuncletizationContext CreateContext() + => Fixture.CreateContext(); [ConditionalFact] public virtual void DbContext_property_parameter_does_not_clash_with_closure_parameter_name() diff --git a/test/EFCore.Specification.Tests/Query/QueryTestBase.cs b/test/EFCore.Specification.Tests/Query/QueryTestBase.cs index a6e807ee0c7..046c090eac4 100644 --- a/test/EFCore.Specification.Tests/Query/QueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/QueryTestBase.cs @@ -28,9 +28,11 @@ protected QueryTestBase(TFixture fixture) protected virtual QueryAsserter CreateQueryAsserter(TFixture fixture) => new QueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, IgnoreEntryCount); - protected virtual bool IgnoreEntryCount => false; + protected virtual bool IgnoreEntryCount + => false; - protected virtual Expression RewriteServerQueryExpression(Expression serverQueryExpression) => serverQueryExpression; + protected virtual Expression RewriteServerQueryExpression(Expression serverQueryExpression) + => serverQueryExpression; protected virtual Expression RewriteExpectedQueryExpression(Expression expectedQueryExpression) => new ExpectedQueryRewritingVisitor().Visit(expectedQueryExpression); diff --git a/test/EFCore.Specification.Tests/Query/SpatialQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/SpatialQueryFixtureBase.cs index 1d8bdf96bef..9ea8fdc0fa6 100644 --- a/test/EFCore.Specification.Tests/Query/SpatialQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/SpatialQueryFixtureBase.cs @@ -15,13 +15,17 @@ public abstract class SpatialQueryFixtureBase : SharedStoreFixtureBase GetContextCreator() => () => CreateContext(); + public Func GetContextCreator() + => () => CreateContext(); - public ISetSource GetExpectedData() => new SpatialData(GeometryFactory); + public ISetSource GetExpectedData() + => new SpatialData(GeometryFactory); - public IReadOnlyDictionary GetEntitySorters() => null; + public IReadOnlyDictionary GetEntitySorters() + => null; - public IReadOnlyDictionary GetEntityAsserters() => null; + public IReadOnlyDictionary GetEntityAsserters() + => null; public virtual GeometryFactory GeometryFactory => LazyInitializer.EnsureInitialized( diff --git a/test/EFCore.Specification.Tests/Query/SpatialQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/SpatialQueryTestBase.cs index bc8b31e7cfd..ac80c71a8d1 100644 --- a/test/EFCore.Specification.Tests/Query/SpatialQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/SpatialQueryTestBase.cs @@ -212,7 +212,8 @@ public virtual Task Contains(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Contains = (bool?)e.Polygon.Contains(point) }), - ss => ss.Set().Select(e => new { e.Id, Contains = e.Polygon == null ? (bool?)null : e.Polygon.Contains(point) }), + ss => ss.Set() + .Select(e => new { e.Id, Contains = e.Polygon == null ? (bool?)null : e.Polygon.Contains(point) }), elementSorter: x => x.Id); } @@ -267,7 +268,8 @@ public virtual Task CoveredBy(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, CoveredBy = (bool?)e.Point.CoveredBy(polygon) }), - ss => ss.Set().Select(e => new { e.Id, CoveredBy = e.Point == null ? (bool?)null : e.Point.CoveredBy(polygon) }), + ss => ss.Set() + .Select(e => new { e.Id, CoveredBy = e.Point == null ? (bool?)null : e.Point.CoveredBy(polygon) }), elementSorter: x => x.Id); } @@ -294,7 +296,8 @@ public virtual Task Crosses(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Crosses = (bool?)e.LineString.Crosses(lineString) }), - ss => ss.Set().Select(e => new { e.Id, Crosses = e.LineString == null ? (bool?)null : e.LineString.Crosses(lineString) }), + ss => ss.Set().Select( + e => new { e.Id, Crosses = e.LineString == null ? (bool?)null : e.LineString.Crosses(lineString) }), elementSorter: x => x.Id); } @@ -308,7 +311,8 @@ public virtual Task Difference(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Difference = e.Polygon.Difference(polygon) }), - ss => ss.Set().Select(e => new { e.Id, Difference = e.Polygon == null ? null : e.Polygon.Difference(polygon) }), + ss => ss.Set() + .Select(e => new { e.Id, Difference = e.Polygon == null ? null : e.Polygon.Difference(polygon) }), elementSorter: x => x.Id, elementAsserter: (e, a) => { @@ -336,7 +340,8 @@ public virtual Task Disjoint_with_cast_to_nullable(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Disjoint = (bool?)e.Polygon.Disjoint(point) }), - ss => ss.Set().Select(e => new { e.Id, Disjoint = e.Polygon == null ? (bool?)null : e.Polygon.Disjoint(point) }), + ss => ss.Set() + .Select(e => new { e.Id, Disjoint = e.Polygon == null ? (bool?)null : e.Polygon.Disjoint(point) }), elementSorter: x => x.Id); } @@ -348,7 +353,8 @@ public virtual Task Disjoint_with_null_check(bool async) return AssertQuery( async, - ss => ss.Set().Select(e => new { e.Id, Disjoint = e.Polygon == null ? (bool?)null : e.Polygon.Disjoint(point) }), + ss => ss.Set() + .Select(e => new { e.Id, Disjoint = e.Polygon == null ? (bool?)null : e.Polygon.Disjoint(point) }), elementSorter: x => x.Id); } @@ -361,7 +367,8 @@ public virtual Task Distance_with_null_check(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Distance = (double?)e.Point.Distance(point) }), - ss => ss.Set().Select(e => new { e.Id, Distance = (e.Point == null ? (double?)null : e.Point.Distance(point)) }), + ss => ss.Set() + .Select(e => new { e.Id, Distance = (e.Point == null ? (double?)null : e.Point.Distance(point)) }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -404,7 +411,6 @@ public virtual Task Distance_with_cast_to_nullable(bool async) }); } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Distance_geometry(bool async) @@ -414,7 +420,8 @@ public virtual Task Distance_geometry(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Distance = (double?)e.Geometry.Distance(point) }), - ss => ss.Set().Select(e => new { e.Id, Distance = e.Geometry == null ? (double?)null : e.Geometry.Distance(point) }), + ss => ss.Set().Select( + e => new { e.Id, Distance = e.Geometry == null ? (double?)null : e.Geometry.Distance(point) }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -438,7 +445,8 @@ public virtual Task Distance_constant(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Distance = (double?)e.Point.Distance(new Point(0, 1)) }), - ss => ss.Set().Select(e => new { e.Id, Distance = e.Point == null ? (double?)null : e.Point.Distance(new Point(0, 1)) }), + ss => ss.Set().Select( + e => new { e.Id, Distance = e.Point == null ? (double?)null : e.Point.Distance(new Point(0, 1)) }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -461,8 +469,10 @@ public virtual Task Distance_constant_srid_4326(bool async) { return AssertQuery( async, - ss => ss.Set().Select(e => new { e.Id, Distance = (double?)e.Point.Distance(new Point(1, 1) { SRID = 4326 }) }), - ss => ss.Set().Select(e => new { e.Id, Distance = e.Point == null ? (double?)null : e.Point.Distance(new Point(1, 1) { SRID = 4326 }) }), + ss => ss.Set() + .Select(e => new { e.Id, Distance = (double?)e.Point.Distance(new Point(1, 1) { SRID = 4326 }) }), + ss => ss.Set().Select( + 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) => { @@ -486,7 +496,8 @@ public virtual Task Distance_constant_lhs(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Distance = (double?)new Point(0, 1).Distance(e.Point) }), - ss => ss.Set().Select(e => new { e.Id, Distance = e.Point == null ? (double?)null : new Point(0, 1).Distance(e.Point) }), + ss => ss.Set().Select( + e => new { e.Id, Distance = e.Point == null ? (double?)null : new Point(0, 1).Distance(e.Point) }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -603,7 +614,8 @@ public virtual Task EqualsTopologically(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, EqualsTopologically = (bool?)e.Point.EqualsTopologically(point) }), - ss => ss.Set().Select(e => new { e.Id, EqualsTopologically = e.Point == null ? (bool?)null : e.Point.EqualsTopologically(point) }), + ss => ss.Set().Select( + e => new { e.Id, EqualsTopologically = e.Point == null ? (bool?)null : e.Point.EqualsTopologically(point) }), elementSorter: x => x.Id); } @@ -635,7 +647,8 @@ public virtual Task GetGeometryN(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Geometry0 = e.MultiLineString.GetGeometryN(0) }), - ss => ss.Set().Select(e => new { e.Id, Geometry0 = e.MultiLineString == null ? null : e.MultiLineString.GetGeometryN(0) }), + ss => ss.Set().Select( + e => new { e.Id, Geometry0 = e.MultiLineString == null ? null : e.MultiLineString.GetGeometryN(0) }), elementSorter: x => x.Id); } @@ -645,7 +658,12 @@ public virtual Task GetGeometryN_with_null_argument(bool async) { return AssertQuery( async, - ss => ss.Set().Select(e => new { e.Id, Geometry0 = e.MultiLineString.GetGeometryN(ss.Set().Where(ee => false).Max(ee => ee.Id)) }), + ss => ss.Set().Select( + e => new + { + e.Id, + Geometry0 = e.MultiLineString.GetGeometryN(ss.Set().Where(ee => false).Max(ee => ee.Id)) + }), ss => ss.Set().Select(e => new { e.Id, Geometry0 = default(Geometry) }), elementSorter: x => x.Id); } @@ -682,7 +700,8 @@ public virtual Task GetPointN(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Point0 = e.LineString.GetPointN(0) }), - ss => ss.Set().Select(e => new { e.Id, Point0 = e.LineString == null ? null : e.LineString.GetPointN(0) }), + ss => ss.Set() + .Select(e => new { e.Id, Point0 = e.LineString == null ? null : e.LineString.GetPointN(0) }), elementSorter: x => x.Id); } @@ -725,7 +744,8 @@ public virtual Task Intersection(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Intersection = e.Polygon.Intersection(polygon) }), - ss => ss.Set().Select(e => new { e.Id, Intersection = e.Polygon == null ? null : e.Polygon.Intersection(polygon) }), + ss => ss.Set().Select( + e => new { e.Id, Intersection = e.Polygon == null ? null : e.Polygon.Intersection(polygon) }), elementSorter: x => x.Id, elementAsserter: (e, a) => { @@ -744,7 +764,8 @@ public virtual Task Intersects(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Intersects = (bool?)e.LineString.Intersects(lineString) }), - ss => ss.Set().Select(e => new { e.Id, Intersects = e.LineString == null ? (bool?)null : e.LineString.Intersects(lineString) }), + ss => ss.Set().Select( + e => new { e.Id, Intersects = e.LineString == null ? (bool?)null : e.LineString.Intersects(lineString) }), elementSorter: x => x.Id); } @@ -824,7 +845,8 @@ public virtual Task IsWithinDistance(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, IsWithinDistance = (bool?)e.Point.IsWithinDistance(point, 1) }), - ss => ss.Set().Select(e => new { e.Id, IsWithinDistance = e.Point == null ? (bool?)null : e.Point.IsWithinDistance(point, 1) }), + ss => ss.Set().Select( + e => new { e.Id, IsWithinDistance = e.Point == null ? (bool?)null : e.Point.IsWithinDistance(point, 1) }), elementSorter: e => e.Id, elementAsserter: (e, a) => { @@ -848,7 +870,8 @@ public virtual Task Item(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Item0 = e.MultiLineString[0] }), - ss => ss.Set().Select(e => new { e.Id, Item0 = e.MultiLineString == null ? null : e.MultiLineString[0] }), + ss => ss.Set() + .Select(e => new { e.Id, Item0 = e.MultiLineString == null ? null : e.MultiLineString[0] }), elementSorter: x => x.Id); } @@ -969,7 +992,8 @@ public virtual Task Overlaps(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Overlaps = (bool?)e.Polygon.Overlaps(polygon) }), - ss => ss.Set().Select(e => new { e.Id, Overlaps = e.Polygon == null ? (bool?)null : e.Polygon.Overlaps(polygon) }), + ss => ss.Set() + .Select(e => new { e.Id, Overlaps = e.Polygon == null ? (bool?)null : e.Polygon.Overlaps(polygon) }), elementSorter: x => x.Id); } @@ -1012,7 +1036,8 @@ public virtual Task Relate(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Relate = (bool?)e.Polygon.Relate(polygon, "212111212") }), - ss => ss.Set().Select(e => new { e.Id, Relate = e.Polygon == null ? (bool?)null : e.Polygon.Relate(polygon, "212111212") }), + ss => ss.Set().Select( + e => new { e.Id, Relate = e.Polygon == null ? (bool?)null : e.Polygon.Relate(polygon, "212111212") }), elementSorter: x => x.Id); } @@ -1070,7 +1095,8 @@ public virtual Task SymmetricDifference(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, SymmetricDifference = e.Polygon.SymmetricDifference(polygon) }), - ss => ss.Set().Select(e => new { e.Id, SymmetricDifference = e.Polygon == null ? null : e.Polygon.SymmetricDifference(polygon) }), + ss => ss.Set().Select( + e => new { e.Id, SymmetricDifference = e.Polygon == null ? null : e.Polygon.SymmetricDifference(polygon) }), elementSorter: x => x.Id, elementAsserter: (e, a) => { @@ -1121,7 +1147,8 @@ public virtual Task Touches(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Touches = (bool?)e.Polygon.Touches(polygon) }), - ss => ss.Set().Select(e => new { e.Id, Touches = e.Polygon == null ? (bool?)null : e.Polygon.Touches(polygon) }), + ss => ss.Set() + .Select(e => new { e.Id, Touches = e.Polygon == null ? (bool?)null : e.Polygon.Touches(polygon) }), elementSorter: x => x.Id); } @@ -1151,7 +1178,8 @@ public virtual Task Union_void(bool async) return AssertQuery( async, ss => ss.Set().Select(e => new { e.Id, Union = e.MultiLineString.Union() }), - ss => ss.Set().Select(e => new { e.Id, Union = e.MultiLineString == null ? null : e.MultiLineString.Union() }), + ss => ss.Set() + .Select(e => new { e.Id, Union = e.MultiLineString == null ? null : e.MultiLineString.Union() }), elementSorter: x => x.Id); } diff --git a/test/EFCore.Specification.Tests/SaveChangesInterceptionTestBase.cs b/test/EFCore.Specification.Tests/SaveChangesInterceptionTestBase.cs index defb9cd051a..3532acb87de 100644 --- a/test/EFCore.Specification.Tests/SaveChangesInterceptionTestBase.cs +++ b/test/EFCore.Specification.Tests/SaveChangesInterceptionTestBase.cs @@ -163,7 +163,9 @@ public override InterceptionResult SavingChanges(DbContextEventData eventDa } public override async ValueTask> SavingChangesAsync( - DbContextEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) + DbContextEventData eventData, + InterceptionResult result, + CancellationToken cancellationToken = default) { await base.SavingChangesAsync(eventData, result, cancellationToken); @@ -247,7 +249,9 @@ public override int SavedChanges(SaveChangesCompletedEventData eventData, int re } public override async ValueTask SavedChangesAsync( - SaveChangesCompletedEventData eventData, int result, CancellationToken cancellationToken = default) + SaveChangesCompletedEventData eventData, + int result, + CancellationToken cancellationToken = default) { await base.SavedChangesAsync(eventData, result, cancellationToken); @@ -454,7 +458,9 @@ public virtual void SaveChangesFailed(DbContextErrorEventData eventData) } public virtual ValueTask> SavingChangesAsync( - DbContextEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) + DbContextEventData eventData, + InterceptionResult result, + CancellationToken cancellationToken = default) { Assert.NotNull(eventData.Context); @@ -466,7 +472,9 @@ public virtual ValueTask> SavingChangesAsync( } public virtual ValueTask SavedChangesAsync( - SaveChangesCompletedEventData eventData, int result, CancellationToken cancellationToken = default) + SaveChangesCompletedEventData eventData, + int result, + CancellationToken cancellationToken = default) { Assert.NotNull(eventData.Context); @@ -478,7 +486,8 @@ public virtual ValueTask SavedChangesAsync( } public virtual Task SaveChangesFailedAsync( - DbContextErrorEventData eventData, CancellationToken cancellationToken = default) + DbContextErrorEventData eventData, + CancellationToken cancellationToken = default) { Assert.NotNull(eventData.Context); Assert.NotNull(eventData.Exception); @@ -501,6 +510,7 @@ private static void AssertNormalOutcome(DbContext context, SaveChangesIntercepto Assert.Same(context, interceptor.Context); } - protected virtual bool SupportsOptimisticConcurrency => true; + protected virtual bool SupportsOptimisticConcurrency + => true; } } diff --git a/test/EFCore.Specification.Tests/SerializationTestBase.cs b/test/EFCore.Specification.Tests/SerializationTestBase.cs index 63b14711a55..fe3fe66f7dd 100644 --- a/test/EFCore.Specification.Tests/SerializationTestBase.cs +++ b/test/EFCore.Specification.Tests/SerializationTestBase.cs @@ -3,10 +3,9 @@ using System.Collections.Generic; using System.Linq; -using System.Text.Json; -using System.Text.Json.Serialization; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.TestModels.ConcurrencyModel; +using Newtonsoft.Json; using Xunit; namespace Microsoft.EntityFrameworkCore @@ -14,7 +13,8 @@ namespace Microsoft.EntityFrameworkCore public abstract class SerializationTestBase : IClassFixture where TFixture : F1FixtureBase, new() { - protected SerializationTestBase(TFixture fixture) => Fixture = fixture; + protected SerializationTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -98,7 +98,9 @@ private static void VerifyEngine(F1Context context, Engine engine, IDictionary engineSupplierMap) + F1Context context, + EngineSupplier engineSupplier, + IDictionary engineSupplierMap) { var trackedEngineSupplier = context.EngineSuppliers.Find(engineSupplier.Id); Assert.Equal(trackedEngineSupplier.Name, engineSupplier.Name); @@ -134,23 +136,23 @@ private static T RoundtripThroughBclJson(T collection, bool ignoreLoops, bool private static T RoundtripThroughNewtonsoftJson(T collection, bool ignoreLoops, bool writeIndented) { - var options = new Newtonsoft.Json.JsonSerializerSettings + var options = new JsonSerializerSettings { PreserveReferencesHandling = ignoreLoops - ? Newtonsoft.Json.PreserveReferencesHandling.None - : Newtonsoft.Json.PreserveReferencesHandling.All, + ? PreserveReferencesHandling.None + : PreserveReferencesHandling.All, ReferenceLoopHandling = ignoreLoops - ? Newtonsoft.Json.ReferenceLoopHandling.Ignore - : Newtonsoft.Json.ReferenceLoopHandling.Error, + ? ReferenceLoopHandling.Ignore + : ReferenceLoopHandling.Error, EqualityComparer = LegacyReferenceEqualityComparer.Instance, Formatting = writeIndented - ? Newtonsoft.Json.Formatting.Indented - : Newtonsoft.Json.Formatting.None + ? Formatting.Indented + : Formatting.None }; - var serializeObject = Newtonsoft.Json.JsonConvert.SerializeObject(collection, options); + var serializeObject = JsonConvert.SerializeObject(collection, options); - return Newtonsoft.Json.JsonConvert.DeserializeObject(serializeObject); + return JsonConvert.DeserializeObject(serializeObject); } } } diff --git a/test/EFCore.Specification.Tests/ServiceProviderFixtureBase.cs b/test/EFCore.Specification.Tests/ServiceProviderFixtureBase.cs index 9b96239d63a..8ab99000b90 100644 --- a/test/EFCore.Specification.Tests/ServiceProviderFixtureBase.cs +++ b/test/EFCore.Specification.Tests/ServiceProviderFixtureBase.cs @@ -35,6 +35,7 @@ protected override IServiceCollection AddServices(IServiceCollection serviceColl => base.AddServices(serviceCollection) .AddSingleton(TestStoreFactory.CreateListLoggerFactory(ShouldLogCategory)); - protected virtual bool ShouldLogCategory(string logCategory) => false; + protected virtual bool ShouldLogCategory(string logCategory) + => false; } } diff --git a/test/EFCore.Specification.Tests/SharedStoreFixtureBase.cs b/test/EFCore.Specification.Tests/SharedStoreFixtureBase.cs index b1f41f95ebe..162b259f613 100644 --- a/test/EFCore.Specification.Tests/SharedStoreFixtureBase.cs +++ b/test/EFCore.Specification.Tests/SharedStoreFixtureBase.cs @@ -20,7 +20,9 @@ public abstract class SharedStoreFixtureBase : FixtureBase, IDisposabl protected abstract string StoreName { get; } protected abstract ITestStoreFactory TestStoreFactory { get; } public TestStore TestStore { get; } - protected virtual bool UsePooling => true; + + protected virtual bool UsePooling + => true; private IDbContextPool _contextPool; @@ -77,7 +79,8 @@ protected override IServiceCollection AddServices(IServiceCollection serviceColl => base.AddServices(serviceCollection) .AddSingleton(TestStoreFactory.CreateListLoggerFactory(ShouldLogCategory)); - protected virtual bool ShouldLogCategory(string logCategory) => false; + protected virtual bool ShouldLogCategory(string logCategory) + => false; public virtual void Reseed() { @@ -120,6 +123,7 @@ public virtual void Dispose() { } - public virtual Task DisposeAsync() => TestStore.DisposeAsync(); + public virtual Task DisposeAsync() + => TestStore.DisposeAsync(); } } diff --git a/test/EFCore.Specification.Tests/SpatialTestBase.cs b/test/EFCore.Specification.Tests/SpatialTestBase.cs index 95a0e657be0..13babe0116b 100644 --- a/test/EFCore.Specification.Tests/SpatialTestBase.cs +++ b/test/EFCore.Specification.Tests/SpatialTestBase.cs @@ -142,6 +142,7 @@ protected virtual void ExecuteWithStrategyInTransaction( protected abstract void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction); - protected SpatialContext CreateContext() => Fixture.CreateContext(); + protected SpatialContext CreateContext() + => Fixture.CreateContext(); } } diff --git a/test/EFCore.Specification.Tests/StoreGeneratedFixupTestBase.cs b/test/EFCore.Specification.Tests/StoreGeneratedFixupTestBase.cs index b51bb1cf6e1..5043c873666 100644 --- a/test/EFCore.Specification.Tests/StoreGeneratedFixupTestBase.cs +++ b/test/EFCore.Specification.Tests/StoreGeneratedFixupTestBase.cs @@ -21,7 +21,8 @@ public abstract class StoreGeneratedFixupTestBase : IClassFixture Fixture = fixture; + protected StoreGeneratedFixupTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -4638,7 +4639,8 @@ protected virtual void UseTransaction(DatabaseFacade facade, IDbContextTransacti protected virtual void ExecuteWithStrategyInTransaction(Action testOperation) => TestHelpers.ExecuteWithStrategyInTransaction(CreateContext, UseTransaction, testOperation); - protected DbContext CreateContext() => Fixture.CreateContext(); + protected DbContext CreateContext() + => Fixture.CreateContext(); public abstract class StoreGeneratedFixupFixtureBase : SharedStoreFixtureBase { diff --git a/test/EFCore.Specification.Tests/StoreGeneratedTestBase.cs b/test/EFCore.Specification.Tests/StoreGeneratedTestBase.cs index ea936471415..46773825b10 100644 --- a/test/EFCore.Specification.Tests/StoreGeneratedTestBase.cs +++ b/test/EFCore.Specification.Tests/StoreGeneratedTestBase.cs @@ -18,7 +18,8 @@ namespace Microsoft.EntityFrameworkCore public abstract class StoreGeneratedTestBase : IClassFixture where TFixture : StoreGeneratedTestBase.StoreGeneratedFixtureBase, new() { - protected StoreGeneratedTestBase(TFixture fixture) => Fixture = fixture; + protected StoreGeneratedTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -634,7 +635,7 @@ public void Clearing_optional_FK_does_not_leave_temporary_value() protected class OptionalProduct { public int Id { get; set; } - public int? CategoryId { get; set; } + public int? CategoryId { get; set; } public OptionalCategory Category { get; set; } } @@ -1618,7 +1619,8 @@ protected virtual void UseTransaction(DatabaseFacade facade, IDbContextTransacti { } - protected DbContext CreateContext() => Fixture.CreateContext(); + protected DbContext CreateContext() + => Fixture.CreateContext(); public abstract class StoreGeneratedFixtureBase : SharedStoreFixtureBase { diff --git a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUserContext.cs b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUserContext.cs index 3b5fa22c502..d6fbc259898 100644 --- a/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUserContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/AspNetIdentity/IdentityUserContext.cs @@ -40,8 +40,11 @@ public PersonalDataConverter(IPersonalDataProtector protector) private class PersonalDataProtector : IPersonalDataProtector { - public string Protect(string data) => data; - public string Unprotect(string data) => data; + public string Protect(string data) + => data; + + public string Unprotect(string data) + => data; } protected override void OnModelCreating(ModelBuilder builder) diff --git a/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/ComplexNavigationsData.cs b/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/ComplexNavigationsData.cs index 2ccc340882a..c07701fdd0d 100644 --- a/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/ComplexNavigationsData.cs +++ b/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/ComplexNavigationsData.cs @@ -380,7 +380,10 @@ public static void WireUpInheritancePart2( } public static void WireUpPart1( - IReadOnlyList l1s, IReadOnlyList l2s, IReadOnlyList l3s, IReadOnlyList l4s, + IReadOnlyList l1s, + IReadOnlyList l2s, + IReadOnlyList l3s, + IReadOnlyList l4s, bool tableSplitting) { l1s[0].OneToOne_Required_PK1 = l2s[0]; @@ -620,7 +623,10 @@ public static void WireUpPart1( } public static void WireUpInversePart1( - IReadOnlyList l1s, IReadOnlyList l2s, IReadOnlyList l3s, IReadOnlyList l4s, + IReadOnlyList l1s, + IReadOnlyList l2s, + IReadOnlyList l3s, + IReadOnlyList l4s, bool tableSplitting) { l2s[0].OneToOne_Required_PK_Inverse2 = l1s[0]; @@ -903,7 +909,10 @@ public static void WireUpInversePart1( } public static void WireUpPart2( - IReadOnlyList l1s, IReadOnlyList l2s, IReadOnlyList l3s, IReadOnlyList l4s, + IReadOnlyList l1s, + IReadOnlyList l2s, + IReadOnlyList l3s, + IReadOnlyList l4s, bool tableSplitting) { l1s[0].OneToOne_Optional_PK1 = l2s[0]; @@ -1012,7 +1021,10 @@ public static void WireUpPart2( } public static void WireUpInversePart2( - IReadOnlyList l1s, IReadOnlyList l2s, IReadOnlyList l3s, IReadOnlyList l4s, + IReadOnlyList l1s, + IReadOnlyList l2s, + IReadOnlyList l3s, + IReadOnlyList l4s, bool tableSplitting) { l2s[0].OneToOne_Optional_PK_Inverse2 = l1s[0]; diff --git a/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level1.cs b/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level1.cs index 242206bee65..8ae8c27870d 100644 --- a/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level1.cs +++ b/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level1.cs @@ -45,6 +45,7 @@ private bool Equals(Level1 other) return Id == other.Id && string.Equals(Name, other.Name) && Date.Equals(other.Date); } - public override int GetHashCode() => HashCode.Combine(Id, Name, Date); + public override int GetHashCode() + => HashCode.Combine(Id, Name, Date); } } diff --git a/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level2.cs b/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level2.cs index c0553992d5c..db287448a11 100644 --- a/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level2.cs +++ b/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level2.cs @@ -60,6 +60,7 @@ private bool Equals(Level2 other) && Level1_Optional_Id == other.Level1_Optional_Id; } - public override int GetHashCode() => HashCode.Combine(Id, Name, Date, Level1_Required_Id, Level1_Optional_Id); + public override int GetHashCode() + => HashCode.Combine(Id, Name, Date, Level1_Required_Id, Level1_Optional_Id); } } diff --git a/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level3.cs b/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level3.cs index 3a707d6e5f0..2e623c1eac2 100644 --- a/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level3.cs +++ b/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level3.cs @@ -58,6 +58,7 @@ protected bool Equals(Level3 other) && Level2_Optional_Id == other.Level2_Optional_Id; } - public override int GetHashCode() => HashCode.Combine(Id, Name, Level2_Required_Id, Level2_Optional_Id); + public override int GetHashCode() + => HashCode.Combine(Id, Name, Level2_Required_Id, Level2_Optional_Id); } } diff --git a/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level4.cs b/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level4.cs index 62b15ead4a1..a1b140b714d 100644 --- a/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level4.cs +++ b/test/EFCore.Specification.Tests/TestModels/ComplexNavigationsModel/Level4.cs @@ -49,6 +49,7 @@ protected bool Equals(Level4 other) && Level3_Optional_Id == other.Level3_Optional_Id; } - public override int GetHashCode() => HashCode.Combine(Id, Name, Level3_Required_Id, Level3_Optional_Id); + public override int GetHashCode() + => HashCode.Combine(Id, Name, Level3_Required_Id, Level3_Optional_Id); } } diff --git a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Sponsor.cs b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Sponsor.cs index 4e6cd0712ef..d5f06f9d17c 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Sponsor.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Sponsor.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; -using System.ComponentModel.DataAnnotations.Schema; namespace Microsoft.EntityFrameworkCore.TestModels.ConcurrencyModel { @@ -16,6 +15,7 @@ public class Sponsor public int Id { get; set; } public string Name { get; set; } - public virtual ICollection Teams => _teams; + public virtual ICollection Teams + => _teams; } } diff --git a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Team.cs b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Team.cs index e92cffe8fb9..9e07beb9631 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Team.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/Team.cs @@ -84,7 +84,8 @@ public virtual ICollection Drivers } } - public virtual ICollection Sponsors => _sponsors; + public virtual ICollection Sponsors + => _sponsors; public int? GearboxId { get; set; } diff --git a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/TeamSponsor.cs b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/TeamSponsor.cs index 888d85d5b5b..3d553bb61ef 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/TeamSponsor.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConcurrencyModel/TeamSponsor.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. + namespace Microsoft.EntityFrameworkCore.TestModels.ConcurrencyModel { public class TeamSponsor diff --git a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/Session.cs b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/Session.cs index 20b3df59cbc..47d3068878f 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/Session.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/ConferenceDTO/Session.cs @@ -22,7 +22,8 @@ public class Session public virtual DateTimeOffset? EndTime { get; set; } // Bonus points to those who can figure out why this is written this way - public TimeSpan Duration => EndTime?.Subtract(StartTime ?? EndTime ?? DateTimeOffset.MinValue) ?? TimeSpan.Zero; + public TimeSpan Duration + => EndTime?.Subtract(StartTime ?? EndTime ?? DateTimeOffset.MinValue) ?? TimeSpan.Zero; public int? TrackId { get; set; } } diff --git a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/EntityExtensions.cs b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/EntityExtensions.cs index c372ceca874..d3e9f7871a5 100644 --- a/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/EntityExtensions.cs +++ b/test/EFCore.Specification.Tests/TestModels/ConferencePlanner/EntityExtensions.cs @@ -8,8 +8,8 @@ namespace Microsoft.EntityFrameworkCore.TestModels.ConferencePlanner { public static class EntityExtensions { - public static SessionResponse MapSessionResponse(this Session session) => - new SessionResponse + public static SessionResponse MapSessionResponse(this Session session) + => new SessionResponse { Id = session.Id, Title = session.Title, @@ -23,8 +23,8 @@ public static SessionResponse MapSessionResponse(this Session session) => Abstract = session.Abstract }; - public static SpeakerResponse MapSpeakerResponse(this Speaker speaker) => - new SpeakerResponse + public static SpeakerResponse MapSpeakerResponse(this Speaker speaker) + => new SpeakerResponse { Id = speaker.Id, Name = speaker.Name, @@ -37,8 +37,8 @@ public static SpeakerResponse MapSpeakerResponse(this Speaker speaker) => .ToList() }; - public static AttendeeResponse MapAttendeeResponse(this Attendee attendee) => - new AttendeeResponse + public static AttendeeResponse MapAttendeeResponse(this Attendee attendee) + => new AttendeeResponse { Id = attendee.Id, FirstName = attendee.FirstName, diff --git a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Gear.cs b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Gear.cs index a83f76975a6..dc961efa861 100644 --- a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Gear.cs +++ b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/Gear.cs @@ -40,6 +40,7 @@ public Gear() public bool HasSoulPatch { get; set; } [NotMapped] - public bool IsMarcus => Nickname == "Marcus"; + public bool IsMarcus + => Nickname == "Marcus"; } } diff --git a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs index 230d80d0b52..601b4fd64c9 100644 --- a/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs +++ b/test/EFCore.Specification.Tests/TestModels/GearsOfWarModel/GearsOfWarData.cs @@ -107,8 +107,20 @@ public virtual IQueryable Set() public static IReadOnlyList CreateSquads() => new List { - new Squad { Id = 1, Name = "Delta", Banner = new byte[] { 0x00, 0x01 }, Banner5 = new byte[] { 0x04, 0x05, 0x06, 0x07, 0x08 } }, - new Squad { Id = 2, Name = "Kilo", Banner = new byte[] { 0x02, 0x03 }, Banner5 = new byte[] { 0x04, 0x05, 0x06, 0x07, 0x08 } } + new Squad + { + Id = 1, + Name = "Delta", + Banner = new byte[] { 0x00, 0x01 }, + Banner5 = new byte[] { 0x04, 0x05, 0x06, 0x07, 0x08 } + }, + new Squad + { + Id = 2, + Name = "Kilo", + Banner = new byte[] { 0x02, 0x03 }, + Banner5 = new byte[] { 0x04, 0x05, 0x06, 0x07, 0x08 } + } }; public static IReadOnlyList CreateMissions() @@ -324,12 +336,48 @@ public static IReadOnlyList CreateGears() public static IReadOnlyList CreateLocustLeaders() => new List { - new LocustLeader { Name = "General Karn", ThreatLevel = 3, ThreatLevelByte = 3, ThreatLevelNullableByte = 3 }, - new LocustLeader { Name = "General RAAM", ThreatLevel = 4, ThreatLevelByte = 4, ThreatLevelNullableByte = 4 }, - new LocustLeader { Name = "High Priest Skorge", ThreatLevel = 1, ThreatLevelByte = 1, ThreatLevelNullableByte = 1 }, - new LocustCommander { Name = "Queen Myrrah", ThreatLevel = 5, ThreatLevelByte = 5, ThreatLevelNullableByte = 5 }, - new LocustLeader { Name = "The Speaker", ThreatLevel = 3, ThreatLevelByte = 3, ThreatLevelNullableByte = 3 }, - new LocustCommander { Name = "Unknown", ThreatLevel = 0, ThreatLevelByte = 0, ThreatLevelNullableByte = null } + new LocustLeader + { + Name = "General Karn", + ThreatLevel = 3, + ThreatLevelByte = 3, + ThreatLevelNullableByte = 3 + }, + new LocustLeader + { + Name = "General RAAM", + ThreatLevel = 4, + ThreatLevelByte = 4, + ThreatLevelNullableByte = 4 + }, + new LocustLeader + { + Name = "High Priest Skorge", + ThreatLevel = 1, + ThreatLevelByte = 1, + ThreatLevelNullableByte = 1 + }, + new LocustCommander + { + Name = "Queen Myrrah", + ThreatLevel = 5, + ThreatLevelByte = 5, + ThreatLevelNullableByte = 5 + }, + new LocustLeader + { + Name = "The Speaker", + ThreatLevel = 3, + ThreatLevelByte = 3, + ThreatLevelNullableByte = 3 + }, + new LocustCommander + { + Name = "Unknown", + ThreatLevel = 0, + ThreatLevelByte = 0, + ThreatLevelNullableByte = null + } }; public static IReadOnlyList CreateFactions() diff --git a/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs b/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs index 253b891459b..72d538e6777 100644 --- a/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs +++ b/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs @@ -25,22 +25,24 @@ public InheritanceData() WireUp(Animals, Countries); - AnimalQueries = Animals.Select(a => a is Eagle - ? (AnimalQuery)new EagleQuery { - Name = a.Name, - CountryId = a.CountryId, - EagleId = ((Bird)a).EagleId, - IsFlightless = ((Bird)a).IsFlightless, - Group = ((Eagle)a).Group, - } - : new KiwiQuery - { - Name = a.Name, - CountryId = a.CountryId, - EagleId = ((Bird)a).EagleId, - IsFlightless = ((Bird)a).IsFlightless, - FoundOn = ((Kiwi)a).FoundOn, - }).ToList().AsReadOnly(); + AnimalQueries = Animals.Select( + a => a is Eagle + ? (AnimalQuery)new EagleQuery + { + Name = a.Name, + CountryId = a.CountryId, + EagleId = ((Bird)a).EagleId, + IsFlightless = ((Bird)a).IsFlightless, + Group = ((Eagle)a).Group, + } + : new KiwiQuery + { + Name = a.Name, + CountryId = a.CountryId, + EagleId = ((Bird)a).EagleId, + IsFlightless = ((Bird)a).IsFlightless, + FoundOn = ((Kiwi)a).FoundOn, + }).ToList().AsReadOnly(); } public virtual IQueryable Set() @@ -137,30 +139,67 @@ public virtual IQueryable Set() public static IReadOnlyList CreateAnimals() => new List { - new Kiwi { Species = "Apteryx haastii", Name = "Great spotted kiwi", IsFlightless = true, FoundOn = Island.South }, - new Eagle { Species = "Aquila chrysaetos canadensis", Name = "American golden eagle", Group = EagleGroup.Booted }, + new Kiwi + { + Species = "Apteryx haastii", + Name = "Great spotted kiwi", + IsFlightless = true, + FoundOn = Island.South + }, + new Eagle + { + Species = "Aquila chrysaetos canadensis", + Name = "American golden eagle", + Group = EagleGroup.Booted + }, }; public static IReadOnlyList CreateCountries() => new List { - new Country { Id = 1, Name = "New Zealand" }, - new Country { Id = 2, Name = "USA" }, + new Country { Id = 1, Name = "New Zealand" }, new Country { Id = 2, Name = "USA" }, }; public static IReadOnlyList CreateDrinks() => new List { - new Tea { Id = 1, HasMilk = true, CaffeineGrams = 1 }, - new Lilt { Id = 2, SugarGrams = 4, Carbonation = 7 }, - new Coke { Id = 3, SugarGrams = 6, CaffeineGrams = 4, Carbonation = 5 }, + new Tea + { + Id = 1, + HasMilk = true, + CaffeineGrams = 1 + }, + new Lilt + { + Id = 2, + SugarGrams = 4, + Carbonation = 7 + }, + new Coke + { + Id = 3, + SugarGrams = 6, + CaffeineGrams = 4, + Carbonation = 5 + }, }; public static IReadOnlyList CreatePlants() => new List { - new Rose { Genus = PlantGenus.Rose, Species = "Rosa canina", Name = "Dog-rose", HasThorns = true }, - new Daisy { Genus = PlantGenus.Daisy, Species = "Bellis perennis", Name = "Common daisy" }, + new Rose + { + Genus = PlantGenus.Rose, + Species = "Rosa canina", + Name = "Dog-rose", + HasThorns = true + }, + new Daisy + { + Genus = PlantGenus.Daisy, + Species = "Bellis perennis", + Name = "Common daisy" + }, }; public static void WireUp( diff --git a/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/InheritanceRelationshipsData.cs b/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/InheritanceRelationshipsData.cs index ca3a53ae389..d2d12586686 100644 --- a/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/InheritanceRelationshipsData.cs +++ b/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/InheritanceRelationshipsData.cs @@ -138,11 +138,8 @@ public static IReadOnlyList CreateBaseEntitie Id = 1, Name = "Base1", OwnedReferenceOnBase = new OwnedEntity { Name = "OROB1" }, - OwnedCollectionOnBase = new List - { - new OwnedEntity { Id = 1, Name = "OCOB11" }, - new OwnedEntity { Id = 2, Name = "OCOB12" } - }, + OwnedCollectionOnBase = + new List { new OwnedEntity { Id = 1, Name = "OCOB11" }, new OwnedEntity { Id = 2, Name = "OCOB12" } }, BaseCollectionOnBase = new List(), CollectionOnBase = new List(), }, @@ -151,10 +148,7 @@ public static IReadOnlyList CreateBaseEntitie Id = 2, Name = "Base2", OwnedReferenceOnBase = new OwnedEntity { Name = "OROB2" }, - OwnedCollectionOnBase = new List - { - new OwnedEntity { Id = 3, Name = "OCOB21" } - }, + OwnedCollectionOnBase = new List { new OwnedEntity { Id = 3, Name = "OCOB21" } }, BaseCollectionOnBase = new List(), CollectionOnBase = new List(), }, @@ -171,17 +165,11 @@ public static IReadOnlyList CreateBaseEntitie Id = 4, Name = "Derived1(4)", OwnedReferenceOnBase = new OwnedEntity { Name = "OROB4" }, - OwnedCollectionOnBase = new List - { - new OwnedEntity { Id = 4, Name = "OCOB41" }, - new OwnedEntity { Id = 5, Name = "OCOB42" } - }, + OwnedCollectionOnBase = + new List { new OwnedEntity { Id = 4, Name = "OCOB41" }, new OwnedEntity { Id = 5, Name = "OCOB42" } }, OwnedReferenceOnDerived = new OwnedEntity { Name = "OROD4" }, - OwnedCollectionOnDerived = new List - { - new OwnedEntity { Id = 1, Name = "OCOD41" }, - new OwnedEntity { Id = 2, Name = "OCOD42" } - }, + OwnedCollectionOnDerived = + new List { new OwnedEntity { Id = 1, Name = "OCOD41" }, new OwnedEntity { Id = 2, Name = "OCOD42" } }, BaseCollectionOnBase = new List(), BaseCollectionOnDerived = new List(), CollectionOnBase = new List(), @@ -193,15 +181,9 @@ public static IReadOnlyList CreateBaseEntitie Id = 5, Name = "Derived2(5)", OwnedReferenceOnBase = new OwnedEntity { Name = "OROB5" }, - OwnedCollectionOnBase = new List - { - new OwnedEntity { Id = 6, Name = "OCOB51" } - }, + OwnedCollectionOnBase = new List { new OwnedEntity { Id = 6, Name = "OCOB51" } }, OwnedReferenceOnDerived = new OwnedEntity { Name = "OROD5" }, - OwnedCollectionOnDerived = new List - { - new OwnedEntity { Id = 3, Name = "OCOD51" } - }, + OwnedCollectionOnDerived = new List { new OwnedEntity { Id = 3, Name = "OCOD51" } }, BaseCollectionOnBase = new List(), BaseCollectionOnDerived = new List(), CollectionOnBase = new List(), @@ -225,14 +207,54 @@ public static IReadOnlyList CreateBaseEntitie public static IReadOnlyList CreateBaseReferencesOnBase() => new List { - new BaseReferenceOnBase { Id = 1, Name = "BROB1", NestedCollection = new List() }, - new BaseReferenceOnBase { Id = 2, Name = "BROB2", NestedCollection = new List() }, - new BaseReferenceOnBase { Id = 3, Name = "BROB3 (dangling)", NestedCollection = new List() }, - new DerivedReferenceOnBase { Id = 4, Name = "DROB1", NestedCollection = new List() }, - new DerivedReferenceOnBase { Id = 5, Name = "DROB2", NestedCollection = new List() }, - new DerivedReferenceOnBase { Id = 6, Name = "DROB3", NestedCollection = new List() }, - new DerivedReferenceOnBase { Id = 7, Name = "DROB4 (half-dangling)", NestedCollection = new List() }, - new DerivedReferenceOnBase { Id = 8, Name = "DROB5 (dangling)", NestedCollection = new List() }, + new BaseReferenceOnBase + { + Id = 1, + Name = "BROB1", + NestedCollection = new List() + }, + new BaseReferenceOnBase + { + Id = 2, + Name = "BROB2", + NestedCollection = new List() + }, + new BaseReferenceOnBase + { + Id = 3, + Name = "BROB3 (dangling)", + NestedCollection = new List() + }, + new DerivedReferenceOnBase + { + Id = 4, + Name = "DROB1", + NestedCollection = new List() + }, + new DerivedReferenceOnBase + { + Id = 5, + Name = "DROB2", + NestedCollection = new List() + }, + new DerivedReferenceOnBase + { + Id = 6, + Name = "DROB3", + NestedCollection = new List() + }, + new DerivedReferenceOnBase + { + Id = 7, + Name = "DROB4 (half-dangling)", + NestedCollection = new List() + }, + new DerivedReferenceOnBase + { + Id = 8, + Name = "DROB5 (dangling)", + NestedCollection = new List() + }, }; public static IReadOnlyList CreateBaseReferencesOnDerived() @@ -280,19 +302,92 @@ public static IReadOnlyList CreateNestedReferences() public static IReadOnlyList CreateBaseCollectionsOnBase() => new List { - new BaseCollectionOnBase { Id = 1, Name = "BCOB11", NestedCollection = new List() }, - new BaseCollectionOnBase { Id = 2, Name = "BCOB12", NestedCollection = new List() }, - new BaseCollectionOnBase { Id = 3, Name = "BCOB21", NestedCollection = new List() }, - new BaseCollectionOnBase { Id = 4, Name = "BCOB31 (dangling)", NestedCollection = new List() }, - new BaseCollectionOnBase { Id = 5, Name = "BCOB32 (dangling)", NestedCollection = new List() }, - new DerivedCollectionOnBase { Id = 6, Name = "DCOB11", DerivedProperty = 1, NestedCollection = new List() }, - new DerivedCollectionOnBase { Id = 7, Name = "DCOB12", DerivedProperty = 2, NestedCollection = new List() }, - new DerivedCollectionOnBase { Id = 8, Name = "DCOB21", DerivedProperty = 3, NestedCollection = new List() }, - new DerivedCollectionOnBase { Id = 9, Name = "DCOB31", DerivedProperty = 4, NestedCollection = new List() }, - new DerivedCollectionOnBase { Id = 10, Name = "DCOB32", DerivedProperty = 5, NestedCollection = new List() }, - new DerivedCollectionOnBase { Id = 11, Name = "DCOB41", DerivedProperty = 6, NestedCollection = new List() }, - new DerivedCollectionOnBase { Id = 12, Name = "DCOB51 (dangling)", DerivedProperty = 7, NestedCollection = new List() }, - new DerivedCollectionOnBase { Id = 13, Name = "DCOB52 (dangling)", DerivedProperty = 8, NestedCollection = new List() }, + new BaseCollectionOnBase + { + Id = 1, + Name = "BCOB11", + NestedCollection = new List() + }, + new BaseCollectionOnBase + { + Id = 2, + Name = "BCOB12", + NestedCollection = new List() + }, + new BaseCollectionOnBase + { + Id = 3, + Name = "BCOB21", + NestedCollection = new List() + }, + new BaseCollectionOnBase + { + Id = 4, + Name = "BCOB31 (dangling)", + NestedCollection = new List() + }, + new BaseCollectionOnBase + { + Id = 5, + Name = "BCOB32 (dangling)", + NestedCollection = new List() + }, + new DerivedCollectionOnBase + { + Id = 6, + Name = "DCOB11", + DerivedProperty = 1, + NestedCollection = new List() + }, + new DerivedCollectionOnBase + { + Id = 7, + Name = "DCOB12", + DerivedProperty = 2, + NestedCollection = new List() + }, + new DerivedCollectionOnBase + { + Id = 8, + Name = "DCOB21", + DerivedProperty = 3, + NestedCollection = new List() + }, + new DerivedCollectionOnBase + { + Id = 9, + Name = "DCOB31", + DerivedProperty = 4, + NestedCollection = new List() + }, + new DerivedCollectionOnBase + { + Id = 10, + Name = "DCOB32", + DerivedProperty = 5, + NestedCollection = new List() + }, + new DerivedCollectionOnBase + { + Id = 11, + Name = "DCOB41", + DerivedProperty = 6, + NestedCollection = new List() + }, + new DerivedCollectionOnBase + { + Id = 12, + Name = "DCOB51 (dangling)", + DerivedProperty = 7, + NestedCollection = new List() + }, + new DerivedCollectionOnBase + { + Id = 13, + Name = "DCOB52 (dangling)", + DerivedProperty = 8, + NestedCollection = new List() + }, }; public static IReadOnlyList CreateBaseCollectionsOnDerived() @@ -351,15 +446,24 @@ public static IReadOnlyList CreateNestedCollections() public static IReadOnlyList CreatePrincipalEntities() => new List { - new PrincipalEntity { Id = 1, Name = "PE1" }, - new PrincipalEntity { Id = 2, Name = "PE2" }, + new PrincipalEntity { Id = 1, Name = "PE1" }, new PrincipalEntity { Id = 2, Name = "PE2" }, }; public static IReadOnlyList CreateReferencedEntities() => new List { - new ReferencedEntity { Id = 1, Name = "RE1", Principals = new List() }, - new ReferencedEntity { Id = 2, Name = "RE2", Principals = new List() }, + new ReferencedEntity + { + Id = 1, + Name = "RE1", + Principals = new List() + }, + new ReferencedEntity + { + Id = 2, + Name = "RE2", + Principals = new List() + }, }; public static void WireUp( @@ -552,25 +656,27 @@ public static void WireUp( baseReferencesOnDerived[0].BaseParent = (DerivedInheritanceRelationshipEntity)baseEntities[3]; baseReferencesOnDerived[0].BaseParentId = baseEntities[3].Id; - ((DerivedInheritanceRelationshipEntity)baseEntities[3]).DerivedReferenceOnDerived = (DerivedReferenceOnDerived)baseReferencesOnDerived[3]; + ((DerivedInheritanceRelationshipEntity)baseEntities[3]).DerivedReferenceOnDerived = + (DerivedReferenceOnDerived)baseReferencesOnDerived[3]; ((DerivedInheritanceRelationshipEntity)baseEntities[3]).ReferenceOnDerived = referencesOnDerived[0]; referencesOnDerived[0].Parent = (DerivedInheritanceRelationshipEntity)baseEntities[3]; referencesOnDerived[0].ParentId = baseEntities[3].Id; - ((DerivedInheritanceRelationshipEntity)baseEntities[3]).BaseCollectionOnDerived = new List { baseCollectionsOnDerived[0] }; + ((DerivedInheritanceRelationshipEntity)baseEntities[3]).BaseCollectionOnDerived = + new List { baseCollectionsOnDerived[0] }; baseCollectionsOnDerived[0].BaseParent = (DerivedInheritanceRelationshipEntity)baseEntities[3]; baseCollectionsOnDerived[0].ParentId = baseEntities[3].Id; - ((DerivedInheritanceRelationshipEntity)baseEntities[3]).CollectionOnDerived = new List { collectionsOnDerived[0] }; + ((DerivedInheritanceRelationshipEntity)baseEntities[3]).CollectionOnDerived = + new List { collectionsOnDerived[0] }; collectionsOnDerived[0].Parent = (DerivedInheritanceRelationshipEntity)baseEntities[3]; collectionsOnDerived[0].ParentId = baseEntities[3].Id; ((DerivedInheritanceRelationshipEntity)baseEntities[3]).DerivedCollectionOnDerived = new List - { - (DerivedCollectionOnDerived)baseCollectionsOnDerived[3], - (DerivedCollectionOnDerived)baseCollectionsOnDerived[4] - }; + { + (DerivedCollectionOnDerived)baseCollectionsOnDerived[3], (DerivedCollectionOnDerived)baseCollectionsOnDerived[4] + }; } } } diff --git a/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/NestedCollectionBase.cs b/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/NestedCollectionBase.cs index 1ac572a82d9..34928057368 100644 --- a/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/NestedCollectionBase.cs +++ b/test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/NestedCollectionBase.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.ComponentModel.DataAnnotations.Schema; - namespace Microsoft.EntityFrameworkCore.TestModels.InheritanceRelationshipsModel { public class NestedCollectionBase diff --git a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityOne.cs b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityOne.cs index 83e17c5f437..b31aef1ac83 100644 --- a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityOne.cs +++ b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityOne.cs @@ -28,7 +28,7 @@ public class EntityOne public virtual ICollection ThreeSkipPayloadFullShared { get; } = new ObservableCollection(); // #21684 public virtual ICollection> JoinThreePayloadFullShared { get; } - = new ObservableCollection>(); // #21684 + = new ObservableCollection>(); // #21684 public virtual ICollection SelfSkipPayloadLeft { get; } = new ObservableCollection(); // #21684 diff --git a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityThree.cs b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityThree.cs index 1cd8c56d7d3..daeae22bc01 100644 --- a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityThree.cs +++ b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/EntityThree.cs @@ -29,7 +29,7 @@ public class EntityThree public virtual ICollection OneSkipPayloadFullShared { get; } = new ObservableCollection(); // #21684 public virtual ICollection> JoinOnePayloadFullShared { get; } - = new ObservableCollection>(); // #21684 + = new ObservableCollection>(); // #21684 public virtual ICollection CompositeKeySkipFull { get; } = new ObservableCollection(); // #21684 diff --git a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ImplicitManyToManyA.cs b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ImplicitManyToManyA.cs index 4db1084d4aa..bb4ed50d9d6 100644 --- a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ImplicitManyToManyA.cs +++ b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ImplicitManyToManyA.cs @@ -11,6 +11,7 @@ public class ImplicitManyToManyA { [DatabaseGenerated(DatabaseGeneratedOption.None)] public virtual int Id { get; set; } + public virtual string Name { get; set; } public virtual ICollection Bs { get; } = new ObservableCollection(); diff --git a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ImplicitManyToManyB.cs b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ImplicitManyToManyB.cs index 458c6ff5641..7d412f86ab4 100644 --- a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ImplicitManyToManyB.cs +++ b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ImplicitManyToManyB.cs @@ -11,6 +11,7 @@ public class ImplicitManyToManyB { [DatabaseGenerated(DatabaseGeneratedOption.None)] public virtual int Id { get; set; } + public virtual string Name { get; set; } public virtual ICollection As { get; } = new ObservableCollection(); diff --git a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ManyToManyContext.cs b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ManyToManyContext.cs index 83986e07d6d..240e8e56c05 100644 --- a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ManyToManyContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ManyToManyContext.cs @@ -23,8 +23,8 @@ public ManyToManyContext(DbContextOptions options) public DbSet ImplicitManyToManyAs { get; set; } public DbSet ImplicitManyToManyBs { get; set; } - public static void Seed(ManyToManyContext context) => ManyToManyData.Seed(context); - + public static void Seed(ManyToManyContext context) + => ManyToManyData.Seed(context); } public static class ManyToManyContextExtensions diff --git a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ManyToManyData.cs b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ManyToManyData.cs index 0417c4ac8d3..910bba75456 100644 --- a/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ManyToManyData.cs +++ b/test/EFCore.Specification.Tests/TestModels/ManyToManyModel/ManyToManyData.cs @@ -137,9 +137,10 @@ public ManyToManyData() foreach (var joinEntity in _joinThreeToCompositeKeyFulls) { - var compositeKey = _compositeKeys.First(o => o.Key1 == joinEntity.CompositeId1 - && o.Key2 == joinEntity.CompositeId2 - && o.Key3 == joinEntity.CompositeId3); + var compositeKey = _compositeKeys.First( + o => o.Key1 == joinEntity.CompositeId1 + && o.Key2 == joinEntity.CompositeId2 + && o.Key3 == joinEntity.CompositeId3); var three = _threes.First(t => t.Id == joinEntity.ThreeId); compositeKey.ThreeSkipFull.Add(three); compositeKey.JoinThreeFull.Add(joinEntity); @@ -151,9 +152,10 @@ public ManyToManyData() foreach (var joinEntity in _joinCompositeKeyToLeaves) { - var compositeKey = _compositeKeys.First(o => o.Key1 == joinEntity.CompositeId1 - && o.Key2 == joinEntity.CompositeId2 - && o.Key3 == joinEntity.CompositeId3); + var compositeKey = _compositeKeys.First( + o => o.Key1 == joinEntity.CompositeId1 + && o.Key2 == joinEntity.CompositeId2 + && o.Key3 == joinEntity.CompositeId3); var leaf = _roots.OfType().First(t => t.Id == joinEntity.LeafId); compositeKey.LeafSkipFull.Add(leaf); compositeKey.JoinLeafFull.Add(joinEntity); @@ -192,9 +194,10 @@ public ManyToManyData() foreach (var joinEntity in _joinTwoToCompositeKeyShareds) { - var compositeKey = _compositeKeys.First(o => o.Key1 == (int)joinEntity["CompositeId1"] - && o.Key2 == (string)joinEntity["CompositeId2"] - && o.Key3 == (DateTime)joinEntity["CompositeId3"]); + var compositeKey = _compositeKeys.First( + o => o.Key1 == (int)joinEntity["CompositeId1"] + && o.Key2 == (string)joinEntity["CompositeId2"] + && o.Key3 == (DateTime)joinEntity["CompositeId3"]); var two = _twos.First(t => t.Id == (int)joinEntity["TwoId"]); compositeKey.TwoSkipShared.Add(two); two.CompositeKeySkipShared.Add(compositeKey); @@ -210,16 +213,18 @@ public ManyToManyData() foreach (var joinEntity in _joinCompositeKeyToRootShareds) { - var compositeKey = _compositeKeys.First(o => o.Key1 == (int)joinEntity["CompositeId1"] - && o.Key2 == (string)joinEntity["CompositeId2"] - && o.Key3 == (DateTime)joinEntity["CompositeId3"]); + var compositeKey = _compositeKeys.First( + o => o.Key1 == (int)joinEntity["CompositeId1"] + && o.Key2 == (string)joinEntity["CompositeId2"] + && o.Key3 == (DateTime)joinEntity["CompositeId3"]); var root = _roots.First(t => t.Id == (int)joinEntity["RootId"]); compositeKey.RootSkipShared.Add(root); root.CompositeKeySkipShared.Add(compositeKey); } } - public IQueryable Set() where TEntity : class + public IQueryable Set() + where TEntity : class { if (typeof(TEntity) == typeof(EntityOne)) { @@ -276,7 +281,8 @@ public static void Seed(ManyToManyContext context) context.Set().AddRange(CreateJoinTwoToThrees(context)); context.Set>("EntityOneEntityTwo").AddRange(CreateEntityOneEntityTwos(context)); - context.Set>("JoinOneToThreePayloadFullShared").AddRange(CreateJoinOneToThreePayloadFullShareds(context)); + context.Set>("JoinOneToThreePayloadFullShared") + .AddRange(CreateJoinOneToThreePayloadFullShareds(context)); context.Set>("JoinTwoSelfShared").AddRange(CreateJoinTwoSelfShareds(context)); context.Set>("JoinTwoToCompositeKeyShared").AddRange(CreateJoinTwoToCompositeKeyShareds(context)); context.Set>("EntityRootEntityThree").AddRange(CreateEntityRootEntityThrees(context)); @@ -344,7 +350,11 @@ private static EntityTwo[] CreateTwos(ManyToManyContext context) }; private static EntityTwo CreateEntityTwo( - ManyToManyContext context, int id, string name, int? referenceInverseId, int? collectionInverseId) + ManyToManyContext context, + int id, + string name, + int? referenceInverseId, + int? collectionInverseId) => CreateInstance( context?.EntityTwos, e => { @@ -366,22 +376,26 @@ private static EntityThree[] CreateThrees(ManyToManyContext context) CreateEntityThree(context, 7, "EntityThree 7", 6, 13), CreateEntityThree(context, 8, "EntityThree 8", null, 13), CreateEntityThree(context, 9, "EntityThree 9", 8, 11), - CreateEntityThree(context, 10,"EntityThree 10", null, 11), - CreateEntityThree(context, 11,"EntityThree 11", 19, 9), - CreateEntityThree(context, 12,"EntityThree 12", null, 9), - CreateEntityThree(context, 13,"EntityThree 13", 12, 7), - CreateEntityThree(context, 14,"EntityThree 14", null, 7), - CreateEntityThree(context, 15,"EntityThree 15", 14, 5), - CreateEntityThree(context, 16,"EntityThree 16", null, 5), - CreateEntityThree(context, 17,"EntityThree 17", 16, 3), - CreateEntityThree(context, 18,"EntityThree 18", null, 3), - CreateEntityThree(context, 19,"EntityThree 19", 18, 1), - CreateEntityThree(context, 20,"EntityThree 20", null, 1), + CreateEntityThree(context, 10, "EntityThree 10", null, 11), + CreateEntityThree(context, 11, "EntityThree 11", 19, 9), + CreateEntityThree(context, 12, "EntityThree 12", null, 9), + CreateEntityThree(context, 13, "EntityThree 13", 12, 7), + CreateEntityThree(context, 14, "EntityThree 14", null, 7), + CreateEntityThree(context, 15, "EntityThree 15", 14, 5), + CreateEntityThree(context, 16, "EntityThree 16", null, 5), + CreateEntityThree(context, 17, "EntityThree 17", 16, 3), + CreateEntityThree(context, 18, "EntityThree 18", null, 3), + CreateEntityThree(context, 19, "EntityThree 19", 18, 1), + CreateEntityThree(context, 20, "EntityThree 20", null, 1), }; private static EntityThree CreateEntityThree( - ManyToManyContext context, int id, string name, int? referenceInverseId, int? collectionInverseId) - => CreateInstance( + ManyToManyContext context, + int id, + string name, + int? referenceInverseId, + int? collectionInverseId) + => CreateInstance( context?.EntityThrees, e => { e.Id = id; @@ -393,31 +407,35 @@ private static EntityThree CreateEntityThree( private static EntityCompositeKey[] CreateCompositeKeys(ManyToManyContext context) => new[] { - CreateEntityCompositeKey(context, 1, "1_1", new DateTime(2001, 1, 1),"Composite 1"), - CreateEntityCompositeKey(context, 1, "1_2", new DateTime(2001, 2, 1),"Composite 2"), - CreateEntityCompositeKey(context, 3, "3_1", new DateTime(2003, 1, 1),"Composite 3"), - CreateEntityCompositeKey(context, 3, "3_2", new DateTime(2003, 2, 1),"Composite 4"), - CreateEntityCompositeKey(context, 3, "3_3", new DateTime(2003, 3, 1),"Composite 5"), - CreateEntityCompositeKey(context, 6, "6_1", new DateTime(2006, 1, 1),"Composite 6"), - CreateEntityCompositeKey(context, 7, "7_1", new DateTime(2007, 1, 1),"Composite 7"), - CreateEntityCompositeKey(context, 7, "7_2", new DateTime(2007, 2, 1),"Composite 8"), - CreateEntityCompositeKey(context, 8, "8_1", new DateTime(2008, 1, 1),"Composite 9"), - CreateEntityCompositeKey(context, 8, "8_2", new DateTime(2008, 2, 1),"Composite 10"), - CreateEntityCompositeKey(context, 8, "8_3", new DateTime(2008, 3, 1),"Composite 11"), - CreateEntityCompositeKey(context, 8, "8_4", new DateTime(2008, 4, 1),"Composite 12"), - CreateEntityCompositeKey(context, 8, "8_5", new DateTime(2008, 5, 1),"Composite 13"), - CreateEntityCompositeKey(context, 9, "9_1", new DateTime(2009, 1, 1),"Composite 14"), - CreateEntityCompositeKey(context, 9, "9_2", new DateTime(2009, 2, 1),"Composite 15"), - CreateEntityCompositeKey(context, 9, "9_3", new DateTime(2009, 3, 1),"Composite 16"), - CreateEntityCompositeKey(context, 9, "9_4", new DateTime(2009, 4, 1),"Composite 17"), - CreateEntityCompositeKey(context, 9, "9_5", new DateTime(2009, 5, 1),"Composite 18"), - CreateEntityCompositeKey(context, 9, "9_6", new DateTime(2009, 6, 1),"Composite 19"), - CreateEntityCompositeKey(context, 9, "9_7", new DateTime(2009, 7, 1),"Composite 20") + CreateEntityCompositeKey(context, 1, "1_1", new DateTime(2001, 1, 1), "Composite 1"), + CreateEntityCompositeKey(context, 1, "1_2", new DateTime(2001, 2, 1), "Composite 2"), + CreateEntityCompositeKey(context, 3, "3_1", new DateTime(2003, 1, 1), "Composite 3"), + CreateEntityCompositeKey(context, 3, "3_2", new DateTime(2003, 2, 1), "Composite 4"), + CreateEntityCompositeKey(context, 3, "3_3", new DateTime(2003, 3, 1), "Composite 5"), + CreateEntityCompositeKey(context, 6, "6_1", new DateTime(2006, 1, 1), "Composite 6"), + CreateEntityCompositeKey(context, 7, "7_1", new DateTime(2007, 1, 1), "Composite 7"), + CreateEntityCompositeKey(context, 7, "7_2", new DateTime(2007, 2, 1), "Composite 8"), + CreateEntityCompositeKey(context, 8, "8_1", new DateTime(2008, 1, 1), "Composite 9"), + CreateEntityCompositeKey(context, 8, "8_2", new DateTime(2008, 2, 1), "Composite 10"), + CreateEntityCompositeKey(context, 8, "8_3", new DateTime(2008, 3, 1), "Composite 11"), + CreateEntityCompositeKey(context, 8, "8_4", new DateTime(2008, 4, 1), "Composite 12"), + CreateEntityCompositeKey(context, 8, "8_5", new DateTime(2008, 5, 1), "Composite 13"), + CreateEntityCompositeKey(context, 9, "9_1", new DateTime(2009, 1, 1), "Composite 14"), + CreateEntityCompositeKey(context, 9, "9_2", new DateTime(2009, 2, 1), "Composite 15"), + CreateEntityCompositeKey(context, 9, "9_3", new DateTime(2009, 3, 1), "Composite 16"), + CreateEntityCompositeKey(context, 9, "9_4", new DateTime(2009, 4, 1), "Composite 17"), + CreateEntityCompositeKey(context, 9, "9_5", new DateTime(2009, 5, 1), "Composite 18"), + CreateEntityCompositeKey(context, 9, "9_6", new DateTime(2009, 6, 1), "Composite 19"), + CreateEntityCompositeKey(context, 9, "9_7", new DateTime(2009, 7, 1), "Composite 20") }; private static EntityCompositeKey CreateEntityCompositeKey( - ManyToManyContext context, int key1, string key2, DateTime key3, string name) - => CreateInstance( + ManyToManyContext context, + int key1, + string key2, + DateTime key3, + string name) + => CreateInstance( context?.EntityCompositeKeys, e => { e.Key1 = key1; @@ -429,15 +447,15 @@ private static EntityCompositeKey CreateEntityCompositeKey( private static EntityRoot[] CreateRoots(ManyToManyContext context) => new[] { - CreateEntityRoot(context, 1, "Root 1"), - CreateEntityRoot(context, 2, "Root 2"), - CreateEntityRoot(context, 3, "Root 3"), - CreateEntityRoot(context, 4, "Root 4"), - CreateEntityRoot(context, 5, "Root 5"), - CreateEntityRoot(context, 6, "Root 6"), - CreateEntityRoot(context, 7, "Root 7"), - CreateEntityRoot(context, 8, "Root 8"), - CreateEntityRoot(context, 9, "Root 9"), + CreateEntityRoot(context, 1, "Root 1"), + CreateEntityRoot(context, 2, "Root 2"), + CreateEntityRoot(context, 3, "Root 3"), + CreateEntityRoot(context, 4, "Root 4"), + CreateEntityRoot(context, 5, "Root 5"), + CreateEntityRoot(context, 6, "Root 6"), + CreateEntityRoot(context, 7, "Root 7"), + CreateEntityRoot(context, 8, "Root 8"), + CreateEntityRoot(context, 9, "Root 9"), CreateEntityRoot(context, 10, "Root 10"), CreateEntityBranch(context, 11, "Branch 1", 7), CreateEntityBranch(context, 12, "Branch 2", 77), @@ -452,8 +470,10 @@ private static EntityRoot[] CreateRoots(ManyToManyContext context) }; private static EntityRoot CreateEntityRoot( - ManyToManyContext context, int id, string name) - => CreateInstance( + ManyToManyContext context, + int id, + string name) + => CreateInstance( context?.EntityRoots, e => { e.Id = id; @@ -461,7 +481,10 @@ private static EntityRoot CreateEntityRoot( }); private static EntityBranch CreateEntityBranch( - ManyToManyContext context, int id, string name, long number) + ManyToManyContext context, + int id, + string name, + long number) => CreateInstance( context?.Set(), e => { @@ -471,7 +494,11 @@ private static EntityBranch CreateEntityBranch( }); private static EntityLeaf CreateEntityLeaf( - ManyToManyContext context, int id, string name, long number, bool? isGreen) + ManyToManyContext context, + int id, + string name, + long number, + bool? isGreen) => CreateInstance( context?.Set(), e => { @@ -518,7 +545,11 @@ private static JoinCompositeKeyToLeaf[] CreateJoinCompositeKeyToLeaves(ManyToMan }; private static JoinCompositeKeyToLeaf CreateJoinCompositeKeyToLeaf( - ManyToManyContext context, int leafId, int compositeId1, string compositeId2, DateTime compositeId3) + ManyToManyContext context, + int leafId, + int compositeId1, + string compositeId2, + DateTime compositeId3) => CreateInstance( context?.Set(), e => { @@ -563,7 +594,10 @@ private static JoinOneSelfPayload[] CreateJoinOneSelfPayloads(ManyToManyContext }; private static JoinOneSelfPayload CreateJoinOneSelfPayload( - ManyToManyContext context, int leftId, int rightId, DateTime payload) + ManyToManyContext context, + int leftId, + int rightId, + DateTime payload) => CreateInstance( context?.Set(), e => { @@ -625,7 +659,9 @@ private static JoinOneToBranch[] CreateJoinOneToBranches(ManyToManyContext conte }; private static JoinOneToBranch CreateJoinOneToBranch( - ManyToManyContext context, int oneId, int branchId) + ManyToManyContext context, + int oneId, + int branchId) => CreateInstance( context?.Set(), e => { @@ -754,7 +790,10 @@ private static JoinOneToThreePayloadFull[] CreateJoinOneToThreePayloadFulls(Many }; private static JoinOneToThreePayloadFull CreateJoinOneToThreePayloadFull( - ManyToManyContext context, int oneId, int threeId, string payload) + ManyToManyContext context, + int oneId, + int threeId, + string payload) => CreateInstance( context?.Set(), e => { @@ -881,7 +920,9 @@ private static JoinOneToTwo[] CreateJoinOneToTwos(ManyToManyContext context) }; private static JoinOneToTwo CreateJoinOneToTwo( - ManyToManyContext context, int oneId, int twoId) + ManyToManyContext context, + int oneId, + int twoId) => CreateInstance( context?.Set(), e => { @@ -940,7 +981,11 @@ private static JoinThreeToCompositeKeyFull[] CreateJoinThreeToCompositeKeyFulls( }; private static JoinThreeToCompositeKeyFull CreateJoinThreeToCompositeKeyFull( - ManyToManyContext context, int threeId, int compositeId1, string compositeId2, DateTime compositeId3) + ManyToManyContext context, + int threeId, + int compositeId1, + string compositeId2, + DateTime compositeId3) => CreateInstance( context?.Set(), e => { @@ -1008,7 +1053,9 @@ private static JoinTwoToThree[] CreateJoinTwoToThrees(ManyToManyContext context) }; private static JoinTwoToThree CreateJoinTwoToThree( - ManyToManyContext context, int twoId, int threeId) + ManyToManyContext context, + int twoId, + int threeId) => CreateInstance( context?.Set(), e => { @@ -1019,26 +1066,26 @@ private static JoinTwoToThree CreateJoinTwoToThree( private static Dictionary[] CreateEntityOneEntityTwos(ManyToManyContext context) => new[] { - CreateEntityOneEntityTwo(context, 1, 3), - CreateEntityOneEntityTwo(context, 1, 16), - CreateEntityOneEntityTwo(context, 2, 3), - CreateEntityOneEntityTwo(context, 2, 10), - CreateEntityOneEntityTwo(context, 2, 18), - CreateEntityOneEntityTwo(context, 3, 10), - CreateEntityOneEntityTwo(context, 3, 11), - CreateEntityOneEntityTwo(context, 3, 16), - CreateEntityOneEntityTwo(context, 5, 2), - CreateEntityOneEntityTwo(context, 5, 5), - CreateEntityOneEntityTwo(context, 5, 7), - CreateEntityOneEntityTwo(context, 5, 9), - CreateEntityOneEntityTwo(context, 5, 14), - CreateEntityOneEntityTwo(context, 6, 12), - CreateEntityOneEntityTwo(context, 7, 3), - CreateEntityOneEntityTwo(context, 7, 16), - CreateEntityOneEntityTwo(context, 7, 17), - CreateEntityOneEntityTwo(context, 8, 19), - CreateEntityOneEntityTwo(context, 9, 9), - CreateEntityOneEntityTwo(context, 9, 11), + CreateEntityOneEntityTwo(context, 1, 3), + CreateEntityOneEntityTwo(context, 1, 16), + CreateEntityOneEntityTwo(context, 2, 3), + CreateEntityOneEntityTwo(context, 2, 10), + CreateEntityOneEntityTwo(context, 2, 18), + CreateEntityOneEntityTwo(context, 3, 10), + CreateEntityOneEntityTwo(context, 3, 11), + CreateEntityOneEntityTwo(context, 3, 16), + CreateEntityOneEntityTwo(context, 5, 2), + CreateEntityOneEntityTwo(context, 5, 5), + CreateEntityOneEntityTwo(context, 5, 7), + CreateEntityOneEntityTwo(context, 5, 9), + CreateEntityOneEntityTwo(context, 5, 14), + CreateEntityOneEntityTwo(context, 6, 12), + CreateEntityOneEntityTwo(context, 7, 3), + CreateEntityOneEntityTwo(context, 7, 16), + CreateEntityOneEntityTwo(context, 7, 17), + CreateEntityOneEntityTwo(context, 8, 19), + CreateEntityOneEntityTwo(context, 9, 9), + CreateEntityOneEntityTwo(context, 9, 11), CreateEntityOneEntityTwo(context, 10, 6), CreateEntityOneEntityTwo(context, 10, 17), CreateEntityOneEntityTwo(context, 10, 20), @@ -1062,12 +1109,14 @@ private static Dictionary[] CreateEntityOneEntityTwos(ManyToMany CreateEntityOneEntityTwo(context, 18, 4), CreateEntityOneEntityTwo(context, 18, 13), CreateEntityOneEntityTwo(context, 18, 14), - CreateEntityOneEntityTwo(context, 19, 4 ), - CreateEntityOneEntityTwo(context, 19, 14 ) + CreateEntityOneEntityTwo(context, 19, 4), + CreateEntityOneEntityTwo(context, 19, 14) }; private static Dictionary CreateEntityOneEntityTwo( - ManyToManyContext context, int oneId, int twoId) + ManyToManyContext context, + int oneId, + int twoId) => CreateInstance( context?.Set>("EntityOneEntityTwo"), e => { @@ -1121,7 +1170,10 @@ private static Dictionary[] CreateJoinOneToThreePayloadFullShare }; private static Dictionary CreateJoinOneToThreePayloadFullShared( - ManyToManyContext context, int oneId, int threeId, string payload) + ManyToManyContext context, + int oneId, + int threeId, + string payload) => CreateInstance( context?.Set>("JoinOneToThreePayloadFullShared"), e => { @@ -1170,7 +1222,9 @@ private static Dictionary[] CreateJoinTwoSelfShareds(ManyToManyC }; private static Dictionary CreateJoinTwoSelfShared( - ManyToManyContext context, int leftId, int rightId) + ManyToManyContext context, + int leftId, + int rightId) => CreateInstance( context?.Set>("JoinTwoSelfShared"), e => { @@ -1220,7 +1274,11 @@ private static Dictionary[] CreateJoinTwoToCompositeKeyShareds(M }; private static Dictionary CreateJoinTwoToCompositeKeyShared( - ManyToManyContext context, int twoId, int compositeId1, string compositeId2, DateTime compositeId3) + ManyToManyContext context, + int twoId, + int compositeId1, + string compositeId2, + DateTime compositeId3) => CreateInstance( context?.Set>("JoinTwoToCompositeKeyShared"), e => { @@ -1233,23 +1291,23 @@ private static Dictionary CreateJoinTwoToCompositeKeyShared( private static Dictionary[] CreateEntityRootEntityThrees(ManyToManyContext context) => new[] { - CreateEntityRootEntityThree(context, 1, 7), - CreateEntityRootEntityThree(context, 1, 8), - CreateEntityRootEntityThree(context, 1, 15), - CreateEntityRootEntityThree(context, 2, 4), - CreateEntityRootEntityThree(context, 2, 16), - CreateEntityRootEntityThree(context, 3, 12), - CreateEntityRootEntityThree(context, 3, 14), - CreateEntityRootEntityThree(context, 3, 24), - CreateEntityRootEntityThree(context, 5, 14), - CreateEntityRootEntityThree(context, 5, 15), - CreateEntityRootEntityThree(context, 5, 16), - CreateEntityRootEntityThree(context, 6, 21), - CreateEntityRootEntityThree(context, 7, 1), - CreateEntityRootEntityThree(context, 7, 6), - CreateEntityRootEntityThree(context, 7, 13), - CreateEntityRootEntityThree(context, 7, 24), - CreateEntityRootEntityThree(context, 8, 10), + CreateEntityRootEntityThree(context, 1, 7), + CreateEntityRootEntityThree(context, 1, 8), + CreateEntityRootEntityThree(context, 1, 15), + CreateEntityRootEntityThree(context, 2, 4), + CreateEntityRootEntityThree(context, 2, 16), + CreateEntityRootEntityThree(context, 3, 12), + CreateEntityRootEntityThree(context, 3, 14), + CreateEntityRootEntityThree(context, 3, 24), + CreateEntityRootEntityThree(context, 5, 14), + CreateEntityRootEntityThree(context, 5, 15), + CreateEntityRootEntityThree(context, 5, 16), + CreateEntityRootEntityThree(context, 6, 21), + CreateEntityRootEntityThree(context, 7, 1), + CreateEntityRootEntityThree(context, 7, 6), + CreateEntityRootEntityThree(context, 7, 13), + CreateEntityRootEntityThree(context, 7, 24), + CreateEntityRootEntityThree(context, 8, 10), CreateEntityRootEntityThree(context, 10, 3), CreateEntityRootEntityThree(context, 10, 8), CreateEntityRootEntityThree(context, 13, 5), @@ -1265,7 +1323,9 @@ private static Dictionary[] CreateEntityRootEntityThrees(ManyToM }; private static Dictionary CreateEntityRootEntityThree( - ManyToManyContext context, int threeId, int rootId) + ManyToManyContext context, + int threeId, + int rootId) => CreateInstance( context?.Set>("EntityRootEntityThree"), e => { @@ -1318,7 +1378,11 @@ private static Dictionary[] CreateJoinCompositeKeyToRootShareds( }; private static Dictionary CreateJoinCompositeKeyToRootShared( - ManyToManyContext context, int rootId, int compositeId1, string compositeId2, DateTime compositeId3) + ManyToManyContext context, + int rootId, + int compositeId1, + string compositeId2, + DateTime compositeId3) => CreateInstance( context?.Set>("JoinCompositeKeyToRootShared"), e => { diff --git a/test/EFCore.Specification.Tests/TestModels/MonsterContext`.cs b/test/EFCore.Specification.Tests/TestModels/MonsterContext`.cs index 1fa87714845..562e624d23b 100644 --- a/test/EFCore.Specification.Tests/TestModels/MonsterContext`.cs +++ b/test/EFCore.Specification.Tests/TestModels/MonsterContext`.cs @@ -59,67 +59,98 @@ public MonsterContext(DbContextOptions options) { } - public override IQueryable Customers => Set(); + public override IQueryable Customers + => Set(); - public override IQueryable Barcodes => Set(); + public override IQueryable Barcodes + => Set(); - public override IQueryable IncorrectScans => Set(); + public override IQueryable IncorrectScans + => Set(); - public override IQueryable BarcodeDetails => Set(); + public override IQueryable BarcodeDetails + => Set(); - public override IQueryable Complaints => Set(); + public override IQueryable Complaints + => Set(); - public override IQueryable Resolutions => Set(); + public override IQueryable Resolutions + => Set(); - public override IQueryable Logins => Set(); + public override IQueryable Logins + => Set(); - public override IQueryable SuspiciousActivities => Set(); + public override IQueryable SuspiciousActivities + => Set(); - public override IQueryable SmartCards => Set(); + public override IQueryable SmartCards + => Set(); - public override IQueryable RsaTokens => Set(); + public override IQueryable RsaTokens + => Set(); - public override IQueryable PasswordResets => Set(); + public override IQueryable PasswordResets + => Set(); - public override IQueryable PageViews => Set(); + public override IQueryable PageViews + => Set(); - public override IQueryable LastLogins => Set(); + public override IQueryable LastLogins + => Set(); - public override IQueryable Messages => Set(); + public override IQueryable Messages + => Set(); - public override IQueryable Orders => Set(); + public override IQueryable Orders + => Set(); - public override IQueryable OrderNotes => Set(); + public override IQueryable OrderNotes + => Set(); - public override IQueryable OrderQualityChecks => Set(); + public override IQueryable OrderQualityChecks + => Set(); - public override IQueryable OrderLines => Set(); + public override IQueryable OrderLines + => Set(); - public override IQueryable Products => Set(); + public override IQueryable Products + => Set(); - public override IQueryable ProductDetails => Set(); + public override IQueryable ProductDetails + => Set(); - public override IQueryable ProductReviews => Set(); + public override IQueryable ProductReviews + => Set(); - public override IQueryable ProductPhotos => Set(); + public override IQueryable ProductPhotos + => Set(); - public override IQueryable ProductWebFeatures => Set(); + public override IQueryable ProductWebFeatures + => Set(); - public override IQueryable Suppliers => Set(); + public override IQueryable Suppliers + => Set(); - public override IQueryable SupplierLogos => Set(); + public override IQueryable SupplierLogos + => Set(); - public override IQueryable SupplierInformation => Set(); + public override IQueryable SupplierInformation + => Set(); - public override IQueryable CustomerInformation => Set(); + public override IQueryable CustomerInformation + => Set(); - public override IQueryable Computers => Set(); + public override IQueryable Computers + => Set(); - public override IQueryable ComputerDetails => Set(); + public override IQueryable ComputerDetails + => Set(); - public override IQueryable Drivers => Set(); + public override IQueryable Drivers + => Set(); - public override IQueryable Licenses => Set(); + public override IQueryable Licenses + => Set(); protected override void OnModelCreating(ModelBuilder modelBuilder) { diff --git a/test/EFCore.Specification.Tests/TestModels/Northwind/Customer.cs b/test/EFCore.Specification.Tests/TestModels/Northwind/Customer.cs index 01fa8b60971..adea75577f8 100644 --- a/test/EFCore.Specification.Tests/TestModels/Northwind/Customer.cs +++ b/test/EFCore.Specification.Tests/TestModels/Northwind/Customer.cs @@ -42,9 +42,11 @@ public Customer(DbContext context, ILazyLoader lazyLoader, string customerID) public NorthwindContext Context { get; set; } [NotMapped] - public bool IsLondon => City == "London"; + public bool IsLondon + => City == "London"; - protected bool Equals(Customer other) => string.Equals(CustomerID, other.CustomerID); + protected bool Equals(Customer other) + => string.Equals(CustomerID, other.CustomerID); public override bool Equals(object obj) { @@ -59,15 +61,19 @@ public override bool Equals(object obj) && Equals((Customer)obj); } - public static bool operator ==(Customer left, Customer right) => Equals(left, right); + public static bool operator ==(Customer left, Customer right) + => Equals(left, right); - public static bool operator !=(Customer left, Customer right) => !Equals(left, right); + public static bool operator !=(Customer left, Customer right) + => !Equals(left, right); - public int CompareTo(Customer other) => - other == null ? 1 : CustomerID.CompareTo(other.CustomerID); + public int CompareTo(Customer other) + => other == null ? 1 : CustomerID.CompareTo(other.CustomerID); - public override int GetHashCode() => CustomerID.GetHashCode(); + public override int GetHashCode() + => CustomerID.GetHashCode(); - public override string ToString() => "Customer " + CustomerID; + public override string ToString() + => "Customer " + CustomerID; } } diff --git a/test/EFCore.Specification.Tests/TestModels/Northwind/CustomerQuery.cs b/test/EFCore.Specification.Tests/TestModels/Northwind/CustomerQuery.cs index 7578016b140..3937a7fe528 100644 --- a/test/EFCore.Specification.Tests/TestModels/Northwind/CustomerQuery.cs +++ b/test/EFCore.Specification.Tests/TestModels/Northwind/CustomerQuery.cs @@ -14,7 +14,8 @@ public class CustomerQuery public string City { get; set; } [NotMapped] - public bool IsLondon => City == "London"; + public bool IsLondon + => City == "London"; protected bool Equals(CustomerQuery other) => string.Equals(CompanyName, other.CompanyName); diff --git a/test/EFCore.Specification.Tests/TestModels/Northwind/Employee.cs b/test/EFCore.Specification.Tests/TestModels/Northwind/Employee.cs index 09104f26aa9..93d750c1f83 100644 --- a/test/EFCore.Specification.Tests/TestModels/Northwind/Employee.cs +++ b/test/EFCore.Specification.Tests/TestModels/Northwind/Employee.cs @@ -35,7 +35,8 @@ public uint EmployeeID public Employee Manager { get; set; } - protected bool Equals(Employee other) => EmployeeID == other.EmployeeID; + protected bool Equals(Employee other) + => EmployeeID == other.EmployeeID; public override bool Equals(object obj) { @@ -50,8 +51,10 @@ public override bool Equals(object obj) && Equals((Employee)obj); } - public override int GetHashCode() => EmployeeID.GetHashCode(); + public override int GetHashCode() + => EmployeeID.GetHashCode(); - public override string ToString() => "Employee " + EmployeeID; + public override string ToString() + => "Employee " + EmployeeID; } } diff --git a/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindContext.cs b/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindContext.cs index a03fee989bc..5f67e8e68ee 100644 --- a/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindContext.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; // ReSharper disable StringStartsWithIsCultureSpecific diff --git a/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindData.cs b/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindData.cs index 7791c388740..d91e57146a8 100644 --- a/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindData.cs +++ b/test/EFCore.Specification.Tests/TestModels/Northwind/NorthwindData.cs @@ -58,7 +58,12 @@ public NorthwindData() if (!product.Discontinued) { productQueries.Add( - new ProductQuery { CategoryName = "Food", ProductID = product.ProductID, ProductName = product.ProductName }); + new ProductQuery + { + CategoryName = "Food", + ProductID = product.ProductID, + ProductName = product.ProductName + }); } } diff --git a/test/EFCore.Specification.Tests/TestModels/Northwind/Order.cs b/test/EFCore.Specification.Tests/TestModels/Northwind/Order.cs index 28510a41ad4..9c13d2e3493 100644 --- a/test/EFCore.Specification.Tests/TestModels/Northwind/Order.cs +++ b/test/EFCore.Specification.Tests/TestModels/Northwind/Order.cs @@ -34,7 +34,8 @@ public int OrderID public virtual ICollection OrderDetails { get; set; } - protected bool Equals(Order other) => OrderID == other.OrderID; + protected bool Equals(Order other) + => OrderID == other.OrderID; public override bool Equals(object obj) { @@ -49,8 +50,10 @@ public override bool Equals(object obj) && Equals((Order)obj); } - public override int GetHashCode() => OrderID.GetHashCode(); + public override int GetHashCode() + => OrderID.GetHashCode(); - public override string ToString() => "Order " + OrderID; + public override string ToString() + => "Order " + OrderID; } } diff --git a/test/EFCore.Specification.Tests/TestModels/Northwind/OrderDetail.cs b/test/EFCore.Specification.Tests/TestModels/Northwind/OrderDetail.cs index a3242e2252b..dd9f280f74c 100644 --- a/test/EFCore.Specification.Tests/TestModels/Northwind/OrderDetail.cs +++ b/test/EFCore.Specification.Tests/TestModels/Northwind/OrderDetail.cs @@ -46,7 +46,8 @@ public override bool Equals(object obj) && Equals((OrderDetail)obj); } - public override int GetHashCode() => HashCode.Combine(OrderID, ProductID); + public override int GetHashCode() + => HashCode.Combine(OrderID, ProductID); public int CompareTo(OrderDetail other) { diff --git a/test/EFCore.Specification.Tests/TestModels/Northwind/OrderQuery.cs b/test/EFCore.Specification.Tests/TestModels/Northwind/OrderQuery.cs index 9eae46e60a1..40ca085a19c 100644 --- a/test/EFCore.Specification.Tests/TestModels/Northwind/OrderQuery.cs +++ b/test/EFCore.Specification.Tests/TestModels/Northwind/OrderQuery.cs @@ -36,9 +36,11 @@ public override bool Equals(object obj) && Equals((OrderQuery)obj); } - public static bool operator ==(OrderQuery left, OrderQuery right) => Equals(left, right); + public static bool operator ==(OrderQuery left, OrderQuery right) + => Equals(left, right); - public static bool operator !=(OrderQuery left, OrderQuery right) => !Equals(left, right); + public static bool operator !=(OrderQuery left, OrderQuery right) + => !Equals(left, right); public override int GetHashCode() { diff --git a/test/EFCore.Specification.Tests/TestModels/Northwind/Product.cs b/test/EFCore.Specification.Tests/TestModels/Northwind/Product.cs index dabe2111afa..201020d6ebf 100644 --- a/test/EFCore.Specification.Tests/TestModels/Northwind/Product.cs +++ b/test/EFCore.Specification.Tests/TestModels/Northwind/Product.cs @@ -32,7 +32,8 @@ public int ProductID public virtual List OrderDetails { get; set; } - protected bool Equals(Product other) => Equals(ProductID, other.ProductID); + protected bool Equals(Product other) + => Equals(ProductID, other.ProductID); public override bool Equals(object obj) { @@ -47,8 +48,10 @@ public override bool Equals(object obj) && Equals((Product)obj); } - public override int GetHashCode() => ProductID.GetHashCode(); + public override int GetHashCode() + => ProductID.GetHashCode(); - public override string ToString() => "Product " + ProductID; + public override string ToString() + => "Product " + ProductID; } } diff --git a/test/EFCore.Specification.Tests/TestModels/QueryFilterFuncletizationContext.cs b/test/EFCore.Specification.Tests/TestModels/QueryFilterFuncletizationContext.cs index f9bb43568ff..198ac208de1 100644 --- a/test/EFCore.Specification.Tests/TestModels/QueryFilterFuncletizationContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/QueryFilterFuncletizationContext.cs @@ -21,8 +21,13 @@ public QueryFilterFuncletizationContext(DbContextOptions options) public bool Property { get; set; } public bool? IsModerated { get; set; } public int Tenant { get; set; } - public int GetId() => 2; - public Indirection GetFlag() => new Indirection(); + + public int GetId() + => 2; + + public Indirection GetFlag() + => new Indirection(); + public List TenantIds { get; set; } public Indirection IndirectionFlag { get; set; } @@ -80,7 +85,8 @@ private void ConfigureFilter(EntityTypeBuilder builder) } private static void ConfigureFilterParams( - EntityTypeBuilder builder, QueryFilterFuncletizationContext context) + EntityTypeBuilder builder, + QueryFilterFuncletizationContext context) { builder.HasQueryFilter(e => e.IsEnabled == context.Property); } @@ -240,13 +246,15 @@ public DbContextWrapper(QueryFilterFuncletizationContext context) public static class FilterExtensions { public static void BuilderFilter( - this EntityTypeBuilder builder, QueryFilterFuncletizationContext context) + this EntityTypeBuilder builder, + QueryFilterFuncletizationContext context) { builder.HasQueryFilter(e => e.IsEnabled == context.Field); } public static void ContextFilter( - this DbContextWrapper wrapper, EntityTypeBuilder builder) + this DbContextWrapper wrapper, + EntityTypeBuilder builder) { builder.HasQueryFilter(e => e.IsEnabled == wrapper.Context.IndirectionFlag.Enabled); } @@ -255,7 +263,9 @@ public static void ContextFilter( public class Indirection { public bool Enabled { get; set; } - public int GetId() => 2; + + public int GetId() + => 2; public static void ConfigureFilter(EntityTypeBuilder builder, DbContextWrapper wrapper) { @@ -265,7 +275,8 @@ public static void ConfigureFilter(EntityTypeBuilder b public class IncorrectDbContext : DbContext { - public int BossId => 1; + public int BossId + => 1; } #endregion diff --git a/test/EFCore.Specification.Tests/TestModels/TransportationModel/CombustionEngine.cs b/test/EFCore.Specification.Tests/TestModels/TransportationModel/CombustionEngine.cs index 09e1c181c26..b50fc2ea3da 100644 --- a/test/EFCore.Specification.Tests/TestModels/TransportationModel/CombustionEngine.cs +++ b/test/EFCore.Specification.Tests/TestModels/TransportationModel/CombustionEngine.cs @@ -14,6 +14,7 @@ public override bool Equals(object obj) && base.Equals(other) && Equals(FuelTank, other.FuelTank); - public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), FuelTank); + public override int GetHashCode() + => HashCode.Combine(base.GetHashCode(), FuelTank); } } diff --git a/test/EFCore.Specification.Tests/TestModels/TransportationModel/Engine.cs b/test/EFCore.Specification.Tests/TestModels/TransportationModel/Engine.cs index 80b62be16b9..74237da173d 100644 --- a/test/EFCore.Specification.Tests/TestModels/TransportationModel/Engine.cs +++ b/test/EFCore.Specification.Tests/TestModels/TransportationModel/Engine.cs @@ -17,6 +17,7 @@ public override bool Equals(object obj) && VehicleName == other.VehicleName && Description == other.Description; - public override int GetHashCode() => HashCode.Combine(VehicleName, Description); + public override int GetHashCode() + => HashCode.Combine(VehicleName, Description); } } diff --git a/test/EFCore.Specification.Tests/TestModels/TransportationModel/LicensedOperator.cs b/test/EFCore.Specification.Tests/TestModels/TransportationModel/LicensedOperator.cs index f4caa4881aa..6c1cda8d462 100644 --- a/test/EFCore.Specification.Tests/TestModels/TransportationModel/LicensedOperator.cs +++ b/test/EFCore.Specification.Tests/TestModels/TransportationModel/LicensedOperator.cs @@ -12,6 +12,7 @@ public override bool Equals(object obj) && base.Equals(other) && LicenseType == other.LicenseType; - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); } } diff --git a/test/EFCore.Specification.Tests/TestModels/TransportationModel/PoweredVehicle.cs b/test/EFCore.Specification.Tests/TestModels/TransportationModel/PoweredVehicle.cs index dbc218b5fd3..b2b2b3c1790 100644 --- a/test/EFCore.Specification.Tests/TestModels/TransportationModel/PoweredVehicle.cs +++ b/test/EFCore.Specification.Tests/TestModels/TransportationModel/PoweredVehicle.cs @@ -14,6 +14,7 @@ public override bool Equals(object obj) && base.Equals(other) && Equals(Engine, other.Engine); - public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), Engine); + public override int GetHashCode() + => HashCode.Combine(base.GetHashCode(), Engine); } } diff --git a/test/EFCore.Specification.Tests/TestModels/TransportationModel/SolidFuelTank.cs b/test/EFCore.Specification.Tests/TestModels/TransportationModel/SolidFuelTank.cs index 5c358dd9c08..df663989470 100644 --- a/test/EFCore.Specification.Tests/TestModels/TransportationModel/SolidFuelTank.cs +++ b/test/EFCore.Specification.Tests/TestModels/TransportationModel/SolidFuelTank.cs @@ -15,6 +15,7 @@ public override bool Equals(object obj) && base.Equals(other) && GrainGeometry == other.GrainGeometry; - public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), GrainGeometry); + public override int GetHashCode() + => HashCode.Combine(base.GetHashCode(), GrainGeometry); } } diff --git a/test/EFCore.Specification.Tests/TestModels/TransportationModel/TransportationContext.cs b/test/EFCore.Specification.Tests/TestModels/TransportationModel/TransportationContext.cs index 1ac83096175..6751ea8f95a 100644 --- a/test/EFCore.Specification.Tests/TestModels/TransportationModel/TransportationContext.cs +++ b/test/EFCore.Specification.Tests/TestModels/TransportationModel/TransportationContext.cs @@ -48,10 +48,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) }); modelBuilder.Entity(); - modelBuilder.Entity(vb => - { - vb.Navigation(v => v.Operator).IsRequired(); - }); + modelBuilder.Entity( + vb => + { + vb.Navigation(v => v.Operator).IsRequired(); + }); modelBuilder.Entity( eb => diff --git a/test/EFCore.Specification.Tests/TestModels/TransportationModel/Vehicle.cs b/test/EFCore.Specification.Tests/TestModels/TransportationModel/Vehicle.cs index 6eba981a79b..d5ad5c1b89e 100644 --- a/test/EFCore.Specification.Tests/TestModels/TransportationModel/Vehicle.cs +++ b/test/EFCore.Specification.Tests/TestModels/TransportationModel/Vehicle.cs @@ -17,6 +17,7 @@ public override bool Equals(object obj) && SeatingCapacity == other.SeatingCapacity && Equals(Operator, other.Operator); - public override int GetHashCode() => HashCode.Combine(Name, SeatingCapacity, Operator); + public override int GetHashCode() + => HashCode.Combine(Name, SeatingCapacity, Operator); } } diff --git a/test/EFCore.Specification.Tests/TestUtilities/AnnotationComparer.cs b/test/EFCore.Specification.Tests/TestUtilities/AnnotationComparer.cs index 45d04265f88..0f27a7cccab 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/AnnotationComparer.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/AnnotationComparer.cs @@ -17,7 +17,8 @@ private AnnotationComparer() { } - public int Compare(IAnnotation x, IAnnotation y) => StringComparer.Ordinal.Compare(x.Name, y.Name); + public int Compare(IAnnotation x, IAnnotation y) + => StringComparer.Ordinal.Compare(x.Name, y.Name); public bool Equals(IAnnotation x, IAnnotation y) { @@ -33,6 +34,7 @@ public bool Equals(IAnnotation x, IAnnotation y) || Equals(x.Value, y.Value)); } - public int GetHashCode(IAnnotation obj) => obj.Name.GetHashCode() ^ obj.Value?.GetHashCode() ?? 0; + public int GetHashCode(IAnnotation obj) + => obj.Name.GetHashCode() ^ obj.Value?.GetHashCode() ?? 0; } } diff --git a/test/EFCore.Specification.Tests/TestUtilities/DataGenerator.cs b/test/EFCore.Specification.Tests/TestUtilities/DataGenerator.cs index f9dc5e1b74e..49485a58abd 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/DataGenerator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/DataGenerator.cs @@ -51,6 +51,7 @@ public static object[][] GetCombinations(params Type[] types) sets[i] = values; } + return GetCombinations(sets); } diff --git a/test/EFCore.Specification.Tests/TestUtilities/ExpectedQueryRewritingVisitor.cs b/test/EFCore.Specification.Tests/TestUtilities/ExpectedQueryRewritingVisitor.cs index 873fa4a56b1..aa281f79f73 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/ExpectedQueryRewritingVisitor.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/ExpectedQueryRewritingVisitor.cs @@ -7,6 +7,7 @@ using System.Linq.Expressions; using System.Reflection; using Microsoft.EntityFrameworkCore.Query; +using MethodInfoExtensions = Microsoft.EntityFrameworkCore.Infrastructure.MethodInfoExtensions; namespace Microsoft.EntityFrameworkCore.TestUtilities { @@ -31,24 +32,20 @@ private static readonly MethodInfo _endsWithMethodInfo private static readonly MethodInfo _maybeScalarNonNullableMethod; /// - /// used to map shadow property to a series of non-shadow member expressions, - /// e.g. order.CustomerId -> order.Customer + customer.Id - /// key: source type + shadow property name - /// value: list of MemberInfos that should be used during rewrite + /// used to map shadow property to a series of non-shadow member expressions, + /// e.g. order.CustomerId -> order.Customer + customer.Id + /// key: source type + shadow property name + /// value: list of MemberInfos that should be used during rewrite /// private readonly Dictionary<(Type type, string name), MemberInfo[]> _efPropertyMemberInfoMappings; - private bool _negated = false; + private bool _negated; static ExpectedQueryRewritingVisitor() { var maybeScalarMethods = typeof(QueryTestExtensions).GetMethods() .Where(m => m.Name == nameof(QueryTestExtensions.MaybeScalar)) - .Select(m => new - { - method = m, - argument = m.GetParameters()[1].ParameterType.GetGenericArguments()[1] - }); + .Select(m => new { method = m, argument = m.GetParameters()[1].ParameterType.GetGenericArguments()[1] }); _maybeScalarNullableMethod = maybeScalarMethods.Single(x => x.argument.IsNullableValueType()).method; _maybeScalarNonNullableMethod = maybeScalarMethods.Single(x => !x.argument.IsNullableValueType()).method; @@ -102,7 +99,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp return RewriteJoinGroupJoin(methodCallExpression); } - if (Infrastructure.MethodInfoExtensions.IsEFPropertyMethod(methodCallExpression.Method)) + if (MethodInfoExtensions.IsEFPropertyMethod(methodCallExpression.Method)) { var rewritten = TryConvertEFPropertyToMemberAccess(methodCallExpression); @@ -239,7 +236,7 @@ private Expression RewriteStartsWithEndsWithContains(MethodCallExpression method private Expression TryConvertEFPropertyToMemberAccess(Expression expression) { if (expression is MethodCallExpression methodCallExpression - && Infrastructure.MethodInfoExtensions.IsEFPropertyMethod(methodCallExpression.Method)) + && MethodInfoExtensions.IsEFPropertyMethod(methodCallExpression.Method)) { var caller = RemoveConvertToObject(methodCallExpression.Arguments[0]); var propertyName = (methodCallExpression.Arguments[1] as ConstantExpression)?.Value as string @@ -275,7 +272,8 @@ private Expression TryConvertEFPropertyToMemberAccess(Expression expression) } } - throw new InvalidOperationException($"Couldn't convert EF.Property() method. Caller type: '{caller.Type.Name}'. Property name: '{propertyName}'."); + throw new InvalidOperationException( + $"Couldn't convert EF.Property() method. Caller type: '{caller.Type.Name}'. Property name: '{propertyName}'."); } return expression; @@ -285,8 +283,8 @@ static Expression RemoveConvertToObject(Expression expression) && (expression.NodeType == ExpressionType.Convert || expression.NodeType == ExpressionType.ConvertChecked) && expression.Type == typeof(object) - ? RemoveConvertToObject(unaryExpression.Operand) - : expression; + ? RemoveConvertToObject(unaryExpression.Operand) + : expression; } private Expression AddNullProtectionForNonNullableMemberAccess(Expression expression) @@ -304,8 +302,8 @@ private Expression AddNullProtectionForNonNullableMemberAccess(Expression expres var methodInfo = (memberExpression.Type.IsNullableValueType() ? _maybeScalarNullableMethod : _maybeScalarNonNullableMethod).MakeGenericMethod( - instance.Type, - memberExpression.Type.UnwrapNullableType()); + instance.Type, + memberExpression.Type.UnwrapNullableType()); return Expression.Call(methodInfo, instance, maybeLambda); } @@ -315,7 +313,9 @@ private Expression AddNullProtectionForNonNullableMemberAccess(Expression expres protected override Expression VisitUnary(UnaryExpression unaryExpression) { - if ((unaryExpression.NodeType == ExpressionType.Convert || unaryExpression.NodeType == ExpressionType.ConvertChecked || unaryExpression.NodeType == ExpressionType.TypeAs) + if ((unaryExpression.NodeType == ExpressionType.Convert + || unaryExpression.NodeType == ExpressionType.ConvertChecked + || unaryExpression.NodeType == ExpressionType.TypeAs) && unaryExpression.Operand is MemberExpression memberOperand && memberOperand.Type.IsValueType && !memberOperand.Type.IsNullableValueType() diff --git a/test/EFCore.Specification.Tests/TestUtilities/ForeignKeyStrictComparer.cs b/test/EFCore.Specification.Tests/TestUtilities/ForeignKeyStrictComparer.cs index 577cf9b0017..56abfcbdf80 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/ForeignKeyStrictComparer.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/ForeignKeyStrictComparer.cs @@ -18,7 +18,8 @@ public ForeignKeyStrictComparer(bool compareAnnotations = true, bool compareNavi _compareNavigations = compareNavigations; } - public int Compare(IForeignKey x, IForeignKey y) => ForeignKeyComparer.Instance.Compare(x, y); + public int Compare(IForeignKey x, IForeignKey y) + => ForeignKeyComparer.Instance.Compare(x, y); public bool Equals(IForeignKey x, IForeignKey y) { @@ -38,6 +39,7 @@ public bool Equals(IForeignKey x, IForeignKey y) && (!_compareAnnotations || x.GetAnnotations().SequenceEqual(y.GetAnnotations(), AnnotationComparer.Instance)); } - public int GetHashCode(IForeignKey obj) => ForeignKeyComparer.Instance.GetHashCode(obj); + public int GetHashCode(IForeignKey obj) + => ForeignKeyComparer.Instance.GetHashCode(obj); } } diff --git a/test/EFCore.Specification.Tests/TestUtilities/ListLoggerFactory.cs b/test/EFCore.Specification.Tests/TestUtilities/ListLoggerFactory.cs index 479c998f075..182128ee31d 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/ListLoggerFactory.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/ListLoggerFactory.cs @@ -26,12 +26,19 @@ public ListLoggerFactory(Func shouldLogCategory) Logger = new ListLogger(); } - public List<(LogLevel Level, EventId Id, string Message, object State, Exception Exception)> Log => Logger.LoggedEvents; + public List<(LogLevel Level, EventId Id, string Message, object State, Exception Exception)> Log + => Logger.LoggedEvents; + protected ListLogger Logger { get; set; } - public virtual void Clear() => Logger.Clear(); - public CancellationToken CancelQuery() => Logger.CancelOnNextLogEntry(); - public virtual IDisposable SuspendRecordingEvents() => Logger.SuspendRecordingEvents(); + public virtual void Clear() + => Logger.Clear(); + + public CancellationToken CancelQuery() + => Logger.CancelOnNextLogEntry(); + + public virtual IDisposable SuspendRecordingEvents() + => Logger.SuspendRecordingEvents(); public void SetTestOutputHelper(ITestOutputHelper testOutputHelper) { @@ -107,7 +114,11 @@ public IDisposable SuspendRecordingEvents() } public void Log( - LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) + LogLevel logLevel, + EventId eventId, + TState state, + Exception exception, + Func formatter) { lock (_sync) // Guard against tests with explicit concurrency { @@ -117,7 +128,11 @@ public void Log( } protected virtual void UnsafeLog( - LogLevel logLevel, EventId eventId, string message, TState state, Exception exception) + LogLevel logLevel, + EventId eventId, + string message, + TState state, + Exception exception) { if (message != null) { @@ -136,17 +151,24 @@ protected virtual void UnsafeLog( } } - public bool IsEnabled(LogLevel logLevel) => true; + public bool IsEnabled(LogLevel logLevel) + => true; - public IDisposable BeginScope(object state) => null; + public IDisposable BeginScope(object state) + => null; - public IDisposable BeginScope(TState state) => null; + public IDisposable BeginScope(TState state) + => null; private class RecordingSuspensionHandle : IDisposable { private readonly ListLogger _logger; - public RecordingSuspensionHandle(ListLogger logger) => _logger = logger; - public void Dispose() => _logger.IsRecordingSuspended = false; + + public RecordingSuspensionHandle(ListLogger logger) + => _logger = logger; + + public void Dispose() + => _logger.IsRecordingSuspended = false; } } } diff --git a/test/EFCore.Specification.Tests/TestUtilities/MetadataExtensions.cs b/test/EFCore.Specification.Tests/TestUtilities/MetadataExtensions.cs index 2cc3b5eb181..5829109468c 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/MetadataExtensions.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/MetadataExtensions.cs @@ -12,7 +12,8 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities public static class MetadataExtensions { public static IQueryable AsTracking( - this IQueryable source, bool tracking) + this IQueryable source, + bool tracking) where TEntity : class => tracking ? source.AsTracking() : source.AsNoTracking(); diff --git a/test/EFCore.Specification.Tests/TestUtilities/NavigationComparer.cs b/test/EFCore.Specification.Tests/TestUtilities/NavigationComparer.cs index fa596b8780d..9cff0448aba 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/NavigationComparer.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/NavigationComparer.cs @@ -17,7 +17,8 @@ public NavigationComparer(bool compareAnnotations = true) _compareAnnotations = compareAnnotations; } - public int Compare(INavigation x, INavigation y) => StringComparer.Ordinal.Compare(x.Name, y.Name); + public int Compare(INavigation x, INavigation y) + => StringComparer.Ordinal.Compare(x.Name, y.Name); public bool Equals(INavigation x, INavigation y) { @@ -32,6 +33,7 @@ public bool Equals(INavigation x, INavigation y) && (!_compareAnnotations || x.GetAnnotations().SequenceEqual(y.GetAnnotations(), AnnotationComparer.Instance)); } - public int GetHashCode(INavigation obj) => obj.Name.GetHashCode(); + public int GetHashCode(INavigation obj) + => obj.Name.GetHashCode(); } } diff --git a/test/EFCore.Specification.Tests/TestUtilities/PropertyComparer.cs b/test/EFCore.Specification.Tests/TestUtilities/PropertyComparer.cs index 7737967c268..64036354a76 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/PropertyComparer.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/PropertyComparer.cs @@ -17,7 +17,8 @@ public PropertyComparer(bool compareAnnotations = true) _compareAnnotations = compareAnnotations; } - public int Compare(IProperty x, IProperty y) => StringComparer.Ordinal.Compare(x.Name, y.Name); + public int Compare(IProperty x, IProperty y) + => StringComparer.Ordinal.Compare(x.Name, y.Name); public bool Equals(IProperty x, IProperty y) { @@ -39,6 +40,7 @@ public bool Equals(IProperty x, IProperty y) && (!_compareAnnotations || x.GetAnnotations().SequenceEqual(y.GetAnnotations(), AnnotationComparer.Instance)); } - public int GetHashCode(IProperty obj) => obj.Name.GetHashCode(); + public int GetHashCode(IProperty obj) + => obj.Name.GetHashCode(); } } diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs index 88df3422199..2ea7de6a9cd 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryAsserter.cs @@ -16,9 +16,14 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities { public class QueryAsserter { - private static readonly MethodInfo _assertIncludeEntity = typeof(QueryAsserter).GetTypeInfo().GetDeclaredMethod(nameof(AssertIncludeEntity)); - private static readonly MethodInfo _assertIncludeCollectionMethodInfo = typeof(QueryAsserter).GetTypeInfo().GetDeclaredMethod(nameof(AssertIncludeCollection)); - private static readonly MethodInfo _filteredIncludeMethodInfo = typeof(QueryAsserter).GetTypeInfo().GetDeclaredMethod(nameof(FilteredInclude)); + private static readonly MethodInfo _assertIncludeEntity = + typeof(QueryAsserter).GetTypeInfo().GetDeclaredMethod(nameof(AssertIncludeEntity)); + + private static readonly MethodInfo _assertIncludeCollectionMethodInfo = + typeof(QueryAsserter).GetTypeInfo().GetDeclaredMethod(nameof(AssertIncludeCollection)); + + private static readonly MethodInfo _filteredIncludeMethodInfo = + typeof(QueryAsserter).GetTypeInfo().GetDeclaredMethod(nameof(FilteredInclude)); private readonly Func _contextCreator; private readonly IReadOnlyDictionary _entitySorters; @@ -602,7 +607,8 @@ public async Task AssertMin( ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).MinAsync(actualSelector) : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Min(actualSelector); - var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); + var rewrittenExpectedSelector = + (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Min(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); @@ -641,7 +647,8 @@ public async Task AssertMax( ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).MaxAsync(actualSelector) : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Max(actualSelector); - var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); + var rewrittenExpectedSelector = + (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Max(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); @@ -931,7 +938,8 @@ public async Task AssertSum( ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).SumAsync(actualSelector) : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Sum(actualSelector); - var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); + var rewrittenExpectedSelector = + (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Sum(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); @@ -1301,7 +1309,8 @@ public async Task AssertAverage( ? await RewriteServerQuery(actualQuery(SetSourceCreator(context))).AverageAsync(actualSelector) : RewriteServerQuery(actualQuery(SetSourceCreator(context))).Average(actualSelector); - var rewrittenExpectedSelector = (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); + var rewrittenExpectedSelector = + (Expression>)new ExpectedQueryRewritingVisitor().Visit(expectedSelector); var expected = RewriteExpectedQuery(expectedQuery(ExpectedData)).Average(rewrittenExpectedSelector); AssertEqual(expected, actual, asserter); @@ -1515,8 +1524,6 @@ private void AssertIncludeEntity(TElement expected, TElement actual, I { ((Action)asserter)(expected, actual); ProcessIncludes(expected, actual, expectedIncludes); - - return; } } @@ -1562,7 +1569,7 @@ private void ProcessIncludes(TEntity expected, TEntity actual, IEnumera this, BindingFlags.NonPublic, null, - new object[] { expectedIncludedNavigation, expectedInclude }, + new[] { expectedIncludedNavigation, expectedInclude }, CultureInfo.CurrentCulture); assertOrder = (bool)expectedInclude.GetType() @@ -1602,7 +1609,7 @@ private void AssertEntryCount(DbContext context, int entryCount) } private IQueryable RewriteServerQuery(IQueryable query) - => query.Provider.CreateQuery(_rewriteServerQueryExpression(query.Expression)); + => query.Provider.CreateQuery(_rewriteServerQueryExpression(query.Expression)); private IQueryable RewriteExpectedQuery(IQueryable query) => query.Provider.CreateQuery(_rewriteExpectedQueryExpression(query.Expression)); diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendSelectConstantExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendSelectConstantExpressionMutator.cs index 18a9f4c3511..90afe7aa551 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendSelectConstantExpressionMutator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendSelectConstantExpressionMutator.cs @@ -24,7 +24,8 @@ public AppendSelectConstantExpressionMutator(DbContext context) (type: typeof(string), expression: Expression.Constant(null, typeof(string))) }; - public override bool IsValid(Expression expression) => IsQueryableResult(expression); + public override bool IsValid(Expression expression) + => IsQueryableResult(expression); public override Expression Apply(Expression expression, Random random) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendSelectIdentityExpressionMutator.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendSelectIdentityExpressionMutator.cs index 40639e77927..40a3574ba25 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendSelectIdentityExpressionMutator.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryTestGeneration/AppendSelectIdentityExpressionMutator.cs @@ -14,7 +14,8 @@ public AppendSelectIdentityExpressionMutator(DbContext context) { } - public override bool IsValid(Expression expression) => IsQueryableResult(expression); + public override bool IsValid(Expression expression) + => IsQueryableResult(expression); public override Expression Apply(Expression expression, Random random) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestDbContextLogger.cs b/test/EFCore.Specification.Tests/TestUtilities/TestDbContextLogger.cs index b6ef927c00c..f2fb6035431 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestDbContextLogger.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestDbContextLogger.cs @@ -17,6 +17,7 @@ public void Log(EventData eventData) LoggedEvent = eventData.EventId; } - public bool ShouldLog(EventId eventId, LogLevel logLevel) => true; + public bool ShouldLog(EventId eventId, LogLevel logLevel) + => true; } } diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestDiagnosticSource.cs b/test/EFCore.Specification.Tests/TestUtilities/TestDiagnosticSource.cs index 47b02f3df11..67e9d7e081f 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestDiagnosticSource.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestDiagnosticSource.cs @@ -29,6 +29,7 @@ public override void Write(string name, object value) } } - public override bool IsEnabled(string name) => name == EnableFor; + public override bool IsEnabled(string name) + => name == EnableFor; } } diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestHelpers.cs b/test/EFCore.Specification.Tests/TestUtilities/TestHelpers.cs index 1d49b53eefb..519cf26f258 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestHelpers.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestHelpers.cs @@ -106,8 +106,8 @@ public IServiceProvider CreateContextServices(IServiceProvider serviceProvider, public IServiceProvider CreateContextServices(IServiceProvider serviceProvider, DbContextOptions options) => ((IInfrastructure)CreateContext(serviceProvider, options)).Instance; - public IServiceProvider CreateContextServices(IServiceProvider serviceProvider) => - ((IInfrastructure)CreateContext(serviceProvider)).Instance; + public IServiceProvider CreateContextServices(IServiceProvider serviceProvider) + => ((IInfrastructure)CreateContext(serviceProvider)).Instance; public IServiceProvider CreateContextServices(IModel model) => ((IInfrastructure)CreateContext(model)).Instance; @@ -180,7 +180,9 @@ public ConventionSet CreateConventionalConventionSet( public virtual LoggingDefinitions LoggingDefinitions { get; } = new TestLoggingDefinitions(); public InternalEntityEntry CreateInternalEntry( - IModel model, EntityState entityState = EntityState.Detached, TEntity entity = null) + IModel model, + EntityState entityState = EntityState.Detached, + TEntity entity = null) where TEntity : class, new() { var entry = CreateContextServices(model) @@ -219,7 +221,7 @@ public static int AssertResults( && !verifyOrdered && expected.Count > 1 // If there is only 1 element then sorting is not necessary && expected.FirstOrDefault(e => e != null) is T nonNullElement - && nonNullElement.GetType().GetInterface(nameof(IComparable)) == null) + && nonNullElement.GetType().GetInterface(nameof(IComparable)) == null) { if (elementAsserter != null) { diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestIndexComparer.cs b/test/EFCore.Specification.Tests/TestUtilities/TestIndexComparer.cs index b12d4686d3a..2c51e9b41e3 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestIndexComparer.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestIndexComparer.cs @@ -17,7 +17,8 @@ public TestIndexComparer(bool compareAnnotations = true) _compareAnnotations = compareAnnotations; } - public int Compare(IIndex x, IIndex y) => PropertyListComparer.Instance.Compare(x.Properties, y.Properties); + public int Compare(IIndex x, IIndex y) + => PropertyListComparer.Instance.Compare(x.Properties, y.Properties); public bool Equals(IIndex x, IIndex y) { @@ -33,6 +34,7 @@ public bool Equals(IIndex x, IIndex y) && (!_compareAnnotations || x.GetAnnotations().SequenceEqual(y.GetAnnotations(), AnnotationComparer.Instance)); } - public int GetHashCode(IIndex obj) => PropertyListComparer.Instance.GetHashCode(obj.Properties); + public int GetHashCode(IIndex obj) + => PropertyListComparer.Instance.GetHashCode(obj.Properties); } } diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestKeyComparer.cs b/test/EFCore.Specification.Tests/TestUtilities/TestKeyComparer.cs index 0af532b76c4..df3219d7f14 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestKeyComparer.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestKeyComparer.cs @@ -17,7 +17,8 @@ public TestKeyComparer(bool compareAnnotations = true) _compareAnnotations = compareAnnotations; } - public int Compare(IKey x, IKey y) => PropertyListComparer.Instance.Compare(x.Properties, y.Properties); + public int Compare(IKey x, IKey y) + => PropertyListComparer.Instance.Compare(x.Properties, y.Properties); public bool Equals(IKey x, IKey y) { @@ -32,6 +33,7 @@ public bool Equals(IKey x, IKey y) && (!_compareAnnotations || x.GetAnnotations().SequenceEqual(y.GetAnnotations(), AnnotationComparer.Instance)); } - public int GetHashCode(IKey obj) => PropertyListComparer.Instance.GetHashCode(obj.Properties); + public int GetHashCode(IKey obj) + => PropertyListComparer.Instance.GetHashCode(obj.Properties); } } diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestLogger.cs b/test/EFCore.Specification.Tests/TestUtilities/TestLogger.cs index 8d39acd6181..26261731284 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestLogger.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestLogger.cs @@ -12,14 +12,21 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities public class TestLogger : TestLoggerBase, IDiagnosticsLogger, ILogger where TDefinitions : LoggingDefinitions, new() { - public ILoggingOptions Options => new LoggingOptions(); + public ILoggingOptions Options + => new LoggingOptions(); - public bool IsEnabled(LogLevel logLevel) => EnabledFor == logLevel; + public bool IsEnabled(LogLevel logLevel) + => EnabledFor == logLevel; - public IDisposable BeginScope(TState state) => null; + public IDisposable BeginScope(TState state) + => null; public void Log( - LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) + LogLevel logLevel, + EventId eventId, + TState state, + Exception exception, + Func formatter) { LoggedEvent = eventId; LoggedAt = logLevel; @@ -27,9 +34,11 @@ public void Log( Message = formatter(state, exception); } - public bool ShouldLogSensitiveData() => false; + public bool ShouldLogSensitiveData() + => false; - public ILogger Logger => this; + public ILogger Logger + => this; public virtual LoggingDefinitions Definitions { get; } = new TDefinitions(); diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestModelSource.cs b/test/EFCore.Specification.Tests/TestUtilities/TestModelSource.cs index b53dc0105bd..57591bdf4b9 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestModelSource.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestModelSource.cs @@ -20,7 +20,9 @@ private TestModelSource(Action onModelCreating, ModelSo } protected override IModel CreateModel( - DbContext context, IConventionSetBuilder conventionSetBuilder, ModelDependencies modelDependencies) + DbContext context, + IConventionSetBuilder conventionSetBuilder, + ModelDependencies modelDependencies) { var modelBuilder = new ModelBuilder(conventionSetBuilder.CreateConventionSet(), modelDependencies); diff --git a/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs b/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs index 7a2c7c1fbb1..e57606c4442 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/TestStore.cs @@ -89,7 +89,8 @@ public virtual Task CleanAsync(DbContext context) protected virtual DbContext CreateDefaultContext() => new DbContext(AddProviderOptions(new DbContextOptionsBuilder().EnableServiceProviderCaching(false)).Options); - protected virtual TestStoreIndex GetTestStoreIndex(IServiceProvider serviceProvider) => _globalTestStoreIndex; + protected virtual TestStoreIndex GetTestStoreIndex(IServiceProvider serviceProvider) + => _globalTestStoreIndex; public virtual void Dispose() { diff --git a/test/EFCore.Specification.Tests/TestUtilities/Xunit/PlatformSkipConditionAttribute.cs b/test/EFCore.Specification.Tests/TestUtilities/Xunit/PlatformSkipConditionAttribute.cs index 2cfd0f988b9..d733c776727 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/Xunit/PlatformSkipConditionAttribute.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/Xunit/PlatformSkipConditionAttribute.cs @@ -17,7 +17,8 @@ public PlatformSkipConditionAttribute(TestPlatform excludedPlatforms) _excludedPlatforms = excludedPlatforms; } - public ValueTask IsMetAsync() => new ValueTask(CanRunOnThisPlatform(_excludedPlatforms)); + public ValueTask IsMetAsync() + => new ValueTask(CanRunOnThisPlatform(_excludedPlatforms)); public string SkipReason { get; set; } = "Test cannot run on this platform."; diff --git a/test/EFCore.Specification.Tests/UpdatesTestBase.cs b/test/EFCore.Specification.Tests/UpdatesTestBase.cs index b8adfc55190..590836ab1c1 100644 --- a/test/EFCore.Specification.Tests/UpdatesTestBase.cs +++ b/test/EFCore.Specification.Tests/UpdatesTestBase.cs @@ -17,7 +17,8 @@ namespace Microsoft.EntityFrameworkCore public abstract class UpdatesTestBase : IClassFixture where TFixture : UpdatesFixtureBase { - protected UpdatesTestBase(TFixture fixture) => Fixture = fixture; + protected UpdatesTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } @@ -551,6 +552,7 @@ protected virtual void UseTransaction(DatabaseFacade facade, IDbContextTransacti { } - protected UpdatesContext CreateContext() => Fixture.CreateContext(); + protected UpdatesContext CreateContext() + => Fixture.CreateContext(); } } diff --git a/test/EFCore.Specification.Tests/WithConstructorsTestBase.cs b/test/EFCore.Specification.Tests/WithConstructorsTestBase.cs index 99eadf76097..4b4120b58a8 100644 --- a/test/EFCore.Specification.Tests/WithConstructorsTestBase.cs +++ b/test/EFCore.Specification.Tests/WithConstructorsTestBase.cs @@ -26,11 +26,13 @@ namespace Microsoft.EntityFrameworkCore public abstract class WithConstructorsTestBase : IClassFixture where TFixture : WithConstructorsTestBase.WithConstructorsFixtureBase, new() { - protected WithConstructorsTestBase(TFixture fixture) => Fixture = fixture; + protected WithConstructorsTestBase(TFixture fixture) + => Fixture = fixture; protected TFixture Fixture { get; } - protected DbContext CreateContext() => Fixture.CreateContext(); + protected DbContext CreateContext() + => Fixture.CreateContext(); protected virtual void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) { @@ -905,9 +907,11 @@ private TContext Context } // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter - public bool SetterCalled => _setterCalled; + public bool SetterCalled + => _setterCalled; - public TContext GetContext() => Context; + public TContext GetContext() + => Context; } protected class HasEntityType @@ -927,7 +931,8 @@ private HasEntityType(IEntityType entityType) public bool Filler { get; set; } - public IEntityType GetEntityType() => _entityType; + public IEntityType GetEntityType() + => _entityType; } protected class HasEntityTypeProperty @@ -968,9 +973,11 @@ private IEntityType EntityType } // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter - public bool SetterCalled => _setterCalled; + public bool SetterCalled + => _setterCalled; - public IEntityType GetEntityType() => EntityType; + public IEntityType GetEntityType() + => EntityType; } protected class HasStateManager @@ -990,7 +997,8 @@ private HasStateManager(IStateManager stateManager) public bool Filler { get; set; } - public IStateManager GetStateManager() => _stateManager; + public IStateManager GetStateManager() + => _stateManager; } protected class HasStateManagerProperty @@ -1032,9 +1040,11 @@ private IStateManager StateManager } // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter - public bool SetterCalled => _setterCalled; + public bool SetterCalled + => _setterCalled; - public IStateManager GetStateManager() => StateManager; + public IStateManager GetStateManager() + => StateManager; } protected class LazyBlog @@ -1055,9 +1065,11 @@ private LazyBlog(ILazyLoader loader) public bool Filler { get; set; } - public void AddPost(LazyPost post) => _lazyPosts.Add(post); + public void AddPost(LazyPost post) + => _lazyPosts.Add(post); - public IEnumerable LazyPosts => _loader.Load(this, ref _lazyPosts); + public IEnumerable LazyPosts + => _loader.Load(this, ref _lazyPosts); } protected class LazyPost @@ -1095,9 +1107,11 @@ protected class LazyPropertyBlog public bool Filler { get; set; } - public void AddPost(LazyPropertyPost post) => _lazyPropertyPosts.Add(post); + public void AddPost(LazyPropertyPost post) + => _lazyPropertyPosts.Add(post); - public IEnumerable LazyPropertyPosts => Loader.Load(this, ref _lazyPropertyPosts); + public IEnumerable LazyPropertyPosts + => Loader.Load(this, ref _lazyPropertyPosts); } protected class LazyPropertyPost @@ -1116,7 +1130,8 @@ public LazyPropertyBlog LazyPropertyBlog set => _lazyPropertyBlog = value; } - public ILazyLoader GetLoader() => Loader; + public ILazyLoader GetLoader() + => Loader; } protected class LazyFieldBlog @@ -1133,9 +1148,11 @@ protected class LazyFieldBlog public bool Filler { get; set; } - public void AddPost(LazyFieldPost post) => _lazyFieldPosts.Add(post); + public void AddPost(LazyFieldPost post) + => _lazyFieldPosts.Add(post); - public IEnumerable LazyFieldPosts => _loader.Load(this, ref _lazyFieldPosts); + public IEnumerable LazyFieldPosts + => _loader.Load(this, ref _lazyFieldPosts); } protected class LazyFieldPost @@ -1158,7 +1175,8 @@ public LazyFieldBlog LazyFieldBlog set => _lazyFieldBlog = value; } - public ILazyLoader GetLoader() => _loader; + public ILazyLoader GetLoader() + => _loader; } protected class LazyPsBlog @@ -1171,9 +1189,11 @@ protected class LazyPsBlog public bool Filler { get; set; } - public void AddPost(LazyPsPost post) => _lazyPsPosts.Add(post); + public void AddPost(LazyPsPost post) + => _lazyPsPosts.Add(post); - public IEnumerable LazyPsPosts => LazyLoader.Load(this, ref _lazyPsPosts); + public IEnumerable LazyPsPosts + => LazyLoader.Load(this, ref _lazyPsPosts); } protected class LazyPsPost @@ -1203,7 +1223,8 @@ protected class LazyAsyncPsBlog public bool Filler { get; set; } - public void AddPost(LazyAsyncPsPost post) => _lazyAsyncPsPosts.Add(post); + public void AddPost(LazyAsyncPsPost post) + => _lazyAsyncPsPosts.Add(post); public async Task> LoadPostsAsync(CancellationToken cancellationToken = default) { @@ -1212,7 +1233,8 @@ public async Task> LoadPostsAsync(CancellationToken return LazyAsyncPsPosts; } - public IEnumerable LazyAsyncPsPosts => _lazyAsyncPsPosts; + public IEnumerable LazyAsyncPsPosts + => _lazyAsyncPsPosts; } protected class LazyAsyncPsPost @@ -1264,9 +1286,11 @@ private ILazyLoader Loader public bool Filler { get; set; } - public void AddPost(LazyPcPost post) => _lazyPcPosts.Add(post); + public void AddPost(LazyPcPost post) + => _lazyPcPosts.Add(post); - public IEnumerable LazyPcPosts => Loader.Load(this, ref _lazyPcPosts); + public IEnumerable LazyPcPosts + => Loader.Load(this, ref _lazyPcPosts); } protected class LazyPcPost @@ -1340,9 +1364,11 @@ private Action LazyLoader public bool Filler { get; set; } - public void AddPost(LazyPcsPost post) => _lazyPcsPosts.Add(post); + public void AddPost(LazyPcsPost post) + => _lazyPcsPosts.Add(post); - public IEnumerable LazyPcsPosts => LazyLoader.Load(this, ref _lazyPcsPosts); + public IEnumerable LazyPcsPosts + => LazyLoader.Load(this, ref _lazyPcsPosts); } protected class LazyPcsPost @@ -1383,7 +1409,8 @@ public LazyPcsBlog LazyPcsBlog set => _lazyPcsBlog = value; } - public Action GetLoader() => _loader; + public Action GetLoader() + => _loader; } protected class LazyPocoBlog @@ -1404,9 +1431,11 @@ private LazyPocoBlog(Action lazyLoader) public bool Filler { get; set; } - public void AddPost(LazyPocoPost post) => _lazyPocoPosts.Add(post); + public void AddPost(LazyPocoPost post) + => _lazyPocoPosts.Add(post); - public IEnumerable LazyPocoPosts => _loader.Load(this, ref _lazyPocoPosts); + public IEnumerable LazyPocoPosts + => _loader.Load(this, ref _lazyPocoPosts); } protected class LazyPocoPost @@ -1452,7 +1481,8 @@ private LazyAsyncPocoBlog(Func lazyLoad public bool Filler { get; set; } - public void AddPost(LazyAsyncPocoPost post) => _lazyAsyncPocoPosts.Add(post); + public void AddPost(LazyAsyncPocoPost post) + => _lazyAsyncPocoPosts.Add(post); public async Task> LoadPostsAsync(CancellationToken cancellationToken = default) { @@ -1461,7 +1491,8 @@ public async Task> LoadPostsAsync(CancellationTok return LazyAsyncPocoPosts; } - public IEnumerable LazyAsyncPocoPosts => _lazyAsyncPocoPosts; + public IEnumerable LazyAsyncPocoPosts + => _lazyAsyncPocoPosts; } protected class LazyAsyncPocoPost @@ -1509,7 +1540,8 @@ private LazyAsyncBlog(ILazyLoader loader) public bool Filler { get; set; } - public void AddPost(LazyAsyncPost post) => _lazyAsyncPosts.Add(post); + public void AddPost(LazyAsyncPost post) + => _lazyAsyncPosts.Add(post); public async Task> LoadPostsAsync(CancellationToken cancellationToken = default) { @@ -1518,7 +1550,8 @@ public async Task> LoadPostsAsync(CancellationToken c return LazyAsyncPosts; } - public IEnumerable LazyAsyncPosts => _lazyAsyncPosts; + public IEnumerable LazyAsyncPosts + => _lazyAsyncPosts; } protected class LazyAsyncPost @@ -1575,203 +1608,203 @@ private BlogAsImmutableRecord( } #endif - public class OtherContext : DbContext - { - } + public class OtherContext : DbContext + { + } - public class WithConstructorsContext : PoolableDbContext + public class WithConstructorsContext : PoolableDbContext + { + public WithConstructorsContext(DbContextOptions options) + : base(options) { - public WithConstructorsContext(DbContextOptions options) - : base(options) - { - } } + } - public abstract class WithConstructorsFixtureBase : SharedStoreFixtureBase - { - protected override string StoreName { get; } = "WithConstructors"; + public abstract class WithConstructorsFixtureBase : SharedStoreFixtureBase + { + protected override string StoreName { get; } = "WithConstructors"; - protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) - { - modelBuilder.Entity( - b => - { - b.HasKey("_blogId"); - b.Property(e => e.Title); - }); + protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) + { + modelBuilder.Entity( + b => + { + b.HasKey("_blogId"); + 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 => - { - b.HasKey("_id"); - b.Property(e => e.Title); - }); + modelBuilder.Entity( + b => + { + b.HasKey("_id"); + b.Property(e => e.Title); + }); - modelBuilder.Entity>(); - modelBuilder.Entity>(); - modelBuilder.Entity>(); + modelBuilder.Entity>(); + modelBuilder.Entity>(); + modelBuilder.Entity>(); - modelBuilder.Entity>(); - modelBuilder.Entity>(); - modelBuilder.Entity>(); + modelBuilder.Entity>(); + modelBuilder.Entity>(); + modelBuilder.Entity>(); - modelBuilder.Entity>(); - modelBuilder.Entity>(); - modelBuilder.Entity>(); + modelBuilder.Entity>(); + modelBuilder.Entity>(); + modelBuilder.Entity>(); - modelBuilder.Entity(); - modelBuilder.Entity(); - modelBuilder.Entity(); + modelBuilder.Entity(); + modelBuilder.Entity(); + modelBuilder.Entity(); - modelBuilder.Entity(); - modelBuilder.Entity(); - modelBuilder.Entity(); + modelBuilder.Entity(); + modelBuilder.Entity(); + modelBuilder.Entity(); - modelBuilder.Entity(); - modelBuilder.Entity(); + modelBuilder.Entity(); + modelBuilder.Entity(); - modelBuilder.Entity(); - modelBuilder.Entity(); + modelBuilder.Entity(); + modelBuilder.Entity(); - modelBuilder.Entity(); - modelBuilder.Entity(); - modelBuilder.Entity(); - modelBuilder.Entity(); - modelBuilder.Entity(); + modelBuilder.Entity(); + modelBuilder.Entity(); + modelBuilder.Entity(); + modelBuilder.Entity(); + modelBuilder.Entity(); #if NET5_0 - modelBuilder.Entity(); + modelBuilder.Entity(); #endif - // Manually configure service fields since there is no public API yet + // Manually configure service fields since there is no public API yet - var bindingFactories = context.GetService(); + var bindingFactories = context.GetService(); - var blogServiceProperty = modelBuilder.Entity().Metadata.AddServiceProperty( - typeof(LazyFieldBlog).GetRuntimeFields().Single(f => f.Name == "_loader")); + var blogServiceProperty = modelBuilder.Entity().Metadata.AddServiceProperty( + typeof(LazyFieldBlog).GetRuntimeFields().Single(f => f.Name == "_loader")); - blogServiceProperty.ParameterBinding = - (ServiceParameterBinding)bindingFactories.FindFactory(typeof(ILazyLoader), "_loader") - .Bind(blogServiceProperty.DeclaringEntityType, typeof(ILazyLoader), "_loader"); + blogServiceProperty.ParameterBinding = + (ServiceParameterBinding)bindingFactories.FindFactory(typeof(ILazyLoader), "_loader") + .Bind(blogServiceProperty.DeclaringEntityType, typeof(ILazyLoader), "_loader"); - var postServiceProperty = modelBuilder.Entity().Metadata.AddServiceProperty( - typeof(LazyFieldPost).GetRuntimeFields().Single(f => f.Name == "_loader")); + var postServiceProperty = modelBuilder.Entity().Metadata.AddServiceProperty( + typeof(LazyFieldPost).GetRuntimeFields().Single(f => f.Name == "_loader")); - postServiceProperty.ParameterBinding = - (ServiceParameterBinding)bindingFactories.FindFactory(typeof(ILazyLoader), "_loader") - .Bind(postServiceProperty.DeclaringEntityType, typeof(ILazyLoader), "_loader"); - } + postServiceProperty.ParameterBinding = + (ServiceParameterBinding)bindingFactories.FindFactory(typeof(ILazyLoader), "_loader") + .Bind(postServiceProperty.DeclaringEntityType, typeof(ILazyLoader), "_loader"); + } - protected override void Seed(WithConstructorsContext context) - { - var blog = new Blog("Puppies"); + protected override void Seed(WithConstructorsContext context) + { + var blog = new Blog("Puppies"); - var post1 = new Post( - "Golden Toasters Rock", - "Smaller than the Black Library Dog, and more chewy.", - blog); + var post1 = new Post( + "Golden Toasters Rock", + "Smaller than the Black Library Dog, and more chewy.", + blog); - var post2 = new Post( - "Baxter is not a dog", - "He is a cat. Who eats dog food. And wags his tail.", - blog); + var post2 = new Post( + "Baxter is not a dog", + "He is a cat. Who eats dog food. And wags his tail.", + blog); - context.AddRange(blog, post1, post2); + context.AddRange(blog, post1, post2); - context.AddRange( - new HasContext(), - new HasContext(), - new HasContext()); + context.AddRange( + new HasContext(), + new HasContext(), + new HasContext()); - context.AddRange( - new HasContextProperty(), - new HasContextProperty(), - new HasContextProperty()); + context.AddRange( + new HasContextProperty(), + new HasContextProperty(), + new HasContextProperty()); - context.AddRange( - new HasContextPc(), - new HasContextPc(), - new HasContextPc()); + context.AddRange( + new HasContextPc(), + new HasContextPc(), + new HasContextPc()); - context.AddRange( - new HasEntityType(), - new HasEntityTypeProperty(), - new HasEntityTypePc()); + context.AddRange( + new HasEntityType(), + new HasEntityTypeProperty(), + new HasEntityTypePc()); - context.AddRange( - new HasStateManager(), - new HasStateManagerProperty(), - new HasStateManagerPc()); + context.AddRange( + new HasStateManager(), + new HasStateManagerProperty(), + new HasStateManagerPc()); - var lazyBlog = new LazyBlog(); - lazyBlog.AddPost(new LazyPost()); - lazyBlog.AddPost(new LazyPost()); + var lazyBlog = new LazyBlog(); + lazyBlog.AddPost(new LazyPost()); + lazyBlog.AddPost(new LazyPost()); - context.Add(lazyBlog); + context.Add(lazyBlog); - var lazyAsyncBlog = new LazyAsyncBlog(); - lazyAsyncBlog.AddPost(new LazyAsyncPost()); - lazyAsyncBlog.AddPost(new LazyAsyncPost()); + var lazyAsyncBlog = new LazyAsyncBlog(); + lazyAsyncBlog.AddPost(new LazyAsyncPost()); + lazyAsyncBlog.AddPost(new LazyAsyncPost()); - context.Add(lazyAsyncBlog); + context.Add(lazyAsyncBlog); - var lazyPocoBlog = new LazyPocoBlog(); - lazyPocoBlog.AddPost(new LazyPocoPost()); - lazyPocoBlog.AddPost(new LazyPocoPost()); + var lazyPocoBlog = new LazyPocoBlog(); + lazyPocoBlog.AddPost(new LazyPocoPost()); + lazyPocoBlog.AddPost(new LazyPocoPost()); - context.Add(lazyPocoBlog); + context.Add(lazyPocoBlog); - var lazyAsyncPocoBlog = new LazyAsyncPocoBlog(); - lazyAsyncPocoBlog.AddPost(new LazyAsyncPocoPost()); - lazyAsyncPocoBlog.AddPost(new LazyAsyncPocoPost()); + var lazyAsyncPocoBlog = new LazyAsyncPocoBlog(); + lazyAsyncPocoBlog.AddPost(new LazyAsyncPocoPost()); + lazyAsyncPocoBlog.AddPost(new LazyAsyncPocoPost()); - context.Add(lazyAsyncPocoBlog); + context.Add(lazyAsyncPocoBlog); - var lazyPropertyBlog = new LazyPropertyBlog(); - lazyPropertyBlog.AddPost(new LazyPropertyPost()); - lazyPropertyBlog.AddPost(new LazyPropertyPost()); + var lazyPropertyBlog = new LazyPropertyBlog(); + lazyPropertyBlog.AddPost(new LazyPropertyPost()); + lazyPropertyBlog.AddPost(new LazyPropertyPost()); - context.Add(lazyPropertyBlog); + context.Add(lazyPropertyBlog); - var lazyFieldBlog = new LazyFieldBlog(); - lazyFieldBlog.AddPost(new LazyFieldPost()); - lazyFieldBlog.AddPost(new LazyFieldPost()); + var lazyFieldBlog = new LazyFieldBlog(); + lazyFieldBlog.AddPost(new LazyFieldPost()); + lazyFieldBlog.AddPost(new LazyFieldPost()); - context.Add(lazyFieldBlog); + context.Add(lazyFieldBlog); - var lazyPsBlog = new LazyPsBlog(); - lazyPsBlog.AddPost(new LazyPsPost()); - lazyPsBlog.AddPost(new LazyPsPost()); + var lazyPsBlog = new LazyPsBlog(); + lazyPsBlog.AddPost(new LazyPsPost()); + lazyPsBlog.AddPost(new LazyPsPost()); - context.Add(lazyPsBlog); + context.Add(lazyPsBlog); - var lazyAsyncPsBlog = new LazyAsyncPsBlog(); - lazyAsyncPsBlog.AddPost(new LazyAsyncPsPost()); - lazyAsyncPsBlog.AddPost(new LazyAsyncPsPost()); + var lazyAsyncPsBlog = new LazyAsyncPsBlog(); + lazyAsyncPsBlog.AddPost(new LazyAsyncPsPost()); + lazyAsyncPsBlog.AddPost(new LazyAsyncPsPost()); - context.Add(lazyAsyncPsBlog); + context.Add(lazyAsyncPsBlog); - var lazyPcBlog = new LazyPcBlog(); - lazyPcBlog.AddPost(new LazyPcPost()); - lazyPcBlog.AddPost(new LazyPcPost()); + var lazyPcBlog = new LazyPcBlog(); + lazyPcBlog.AddPost(new LazyPcPost()); + lazyPcBlog.AddPost(new LazyPcPost()); - context.Add(lazyPcBlog); + context.Add(lazyPcBlog); - var lazyPcsBlog = new LazyPcsBlog(); - lazyPcsBlog.AddPost(new LazyPcsPost()); - lazyPcsBlog.AddPost(new LazyPcsPost()); + var lazyPcsBlog = new LazyPcsBlog(); + lazyPcsBlog.AddPost(new LazyPcsPost()); + lazyPcsBlog.AddPost(new LazyPcsPost()); - context.Add(lazyPcsBlog); + context.Add(lazyPcsBlog); - context.SaveChanges(); - } + context.SaveChanges(); } } } +} diff --git a/test/EFCore.SqlServer.FunctionalTests/BatchingTest.cs b/test/EFCore.SqlServer.FunctionalTests/BatchingTest.cs index e5ffc1459df..81b5c3c40f9 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BatchingTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BatchingTest.cs @@ -199,7 +199,8 @@ private void AssertDatabaseState(DbContext context, bool clientOrder, List } } - private BloggingContext CreateContext() => (BloggingContext)Fixture.CreateContext(); + private BloggingContext CreateContext() + => (BloggingContext)Fixture.CreateContext(); private void ExecuteWithStrategyInTransaction( Action testOperation, @@ -258,8 +259,13 @@ private class Owner public class BatchingTestFixture : SharedStoreFixtureBase { protected override string StoreName { get; } = "BatchingTest"; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; + protected override Type ContextType { get; } = typeof(BloggingContext); protected override bool ShouldLogCategory(string logCategory) diff --git a/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs index 01be1c16953..145c91bac2f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs @@ -747,7 +747,9 @@ private static void AssertMappedDataTypes(MappedDataTypes entity, int id) Assert.Equal(84.4f, entity.FloatAsReal); Assert.Equal(85.5, entity.DoubleAsDoublePrecision); Assert.Equal(new DateTime(2015, 1, 2), entity.DateTimeAsDate); - Assert.Equal(new DateTimeOffset(new DateTime(2016, 1, 2, 11, 11, 12).AddTicks(1234567), TimeSpan.Zero), entity.DateTimeOffsetAsDatetimeoffset); + Assert.Equal( + new DateTimeOffset(new DateTime(2016, 1, 2, 11, 11, 12).AddTicks(1234567), TimeSpan.Zero), + entity.DateTimeOffsetAsDatetimeoffset); Assert.Equal(new DateTime(2017, 1, 2, 12, 11, 12).AddTicks(1234567), entity.DateTimeAsDatetime2); Assert.Equal(new DateTime(2018, 1, 2, 13, 11, 00), entity.DateTimeAsSmalldatetime); Assert.Equal(new DateTime(2019, 1, 2, 14, 11, 12), entity.DateTimeAsDatetime); @@ -933,7 +935,9 @@ private static void AssertMappedNullableDataTypes(MappedNullableDataTypes entity Assert.Equal(84.4f, entity.FloatAsReal); Assert.Equal(85.5, entity.DoubleAsDoublePrecision); Assert.Equal(new DateTime(2015, 1, 2), entity.DateTimeAsDate); - Assert.Equal(new DateTimeOffset(new DateTime(2016, 1, 2, 11, 11, 12).AddTicks(9876543), TimeSpan.Zero), entity.DateTimeOffsetAsDatetimeoffset); + Assert.Equal( + new DateTimeOffset(new DateTime(2016, 1, 2, 11, 11, 12).AddTicks(9876543), TimeSpan.Zero), + entity.DateTimeOffsetAsDatetimeoffset); Assert.Equal(new DateTime(2017, 1, 2, 12, 11, 12).AddTicks(9876543), entity.DateTimeAsDatetime2); Assert.Equal(new DateTime(2018, 1, 2, 13, 11, 00), entity.DateTimeAsSmalldatetime); Assert.Equal(new DateTime(2019, 1, 2, 14, 11, 12), entity.DateTimeAsDatetime); @@ -1441,7 +1445,8 @@ private static void AssertMappedScaledDataTypes(MappedScaledDataTypes entity, in Assert.Equal(85.5f, entity.FloatAsDoublePrecision3); Assert.Equal(83.33f, entity.FloatAsFloat25); Assert.Equal(85.55f, entity.FloatAsDoublePrecision25); - Assert.Equal(new DateTimeOffset(new DateTime(2016, 1, 2, 11, 11, 12, 765), TimeSpan.Zero), entity.DateTimeOffsetAsDatetimeoffset3); + Assert.Equal( + new DateTimeOffset(new DateTime(2016, 1, 2, 11, 11, 12, 765), TimeSpan.Zero), entity.DateTimeOffsetAsDatetimeoffset3); Assert.Equal(new DateTime(2017, 1, 2, 12, 11, 12, 321), entity.DateTimeAsDatetime23); Assert.Equal(101m, entity.DecimalAsDecimal3); Assert.Equal(102m, entity.DecimalAsDec3); @@ -1501,7 +1506,8 @@ private static void AssertMappedScaledSeparatelyDataTypes(MappedScaledSeparately Assert.Equal(85.5f, entity.FloatAsDoublePrecision3); Assert.Equal(83.33f, entity.FloatAsFloat25); Assert.Equal(85.55f, entity.FloatAsDoublePrecision25); - Assert.Equal(new DateTimeOffset(new DateTime(2016, 1, 2, 11, 11, 12, 765), TimeSpan.Zero), entity.DateTimeOffsetAsDatetimeoffset3); + Assert.Equal( + new DateTimeOffset(new DateTime(2016, 1, 2, 11, 11, 12, 765), TimeSpan.Zero), entity.DateTimeOffsetAsDatetimeoffset3); Assert.Equal(new DateTime(2017, 1, 2, 12, 11, 12, 321), entity.DateTimeAsDatetime23); Assert.Equal(101m, entity.DecimalAsDecimal3); Assert.Equal(102m, entity.DecimalAsDec3); @@ -1586,7 +1592,8 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_with_precisio using (var context = CreateContext()) { - AssertMappedPrecisionAndScaledSeparatelyDataTypes(context.Set().Single(e => e.Id == 77), 77); + AssertMappedPrecisionAndScaledSeparatelyDataTypes( + context.Set().Single(e => e.Id == 77), 77); } } @@ -1697,7 +1704,9 @@ private static void AssertMappedDataTypesWithIdentity(MappedDataTypesWithIdentit Assert.Equal(84.4f, entity.FloatAsReal); Assert.Equal(85.5, entity.DoubleAsDoublePrecision); Assert.Equal(new DateTime(2015, 1, 2), entity.DateTimeAsDate); - Assert.Equal(new DateTimeOffset(new DateTime(2016, 1, 2, 11, 11, 12).AddTicks(7654321), TimeSpan.Zero), entity.DateTimeOffsetAsDatetimeoffset); + Assert.Equal( + new DateTimeOffset(new DateTime(2016, 1, 2, 11, 11, 12).AddTicks(7654321), TimeSpan.Zero), + entity.DateTimeOffsetAsDatetimeoffset); Assert.Equal(new DateTime(2017, 1, 2, 12, 11, 12).AddTicks(7654321), entity.DateTimeAsDatetime2); Assert.Equal(new DateTime(2018, 1, 2, 13, 11, 00), entity.DateTimeAsSmalldatetime); Assert.Equal(new DateTime(2019, 1, 2, 14, 11, 12), entity.DateTimeAsDatetime); @@ -1883,7 +1892,9 @@ private static void AssertMappedNullableDataTypesWithIdentity(MappedNullableData Assert.Equal(84.4f, entity.FloatAsReal); Assert.Equal(85.5, entity.DoubleAsDoublePrecision); Assert.Equal(new DateTime(2015, 1, 2), entity.DateTimeAsDate); - Assert.Equal(new DateTimeOffset(new DateTime(2016, 1, 2, 11, 11, 12).AddTicks(2345678), TimeSpan.Zero), entity.DateTimeOffsetAsDatetimeoffset); + Assert.Equal( + new DateTimeOffset(new DateTime(2016, 1, 2, 11, 11, 12).AddTicks(2345678), TimeSpan.Zero), + entity.DateTimeOffsetAsDatetimeoffset); Assert.Equal(new DateTime(2017, 1, 2, 12, 11, 12).AddTicks(2345678), entity.DateTimeAsDatetime2); Assert.Equal(new DateTime(2018, 1, 2, 13, 11, 00), entity.DateTimeAsSmalldatetime); Assert.Equal(new DateTime(2019, 1, 2, 14, 11, 12), entity.DateTimeAsDatetime); @@ -2054,7 +2065,8 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_set_to_null_w } private static void AssertNullMappedNullableDataTypesWithIdentity( - MappedNullableDataTypesWithIdentity entity, int id) + MappedNullableDataTypesWithIdentity entity, + int id) { Assert.Equal(id, entity.Int); Assert.Null(entity.LongAsBigint); @@ -2303,7 +2315,8 @@ private static void AssertMappedScaledDataTypesWithIdentity(MappedScaledDataType Assert.Equal(85.5f, entity.FloatAsDoublePrecision3); Assert.Equal(83.33f, entity.FloatAsFloat25); Assert.Equal(85.55f, entity.FloatAsDoublePrecision25); - Assert.Equal(new DateTimeOffset(new DateTime(2016, 1, 2, 11, 11, 12, 567), TimeSpan.Zero), entity.DateTimeOffsetAsDatetimeoffset3); + Assert.Equal( + new DateTimeOffset(new DateTime(2016, 1, 2, 11, 11, 12, 567), TimeSpan.Zero), entity.DateTimeOffsetAsDatetimeoffset3); Assert.Equal(new DateTime(2017, 1, 2, 12, 11, 12, 123), entity.DateTimeAsDatetime23); Assert.Equal(101m, entity.DecimalAsDecimal3); Assert.Equal(102m, entity.DecimalAsDec3); @@ -2353,7 +2366,8 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_with_precisio } private static void AssertMappedPrecisionAndScaledDataTypesWithIdentity( - MappedPrecisionAndScaledDataTypesWithIdentity entity, int id) + MappedPrecisionAndScaledDataTypesWithIdentity entity, + int id) { Assert.Equal(id, entity.Int); Assert.Equal(101.1m, entity.DecimalAsDecimal52); @@ -3259,15 +3273,20 @@ private void AssertSql(params string[] expected) public class BuiltInDataTypesSqlServerFixture : BuiltInDataTypesFixtureBase { - public override bool StrictEquality => true; + public override bool StrictEquality + => true; - public override bool SupportsAnsi => true; + public override bool SupportsAnsi + => true; - public override bool SupportsUnicodeToAnsiConversion => true; + public override bool SupportsUnicodeToAnsiConversion + => true; - public override bool SupportsLargeStringComparisons => true; + public override bool SupportsLargeStringComparisons + => true; - public override bool SupportsDecimalComparisons => true; + public override bool SupportsDecimalComparisons + => true; protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; @@ -3275,7 +3294,8 @@ protected override ITestStoreFactory TestStoreFactory protected override bool ShouldLogCategory(string logCategory) => logCategory == DbLoggerCategory.Query.Name; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { @@ -3383,9 +3403,11 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build return options; } - public override bool SupportsBinaryKeys => true; + public override bool SupportsBinaryKeys + => true; - public override DateTime DefaultDateTime => new DateTime(); + public override DateTime DefaultDateTime + => new DateTime(); } [Flags] diff --git a/test/EFCore.SqlServer.FunctionalTests/CommandConfigurationTest.cs b/test/EFCore.SqlServer.FunctionalTests/CommandConfigurationTest.cs index b58f1961073..357023a3700 100644 --- a/test/EFCore.SqlServer.FunctionalTests/CommandConfigurationTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/CommandConfigurationTest.cs @@ -51,7 +51,8 @@ public void Keys_generated_in_batches(int count, int expected) Assert.Equal(expected, CountSqlLinesContaining("SELECT NEXT VALUE FOR", Fixture.TestSqlLoggerFactory.Sql)); } - private ChipsContext CreateContext() => (ChipsContext)Fixture.CreateContext(); + private ChipsContext CreateContext() + => (ChipsContext)Fixture.CreateContext(); protected void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); @@ -98,8 +99,12 @@ public class CommandConfigurationFixture : SharedStoreFixtureBase { protected override string StoreName { get; } = "CommandConfiguration"; protected override Type ContextType { get; } = typeof(ChipsContext); - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/CommandInterceptionSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/CommandInterceptionSqlServerTest.cs index 6a5a347c193..e8dd4205fe1 100644 --- a/test/EFCore.SqlServer.FunctionalTests/CommandInterceptionSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/CommandInterceptionSqlServerTest.cs @@ -48,8 +48,11 @@ public override async Task Intercept_query_to_replace_execution(bool asy public abstract class InterceptionSqlServerFixtureBase : InterceptionFixtureBase { - protected override string StoreName => "CommandInterception"; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override string StoreName + => "CommandInterception"; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override IServiceCollection InjectInterceptors( IServiceCollection serviceCollection, @@ -67,7 +70,8 @@ public CommandInterceptionSqlServerTest(InterceptionSqlServerFixture fixture) public class InterceptionSqlServerFixture : InterceptionSqlServerFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => false; + protected override bool ShouldSubscribeToDiagnosticListener + => false; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) { @@ -89,7 +93,8 @@ public CommandInterceptionWithDiagnosticsSqlServerTest(InterceptionSqlServerFixt public class InterceptionSqlServerFixture : InterceptionSqlServerFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => true; + protected override bool ShouldSubscribeToDiagnosticListener + => true; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) { diff --git a/test/EFCore.SqlServer.FunctionalTests/CompositeKeyEndToEndSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/CompositeKeyEndToEndSqlServerTest.cs index ccc0550d94d..2096cbe5bfe 100644 --- a/test/EFCore.SqlServer.FunctionalTests/CompositeKeyEndToEndSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/CompositeKeyEndToEndSqlServerTest.cs @@ -15,7 +15,8 @@ public CompositeKeyEndToEndSqlServerTest(CompositeKeyEndToEndSqlServerFixture fi public class CompositeKeyEndToEndSqlServerFixture : CompositeKeyEndToEndFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/ComputedColumnTest.cs b/test/EFCore.SqlServer.FunctionalTests/ComputedColumnTest.cs index a326e2832ce..bd001b05076 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ComputedColumnTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ComputedColumnTest.cs @@ -155,6 +155,7 @@ public ComputedColumnTest() protected SqlServerTestStore TestStore { get; } - public virtual void Dispose() => TestStore.Dispose(); + public virtual void Dispose() + => TestStore.Dispose(); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/ConferencePlannerSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ConferencePlannerSqlServerTest.cs index 8280d88b38c..6f473b6d20c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ConferencePlannerSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ConferencePlannerSqlServerTest.cs @@ -20,7 +20,8 @@ protected override void UseTransaction(DatabaseFacade facade, IDbContextTransact public class ConferencePlannerSqlServerFixture : ConferencePlannerFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs index c6cf5271bea..b6ebd893910 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ConnectionInterceptionSqlServerTest.cs @@ -21,8 +21,11 @@ protected ConnectionInterceptionSqlServerTestBase(InterceptionSqlServerFixtureBa public abstract class InterceptionSqlServerFixtureBase : InterceptionFixtureBase { - protected override string StoreName => "ConnectionInterception"; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override string StoreName + => "ConnectionInterception"; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override IServiceCollection InjectInterceptors( IServiceCollection serviceCollection, @@ -36,15 +39,33 @@ protected override BadUniverseContext CreateBadUniverse(DbContextOptionsBuilder public class FakeDbConnection : DbConnection { public override string ConnectionString { get; set; } - public override string Database => "Database"; - public override string DataSource => "DataSource"; - public override string ServerVersion => throw new NotImplementedException(); - public override ConnectionState State => ConnectionState.Closed; - 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(IsolationLevel isolationLevel) => throw new NotImplementedException(); - protected override DbCommand CreateDbCommand() => throw new NotImplementedException(); + + public override string Database + => "Database"; + + public override string DataSource + => "DataSource"; + + public override string ServerVersion + => throw new NotImplementedException(); + + public override ConnectionState State + => ConnectionState.Closed; + + 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(IsolationLevel isolationLevel) + => throw new NotImplementedException(); + + protected override DbCommand CreateDbCommand() + => throw new NotImplementedException(); } public class ConnectionInterceptionSqlServerTest @@ -57,7 +78,8 @@ public ConnectionInterceptionSqlServerTest(InterceptionSqlServerFixture fixture) public class InterceptionSqlServerFixture : InterceptionSqlServerFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => false; + protected override bool ShouldSubscribeToDiagnosticListener + => false; } } @@ -72,7 +94,8 @@ public ConnectionInterceptionWithDiagnosticsSqlServerTest(InterceptionSqlServerF public class InterceptionSqlServerFixture : InterceptionSqlServerFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => true; + protected override bool ShouldSubscribeToDiagnosticListener + => true; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs index 3908752dfc5..6631b6a7083 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs @@ -173,21 +173,29 @@ public override void Object_to_string_conversion() public class ConvertToProviderTypesSqlServerFixture : ConvertToProviderTypesFixtureBase { - public override bool StrictEquality => true; + public override bool StrictEquality + => true; - public override bool SupportsAnsi => true; + public override bool SupportsAnsi + => true; - public override bool SupportsUnicodeToAnsiConversion => true; + public override bool SupportsUnicodeToAnsiConversion + => true; - public override bool SupportsLargeStringComparisons => true; + public override bool SupportsLargeStringComparisons + => true; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; - public override bool SupportsBinaryKeys => true; + public override bool SupportsBinaryKeys + => true; - public override bool SupportsDecimalComparisons => true; + public override bool SupportsDecimalComparisons + => true; - public override DateTime DefaultDateTime => new DateTime(); + public override DateTime DefaultDateTime + => new DateTime(); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base diff --git a/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs index e9c8c18cde2..fa4f483a88c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/CustomConvertersSqlServerTest.cs @@ -269,21 +269,32 @@ private void AssertSql(params string[] expected) public class CustomConvertersSqlServerFixture : CustomConvertersFixtureBase { - public override bool StrictEquality => true; + public override bool StrictEquality + => true; - public override bool SupportsAnsi => true; + public override bool SupportsAnsi + => true; - public override bool SupportsUnicodeToAnsiConversion => true; + public override bool SupportsUnicodeToAnsiConversion + => true; - public override bool SupportsLargeStringComparisons => true; + public override bool SupportsLargeStringComparisons + => true; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - public override bool SupportsBinaryKeys => true; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; - public override bool SupportsDecimalComparisons => true; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; - public override DateTime DefaultDateTime => new DateTime(); + public override bool SupportsBinaryKeys + => true; + + public override bool SupportsDecimalComparisons + => true; + + public override DateTime DefaultDateTime + => new DateTime(); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base diff --git a/test/EFCore.SqlServer.FunctionalTests/DataAnnotationSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/DataAnnotationSqlServerTest.cs index 329e3d6b603..b7a8a869b08 100644 --- a/test/EFCore.SqlServer.FunctionalTests/DataAnnotationSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/DataAnnotationSqlServerTest.cs @@ -131,7 +131,8 @@ public virtual void ColumnAttribute_configures_the_property_correctly() var modelBuilder = CreateModelBuilder(); modelBuilder.Entity(); - Assert.Equal("Name", + Assert.Equal( + "Name", modelBuilder.Model.FindEntityType(typeof(One)).FindProperty(nameof(One.RequiredColumn)).GetColumnName()); } @@ -277,8 +278,11 @@ private void AssertSql(params string[] expected) public class DataAnnotationSqlServerFixture : DataAnnotationFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs b/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs index ca315f21845..8eeeee5cdd6 100644 --- a/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs @@ -570,10 +570,12 @@ public void Change_tracker_can_be_cleared_without_resetting_context_config() } private bool _changeTracker_OnTracked; + private void ChangeTracker_OnTracked(object sender, EntityTrackedEventArgs e) => _changeTracker_OnTracked = true; private bool _changeTracker_OnStateChanged; + private void ChangeTracker_OnStateChanged(object sender, EntityStateChangedEventArgs e) => _changeTracker_OnStateChanged = true; @@ -683,7 +685,8 @@ public void State_manager_is_reset(bool useInterface) Assert.False(weakRef.IsAlive); } - private static T Scoper(Func getter) => getter(); + private static T Scoper(Func getter) + => getter(); [ConditionalFact] public void State_manager_is_reset_with_factory() @@ -819,7 +822,6 @@ public void Double_dispose_does_not_enter_pool_twice(bool useInterface) Assert.NotSame(lease1.Context, lease2.Context); } - [ConditionalTheory] [InlineData(true)] [InlineData(false)] diff --git a/test/EFCore.SqlServer.FunctionalTests/DefaultValuesTest.cs b/test/EFCore.SqlServer.FunctionalTests/DefaultValuesTest.cs index 551e7be7042..149adfbf390 100644 --- a/test/EFCore.SqlServer.FunctionalTests/DefaultValuesTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/DefaultValuesTest.cs @@ -100,6 +100,7 @@ public DefaultValuesTest() protected SqlServerTestStore TestStore { get; } - public virtual void Dispose() => TestStore.Dispose(); + public virtual void Dispose() + => TestStore.Dispose(); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs index 25ef159a987..bab2b9a1c5b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/EverythingIsBytesSqlServerTest.cs @@ -195,23 +195,31 @@ public override void Can_compare_enum_to_parameter() public class EverythingIsBytesSqlServerFixture : BuiltInDataTypesFixtureBase { - public override bool StrictEquality => true; + public override bool StrictEquality + => true; - public override bool SupportsAnsi => true; + public override bool SupportsAnsi + => true; - public override bool SupportsUnicodeToAnsiConversion => false; + public override bool SupportsUnicodeToAnsiConversion + => false; - public override bool SupportsLargeStringComparisons => true; + public override bool SupportsLargeStringComparisons + => true; protected override string StoreName { get; } = "EverythingIsBytes"; - protected override ITestStoreFactory TestStoreFactory => SqlServerBytesTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerBytesTestStoreFactory.Instance; - public override bool SupportsBinaryKeys => true; + public override bool SupportsBinaryKeys + => true; - public override bool SupportsDecimalComparisons => true; + public override bool SupportsDecimalComparisons + => true; - public override DateTime DefaultDateTime => new DateTime(); + public override DateTime DefaultDateTime + => new DateTime(); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base diff --git a/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs index f466ae35f92..8623d81de5d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/EverythingIsStringsSqlServerTest.cs @@ -191,23 +191,31 @@ public override void Can_compare_enum_to_parameter() public class EverythingIsStringsSqlServerFixture : BuiltInDataTypesFixtureBase { - public override bool StrictEquality => true; + public override bool StrictEquality + => true; - public override bool SupportsAnsi => true; + public override bool SupportsAnsi + => true; - public override bool SupportsUnicodeToAnsiConversion => true; + public override bool SupportsUnicodeToAnsiConversion + => true; - public override bool SupportsLargeStringComparisons => true; + public override bool SupportsLargeStringComparisons + => true; protected override string StoreName { get; } = "EverythingIsStrings"; - protected override ITestStoreFactory TestStoreFactory => SqlServerStringsTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerStringsTestStoreFactory.Instance; - public override bool SupportsBinaryKeys => true; + public override bool SupportsBinaryKeys + => true; - public override bool SupportsDecimalComparisons => true; + public override bool SupportsDecimalComparisons + => true; - public override DateTime DefaultDateTime => new DateTime(); + public override DateTime DefaultDateTime + => new DateTime(); public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base diff --git a/test/EFCore.SqlServer.FunctionalTests/ExecutionStrategyTest.cs b/test/EFCore.SqlServer.FunctionalTests/ExecutionStrategyTest.cs index 1b5c46cea26..3d4edbf054a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ExecutionStrategyTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ExecutionStrategyTest.cs @@ -199,7 +199,8 @@ await Test_commit_failure_async( } private async Task Test_commit_failure_async( - bool realFailure, Func execute) + bool realFailure, + Func execute) { CleanContext(); @@ -278,7 +279,10 @@ public void Handles_commit_failure_multiple_SaveChanges(bool realFailure) [ConditionalTheory] [MemberData(nameof(DataGenerator.GetBoolCombinations), 4, MemberType = typeof(DataGenerator))] public async Task Retries_SaveChanges_on_execution_failure( - bool realFailure, bool externalStrategy, bool openConnection, bool async) + bool realFailure, + bool externalStrategy, + bool openConnection, + bool async) { CleanContext(); @@ -648,11 +652,20 @@ private void CleanContext() public class ExecutionStrategyFixture : SharedStoreFixtureBase { - protected override bool UsePooling => false; + protected override bool UsePooling + => false; + protected override string StoreName { get; } = nameof(ExecutionStrategyTest); - public new RelationalTestStore TestStore => (RelationalTestStore)base.TestStore; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + + public new RelationalTestStore TestStore + => (RelationalTestStore)base.TestStore; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; + protected override Type ContextType { get; } = typeof(ExecutionStrategyContext); protected override IServiceCollection AddServices(IServiceCollection serviceCollection) diff --git a/test/EFCore.SqlServer.FunctionalTests/F1SqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/F1SqlServerFixture.cs index dabf9dd146d..d3727505722 100644 --- a/test/EFCore.SqlServer.FunctionalTests/F1SqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/F1SqlServerFixture.cs @@ -8,8 +8,11 @@ namespace Microsoft.EntityFrameworkCore { public class F1SqlServerFixture : F1RelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; - public override TestHelpers TestHelpers => SqlServerTestHelpers.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; + + public override TestHelpers TestHelpers + => SqlServerTestHelpers.Instance; protected override void BuildModelExternal(ModelBuilder modelBuilder) { diff --git a/test/EFCore.SqlServer.FunctionalTests/FieldMappingSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/FieldMappingSqlServerTest.cs index 59c952653eb..6ae9cdd8652 100644 --- a/test/EFCore.SqlServer.FunctionalTests/FieldMappingSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/FieldMappingSqlServerTest.cs @@ -19,7 +19,8 @@ protected override void UseTransaction(DatabaseFacade facade, IDbContextTransact public class FieldMappingSqlServerFixture : FieldMappingFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/FindSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/FindSqlServerTest.cs index 6c983fd5755..3d8326d7068 100644 --- a/test/EFCore.SqlServer.FunctionalTests/FindSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/FindSqlServerTest.cs @@ -319,15 +319,19 @@ FROM [ShadowKey] AS [s] WHERE [s].[Id] = @__p_0"); } - private string Sql => Fixture.TestSqlLoggerFactory.Sql; + private string Sql + => Fixture.TestSqlLoggerFactory.Sql; private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); public class FindSqlServerFixture : FindFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerTest.cs index 27edcbdca6c..cfd0f7db27e 100644 --- a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerTest.cs @@ -22,7 +22,8 @@ protected override void UseTransaction(DatabaseFacade facade, IDbContextTransact public class SqlServerFixture : GraphUpdatesSqlServerFixtureBase { - public override bool NoStoreCascades => true; + public override bool NoStoreCascades + => true; protected override string StoreName { get; } = "GraphClientCascadeUpdatesTest"; @@ -32,7 +33,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con foreach (var foreignKey in modelBuilder.Model .GetEntityTypes() - .SelectMany(e => MutableEntityTypeExtensions.GetDeclaredForeignKeys(e)) + .SelectMany(e => e.GetDeclaredForeignKeys()) .Where(e => e.DeleteBehavior == DeleteBehavior.Cascade)) { foreignKey.DeleteBehavior = DeleteBehavior.ClientCascade; @@ -53,7 +54,8 @@ protected override void UseTransaction(DatabaseFacade facade, IDbContextTransact public class SqlServerFixture : GraphUpdatesSqlServerFixtureBase { - public override bool ForceClientNoAction => true; + public override bool ForceClientNoAction + => true; protected override string StoreName { get; } = "GraphClientNoActionUpdatesTest"; @@ -125,15 +127,19 @@ protected GraphUpdatesSqlServerTestBase(TFixture fixture) { } - protected override IQueryable ModifyQueryRoot(IQueryable query) => query.AsSplitQuery(); + protected override IQueryable ModifyQueryRoot(IQueryable query) + => query.AsSplitQuery(); protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); public abstract class GraphUpdatesSqlServerFixtureBase : GraphUpdatesFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/ProxyGraphUpdatesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/ProxyGraphUpdatesSqlServerTest.cs index 0f7c2e26239..509e7aa7706 100644 --- a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/ProxyGraphUpdatesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/ProxyGraphUpdatesSqlServerTest.cs @@ -23,8 +23,11 @@ protected override void UseTransaction(DatabaseFacade facade, IDbContextTransact public abstract class ProxyGraphUpdatesSqlServerFixtureBase : ProxyGraphUpdatesFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } @@ -35,8 +38,11 @@ public LazyLoading(ProxyGraphUpdatesWithLazyLoadingSqlServerFixture fixture) { } - protected override bool DoesLazyLoading => true; - protected override bool DoesChangeTracking => false; + protected override bool DoesLazyLoading + => true; + + protected override bool DoesChangeTracking + => false; public class ProxyGraphUpdatesWithLazyLoadingSqlServerFixture : ProxyGraphUpdatesSqlServerFixtureBase { @@ -64,8 +70,11 @@ public ChangeTracking(ProxyGraphUpdatesWithChangeTrackingSqlServerFixture fixtur { } - protected override bool DoesLazyLoading => false; - protected override bool DoesChangeTracking => true; + protected override bool DoesLazyLoading + => false; + + protected override bool DoesChangeTracking + => true; public class ProxyGraphUpdatesWithChangeTrackingSqlServerFixture : ProxyGraphUpdatesSqlServerFixtureBase { @@ -86,15 +95,19 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con } } - public class ChangeTrackingAndLazyLoading : ProxyGraphUpdatesSqlServerTestBase + public class ChangeTrackingAndLazyLoading : ProxyGraphUpdatesSqlServerTestBase< + ChangeTrackingAndLazyLoading.ProxyGraphUpdatesWithChangeTrackingAndLazyLoadingSqlServerFixture> { public ChangeTrackingAndLazyLoading(ProxyGraphUpdatesWithChangeTrackingAndLazyLoadingSqlServerFixture fixture) : base(fixture) { } - protected override bool DoesLazyLoading => true; - protected override bool DoesChangeTracking => true; + protected override bool DoesLazyLoading + => true; + + protected override bool DoesChangeTracking + => true; public class ProxyGraphUpdatesWithChangeTrackingAndLazyLoadingSqlServerFixture : ProxyGraphUpdatesSqlServerFixtureBase { diff --git a/test/EFCore.SqlServer.FunctionalTests/LazyLoadProxySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/LazyLoadProxySqlServerTest.cs index 975c89a3490..826c23ad5a8 100644 --- a/test/EFCore.SqlServer.FunctionalTests/LazyLoadProxySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/LazyLoadProxySqlServerTest.cs @@ -178,7 +178,8 @@ public override void Lazy_load_collection_already_loaded(EntityState state, Casc } public override void Lazy_load_many_to_one_reference_to_principal_already_loaded( - EntityState state, CascadeTiming cascadeDeleteTiming) + EntityState state, + CascadeTiming cascadeDeleteTiming) { base.Lazy_load_many_to_one_reference_to_principal_already_loaded(state, cascadeDeleteTiming); @@ -193,7 +194,8 @@ public override void Lazy_load_one_to_one_reference_to_principal_already_loaded( } public override void Lazy_load_one_to_one_reference_to_dependent_already_loaded( - EntityState state, CascadeTiming cascadeDeleteTiming) + EntityState state, + CascadeTiming cascadeDeleteTiming) { base.Lazy_load_one_to_one_reference_to_dependent_already_loaded(state, cascadeDeleteTiming); @@ -461,16 +463,21 @@ FROM [Child] AS [c] ignoreLineEndingDifferences: true); } - protected override void ClearLog() => Fixture.TestSqlLoggerFactory.Clear(); + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); - protected override void RecordLog() => Sql = Fixture.TestSqlLoggerFactory.Sql; + protected override void RecordLog() + => Sql = Fixture.TestSqlLoggerFactory.Sql; private string Sql { get; set; } public class LoadSqlServerFixture : LoadFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/LoadSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/LoadSqlServerTest.cs index 24e987aad5a..d815fc167eb 100644 --- a/test/EFCore.SqlServer.FunctionalTests/LoadSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/LoadSqlServerTest.cs @@ -174,7 +174,8 @@ public override void Lazy_load_one_to_one_reference_to_principal_already_loaded( } public override void Lazy_load_one_to_one_reference_to_dependent_already_loaded( - EntityState state, CascadeTiming cascadeDeleteTiming) + EntityState state, + CascadeTiming cascadeDeleteTiming) { base.Lazy_load_one_to_one_reference_to_dependent_already_loaded(state, cascadeDeleteTiming); @@ -662,7 +663,9 @@ public override async Task Load_many_to_one_reference_to_principal_already_loade } public override async Task Load_one_to_one_reference_to_principal_already_loaded( - EntityState state, bool async, CascadeTiming cascadeDeleteTiming) + EntityState state, + bool async, + CascadeTiming cascadeDeleteTiming) { await base.Load_one_to_one_reference_to_principal_already_loaded(state, async, cascadeDeleteTiming); @@ -670,7 +673,9 @@ public override async Task Load_one_to_one_reference_to_principal_already_loaded } public override async Task Load_one_to_one_reference_to_dependent_already_loaded( - EntityState state, bool async, CascadeTiming cascadeDeleteTiming) + EntityState state, + bool async, + CascadeTiming cascadeDeleteTiming) { await base.Load_one_to_one_reference_to_dependent_already_loaded(state, async, cascadeDeleteTiming); @@ -692,7 +697,9 @@ public override async Task Load_one_to_one_PK_to_PK_reference_to_dependent_alrea } public override async Task Load_collection_using_Query_already_loaded( - EntityState state, bool async, CascadeTiming cascadeDeleteTiming) + EntityState state, + bool async, + CascadeTiming cascadeDeleteTiming) { await base.Load_collection_using_Query_already_loaded(state, async, cascadeDeleteTiming); @@ -729,7 +736,9 @@ FROM [Parent] AS [p] } public override async Task Load_one_to_one_reference_to_dependent_using_Query_already_loaded( - EntityState state, bool async, CascadeTiming cascadeDeleteTiming) + EntityState state, + bool async, + CascadeTiming cascadeDeleteTiming) { await base.Load_one_to_one_reference_to_dependent_using_Query_already_loaded(state, async, cascadeDeleteTiming); @@ -979,7 +988,9 @@ public override async Task Load_one_to_one_reference_to_principal_already_loaded } public override async Task Load_one_to_one_reference_to_dependent_already_loaded_untyped( - EntityState state, bool async, CascadeTiming cascadeDeleteTiming) + EntityState state, + bool async, + CascadeTiming cascadeDeleteTiming) { await base.Load_one_to_one_reference_to_dependent_already_loaded_untyped(state, async, cascadeDeleteTiming); @@ -987,7 +998,9 @@ public override async Task Load_one_to_one_reference_to_dependent_already_loaded } public override async Task Load_collection_using_Query_already_loaded_untyped( - EntityState state, bool async, CascadeTiming cascadeDeleteTiming) + EntityState state, + bool async, + CascadeTiming cascadeDeleteTiming) { await base.Load_collection_using_Query_already_loaded_untyped(state, async, cascadeDeleteTiming); @@ -1024,7 +1037,9 @@ FROM [Parent] AS [p] } public override async Task Load_one_to_one_reference_to_dependent_using_Query_already_loaded_untyped( - EntityState state, bool async, CascadeTiming cascadeDeleteTiming) + EntityState state, + bool async, + CascadeTiming cascadeDeleteTiming) { await base.Load_one_to_one_reference_to_dependent_using_Query_already_loaded_untyped(state, async, cascadeDeleteTiming); @@ -1434,9 +1449,11 @@ FROM [Parent] AS [p] WHERE 0 = 1"); } - protected override void ClearLog() => Fixture.TestSqlLoggerFactory.Clear(); + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); - protected override void RecordLog() => Sql = Fixture.TestSqlLoggerFactory.Sql; + protected override void RecordLog() + => Sql = Fixture.TestSqlLoggerFactory.Sql; private const string FileNewLine = @" "; @@ -1485,8 +1502,11 @@ private void AssertSql(string expected) public class LoadSqlServerFixture : LoadFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/LoggingSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/LoggingSqlServerTest.cs index 95fe2accb1f..a8f798f91d0 100644 --- a/test/EFCore.SqlServer.FunctionalTests/LoggingSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/LoggingSqlServerTest.cs @@ -18,6 +18,7 @@ protected override DbContextOptionsBuilder CreateOptionsBuilder( .UseInternalServiceProvider(services.AddEntityFrameworkSqlServer().BuildServiceProvider()) .UseSqlServer("Data Source=LoggingSqlServerTest.db", relationalAction); - protected override string ProviderName => "Microsoft.EntityFrameworkCore.SqlServer"; + protected override string ProviderName + => "Microsoft.EntityFrameworkCore.SqlServer"; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/ManyToManyLoadSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ManyToManyLoadSqlServerTest.cs index 5d94343a113..68a402bfc7e 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ManyToManyLoadSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ManyToManyLoadSqlServerTest.cs @@ -42,9 +42,11 @@ FROM [JoinOneToTwo] AS [j0] ORDER BY [e].[Id], [t].[OneId], [t].[TwoId], [t].[Id], [t0].[OneId], [t0].[TwoId], [t0].[Id]"); } - protected override void ClearLog() => Fixture.TestSqlLoggerFactory.Clear(); + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); - protected override void RecordLog() => Sql = Fixture.TestSqlLoggerFactory.Sql; + protected override void RecordLog() + => Sql = Fixture.TestSqlLoggerFactory.Sql; private const string FileNewLine = @" "; @@ -93,9 +95,11 @@ private void AssertSql(string expected) public class ManyToManyLoadSqlServerFixture : ManyToManyLoadFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.SqlServer.FunctionalTests/ManyToManyTrackingProxySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ManyToManyTrackingProxySqlServerTest.cs index 62a659057bc..de062222dfe 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ManyToManyTrackingProxySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ManyToManyTrackingProxySqlServerTest.cs @@ -13,7 +13,8 @@ public ManyToManyTrackingProxySqlServerTest(ManyToManyTrackingProxySqlServerFixt { } - protected override bool RequiresDetectChanges => false; + protected override bool RequiresDetectChanges + => false; public class ManyToManyTrackingProxySqlServerFixture : ManyToManyTrackingSqlServerFixtureBase { diff --git a/test/EFCore.SqlServer.FunctionalTests/ManyToManyTrackingSqlServerTestBase.cs b/test/EFCore.SqlServer.FunctionalTests/ManyToManyTrackingSqlServerTestBase.cs index 9c0165cbba0..a88472ec150 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ManyToManyTrackingSqlServerTestBase.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ManyToManyTrackingSqlServerTestBase.cs @@ -22,7 +22,8 @@ protected override void UseTransaction(DatabaseFacade facade, IDbContextTransact public class ManyToManyTrackingSqlServerFixtureBase : ManyToManyTrackingFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.SqlServer.FunctionalTests/MemoryOptimizedTablesTest.cs b/test/EFCore.SqlServer.FunctionalTests/MemoryOptimizedTablesTest.cs index 3cf21200008..f15b9708893 100644 --- a/test/EFCore.SqlServer.FunctionalTests/MemoryOptimizedTablesTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/MemoryOptimizedTablesTest.cs @@ -17,7 +17,8 @@ public class MemoryOptimizedTablesTest : IClassFixture Fixture = fixture; + public MemoryOptimizedTablesTest(MemoryOptimizedTablesFixture fixture) + => Fixture = fixture; [ConditionalFact] public void Can_create_memoryOptimized_table() @@ -52,11 +53,13 @@ protected TestStore CreateTestStore() return TestStore; } - private MemoryOptimizedContext CreateContext() => new MemoryOptimizedContext(Fixture.CreateOptions(TestStore)); + private MemoryOptimizedContext CreateContext() + => new MemoryOptimizedContext(Fixture.CreateOptions(TestStore)); public class MemoryOptimizedTablesFixture : ServiceProviderFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } private class MemoryOptimizedContext : DbContext diff --git a/test/EFCore.SqlServer.FunctionalTests/MigrationsInfrastructureSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/MigrationsInfrastructureSqlServerTest.cs index fd38f206c21..a3c9b45d577 100644 --- a/test/EFCore.SqlServer.FunctionalTests/MigrationsInfrastructureSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/MigrationsInfrastructureSqlServerTest.cs @@ -1396,7 +1396,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) public class MigrationsInfrastructureSqlServerFixture : MigrationsInfrastructureFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; public MigrationsInfrastructureSqlServerFixture() { diff --git a/test/EFCore.SqlServer.FunctionalTests/MigrationsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/MigrationsSqlServerTest.cs index f5f4d040086..dc763a93f38 100644 --- a/test/EFCore.SqlServer.FunctionalTests/MigrationsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/MigrationsSqlServerTest.cs @@ -23,7 +23,8 @@ namespace Microsoft.EntityFrameworkCore { public class MigrationsSqlServerTest : MigrationsTestBase { - protected static string EOL => Environment.NewLine; + protected static string EOL + => Environment.NewLine; public MigrationsSqlServerTest(MigrationsSqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -1795,8 +1796,12 @@ protected override ReferentialAction Normalize(ReferentialAction value) public class MigrationsSqlServerFixture : MigrationsFixtureBase { protected override string StoreName { get; } = nameof(MigrationsSqlServerTest); - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; - public override TestHelpers TestHelpers => SqlServerTestHelpers.Instance; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; + + public override TestHelpers TestHelpers + => SqlServerTestHelpers.Instance; protected override IServiceCollection AddServices(IServiceCollection serviceCollection) => base.AddServices(serviceCollection) diff --git a/test/EFCore.SqlServer.FunctionalTests/MonsterFixupChangedChangingSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/MonsterFixupChangedChangingSqlServerTest.cs index 4c08b512a68..e44638a4134 100644 --- a/test/EFCore.SqlServer.FunctionalTests/MonsterFixupChangedChangingSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/MonsterFixupChangedChangingSqlServerTest.cs @@ -15,7 +15,8 @@ public MonsterFixupChangedChangingSqlServerTest(MonsterFixupChangedChangingSqlSe public class MonsterFixupChangedChangingSqlServerFixture : MonsterFixupChangedChangingFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override void OnModelCreating( ModelBuilder builder) diff --git a/test/EFCore.SqlServer.FunctionalTests/MusicStoreSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/MusicStoreSqlServerTest.cs index 06cfdcff155..75668b569d5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/MusicStoreSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/MusicStoreSqlServerTest.cs @@ -14,7 +14,8 @@ public MusicStoreSqlServerTest(MusicStoreSqlServerFixture fixture) public class MusicStoreSqlServerFixture : MusicStoreFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/NavigationTest.cs b/test/EFCore.SqlServer.FunctionalTests/NavigationTest.cs index 23c028ca4fc..6607424aa67 100644 --- a/test/EFCore.SqlServer.FunctionalTests/NavigationTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/NavigationTest.cs @@ -61,7 +61,8 @@ public void Duplicate_entries_are_not_created_for_navigations_to_dependent() private readonly NavigationTestFixture _fixture; - public NavigationTest(NavigationTestFixture fixture) => _fixture = fixture; + public NavigationTest(NavigationTestFixture fixture) + => _fixture = fixture; } public class GoTPerson @@ -85,7 +86,8 @@ public GoTContext(DbContextOptions options) public DbSet People { get; set; } public Func ConfigAction { get; set; } - protected override void OnModelCreating(ModelBuilder modelBuilder) => ConfigAction.Invoke(modelBuilder); + protected override void OnModelCreating(ModelBuilder modelBuilder) + => ConfigAction.Invoke(modelBuilder); } public class NavigationTestFixture @@ -111,6 +113,7 @@ public NavigationTestFixture() .Options; } - public virtual GoTContext CreateContext() => new GoTContext(_options); + public virtual GoTContext CreateContext() + => new GoTContext(_options); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/NotificationEntitiesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/NotificationEntitiesSqlServerTest.cs index 70f81e4cf0e..bfac9e52bfb 100644 --- a/test/EFCore.SqlServer.FunctionalTests/NotificationEntitiesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/NotificationEntitiesSqlServerTest.cs @@ -15,7 +15,8 @@ public NotificationEntitiesSqlServerTest(NotificationEntitiesSqlServerFixture fi public class NotificationEntitiesSqlServerFixture : NotificationEntitiesFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/OverzealousInitializationSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/OverzealousInitializationSqlServerTest.cs index af1a8560503..77c7dc0d391 100644 --- a/test/EFCore.SqlServer.FunctionalTests/OverzealousInitializationSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/OverzealousInitializationSqlServerTest.cs @@ -15,7 +15,8 @@ public OverzealousInitializationSqlServerTest(OverzealousInitializationSqlServer public class OverzealousInitializationSqlServerFixture : OverzealousInitializationFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/PropertyValuesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/PropertyValuesSqlServerTest.cs index 2d0ac93fff3..6ae31090154 100644 --- a/test/EFCore.SqlServer.FunctionalTests/PropertyValuesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/PropertyValuesSqlServerTest.cs @@ -14,7 +14,8 @@ public PropertyValuesSqlServerTest(PropertyValuesSqlServerFixture fixture) public class PropertyValuesSqlServerFixture : PropertyValuesFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AsyncGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AsyncGearsOfWarQuerySqlServerTest.cs index b7bb3601bf0..b0a21b1f4e6 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AsyncGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/AsyncGearsOfWarQuerySqlServerTest.cs @@ -14,6 +14,7 @@ public AsyncGearsOfWarQuerySqlServerTest(GearsOfWarQuerySqlServerFixture fixture //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerFixture.cs index e2c30b68fdf..df0ffad0182 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class ComplexNavigationsQuerySqlServerFixture : ComplexNavigationsQueryRelationalFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs index ac099482ab0..85e85bd1385 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs @@ -12,14 +12,16 @@ namespace Microsoft.EntityFrameworkCore.Query public class ComplexNavigationsQuerySqlServerTest : ComplexNavigationsQueryRelationalTestBase { public ComplexNavigationsQuerySqlServerTest( - ComplexNavigationsQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + ComplexNavigationsQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task Entity_equality_empty(bool async) { @@ -4774,9 +4776,11 @@ ORDER BY [l0].[Id] ORDER BY [l].[Id], [t0].[Id], [t0].[Id0], [t0].[Id1]"); } - public override async Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async) + public override async Task + Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async) { - await base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async); + await base + .Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async); AssertSql( @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [t0].[Id1], [t0].[Level2_Optional_Id0], [t0].[Level2_Required_Id0], [t0].[Name1], [t0].[OneToMany_Optional_Inverse3Id0], [t0].[OneToMany_Optional_Self_Inverse3Id0], [t0].[OneToMany_Required_Inverse3Id0], [t0].[OneToMany_Required_Self_Inverse3Id0], [t0].[OneToOne_Optional_PK_Inverse3Id0], [t0].[OneToOne_Optional_Self3Id0] @@ -5413,9 +5417,11 @@ ORDER BY [l0].[Id] ORDER BY [l].[Id], [t0].[Id], [t0].[Id0]"); } - public override async Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(bool async) + public override async Task + Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(bool async) { - await base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(async); + await base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split( + async); AssertSql( @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] @@ -5848,6 +5854,7 @@ FROM [LevelOne] AS [l] ORDER BY [t].[Id], [l0].[Id]"); } - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerFixture.cs index e2bf0183079..7e41954e257 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class ComplexNavigationsWeakQuerySqlServerFixture : ComplexNavigationsWeakQueryRelationalFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerTest.cs index 986ba4bc846..3182abda89b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsWeakQuerySqlServerTest.cs @@ -6,10 +6,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class ComplexNavigationsWeakQuerySqlServerTest : ComplexNavigationsWeakQueryRelationalTestBase + public class ComplexNavigationsWeakQuerySqlServerTest : ComplexNavigationsWeakQueryRelationalTestBase< + ComplexNavigationsWeakQuerySqlServerFixture> { public ComplexNavigationsWeakQuerySqlServerTest( - ComplexNavigationsWeakQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + ComplexNavigationsWeakQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/FiltersInheritanceQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/FiltersInheritanceQuerySqlServerFixture.cs index ff37f61a244..879f172ac2a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/FiltersInheritanceQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/FiltersInheritanceQuerySqlServerFixture.cs @@ -5,6 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class FiltersInheritanceQuerySqlServerFixture : InheritanceQuerySqlServerFixture { - protected override bool EnableFilters => true; + protected override bool EnableFilters + => true; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs index 2236e9e7f3f..73db7f8a4e9 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.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.Data.Common; using System.Linq; using Microsoft.Data.SqlClient; @@ -47,7 +46,8 @@ public override string FromSqlRaw_queryable_composed() { var queryString = base.FromSqlRaw_queryable_composed(); - var expected = @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] + var expected = + @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM ( SELECT * FROM ""Customers"" ) AS [c] @@ -346,7 +346,8 @@ public override string FromSqlRaw_queryable_with_parameters_and_closure() ) AS [c] WHERE [c].[ContactTitle] = @__contactTitle_1"); - Assert.Equal(@"DECLARE p0 nvarchar(4000) = N'London'; + Assert.Equal( + @"DECLARE p0 nvarchar(4000) = N'London'; DECLARE @__contactTitle_1 nvarchar(4000) = N'Sales Representative'; SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlSprocQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlSprocQuerySqlServerTest.cs index 311e52dc1e0..86dbfe89068 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlSprocQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlSprocQuerySqlServerTest.cs @@ -82,8 +82,10 @@ public override async Task From_sql_queryable_stored_procedure_min_on_client(boo private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - protected override string TenMostExpensiveProductsSproc => "[dbo].[Ten Most Expensive Products]"; + protected override string TenMostExpensiveProductsSproc + => "[dbo].[Ten Most Expensive Products]"; - protected override string CustomerOrderHistorySproc => "[dbo].[CustOrderHist] @CustomerID = {0}"; + protected override string CustomerOrderHistorySproc + => "[dbo].[CustOrderHist] @CustomerID = {0}"; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs index 4ed58e66c0d..7c898921226 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/FunkyDataQuerySqlServerTest.cs @@ -16,10 +16,12 @@ public FunkyDataQuerySqlServerTest(FunkyDataQuerySqlServerFixture fixture, ITest //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected virtual bool CanExecuteQueryString => true; + protected virtual bool CanExecuteQueryString + => true; protected override QueryAsserter CreateQueryAsserter(FunkyDataQuerySqlServerFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); public override async Task String_contains_on_argument_with_wildcard_constant(bool async) { @@ -462,9 +464,11 @@ private void AssertSql(params string[] expected) public class FunkyDataQuerySqlServerFixture : FunkyDataQueryFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarFromSqlQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarFromSqlQuerySqlServerTest.cs index 9228a0e2b34..3dd95d9fc1d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarFromSqlQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarFromSqlQuerySqlServerTest.cs @@ -23,8 +23,10 @@ public override void From_sql_queryable_simple_columns_out_of_order() Sql); } - protected override void ClearLog() => Fixture.TestSqlLoggerFactory.Clear(); + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); - private string Sql => Fixture.TestSqlLoggerFactory.Sql; + private string Sql + => Fixture.TestSqlLoggerFactory.Sql; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerFixture.cs index 60a91321fb2..9b55f3712c5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerFixture.cs @@ -8,7 +8,8 @@ namespace Microsoft.EntityFrameworkCore.Query { public class GearsOfWarQuerySqlServerFixture : GearsOfWarQueryRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index 2a0fb173bda..52a9f50bd30 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -20,7 +20,8 @@ public GearsOfWarQuerySqlServerTest(GearsOfWarQuerySqlServerFixture fixture, ITe //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task Negate_on_binary_expression(bool async) { @@ -1564,7 +1565,7 @@ public override async Task Singleton_Navigation_With_Member_Access(bool async) await base.Singleton_Navigation_With_Member_Access(async); AssertSql( - @"SELECT [g].[CityOfBirthName] AS [B] + @"SELECT [g].[CityOfBirthName] AS [B] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE ([g].[Nickname] = N'Marcus') AND (([g].[CityOfBirthName] <> N'Ephyra') OR [g].[CityOfBirthName] IS NULL)"); @@ -5582,7 +5583,8 @@ FROM [Gears] AS [g] WHERE [g].[Nickname] <> N'Dom'"); } - public override async Task Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(bool async) + public override async Task + Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(bool async) { await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(async); @@ -5590,9 +5592,11 @@ public override async Task Null_semantics_is_correctly_applied_for_function_comp @""); } - public override async Task Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) + public override async Task + Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) { - await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(async); + await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex( + async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[Note] @@ -6541,7 +6545,8 @@ public override async Task Byte_array_filter_by_length_literal_does_not_cast_on_ { await base.Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(async); - AssertSql(@"SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] + AssertSql( + @"SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] WHERE DATALENGTH([s].[Banner5]) = 5"); } @@ -6640,7 +6645,8 @@ public override async Task Byte_array_filter_by_SequenceEqual(bool isAsync) { await base.Byte_array_filter_by_SequenceEqual(isAsync); - AssertSql(@"@__byteArrayParam_0='0x0405060708' (Size = 5) + AssertSql( + @"@__byteArrayParam_0='0x0405060708' (Size = 5) SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] @@ -6835,7 +6841,8 @@ CROSS JOIN [LocustLeaders] AS [l] WHERE CHARINDEX(CAST([l].[ThreatLevelByte] AS varbinary(max)), [s].[Banner]) > 0"); } - public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(bool async) + public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion( + bool async) { await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(async); @@ -6852,7 +6859,8 @@ FROM [LocustLeaders] AS [l0] ) AS [t]"); } - public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(bool async) + public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated( + bool async) { await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(async); @@ -7030,7 +7038,8 @@ LEFT JOIN [Weapons] AS [w] ON ([g].[FullName] <> [w].[OwnerFullName]) OR [w].[Ow ORDER BY [g].[Nickname], [w].[Id]"); } - public override async Task SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(bool async) + public override async Task SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join( + bool async) { await base.SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeOneToOneSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/IncludeOneToOneSqlServerTest.cs index 4043a35fc79..db81d761b07 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/IncludeOneToOneSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/IncludeOneToOneSqlServerTest.cs @@ -59,8 +59,11 @@ private void AssertSql(params string[] expected) public class OneToOneQuerySqlServerFixture : OneToOneQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqlServerFixture.cs index 1bfd349f97d..91d766cc203 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqlServerFixture.cs @@ -5,6 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class IncompleteMappingInheritanceQuerySqlServerFixture : InheritanceQuerySqlServerFixture { - protected override bool IsDiscriminatorMappingComplete => false; + protected override bool IsDiscriminatorMappingComplete + => false; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqlServerTest.cs index ff59f80c42c..26c8ff2730d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqlServerTest.cs @@ -9,11 +9,13 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public class IncompleteMappingInheritanceQuerySqlServerTest : InheritanceRelationalQueryTestBase + public class IncompleteMappingInheritanceQuerySqlServerTest : InheritanceRelationalQueryTestBase< + IncompleteMappingInheritanceQuerySqlServerFixture> { #pragma warning disable IDE0060 // Remove unused parameter public IncompleteMappingInheritanceQuerySqlServerTest( - IncompleteMappingInheritanceQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + IncompleteMappingInheritanceQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) #pragma warning restore IDE0060 // Remove unused parameter : base(fixture) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceQuerySqlServerFixture.cs index 1ded4aefe68..cf1d105dee2 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceQuerySqlServerFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class InheritanceQuerySqlServerFixture : InheritanceQueryRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceQuerySqlServerTest.cs index c4c529295a9..1d8185d60e6 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceQuerySqlServerTest.cs @@ -2,8 +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 Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestModels.InheritanceModel; using Xunit; using Xunit.Abstractions; diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs index 0ac18f23f8d..713b7ac7282 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/InheritanceRelationshipsQuerySqlServerTest.cs @@ -8,10 +8,12 @@ namespace Microsoft.EntityFrameworkCore.Query { public class InheritanceRelationshipsQuerySqlServerTest - : InheritanceRelationshipsQueryRelationalTestBase + : InheritanceRelationshipsQueryRelationalTestBase< + InheritanceRelationshipsQuerySqlServerTest.InheritanceRelationshipsQuerySqlServerFixture> { public InheritanceRelationshipsQuerySqlServerTest( - InheritanceRelationshipsQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + InheritanceRelationshipsQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { fixture.TestSqlLoggerFactory.Clear(); @@ -28,7 +30,6 @@ FROM [BaseEntities] AS [b] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [b].[Id] = [b1].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b2] ON [b].[Id] = [b2].[DerivedInheritanceRelationshipEntityId] ORDER BY [b].[Id], [b0].[Id], [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [b2].[DerivedInheritanceRelationshipEntityId], [b2].[Id]"); - } public override async Task Include_reference_with_inheritance_reverse(bool async) @@ -105,7 +106,6 @@ FROM [BaseReferencesOnBase] AS [b] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b2] ON [b0].[Id] = [b2].[DerivedInheritanceRelationshipEntityId] WHERE ([b].[Name] <> N'Bar') OR [b].[Name] IS NULL ORDER BY [b].[Id], [b0].[Id], [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [b2].[DerivedInheritanceRelationshipEntityId], [b2].[Id]"); - } public override async Task Include_reference_without_inheritance(bool async) @@ -119,7 +119,6 @@ FROM [BaseEntities] AS [b] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b0] ON [b].[Id] = [b0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b1] ON [b].[Id] = [b1].[DerivedInheritanceRelationshipEntityId] ORDER BY [b].[Id], [r].[Id], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [b1].[DerivedInheritanceRelationshipEntityId], [b1].[Id]"); - } public override async Task Include_reference_without_inheritance_reverse(bool async) @@ -133,7 +132,6 @@ FROM [ReferencesOnBase] AS [r] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b0] ON [b].[Id] = [b0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b1] ON [b].[Id] = [b1].[DerivedInheritanceRelationshipEntityId] ORDER BY [r].[Id], [b].[Id], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [b1].[DerivedInheritanceRelationshipEntityId], [b1].[Id]"); - } public override async Task Include_reference_without_inheritance_with_filter(bool async) @@ -333,7 +331,6 @@ FROM [BaseEntities] AS [b0] LEFT JOIN [BaseEntities_OwnedCollectionOnBase] AS [b1] ON [t].[Id] = [b1].[BaseInheritanceRelationshipEntityId] LEFT JOIN [BaseEntities_OwnedCollectionOnDerived] AS [b2] ON [t].[Id] = [b2].[DerivedInheritanceRelationshipEntityId] ORDER BY [b].[Id], [t].[Id], [b1].[BaseInheritanceRelationshipEntityId], [b1].[Id], [b2].[DerivedInheritanceRelationshipEntityId], [b2].[Id]"); - } public override async Task Include_reference_with_inheritance_on_derived_with_filter1(bool async) @@ -489,7 +486,6 @@ FROM [BaseCollectionsOnDerived] AS [b2] ) AS [t] ON [b].[Id] = [t].[DerivedInheritanceRelationshipEntityId] WHERE [b].[Discriminator] = N'DerivedInheritanceRelationshipEntity' ORDER BY [b].[Id], [b0].[BaseInheritanceRelationshipEntityId], [b0].[Id], [b1].[DerivedInheritanceRelationshipEntityId], [b1].[Id], [t].[Id]"); - } public override async Task Include_collection_with_inheritance_on_derived_reverse(bool async) @@ -1254,7 +1250,8 @@ private void AssertSql(params string[] expected) public class InheritanceRelationshipsQuerySqlServerFixture : InheritanceRelationshipsQueryRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyNoTrackingQuerySqlServerTest.cs index 6f81ef47120..49c783cae7c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyNoTrackingQuerySqlServerTest.cs @@ -16,7 +16,8 @@ public ManyToManyNoTrackingQuerySqlServerTest(ManyToManyQuerySqlServerFixture fi //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task Skip_navigation_all(bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerFixture.cs index d21d92df777..1f6b8d944ba 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class ManyToManyQuerySqlServerFixture : ManyToManyQueryRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs index a9c8e766841..6766a6cb4d2 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ManyToManyQuerySqlServerTest.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; using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query @@ -16,7 +15,8 @@ public ManyToManyQuerySqlServerTest(ManyToManyQuerySqlServerFixture fixture, ITe //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task Skip_navigation_all(bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/MappingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/MappingQuerySqlServerTest.cs index eb9e10e4d6b..c43486c71ec 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/MappingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/MappingQuerySqlServerTest.cs @@ -54,7 +54,8 @@ private void AssertSql(params string[] expected) public class MappingQuerySqlServerFixture : MappingQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerNorthwindTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerNorthwindTestStoreFactory.Instance; protected override string DatabaseSchema { get; } = "dbo"; diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs index 0fa302d2a66..d8b39f7d7f2 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs @@ -7,17 +7,20 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindAggregateOperatorsQuerySqlServerTest : NorthwindAggregateOperatorsQueryRelationalTestBase> + public class NorthwindAggregateOperatorsQuerySqlServerTest : NorthwindAggregateOperatorsQueryRelationalTestBase< + NorthwindQuerySqlServerFixture> { public NorthwindAggregateOperatorsQuerySqlServerTest( - NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { ClearLog(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override void Select_All() { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqlServerTest.cs index f517236a941..c963067d8ad 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsNoTrackingQuerySqlServerTest.cs @@ -6,10 +6,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindAsNoTrackingQuerySqlServerTest : NorthwindAsNoTrackingQueryTestBase> + public class NorthwindAsNoTrackingQuerySqlServerTest : NorthwindAsNoTrackingQueryTestBase< + NorthwindQuerySqlServerFixture> { public NorthwindAsNoTrackingQuerySqlServerTest( - NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsTrackingQuerySqlServerTest.cs index 1dbfb6e4749..a5d66fa1ac4 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsTrackingQuerySqlServerTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindAsTrackingQuerySqlServerTest : NorthwindAsTrackingQueryTestBase> + public class NorthwindAsTrackingQuerySqlServerTest : NorthwindAsTrackingQueryTestBase< + NorthwindQuerySqlServerFixture> { public NorthwindAsTrackingQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture) : base(fixture) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqlServerTest.cs index ebc22dc29e5..5e34a2486cb 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqlServerTest.cs @@ -13,18 +13,21 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindAsyncSimpleQuerySqlServerTest : NorthwindAsyncSimpleQueryRelationalTestBase> + public class NorthwindAsyncSimpleQuerySqlServerTest : NorthwindAsyncSimpleQueryRelationalTestBase< + NorthwindQuerySqlServerFixture> { // ReSharper disable once UnusedParameter.Local public NorthwindAsyncSimpleQuerySqlServerTest( - NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; [ConditionalFact] public override Task Throws_on_concurrent_query_list() diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindChangeTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindChangeTrackingQuerySqlServerTest.cs index aece2e25e23..a7a878b239a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindChangeTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindChangeTrackingQuerySqlServerTest.cs @@ -6,7 +6,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindChangeTrackingQuerySqlServerTest : NorthwindChangeTrackingQueryTestBase> + public class NorthwindChangeTrackingQuerySqlServerTest : NorthwindChangeTrackingQueryTestBase< + NorthwindQuerySqlServerFixture> { public NorthwindChangeTrackingQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture) : base(fixture) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindCompiledQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindCompiledQuerySqlServerTest.cs index a917c8210e1..dbc0fc24ce7 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindCompiledQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindCompiledQuerySqlServerTest.cs @@ -12,7 +12,9 @@ namespace Microsoft.EntityFrameworkCore.Query { public class NorthwindCompiledQuerySqlServerTest : NorthwindCompiledQueryTestBase> { - public NorthwindCompiledQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindCompiledQuerySqlServerTest( + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs index 1b1262610df..45b802ba9a2 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindDbFunctionsQuerySqlServerTest.cs @@ -14,10 +14,12 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindDbFunctionsQuerySqlServerTest : NorthwindDbFunctionsQueryRelationalTestBase> + public class NorthwindDbFunctionsQuerySqlServerTest : NorthwindDbFunctionsQueryRelationalTestBase< + NorthwindQuerySqlServerFixture> { public NorthwindDbFunctionsQuerySqlServerTest( - NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); @@ -74,8 +76,11 @@ FROM [Customers] AS [c] WHERE [c].[ContactName] COLLATE Latin1_General_CS_AS = N'maria anders'"); } - protected override string CaseInsensitiveCollation => "Latin1_General_CI_AI"; - protected override string CaseSensitiveCollation => "Latin1_General_CS_AS"; + protected override string CaseInsensitiveCollation + => "Latin1_General_CI_AI"; + + protected override string CaseSensitiveCollation + => "Latin1_General_CS_AS"; [ConditionalFact] [SqlServerCondition(SqlServerCondition.SupportsFullTextSearch)] @@ -596,9 +601,11 @@ public virtual void DateDiff_Week_datetime() { using var context = CreateContext(); var count = context.Orders - .Count(c => EF.Functions.DateDiffWeek( - c.OrderDate, - new DateTime(1998, 5, 6, 0, 0, 0)) == 5); + .Count( + c => EF.Functions.DateDiffWeek( + c.OrderDate, + new DateTime(1998, 5, 6, 0, 0, 0)) + == 5); Assert.Equal(16, count); @@ -613,9 +620,11 @@ public virtual void DateDiff_Week_datetimeoffset() { using var context = CreateContext(); var count = context.Orders - .Count(c => EF.Functions.DateDiffWeek( - c.OrderDate, - new DateTimeOffset(1998, 5, 6, 0, 0, 0, TimeSpan.Zero)) == 5); + .Count( + c => EF.Functions.DateDiffWeek( + c.OrderDate, + new DateTimeOffset(1998, 5, 6, 0, 0, 0, TimeSpan.Zero)) + == 5); Assert.Equal(16, count); @@ -630,9 +639,11 @@ public virtual void DateDiff_Week_parameters_null() { using var context = CreateContext(); var count = context.Orders - .Count(c => EF.Functions.DateDiffWeek( - null, - c.OrderDate) == 5); + .Count( + c => EF.Functions.DateDiffWeek( + null, + c.OrderDate) + == 5); Assert.Equal(0, count); @@ -744,11 +755,17 @@ await AssertCount( async, ss => ss.Set(), ss => ss.Set(), - c => dateTime > EF.Functions.DateTimeFromParts(DateTime.Now.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second, dateTime.Millisecond), - c => dateTime > new DateTime(DateTime.Now.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second, dateTime.Millisecond)); + c => dateTime + > EF.Functions.DateTimeFromParts( + DateTime.Now.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second, + dateTime.Millisecond), + c => dateTime + > new DateTime( + DateTime.Now.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second, + dateTime.Millisecond)); AssertSql( - @$"@__dateTime_0='1919-12-12T10:20:15.0000000' (DbType = DateTime) + @"@__dateTime_0='1919-12-12T10:20:15.0000000' (DbType = DateTime) @__dateTime_Month_2='12' @__dateTime_Day_3='12' @__dateTime_Hour_4='10' @@ -808,7 +825,7 @@ await AssertCount( c => date > new DateTime(DateTime.Now.Year, date.Month, date.Day)); AssertSql( - @$"@__date_0='1919-12-12T00:00:00.0000000' (DbType = Date) + @"@__date_0='1919-12-12T00:00:00.0000000' (DbType = Date) @__date_Month_2='12' @__date_Day_3='12' @@ -840,7 +857,9 @@ public virtual void DateTime2FromParts_constant_compare() using (var context = CreateContext()) { var count = context.Orders - .Count(c => new DateTime(2018, 12, 29, 23, 20, 40) > EF.Functions.DateTime2FromParts(DateTime.Now.Year, 12, 31, 23, 59, 59, 9999999, 7)); + .Count( + c => new DateTime(2018, 12, 29, 23, 20, 40) + > EF.Functions.DateTime2FromParts(DateTime.Now.Year, 12, 31, 23, 59, 59, 9999999, 7)); Assert.Equal(0, count); @@ -859,12 +878,16 @@ public virtual void DateTime2FromParts_compare_with_local_variable() using (var context = CreateContext()) { var count = context.Orders - .Count(c => dateTime > EF.Functions.DateTime2FromParts(DateTime.Now.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second, fractions, 7)); + .Count( + c => dateTime + > EF.Functions.DateTime2FromParts( + DateTime.Now.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second, fractions, + 7)); Assert.Equal(0, count); AssertSql( - @$"@__dateTime_0='1919-12-12T10:20:15.0000000' + @"@__dateTime_0='1919-12-12T10:20:15.0000000' @__dateTime_Month_2='12' @__dateTime_Day_3='12' @__dateTime_Hour_4='10' @@ -901,7 +924,9 @@ public virtual void DateTimeOffsetFromParts_constant_compare() using (var context = CreateContext()) { var count = context.Orders - .Count(c => new DateTimeOffset(2018, 12, 29, 23, 20, 40, new TimeSpan(1, 0, 0)) > EF.Functions.DateTimeOffsetFromParts(DateTime.Now.Year, 12, 31, 23, 59, 59, 50, 1, 0, 7)); + .Count( + c => new DateTimeOffset(2018, 12, 29, 23, 20, 40, new TimeSpan(1, 0, 0)) + > EF.Functions.DateTimeOffsetFromParts(DateTime.Now.Year, 12, 31, 23, 59, 59, 50, 1, 0, 7)); Assert.Equal(0, count); @@ -922,12 +947,16 @@ public virtual void DateTimeOffsetFromParts_compare_with_local_variable() using (var context = CreateContext()) { var count = context.Orders - .Count(c => dateTimeOffset > EF.Functions.DateTimeOffsetFromParts(DateTime.Now.Year, dateTimeOffset.Month, dateTimeOffset.Day, dateTimeOffset.Hour, dateTimeOffset.Minute, dateTimeOffset.Second, fractions, hourOffset, minuteOffset, 7)); + .Count( + c => dateTimeOffset + > EF.Functions.DateTimeOffsetFromParts( + DateTime.Now.Year, dateTimeOffset.Month, dateTimeOffset.Day, dateTimeOffset.Hour, dateTimeOffset.Minute, + dateTimeOffset.Second, fractions, hourOffset, minuteOffset, 7)); Assert.Equal(0, count); AssertSql( - @$"@__dateTimeOffset_0='1919-12-12T10:20:15.0000000+01:30' + @"@__dateTimeOffset_0='1919-12-12T10:20:15.0000000+01:30' @__dateTimeOffset_Month_2='12' @__dateTimeOffset_Day_3='12' @__dateTimeOffset_Hour_4='10' @@ -986,11 +1015,12 @@ await AssertCount( async, ss => ss.Set(), ss => ss.Set(), - c => dateTime > EF.Functions.SmallDateTimeFromParts(DateTime.Now.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute), + c => dateTime + > EF.Functions.SmallDateTimeFromParts(DateTime.Now.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute), c => dateTime > new DateTime(DateTime.Now.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, 0)); AssertSql( - @$"@__dateTime_0='1919-12-12T23:20:00.0000000' (DbType = DateTime) + @"@__dateTime_0='1919-12-12T23:20:00.0000000' (DbType = DateTime) @__dateTime_Month_2='12' @__dateTime_Day_3='12' @__dateTime_Hour_4='23' @@ -1064,7 +1094,7 @@ public virtual void DataLength_compare_with_local_variable() Assert.Equal(0, count); AssertSql( - @$"@__lenght_0='100' (Nullable = true) + @"@__lenght_0='100' (Nullable = true) SELECT COUNT(*) FROM [Orders] AS [o] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs index 0fbe2013361..9b51258677c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs @@ -10,11 +10,13 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindFunctionsQuerySqlServerTest : NorthwindFunctionsQueryRelationalTestBase> + public class NorthwindFunctionsQuerySqlServerTest : NorthwindFunctionsQueryRelationalTestBase< + NorthwindQuerySqlServerFixture> { public NorthwindFunctionsQuerySqlServerTest( #pragma warning disable IDE0060 // Remove unused parameter - NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) #pragma warning restore IDE0060 // Remove unused parameter : base(fixture) { @@ -22,7 +24,8 @@ public NorthwindFunctionsQuerySqlServerTest( Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task String_StartsWith_Literal(bool async) { @@ -891,10 +894,12 @@ FROM [Order Details] AS [o] } [ConditionalTheory(Skip = "Issue#17328")] - public override Task Where_math_min(bool async) => base.Where_math_min(async); + public override Task Where_math_min(bool async) + => base.Where_math_min(async); [ConditionalTheory(Skip = "Issue#17328")] - public override Task Where_math_max(bool async) => base.Where_math_max(async); + public override Task Where_math_max(bool async) + => base.Where_math_max(async); public override async Task Where_guid_newguid(bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs index bcc3c59854b..884336091dd 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.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.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -10,17 +9,21 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindGroupByQuerySqlServerTest : NorthwindGroupByQueryRelationalTestBase> + public class NorthwindGroupByQuerySqlServerTest : NorthwindGroupByQueryRelationalTestBase< + NorthwindQuerySqlServerFixture> { // ReSharper disable once UnusedParameter.Local - public NorthwindGroupByQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindGroupByQuerySqlServerTest( + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task GroupBy_Property_Select_Average(bool async) { @@ -1535,7 +1538,6 @@ FROM [Orders] AS [o] GROUP BY [o].[CustomerID]"); } - public override async Task GroupBy_Where_Count(bool async) { await base.GroupBy_Where_Count(async); @@ -2158,7 +2160,7 @@ FROM [Orders] AS [o] public override async Task GroupBy_Property_Select_LongCount_with_predicate(bool async) { - await base.GroupBy_Property_Select_LongCount_with_predicate(async); + await base.GroupBy_Property_Select_LongCount_with_predicate(async); AssertSql( @"SELECT COUNT_BIG(CASE diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs index 90135d75906..17f29837638 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs @@ -10,7 +10,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindIncludeNoTrackingQuerySqlServerTest : NorthwindIncludeNoTrackingQueryTestBase> + public class NorthwindIncludeNoTrackingQuerySqlServerTest : NorthwindIncludeNoTrackingQueryTestBase< + NorthwindQuerySqlServerFixture> { // ReSharper disable once UnusedParameter.Local public NorthwindIncludeNoTrackingQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs index 896a1f959df..297cba21499 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs @@ -9,17 +9,21 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindIncludeQuerySqlServerTest : NorthwindIncludeQueryRelationalTestBase> + public class NorthwindIncludeQuerySqlServerTest : NorthwindIncludeQueryRelationalTestBase< + NorthwindQuerySqlServerFixture> { // ReSharper disable once UnusedParameter.Local - public NorthwindIncludeQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindIncludeQuerySqlServerTest( + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task Include_list(bool async) { @@ -1232,7 +1236,7 @@ public override async Task Multi_level_includes_are_applied_with_skip_take(bool await base.Multi_level_includes_are_applied_with_skip_take(async); AssertSql( - @"@__p_0='1' + @"@__p_0='1' SELECT [t0].[CustomerID], [t1].[OrderID], [t1].[CustomerID], [t1].[EmployeeID], [t1].[OrderDate], [t1].[OrderID0], [t1].[ProductID], [t1].[Discount], [t1].[Quantity], [t1].[UnitPrice] FROM ( diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinQuerySqlServerTest.cs index b2779615955..f5bf5fdc1fc 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindJoinQuerySqlServerTest.cs @@ -9,14 +9,17 @@ namespace Microsoft.EntityFrameworkCore.Query { public class NorthwindJoinQuerySqlServerTest : NorthwindJoinQueryRelationalTestBase> { - public NorthwindJoinQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindJoinQuerySqlServerTest( + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { ClearLog(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task Join_customers_orders_projection(bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqlServerTest.cs index 82a9cdf355e..2e3b09a79f7 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqlServerTest.cs @@ -8,16 +8,20 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindKeylessEntitiesQuerySqlServerTest : NorthwindKeylessEntitiesQueryRelationalTestBase> + public class NorthwindKeylessEntitiesQuerySqlServerTest : NorthwindKeylessEntitiesQueryRelationalTestBase< + NorthwindQuerySqlServerFixture> { - public NorthwindKeylessEntitiesQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindKeylessEntitiesQuerySqlServerTest( + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { ClearLog(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; [ConditionalTheory] public override async Task KeylessEntity_simple(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs index 89894369324..652a3a5849a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs @@ -13,16 +13,20 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindMiscellaneousQuerySqlServerTest : NorthwindMiscellaneousQueryRelationalTestBase> + public class NorthwindMiscellaneousQuerySqlServerTest : NorthwindMiscellaneousQueryRelationalTestBase< + NorthwindQuerySqlServerFixture> { - public NorthwindMiscellaneousQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindMiscellaneousQuerySqlServerTest( + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { ClearLog(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override void Shaper_command_caching_when_parameter_names_different() { @@ -108,13 +112,13 @@ public virtual void Cache_key_contexts_are_detached() { var orderDetails = context.OrderDetails; - Customer Query(NorthwindContext param) => - (from c in context.Customers - from o in context.Set() - from od in orderDetails - from e1 in param.Employees - from e2 in param.Set() - select c).First(); + Customer Query(NorthwindContext param) + => (from c in context.Customers + from o in context.Set() + from od in orderDetails + from e1 in param.Employees + from e2 in param.Set() + select c).First(); Assert.NotNull(Query(context)); @@ -5127,7 +5131,8 @@ FROM [Customers] AS [c] ORDER BY [c].[CustomerID]"); } - public override async Task Pending_selector_in_cardinality_reducing_method_is_applied_before_expanding_collection_navigation_member(bool async) + public override async Task Pending_selector_in_cardinality_reducing_method_is_applied_before_expanding_collection_navigation_member( + bool async) { await base.Pending_selector_in_cardinality_reducing_method_is_applied_before_expanding_collection_navigation_member(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs index 1aff134cdbe..75709193b6b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindNavigationsQuerySqlServerTest.cs @@ -7,16 +7,19 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindNavigationsQuerySqlServerTest : NorthwindNavigationsQueryRelationalTestBase> + public class NorthwindNavigationsQuerySqlServerTest : NorthwindNavigationsQueryRelationalTestBase< + NorthwindQuerySqlServerFixture> { public NorthwindNavigationsQuerySqlServerTest( - NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { fixture.TestSqlLoggerFactory.Clear(); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task Select_Where_Navigation(bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryFiltersQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryFiltersQuerySqlServerTest.cs index c1cb88e57fc..bec7c6de924 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryFiltersQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryFiltersQuerySqlServerTest.cs @@ -8,9 +8,12 @@ // ReSharper disable InconsistentNaming namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindQueryFiltersQuerySqlServerTest : NorthwindQueryFiltersQueryTestBase> + public class NorthwindQueryFiltersQuerySqlServerTest : NorthwindQueryFiltersQueryTestBase< + NorthwindQuerySqlServerFixture> { - public NorthwindQueryFiltersQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindQueryFiltersQuerySqlServerTest( + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQuerySqlServerFixture.cs index 978037227e1..d6f17378366 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQuerySqlServerFixture.cs @@ -10,7 +10,8 @@ namespace Microsoft.EntityFrameworkCore.Query public class NorthwindQuerySqlServerFixture : NorthwindQueryRelationalFixture where TModelCustomizer : IModelCustomizer, new() { - protected override ITestStoreFactory TestStoreFactory => SqlServerNorthwindTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerNorthwindTestStoreFactory.Instance; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryTaggingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryTaggingQuerySqlServerTest.cs index f5c798ba63c..868657c617e 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryTaggingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindQueryTaggingQuerySqlServerTest.cs @@ -1,18 +1,20 @@ // 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.TestUtilities; +using System.Linq; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; using Xunit.Abstractions; -using System.Linq; namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindQueryTaggingQuerySqlServerTest : NorthwindQueryTaggingQueryTestBase> + public class NorthwindQueryTaggingQuerySqlServerTest : NorthwindQueryTaggingQueryTestBase< + NorthwindQuerySqlServerFixture> { public NorthwindQueryTaggingQuerySqlServerTest( - NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs index db75580dc9f..863f4a29458 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs @@ -1,25 +1,27 @@ // 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 System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindSelectQuerySqlServerTest : NorthwindSelectQueryRelationalTestBase> + public class NorthwindSelectQuerySqlServerTest : NorthwindSelectQueryRelationalTestBase< + NorthwindQuerySqlServerFixture> { - public NorthwindSelectQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindSelectQuerySqlServerTest( + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { ClearLog(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task Projection_when_arithmetic_expression_precedence(bool async) { @@ -1361,7 +1363,8 @@ public override async Task Reverse_changes_asc_order_to_desc(bool async) { await base.Reverse_changes_asc_order_to_desc(async); - AssertSql(@"SELECT [e].[EmployeeID] + AssertSql( + @"SELECT [e].[EmployeeID] FROM [Employees] AS [e] ORDER BY [e].[EmployeeID] DESC"); } @@ -1370,7 +1373,8 @@ public override async Task Reverse_changes_desc_order_to_asc(bool async) { await base.Reverse_changes_desc_order_to_asc(async); - AssertSql(@"SELECT [e].[EmployeeID] + AssertSql( + @"SELECT [e].[EmployeeID] FROM [Employees] AS [e] ORDER BY [e].[EmployeeID]"); } @@ -1442,7 +1446,7 @@ WHERE [o0].[OrderID] IN (10248, 10249, 10250) AND (([t].[CustomerID] = [o0].[Cus public override Task Reverse_without_explicit_ordering_throws(bool async) { return AssertTranslationFailedWithDetails( - () => base.Reverse_without_explicit_ordering_throws(async), RelationalStrings.MissingOrderingInSqlExpression); + () => base.Reverse_without_explicit_ordering_throws(async), RelationalStrings.MissingOrderingInSqlExpression); } public override async Task Custom_projection_reference_navigation_PK_to_FK_optimization(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSetOperationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSetOperationsQuerySqlServerTest.cs index 1840f1d9a03..c3c3ad203a6 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSetOperationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSetOperationsQuerySqlServerTest.cs @@ -9,16 +9,20 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindSetOperationsQuerySqlServerTest : NorthwindSetOperationsQueryRelationalTestBase> + public class NorthwindSetOperationsQuerySqlServerTest : NorthwindSetOperationsQueryRelationalTestBase< + NorthwindQuerySqlServerFixture> { - public NorthwindSetOperationsQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindSetOperationsQuerySqlServerTest( + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { ClearLog(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task Union(bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqlServerTest.cs index 11dd468e374..48236ce2f8a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqlServerTest.cs @@ -6,10 +6,13 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindSplitIncludeNoTrackingQuerySqlServerTest : NorthwindSplitIncludeNoTrackingQueryTestBase> + public class NorthwindSplitIncludeNoTrackingQuerySqlServerTest : NorthwindSplitIncludeNoTrackingQueryTestBase< + NorthwindQuerySqlServerFixture> { // ReSharper disable once UnusedParameter.Local - public NorthwindSplitIncludeNoTrackingQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindSplitIncludeNoTrackingQuerySqlServerTest( + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs index 046265a45c0..5d20ce2ad70 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs @@ -9,10 +9,13 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindSplitIncludeQuerySqlServerTest : NorthwindSplitIncludeQueryTestBase> + public class NorthwindSplitIncludeQuerySqlServerTest : NorthwindSplitIncludeQueryTestBase< + NorthwindQuerySqlServerFixture> { // ReSharper disable once UnusedParameter.Local - public NorthwindSplitIncludeQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindSplitIncludeQuerySqlServerTest( + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs index 3a68631122a..24ddb83125a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs @@ -10,7 +10,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindStringIncludeQuerySqlServerTest : NorthwindStringIncludeQueryTestBase> + public class NorthwindStringIncludeQuerySqlServerTest : NorthwindStringIncludeQueryTestBase< + NorthwindQuerySqlServerFixture> { // ReSharper disable once UnusedParameter.Local public NorthwindStringIncludeQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs index 1bf7cff9a63..d9be400d59c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs @@ -3,24 +3,26 @@ using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Diagnostics.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindWhereQuerySqlServerTest : NorthwindWhereQueryRelationalTestBase> + public class NorthwindWhereQuerySqlServerTest : NorthwindWhereQueryRelationalTestBase< + NorthwindQuerySqlServerFixture> { - public NorthwindWhereQuerySqlServerTest(NorthwindQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindWhereQuerySqlServerTest( + NorthwindQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { ClearLog(); Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task Where_simple(bool async) { @@ -529,7 +531,9 @@ public override async Task Where_equals_using_object_overload_on_mismatched_type FROM [Employees] AS [e] WHERE 0 = 1"); - Assert.Contains("Possible unintended use of method Equals(object) for arguments 'e.EmployeeID' and '@__longPrm_0' of different types in query. This comparison will always return 'false'.", Fixture.TestSqlLoggerFactory.Log.Select(l => l.Message)); + Assert.Contains( + "Possible unintended use of method Equals(object) for arguments 'e.EmployeeID' and '@__longPrm_0' of different types in query. This comparison will always return 'false'.", + Fixture.TestSqlLoggerFactory.Log.Select(l => l.Message)); } public override async Task Where_equals_using_int_overload_on_mismatched_types(bool async) @@ -557,8 +561,12 @@ FROM [Employees] AS [e] FROM [Employees] AS [e] WHERE 0 = 1"); - Assert.Contains("Possible unintended use of method Equals(object) for arguments 'e.ReportsTo' and '@__longPrm_0' of different types in query. This comparison will always return 'false'.", Fixture.TestSqlLoggerFactory.Log.Select(l => l.Message)); - Assert.Contains("Possible unintended use of method Equals(object) for arguments '@__longPrm_0' and 'e.ReportsTo' of different types in query. This comparison will always return 'false'.", Fixture.TestSqlLoggerFactory.Log.Select(l => l.Message)); + Assert.Contains( + "Possible unintended use of method Equals(object) for arguments 'e.ReportsTo' and '@__longPrm_0' of different types in query. This comparison will always return 'false'.", + Fixture.TestSqlLoggerFactory.Log.Select(l => l.Message)); + Assert.Contains( + "Possible unintended use of method Equals(object) for arguments '@__longPrm_0' and 'e.ReportsTo' of different types in query. This comparison will always return 'false'.", + Fixture.TestSqlLoggerFactory.Log.Select(l => l.Message)); } public override async Task Where_equals_on_mismatched_types_nullable_long_nullable_int(bool async) @@ -574,8 +582,12 @@ FROM [Employees] AS [e] FROM [Employees] AS [e] WHERE 0 = 1"); - Assert.Contains("Possible unintended use of method Equals(object) for arguments 'e.ReportsTo' and '@__nullableLongPrm_0' of different types in query. This comparison will always return 'false'.", Fixture.TestSqlLoggerFactory.Log.Select(l => l.Message)); - Assert.Contains("Possible unintended use of method Equals(object) for arguments '@__nullableLongPrm_0' and 'e.ReportsTo' of different types in query. This comparison will always return 'false'.", Fixture.TestSqlLoggerFactory.Log.Select(l => l.Message)); + Assert.Contains( + "Possible unintended use of method Equals(object) for arguments 'e.ReportsTo' and '@__nullableLongPrm_0' of different types in query. This comparison will always return 'false'.", + Fixture.TestSqlLoggerFactory.Log.Select(l => l.Message)); + Assert.Contains( + "Possible unintended use of method Equals(object) for arguments '@__nullableLongPrm_0' and 'e.ReportsTo' of different types in query. This comparison will always return 'false'.", + Fixture.TestSqlLoggerFactory.Log.Select(l => l.Message)); } public override async Task Where_equals_on_mismatched_types_int_nullable_int(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NullKeysSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NullKeysSqlServerTest.cs index f55fa16d445..8cdd576c50e 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NullKeysSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NullKeysSqlServerTest.cs @@ -14,7 +14,8 @@ public NullKeysSqlServerTest(NullKeysSqlServerFixture fixture) public class NullKeysSqlServerFixture : NullKeysFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerFixture.cs index fec0c1d5645..7d5ea2d87c6 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class NullSemanticsQuerySqlServerFixture : NullSemanticsQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs index 5a3d2d1e1d5..6ce64f0ed73 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs @@ -1821,7 +1821,6 @@ FROM [Entities1] AS [e] WHERE 0 = 1"); } - public override async Task Empty_subquery_with_contains_negated_returns_true(bool async) { await base.Empty_subquery_with_contains_negated_returns_true(async); @@ -1830,6 +1829,7 @@ public override async Task Empty_subquery_with_contains_negated_returns_true(boo @"SELECT [e].[Id], [e].[BoolA], [e].[BoolB], [e].[BoolC], [e].[IntA], [e].[IntB], [e].[IntC], [e].[NullableBoolA], [e].[NullableBoolB], [e].[NullableBoolC], [e].[NullableIntA], [e].[NullableIntB], [e].[NullableIntC], [e].[NullableStringA], [e].[NullableStringB], [e].[NullableStringC], [e].[StringA], [e].[StringB], [e].[StringC] FROM [Entities1] AS [e]"); } + public override async Task Nullable_string_FirstOrDefault_compared_to_nullable_string_LastOrDefault(bool async) { await base.Nullable_string_FirstOrDefault_compared_to_nullable_string_LastOrDefault(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs index 6e25ff0eadb..00ceeab5988 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/OwnedQuerySqlServerTest.cs @@ -15,7 +15,8 @@ public OwnedQuerySqlServerTest(OwnedQuerySqlServerFixture fixture, ITestOutputHe Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task Query_with_owned_entity_equality_operator(bool async) { @@ -998,7 +999,8 @@ private void AssertSql(params string[] expected) public class OwnedQuerySqlServerFixture : RelationalOwnedQueryFixture { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs index 4ff4cb33eaa..f4173e5736a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs @@ -1271,7 +1271,7 @@ 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 + // ReSharper disable once ConstantNullCoalescingCondition select new { One = 1, Coalesce = eRootJoined ?? (eVersion ?? eRootJoined) }; var result = query.ToList(); @@ -1290,7 +1290,7 @@ join eRoot in ctx.Entities on eVersion.RootEntityId equals eRoot.Id into RootEntities from eRootJoined in RootEntities.DefaultIfEmpty() - // ReSharper disable once ConstantNullCoalescingCondition + // ReSharper disable once ConstantNullCoalescingCondition select new { One = eRootJoined, @@ -1314,7 +1314,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 @@ -2213,7 +2213,8 @@ public virtual void Explicitly_compiled_query_does_not_add_cache_entry() { var parameter = Expression.Parameter(typeof(Entity8909)); var predicate = Expression.Lambda>( - Expression.MakeBinary(ExpressionType.Equal, + Expression.MakeBinary( + ExpressionType.Equal, Expression.PropertyOrField(parameter, "Id"), Expression.Constant(1)), parameter); @@ -3433,7 +3434,8 @@ private class LeaderQuery #region Bug11923 #pragma warning disable IDE0060 // Remove unused parameter - private static bool ClientMethod11923(int id) => true; + private static bool ClientMethod11923(int id) + => true; #pragma warning restore IDE0060 // Remove unused parameter [ConditionalFact(Skip = "Issue #17244")] @@ -4301,7 +4303,8 @@ public virtual void Correlated_subquery_with_owned_navigation_being_compared_to_ }).ToList(); Assert.Single(partners); - Assert.Collection(partners[0].Addresses, + Assert.Collection( + partners[0].Addresses, t => { Assert.NotNull(t.Turnovers); @@ -4820,8 +4823,7 @@ private SqlServerTestStore CreateDatabase15684() context.Products.Add( new Product15684 { - Name = "Apple", - Category = new Category15684 { Name = "Fruit", Status = CategoryStatus15684.Active } + Name = "Apple", Category = new Category15684 { Name = "Fruit", Status = CategoryStatus15684.Active } }); context.Products.Add(new Product15684 { Name = "Bike" }); @@ -5667,10 +5669,17 @@ public Bar6864(int value) _value = value; } - public string Value => _value.ToString(); - public override string ToString() => Value; - public static implicit operator string(Bar6864 bar) => bar.Value; - public Bar6864 Clone() => new Bar6864(_value); + public string Value + => _value.ToString(); + + public override string ToString() + => Value; + + public static implicit operator string(Bar6864 bar) + => bar.Value; + + public Bar6864 Clone() + => new Bar6864(_value); } #endregion @@ -5781,7 +5790,8 @@ public void RunQuery() Blogs.Select(b => ClientMethod(b)).ToList(); } - public int ClientMethod(Blog7222 blog) => blog.Id; + public int ClientMethod(Blog7222 blog) + => blog.Id; } private SqlServerTestStore CreateDatabase7222() @@ -6606,16 +6616,11 @@ private SqlServerTestStore CreateDatabase17794() () => new BugContext17794(_options), context => { - context.Add(new Offer17794 - { - Actions = new List + context.Add( + new Offer17794 { - new OfferAction17794 - { - Action = OfferActions17794.Accepted - } - } - }); + Actions = new List { new OfferAction17794 { Action = OfferActions17794.Accepted } } + }); context.SaveChanges(); @@ -6642,7 +6647,7 @@ private class Offer17794 : IOffer17794 public ICollection Actions { get; set; } } - private enum OfferActions17794 : int + private enum OfferActions17794 { Accepted = 1, Declined = 2 @@ -6654,6 +6659,7 @@ private class OfferAction17794 [Required] public Offer17794 Offer { get; set; } + public int OfferId { get; set; } [Required] @@ -6667,7 +6673,6 @@ private class BugContext17794 : DbContext protected override void OnModelCreating(ModelBuilder modelBuilder) { - } public BugContext17794(DbContextOptions options) @@ -6731,7 +6736,7 @@ public void Cast_to_non_implemented_interface_is_not_removed_from_expression_tre Assert.Equal( CoreStrings.TranslationFailed( @"DbSet() .Cast() .Where(e => e.Id == __id_0)"), - message.Replace("\r", "").Replace("\n", "")); + message.Replace("\r", "").Replace("\n", "")); } private SqlServerTestStore CreateDatabase18087() @@ -6739,21 +6744,10 @@ private SqlServerTestStore CreateDatabase18087() () => new BugContext18087(_options), context => { - context.AddRange(new MockEntity() - { - Name = "Entity1", - NavigationEntity = null - }, - new MockEntity() - { - Name = "Entity2", - NavigationEntity = null - }, - new MockEntity() - { - Name = "NewEntity", - NavigationEntity = null - }); + context.AddRange( + new MockEntity { Name = "Entity1", NavigationEntity = null }, + new MockEntity { Name = "Entity2", NavigationEntity = null }, + new MockEntity { Name = "NewEntity", NavigationEntity = null }); context.SaveChanges(); @@ -6951,14 +6945,19 @@ public void GroupJoin_SelectMany_in_defining_query_gets_flattened() var query = context.Set().ToList(); - Assert.Collection(query, + Assert.Collection( + query, t => AssertCustomerView(t, 1, "First", 1, "FirstChild"), t => AssertCustomerView(t, 2, "Second", 2, "SecondChild1"), t => AssertCustomerView(t, 2, "Second", 3, "SecondChild2"), t => AssertCustomerView(t, 3, "Third", null, "")); static void AssertCustomerView( - CustomerView19708 actual, int id, string name, int? customerMembershipId, string customerMembershipName) + CustomerView19708 actual, + int id, + string name, + int? customerMembershipId, + string customerMembershipName) { Assert.Equal(id, actual.Id); Assert.Equal(name, actual.Name); @@ -6967,7 +6966,7 @@ static void AssertCustomerView( } AssertSql( - @"SELECT [c].[Id], [c].[Name], [c0].[Id] AS [CustomerMembershipId], CASE + @"SELECT [c].[Id], [c].[Name], [c0].[Id] AS [CustomerMembershipId], CASE WHEN [c0].[Id] IS NOT NULL THEN [c0].[Name] ELSE N'' END AS [CustomerMembershipName] @@ -7010,16 +7009,14 @@ public BugContext19708(DbContextOptions options) protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity() - .HasQueryFilter(e => (from a in (from c in Customers - join cm in CustomerMemberships on c.Id equals cm.CustomerId into g - from cm in g.DefaultIfEmpty() - select new - { - c.Id, - CustomerMembershipId = (int?)cm.Id - }) - where a.CustomerMembershipId != null && a.Id == e.CustomerId - select a).Count() > 0) + .HasQueryFilter( + e => (from a in (from c in Customers + join cm in CustomerMemberships on c.Id equals cm.CustomerId into g + from cm in g.DefaultIfEmpty() + select new { c.Id, CustomerMembershipId = (int?)cm.Id }) + where a.CustomerMembershipId != null && a.Id == e.CustomerId + select a).Count() + > 0) .HasKey(e => e.CustomerId); #pragma warning disable CS0618 // Type or member is obsolete @@ -7155,11 +7152,8 @@ public void Explicit_interface_casting_checked_in_lambda() using var context = new BugContext20097(_options); var originalQuery = context.Entities.Select(a => new MyModel20097 { Id = a.Id }); - checked - { - var query = originalQuery.Where(a => ((IHaveId20097)a).Id == 1).ToList(); - Assert.Single(query); - } + var query = originalQuery.Where(a => ((IHaveId20097)a).Id == 1).ToList(); + Assert.Single(query); AssertSql( @"SELECT [e].[Id] @@ -7374,7 +7368,8 @@ public virtual void Unconfigured_query_splitting_behavior_throws_a_warning() using var context = new BugContext21355(options); Assert.Contains( - RelationalResources.LogMultipleCollectionIncludeWarning(new TestLogger()).GenerateMessage(), + RelationalResources.LogMultipleCollectionIncludeWarning(new TestLogger()) + .GenerateMessage(), Assert.Throws( () => context.Parents.Include(p => p.Children1).Include(p => p.Children2).ToList()).Message); } @@ -7563,7 +7558,9 @@ private class AnotherChild21355 public Parent21355 Parent { get; set; } } - private (DbContextOptions, TestSqlLoggerFactory) CreateOptions21355(QuerySplittingBehavior? querySplittingBehavior, bool mars = true) + private (DbContextOptions, TestSqlLoggerFactory) CreateOptions21355( + QuerySplittingBehavior? querySplittingBehavior, + bool mars = true) { var testStore = SqlServerTestStore.CreateInitialized("QueryBugsTest", multipleActiveResultSets: mars); var testSqlLoggerFactory = new TestSqlLoggerFactory(); @@ -7582,15 +7579,7 @@ private class AnotherChild21355 var context = new BugContext21355(optionsBuilder.Options); if (context.Database.EnsureCreatedResiliently()) { - context.Add(new Parent21355 - { - Id = "Parent1", - Children1 = new List - { - new Child21355(), - new Child21355() - } - }); + context.Add(new Parent21355 { Id = "Parent1", Children1 = new List { new Child21355(), new Child21355() } }); context.SaveChanges(); } @@ -7743,8 +7732,7 @@ private SqlServerTestStore CreateDatabase21540() OwnedReference = new Owned21540(), Collection = new List { - new Collection21540(), - new Collection21540(), + new Collection21540(), new Collection21540(), } } }; @@ -7840,7 +7828,8 @@ public virtual void Thread_safety_in_relational_command_cache() { var ids = new[] { 1, 2, 3 }; - Parallel.For(0, 100, + Parallel.For( + 0, 100, i => { using var context = new MyContext21666(_options); @@ -7890,11 +7879,11 @@ public virtual void Using_explicit_interface_implementation_as_navigation_works( Expression> projection = b => new BookViewModel21768 { FirstPage = b.FrontCover.Illustrations.FirstOrDefault(i => i.State >= IllustrationState21768.Approved) != null - ? new PageViewModel21768 - { - Uri = b.FrontCover.Illustrations.FirstOrDefault(i => i.State >= IllustrationState21768.Approved).Uri - } - : null, + ? new PageViewModel21768 + { + Uri = b.FrontCover.Illustrations.FirstOrDefault(i => i.State >= IllustrationState21768.Approved).Uri + } + : null, }; var result = context.Books.Where(b => b.Id == 1).Select(projection).SingleOrDefault(); @@ -7961,15 +7950,21 @@ private class Book21768 : IBook21768 public BookCover21768 BackCover { get; set; } public int BackCoverId { get; set; } - IBookCover21768 IBook21768.FrontCover => FrontCover; - IBookCover21768 IBook21768.BackCover => BackCover; + + IBookCover21768 IBook21768.FrontCover + => FrontCover; + + IBookCover21768 IBook21768.BackCover + => BackCover; } private class BookCover21768 : IBookCover21768 { public int Id { get; set; } public ICollection Illustrations { get; set; } - IEnumerable IBookCover21768.Illustrations => Illustrations; + + IEnumerable IBookCover21768.Illustrations + => Illustrations; } private class CoverIllustration21768 : ICoverIllustration21768 @@ -7980,7 +7975,8 @@ private class CoverIllustration21768 : ICoverIllustration21768 public string Uri { get; set; } public IllustrationState21768 State { get; set; } - IBookCover21768 ICoverIllustration21768.Cover => Cover; + IBookCover21768 ICoverIllustration21768.Cover + => Cover; } private enum IllustrationState21768 @@ -8102,10 +8098,7 @@ public virtual void Invoke_inside_query_filter_gets_correctly_evaluated_during_t { using (CreateDatabase18510()) { - using var context = new MyContext18510(_options) - { - TenantId = 1 - }; + using var context = new MyContext18510(_options) { TenantId = 1 }; var query1 = context.Entities.ToList(); Assert.True(query1.All(x => x.TenantId == 1)); @@ -8248,7 +8241,9 @@ private class AppEntity21803 private readonly List _otherEntities = new List(); public int Id { get; private set; } - public IEnumerable OtherEntities => _otherEntities; + + public IEnumerable OtherEntities + => _otherEntities; } private class OtherEntity21803 @@ -8337,17 +8332,19 @@ public MyContext21807(DbContextOptions options) protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.Entity(builder => - { - builder.HasKey(x => x.Id); - - builder.OwnsOne(x => x.Contact, contact => + modelBuilder.Entity( + builder => { - contact.OwnsOne(c => c.Address); - }); + builder.HasKey(x => x.Id); - builder.Navigation(x => x.Contact).IsRequired(); - }); + builder.OwnsOne( + x => x.Contact, contact => + { + contact.OwnsOne(c => c.Address); + }); + + builder.Navigation(x => x.Contact).IsRequired(); + }); } } @@ -8356,17 +8353,7 @@ private SqlServerTestStore CreateDatabase21807() () => new MyContext21807(_options), context => { - context.Add(new Entity21807 - { - Id = "1", - Contact = new Contact21807 - { - Address = new Address21807 - { - Zip = "12345" - } - } - }); + context.Add(new Entity21807 { Id = "1", Contact = new Contact21807 { Address = new Address21807 { Zip = "12345" } } }); context.SaveChanges(); @@ -8440,33 +8427,36 @@ public MyContext22054(DbContextOptions options) protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.Entity(builder => - { - builder.HasKey(x => x.Id); - - builder.OwnsOne(x => x.Contact, contact => + modelBuilder.Entity( + builder => { - contact.Property(e => e.SharedProperty).IsRequired().HasColumnName("SharedProperty"); + builder.HasKey(x => x.Id); - contact.OwnsOne(c => c.Address, address => - { - address.Property("SharedProperty").IsRequired().HasColumnName("SharedProperty"); - }); - }); + builder.OwnsOne( + x => x.Contact, contact => + { + contact.Property(e => e.SharedProperty).IsRequired().HasColumnName("SharedProperty"); - builder.OwnsOne(e => e.Data) - .Property("RowVersion") - .IsRowVersion() - .IsRequired() - .HasColumnType("TIMESTAMP") - .HasColumnName("RowVersion"); - - builder.Property(x => x.RowVersion) - .HasColumnType("TIMESTAMP") - .IsRowVersion() - .IsRequired() - .HasColumnName("RowVersion"); - }); + contact.OwnsOne( + c => c.Address, address => + { + address.Property("SharedProperty").IsRequired().HasColumnName("SharedProperty"); + }); + }); + + builder.OwnsOne(e => e.Data) + .Property("RowVersion") + .IsRowVersion() + .IsRequired() + .HasColumnType("TIMESTAMP") + .HasColumnName("RowVersion"); + + builder.Property(x => x.RowVersion) + .HasColumnType("TIMESTAMP") + .IsRowVersion() + .IsRequired() + .HasColumnName("RowVersion"); + }); } } @@ -8478,10 +8468,7 @@ private SqlServerTestStore CreateDatabase22054() context.AddRange( new User22054 { - Data = new Data22054 - { - Data = "Data1" - }, + Data = new Data22054 { Data = "Data1" }, Contact = new Contact22054 { MobileNumber = "123456", @@ -8496,10 +8483,7 @@ private SqlServerTestStore CreateDatabase22054() }, new User22054 { - Data = new Data22054 - { - Data = "Data2" - }, + Data = new Data22054 { Data = "Data2" }, Contact = new Contact22054 { MobileNumber = "654321", @@ -8507,11 +8491,7 @@ private SqlServerTestStore CreateDatabase22054() Address = null } }, - new User22054 - { - Contact = null, - Data = null - }); + new User22054 { Contact = null, Data = null }); context.SaveChanges(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/QueryFilterFuncletizationSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/QueryFilterFuncletizationSqlServerTest.cs index b6634c0ad57..5349c8b2774 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/QueryFilterFuncletizationSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/QueryFilterFuncletizationSqlServerTest.cs @@ -438,7 +438,8 @@ private void AssertSql(params string[] expected) public class QueryFilterFuncletizationSqlServerFixture : QueryFilterFuncletizationRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/QueryLoggingSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/QueryLoggingSqlServerTest.cs index 6a211df3495..65b04fbd096 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/QueryLoggingSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/QueryLoggingSqlServerTest.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.Linq; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Diagnostics.Internal; @@ -164,6 +163,7 @@ DbContextOptions CreateOptions(ListLoggerFactory listLoggerFactory) Assert.Equal(1, loggerFactory2.Log.Count(e => e.Id == RelationalEventId.CommandExecuted)); } - protected NorthwindContext CreateContext() => Fixture.CreateContext(); + protected NorthwindContext CreateContext() + => Fixture.CreateContext(); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs index cf7fc87474f..939d1d955a9 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs @@ -15,7 +15,8 @@ public SpatialQuerySqlServerGeographyTest(SpatialQuerySqlServerGeographyFixture //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; // TODO: Remove after NetTopologySuite/NetTopologySuite#233 protected override bool AssertDistances diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs index 61716294eab..ff0e9eab901 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs @@ -19,7 +19,8 @@ public SpatialQuerySqlServerGeometryTest(SpatialQuerySqlServerGeometryFixture fi //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task SimpleSelect(bool async) { @@ -236,8 +237,10 @@ public override async Task Distance_constant_srid_4326(bool async) { await AssertQuery( async, - ss => ss.Set().Select(e => new { e.Id, Distance = (double?)e.Point.Distance(new Point(1, 1) { SRID = 4326 }) }), - ss => ss.Set().Select(e => new { e.Id, Distance = e.Point == null ? (double?)null : e.Point.Distance(new Point(1, 1) { SRID = 4326 }) }), + ss => ss.Set() + .Select(e => new { e.Id, Distance = (double?)e.Point.Distance(new Point(1, 1) { SRID = 4326 }) }), + ss => ss.Set().Select( + 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) => { @@ -778,7 +781,8 @@ FROM [LineStringEntity] AS [l] // @"SELECT [l].[Id] FROM [LineStringEntity] AS [l] -WHERE [l].[LineString] IS NULL"); } +WHERE [l].[LineString] IS NULL"); + } public override async Task Intersects_not_equal_to_null(bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SqlExecutorSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SqlExecutorSqlServerTest.cs index 598d9422b29..a706cfe92b9 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SqlExecutorSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SqlExecutorSqlServerTest.cs @@ -150,9 +150,14 @@ public override async Task Query_with_parameters_interpolated_async() protected override DbParameter CreateDbParameter(string name, object value) => new SqlParameter { ParameterName = name, Value = value }; - protected override string TenMostExpensiveProductsSproc => "[dbo].[Ten Most Expensive Products]"; - protected override string CustomerOrderHistorySproc => "[dbo].[CustOrderHist] @CustomerID"; - protected override string CustomerOrderHistoryWithGeneratedParameterSproc => "[dbo].[CustOrderHist] @CustomerID = {0}"; + protected override string TenMostExpensiveProductsSproc + => "[dbo].[Ten Most Expensive Products]"; + + protected override string CustomerOrderHistorySproc + => "[dbo].[CustOrderHist] @CustomerID"; + + protected override string CustomerOrderHistoryWithGeneratedParameterSproc + => "[dbo].[CustOrderHist] @CustomerID = {0}"; private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTFiltersInheritanceQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTFiltersInheritanceQuerySqlServerFixture.cs index 3c3fe1dd833..f98c49c0519 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTFiltersInheritanceQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTFiltersInheritanceQuerySqlServerFixture.cs @@ -5,6 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class TPTFiltersInheritanceQuerySqlServerFixture : TPTInheritanceQuerySqlServerFixture { - protected override bool EnableFilters => true; + protected override bool EnableFilters + => true; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTFiltersInheritanceQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTFiltersInheritanceQuerySqlServerTest.cs index 81b8b315c08..a90bb6481fd 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTFiltersInheritanceQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTFiltersInheritanceQuerySqlServerTest.cs @@ -7,7 +7,9 @@ namespace Microsoft.EntityFrameworkCore.Query { public class TPTFiltersInheritanceQuerySqlServerTest : TPTFiltersInheritanceQueryTestBase { - public TPTFiltersInheritanceQuerySqlServerTest(TPTFiltersInheritanceQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + public TPTFiltersInheritanceQuerySqlServerTest( + TPTFiltersInheritanceQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerFixture.cs index 07f9fe4f7c8..9791db25aca 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerFixture.cs @@ -8,7 +8,8 @@ namespace Microsoft.EntityFrameworkCore.Query { public class TPTGearsOfWarQuerySqlServerFixture : TPTGearsOfWarQueryRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs index 02e713b3317..439ff8e286d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs @@ -20,7 +20,8 @@ public TPTGearsOfWarQuerySqlServerTest(TPTGearsOfWarQuerySqlServerFixture fixtur //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task Negate_on_binary_expression(bool async) { @@ -6537,7 +6538,8 @@ FROM [Gears] AS [g] WHERE [g].[Nickname] <> N'Dom'"); } - public override async Task Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(bool async) + public override async Task + Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(bool async) { await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(async); @@ -6545,9 +6547,11 @@ public override async Task Null_semantics_is_correctly_applied_for_function_comp @""); } - public override async Task Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) + public override async Task + Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) { - await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(async); + await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex( + async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[Note] @@ -7615,7 +7619,8 @@ public override async Task Byte_array_filter_by_length_literal_does_not_cast_on_ { await base.Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(async); - AssertSql(@"SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] + AssertSql( + @"SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] WHERE DATALENGTH([s].[Banner5]) = 5"); } @@ -7720,7 +7725,8 @@ public override async Task Byte_array_filter_by_SequenceEqual(bool isAsync) { await base.Byte_array_filter_by_SequenceEqual(isAsync); - AssertSql(@"@__byteArrayParam_0='0x0405060708' (Size = 5) + AssertSql( + @"@__byteArrayParam_0='0x0405060708' (Size = 5) SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] @@ -7943,7 +7949,8 @@ FROM [LocustLeaders] AS [l] WHERE CHARINDEX(CAST([t].[ThreatLevelByte] AS varbinary(max)), [s].[Banner]) > 0"); } - public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(bool async) + public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion( + bool async) { await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(async); @@ -7964,7 +7971,8 @@ FROM [LocustLeaders] AS [l1] ) AS [t]"); } - public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(bool async) + public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated( + bool async) { await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTInheritanceQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTInheritanceQuerySqlServerFixture.cs index 294877e7ed4..e2af5a0e1ed 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTInheritanceQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTInheritanceQuerySqlServerFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class TPTInheritanceQuerySqlServerFixture : TPTInheritanceQueryFixture { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqlServerTest.cs index 42b38d6c332..3dd85358021 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqlServerTest.cs @@ -6,7 +6,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class TPTManyToManyNoTrackingQuerySqlServerTest : TPTManyToManyNoTrackingQueryRelationalTestBase + public class TPTManyToManyNoTrackingQuerySqlServerTest : TPTManyToManyNoTrackingQueryRelationalTestBase< + TPTManyToManyQuerySqlServerFixture> { public TPTManyToManyNoTrackingQuerySqlServerTest(TPTManyToManyQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -15,7 +16,8 @@ public TPTManyToManyNoTrackingQuerySqlServerTest(TPTManyToManyQuerySqlServerFixt //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task Skip_navigation_all(bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerFixture.cs index 33d007f6907..59561905db8 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class TPTManyToManyQuerySqlServerFixture : TPTManyToManyQueryRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerTest.cs index 09bd5ec8014..5f4b1e27d74 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTManyToManyQuerySqlServerTest.cs @@ -15,7 +15,8 @@ public TPTManyToManyQuerySqlServerTest(TPTManyToManyQuerySqlServerFixture fixtur //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString => true; + protected override bool CanExecuteQueryString + => true; public override async Task Skip_navigation_all(bool async) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTRelationshipsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTRelationshipsQuerySqlServerTest.cs index 367f0da83c7..4213a9b6c97 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTRelationshipsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTRelationshipsQuerySqlServerTest.cs @@ -11,7 +11,8 @@ public class TPTRelationshipsQuerySqlServerTest : TPTRelationshipsQueryTestBase { public TPTRelationshipsQuerySqlServerTest( - TPTRelationshipsQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + TPTRelationshipsQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { fixture.TestSqlLoggerFactory.Clear(); @@ -1838,7 +1839,8 @@ private void AssertSql(params string[] expected) public class TPTRelationshipsQuerySqlServerFixture : TPTRelationshipsQueryRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs b/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs index 22118fd8d2c..86a2ff9feff 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs @@ -262,7 +262,6 @@ FROM [Customers] AS [c] ORDER BY [c].[Id]"); } - public override void Scalar_Function_SqlFragment_Static() { base.Scalar_Function_SqlFragment_Static(); @@ -534,15 +533,14 @@ CROSS APPLY [dbo].[GetCustomerOrderCountByYear]([c].[Id]) AS [g] ORDER BY [g].[Year]"); } - public override void QF_Select_Direct_In_Anonymous() { base.QF_Select_Direct_In_Anonymous(); - AssertSql(@"SELECT [t].[AmountSold], [t].[ProductId] + AssertSql( + @"SELECT [t].[AmountSold], [t].[ProductId] FROM [dbo].[GetTopTwoSellingProducts]() AS [t]", - -@"SELECT [c].[Id] + @"SELECT [c].[Id] FROM [Customers] AS [c]"); } @@ -591,10 +589,10 @@ public override void QF_Select_Correlated_Subquery_In_Anonymous_Nested() { base.QF_Select_Correlated_Subquery_In_Anonymous_Nested(); - AssertSql(@"SELECT [t].[AmountSold], [t].[ProductId] + AssertSql( + @"SELECT [t].[AmountSold], [t].[ProductId] FROM [dbo].[GetTopTwoSellingProducts]() AS [t]", - - @"SELECT [c].[Id], [t].[OrderId], [t].[OrderId0], [t].[CustomerId], [t].[OrderDate] + @"SELECT [c].[Id], [t].[OrderId], [t].[OrderId0], [t].[CustomerId], [t].[OrderDate] FROM [Customers] AS [c] OUTER APPLY ( SELECT [m].[OrderId], [m0].[OrderId] AS [OrderId0], [m0].[CustomerId], [m0].[OrderDate] @@ -872,7 +870,9 @@ protected override void ClearLog() public class SqlServer : UdfFixtureBase { protected override string StoreName { get; } = "UDFDbFunctionSqlServerTests"; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override void Seed(DbContext context) { @@ -1071,7 +1071,6 @@ having count(productId) > 1 return end"); - context.Database.ExecuteSqlRaw( @"create function [dbo].[AddValues] (@a int, @b int) returns int diff --git a/test/EFCore.SqlServer.FunctionalTests/SaveChangesInterceptionSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/SaveChangesInterceptionSqlServerTest.cs index 3d3eba0c83b..378a9a074c6 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SaveChangesInterceptionSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SaveChangesInterceptionSqlServerTest.cs @@ -20,7 +20,8 @@ protected SaveChangesInterceptionSqlServerTestBase(InterceptionSqlServerFixtureB public abstract class InterceptionSqlServerFixtureBase : InterceptionFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override IServiceCollection InjectInterceptors( IServiceCollection serviceCollection, @@ -38,9 +39,11 @@ public SaveChangesInterceptionSqlServerTest(InterceptionSqlServerFixture fixture public class InterceptionSqlServerFixture : InterceptionSqlServerFixtureBase { - protected override string StoreName => "SaveChangesInterception"; + protected override string StoreName + => "SaveChangesInterception"; - protected override bool ShouldSubscribeToDiagnosticListener => false; + protected override bool ShouldSubscribeToDiagnosticListener + => false; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) { @@ -62,9 +65,11 @@ public SaveChangesInterceptionWithDiagnosticsSqlServerTest(InterceptionSqlServer public class InterceptionSqlServerFixture : InterceptionSqlServerFixtureBase { - protected override string StoreName => "SaveChangesInterceptionWithDiagnostics"; + protected override string StoreName + => "SaveChangesInterceptionWithDiagnostics"; - protected override bool ShouldSubscribeToDiagnosticListener => true; + protected override bool ShouldSubscribeToDiagnosticListener + => true; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) { diff --git a/test/EFCore.SqlServer.FunctionalTests/Scaffolding/SqlServerDatabaseModelFactoryTest.cs b/test/EFCore.SqlServer.FunctionalTests/Scaffolding/SqlServerDatabaseModelFactoryTest.cs index 0ba206ff3a3..f487144f0fc 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Scaffolding/SqlServerDatabaseModelFactoryTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Scaffolding/SqlServerDatabaseModelFactoryTest.cs @@ -1513,12 +1513,12 @@ NonDefaultCollation nvarchar(max) COLLATE German_PhoneBook_CI_AS, Enumerable.Empty(), Enumerable.Empty(), dbModel => - { - var columns = dbModel.Tables.Single().Columns; + { + var columns = dbModel.Tables.Single().Columns; - Assert.Null(columns.Single(c => c.Name == "DefaultCollation").Collation); - Assert.Equal("German_PhoneBook_CI_AS", columns.Single(c => c.Name == "NonDefaultCollation").Collation); - }, + Assert.Null(columns.Single(c => c.Name == "DefaultCollation").Collation); + Assert.Equal("German_PhoneBook_CI_AS", columns.Single(c => c.Name == "NonDefaultCollation").Collation); + }, "DROP TABLE ColumnsWithCollation;"); } @@ -2260,7 +2260,11 @@ CONSTRAINT MYFK FOREIGN KEY (Id) REFERENCES PrincipalTable(Id) #endregion private void Test( - string createSql, IEnumerable tables, IEnumerable schemas, Action asserter, string cleanupSql) + string createSql, + IEnumerable tables, + IEnumerable schemas, + Action asserter, + string cleanupSql) { Fixture.TestStore.ExecuteNonQuery(createSql); @@ -2292,8 +2296,12 @@ private void Test( public class SqlServerDatabaseModelFixture : SharedStoreFixtureBase { protected override string StoreName { get; } = nameof(SqlServerDatabaseModelFactoryTest); - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; - public new SqlServerTestStore TestStore => (SqlServerTestStore)base.TestStore; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; + + public new SqlServerTestStore TestStore + => (SqlServerTestStore)base.TestStore; public SqlServerDatabaseModelFixture() { diff --git a/test/EFCore.SqlServer.FunctionalTests/SequenceEndToEndTest.cs b/test/EFCore.SqlServer.FunctionalTests/SequenceEndToEndTest.cs index ae7e2426bdd..6eceeb06fce 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SequenceEndToEndTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SequenceEndToEndTest.cs @@ -433,6 +433,7 @@ public SequenceEndToEndTest() protected SqlServerTestStore TestStore { get; } - public void Dispose() => TestStore.Dispose(); + public void Dispose() + => TestStore.Dispose(); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/SequentialGuidEndToEndTest.cs b/test/EFCore.SqlServer.FunctionalTests/SequentialGuidEndToEndTest.cs index bef51e652af..cb27a1fa90d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SequentialGuidEndToEndTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SequentialGuidEndToEndTest.cs @@ -118,6 +118,7 @@ public SequentialGuidEndToEndTest() protected SqlServerTestStore TestStore { get; } - public virtual void Dispose() => TestStore.Dispose(); + public virtual void Dispose() + => TestStore.Dispose(); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/AdventureWorksContext.cs b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/AdventureWorksContext.cs index 894a1433605..93e6d9c03ba 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/AdventureWorksContext.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/Model/AdventureWorksContext.cs @@ -18,15 +18,15 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) entity => { entity.HasIndex( - e => new - { - e.AddressLine1, - e.AddressLine2, - e.City, - e.StateProvince, - e.PostalCode, - e.CountryRegion - }, + e => new + { + e.AddressLine1, + e.AddressLine2, + e.City, + e.StateProvince, + e.PostalCode, + e.CountryRegion + }, "IX_Address_AddressLine1_AddressLine2_City_StateProvince_PostalCode_CountryRegion"); entity.HasIndex(e => e.StateProvince, "IX_Address_StateProvince"); @@ -113,7 +113,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity( entity => { - entity.HasIndex(e => e.Name,"AK_ProductCategory_Name") + entity.HasIndex(e => e.Name, "AK_ProductCategory_Name") .IsUnique(); entity.HasIndex(e => e.rowguid, "AK_ProductCategory_rowguid") @@ -218,12 +218,14 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) entity.HasIndex(e => e.CustomerID, "IX_SalesOrderHeader_CustomerID"); - entity.HasIndex(e => e.SalesOrderNumber, - "AK_SalesOrderHeader_SalesOrderNumber") + entity.HasIndex( + e => e.SalesOrderNumber, + "AK_SalesOrderHeader_SalesOrderNumber") .IsUnique(); - entity.HasIndex(e => e.rowguid, - "AK_SalesOrderHeader_rowguid") + entity.HasIndex( + e => e.rowguid, + "AK_SalesOrderHeader_rowguid") .IsUnique(); entity.Property(e => e.SalesOrderID).UseHiLo("SalesOrderNumber", "SalesLT"); diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureFixture.cs b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureFixture.cs index aa22d7f786a..8e46d6c48c5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureFixture.cs @@ -9,7 +9,11 @@ namespace Microsoft.EntityFrameworkCore.SqlAzure public class SqlAzureFixture : SharedStoreFixtureBase { protected override string StoreName { get; } = "adventureworks"; - protected override ITestStoreFactory TestStoreFactory => SqlServerAdventureWorksTestStoreFactory.Instance; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerAdventureWorksTestStoreFactory.Instance; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureFundamentalsTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureFundamentalsTest.cs index f3d06530281..804afdfd979 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureFundamentalsTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlAzure/SqlAzureFundamentalsTest.cs @@ -13,7 +13,9 @@ namespace Microsoft.EntityFrameworkCore.SqlAzure [SqlServerCondition(SqlServerCondition.IsSqlAzure)] public class SqlAzureFundamentalsTest : IClassFixture { - public SqlAzureFundamentalsTest(SqlAzureFixture fixture) => Fixture = fixture; + public SqlAzureFundamentalsTest(SqlAzureFixture fixture) + => Fixture = fixture; + public SqlAzureFixture Fixture { get; } [ConditionalFact] @@ -77,6 +79,7 @@ public void IncludeQuery() Assert.NotNull(order.Customer); } - protected AdventureWorksContext CreateContext() => Fixture.CreateContext(); + protected AdventureWorksContext CreateContext() + => Fixture.CreateContext(); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerConfigPatternsTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerConfigPatternsTest.cs index a6ca6b83798..5e9466b5de8 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerConfigPatternsTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerConfigPatternsTest.cs @@ -240,8 +240,9 @@ public NorthwindContext(DbContextOptions options) public DbSet Customers { get; set; } - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => - optionsBuilder.UseSqlServer(SqlServerNorthwindTestStoreFactory.NorthwindConnectionString, b => b.ApplyConfiguration()); + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + => optionsBuilder.UseSqlServer( + SqlServerNorthwindTestStoreFactory.NorthwindConnectionString, b => b.ApplyConfiguration()); protected override void OnModelCreating(ModelBuilder modelBuilder) => ConfigureModel(modelBuilder); @@ -455,9 +456,10 @@ public NorthwindContext(IServiceProvider serviceProvider) protected override void OnModelCreating(ModelBuilder modelBuilder) => ConfigureModel(modelBuilder); - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseInternalServiceProvider(_serviceProvider) - .UseSqlServer(SqlServerNorthwindTestStoreFactory.NorthwindConnectionString, b => b.ApplyConfiguration()); + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + => optionsBuilder + .UseInternalServiceProvider(_serviceProvider) + .UseSqlServer(SqlServerNorthwindTestStoreFactory.NorthwindConnectionString, b => b.ApplyConfiguration()); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerDatabaseCreatorTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerDatabaseCreatorTest.cs index 136bfd4f5a4..c5ee953a430 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerDatabaseCreatorTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerDatabaseCreatorTest.cs @@ -45,7 +45,10 @@ public Task Returns_false_when_database_with_filename_does_not_exist(bool async, } private static async Task Returns_false_when_database_does_not_exist_test( - bool async, bool ambientTransaction, bool useCanConnect, bool file) + bool async, + bool ambientTransaction, + bool useCanConnect, + bool file) { using var testDatabase = SqlServerTestStore.Create("NonExisting", file); using var context = new BloggingContext(testDatabase); @@ -811,7 +814,8 @@ public Task HasTablesAsyncBase(CancellationToken cancellationToken = defau return HasTablesAsync(cancellationToken); } - public IExecutionStrategyFactory ExecutionStrategyFactory => Dependencies.ExecutionStrategyFactory; + public IExecutionStrategyFactory ExecutionStrategyFactory + => Dependencies.ExecutionStrategyFactory; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerFixture.cs index 37fd2533b1b..776686c32c4 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerFixture.cs @@ -14,8 +14,11 @@ public class SqlServerFixture : ServiceProviderFixtureBase public static IServiceProvider DefaultServiceProvider { get; } = new ServiceCollection().AddEntityFrameworkSqlServer().BuildServiceProvider(); - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ServiceProvider.GetRequiredService(); - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ServiceProvider.GetRequiredService(); + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder).ConfigureWarnings( diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerQueryTriggersTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerQueryTriggersTest.cs index 57f1aed9878..8187d56023d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerQueryTriggersTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerQueryTriggersTest.cs @@ -11,7 +11,8 @@ namespace Microsoft.EntityFrameworkCore { public class SqlServerQueryTriggersTest : IClassFixture { - public SqlServerQueryTriggersTest(SqlServerTriggersFixture fixture) => Fixture = fixture; + public SqlServerQueryTriggersTest(SqlServerTriggersFixture fixture) + => Fixture = fixture; private SqlServerTriggersFixture Fixture { get; } @@ -78,7 +79,8 @@ public void Triggers_with_subqueries_work_with_batch_operations() context.SaveChanges(); } - protected QueryTriggersContext CreateContext() => (QueryTriggersContext)Fixture.CreateContext(); + protected QueryTriggersContext CreateContext() + => (QueryTriggersContext)Fixture.CreateContext(); protected class QueryTriggersContext : PoolableDbContext { @@ -114,7 +116,9 @@ public class SqlServerTriggersFixture : SharedStoreFixtureBase { protected override string StoreName { get; } = "SqlServerQueryTriggers"; protected override Type ContextType { get; } = typeof(QueryTriggersContext); - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override void Seed(DbContext context) { diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerTriggersTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerTriggersTest.cs index 8446d36ebb3..d4cfc82d2ff 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerTriggersTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerTriggersTest.cs @@ -12,7 +12,8 @@ namespace Microsoft.EntityFrameworkCore { public class SqlServerTriggersTest : IClassFixture { - public SqlServerTriggersTest(SqlServerTriggersFixture fixture) => Fixture = fixture; + public SqlServerTriggersTest(SqlServerTriggersFixture fixture) + => Fixture = fixture; private SqlServerTriggersFixture Fixture { get; } @@ -91,7 +92,8 @@ private static void AssertEqual(Product product, ProductBackup productBackup) Assert.Equal(product.Version, productBackup.Version); } - protected TriggersContext CreateContext() => (TriggersContext)Fixture.CreateContext(); + protected TriggersContext CreateContext() + => (TriggersContext)Fixture.CreateContext(); protected class TriggersContext : PoolableDbContext { @@ -138,7 +140,9 @@ public class SqlServerTriggersFixture : SharedStoreFixtureBase SqlServerTestStoreFactory.Instance; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override void Seed(PoolableDbContext context) { diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationConflictTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationConflictTest.cs index 0e1402a0c24..9a4102e42c2 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationConflictTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationConflictTest.cs @@ -10,7 +10,6 @@ using Microsoft.EntityFrameworkCore.SqlServer.Diagnostics.Internal; using Microsoft.EntityFrameworkCore.SqlServer.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Xunit; @@ -39,7 +38,7 @@ public virtual void SqlServerValueGeneration_conflicting_with_existing_ValueGene CoreStrings.WarningAsErrorTemplate( SqlServerEventId.ConflictingValueGenerationStrategiesWarning, SqlServerResources.LogConflictingValueGenerationStrategies( - new TestLogger()) + new TestLogger()) .GenerateMessage(SqlServerValueGenerationStrategy.SequenceHiLo.ToString(), "DefaultValueSql", "Id", nameof(Fred)), "SqlServerEventId.ConflictingValueGenerationStrategiesWarning"), Assert.Throws(() => Validate(modelBuilder)).Message); @@ -84,15 +83,17 @@ public virtual void SqlServerValueGeneration_conflicting_with_existing_ValueGene var logEntry = Fixture.ListLoggerFactory.Log.Single( l => l.Level == LogLevel.Warning && l.Id == SqlServerEventId.ConflictingValueGenerationStrategiesWarning); - Assert.Equal(SqlServerResources.LogConflictingValueGenerationStrategies( + Assert.Equal( + SqlServerResources.LogConflictingValueGenerationStrategies( new TestLogger()) - .GenerateMessage(SqlServerValueGenerationStrategy.SequenceHiLo.ToString(), "DefaultValueSql", "Id", nameof(Fred)), - logEntry.Message); + .GenerateMessage(SqlServerValueGenerationStrategy.SequenceHiLo.ToString(), "DefaultValueSql", "Id", nameof(Fred)), + logEntry.Message); } public class NoThrowContext : DbContext { - public NoThrowContext(DbContextOptions options) : base(options) + public NoThrowContext(DbContextOptions options) + : base(options) { } @@ -116,7 +117,8 @@ public SqlServerValueGenerationConflictTest(SqlServerValueGenerationStrategyFixt protected SqlServerValueGenerationStrategyFixture Fixture { get; } - public TContext CreateContext() => (TContext)Fixture.CreateContext(); + public TContext CreateContext() + => (TContext)Fixture.CreateContext(); protected virtual ModelBuilder CreateModelBuilder() { @@ -140,9 +142,14 @@ public class SqlServerValueGenerationStrategyFixture : SharedStoreFixt { protected override string StoreName { get; } = "SqlServerValueGenerationStrategy"; protected override Type ContextType { get; } = typeof(TContext); - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; + protected override bool ShouldLogCategory(string logCategory) => logCategory == DbLoggerCategory.Model.Validation.Name; - protected override bool UsePooling => false; + + protected override bool UsePooling + => false; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedFixupSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedFixupSqlServerTest.cs index 2c3312bfbd5..5855d412b02 100644 --- a/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedFixupSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedFixupSqlServerTest.cs @@ -65,14 +65,16 @@ protected override void MarkIdsTemporary(DbContext context, object game, object entry.Property("Id").IsTemporary = true; } - protected override bool EnforcesFKs => true; + protected override bool EnforcesFKs + => true; protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); public class StoreGeneratedFixupSqlServerFixture : StoreGeneratedFixupRelationalFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSqlServerTest.cs index 0e90b6ede6d..c9e65370978 100644 --- a/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/StoreGeneratedSqlServerTest.cs @@ -97,7 +97,8 @@ public virtual void Exception_in_SaveChanges_causes_store_values_to_be_reverted( public class StoreGeneratedSqlServerFixture : StoreGeneratedFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => builder diff --git a/test/EFCore.SqlServer.FunctionalTests/TPTTableSplittingSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/TPTTableSplittingSqlServerTest.cs index bfd387eb7a3..7dddf73b8ab 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TPTTableSplittingSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TPTTableSplittingSqlServerTest.cs @@ -13,7 +13,8 @@ public TPTTableSplittingSqlServerTest(ITestOutputHelper testOutputHelper) { } - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; public override void Can_use_with_redundant_relationships() { diff --git a/test/EFCore.SqlServer.FunctionalTests/TableSplittingSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/TableSplittingSqlServerTest.cs index 439e9c17232..f127c7b54d5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TableSplittingSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TableSplittingSqlServerTest.cs @@ -14,7 +14,8 @@ public TableSplittingSqlServerTest(ITestOutputHelper testOutputHelper) { } - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; public override void Can_use_with_redundant_relationships() { diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConditionAttribute.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConditionAttribute.cs index b37c2585ef9..903db7cb539 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConditionAttribute.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConditionAttribute.cs @@ -68,14 +68,15 @@ public ValueTask IsMetAsync() return new ValueTask(isMet); } - public string SkipReason => - // ReSharper disable once UseStringInterpolation - string.Format( - "The test SQL Server does not meet these conditions: '{0}'", - string.Join( - ", ", Enum.GetValues(typeof(SqlServerCondition)) - .Cast() - .Where(f => Conditions.HasFlag(f)) - .Select(f => Enum.GetName(typeof(SqlServerCondition), f)))); + public string SkipReason + => + // ReSharper disable once UseStringInterpolation + string.Format( + "The test SQL Server does not meet these conditions: '{0}'", + string.Join( + ", ", Enum.GetValues(typeof(SqlServerCondition)) + .Cast() + .Where(f => Conditions.HasFlag(f)) + .Select(f => Enum.GetName(typeof(SqlServerCondition), f)))); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConfiguredConditionAttribute.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConfiguredConditionAttribute.cs index 1f3dd5bc9e7..035cd4aa2ab 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConfiguredConditionAttribute.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerConfiguredConditionAttribute.cs @@ -15,8 +15,9 @@ public ValueTask IsMetAsync() => 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." - : "No test SQL Server has been configured."; + public string SkipReason + => TestEnvironment.IsLocalDb + ? "LocalDb is not accessible on this platform. An external SQL Server must be configured." + : "No test SQL Server has been configured."; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerDatabaseCleaner.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerDatabaseCleaner.cs index 43291143afe..40952b446a8 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerDatabaseCleaner.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerDatabaseCleaner.cs @@ -25,7 +25,8 @@ protected override IDatabaseModelFactory CreateDatabaseModelFactory(ILoggerFacto new SqlServerLoggingDefinitions(), new NullDbContextLogger())); - protected override bool AcceptTable(DatabaseTable table) => !(table is DatabaseView); + protected override bool AcceptTable(DatabaseTable table) + => !(table is DatabaseView); protected override bool AcceptIndex(DatabaseIndex index) => false; diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs index 86a8071fd43..b0967348b46 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/SqlServerTestStore.cs @@ -19,7 +19,9 @@ namespace Microsoft.EntityFrameworkCore.TestUtilities public class SqlServerTestStore : RelationalTestStore { public const int CommandTimeout = 300; - private static string CurrentDirectory => Environment.CurrentDirectory; + + private static string CurrentDirectory + => Environment.CurrentDirectory; public static SqlServerTestStore GetNorthwindStore() => (SqlServerTestStore)SqlServerNorthwindTestStoreFactory.Instance @@ -67,11 +69,15 @@ private SqlServerTestStore( } public SqlServerTestStore InitializeSqlServer( - IServiceProvider serviceProvider, Func createContext, Action seed) + IServiceProvider serviceProvider, + Func createContext, + Action seed) => (SqlServerTestStore)Initialize(serviceProvider, createContext, seed); public SqlServerTestStore InitializeSqlServer( - IServiceProvider serviceProvider, Func createContext, Action seed) + IServiceProvider serviceProvider, + Func createContext, + Action seed) => InitializeSqlServer(serviceProvider, () => createContext(this), seed); protected override void Initialize(Func createContext, Action seed, Action clean) @@ -290,8 +296,11 @@ private static Task> QueryAsync(DbConnection connection, strin }, sql, false, parameters); private static T Execute( - DbConnection connection, Func execute, string sql, - bool useTransaction = false, object[] parameters = null) + DbConnection connection, + Func execute, + string sql, + bool useTransaction = false, + object[] parameters = null) => new TestSqlServerRetryingExecutionStrategy().Execute( new { @@ -304,7 +313,11 @@ private static T Execute( 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) + DbConnection connection, + Func execute, + string sql, + bool useTransaction, + object[] parameters) { if (connection.State != ConnectionState.Closed) { @@ -336,8 +349,11 @@ private static T ExecuteCommand( } private static Task ExecuteAsync( - DbConnection connection, Func> executeAsync, string sql, - bool useTransaction = false, IReadOnlyList parameters = null) + DbConnection connection, + Func> executeAsync, + string sql, + bool useTransaction = false, + IReadOnlyList parameters = null) => new TestSqlServerRetryingExecutionStrategy().ExecuteAsync( new { @@ -350,7 +366,10 @@ private static Task ExecuteAsync( state => ExecuteCommandAsync(state.connection, state.executeAsync, state.sql, state.useTransaction, state.parameters)); private static async Task ExecuteCommandAsync( - DbConnection connection, Func> executeAsync, string sql, bool useTransaction, + DbConnection connection, + Func> executeAsync, + string sql, + bool useTransaction, IReadOnlyList parameters) { if (connection.State != ConnectionState.Closed) @@ -385,7 +404,9 @@ private static async Task ExecuteCommandAsync( } private static DbCommand CreateCommand( - DbConnection connection, string commandText, IReadOnlyList parameters = null) + DbConnection connection, + string commandText, + IReadOnlyList parameters = null) { var command = (SqlCommand)connection.CreateCommand(); diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestEnvironment.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestEnvironment.cs index a8f3fef272c..35fcc9d8d42 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestEnvironment.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestEnvironment.cs @@ -65,7 +65,7 @@ public static bool IsSqlAzure { _isAzureSqlDb = false; } - + return _isAzureSqlDb.Value; } } @@ -106,7 +106,7 @@ public static bool IsFullTextSearchSupported } } - public static bool IsHiddenColumnsSupported + public static bool IsHiddenColumnsSupported { get { @@ -131,7 +131,7 @@ public static bool IsHiddenColumnsSupported { _supportsHiddenColumns = false; } - + return _supportsHiddenColumns.Value; } } diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs index f54a4da73c6..a534ec6a3e5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs @@ -36,7 +36,8 @@ public TestRelationalCommandBuilder( public RelationalCommandBuilderDependencies Dependencies { get; } - public IReadOnlyList Parameters => _parameters; + public IReadOnlyList Parameters + => _parameters; public IRelationalCommandBuilder AddParameter(IRelationalParameter parameter) { @@ -45,7 +46,8 @@ public IRelationalCommandBuilder AddParameter(IRelationalParameter parameter) return this; } - public IRelationalTypeMappingSource TypeMappingSource => Dependencies.TypeMappingSource; + public IRelationalTypeMappingSource TypeMappingSource + => Dependencies.TypeMappingSource; public IRelationalCommand Build() => new TestRelationalCommand( @@ -81,7 +83,8 @@ public IRelationalCommandBuilder DecrementIndent() return this; } - public int CommandTextLength => Instance.Length; + public int CommandTextLength + => Instance.Length; } private class TestRelationalCommand : IRelationalCommand @@ -96,9 +99,11 @@ public TestRelationalCommand( _realRelationalCommand = new RelationalCommand(dependencies, commandText, parameters); } - public string CommandText => _realRelationalCommand.CommandText; + public string CommandText + => _realRelationalCommand.CommandText; - public IReadOnlyList Parameters => _realRelationalCommand.Parameters; + public IReadOnlyList Parameters + => _realRelationalCommand.Parameters; public int ExecuteNonQuery(RelationalCommandParameterObject parameterObject) { diff --git a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalTransaction.cs b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalTransaction.cs index ef7505e7f37..bf4d47aba23 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalTransaction.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TestUtilities/TestRelationalTransaction.cs @@ -83,16 +83,19 @@ public override async Task CommitAsync(CancellationToken cancellationToken = def await base.CommitAsync(cancellationToken); } - public override bool SupportsSavepoints => true; + public override bool SupportsSavepoints + => true; /// - protected override string GetCreateSavepointSql(string name) => "SAVE TRANSACTION " + name; + protected override string GetCreateSavepointSql(string name) + => "SAVE TRANSACTION " + name; /// - protected override string GetRollbackToSavepointSql(string name) => "ROLLBACK TRANSACTION " + name; + protected override string GetRollbackToSavepointSql(string name) + => "ROLLBACK TRANSACTION " + name; /// - public override void ReleaseSavepoint(string name) {} + public override void ReleaseSavepoint(string name) { } /// public override Task ReleaseSavepointAsync(string name, CancellationToken cancellationToken = default) diff --git a/test/EFCore.SqlServer.FunctionalTests/TransactionInterceptionSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/TransactionInterceptionSqlServerTest.cs index 2e7b2e3e157..12a5668863a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TransactionInterceptionSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TransactionInterceptionSqlServerTest.cs @@ -19,8 +19,11 @@ protected TransactionInterceptionSqlServerTestBase(InterceptionSqlServerFixtureB public abstract class InterceptionSqlServerFixtureBase : InterceptionFixtureBase { - protected override string StoreName => "TransactionInterception"; - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override string StoreName + => "TransactionInterception"; + + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override IServiceCollection InjectInterceptors( IServiceCollection serviceCollection, @@ -37,11 +40,13 @@ public TransactionInterceptionSqlServerTest(InterceptionSqlServerFixture fixture } // ReleaseSavepoint is unsupported by SQL Server and is ignored - public override Task Intercept_ReleaseSavepoint(bool async) => Task.CompletedTask; + public override Task Intercept_ReleaseSavepoint(bool async) + => Task.CompletedTask; public class InterceptionSqlServerFixture : InterceptionSqlServerFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => false; + protected override bool ShouldSubscribeToDiagnosticListener + => false; } } @@ -55,11 +60,13 @@ public TransactionInterceptionWithDiagnosticsSqlServerTest(InterceptionSqlServer } // ReleaseSavepoint is unsupported by SQL Server and is ignored - public override Task Intercept_ReleaseSavepoint(bool async) => Task.CompletedTask; + public override Task Intercept_ReleaseSavepoint(bool async) + => Task.CompletedTask; public class InterceptionSqlServerFixture : InterceptionSqlServerFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => true; + protected override bool ShouldSubscribeToDiagnosticListener + => true; } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/TransactionSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/TransactionSqlServerTest.cs index 82227ed1b5a..fce8f6710fe 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TransactionSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TransactionSqlServerTest.cs @@ -14,9 +14,11 @@ public TransactionSqlServerTest(TransactionSqlServerFixture fixture) { } - protected override bool SnapshotSupported => true; + protected override bool SnapshotSupported + => true; - protected override bool AmbientTransactionsSupported => true; + protected override bool AmbientTransactionsSupported + => true; protected override DbContext CreateContextWithConnectionString() { @@ -32,7 +34,8 @@ protected override DbContext CreateContextWithConnectionString() public class TransactionSqlServerFixture : TransactionFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override void Seed(PoolableDbContext context) { diff --git a/test/EFCore.SqlServer.FunctionalTests/TwoDatabasesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/TwoDatabasesSqlServerTest.cs index fa201722dba..d66be4da382 100644 --- a/test/EFCore.SqlServer.FunctionalTests/TwoDatabasesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/TwoDatabasesSqlServerTest.cs @@ -13,10 +13,12 @@ public TwoDatabasesSqlServerTest(SqlServerFixture fixture) { } - protected new SqlServerFixture Fixture => (SqlServerFixture)base.Fixture; + protected new SqlServerFixture Fixture + => (SqlServerFixture)base.Fixture; protected override DbContextOptionsBuilder CreateTestOptions( - DbContextOptionsBuilder optionsBuilder, bool withConnectionString = false) + DbContextOptionsBuilder optionsBuilder, + bool withConnectionString = false) => withConnectionString ? optionsBuilder.UseSqlServer(DummyConnectionString) : optionsBuilder.UseSqlServer(); diff --git a/test/EFCore.SqlServer.FunctionalTests/UpdatesSqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/UpdatesSqlServerFixture.cs index 492c70cb39c..22705505bd9 100644 --- a/test/EFCore.SqlServer.FunctionalTests/UpdatesSqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/UpdatesSqlServerFixture.cs @@ -9,7 +9,8 @@ namespace Microsoft.EntityFrameworkCore { public class UpdatesSqlServerFixture : UpdatesRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => base.AddOptions(builder).ConfigureWarnings( diff --git a/test/EFCore.SqlServer.FunctionalTests/UpdatesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/UpdatesSqlServerTest.cs index 3b490a75228..f8044d88651 100644 --- a/test/EFCore.SqlServer.FunctionalTests/UpdatesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/UpdatesSqlServerTest.cs @@ -26,13 +26,7 @@ public virtual void Save_with_shared_foreign_key() context => { context.AddRange( - new ProductWithBytes - { - ProductCategories = new List - { - new ProductCategory { CategoryId = 77 } - } - }, + new ProductWithBytes { ProductCategories = new List { new ProductCategory { CategoryId = 77 } } }, new Category { Id = 77, PrincipalId = 777 }); context.SaveChanges(); @@ -75,7 +69,6 @@ WHEN NOT MATCHED THEN SELECT [t].[Id] FROM [ProductBase] t INNER JOIN @inserted0 i ON ([t].[Id] = [i].[Id]) ORDER BY [i].[_Position];"); - } public override void Save_replaced_principal() diff --git a/test/EFCore.SqlServer.FunctionalTests/WithConstructorsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/WithConstructorsSqlServerTest.cs index 90f2e4fe818..59787a7f6bc 100644 --- a/test/EFCore.SqlServer.FunctionalTests/WithConstructorsSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/WithConstructorsSqlServerTest.cs @@ -19,7 +19,8 @@ protected override void UseTransaction(DatabaseFacade facade, IDbContextTransact public class WithConstructorsSqlServerFixture : WithConstructorsFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqlServerTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.SqlServer.Tests/DbSetAsTableNameSqlServerTest.cs b/test/EFCore.SqlServer.Tests/DbSetAsTableNameSqlServerTest.cs index 7ff33ac299d..0fa2fb385c2 100644 --- a/test/EFCore.SqlServer.Tests/DbSetAsTableNameSqlServerTest.cs +++ b/test/EFCore.SqlServer.Tests/DbSetAsTableNameSqlServerTest.cs @@ -8,9 +8,11 @@ public class DbSetAsTableNameSqlServerTest : DbSetAsTableNameTest protected override string GetTableName(DbContext context) => context.Model.FindEntityType(typeof(TEntity)).GetTableName(); - protected override SetsContext CreateContext() => new SqlServerSetsContext(); + protected override SetsContext CreateContext() + => new SqlServerSetsContext(); - protected override SetsContext CreateNamedTablesContext() => new SqlServerNamedTablesContextContext(); + protected override SetsContext CreateNamedTablesContext() + => new SqlServerNamedTablesContextContext(); protected class SqlServerSetsContext : SetsContext { diff --git a/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs b/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs index 125bff8cd29..bac030f2e87 100644 --- a/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs +++ b/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs @@ -2,12 +2,9 @@ // 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 Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.SqlServer.Design.Internal; -using Microsoft.EntityFrameworkCore.SqlServer.Metadata.Internal; using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -171,7 +168,8 @@ public void GenerateFluentApi_IModel_works_with_identity() Assert.Equal("UseIdentityColumns", result.Method); - Assert.Collection(result.Arguments, + Assert.Collection( + result.Arguments, seed => Assert.Equal(5, seed), increment => Assert.Equal(10, increment)); } @@ -189,7 +187,8 @@ public void GenerateFluentApi_IProperty_works_with_identity() Assert.Equal("UseIdentityColumn", result.Method); - Assert.Collection(result.Arguments, + Assert.Collection( + result.Arguments, seed => Assert.Equal(5, seed), increment => Assert.Equal(10, increment)); } @@ -206,7 +205,8 @@ public void GenerateFluentApi_IModel_works_with_HiLo() Assert.Equal("UseHiLo", result.Method); - Assert.Collection(result.Arguments, + Assert.Collection( + result.Arguments, name => Assert.Equal("HiLoIndexName", name), schema => Assert.Equal("HiLoIndexSchema", schema)); } @@ -224,7 +224,8 @@ public void GenerateFluentApi_IProperty_works_with_HiLo() Assert.Equal("UseHiLo", result.Method); - Assert.Collection(result.Arguments, + Assert.Collection( + result.Arguments, name => Assert.Equal("HiLoIndexName", name), schema => Assert.Equal("HiLoIndexSchema", schema)); } diff --git a/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs b/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs index 44dcb008327..c4e072023b7 100644 --- a/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs +++ b/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Diagnostics.Internal; 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; @@ -524,7 +523,8 @@ public void Metadata_throws_when_setting_conflicting_serverGenerated_values(stri [InlineData(SqlServerValueGenerationStrategy.SequenceHiLo, "DefaultValueSql")] [InlineData(SqlServerValueGenerationStrategy.SequenceHiLo, "ComputedColumnSql")] public void SqlServerValueGenerationStrategy_warns_when_setting_conflicting_value_generation_strategies( - SqlServerValueGenerationStrategy sqlServerValueGenerationStrategy, string conflictingValueGenerationStrategy) + SqlServerValueGenerationStrategy sqlServerValueGenerationStrategy, + string conflictingValueGenerationStrategy) { var modelBuilder = CreateConventionalModelBuilder(); @@ -552,11 +552,13 @@ public void SqlServerValueGenerationStrategy_warns_when_setting_conflicting_Defa propertyBuilder.Metadata.SetValueGenerationStrategy(sqlServerValueGenerationStrategy); ConfigureProperty(propertyBuilder.Metadata, "DefaultValue", "2"); - VerifyWarnings( new[] { - SqlServerResources.LogConflictingValueGenerationStrategies(new TestLogger()) - .GenerateMessage(sqlServerValueGenerationStrategy.ToString(), "DefaultValue", "Id", nameof(Dog)), - RelationalResources.LogKeyHasDefaultValue(new TestLogger()) - .GenerateMessage("Id", nameof(Dog)) + VerifyWarnings( + new[] + { + SqlServerResources.LogConflictingValueGenerationStrategies(new TestLogger()) + .GenerateMessage(sqlServerValueGenerationStrategy.ToString(), "DefaultValue", "Id", nameof(Dog)), + RelationalResources.LogKeyHasDefaultValue(new TestLogger()) + .GenerateMessage("Id", nameof(Dog)) }, modelBuilder.Model); } @@ -596,6 +598,7 @@ private class Cheese public string Name { get; set; } } - protected override TestHelpers TestHelpers => SqlServerTestHelpers.Instance; + protected override TestHelpers TestHelpers + => SqlServerTestHelpers.Instance; } } diff --git a/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerConventionSetBuilderTests.cs b/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerConventionSetBuilderTests.cs index 0a40ccd97f8..6e4a93da86d 100644 --- a/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerConventionSetBuilderTests.cs +++ b/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerConventionSetBuilderTests.cs @@ -17,7 +17,10 @@ public override IModel Can_build_a_model_with_default_conventions_without_DI() return model; } - protected override ConventionSet GetConventionSet() => SqlServerConventionSetBuilder.Build(); - protected override ModelBuilder GetModelBuilder() => SqlServerConventionSetBuilder.CreateModelBuilder(); + protected override ConventionSet GetConventionSet() + => SqlServerConventionSetBuilder.Build(); + + protected override ModelBuilder GetModelBuilder() + => SqlServerConventionSetBuilder.CreateModelBuilder(); } } diff --git a/test/EFCore.SqlServer.Tests/Metadata/SqlServerBuilderExtensionsTest.cs b/test/EFCore.SqlServer.Tests/Metadata/SqlServerBuilderExtensionsTest.cs index 2e057ab3870..415650d0a4b 100644 --- a/test/EFCore.SqlServer.Tests/Metadata/SqlServerBuilderExtensionsTest.cs +++ b/test/EFCore.SqlServer.Tests/Metadata/SqlServerBuilderExtensionsTest.cs @@ -738,7 +738,6 @@ public void Can_write_index_filter_with_where_clauses_generic() Assert.Equal("[Id] % 2 = 0", index.GetFilter()); } - [ConditionalFact] public void Can_set_index_with_fillfactor() { @@ -776,13 +775,14 @@ public void Throws_if_attempt_to_set_fillfactor_with_argument_out_of_range(int f { var modelBuilder = CreateConventionModelBuilder(); - Assert.Throws(() => - { - modelBuilder - .Entity(typeof(Customer)) - .HasIndex("Name") - .HasFillFactor(fillFactor); - }); + Assert.Throws( + () => + { + modelBuilder + .Entity(typeof(Customer)) + .HasIndex("Name") + .HasFillFactor(fillFactor); + }); } private void AssertIsGeneric(EntityTypeBuilder _) diff --git a/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataExtensionsTest.cs b/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataExtensionsTest.cs index d1079a83a15..be296162d87 100644 --- a/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataExtensionsTest.cs +++ b/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataExtensionsTest.cs @@ -512,7 +512,8 @@ public void TryGetSequence_with_schema_returns_sequence_model_is_marked_for_sequ Assert.Equal("R", property.FindHiLoSequence().Schema); } - private static ModelBuilder GetModelBuilder() => SqlServerTestHelpers.Instance.CreateConventionBuilder(); + private static ModelBuilder GetModelBuilder() + => SqlServerTestHelpers.Instance.CreateConventionBuilder(); // ReSharper disable once ClassNeverInstantiated.Local private class Customer diff --git a/test/EFCore.SqlServer.Tests/Migrations/SqlServerHistoryRepositoryTest.cs b/test/EFCore.SqlServer.Tests/Migrations/SqlServerHistoryRepositoryTest.cs index 888f7581bd9..574d83be2e4 100644 --- a/test/EFCore.SqlServer.Tests/Migrations/SqlServerHistoryRepositoryTest.cs +++ b/test/EFCore.SqlServer.Tests/Migrations/SqlServerHistoryRepositoryTest.cs @@ -12,7 +12,8 @@ namespace Microsoft.EntityFrameworkCore.Migrations { public class SqlServerHistoryRepositoryTest { - private static string EOL => Environment.NewLine; + private static string EOL + => Environment.NewLine; [ConditionalFact] public void GetCreateScript_works() diff --git a/test/EFCore.SqlServer.Tests/Migrations/SqlServerMigrationsSqlGeneratorTest.cs b/test/EFCore.SqlServer.Tests/Migrations/SqlServerMigrationsSqlGeneratorTest.cs index 3aa0e39eb71..aac80af8446 100644 --- a/test/EFCore.SqlServer.Tests/Migrations/SqlServerMigrationsSqlGeneratorTest.cs +++ b/test/EFCore.SqlServer.Tests/Migrations/SqlServerMigrationsSqlGeneratorTest.cs @@ -18,7 +18,8 @@ namespace Microsoft.EntityFrameworkCore.Migrations { public class SqlServerMigrationsSqlGeneratorTest : MigrationsSqlGeneratorTestBase { - protected static string SQL_EOL => string.Join(", ", EOL.Select(c => "CHAR(" + (short)c + ")")); + protected static string SQL_EOL + => string.Join(", ", EOL.Select(c => "CHAR(" + (short)c + ")")); [ConditionalFact] public virtual void AddColumnOperation_identity_legacy() @@ -1071,12 +1072,13 @@ public virtual void UpdateData_generates_exec_when_idempotent() } public SqlServerMigrationsSqlGeneratorTest() - : base(SqlServerTestHelpers.Instance, - new ServiceCollection().AddEntityFrameworkSqlServerNetTopologySuite(), - SqlServerTestHelpers.Instance.AddProviderOptions( - ((IRelationalDbContextOptionsBuilderInfrastructure) - new SqlServerDbContextOptionsBuilder(new DbContextOptionsBuilder()).UseNetTopologySuite()) - .OptionsBuilder).Options) + : base( + SqlServerTestHelpers.Instance, + new ServiceCollection().AddEntityFrameworkSqlServerNetTopologySuite(), + SqlServerTestHelpers.Instance.AddProviderOptions( + ((IRelationalDbContextOptionsBuilderInfrastructure) + new SqlServerDbContextOptionsBuilder(new DbContextOptionsBuilder()).UseNetTopologySuite()) + .OptionsBuilder).Options) { } } diff --git a/test/EFCore.SqlServer.Tests/Migrations/SqlServerModelDifferTest.cs b/test/EFCore.SqlServer.Tests/Migrations/SqlServerModelDifferTest.cs index 179a7f90c88..43257f8de05 100644 --- a/test/EFCore.SqlServer.Tests/Migrations/SqlServerModelDifferTest.cs +++ b/test/EFCore.SqlServer.Tests/Migrations/SqlServerModelDifferTest.cs @@ -740,11 +740,7 @@ public void Dont_reseed_value_with_value_generated_on_add_property() x.Property("ValueGeneratedOnAddProperty") .ValueGeneratedOnAdd(); x.HasData( - new - { - Id = 1, - ValueGeneratedOnAddProperty = "Value" - }); + new { Id = 1, ValueGeneratedOnAddProperty = "Value" }); }); }, source => { }, @@ -936,117 +932,114 @@ public void Noop_TPT_with_FKs_and_seed_data() }, source => { - source.Entity("Animal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .UseIdentityColumn(); + source.Entity( + "Animal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .UseIdentityColumn(); - b.Property("MouseId") - .HasColumnType("int"); + b.Property("MouseId") + .HasColumnType("int"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("MouseId"); + b.HasIndex("MouseId"); - b.ToTable("Animal"); - }); + b.ToTable("Animal"); + }); - source.Entity("Cat", b => - { - b.HasBaseType("Animal"); + source.Entity( + "Cat", b => + { + b.HasBaseType("Animal"); - b.Property("PreyId") - .HasColumnType("int") - .HasColumnName("PreyId"); + b.Property("PreyId") + .HasColumnType("int") + .HasColumnName("PreyId"); - b.HasIndex("PreyId"); + b.HasIndex("PreyId"); - b.ToTable("Cats"); + b.ToTable("Cats"); - b.HasData( - new - { - Id = 11, - MouseId = 31 - }); - }); + b.HasData( + new { Id = 11, MouseId = 31 }); + }); - source.Entity("Dog", b => - { - b.HasBaseType("Animal"); + source.Entity( + "Dog", b => + { + b.HasBaseType("Animal"); - b.Property("PreyId") - .HasColumnType("int") - .HasColumnName("PreyId"); + b.Property("PreyId") + .HasColumnType("int") + .HasColumnName("PreyId"); - b.HasIndex("PreyId"); + b.HasIndex("PreyId"); - b.ToTable("Dogs"); + b.ToTable("Dogs"); - b.HasData( - new - { - Id = 21, - PreyId = 31 - }); - }); + b.HasData( + new { Id = 21, PreyId = 31 }); + }); - source.Entity("Mouse", b => - { - b.HasBaseType("Animal"); + source.Entity( + "Mouse", b => + { + b.HasBaseType("Animal"); - b.ToTable("Mice"); + b.ToTable("Mice"); - b.HasData( - new - { - Id = 31 - }); - }); + b.HasData( + new { Id = 31 }); + }); - source.Entity("Animal", b => - { - b.HasOne("Mouse", null) - .WithMany() - .HasForeignKey("MouseId"); - }); + source.Entity( + "Animal", b => + { + b.HasOne("Mouse", null) + .WithMany() + .HasForeignKey("MouseId"); + }); - source.Entity("Cat", b => - { - b.HasOne("Animal", null) - .WithOne() - .HasForeignKey("Cat", "Id") - .OnDelete(DeleteBehavior.ClientCascade) - .IsRequired(); - - b.HasOne("Animal", null) - .WithMany() - .HasForeignKey("PreyId"); - }); - - source.Entity("Dog", b => - { - b.HasOne("Animal", null) - .WithOne() - .HasForeignKey("Dog", "Id") - .OnDelete(DeleteBehavior.ClientCascade) - .IsRequired(); - - b.HasOne("Animal", null) - .WithMany() - .HasForeignKey("PreyId"); - }); - - source.Entity("Mouse", b => - { - b.HasOne("Animal", null) - .WithOne() - .HasForeignKey("Mouse", "Id") - .OnDelete(DeleteBehavior.ClientCascade) - .IsRequired(); - }); + source.Entity( + "Cat", b => + { + b.HasOne("Animal", null) + .WithOne() + .HasForeignKey("Cat", "Id") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.HasOne("Animal", null) + .WithMany() + .HasForeignKey("PreyId"); + }); + + source.Entity( + "Dog", b => + { + b.HasOne("Animal", null) + .WithOne() + .HasForeignKey("Dog", "Id") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.HasOne("Animal", null) + .WithMany() + .HasForeignKey("PreyId"); + }); + + source.Entity( + "Mouse", b => + { + b.HasOne("Animal", null) + .WithOne() + .HasForeignKey("Mouse", "Id") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + }); }, modelBuilder => { @@ -1095,7 +1088,8 @@ public void Noop_TPT_with_FKs_and_seed_data() skipSourceConventions: true); } - protected override TestHelpers TestHelpers => SqlServerTestHelpers.Instance; + protected override TestHelpers TestHelpers + => SqlServerTestHelpers.Instance; protected override MigrationsModelDiffer CreateModelDiffer(DbContextOptions options) => (MigrationsModelDiffer)TestHelpers.CreateContext(options).GetService(); @@ -1241,10 +1235,10 @@ public void Rebuild_index_with_different_fillfactor_value() Assert.Equal("IX_Address_Zip", operation1.Name); var annotation = operation2.GetAnnotation(SqlServerAnnotationNames.FillFactor); - Assert.NotNull(annotation); + Assert.NotNull(annotation); + + var annotationValue = Assert.IsType(annotation.Value); - var annotationValue = Assert.IsType(annotation.Value); - Assert.Equal(90, annotationValue); }); } diff --git a/test/EFCore.SqlServer.Tests/ModelBuilding/SqlServerModelBuilderGenericTest.cs b/test/EFCore.SqlServer.Tests/ModelBuilding/SqlServerModelBuilderGenericTest.cs index a4b72de3749..574c3478157 100644 --- a/test/EFCore.SqlServer.Tests/ModelBuilding/SqlServerModelBuilderGenericTest.cs +++ b/test/EFCore.SqlServer.Tests/ModelBuilding/SqlServerModelBuilderGenericTest.cs @@ -262,9 +262,11 @@ public virtual void Owned_types_use_table_splitting_by_default() Assert.Equal(4, model.GetEntityTypes().Count(e => e.ClrType == typeof(AnotherBookLabel))); Assert.Equal(4, model.GetEntityTypes().Count(e => e.ClrType == typeof(SpecialBookLabel))); - Assert.Null(bookOwnership1.DeclaringEntityType.FindProperty(nameof(BookLabel.Id)) + Assert.Null( + bookOwnership1.DeclaringEntityType.FindProperty(nameof(BookLabel.Id)) .GetColumnName(StoreObjectIdentifier.Table("Label", null))); - Assert.Null(bookLabel2Ownership1.DeclaringEntityType.FindProperty(nameof(BookLabel.Id)) + Assert.Null( + bookLabel2Ownership1.DeclaringEntityType.FindProperty(nameof(BookLabel.Id)) .GetColumnName(StoreObjectIdentifier.Table("AlternateLabel", null))); modelBuilder.Entity().OwnsOne(b => b.Label).ToTable("Label"); diff --git a/test/EFCore.SqlServer.Tests/ModelBuilding/SqlServerTestModelBuilderExtensions.cs b/test/EFCore.SqlServer.Tests/ModelBuilding/SqlServerTestModelBuilderExtensions.cs index e7ebabce531..4910a2694c2 100644 --- a/test/EFCore.SqlServer.Tests/ModelBuilding/SqlServerTestModelBuilderExtensions.cs +++ b/test/EFCore.SqlServer.Tests/ModelBuilding/SqlServerTestModelBuilderExtensions.cs @@ -9,7 +9,8 @@ namespace Microsoft.EntityFrameworkCore.ModelBuilding public static class SqlServerTestModelBuilderExtensions { public static ModelBuilderTest.TestIndexBuilder IsClustered( - this ModelBuilderTest.TestIndexBuilder builder, bool clustered = true) + this ModelBuilderTest.TestIndexBuilder builder, + bool clustered = true) { switch (builder) { @@ -26,7 +27,8 @@ public static ModelBuilderTest.TestIndexBuilder IsClustered( public static ModelBuilderTest.TestOwnedNavigationBuilder IsMemoryOptimized( - this ModelBuilderTest.TestOwnedNavigationBuilder builder, bool memoryOptimized = true) + this ModelBuilderTest.TestOwnedNavigationBuilder builder, + bool memoryOptimized = true) where TEntity : class where TDependentEntity : class { diff --git a/test/EFCore.SqlServer.Tests/SqlServerApiConsistencyTest.cs b/test/EFCore.SqlServer.Tests/SqlServerApiConsistencyTest.cs index 4af42a0cbd7..dc985804c16 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerApiConsistencyTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerApiConsistencyTest.cs @@ -23,7 +23,8 @@ public SqlServerApiConsistencyTest(SqlServerApiConsistencyFixture fixture) protected override void AddServices(ServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkSqlServer(); - protected override Assembly TargetAssembly => typeof(SqlServerConnection).Assembly; + protected override Assembly TargetAssembly + => typeof(SqlServerConnection).Assembly; public class SqlServerApiConsistencyFixture : ApiConsistencyFixtureBase { @@ -34,7 +35,7 @@ public override bool TryGetProviderOptionsDelegate(out Action FluentApiTypes { get; } = new HashSet() + public override HashSet FluentApiTypes { get; } = new HashSet { typeof(SqlServerDbContextOptionsBuilder), typeof(SqlServerDbContextOptionsExtensions), @@ -47,14 +48,21 @@ public override bool TryGetProviderOptionsDelegate(out Action MetadataExtensionTypes { get; } + public override + List<(Type Type, Type ReadonlyExtensions, Type MutableExtensions, Type ConventionExtensions, Type + ConventionBuilderExtensions)> MetadataExtensionTypes { get; } = new List<(Type, Type, Type, Type, Type)> { - { (typeof(IModel), typeof(SqlServerModelExtensions), typeof(SqlServerModelExtensions), typeof(SqlServerModelExtensions), typeof(SqlServerModelBuilderExtensions)) }, - { (typeof(IEntityType), typeof(SqlServerEntityTypeExtensions), typeof(SqlServerEntityTypeExtensions), typeof(SqlServerEntityTypeExtensions), typeof(SqlServerEntityTypeBuilderExtensions)) }, - { (typeof(IKey),typeof(SqlServerKeyExtensions), typeof(SqlServerKeyExtensions), typeof(SqlServerKeyExtensions), typeof(SqlServerKeyBuilderExtensions)) }, - { (typeof(IProperty), typeof(SqlServerPropertyExtensions), typeof(SqlServerPropertyExtensions), typeof(SqlServerPropertyExtensions), typeof(SqlServerPropertyBuilderExtensions)) }, - { (typeof(IIndex), typeof(SqlServerIndexExtensions), typeof(SqlServerIndexExtensions), typeof(SqlServerIndexExtensions), typeof(SqlServerIndexBuilderExtensions)) } + (typeof(IModel), typeof(SqlServerModelExtensions), typeof(SqlServerModelExtensions), + typeof(SqlServerModelExtensions), typeof(SqlServerModelBuilderExtensions)), + (typeof(IEntityType), typeof(SqlServerEntityTypeExtensions), typeof(SqlServerEntityTypeExtensions), + typeof(SqlServerEntityTypeExtensions), typeof(SqlServerEntityTypeBuilderExtensions)), + (typeof(IKey), typeof(SqlServerKeyExtensions), typeof(SqlServerKeyExtensions), typeof(SqlServerKeyExtensions), + typeof(SqlServerKeyBuilderExtensions)), + (typeof(IProperty), typeof(SqlServerPropertyExtensions), typeof(SqlServerPropertyExtensions), + typeof(SqlServerPropertyExtensions), typeof(SqlServerPropertyBuilderExtensions)), + (typeof(IIndex), typeof(SqlServerIndexExtensions), typeof(SqlServerIndexExtensions), + typeof(SqlServerIndexExtensions), typeof(SqlServerIndexBuilderExtensions)) }; } } diff --git a/test/EFCore.SqlServer.Tests/SqlServerDatabaseCreatorTest.cs b/test/EFCore.SqlServer.Tests/SqlServerDatabaseCreatorTest.cs index b1ac84d4487..49055c09b8e 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerDatabaseCreatorTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerDatabaseCreatorTest.cs @@ -207,7 +207,8 @@ private class FakeRelationalCommandBuilder : IRelationalCommandBuilder private readonly List _parameters = new List(); public IndentedStringBuilder Instance { get; } = new IndentedStringBuilder(); - public IReadOnlyList Parameters => _parameters; + public IReadOnlyList Parameters + => _parameters; public IRelationalCommandBuilder AddParameter(IRelationalParameter parameter) { @@ -216,9 +217,11 @@ public IRelationalCommandBuilder AddParameter(IRelationalParameter parameter) return this; } - public IRelationalTypeMappingSource TypeMappingSource => null; + public IRelationalTypeMappingSource TypeMappingSource + => null; - public IRelationalCommand Build() => new FakeRelationalCommand(); + public IRelationalCommand Build() + => new FakeRelationalCommand(); public IRelationalCommandBuilder Append(string value) { @@ -248,7 +251,8 @@ public IRelationalCommandBuilder DecrementIndent() return this; } - public int CommandTextLength => Instance.Length; + public int CommandTextLength + => Instance.Length; } private class FakeRelationalCommand : IRelationalCommand @@ -257,7 +261,8 @@ private class FakeRelationalCommand : IRelationalCommand public IReadOnlyList Parameters { get; } - public IReadOnlyDictionary ParameterValues => throw new NotImplementedException(); + public IReadOnlyDictionary ParameterValues + => throw new NotImplementedException(); public int ExecuteNonQuery(RelationalCommandParameterObject parameterObject) { diff --git a/test/EFCore.SqlServer.Tests/SqlServerNTSApiConsistencyTest.cs b/test/EFCore.SqlServer.Tests/SqlServerNTSApiConsistencyTest.cs index f7dd61a77de..9d1b0e6a6eb 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerNTSApiConsistencyTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerNTSApiConsistencyTest.cs @@ -31,7 +31,7 @@ public override bool TryGetProviderOptionsDelegate(out Action FluentApiTypes { get; } = new HashSet() + public override HashSet FluentApiTypes { get; } = new HashSet { typeof(SqlServerNetTopologySuiteDbContextOptionsBuilderExtensions), typeof(SqlServerNetTopologySuiteServiceCollectionExtensions) diff --git a/test/EFCore.SqlServer.Tests/SqlServerSequenceValueGeneratorTest.cs b/test/EFCore.SqlServer.Tests/SqlServerSequenceValueGeneratorTest.cs index b38451dea63..c55eb098c55 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerSequenceValueGeneratorTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerSequenceValueGeneratorTest.cs @@ -26,42 +26,50 @@ public class SqlServerSequenceValueGeneratorTest [ConditionalTheory] [InlineData(false)] [InlineData(true)] - public async Task Generates_sequential_int_values(bool async) => await Generates_sequential_values(async); + public async Task Generates_sequential_int_values(bool async) + => await Generates_sequential_values(async); [ConditionalTheory] [InlineData(false)] [InlineData(true)] - public async Task Generates_sequential_long_values(bool async) => await Generates_sequential_values(async); + public async Task Generates_sequential_long_values(bool async) + => await Generates_sequential_values(async); [ConditionalTheory] [InlineData(false)] [InlineData(true)] - public async Task Generates_sequential_short_values(bool async) => await Generates_sequential_values(async); + public async Task Generates_sequential_short_values(bool async) + => await Generates_sequential_values(async); [ConditionalTheory] [InlineData(false)] [InlineData(true)] - public async Task Generates_sequential_byte_values(bool async) => await Generates_sequential_values(async); + public async Task Generates_sequential_byte_values(bool async) + => await Generates_sequential_values(async); [ConditionalTheory] [InlineData(false)] [InlineData(true)] - public async Task Generates_sequential_uint_values(bool async) => await Generates_sequential_values(async); + public async Task Generates_sequential_uint_values(bool async) + => await Generates_sequential_values(async); [ConditionalTheory] [InlineData(false)] [InlineData(true)] - public async Task Generates_sequential_ulong_values(bool async) => await Generates_sequential_values(async); + public async Task Generates_sequential_ulong_values(bool async) + => await Generates_sequential_values(async); [ConditionalTheory] [InlineData(false)] [InlineData(true)] - public async Task Generates_sequential_ushort_values(bool async) => await Generates_sequential_values(async); + public async Task Generates_sequential_ushort_values(bool async) + => await Generates_sequential_values(async); [ConditionalTheory] [InlineData(false)] [InlineData(true)] - public async Task Generates_sequential_sbyte_values(bool async) => await Generates_sequential_values(async); + public async Task Generates_sequential_sbyte_values(bool async) + => await Generates_sequential_values(async); private async Task Generates_sequential_values(bool async) { @@ -229,11 +237,14 @@ public FakeRelationalCommand(FakeRawSqlCommandBuilder commandBuilder) _commandBuilder = commandBuilder; } - public string CommandText => throw new NotImplementedException(); + public string CommandText + => throw new NotImplementedException(); - public IReadOnlyList Parameters => throw new NotImplementedException(); + public IReadOnlyList Parameters + => throw new NotImplementedException(); - public IReadOnlyDictionary ParameterValues => throw new NotImplementedException(); + public IReadOnlyDictionary ParameterValues + => throw new NotImplementedException(); public int ExecuteNonQuery(RelationalCommandParameterObject parameterObject) { diff --git a/test/EFCore.SqlServer.Tests/SqlServerTypeMapperTest.cs b/test/EFCore.SqlServer.Tests/SqlServerTypeMapperTest.cs index 2c05a33ecf3..550ba5b7474 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerTypeMapperTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerTypeMapperTest.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.EntityFrameworkCore.SqlServer.Internal; using Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -1272,7 +1271,8 @@ private enum ByteEnum : byte { } - protected override ModelBuilder CreateModelBuilder() => SqlServerTestHelpers.Instance.CreateConventionBuilder(); + protected override ModelBuilder CreateModelBuilder() + => SqlServerTestHelpers.Instance.CreateConventionBuilder(); private class TestParameter : DbParameter { diff --git a/test/EFCore.SqlServer.Tests/SqlServerValueGeneratorCacheTest.cs b/test/EFCore.SqlServer.Tests/SqlServerValueGeneratorCacheTest.cs index 1a7b0228f4a..8333f766a4d 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerValueGeneratorCacheTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerValueGeneratorCacheTest.cs @@ -432,18 +432,22 @@ public void Schema_qualified_sequence_name_is_obtained_from_specified_model_defa Assert.Equal("R", cache.GetOrAddSequenceState(property, CreateConnection()).Sequence.Schema); } - protected virtual ModelBuilder CreateConventionModelBuilder() => SqlServerTestHelpers.Instance.CreateConventionBuilder(); + protected virtual ModelBuilder CreateConventionModelBuilder() + => SqlServerTestHelpers.Instance.CreateConventionBuilder(); private class Robot { public int Id { get; set; } } - private static IProperty GetProperty1(IModel model) => model.FindEntityType(typeof(Led)).FindProperty("Zeppelin"); + private static IProperty GetProperty1(IModel model) + => model.FindEntityType(typeof(Led)).FindProperty("Zeppelin"); - private static IProperty GetProperty2(IModel model) => model.FindEntityType(typeof(Led)).FindProperty("Stairway"); + private static IProperty GetProperty2(IModel model) + => model.FindEntityType(typeof(Led)).FindProperty("Stairway"); - private static IProperty GetProperty3(IModel model) => model.FindEntityType(typeof(Led)).FindProperty("WholeLotta"); + private static IProperty GetProperty3(IModel model) + => model.FindEntityType(typeof(Led)).FindProperty("WholeLotta"); private static IModel CreateModel() { diff --git a/test/EFCore.SqlServer.Tests/SqlServerValueGeneratorSelectorTest.cs b/test/EFCore.SqlServer.Tests/SqlServerValueGeneratorSelectorTest.cs index 6883768af43..2d3d19943d8 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerValueGeneratorSelectorTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerValueGeneratorSelectorTest.cs @@ -200,13 +200,17 @@ private struct Something : IComparable { public int Id { get; set; } - public int CompareTo(Something other) => throw new NotImplementedException(); + public int CompareTo(Something other) + => throw new NotImplementedException(); } private class CustomValueGenerator : ValueGenerator { - public override int Next(EntityEntry entry) => throw new NotImplementedException(); - public override bool GeneratesTemporaryValues => false; + public override int Next(EntityEntry entry) + => throw new NotImplementedException(); + + public override bool GeneratesTemporaryValues + => false; } } } diff --git a/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs b/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs index 34bdfa078bb..8f2e694b04c 100644 --- a/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs +++ b/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs @@ -291,63 +291,142 @@ public FakeType(string fullName) FullName = fullName; } - public override object[] GetCustomAttributes(bool inherit) => throw new NotImplementedException(); - public override bool IsDefined(Type attributeType, bool inherit) => throw new NotImplementedException(); - public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) => throw new NotImplementedException(); - public override Type GetInterface(string name, bool ignoreCase) => throw new NotImplementedException(); - public override Type[] GetInterfaces() => throw new NotImplementedException(); - public override EventInfo GetEvent(string name, BindingFlags bindingAttr) => throw new NotImplementedException(); - public override EventInfo[] GetEvents(BindingFlags bindingAttr) => throw new NotImplementedException(); - public override Type[] GetNestedTypes(BindingFlags bindingAttr) => throw new NotImplementedException(); - public override Type GetNestedType(string name, BindingFlags bindingAttr) => throw new NotImplementedException(); - public override Type GetElementType() => throw new NotImplementedException(); - protected override bool HasElementTypeImpl() => throw new NotImplementedException(); + public override object[] GetCustomAttributes(bool inherit) + => throw new NotImplementedException(); + + public override bool IsDefined(Type attributeType, bool inherit) + => throw new NotImplementedException(); + + public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) + => throw new NotImplementedException(); + + public override Type GetInterface(string name, bool ignoreCase) + => throw new NotImplementedException(); + + public override Type[] GetInterfaces() + => throw new NotImplementedException(); + + public override EventInfo GetEvent(string name, BindingFlags bindingAttr) + => throw new NotImplementedException(); + + public override EventInfo[] GetEvents(BindingFlags bindingAttr) + => throw new NotImplementedException(); + + public override Type[] GetNestedTypes(BindingFlags bindingAttr) + => throw new NotImplementedException(); + + public override Type GetNestedType(string name, BindingFlags bindingAttr) + => throw new NotImplementedException(); + + public override Type GetElementType() + => throw new NotImplementedException(); + + protected override bool HasElementTypeImpl() + => throw new NotImplementedException(); protected override PropertyInfo GetPropertyImpl( - string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) => - throw new NotImplementedException(); + string name, + BindingFlags bindingAttr, + Binder binder, + Type returnType, + Type[] types, + ParameterModifier[] modifiers) + => throw new NotImplementedException(); - public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) => throw new NotImplementedException(); + public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) + => throw new NotImplementedException(); protected override MethodInfo GetMethodImpl( - string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, - ParameterModifier[] modifiers) => throw new NotImplementedException(); - - public override MethodInfo[] GetMethods(BindingFlags bindingAttr) => throw new NotImplementedException(); - public override FieldInfo GetField(string name, BindingFlags bindingAttr) => throw new NotImplementedException(); - public override FieldInfo[] GetFields(BindingFlags bindingAttr) => throw new NotImplementedException(); - public override MemberInfo[] GetMembers(BindingFlags bindingAttr) => throw new NotImplementedException(); - protected override TypeAttributes GetAttributeFlagsImpl() => throw new NotImplementedException(); - protected override bool IsArrayImpl() => throw new NotImplementedException(); - protected override bool IsByRefImpl() => throw new NotImplementedException(); - protected override bool IsPointerImpl() => throw new NotImplementedException(); - protected override bool IsPrimitiveImpl() => throw new NotImplementedException(); - protected override bool IsCOMObjectImpl() => throw new NotImplementedException(); + string name, + BindingFlags bindingAttr, + Binder binder, + CallingConventions callConvention, + Type[] types, + ParameterModifier[] modifiers) + => throw new NotImplementedException(); + + public override MethodInfo[] GetMethods(BindingFlags bindingAttr) + => throw new NotImplementedException(); + + public override FieldInfo GetField(string name, BindingFlags bindingAttr) + => throw new NotImplementedException(); + + public override FieldInfo[] GetFields(BindingFlags bindingAttr) + => throw new NotImplementedException(); + + public override MemberInfo[] GetMembers(BindingFlags bindingAttr) + => throw new NotImplementedException(); + + protected override TypeAttributes GetAttributeFlagsImpl() + => throw new NotImplementedException(); + + protected override bool IsArrayImpl() + => throw new NotImplementedException(); + + protected override bool IsByRefImpl() + => throw new NotImplementedException(); + + protected override bool IsPointerImpl() + => throw new NotImplementedException(); + + protected override bool IsPrimitiveImpl() + => throw new NotImplementedException(); + + protected override bool IsCOMObjectImpl() + => throw new NotImplementedException(); public override object InvokeMember( - string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, - CultureInfo culture, string[] namedParameters) => throw new NotImplementedException(); + string name, + BindingFlags invokeAttr, + Binder binder, + object target, + object[] args, + ParameterModifier[] modifiers, + CultureInfo culture, + string[] namedParameters) + => throw new NotImplementedException(); public override Type UnderlyingSystemType { get; } protected override ConstructorInfo GetConstructorImpl( - BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) => - throw new NotImplementedException(); - - public override string Name => throw new NotImplementedException(); - public override Guid GUID => throw new NotImplementedException(); - public override Module Module => throw new NotImplementedException(); - public override Assembly Assembly => throw new NotImplementedException(); - public override string Namespace => throw new NotImplementedException(); - public override string AssemblyQualifiedName => throw new NotImplementedException(); - public override Type BaseType => throw new NotImplementedException(); - public override object[] GetCustomAttributes(Type attributeType, bool inherit) => throw new NotImplementedException(); + BindingFlags bindingAttr, + Binder binder, + CallingConventions callConvention, + Type[] types, + ParameterModifier[] modifiers) + => throw new NotImplementedException(); + + public override string Name + => throw new NotImplementedException(); + + public override Guid GUID + => throw new NotImplementedException(); + + public override Module Module + => throw new NotImplementedException(); + + public override Assembly Assembly + => throw new NotImplementedException(); + + public override string Namespace + => throw new NotImplementedException(); + + public override string AssemblyQualifiedName + => throw new NotImplementedException(); + + public override Type BaseType + => throw new NotImplementedException(); + + public override object[] GetCustomAttributes(Type attributeType, bool inherit) + => throw new NotImplementedException(); public override string FullName { get; } - public override int GetHashCode() => FullName.GetHashCode(); + public override int GetHashCode() + => FullName.GetHashCode(); - public override bool Equals(object o) => ReferenceEquals(this, o); + public override bool Equals(object o) + => ReferenceEquals(this, o); } protected override DbContextOptions ContextOptions { get; } diff --git a/test/EFCore.SqlServer.Tests/Update/SqlServerUpdateSqlGeneratorTest.cs b/test/EFCore.SqlServer.Tests/Update/SqlServerUpdateSqlGeneratorTest.cs index 5f778cb958b..bffc50792bc 100644 --- a/test/EFCore.SqlServer.Tests/Update/SqlServerUpdateSqlGeneratorTest.cs +++ b/test/EFCore.SqlServer.Tests/Update/SqlServerUpdateSqlGeneratorTest.cs @@ -23,7 +23,8 @@ protected override IUpdateSqlGenerator CreateSqlGenerator() TestServiceFactory.Instance.Create(), TestServiceFactory.Instance.Create()))); - protected override TestHelpers TestHelpers => SqlServerTestHelpers.Instance; + protected override TestHelpers TestHelpers + => SqlServerTestHelpers.Instance; [ConditionalFact] public void AppendBatchHeader_should_append_SET_NOCOUNT_ON() @@ -201,13 +202,17 @@ public void AppendBulkInsertOperation_appends_insert_if_no_store_generated_colum Assert.Equal(ResultSetMapping.NoResultSet, grouping); } - protected override string RowsAffected => "@@ROWCOUNT"; + protected override string RowsAffected + => "@@ROWCOUNT"; - protected override string Identity => throw new NotImplementedException(); + protected override string Identity + => throw new NotImplementedException(); - protected override string OpenDelimiter => "["; + protected override string OpenDelimiter + => "["; - protected override string CloseDelimiter => "]"; + protected override string CloseDelimiter + => "]"; private void AssertBaseline(string expected, string actual) { diff --git a/test/EFCore.Sqlite.FunctionalTests/AutoincrementTest.cs b/test/EFCore.Sqlite.FunctionalTests/AutoincrementTest.cs index 2b2e4506734..f5155a03de8 100644 --- a/test/EFCore.Sqlite.FunctionalTests/AutoincrementTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/AutoincrementTest.cs @@ -11,7 +11,8 @@ namespace Microsoft.EntityFrameworkCore { public class AutoincrementTest : IClassFixture { - public AutoincrementTest(AutoincrementFixture fixture) => Fixture = fixture; + public AutoincrementTest(AutoincrementFixture fixture) + => Fixture = fixture; protected AutoincrementFixture Fixture { get; } @@ -37,13 +38,18 @@ public void Autoincrement_prevents_reusing_rowid() Assert.NotNull(begins); } - private BatContext CreateContext() => (BatContext)Fixture.CreateContext(); + private BatContext CreateContext() + => (BatContext)Fixture.CreateContext(); public class AutoincrementFixture : SharedStoreFixtureBase { protected override string StoreName { get; } = "AutoincrementTest"; - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; - protected override Type ContextType => typeof(BatContext); + + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; + + protected override Type ContextType + => typeof(BatContext); } protected class BatContext : PoolableDbContext diff --git a/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs index 1d22abb7385..ae8b3f72bd2 100644 --- a/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs @@ -1562,18 +1562,26 @@ private void AssertSql(params string[] expected) public class BuiltInDataTypesSqliteFixture : BuiltInDataTypesFixtureBase { - public override bool StrictEquality => false; + public override bool StrictEquality + => false; - public override bool SupportsAnsi => false; + public override bool SupportsAnsi + => false; - public override bool SupportsUnicodeToAnsiConversion => true; + public override bool SupportsUnicodeToAnsiConversion + => true; - public override bool SupportsLargeStringComparisons => true; + public override bool SupportsLargeStringComparisons + => true; - public override bool SupportsDecimalComparisons => false; + public override bool SupportsDecimalComparisons + => false; - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { @@ -1670,9 +1678,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b => b.Property(e => e.Decimal).HasColumnType("decimal(5, 2)")); } - public override bool SupportsBinaryKeys => true; + public override bool SupportsBinaryKeys + => true; - public override DateTime DefaultDateTime => new DateTime(); + public override DateTime DefaultDateTime + => new DateTime(); } protected class MappedDataTypes diff --git a/test/EFCore.Sqlite.FunctionalTests/CommandConfigurationTest.cs b/test/EFCore.Sqlite.FunctionalTests/CommandConfigurationTest.cs index d7dc034b813..637af41659d 100644 --- a/test/EFCore.Sqlite.FunctionalTests/CommandConfigurationTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/CommandConfigurationTest.cs @@ -10,7 +10,8 @@ namespace Microsoft.EntityFrameworkCore { public class CommandConfigurationTest : IClassFixture { - public CommandConfigurationTest(CommandConfigurationTestFixture fixture) => Fixture = fixture; + public CommandConfigurationTest(CommandConfigurationTestFixture fixture) + => Fixture = fixture; protected CommandConfigurationTestFixture Fixture { get; } @@ -21,12 +22,15 @@ public void Constructed_select_query_CommandBuilder_throws_when_negative_Command Assert.Throws(() => context.Database.SetCommandTimeout(-5)); } - protected DbContext CreateContext() => Fixture.CreateContext(); + protected DbContext CreateContext() + => Fixture.CreateContext(); public class CommandConfigurationTestFixture : SharedStoreFixtureBase { protected override string StoreName { get; } = "Empty"; - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/CommandInterceptionSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/CommandInterceptionSqliteTest.cs index 981df5e087e..a7f9b2c7be8 100644 --- a/test/EFCore.Sqlite.FunctionalTests/CommandInterceptionSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/CommandInterceptionSqliteTest.cs @@ -46,8 +46,11 @@ public override async Task Intercept_query_to_replace_execution(bool asy public abstract class InterceptionSqliteFixtureBase : InterceptionFixtureBase { - protected override string StoreName => "CommandInterception"; - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override string StoreName + => "CommandInterception"; + + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; protected override IServiceCollection InjectInterceptors( IServiceCollection serviceCollection, @@ -65,7 +68,8 @@ public CommandInterceptionSqliteTest(InterceptionSqliteFixture fixture) public class InterceptionSqliteFixture : InterceptionSqliteFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => false; + protected override bool ShouldSubscribeToDiagnosticListener + => false; } } @@ -79,7 +83,8 @@ public CommandInterceptionWithDiagnosticsSqliteTest(InterceptionSqliteFixture fi public class InterceptionSqliteFixture : InterceptionSqliteFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => true; + protected override bool ShouldSubscribeToDiagnosticListener + => true; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/CompositeKeyEndToEndSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/CompositeKeyEndToEndSqliteTest.cs index 4193207b82e..1e450e3b697 100644 --- a/test/EFCore.Sqlite.FunctionalTests/CompositeKeyEndToEndSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/CompositeKeyEndToEndSqliteTest.cs @@ -22,7 +22,8 @@ public override Task Can_use_generated_values_in_composite_key_end_to_end() public class CompositeKeyEndToEndSqliteFixture : CompositeKeyEndToEndFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/ConferencePlannerSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/ConferencePlannerSqliteTest.cs index 4834bd831ba..82bbc49b03d 100644 --- a/test/EFCore.Sqlite.FunctionalTests/ConferencePlannerSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/ConferencePlannerSqliteTest.cs @@ -19,7 +19,8 @@ protected override void UseTransaction(DatabaseFacade facade, IDbContextTransact public class ConferencePlannerSqliteFixture : ConferencePlannerFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/ConnectionInterceptionSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/ConnectionInterceptionSqliteTest.cs index bee57ec3ef5..28194080075 100644 --- a/test/EFCore.Sqlite.FunctionalTests/ConnectionInterceptionSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/ConnectionInterceptionSqliteTest.cs @@ -21,8 +21,11 @@ protected override BadUniverseContext CreateBadUniverse(DbContextOptionsBuilder public abstract class InterceptionSqliteFixtureBase : InterceptionFixtureBase { - protected override string StoreName => "ConnectionInterception"; - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override string StoreName + => "ConnectionInterception"; + + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; protected override IServiceCollection InjectInterceptors( IServiceCollection serviceCollection, @@ -40,7 +43,8 @@ public ConnectionInterceptionSqliteTest(InterceptionSqliteFixture fixture) public class InterceptionSqliteFixture : InterceptionSqliteFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => false; + protected override bool ShouldSubscribeToDiagnosticListener + => false; } } @@ -54,7 +58,8 @@ public ConnectionInterceptionWithDiagnosticsSqliteTest(InterceptionSqliteFixture public class InterceptionSqliteFixture : InterceptionSqliteFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => true; + protected override bool ShouldSubscribeToDiagnosticListener + => true; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/ConvertToProviderTypesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/ConvertToProviderTypesSqliteTest.cs index fca895cd00a..70bcc5df654 100644 --- a/test/EFCore.Sqlite.FunctionalTests/ConvertToProviderTypesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/ConvertToProviderTypesSqliteTest.cs @@ -19,22 +19,32 @@ public ConvertToProviderTypesSqliteTest(ConvertToProviderTypesSqliteFixture fixt public class ConvertToProviderTypesSqliteFixture : ConvertToProviderTypesFixtureBase { - public override bool StrictEquality => false; + public override bool StrictEquality + => false; - public override bool SupportsAnsi => false; + public override bool SupportsAnsi + => false; - public override bool SupportsUnicodeToAnsiConversion => true; + public override bool SupportsUnicodeToAnsiConversion + => true; - public override bool SupportsLargeStringComparisons => true; + public override bool SupportsLargeStringComparisons + => true; - public override bool SupportsDecimalComparisons => false; + public override bool SupportsDecimalComparisons + => false; - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; - public override bool SupportsBinaryKeys => true; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; - public override DateTime DefaultDateTime => new DateTime(); + public override bool SupportsBinaryKeys + => true; + + public override DateTime DefaultDateTime + => new DateTime(); } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs index 196d03cc070..e80b5ec0388 100644 --- a/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/CustomConvertersSqliteTest.cs @@ -109,22 +109,32 @@ private void AssertSql(params string[] expected) public class CustomConvertersSqliteFixture : CustomConvertersFixtureBase { - public override bool StrictEquality => false; + public override bool StrictEquality + => false; - public override bool SupportsAnsi => false; + public override bool SupportsAnsi + => false; - public override bool SupportsUnicodeToAnsiConversion => true; + public override bool SupportsUnicodeToAnsiConversion + => true; - public override bool SupportsLargeStringComparisons => true; + public override bool SupportsLargeStringComparisons + => true; - public override bool SupportsDecimalComparisons => false; + public override bool SupportsDecimalComparisons + => false; - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; - public override bool SupportsBinaryKeys => true; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; - public override DateTime DefaultDateTime => new DateTime(); + public override bool SupportsBinaryKeys + => true; + + public override DateTime DefaultDateTime + => new DateTime(); } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/DataAnnotationSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/DataAnnotationSqliteTest.cs index 48a291fe0f6..b13a112458e 100644 --- a/test/EFCore.Sqlite.FunctionalTests/DataAnnotationSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/DataAnnotationSqliteTest.cs @@ -172,8 +172,11 @@ private void AssertSql(params string[] expected) public class DataAnnotationSqliteFixture : DataAnnotationFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/DefaultValuesTest.cs b/test/EFCore.Sqlite.FunctionalTests/DefaultValuesTest.cs index f8395e01d34..354cde21a87 100644 --- a/test/EFCore.Sqlite.FunctionalTests/DefaultValuesTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/DefaultValuesTest.cs @@ -35,10 +35,14 @@ public void Can_use_SQLite_default_values() } protected override string StoreName { get; } = "DefaultKettleChips"; - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; + protected override Type ContextType { get; } = typeof(ChipsContext); - private ChipsContext CreateChipsContext() => (ChipsContext)CreateContext(); + private ChipsContext CreateChipsContext() + => (ChipsContext)CreateContext(); private class ChipsContext : PoolableDbContext { diff --git a/test/EFCore.Sqlite.FunctionalTests/F1SqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/F1SqliteFixture.cs index 98d6438c111..8a35cd4b2d2 100644 --- a/test/EFCore.Sqlite.FunctionalTests/F1SqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/F1SqliteFixture.cs @@ -7,7 +7,10 @@ namespace Microsoft.EntityFrameworkCore { public class F1SqliteFixture : F1RelationalFixture { - protected override ITestStoreFactory TestStoreFactory => PrivateCacheSqliteTestStoreFactory.Instance; - public override TestHelpers TestHelpers => SqliteTestHelpers.Instance; + protected override ITestStoreFactory TestStoreFactory + => PrivateCacheSqliteTestStoreFactory.Instance; + + public override TestHelpers TestHelpers + => SqliteTestHelpers.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/FieldMappingSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/FieldMappingSqliteTest.cs index 4968c1be272..8f366ef8b7b 100644 --- a/test/EFCore.Sqlite.FunctionalTests/FieldMappingSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/FieldMappingSqliteTest.cs @@ -22,7 +22,8 @@ protected override void UseTransaction(DatabaseFacade facade, IDbContextTransact public abstract class FieldMappingSqliteFixtureBase : FieldMappingFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/FindSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/FindSqliteTest.cs index cc967689cdd..b82701d2fc2 100644 --- a/test/EFCore.Sqlite.FunctionalTests/FindSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/FindSqliteTest.cs @@ -57,7 +57,8 @@ protected override async ValueTask FindAsync(DbContext context public class FindSqliteFixture : FindFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/GraphUpdates/GraphUpdatesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/GraphUpdates/GraphUpdatesSqliteTest.cs index 2e5fbaf71e8..2b25d9577f0 100644 --- a/test/EFCore.Sqlite.FunctionalTests/GraphUpdates/GraphUpdatesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/GraphUpdates/GraphUpdatesSqliteTest.cs @@ -97,7 +97,8 @@ public class SqliteFixture : GraphUpdatesSqliteTestBase.GraphUpda { protected override string StoreName { get; } = "GraphUpdatesSnapshotTest"; - protected override bool AutoDetectChanges => true; + protected override bool AutoDetectChanges + => true; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { @@ -116,16 +117,22 @@ protected GraphUpdatesSqliteTestBase(TFixture fixture) { } - protected override IQueryable ModifyQueryRoot(IQueryable query) => query.AsSplitQuery(); + protected override IQueryable ModifyQueryRoot(IQueryable query) + => query.AsSplitQuery(); protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); public abstract class GraphUpdatesSqliteFixtureBase : GraphUpdatesFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; - protected virtual bool AutoDetectChanges => false; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; + + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; + + protected virtual bool AutoDetectChanges + => false; public override PoolableDbContext CreateContext() { diff --git a/test/EFCore.Sqlite.FunctionalTests/GraphUpdates/ProxyGraphUpdatesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/GraphUpdates/ProxyGraphUpdatesSqliteTest.cs index 5eaff3ba8ef..9fbc98ce053 100644 --- a/test/EFCore.Sqlite.FunctionalTests/GraphUpdates/ProxyGraphUpdatesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/GraphUpdates/ProxyGraphUpdatesSqliteTest.cs @@ -24,8 +24,11 @@ protected override void UseTransaction(DatabaseFacade facade, IDbContextTransact public abstract class ProxyGraphUpdatesSqliteFixtureBase : ProxyGraphUpdatesFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; + + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } @@ -36,8 +39,11 @@ public LazyLoading(ProxyGraphUpdatesWithLazyLoadingSqliteFixture fixture) { } - protected override bool DoesLazyLoading => true; - protected override bool DoesChangeTracking => false; + protected override bool DoesLazyLoading + => true; + + protected override bool DoesChangeTracking + => false; public class ProxyGraphUpdatesWithLazyLoadingSqliteFixture : ProxyGraphUpdatesSqliteFixtureBase { @@ -58,8 +64,11 @@ public ChangeTracking(ProxyGraphUpdatesWithChangeTrackingSqliteFixture fixture) { } - protected override bool DoesLazyLoading => false; - protected override bool DoesChangeTracking => true; + protected override bool DoesLazyLoading + => false; + + protected override bool DoesChangeTracking + => true; public class ProxyGraphUpdatesWithChangeTrackingSqliteFixture : ProxyGraphUpdatesSqliteFixtureBase { @@ -73,15 +82,19 @@ protected override IServiceCollection AddServices(IServiceCollection serviceColl } } - public class ChangeTrackingAndLazyLoading : ProxyGraphUpdatesSqliteTestBase + public class ChangeTrackingAndLazyLoading : ProxyGraphUpdatesSqliteTestBase< + ChangeTrackingAndLazyLoading.ProxyGraphUpdatesWithChangeTrackingAndLazyLoadingSqliteFixture> { public ChangeTrackingAndLazyLoading(ProxyGraphUpdatesWithChangeTrackingAndLazyLoadingSqliteFixture fixture) : base(fixture) { } - protected override bool DoesLazyLoading => true; - protected override bool DoesChangeTracking => true; + protected override bool DoesLazyLoading + => true; + + protected override bool DoesChangeTracking + => true; public class ProxyGraphUpdatesWithChangeTrackingAndLazyLoadingSqliteFixture : ProxyGraphUpdatesSqliteFixtureBase { diff --git a/test/EFCore.Sqlite.FunctionalTests/LazyLoadProxySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/LazyLoadProxySqliteTest.cs index 9fa0bb93f81..899c0f33056 100644 --- a/test/EFCore.Sqlite.FunctionalTests/LazyLoadProxySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/LazyLoadProxySqliteTest.cs @@ -14,7 +14,8 @@ public LazyLoadProxySqliteTest(LoadSqliteFixture fixture) public class LoadSqliteFixture : LoadFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/LoadSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/LoadSqliteTest.cs index ab6578f8ff0..a884c628cb4 100644 --- a/test/EFCore.Sqlite.FunctionalTests/LoadSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/LoadSqliteTest.cs @@ -14,7 +14,8 @@ public LoadSqliteTest(LoadSqliteFixture fixture) public class LoadSqliteFixture : LoadFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/LoggingSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/LoggingSqliteTest.cs index 5b9d44e320f..e84f9ac3b6e 100644 --- a/test/EFCore.Sqlite.FunctionalTests/LoggingSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/LoggingSqliteTest.cs @@ -18,6 +18,7 @@ protected override DbContextOptionsBuilder CreateOptionsBuilder( .UseInternalServiceProvider(services.AddEntityFrameworkSqlite().BuildServiceProvider()) .UseSqlite("Data Source=LoggingSqliteTest.db", relationalAction); - protected override string ProviderName => "Microsoft.EntityFrameworkCore.Sqlite"; + protected override string ProviderName + => "Microsoft.EntityFrameworkCore.Sqlite"; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/ManyToManyLoadProxySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/ManyToManyLoadProxySqliteTest.cs index fcdbc3adfea..f3eb4f5ba89 100644 --- a/test/EFCore.Sqlite.FunctionalTests/ManyToManyLoadProxySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/ManyToManyLoadProxySqliteTest.cs @@ -13,7 +13,8 @@ public ManyToManyLoadProxySqliteTest(ManyToManyLoadProxySqliteFixture fixture) { } - protected override bool ExpectLazyLoading => true; + protected override bool ExpectLazyLoading + => true; public class ManyToManyLoadProxySqliteFixture : ManyToManyLoadSqliteFixtureBase { diff --git a/test/EFCore.Sqlite.FunctionalTests/ManyToManyLoadSqliteTestBase.cs b/test/EFCore.Sqlite.FunctionalTests/ManyToManyLoadSqliteTestBase.cs index 4bc8bb981d7..30991d1480e 100644 --- a/test/EFCore.Sqlite.FunctionalTests/ManyToManyLoadSqliteTestBase.cs +++ b/test/EFCore.Sqlite.FunctionalTests/ManyToManyLoadSqliteTestBase.cs @@ -17,7 +17,8 @@ protected ManyToManyLoadSqliteTestBase(TFixture fixture) public class ManyToManyLoadSqliteFixtureBase : ManyToManyLoadFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Sqlite.FunctionalTests/ManyToManyTrackingSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/ManyToManyTrackingSqliteTest.cs index d4eba3a1681..eeb8169832d 100644 --- a/test/EFCore.Sqlite.FunctionalTests/ManyToManyTrackingSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/ManyToManyTrackingSqliteTest.cs @@ -21,7 +21,8 @@ protected override void UseTransaction(DatabaseFacade facade, IDbContextTransact public class ManyToManyTrackingSqliteFixture : ManyToManyTrackingFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Sqlite.FunctionalTests/MigrationsInfrastructureSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/MigrationsInfrastructureSqliteTest.cs index d37a47e9d8e..3bd7bba9f6f 100644 --- a/test/EFCore.Sqlite.FunctionalTests/MigrationsInfrastructureSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/MigrationsInfrastructureSqliteTest.cs @@ -1058,7 +1058,8 @@ public override void Can_diff_against_3_0_ASP_NET_Identity_model() public class MigrationsInfrastructureSqliteFixture : MigrationsInfrastructureFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/MigrationsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/MigrationsSqliteTest.cs index 8ed8168de98..e846272ea3d 100644 --- a/test/EFCore.Sqlite.FunctionalTests/MigrationsSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/MigrationsSqliteTest.cs @@ -881,24 +881,31 @@ public override Task Move_sequence() => AssertNotSupportedAsync(base.Create_sequence, SqliteStrings.SequencesNotSupported); // SQLite does not support schemas - protected override bool AssertSchemaNames => false; + protected override bool AssertSchemaNames + => false; // Reverse-engineering of comments isn't supported in Sqlite - protected override bool AssertComments => false; + protected override bool AssertComments + => false; // Reverse engineering of computed columns isn't fully supported on SQLite - protected override bool AssertComputedColumns => false; + protected override bool AssertComputedColumns + => false; // Our current version Sqlite doesn't seem to support scaffolding collations - protected override bool AssertCollations => false; + protected override bool AssertCollations + => false; // Reverse engineering of index filters isn't supported in SQLite - protected override bool AssertIndexFilters => false; + protected override bool AssertIndexFilters + => false; // Reverse engineering of constraint names isn't supported in SQLite - protected override bool AssertConstraintNames => false; + protected override bool AssertConstraintNames + => false; - protected override string NonDefaultCollation => "NOCASE"; + protected override string NonDefaultCollation + => "NOCASE"; protected virtual async Task AssertNotSupportedAsync(Func action, string? message = null) { @@ -912,8 +919,12 @@ protected virtual async Task AssertNotSupportedAsync(Func action, string? public class MigrationsSqliteFixture : MigrationsFixtureBase { protected override string StoreName { get; } = nameof(MigrationsSqliteTest); - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; - public override TestHelpers TestHelpers => SqliteTestHelpers.Instance; + + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; + + public override TestHelpers TestHelpers + => SqliteTestHelpers.Instance; protected override IServiceCollection AddServices(IServiceCollection serviceCollection) => base.AddServices(serviceCollection) diff --git a/test/EFCore.Sqlite.FunctionalTests/MonsterFixupChangedOnlySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/MonsterFixupChangedOnlySqliteTest.cs index a42f37d1552..0e67ac5d976 100644 --- a/test/EFCore.Sqlite.FunctionalTests/MonsterFixupChangedOnlySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/MonsterFixupChangedOnlySqliteTest.cs @@ -15,7 +15,8 @@ public MonsterFixupChangedOnlySqliteTest(MonsterFixupChangedOnlySqliteFixture fi public class MonsterFixupChangedOnlySqliteFixture : MonsterFixupChangedOnlyFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; protected override void OnModelCreating( ModelBuilder builder) diff --git a/test/EFCore.Sqlite.FunctionalTests/MusicStoreSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/MusicStoreSqliteTest.cs index 99d2158bb0d..c74dd4cda7e 100644 --- a/test/EFCore.Sqlite.FunctionalTests/MusicStoreSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/MusicStoreSqliteTest.cs @@ -14,7 +14,8 @@ public MusicStoreSqliteTest(MusicStoreSqliteFixture fixture) public class MusicStoreSqliteFixture : MusicStoreFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/NotificationEntitiesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/NotificationEntitiesSqliteTest.cs index 6f9fca57661..a4e5c65d361 100644 --- a/test/EFCore.Sqlite.FunctionalTests/NotificationEntitiesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/NotificationEntitiesSqliteTest.cs @@ -15,7 +15,8 @@ public NotificationEntitiesSqliteTest(NotificationEntitiesSqliteFixture fixture) public class NotificationEntitiesSqliteFixture : NotificationEntitiesFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/OptimisticConcurrencySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/OptimisticConcurrencySqliteTest.cs index 54e8da753da..e2cf6b944c2 100644 --- a/test/EFCore.Sqlite.FunctionalTests/OptimisticConcurrencySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/OptimisticConcurrencySqliteTest.cs @@ -16,32 +16,40 @@ public OptimisticConcurrencySqliteTest(F1SqliteFixture fixture) // Override failing tests because SQLite does not allow store-generated row versions. // Row version behavior could be imitated on SQLite. See Issue #2195 - public override Task Simple_concurrency_exception_can_be_resolved_with_store_values() => Task.FromResult(true); + public override Task Simple_concurrency_exception_can_be_resolved_with_store_values() + => Task.FromResult(true); - public override Task Simple_concurrency_exception_can_be_resolved_with_client_values() => Task.FromResult(true); - public override Task Simple_concurrency_exception_can_be_resolved_with_new_values() => Task.FromResult(true); + public override Task Simple_concurrency_exception_can_be_resolved_with_client_values() + => Task.FromResult(true); - public override Task Simple_concurrency_exception_can_be_resolved_with_store_values_using_equivalent_of_accept_changes() => - Task.FromResult(true); + public override Task Simple_concurrency_exception_can_be_resolved_with_new_values() + => Task.FromResult(true); - public override Task Simple_concurrency_exception_can_be_resolved_with_store_values_using_Reload() => Task.FromResult(true); - public override Task Updating_then_deleting_the_same_entity_results_in_DbUpdateConcurrencyException() => Task.FromResult(true); + public override Task Simple_concurrency_exception_can_be_resolved_with_store_values_using_equivalent_of_accept_changes() + => Task.FromResult(true); + + public override Task Simple_concurrency_exception_can_be_resolved_with_store_values_using_Reload() + => Task.FromResult(true); + + public override Task Updating_then_deleting_the_same_entity_results_in_DbUpdateConcurrencyException() + => Task.FromResult(true); public override Task - Updating_then_deleting_the_same_entity_results_in_DbUpdateConcurrencyException_which_can_be_resolved_with_store_values() => - Task.FromResult(true); + Updating_then_deleting_the_same_entity_results_in_DbUpdateConcurrencyException_which_can_be_resolved_with_store_values() + => Task.FromResult(true); public override Task - Change_in_independent_association_after_change_in_different_concurrency_token_results_in_independent_association_exception() => - Task.FromResult(true); + Change_in_independent_association_after_change_in_different_concurrency_token_results_in_independent_association_exception() + => Task.FromResult(true); - public override Task Change_in_independent_association_results_in_independent_association_exception() => Task.FromResult(true); + public override Task Change_in_independent_association_results_in_independent_association_exception() + => Task.FromResult(true); - public override Task Two_concurrency_issues_in_one_to_many_related_entities_can_be_handled_by_dealing_with_dependent_first() => - Task.FromResult(true); + public override Task Two_concurrency_issues_in_one_to_many_related_entities_can_be_handled_by_dealing_with_dependent_first() + => Task.FromResult(true); - public override Task Two_concurrency_issues_in_one_to_one_related_entities_can_be_handled_by_dealing_with_dependent_first() => - Task.FromResult(true); + public override Task Two_concurrency_issues_in_one_to_one_related_entities_can_be_handled_by_dealing_with_dependent_first() + => Task.FromResult(true); protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.Sqlite.FunctionalTests/OverzealousInitializationSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/OverzealousInitializationSqliteTest.cs index 16657aafe74..62fd73849c1 100644 --- a/test/EFCore.Sqlite.FunctionalTests/OverzealousInitializationSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/OverzealousInitializationSqliteTest.cs @@ -15,7 +15,8 @@ public OverzealousInitializationSqliteTest(OverzealousInitializationSqliteFixtur public class OverzealousInitializationSqliteFixture : OverzealousInitializationFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/PropertyValuesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/PropertyValuesSqliteTest.cs index 8cd4c690e0a..3fdc86c8a3e 100644 --- a/test/EFCore.Sqlite.FunctionalTests/PropertyValuesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/PropertyValuesSqliteTest.cs @@ -14,7 +14,8 @@ public PropertyValuesSqliteTest(PropertyValuesSqliteFixture fixture) public class PropertyValuesSqliteFixture : PropertyValuesFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/BadDataSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/BadDataSqliteTest.cs index e16cd4160ee..df5b8052641 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/BadDataSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/BadDataSqliteTest.cs @@ -22,7 +22,8 @@ namespace Microsoft.EntityFrameworkCore.Query { public class BadDataSqliteTest : IClassFixture { - public BadDataSqliteTest(BadDataSqliteFixture fixture) => Fixture = fixture; + public BadDataSqliteTest(BadDataSqliteFixture fixture) + => Fixture = fixture; public BadDataSqliteFixture Fixture { get; } @@ -197,20 +198,26 @@ public BadDataDataReader(object[] values) _values = values; } - public override bool Read() => true; + public override bool Read() + => true; public override bool IsDBNull(int ordinal) => false; - public override int GetInt32(int ordinal) => (int)GetValue(ordinal); + public override int GetInt32(int ordinal) + => (int)GetValue(ordinal); - public override short GetInt16(int ordinal) => (short)GetValue(ordinal); + public override short GetInt16(int ordinal) + => (short)GetValue(ordinal); - public override bool GetBoolean(int ordinal) => (bool)GetValue(ordinal); + public override bool GetBoolean(int ordinal) + => (bool)GetValue(ordinal); - public override string GetString(int ordinal) => (string)GetValue(ordinal); + public override string GetString(int ordinal) + => (string)GetValue(ordinal); - public override object GetValue(int ordinal) => _values[ordinal]; + public override object GetValue(int ordinal) + => _values[ordinal]; #region NotImplemented members @@ -224,24 +231,31 @@ public override int GetValues(object[] values) throw new NotImplementedException(); } - public override int FieldCount => throw new NotImplementedException(); + public override int FieldCount + => throw new NotImplementedException(); - public override object this[int ordinal] => throw new NotImplementedException(); + public override object this[int ordinal] + => throw new NotImplementedException(); - public override object this[string name] => throw new NotImplementedException(); + public override object this[string name] + => throw new NotImplementedException(); - public override bool HasRows => throw new NotImplementedException(); + public override bool HasRows + => throw new NotImplementedException(); - public override bool IsClosed => throw new NotImplementedException(); + public override bool IsClosed + => throw new NotImplementedException(); - public override int RecordsAffected => 0; + public override int RecordsAffected + => 0; public override bool NextResult() { throw new NotImplementedException(); } - public override int Depth => throw new NotImplementedException(); + public override int Depth + => throw new NotImplementedException(); public override int GetOrdinal(string name) { @@ -338,59 +352,82 @@ public void ResetState() { } - public Task ResetStateAsync(CancellationToken cancellationToken = default) => Task.CompletedTask; + public Task ResetStateAsync(CancellationToken cancellationToken = default) + => Task.CompletedTask; - public IDbContextTransaction BeginTransaction() => throw new NotImplementedException(); + public IDbContextTransaction BeginTransaction() + => throw new NotImplementedException(); - public Task BeginTransactionAsync(CancellationToken cancellationToken = default) => - throw new NotImplementedException(); + public Task BeginTransactionAsync(CancellationToken cancellationToken = default) + => throw new NotImplementedException(); public void CommitTransaction() { } + public Task CommitTransactionAsync(CancellationToken cancellationToken = default) => Task.CompletedTask; public void RollbackTransaction() { } + public Task RollbackTransactionAsync(CancellationToken cancellationToken = default) => Task.CompletedTask; - public IDbContextTransaction CurrentTransaction => throw new NotImplementedException(); + public IDbContextTransaction CurrentTransaction + => throw new NotImplementedException(); + public SemaphoreSlim Semaphore { get; } public string ConnectionString { get; } public DbConnection DbConnection { get; } - public DbContext Context => null; + + public DbContext Context + => null; + public Guid ConnectionId { get; } public int? CommandTimeout { get; set; } - public bool Open(bool errorsExpected = false) => true; - public Task OpenAsync(CancellationToken cancellationToken, bool errorsExpected = false) => - throw new NotImplementedException(); + public bool Open(bool errorsExpected = false) + => true; + + public Task OpenAsync(CancellationToken cancellationToken, bool errorsExpected = false) + => throw new NotImplementedException(); - public bool Close() => true; + public bool Close() + => true; - public Task CloseAsync() => Task.FromResult(true); + public Task CloseAsync() + => Task.FromResult(true); - public IDbContextTransaction BeginTransaction(IsolationLevel isolationLevel) => throw new NotImplementedException(); + public IDbContextTransaction BeginTransaction(IsolationLevel isolationLevel) + => throw new NotImplementedException(); public Task BeginTransactionAsync( - IsolationLevel isolationLevel, CancellationToken cancellationToken = default) => throw new NotImplementedException(); + IsolationLevel isolationLevel, + CancellationToken cancellationToken = default) + => throw new NotImplementedException(); - public IDbContextTransaction UseTransaction(DbTransaction transaction) => throw new NotImplementedException(); + public IDbContextTransaction UseTransaction(DbTransaction transaction) + => throw new NotImplementedException(); - public IDbContextTransaction UseTransaction(DbTransaction transaction, Guid transactionId) => - throw new NotImplementedException(); + public IDbContextTransaction UseTransaction(DbTransaction transaction, Guid transactionId) + => throw new NotImplementedException(); public Task UseTransactionAsync( - DbTransaction transaction, CancellationToken cancellationToken = default) => throw new NotImplementedException(); + DbTransaction transaction, + CancellationToken cancellationToken = default) + => throw new NotImplementedException(); public Task UseTransactionAsync( - DbTransaction transaction, Guid transactionId, CancellationToken cancellationToken = default) => throw new NotImplementedException(); + DbTransaction transaction, + Guid transactionId, + CancellationToken cancellationToken = default) + => throw new NotImplementedException(); public void Dispose() { } - public ValueTask DisposeAsync() => default; + public ValueTask DisposeAsync() + => default; } public class BadDataSqliteFixture : NorthwindQuerySqliteFixture diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteFixture.cs index 2be3cb411b5..abff666ea68 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class ComplexNavigationsQuerySqliteFixture : ComplexNavigationsQueryRelationalFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs index 63e2f49fbb2..f98def2e510 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs @@ -20,16 +20,35 @@ public override Task Include_inside_subquery(bool async) } // Sqlite does not support cross/outer apply - public override Task Filtered_include_after_different_filtered_include_different_level(bool async) => null; + public override Task Filtered_include_after_different_filtered_include_different_level(bool async) + => null; + public override void Filtered_include_outer_parameter_used_inside_filter() { } - public override Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) => null; - public override Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async) => null; - public override Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) => null; - public override Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) => null; - public override Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async) => null; - - public override Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation_split(bool async) => null; - public override Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(bool async) => null; - public override Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes_split(bool async) => null; + + public override Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) + => null; + + public override Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only( + bool async) + => null; + + public override Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) + => null; + + public override Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) + => null; + + public override Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async) + => null; + + public override Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation_split(bool async) + => null; + + public override Task + Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(bool async) + => null; + + public override Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes_split(bool async) + => null; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsWeakQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsWeakQuerySqliteFixture.cs index aee2fdda0b8..79746dc27a7 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsWeakQuerySqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsWeakQuerySqliteFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class ComplexNavigationsWeakQuerySqliteFixture : ComplexNavigationsWeakQueryRelationalFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsWeakQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsWeakQuerySqliteTest.cs index c324436faae..35501d0dcbb 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsWeakQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsWeakQuerySqliteTest.cs @@ -2,12 +2,12 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; -using Xunit; using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { - public class ComplexNavigationsWeakQuerySqliteTest : ComplexNavigationsWeakQueryRelationalTestBase + public class ComplexNavigationsWeakQuerySqliteTest : ComplexNavigationsWeakQueryRelationalTestBase< + ComplexNavigationsWeakQuerySqliteFixture> { public ComplexNavigationsWeakQuerySqliteTest(ComplexNavigationsWeakQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) @@ -15,11 +15,23 @@ public ComplexNavigationsWeakQuerySqliteTest(ComplexNavigationsWeakQuerySqliteFi } // Sqlite does not support cross/outer apply - public override Task Filtered_include_after_different_filtered_include_different_level(bool async) => null; - public override Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) => null; - public override Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) => null; - public override Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async) => null; - public override Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) => null; - public override Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async) => null; + public override Task Filtered_include_after_different_filtered_include_different_level(bool async) + => null; + + public override Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) + => null; + + public override Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) + => null; + + public override Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only( + bool async) + => null; + + public override Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) + => null; + + public override Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async) + => null; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/FiltersInheritanceQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/FiltersInheritanceQuerySqliteFixture.cs index 94e8a3d2010..d4f347a79a8 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/FiltersInheritanceQuerySqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/FiltersInheritanceQuerySqliteFixture.cs @@ -5,6 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class FiltersInheritanceQuerySqliteFixture : InheritanceQuerySqliteFixture { - protected override bool EnableFilters => true; + protected override bool EnableFilters + => true; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs index c63c114c112..87fe6ab7a4f 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs @@ -21,7 +21,8 @@ public override string FromSqlRaw_queryable_composed() { var queryString = base.FromSqlRaw_queryable_composed(); - var expected = @"SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" + var expected = + @"SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" FROM ( SELECT * FROM ""Customers"" ) AS ""c"" @@ -36,7 +37,8 @@ public override string FromSqlRaw_queryable_with_parameters_and_closure() { var queryString = base.FromSqlRaw_queryable_with_parameters_and_closure(); - Assert.Equal(@".param set p0 'London' + Assert.Equal( + @".param set p0 'London' .param set @__contactTitle_1 'Sales Representative' SELECT ""c"".""CustomerID"", ""c"".""Address"", ""c"".""City"", ""c"".""CompanyName"", ""c"".""ContactName"", ""c"".""ContactTitle"", ""c"".""Country"", ""c"".""Fax"", ""c"".""Phone"", ""c"".""PostalCode"", ""c"".""Region"" diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/FunkyDataQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/FunkyDataQuerySqliteTest.cs index f8ea62c5c45..6db10eaaf59 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/FunkyDataQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/FunkyDataQuerySqliteTest.cs @@ -12,16 +12,20 @@ public FunkyDataQuerySqliteTest(FunkyDataQuerySqliteFixture fixture) { } - protected virtual bool CanExecuteQueryString => false; + protected virtual bool CanExecuteQueryString + => false; protected override QueryAsserter CreateQueryAsserter(FunkyDataQuerySqliteFixture fixture) - => new RelationalQueryAsserter(fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); + => new RelationalQueryAsserter( + fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression, canExecuteQueryString: CanExecuteQueryString); public class FunkyDataQuerySqliteFixture : FunkyDataQueryFixtureBase { - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteFixture.cs index 7429045b7a4..44d306c3a78 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class GearsOfWarQuerySqliteFixture : GearsOfWarQueryRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs index 1a48a3d79bb..782714b1cab 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs @@ -56,28 +56,42 @@ public override Task DateTimeOffset_Date_returns_datetime(bool async) => AssertTranslationFailed(() => base.DateTimeOffset_Date_returns_datetime(async)); // Sqlite does not support cross/outer apply - public override Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool async) => null; + public override Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool async) + => null; - public override Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool async) => null; + public override Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool async) + => null; - public override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(bool async) => null; + public override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(bool async) + => null; - public override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(bool async) => null; + public override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(bool async) + => null; - public override Task Outer_parameter_in_group_join_with_DefaultIfEmpty(bool async) => null; + public override Task Outer_parameter_in_group_join_with_DefaultIfEmpty(bool async) + => null; - public override Task Outer_parameter_in_join_key(bool async) => null; + public override Task Outer_parameter_in_join_key(bool async) + => null; - public override Task Outer_parameter_in_join_key_inner_and_outer(bool async) => null; + public override Task Outer_parameter_in_join_key_inner_and_outer(bool async) + => null; - public override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async) => null; + public override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async) + => null; - public override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(bool async) => null; + public override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(bool async) + => null; - public override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(bool async) => null; + public override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(bool async) + => null; - public override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(bool async) => null; - public override Task SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(bool async) => null; + public override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated( + bool async) + => null; + + public override Task SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(bool async) + => null; public override async Task Negate_on_binary_expression(bool async) { @@ -144,7 +158,8 @@ public override async Task Byte_array_filter_by_length_literal(bool async) { await base.Byte_array_filter_by_length_literal(async); - AssertSql(@"SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name"" + AssertSql( + @"SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name"" FROM ""Squads"" AS ""s"" WHERE length(""s"".""Banner"") = 1"); } @@ -153,7 +168,8 @@ public override async Task Byte_array_filter_by_length_parameter(bool async) { await base.Byte_array_filter_by_length_parameter(async); - AssertSql(@"@__p_0='1' (DbType = String) + AssertSql( + @"@__p_0='1' (DbType = String) SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name"" FROM ""Squads"" AS ""s"" @@ -176,7 +192,8 @@ public override async Task Byte_array_filter_by_SequenceEqual(bool async) { await base.Byte_array_filter_by_SequenceEqual(async); - AssertSql(@"@__byteArrayParam_0='0x0405060708' (Size = 5) (DbType = String) + AssertSql( + @"@__byteArrayParam_0='0x0405060708' (Size = 5) (DbType = String) SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name"" FROM ""Squads"" AS ""s"" @@ -184,28 +201,36 @@ public override async Task Byte_array_filter_by_SequenceEqual(bool async) } [ConditionalTheory(Skip = "Issue#18844")] - public override Task TimeSpan_Hours(bool async) => base.TimeSpan_Hours(async); + public override Task TimeSpan_Hours(bool async) + => base.TimeSpan_Hours(async); [ConditionalTheory(Skip = "Issue#18844")] - public override Task TimeSpan_Minutes(bool async) => base.TimeSpan_Minutes(async); + public override Task TimeSpan_Minutes(bool async) + => base.TimeSpan_Minutes(async); [ConditionalTheory(Skip = "Issue#18844")] - public override Task TimeSpan_Seconds(bool async) => base.TimeSpan_Seconds(async); + public override Task TimeSpan_Seconds(bool async) + => base.TimeSpan_Seconds(async); [ConditionalTheory(Skip = "Issue#18844")] - public override Task TimeSpan_Milliseconds(bool async) => base.TimeSpan_Milliseconds(async); + public override Task TimeSpan_Milliseconds(bool async) + => base.TimeSpan_Milliseconds(async); [ConditionalTheory(Skip = "Issue#18844")] - public override Task Where_TimeSpan_Hours(bool async) => base.Where_TimeSpan_Hours(async); + public override Task Where_TimeSpan_Hours(bool async) + => base.Where_TimeSpan_Hours(async); [ConditionalTheory(Skip = "Issue#18844")] - public override Task Where_TimeSpan_Minutes(bool async) => base.Where_TimeSpan_Minutes(async); + public override Task Where_TimeSpan_Minutes(bool async) + => base.Where_TimeSpan_Minutes(async); [ConditionalTheory(Skip = "Issue#18844")] - public override Task Where_TimeSpan_Seconds(bool async) => base.Where_TimeSpan_Seconds(async); + public override Task Where_TimeSpan_Seconds(bool async) + => base.Where_TimeSpan_Seconds(async); [ConditionalTheory(Skip = "Issue#18844")] - public override Task Where_TimeSpan_Milliseconds(bool async) => base.Where_TimeSpan_Milliseconds(async); + public override Task Where_TimeSpan_Milliseconds(bool async) + => base.Where_TimeSpan_Milliseconds(async); private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/IncludeOneToOneSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/IncludeOneToOneSqliteTest.cs index d9cf09084d7..2372f50fe24 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/IncludeOneToOneSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/IncludeOneToOneSqliteTest.cs @@ -14,9 +14,11 @@ public IncludeOneToOneSqliteTest(OneToOneQuerySqliteFixture fixture) public class OneToOneQuerySqliteFixture : OneToOneQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; - public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqliteFixture.cs index a4c9039f98a..34e0e4be1f0 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqliteFixture.cs @@ -5,6 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class IncompleteMappingInheritanceQuerySqliteFixture : InheritanceQuerySqliteFixture { - protected override bool IsDiscriminatorMappingComplete => false; + protected override bool IsDiscriminatorMappingComplete + => false; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqliteTest.cs index bfe818fb43d..8c9a5f60c15 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/IncompleteMappingInheritanceQuerySqliteTest.cs @@ -3,7 +3,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class IncompleteMappingInheritanceQuerySqliteTest : InheritanceRelationalQueryTestBase + public class IncompleteMappingInheritanceQuerySqliteTest : InheritanceRelationalQueryTestBase< + IncompleteMappingInheritanceQuerySqliteFixture> { public IncompleteMappingInheritanceQuerySqliteTest(IncompleteMappingInheritanceQuerySqliteFixture fixture) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceQuerySqliteFixture.cs index 23a61689e09..c26c84e6cf0 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceQuerySqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceQuerySqliteFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class InheritanceQuerySqliteFixture : InheritanceQueryRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceRelationshipsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceRelationshipsQuerySqliteTest.cs index 21d5e04c545..c7e7af515a7 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceRelationshipsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/InheritanceRelationshipsQuerySqliteTest.cs @@ -15,7 +15,8 @@ public InheritanceRelationshipsQuerySqliteTest(InheritanceRelationshipsQuerySqli public class InheritanceRelationshipsQuerySqliteFixture : InheritanceRelationshipsQueryRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyNoTrackingQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyNoTrackingQuerySqliteTest.cs index c2a4bb8809b..a2ac439bafc 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyNoTrackingQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyNoTrackingQuerySqliteTest.cs @@ -31,6 +31,7 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take_t () => base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(async))).Message); [ConditionalTheory(Skip = "Issue#21541")] - public override Task Left_join_with_skip_navigation(bool async) => base.Left_join_with_skip_navigation(async); + public override Task Left_join_with_skip_navigation(bool async) + => base.Left_join_with_skip_navigation(async); } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyQuerySqliteFixture.cs index a82228397bd..58577f1565b 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyQuerySqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ManyToManyQuerySqliteFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class ManyToManyQuerySqliteFixture : ManyToManyQueryRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/MappingQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/MappingQuerySqliteTest.cs index 5daab366463..3d5547a42e7 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/MappingQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/MappingQuerySqliteTest.cs @@ -52,11 +52,13 @@ public override void Project_nullable_enum() private static readonly string EOL = Environment.NewLine; - private string Sql => Fixture.TestSqlLoggerFactory.Sql; + private string Sql + => Fixture.TestSqlLoggerFactory.Sql; public class MappingQuerySqliteFixture : MappingQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteNorthwindTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteNorthwindTestStoreFactory.Instance; protected override string DatabaseSchema { get; } = null; diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs index b94c08ca9fa..aec0507adfd 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqliteTest.cs @@ -10,9 +10,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindAggregateOperatorsQuerySqliteTest : NorthwindAggregateOperatorsQueryRelationalTestBase> + public class NorthwindAggregateOperatorsQuerySqliteTest : NorthwindAggregateOperatorsQueryRelationalTestBase< + NorthwindQuerySqliteFixture> { - public NorthwindAggregateOperatorsQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindAggregateOperatorsQuerySqliteTest( + NorthwindQuerySqliteFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { ClearLog(); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqliteTest.cs index 8d682393edb..360cc732b67 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindAsyncSimpleQuerySqliteTest.cs @@ -10,7 +10,8 @@ #pragma warning disable 1998 namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindAsyncSimpleQuerySqliteTest : NorthwindAsyncSimpleQueryRelationalTestBase> + public class NorthwindAsyncSimpleQuerySqliteTest : NorthwindAsyncSimpleQueryRelationalTestBase< + NorthwindQuerySqliteFixture> { public NorthwindAsyncSimpleQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindChangeTrackingQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindChangeTrackingQuerySqliteTest.cs index 9e9dad0dbaa..c1d637b5cc9 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindChangeTrackingQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindChangeTrackingQuerySqliteTest.cs @@ -6,7 +6,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindChangeTrackingQuerySqliteTest : NorthwindChangeTrackingQueryTestBase> + public class NorthwindChangeTrackingQuerySqliteTest : NorthwindChangeTrackingQueryTestBase< + NorthwindQuerySqliteFixture> { public NorthwindChangeTrackingQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs index 747459a4c39..37bc5caa267 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindDbFunctionsQuerySqliteTest.cs @@ -6,15 +6,21 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindDbFunctionsQuerySqliteTest : NorthwindDbFunctionsQueryRelationalTestBase> + public class NorthwindDbFunctionsQuerySqliteTest : NorthwindDbFunctionsQueryRelationalTestBase< + NorthwindQuerySqliteFixture> { - public NorthwindDbFunctionsQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindDbFunctionsQuerySqliteTest( + NorthwindQuerySqliteFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); } - protected override string CaseInsensitiveCollation => "NOCASE"; - protected override string CaseSensitiveCollation => "BINARY"; + protected override string CaseInsensitiveCollation + => "NOCASE"; + + protected override string CaseSensitiveCollation + => "BINARY"; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs index 9d22a2e18dc..f83b8e2cca9 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs @@ -7,9 +7,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindFunctionsQuerySqliteTest : NorthwindFunctionsQueryRelationalTestBase> + public class NorthwindFunctionsQuerySqliteTest : NorthwindFunctionsQueryRelationalTestBase< + NorthwindQuerySqliteFixture> { - public NorthwindFunctionsQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindFunctionsQuerySqliteTest( + NorthwindQuerySqliteFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); @@ -228,7 +231,6 @@ public override async Task String_Contains_Column(bool async) WHERE (""c"".""ContactName"" = '') OR (instr(""c"".""ContactName"", ""c"".""ContactName"") > 0)"); } - public override async Task String_FirstOrDefault_MethodCall(bool async) { await base.String_FirstOrDefault_MethodCall(async); @@ -238,7 +240,6 @@ public override async Task String_FirstOrDefault_MethodCall(bool async) WHERE substr(""c"".""ContactName"", 1, 1) = 'A'"); } - public override async Task String_LastOrDefault_MethodCall(bool async) { await base.String_LastOrDefault_MethodCall(async); @@ -248,7 +249,6 @@ public override async Task String_LastOrDefault_MethodCall(bool async) WHERE substr(""c"".""ContactName"", length(""c"".""ContactName""), 1) = 's'"); } - public override async Task String_Contains_MethodCall(bool async) { await base.String_Contains_MethodCall(async); @@ -279,7 +279,6 @@ public override async Task Indexof_with_emptystring(bool async) WHERE ""c"".""CustomerID"" = 'ALFKI'"); } - public override async Task Replace_with_emptystring(bool async) { await base.Replace_with_emptystring(async); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindGroupByQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindGroupByQuerySqliteTest.cs index cdbba5b44a8..65a9dd1266c 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindGroupByQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindGroupByQuerySqliteTest.cs @@ -1,10 +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.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestUtilities; -using Xunit; using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqliteTest.cs index 04d07d549a8..ef2e2f5d2e2 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqliteTest.cs @@ -12,9 +12,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindIncludeNoTrackingQuerySqliteTest : NorthwindIncludeNoTrackingQueryTestBase> + public class NorthwindIncludeNoTrackingQuerySqliteTest : NorthwindIncludeNoTrackingQueryTestBase< + NorthwindQuerySqliteFixture> { - public NorthwindIncludeNoTrackingQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindIncludeNoTrackingQuerySqliteTest( + NorthwindQuerySqliteFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { //TestSqlLoggerFactory.CaptureOutput(testOutputHelper); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqliteTest.cs index d3b832f3f8f..dc1cba24307 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySqliteTest.cs @@ -7,9 +7,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindKeylessEntitiesQuerySqliteTest : NorthwindKeylessEntitiesQueryRelationalTestBase> + public class NorthwindKeylessEntitiesQuerySqliteTest : NorthwindKeylessEntitiesQueryRelationalTestBase< + NorthwindQuerySqliteFixture> { - public NorthwindKeylessEntitiesQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindKeylessEntitiesQuerySqliteTest( + NorthwindQuerySqliteFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs index 53ddd113260..2ad88a0b17f 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindMiscellaneousQuerySqliteTest.cs @@ -12,10 +12,13 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindMiscellaneousQuerySqliteTest : NorthwindMiscellaneousQueryRelationalTestBase> + public class NorthwindMiscellaneousQuerySqliteTest : NorthwindMiscellaneousQueryRelationalTestBase< + NorthwindQuerySqliteFixture> { // ReSharper disable once UnusedParameter.Local - public NorthwindMiscellaneousQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindMiscellaneousQuerySqliteTest( + NorthwindQuerySqliteFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); @@ -239,7 +242,8 @@ LIMIT @__p_0 public override Task Complex_nested_query_doesnt_try_binding_to_grandparent_when_parent_returns_complex_result(bool async) => null; - public override Task SelectMany_correlated_subquery_hard(bool async) => null; + public override Task SelectMany_correlated_subquery_hard(bool async) + => null; public override async Task Concat_string_int(bool async) { @@ -285,14 +289,12 @@ public override async Task DefaultIfEmpty_in_subquery_nested_filter_order_compar (await Assert.ThrowsAsync( () => base.DefaultIfEmpty_in_subquery_nested_filter_order_comparison(async))).Message); - public override async Task Select_subquery_recursive_trivial(bool async) => Assert.Equal( SqliteStrings.ApplyNotSupported, (await Assert.ThrowsAsync( () => base.Select_subquery_recursive_trivial(async))).Message); - public override async Task Select_correlated_subquery_ordered(bool async) => Assert.Equal( SqliteStrings.ApplyNotSupported, diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindNavigationsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindNavigationsQuerySqliteTest.cs index d0f9d9eb088..e7116eab259 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindNavigationsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindNavigationsQuerySqliteTest.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindNavigationsQuerySqliteTest : NorthwindNavigationsQueryRelationalTestBase> + public class NorthwindNavigationsQuerySqliteTest : NorthwindNavigationsQueryRelationalTestBase< + NorthwindQuerySqliteFixture> { public NorthwindNavigationsQuerySqliteTest(NorthwindQuerySqliteFixture fixture) : base(fixture) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQueryFiltersQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQueryFiltersQuerySqliteTest.cs index 8c9604e7161..0cdf29b42be 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQueryFiltersQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQueryFiltersQuerySqliteTest.cs @@ -5,9 +5,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindQueryFiltersQuerySqliteTest : NorthwindQueryFiltersQueryTestBase> + public class NorthwindQueryFiltersQuerySqliteTest : NorthwindQueryFiltersQueryTestBase< + NorthwindQuerySqliteFixture> { - public NorthwindQueryFiltersQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindQueryFiltersQuerySqliteTest( + NorthwindQuerySqliteFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQuerySqliteFixture.cs index 7af887cb175..1ba997c0052 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQuerySqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQuerySqliteFixture.cs @@ -10,7 +10,8 @@ namespace Microsoft.EntityFrameworkCore.Query public class NorthwindQuerySqliteFixture : NorthwindQueryRelationalFixture where TModelCustomizer : IModelCustomizer, new() { - protected override ITestStoreFactory TestStoreFactory => SqliteNorthwindTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteNorthwindTestStoreFactory.Instance; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQueryTaggingQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQueryTaggingQuerySqliteTest.cs index c829da25c37..c8a3fb0cd57 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQueryTaggingQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindQueryTaggingQuerySqliteTest.cs @@ -9,7 +9,8 @@ namespace Microsoft.EntityFrameworkCore.Query public class NorthwindQueryTaggingQuerySqliteTest : NorthwindQueryTaggingQueryTestBase> { public NorthwindQueryTaggingQuerySqliteTest( - NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + NorthwindQuerySqliteFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSelectQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSelectQuerySqliteTest.cs index c17d319146a..13ec6ed88b8 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSelectQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSelectQuerySqliteTest.cs @@ -218,7 +218,7 @@ public override Task SelectMany_with_collection_being_correlated_subquery_which_ public override Task Reverse_without_explicit_ordering_throws(bool async) { return AssertTranslationFailedWithDetails( - () => base.Reverse_without_explicit_ordering_throws(async), RelationalStrings.MissingOrderingInSqlExpression); + () => base.Reverse_without_explicit_ordering_throws(async), RelationalStrings.MissingOrderingInSqlExpression); } private void AssertSql(params string[] expected) diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSetOperationsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSetOperationsQuerySqliteTest.cs index e1a2643a4a1..dfff0914df0 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSetOperationsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSetOperationsQuerySqliteTest.cs @@ -6,9 +6,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindSetOperationsQuerySqliteTest : NorthwindSetOperationsQueryRelationalTestBase> + public class NorthwindSetOperationsQuerySqliteTest : NorthwindSetOperationsQueryRelationalTestBase< + NorthwindQuerySqliteFixture> { - public NorthwindSetOperationsQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindSetOperationsQuerySqliteTest( + NorthwindQuerySqliteFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqliteTest.cs index 5524f12e87a..625acbe648e 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqliteTest.cs @@ -10,9 +10,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindSplitIncludeNoTrackingQuerySqliteTest : NorthwindSplitIncludeNoTrackingQueryTestBase> + public class NorthwindSplitIncludeNoTrackingQuerySqliteTest : NorthwindSplitIncludeNoTrackingQueryTestBase< + NorthwindQuerySqliteFixture> { - public NorthwindSplitIncludeNoTrackingQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindSplitIncludeNoTrackingQuerySqliteTest( + NorthwindQuerySqliteFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { //TestSqlLoggerFactory.CaptureOutput(testOutputHelper); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSplitIncludeQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSplitIncludeQuerySqliteTest.cs index d3fa3954af5..608843cadd5 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSplitIncludeQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindSplitIncludeQuerySqliteTest.cs @@ -12,7 +12,9 @@ namespace Microsoft.EntityFrameworkCore.Query { public class NorthwindSplitIncludeQuerySqliteTest : NorthwindSplitIncludeQueryTestBase> { - public NorthwindSplitIncludeQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindSplitIncludeQuerySqliteTest( + NorthwindQuerySqliteFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { //TestSqlLoggerFactory.CaptureOutput(testOutputHelper); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindStringIncludeQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindStringIncludeQuerySqliteTest.cs index ffde5bcdd51..a643243a0b0 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindStringIncludeQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindStringIncludeQuerySqliteTest.cs @@ -12,9 +12,12 @@ namespace Microsoft.EntityFrameworkCore.Query { - public class NorthwindStringIncludeQuerySqliteTest : NorthwindStringIncludeQueryTestBase> + public class NorthwindStringIncludeQuerySqliteTest : NorthwindStringIncludeQueryTestBase< + NorthwindQuerySqliteFixture> { - public NorthwindStringIncludeQuerySqliteTest(NorthwindQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + public NorthwindStringIncludeQuerySqliteTest( + NorthwindQuerySqliteFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { //TestSqlLoggerFactory.CaptureOutput(testOutputHelper); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NullKeysSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NullKeysSqliteTest.cs index 96ef8d062ef..98b5b6cb4fd 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NullKeysSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NullKeysSqliteTest.cs @@ -14,7 +14,8 @@ public NullKeysSqliteTest(NullKeysSqliteFixture fixture) public class NullKeysSqliteFixture : NullKeysFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteFixture.cs index d33b545fbf9..b3eea793c48 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NullSemanticsQuerySqliteFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class NullSemanticsQuerySqliteFixture : NullSemanticsQueryFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/OwnedQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/OwnedQuerySqliteTest.cs index 8b175078a0e..6f847d5de81 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/OwnedQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/OwnedQuerySqliteTest.cs @@ -14,7 +14,8 @@ public OwnedQuerySqliteTest(OwnedQuerySqliteFixture fixture) public class OwnedQuerySqliteFixture : RelationalOwnedQueryFixture { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/QueryFilterFuncletizationSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/QueryFilterFuncletizationSqliteTest.cs index 4d8483a7044..3a32ae733be 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/QueryFilterFuncletizationSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/QueryFilterFuncletizationSqliteTest.cs @@ -10,7 +10,8 @@ public class QueryFilterFuncletizationSqliteTest : QueryFilterFuncletizationTest QueryFilterFuncletizationSqliteTest.QueryFilterFuncletizationSqliteFixture> { public QueryFilterFuncletizationSqliteTest( - QueryFilterFuncletizationSqliteFixture fixture, ITestOutputHelper testOutputHelper) + QueryFilterFuncletizationSqliteFixture fixture, + ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); @@ -19,7 +20,8 @@ public QueryFilterFuncletizationSqliteTest( public class QueryFilterFuncletizationSqliteFixture : QueryFilterFuncletizationRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPTFiltersInheritanceQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPTFiltersInheritanceQuerySqliteFixture.cs index b6bc031f8ab..5fc3a2a56bf 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPTFiltersInheritanceQuerySqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPTFiltersInheritanceQuerySqliteFixture.cs @@ -5,6 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class TPTFiltersInheritanceQuerySqliteFixture : TPTInheritanceQuerySqliteFixture { - protected override bool EnableFilters => true; + protected override bool EnableFilters + => true; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteFixture.cs index 40c26cd87af..b0d2789136b 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class TPTGearsOfWarQuerySqliteFixture : TPTGearsOfWarQueryRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs index 78eb275dcf4..ee3cfd4ff26 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs @@ -56,29 +56,42 @@ public override Task DateTimeOffset_Date_returns_datetime(bool async) => AssertTranslationFailed(() => base.DateTimeOffset_Date_returns_datetime(async)); // Sqlite does not support cross/outer apply - public override Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool async) => null; + public override Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool async) + => null; - public override Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool async) => null; + public override Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool async) + => null; - public override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(bool async) => null; + public override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(bool async) + => null; - public override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(bool async) => null; + public override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(bool async) + => null; - public override Task Outer_parameter_in_group_join_with_DefaultIfEmpty(bool async) => null; + public override Task Outer_parameter_in_group_join_with_DefaultIfEmpty(bool async) + => null; - public override Task Outer_parameter_in_join_key(bool async) => null; + public override Task Outer_parameter_in_join_key(bool async) + => null; - public override Task Outer_parameter_in_join_key_inner_and_outer(bool async) => null; + public override Task Outer_parameter_in_join_key_inner_and_outer(bool async) + => null; - public override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async) => null; + public override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async) + => null; - public override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(bool async) => null; + public override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(bool async) + => null; - public override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(bool async) => null; + public override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(bool async) + => null; - public override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(bool async) => null; + public override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated( + bool async) + => null; - public override Task SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(bool async) => null; + public override Task SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(bool async) + => null; public override async Task Negate_on_binary_expression(bool async) { @@ -145,7 +158,8 @@ public override async Task Byte_array_filter_by_length_literal(bool async) { await base.Byte_array_filter_by_length_literal(async); - AssertSql(@"SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name"" + AssertSql( + @"SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name"" FROM ""Squads"" AS ""s"" WHERE length(""s"".""Banner"") = 1"); } @@ -154,7 +168,8 @@ public override async Task Byte_array_filter_by_length_parameter(bool async) { await base.Byte_array_filter_by_length_parameter(async); - AssertSql(@"@__p_0='1' (DbType = String) + AssertSql( + @"@__p_0='1' (DbType = String) SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name"" FROM ""Squads"" AS ""s"" @@ -177,7 +192,8 @@ public override async Task Byte_array_filter_by_SequenceEqual(bool async) { await base.Byte_array_filter_by_SequenceEqual(async); - AssertSql(@"@__byteArrayParam_0='0x0405060708' (Size = 5) (DbType = String) + AssertSql( + @"@__byteArrayParam_0='0x0405060708' (Size = 5) (DbType = String) SELECT ""s"".""Id"", ""s"".""Banner"", ""s"".""Banner5"", ""s"".""InternalNumber"", ""s"".""Name"" FROM ""Squads"" AS ""s"" @@ -185,28 +201,36 @@ public override async Task Byte_array_filter_by_SequenceEqual(bool async) } [ConditionalTheory(Skip = "Issue#18844")] - public override Task TimeSpan_Hours(bool async) => base.TimeSpan_Hours(async); + public override Task TimeSpan_Hours(bool async) + => base.TimeSpan_Hours(async); [ConditionalTheory(Skip = "Issue#18844")] - public override Task TimeSpan_Minutes(bool async) => base.TimeSpan_Minutes(async); + public override Task TimeSpan_Minutes(bool async) + => base.TimeSpan_Minutes(async); [ConditionalTheory(Skip = "Issue#18844")] - public override Task TimeSpan_Seconds(bool async) => base.TimeSpan_Seconds(async); + public override Task TimeSpan_Seconds(bool async) + => base.TimeSpan_Seconds(async); [ConditionalTheory(Skip = "Issue#18844")] - public override Task TimeSpan_Milliseconds(bool async) => base.TimeSpan_Milliseconds(async); + public override Task TimeSpan_Milliseconds(bool async) + => base.TimeSpan_Milliseconds(async); [ConditionalTheory(Skip = "Issue#18844")] - public override Task Where_TimeSpan_Hours(bool async) => base.Where_TimeSpan_Hours(async); + public override Task Where_TimeSpan_Hours(bool async) + => base.Where_TimeSpan_Hours(async); [ConditionalTheory(Skip = "Issue#18844")] - public override Task Where_TimeSpan_Minutes(bool async) => base.Where_TimeSpan_Minutes(async); + public override Task Where_TimeSpan_Minutes(bool async) + => base.Where_TimeSpan_Minutes(async); [ConditionalTheory(Skip = "Issue#18844")] - public override Task Where_TimeSpan_Seconds(bool async) => base.Where_TimeSpan_Seconds(async); + public override Task Where_TimeSpan_Seconds(bool async) + => base.Where_TimeSpan_Seconds(async); [ConditionalTheory(Skip = "Issue#18844")] - public override Task Where_TimeSpan_Milliseconds(bool async) => base.Where_TimeSpan_Milliseconds(async); + public override Task Where_TimeSpan_Milliseconds(bool async) + => base.Where_TimeSpan_Milliseconds(async); private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPTInheritanceQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPTInheritanceQuerySqliteFixture.cs index 05e666f7130..99a08c45c3f 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPTInheritanceQuerySqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPTInheritanceQuerySqliteFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class TPTInheritanceQuerySqliteFixture : TPTInheritanceQueryFixture { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqliteTest.cs index ee4894f37e7..da53f67787b 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySqliteTest.cs @@ -28,6 +28,7 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take_t () => base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(async))).Message); [ConditionalTheory(Skip = "Issue#21541")] - public override Task Left_join_with_skip_navigation(bool async) => base.Left_join_with_skip_navigation(async); + public override Task Left_join_with_skip_navigation(bool async) + => base.Left_join_with_skip_navigation(async); } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyQuerySqliteFixture.cs index aa3c21a1e1c..fed02d36df1 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyQuerySqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyQuerySqliteFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query { public class TPTManyToManyQuerySqliteFixture : TPTManyToManyQueryRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyQuerySqliteTest.cs index 97955f68180..470e294af0d 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPTManyToManyQuerySqliteTest.cs @@ -28,6 +28,7 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take_t () => base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(async))).Message); [ConditionalTheory(Skip = "Issue#21541")] - public override Task Left_join_with_skip_navigation(bool async) => base.Left_join_with_skip_navigation(async); + public override Task Left_join_with_skip_navigation(bool async) + => base.Left_join_with_skip_navigation(async); } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPTRelationshipsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPTRelationshipsQuerySqliteTest.cs index 857f8a09c2f..bddbbcb52b8 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPTRelationshipsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPTRelationshipsQuerySqliteTest.cs @@ -15,7 +15,8 @@ public TPTRelationshipsQuerySqliteTest(TPTRelationshipsQuerySqliteFixture fixtur public class TPTRelationshipsQuerySqliteFixture : TPTRelationshipsQueryRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/SaveChangesInterceptionSqliteTestBase.cs b/test/EFCore.Sqlite.FunctionalTests/SaveChangesInterceptionSqliteTestBase.cs index 6b3b4643fec..c421eb88e80 100644 --- a/test/EFCore.Sqlite.FunctionalTests/SaveChangesInterceptionSqliteTestBase.cs +++ b/test/EFCore.Sqlite.FunctionalTests/SaveChangesInterceptionSqliteTestBase.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -19,9 +18,11 @@ protected SaveChangesInterceptionSqliteTestBase(InterceptionSqliteFixtureBase fi public abstract class InterceptionSqliteFixtureBase : InterceptionFixtureBase { - protected override string StoreName => "SaveChangesInterception"; + protected override string StoreName + => "SaveChangesInterception"; - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; protected override IServiceCollection InjectInterceptors( IServiceCollection serviceCollection, @@ -39,7 +40,8 @@ public SaveChangesInterceptionSqliteTest(InterceptionSqliteFixture fixture) public class InterceptionSqliteFixture : InterceptionSqliteFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => false; + protected override bool ShouldSubscribeToDiagnosticListener + => false; } } @@ -54,7 +56,8 @@ public SaveChangesInterceptionWithDiagnosticsSqliteTest(InterceptionSqliteFixtur public class InterceptionSqliteFixture : InterceptionSqliteFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => true; + protected override bool ShouldSubscribeToDiagnosticListener + => true; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/Scaffolding/SqliteDatabaseModelFactoryTest.cs b/test/EFCore.Sqlite.FunctionalTests/Scaffolding/SqliteDatabaseModelFactoryTest.cs index 436e2916dc6..6be4947734a 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Scaffolding/SqliteDatabaseModelFactoryTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Scaffolding/SqliteDatabaseModelFactoryTest.cs @@ -35,7 +35,11 @@ public SqliteDatabaseModelFactoryTest(SqliteDatabaseModelFixture fixture) } private void Test( - string createSql, IEnumerable tables, IEnumerable schemas, Action asserter, string cleanupSql) + string createSql, + IEnumerable tables, + IEnumerable schemas, + Action asserter, + string cleanupSql) { Fixture.TestStore.ExecuteNonQuery(createSql); @@ -351,7 +355,6 @@ FOREIGN KEY (Id3, Id1, Id2) REFERENCES MinimalFKTest1 Assert.Equal(new[] { "Id3", "Id1", "Id2" }, foreignKey.Columns.Select(c => c.Name)); Assert.Equal("MinimalFKTest1", foreignKey.PrincipalTable.Name); Assert.Equal(new[] { "Id2", "Id3", "Id1" }, foreignKey.PrincipalColumns.Select(c => c.Name)); - }, @" DROP TABLE MinimalFKTest2; @@ -1006,8 +1009,12 @@ CONSTRAINT MYFK FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(ImaginaryId public class SqliteDatabaseModelFixture : SharedStoreFixtureBase { protected override string StoreName { get; } = nameof(SqliteDatabaseModelFactoryTest); - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; - public new SqliteTestStore TestStore => (SqliteTestStore)base.TestStore; + + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; + + public new SqliteTestStore TestStore + => (SqliteTestStore)base.TestStore; protected override bool ShouldLogCategory(string logCategory) => logCategory == DbLoggerCategory.Scaffolding.Name; diff --git a/test/EFCore.Sqlite.FunctionalTests/StoreGeneratedFixupSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/StoreGeneratedFixupSqliteTest.cs index cc89a152a6e..7f56437f4dc 100644 --- a/test/EFCore.Sqlite.FunctionalTests/StoreGeneratedFixupSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/StoreGeneratedFixupSqliteTest.cs @@ -36,14 +36,16 @@ public void Temp_values_can_be_made_permanent() Assert.Equal(tempValue, entry.Property(e => e.Id).CurrentValue); } - protected override bool EnforcesFKs => true; + protected override bool EnforcesFKs + => true; protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); public class StoreGeneratedFixupSqliteFixture : StoreGeneratedFixupRelationalFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/StoreGeneratedSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/StoreGeneratedSqliteTest.cs index 12dc3ddb954..baf6b6f5181 100644 --- a/test/EFCore.Sqlite.FunctionalTests/StoreGeneratedSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/StoreGeneratedSqliteTest.cs @@ -41,7 +41,8 @@ protected override void UseTransaction(DatabaseFacade facade, IDbContextTransact public class StoreGeneratedSqliteFixture : StoreGeneratedFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) => builder diff --git a/test/EFCore.Sqlite.FunctionalTests/TPTTableSplittingSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/TPTTableSplittingSqliteTest.cs index 091a4d1a2b4..8cfa0dd7c14 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TPTTableSplittingSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TPTTableSplittingSqliteTest.cs @@ -13,6 +13,7 @@ public TPTTableSplittingSqliteTest(ITestOutputHelper testOutputHelper) { } - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/TableSplittingSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/TableSplittingSqliteTest.cs index 3584648c2cb..2dcacc0d8e4 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TableSplittingSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TableSplittingSqliteTest.cs @@ -22,6 +22,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .Property(e => e.Computed).HasComputedColumnSql("1"); } - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SpatialiteRequiredAttribute.cs b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SpatialiteRequiredAttribute.cs index a2680a8605e..df5a55739c9 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SpatialiteRequiredAttribute.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SpatialiteRequiredAttribute.cs @@ -20,7 +20,8 @@ private static readonly Lazy _loaded return SpatialiteLoader.TryLoad(connection); }); - public ValueTask IsMetAsync() => new ValueTask(_loaded.Value); + public ValueTask IsMetAsync() + => new ValueTask(_loaded.Value); public string SkipReason => "mod_spatialite not found. Install it to run this test."; diff --git a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteDatabaseCleaner.cs b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteDatabaseCleaner.cs index bead91da925..ad4a5bec563 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteDatabaseCleaner.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteDatabaseCleaner.cs @@ -41,11 +41,14 @@ protected override IDatabaseModelFactory CreateDatabaseModelFactory(ILoggerFacto .GetRequiredService(); } - protected override bool AcceptForeignKey(DatabaseForeignKey foreignKey) => false; + protected override bool AcceptForeignKey(DatabaseForeignKey foreignKey) + => false; - protected override bool AcceptIndex(DatabaseIndex index) => false; + protected override bool AcceptIndex(DatabaseIndex index) + => false; - protected override string BuildCustomSql(DatabaseModel databaseModel) => "PRAGMA foreign_keys=OFF;"; + protected override string BuildCustomSql(DatabaseModel databaseModel) + => "PRAGMA foreign_keys=OFF;"; protected override void OpenConnection(IRelationalConnection connection) { diff --git a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStore.cs b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStore.cs index 5ad84c97759..59bb8f644b4 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStore.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteTestStore.cs @@ -63,7 +63,9 @@ public SqliteTestStore InitializeSqlite(IServiceProvider serviceProvider, Func (SqliteTestStore)Initialize(serviceProvider, createContext, seed); public SqliteTestStore InitializeSqlite( - IServiceProvider serviceProvider, Func createContext, Action seed) + IServiceProvider serviceProvider, + Func createContext, + Action seed) => (SqliteTestStore)Initialize(serviceProvider, () => createContext(this), seed); protected override void Initialize(Func createContext, Action seed, Action clean) diff --git a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteVersionConditionAttribute.cs b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteVersionConditionAttribute.cs index f7d97700dfb..0baa0576cb1 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteVersionConditionAttribute.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TestUtilities/SqliteVersionConditionAttribute.cs @@ -68,9 +68,10 @@ public ValueTask IsMetAsync() public string SkipReason { set => _skipReason = value; - get => _skipReason - ?? $"Test only runs for SQLite versions >= {Min ?? "Any"} and <= {Max ?? "Any"}" - + (Skip == null ? "" : "and skipping on " + Skip); + get + => _skipReason + ?? $"Test only runs for SQLite versions >= {Min ?? "Any"} and <= {Max ?? "Any"}" + + (Skip == null ? "" : "and skipping on " + Skip); } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/TransactionInterceptionSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/TransactionInterceptionSqliteTest.cs index 7e2869dfd6d..cd42fbf3ed4 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TransactionInterceptionSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TransactionInterceptionSqliteTest.cs @@ -18,8 +18,11 @@ protected TransactionInterceptionSqliteTestBase(InterceptionSqliteFixtureBase fi public abstract class InterceptionSqliteFixtureBase : InterceptionFixtureBase { - protected override string StoreName => "TransactionInterception"; - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override string StoreName + => "TransactionInterception"; + + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; protected override IServiceCollection InjectInterceptors( IServiceCollection serviceCollection, @@ -37,7 +40,8 @@ public TransactionInterceptionSqliteTest(InterceptionSqliteFixture fixture) public class InterceptionSqliteFixture : InterceptionSqliteFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => false; + protected override bool ShouldSubscribeToDiagnosticListener + => false; } } @@ -52,7 +56,8 @@ public TransactionInterceptionWithDiagnosticsSqliteTest(InterceptionSqliteFixtur public class InterceptionSqliteFixture : InterceptionSqliteFixtureBase { - protected override bool ShouldSubscribeToDiagnosticListener => true; + protected override bool ShouldSubscribeToDiagnosticListener + => true; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/TransactionSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/TransactionSqliteTest.cs index 4c85bcbfd1f..30a98882ae5 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TransactionSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TransactionSqliteTest.cs @@ -13,7 +13,8 @@ public TransactionSqliteTest(TransactionSqliteFixture fixture) { } - protected override bool SnapshotSupported => false; + protected override bool SnapshotSupported + => false; protected override DbContext CreateContextWithConnectionString() { @@ -27,7 +28,8 @@ protected override DbContext CreateContextWithConnectionString() public class TransactionSqliteFixture : TransactionFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; public override void Reseed() { diff --git a/test/EFCore.Sqlite.FunctionalTests/TwoDatabasesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/TwoDatabasesSqliteTest.cs index 0284164201c..a0cb08d3e67 100644 --- a/test/EFCore.Sqlite.FunctionalTests/TwoDatabasesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/TwoDatabasesSqliteTest.cs @@ -13,10 +13,12 @@ public TwoDatabasesSqliteTest(TwoDatabasesFixture fixture) { } - protected new TwoDatabasesFixture Fixture => (TwoDatabasesFixture)base.Fixture; + protected new TwoDatabasesFixture Fixture + => (TwoDatabasesFixture)base.Fixture; protected override DbContextOptionsBuilder CreateTestOptions( - DbContextOptionsBuilder optionsBuilder, bool withConnectionString = false) + DbContextOptionsBuilder optionsBuilder, + bool withConnectionString = false) => withConnectionString ? optionsBuilder.UseSqlite(DummyConnectionString) : optionsBuilder.UseSqlite(); @@ -28,7 +30,8 @@ protected override TwoDatabasesWithDataContext CreateBackingContext(string datab public class TwoDatabasesFixture : ServiceProviderFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } } diff --git a/test/EFCore.Sqlite.FunctionalTests/UpdatesSqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/UpdatesSqliteFixture.cs index 7071fea1da9..641d36dbe11 100644 --- a/test/EFCore.Sqlite.FunctionalTests/UpdatesSqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/UpdatesSqliteFixture.cs @@ -7,6 +7,7 @@ namespace Microsoft.EntityFrameworkCore { public class UpdatesSqliteFixture : UpdatesRelationalFixture { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; } } diff --git a/test/EFCore.Sqlite.FunctionalTests/WithConstructorsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/WithConstructorsSqliteTest.cs index bd02c4c6aa9..23e1b17f9c7 100644 --- a/test/EFCore.Sqlite.FunctionalTests/WithConstructorsSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/WithConstructorsSqliteTest.cs @@ -19,7 +19,8 @@ protected override void UseTransaction(DatabaseFacade facade, IDbContextTransact public class WithConstructorsSqliteFixture : WithConstructorsFixtureBase { - protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + protected override ITestStoreFactory TestStoreFactory + => SqliteTestStoreFactory.Instance; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { diff --git a/test/EFCore.Sqlite.Tests/DbSetAsTableNameSqliteTest.cs b/test/EFCore.Sqlite.Tests/DbSetAsTableNameSqliteTest.cs index f036f43c49f..599c5013155 100644 --- a/test/EFCore.Sqlite.Tests/DbSetAsTableNameSqliteTest.cs +++ b/test/EFCore.Sqlite.Tests/DbSetAsTableNameSqliteTest.cs @@ -10,9 +10,11 @@ public class DbSetAsTableNameSqliteTest : DbSetAsTableNameTest protected override string GetTableName(DbContext context) => context.Model.FindEntityType(typeof(TEntity)).GetTableName(); - protected override SetsContext CreateContext() => new SqliteSetsContext(); + protected override SetsContext CreateContext() + => new SqliteSetsContext(); - protected override SetsContext CreateNamedTablesContext() => new SqliteNamedTablesContextContext(); + protected override SetsContext CreateNamedTablesContext() + => new SqliteNamedTablesContextContext(); protected class SqliteSetsContext : SetsContext { diff --git a/test/EFCore.Sqlite.Tests/Infrastructure/SqliteModelValidatorTest.cs b/test/EFCore.Sqlite.Tests/Infrastructure/SqliteModelValidatorTest.cs index 82a306a5e73..72b260f0579 100644 --- a/test/EFCore.Sqlite.Tests/Infrastructure/SqliteModelValidatorTest.cs +++ b/test/EFCore.Sqlite.Tests/Infrastructure/SqliteModelValidatorTest.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; 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; @@ -98,9 +97,10 @@ public void Detects_sequences() private static void GenerateMapping(IMutableProperty property) => property.SetTypeMapping( - TestServiceFactory.Instance.Create() + TestServiceFactory.Instance.Create() .FindMapping(property)); - protected override TestHelpers TestHelpers => SqliteTestHelpers.Instance; + protected override TestHelpers TestHelpers + => SqliteTestHelpers.Instance; } } diff --git a/test/EFCore.Sqlite.Tests/Metadata/Conventions/SqliteConventionSetBuilderTests.cs b/test/EFCore.Sqlite.Tests/Metadata/Conventions/SqliteConventionSetBuilderTests.cs index 314dc1ffd36..d5e38c3bb56 100644 --- a/test/EFCore.Sqlite.Tests/Metadata/Conventions/SqliteConventionSetBuilderTests.cs +++ b/test/EFCore.Sqlite.Tests/Metadata/Conventions/SqliteConventionSetBuilderTests.cs @@ -17,7 +17,10 @@ public override IModel Can_build_a_model_with_default_conventions_without_DI() return model; } - protected override ConventionSet GetConventionSet() => SqliteConventionSetBuilder.Build(); - protected override ModelBuilder GetModelBuilder() => SqliteConventionSetBuilder.CreateModelBuilder(); + protected override ConventionSet GetConventionSet() + => SqliteConventionSetBuilder.Build(); + + protected override ModelBuilder GetModelBuilder() + => SqliteConventionSetBuilder.CreateModelBuilder(); } } diff --git a/test/EFCore.Sqlite.Tests/Migrations/SqliteHistoryRepositoryTest.cs b/test/EFCore.Sqlite.Tests/Migrations/SqliteHistoryRepositoryTest.cs index b1957fb7ff9..06e588c10ec 100644 --- a/test/EFCore.Sqlite.Tests/Migrations/SqliteHistoryRepositoryTest.cs +++ b/test/EFCore.Sqlite.Tests/Migrations/SqliteHistoryRepositoryTest.cs @@ -12,7 +12,8 @@ namespace Microsoft.EntityFrameworkCore.Migrations { public class SqliteHistoryRepositoryTest { - private static string EOL => Environment.NewLine; + private static string EOL + => Environment.NewLine; [ConditionalFact] public void GetCreateScript_works() diff --git a/test/EFCore.Sqlite.Tests/Migrations/SqliteMigrationAnnotationProviderTest.cs b/test/EFCore.Sqlite.Tests/Migrations/SqliteMigrationAnnotationProviderTest.cs index 4e695f96f31..305a1a1ff54 100644 --- a/test/EFCore.Sqlite.Tests/Migrations/SqliteMigrationAnnotationProviderTest.cs +++ b/test/EFCore.Sqlite.Tests/Migrations/SqliteMigrationAnnotationProviderTest.cs @@ -30,7 +30,8 @@ public void Adds_Autoincrement_for_OnAdd_integer_property() var property = _modelBuilder.Entity().Property(e => e.IntProp).ValueGeneratedOnAdd().Metadata; _modelBuilder.FinalizeModel(); - Assert.Contains(_provider.For(property.GetTableColumnMappings().Single().Column), + Assert.Contains( + _provider.For(property.GetTableColumnMappings().Single().Column), a => a.Name == _autoincrement.Name && (bool)a.Value); } @@ -40,7 +41,8 @@ public void Does_not_add_Autoincrement_for_OnAddOrUpdate_integer_property() var property = _modelBuilder.Entity().Property(e => e.IntProp).ValueGeneratedOnAddOrUpdate().Metadata; _modelBuilder.FinalizeModel(); - Assert.DoesNotContain(_provider.For(property.GetTableColumnMappings().Single().Column), + Assert.DoesNotContain( + _provider.For(property.GetTableColumnMappings().Single().Column), a => a.Name == _autoincrement.Name); } @@ -50,7 +52,8 @@ public void Does_not_add_Autoincrement_for_OnUpdate_integer_property() var property = _modelBuilder.Entity().Property(e => e.IntProp).ValueGeneratedOnUpdate().Metadata; _modelBuilder.FinalizeModel(); - Assert.DoesNotContain(_provider.For(property.GetTableColumnMappings().Single().Column), + Assert.DoesNotContain( + _provider.For(property.GetTableColumnMappings().Single().Column), a => a.Name == _autoincrement.Name); } @@ -60,7 +63,8 @@ public void Does_not_add_Autoincrement_for_Never_value_generated_integer_propert var property = _modelBuilder.Entity().Property(e => e.IntProp).ValueGeneratedNever().Metadata; _modelBuilder.FinalizeModel(); - Assert.DoesNotContain(_provider.For(property.GetTableColumnMappings().Single().Column), + Assert.DoesNotContain( + _provider.For(property.GetTableColumnMappings().Single().Column), a => a.Name == _autoincrement.Name); } @@ -70,7 +74,8 @@ public void Does_not_add_Autoincrement_for_default_integer_property() var property = _modelBuilder.Entity().Property(e => e.IntProp).Metadata; _modelBuilder.FinalizeModel(); - Assert.DoesNotContain(_provider.For(property.GetTableColumnMappings().Single().Column), + Assert.DoesNotContain( + _provider.For(property.GetTableColumnMappings().Single().Column), a => a.Name == _autoincrement.Name); } @@ -80,7 +85,8 @@ public void Does_not_add_Autoincrement_for_non_integer_OnAdd_property() var property = _modelBuilder.Entity().Property(e => e.StringProp).ValueGeneratedOnAdd().Metadata; _modelBuilder.FinalizeModel(); - Assert.DoesNotContain(_provider.For(property.GetTableColumnMappings().Single().Column), + Assert.DoesNotContain( + _provider.For(property.GetTableColumnMappings().Single().Column), a => a.Name == _autoincrement.Name); } diff --git a/test/EFCore.Sqlite.Tests/Migrations/SqliteMigrationsSqlGeneratorTest.cs b/test/EFCore.Sqlite.Tests/Migrations/SqliteMigrationsSqlGeneratorTest.cs index 298d435641d..791b68a3ae0 100644 --- a/test/EFCore.Sqlite.Tests/Migrations/SqliteMigrationsSqlGeneratorTest.cs +++ b/test/EFCore.Sqlite.Tests/Migrations/SqliteMigrationsSqlGeneratorTest.cs @@ -663,11 +663,7 @@ public virtual void AddCheckConstraint_throws_when_no_model() public virtual void AlterTable_mostly_works_when_no_model() { Generate( - new AlterTableOperation - { - Name = "Blogs", - Comment = "The Blogs table" - }); + new AlterTableOperation { Name = "Blogs", Comment = "The Blogs table" }); Assert.Empty(Sql); } @@ -677,11 +673,7 @@ public virtual void DropForeignKey_throws_when_no_model() { var ex = Assert.Throws( () => Generate( - new DropForeignKeyOperation - { - Table = "Posts", - Name = "FK_Posts_BlogId" - })); + new DropForeignKeyOperation { Table = "Posts", Name = "FK_Posts_BlogId" })); Assert.Equal(SqliteStrings.InvalidMigrationOperation("DropForeignKeyOperation"), ex.Message); } @@ -691,11 +683,7 @@ public virtual void DropPrimaryKey_throws_when_no_model() { var ex = Assert.Throws( () => Generate( - new DropPrimaryKeyOperation - { - Table = "Blogs", - Name = "PK_Blogs" - })); + new DropPrimaryKeyOperation { Table = "Blogs", Name = "PK_Blogs" })); Assert.Equal(SqliteStrings.InvalidMigrationOperation("DropPrimaryKeyOperation"), ex.Message); } @@ -705,11 +693,7 @@ public virtual void DropUniqueConstraint_throws_when_no_model() { var ex = Assert.Throws( () => Generate( - new DropUniqueConstraintOperation - { - Table = "Blogs", - Name = "AK_Blogs_Uri" - })); + new DropUniqueConstraintOperation { Table = "Blogs", Name = "AK_Blogs_Uri" })); Assert.Equal(SqliteStrings.InvalidMigrationOperation("DropUniqueConstraintOperation"), ex.Message); } @@ -719,11 +703,7 @@ public virtual void DropColumn_throws_when_no_model() { var ex = Assert.Throws( () => Generate( - new DropColumnOperation - { - Table = "Posts", - Name = "Rating" - })); + new DropColumnOperation { Table = "Posts", Name = "Rating" })); Assert.Equal(SqliteStrings.InvalidMigrationOperation("DropColumnOperation"), ex.Message); } @@ -960,7 +940,6 @@ public virtual void Deferred_AddColumn_defers_subsequent_CreateIndex() name: "IX_Blog_Name", table: "Blog", column: "Name"); - }); AssertSql( @@ -1034,12 +1013,13 @@ public virtual void RenameTable_preserves_pending_rebuilds() } public SqliteMigrationsSqlGeneratorTest() - : base(SqliteTestHelpers.Instance, - new ServiceCollection().AddEntityFrameworkSqliteNetTopologySuite(), - SqliteTestHelpers.Instance.AddProviderOptions( - ((IRelationalDbContextOptionsBuilderInfrastructure) - new SqliteDbContextOptionsBuilder(new DbContextOptionsBuilder()).UseNetTopologySuite()) - .OptionsBuilder).Options) + : base( + SqliteTestHelpers.Instance, + new ServiceCollection().AddEntityFrameworkSqliteNetTopologySuite(), + SqliteTestHelpers.Instance.AddProviderOptions( + ((IRelationalDbContextOptionsBuilderInfrastructure) + new SqliteDbContextOptionsBuilder(new DbContextOptionsBuilder()).UseNetTopologySuite()) + .OptionsBuilder).Options) { } } diff --git a/test/EFCore.Sqlite.Tests/SqliteApiConsistencyTest.cs b/test/EFCore.Sqlite.Tests/SqliteApiConsistencyTest.cs index ed2ff7d49bb..1f155fca278 100644 --- a/test/EFCore.Sqlite.Tests/SqliteApiConsistencyTest.cs +++ b/test/EFCore.Sqlite.Tests/SqliteApiConsistencyTest.cs @@ -21,7 +21,8 @@ public SqliteApiConsistencyTest(SqliteApiConsistencyFixture fixture) protected override void AddServices(ServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkSqlite(); - protected override Assembly TargetAssembly => typeof(SqliteRelationalConnection).Assembly; + protected override Assembly TargetAssembly + => typeof(SqliteRelationalConnection).Assembly; public class SqliteApiConsistencyFixture : ApiConsistencyFixtureBase { @@ -32,7 +33,7 @@ public override bool TryGetProviderOptionsDelegate(out Action FluentApiTypes { get; } = new HashSet() + public override HashSet FluentApiTypes { get; } = new HashSet { typeof(SqliteServiceCollectionExtensions), typeof(SqliteDbContextOptionsBuilderExtensions), diff --git a/test/EFCore.Sqlite.Tests/SqliteEventIdTest.cs b/test/EFCore.Sqlite.Tests/SqliteEventIdTest.cs index c53ee853888..5bc8460be50 100644 --- a/test/EFCore.Sqlite.Tests/SqliteEventIdTest.cs +++ b/test/EFCore.Sqlite.Tests/SqliteEventIdTest.cs @@ -40,18 +40,38 @@ public void Every_eventId_has_a_logger_method_and_logs_when_level_enabled() private class FakeSequence : ISequence { - public object this[string name] => throw new NotImplementedException(); - - public string Name => "SequenceName"; - public string Schema => throw new NotImplementedException(); - public long StartValue => throw new NotImplementedException(); - public int IncrementBy => throw new NotImplementedException(); - public long? MinValue => throw new NotImplementedException(); - public long? MaxValue => throw new NotImplementedException(); - public Type ClrType => throw new NotImplementedException(); - public Type Type => throw new NotImplementedException(); - public IModel Model => throw new NotImplementedException(); - public bool IsCyclic => throw new NotImplementedException(); + public object this[string name] + => throw new NotImplementedException(); + + public string Name + => "SequenceName"; + + public string Schema + => throw new NotImplementedException(); + + public long StartValue + => throw new NotImplementedException(); + + public int IncrementBy + => throw new NotImplementedException(); + + public long? MinValue + => throw new NotImplementedException(); + + public long? MaxValue + => throw new NotImplementedException(); + + public Type ClrType + => throw new NotImplementedException(); + + public Type Type + => throw new NotImplementedException(); + + public IModel Model + => throw new NotImplementedException(); + + public bool IsCyclic + => throw new NotImplementedException(); public IAnnotation FindAnnotation(string name) { diff --git a/test/EFCore.Sqlite.Tests/SqliteNTSApiConsistencyTest.cs b/test/EFCore.Sqlite.Tests/SqliteNTSApiConsistencyTest.cs index 7c0374c8bda..c2a50878203 100644 --- a/test/EFCore.Sqlite.Tests/SqliteNTSApiConsistencyTest.cs +++ b/test/EFCore.Sqlite.Tests/SqliteNTSApiConsistencyTest.cs @@ -31,7 +31,7 @@ public override bool TryGetProviderOptionsDelegate(out Action FluentApiTypes { get; } = new HashSet() + public override HashSet FluentApiTypes { get; } = new HashSet { typeof(SqliteNetTopologySuiteDbContextOptionsBuilderExtensions), typeof(SqliteNetTopologySuiteServiceCollectionExtensions) diff --git a/test/EFCore.Sqlite.Tests/Storage/SqliteRelationalConnectionTest.cs b/test/EFCore.Sqlite.Tests/Storage/SqliteRelationalConnectionTest.cs index 404597f2bea..d78cebe016b 100644 --- a/test/EFCore.Sqlite.Tests/Storage/SqliteRelationalConnectionTest.cs +++ b/test/EFCore.Sqlite.Tests/Storage/SqliteRelationalConnectionTest.cs @@ -26,10 +26,7 @@ public void Sets_DefaultTimeout_when_connectionString() [Fact] public void Sets_DefaultTimeout_when_connection() { - var originalConnection = new SqliteConnection("Data Source=:memory:") - { - DefaultTimeout = 21 - }; + var originalConnection = new SqliteConnection("Data Source=:memory:") { DefaultTimeout = 21 }; var services = SqliteTestHelpers.Instance.CreateContextServices( new DbContextOptionsBuilder() .UseSqlite(originalConnection, x => x.CommandTimeout(42)) diff --git a/test/EFCore.Sqlite.Tests/Update/SqliteUpdateSqlGeneratorTest.cs b/test/EFCore.Sqlite.Tests/Update/SqliteUpdateSqlGeneratorTest.cs index 1d7f05b5b22..33e786ad931 100644 --- a/test/EFCore.Sqlite.Tests/Update/SqliteUpdateSqlGeneratorTest.cs +++ b/test/EFCore.Sqlite.Tests/Update/SqliteUpdateSqlGeneratorTest.cs @@ -20,10 +20,14 @@ protected override IUpdateSqlGenerator CreateSqlGenerator() new RelationalSqlGenerationHelperDependencies()), TestServiceFactory.Instance.Create())); - protected override TestHelpers TestHelpers => SqliteTestHelpers.Instance; + protected override TestHelpers TestHelpers + => SqliteTestHelpers.Instance; - protected override string RowsAffected => "changes()"; - protected override string Schema => null; + protected override string RowsAffected + => "changes()"; + + protected override string Schema + => null; protected override string GetIdentityWhereCondition(string columnName) => OpenDelimiter + "rowid" + CloseDelimiter + " = last_insert_rowid()"; diff --git a/test/EFCore.Tests/ApiConsistencyTest.cs b/test/EFCore.Tests/ApiConsistencyTest.cs index 7fb489e5b6f..fc558042089 100644 --- a/test/EFCore.Tests/ApiConsistencyTest.cs +++ b/test/EFCore.Tests/ApiConsistencyTest.cs @@ -22,7 +22,8 @@ public ApiConsistencyTest(ApiConsistencyFixture fixture) { } - protected override Assembly TargetAssembly => typeof(EntityType).Assembly; + protected override Assembly TargetAssembly + => typeof(EntityType).Assembly; protected override void AddServices(ServiceCollection serviceCollection) => new EntityFrameworkServicesBuilder(serviceCollection).TryAddCoreServices(); @@ -82,18 +83,27 @@ public override bool TryGetProviderOptionsDelegate(out Action MetadataExtensionTypes { get; } + public override + List<(Type Type, Type ReadonlyExtensions, Type MutableExtensions, Type ConventionExtensions, Type + ConventionBuilderExtensions)> MetadataExtensionTypes { get; } = new List<(Type, Type, Type, Type, Type)> { - { (typeof(IModel), typeof(ModelExtensions), typeof(MutableModelExtensions), typeof(ConventionModelExtensions), null) }, - { (typeof(IAnnotatable), typeof(AnnotatableExtensions), typeof(MutableAnnotatableExtensions), typeof(ConventionAnnotatableExtensions), null) }, - { (typeof(IEntityType), typeof(EntityTypeExtensions), typeof(MutableEntityTypeExtensions), typeof(ConventionEntityTypeExtensions), null) }, - { (typeof(ITypeBase), typeof(TypeBaseExtensions), typeof(MutableTypeBaseExtensions), typeof(ConventionTypeBaseExtensions), null) }, - { (typeof(IKey),typeof(KeyExtensions), typeof(MutableKeyExtensions), typeof(ConventionKeyExtensions), null) }, - { (typeof(IForeignKey), typeof(ForeignKeyExtensions), typeof(MutableForeignKeyExtensions), typeof(ConventionForeignKeyExtensions), null) }, - { (typeof(IProperty), typeof(PropertyExtensions), typeof(MutablePropertyExtensions), typeof(ConventionPropertyExtensions), null) }, - { (typeof(INavigation), typeof(NavigationExtensions), typeof(MutableNavigationExtensions), typeof(ConventionNavigationExtensions), null) }, - { (typeof(IPropertyBase), typeof(PropertyBaseExtensions), typeof(MutablePropertyBaseExtensions), typeof(ConventionPropertyBaseExtensions), null) } + (typeof(IModel), typeof(ModelExtensions), typeof(MutableModelExtensions), typeof(ConventionModelExtensions), null), + (typeof(IAnnotatable), typeof(AnnotatableExtensions), typeof(MutableAnnotatableExtensions), + typeof(ConventionAnnotatableExtensions), null), + (typeof(IEntityType), typeof(EntityTypeExtensions), typeof(MutableEntityTypeExtensions), + typeof(ConventionEntityTypeExtensions), null), + (typeof(ITypeBase), typeof(TypeBaseExtensions), typeof(MutableTypeBaseExtensions), + typeof(ConventionTypeBaseExtensions), null), + (typeof(IKey), typeof(KeyExtensions), typeof(MutableKeyExtensions), typeof(ConventionKeyExtensions), null), + (typeof(IForeignKey), typeof(ForeignKeyExtensions), typeof(MutableForeignKeyExtensions), + typeof(ConventionForeignKeyExtensions), null), + (typeof(IProperty), typeof(PropertyExtensions), typeof(MutablePropertyExtensions), + typeof(ConventionPropertyExtensions), null), + (typeof(INavigation), typeof(NavigationExtensions), typeof(MutableNavigationExtensions), + typeof(ConventionNavigationExtensions), null), + (typeof(IPropertyBase), typeof(PropertyBaseExtensions), typeof(MutablePropertyBaseExtensions), + typeof(ConventionPropertyBaseExtensions), null) }; public override HashSet NonVirtualMethods { get; } = new HashSet @@ -113,13 +123,19 @@ public override bool TryGetProviderOptionsDelegate(out Action UnmatchedMetadataMethods { get; } = new HashSet { - typeof(OwnedNavigationBuilder<,>).GetMethod(nameof(OwnedNavigationBuilder.OwnsOne), 0, new []{ typeof(string), typeof(string) }), - typeof(OwnedNavigationBuilder<,>).GetMethod(nameof(OwnedNavigationBuilder.OwnsOne), 0, new []{ typeof(string), typeof(Type), typeof(string) }), - typeof(OwnedNavigationBuilder<,>).GetMethod(nameof(OwnedNavigationBuilder.OwnsOne), 0, new []{ typeof(Type), typeof(string) }), - typeof(OwnedNavigationBuilder<,>).GetMethod(nameof(OwnedNavigationBuilder.OwnsMany), 0, new []{ typeof(string), typeof(string) }), - typeof(OwnedNavigationBuilder<,>).GetMethod(nameof(OwnedNavigationBuilder.OwnsMany), 0, new []{ typeof(string), typeof(Type), typeof(string) }), - typeof(OwnedNavigationBuilder<,>).GetMethod(nameof(OwnedNavigationBuilder.OwnsMany), 0, new []{ typeof(Type), typeof(string) }), - typeof(IConventionPropertyBase).GetMethod(nameof(IConventionPropertyBase.SetField), new []{ typeof(string), typeof(bool) }), + typeof(OwnedNavigationBuilder<,>).GetMethod( + nameof(OwnedNavigationBuilder.OwnsOne), 0, new[] { typeof(string), typeof(string) }), + typeof(OwnedNavigationBuilder<,>).GetMethod( + nameof(OwnedNavigationBuilder.OwnsOne), 0, new[] { typeof(string), typeof(Type), typeof(string) }), + typeof(OwnedNavigationBuilder<,>).GetMethod( + nameof(OwnedNavigationBuilder.OwnsOne), 0, new[] { typeof(Type), typeof(string) }), + typeof(OwnedNavigationBuilder<,>).GetMethod( + nameof(OwnedNavigationBuilder.OwnsMany), 0, new[] { typeof(string), typeof(string) }), + typeof(OwnedNavigationBuilder<,>).GetMethod( + nameof(OwnedNavigationBuilder.OwnsMany), 0, new[] { typeof(string), typeof(Type), typeof(string) }), + typeof(OwnedNavigationBuilder<,>).GetMethod( + nameof(OwnedNavigationBuilder.OwnsMany), 0, new[] { typeof(Type), typeof(string) }), + typeof(IConventionPropertyBase).GetMethod(nameof(IConventionPropertyBase.SetField), new[] { typeof(string), typeof(bool) }), typeof(IAnnotatable).GetMethod(nameof(IAnnotatable.FindAnnotation)), typeof(IAnnotatable).GetMethod(nameof(IAnnotatable.GetAnnotations)), typeof(IMutableAnnotatable).GetMethod("set_Item"), @@ -139,20 +155,32 @@ public override bool TryGetProviderOptionsDelegate(out Action MetadataMethodExceptions { get; } = new HashSet diff --git a/test/EFCore.Tests/ApiConsistencyTestBase.cs b/test/EFCore.Tests/ApiConsistencyTestBase.cs index 6023f52a072..247db1a64bb 100644 --- a/test/EFCore.Tests/ApiConsistencyTestBase.cs +++ b/test/EFCore.Tests/ApiConsistencyTestBase.cs @@ -61,9 +61,9 @@ public void Generic_fluent_api_methods_should_return_generic_types() foreach (var type in GetAllTypes(Fixture.FluentApiTypes)) { if (!type.IsVisible - || !type.IsGenericType - || type.BaseType == typeof(object) - || type.BaseType.IsGenericType) + || !type.IsGenericType + || type.BaseType == typeof(object) + || type.BaseType.IsGenericType) { continue; } @@ -74,12 +74,12 @@ public void Generic_fluent_api_methods_should_return_generic_types() && !Fixture.UnmatchedMetadataMethods.Contains(method)) { var hidingMethod = type.GetMethod( - method.Name, - method.GetGenericArguments().Length, - PublicInstance | BindingFlags.DeclaredOnly, - null, - method.GetParameters().Select(p => p.ParameterType).ToArray(), - null); + method.Name, + method.GetGenericArguments().Length, + PublicInstance | BindingFlags.DeclaredOnly, + null, + method.GetParameters().Select(p => p.ParameterType).ToArray(), + null); if (hidingMethod == null || hidingMethod == method || hidingMethod.ReturnType != type) { nonGenericMethods.Add((type, method)); @@ -130,16 +130,19 @@ public void Generic_fluent_api_methods_should_return_generic_types() Assert.False( nonGenericMethods.Count > 0, - "\r\n-- Non-generic fluent returns --\r\n" + string.Join(Environment.NewLine, nonGenericMethods.Select(m => - $"{m.Method.ReturnType.ShortDisplayName()} {m.Type.Name}.{m.Method.Name}({Format(m.Method.GetParameters())})"))); + "\r\n-- Non-generic fluent returns --\r\n" + + string.Join( + Environment.NewLine, nonGenericMethods.Select( + m => + $"{m.Method.ReturnType.ShortDisplayName()} {m.Type.Name}.{m.Method.Name}({Format(m.Method.GetParameters())})"))); } [ConditionalFact] public void Metadata_types_have_expected_structure() { var errors = Fixture.MetadataTypes.Select(ValidateMetadata) - .Where(e => e != null) - .ToList(); + .Where(e => e != null) + .ToList(); Assert.False( errors.Count > 0, @@ -260,8 +263,8 @@ private string MatchMutable((MethodInfo Readonly, MethodInfo Mutable) methodTupl { if (mutableMethod == null) { - return $"No IMutable equivalent of " + - $"{readonlyMethod.DeclaringType.Name}.{readonlyMethod.Name}({Format(readonlyMethod.GetParameters())})"; + return "No IMutable equivalent of " + + $"{readonlyMethod.DeclaringType.Name}.{readonlyMethod.Name}({Format(readonlyMethod.GetParameters())})"; } if (mutableMethod.ReturnType != expectedReturnTypes.Mutable) @@ -278,8 +281,8 @@ private string MatchMutable((MethodInfo Readonly, MethodInfo Mutable) methodTupl { if (mutableMethod == null) { - return $"No IMutable equivalent of " + - $"{readonlyMethod.DeclaringType.Name}.{readonlyMethod.Name}({Format(readonlyMethod.GetParameters())})"; + return "No IMutable equivalent of " + + $"{readonlyMethod.DeclaringType.Name}.{readonlyMethod.Name}({Format(readonlyMethod.GetParameters())})"; } if (mutableMethod.ReturnType.TryGetSequenceType() != expectedReturnTypes.Mutable) @@ -298,13 +301,13 @@ public void Convention_metadata_types_have_matching_methods() { var errors = Fixture.MetadataMethods.Select( - typeTuple => - from mutableMethod in typeTuple.Mutable - where !Fixture.UnmatchedMetadataMethods.Contains(mutableMethod) - join conventionMethod in typeTuple.Convention - on GetConventionName(mutableMethod) equals conventionMethod.Name into conventionGroup - from conventionMethod in conventionGroup.DefaultIfEmpty() - select (mutableMethod, conventionMethod)) + typeTuple => + from mutableMethod in typeTuple.Mutable + where !Fixture.UnmatchedMetadataMethods.Contains(mutableMethod) + join conventionMethod in typeTuple.Convention + on GetConventionName(mutableMethod) equals conventionMethod.Name into conventionGroup + from conventionMethod in conventionGroup.DefaultIfEmpty() + select (mutableMethod, conventionMethod)) .SelectMany(m => m.Select(MatchConvention)) .Where(e => e != null) .ToList(); @@ -316,10 +319,11 @@ from conventionMethod in conventionGroup.DefaultIfEmpty() static string GetConventionName(MethodInfo mutableMethod) { var name = mutableMethod.Name; - if(mutableMethod.Name.StartsWith("set_", StringComparison.Ordinal)) + if (mutableMethod.Name.StartsWith("set_", StringComparison.Ordinal)) { name = "Set" + name[4..]; } + return name; } } @@ -333,22 +337,22 @@ private string MatchConvention((MethodInfo Mutable, MethodInfo Convention) metho { if (conventionMethod == null) { - return $"No IConvention equivalent of " + - $"{mutableMethod.DeclaringType.Name}.{mutableMethod.Name}({Format(mutableMethod.GetParameters())})"; + return "No IConvention equivalent of " + + $"{mutableMethod.DeclaringType.Name}.{mutableMethod.Name}({Format(mutableMethod.GetParameters())})"; } } else if (Fixture.MutableMetadataTypes.TryGetValue(mutableMethod.ReturnType, out expectedReturnType)) { if (conventionMethod == null) { - return $"No IConvention equivalent of " + - $"{mutableMethod.DeclaringType.Name}.{mutableMethod.Name}({Format(mutableMethod.GetParameters())})"; + return "No IConvention equivalent of " + + $"{mutableMethod.DeclaringType.Name}.{mutableMethod.Name}({Format(mutableMethod.GetParameters())})"; } if (conventionMethod.ReturnType != expectedReturnType) { - return $"{conventionMethod.DeclaringType.Name}.{conventionMethod.Name}({Format(conventionMethod.GetParameters())})" + - $" expected to have {expectedReturnType.ShortDisplayName()} return type"; + return $"{conventionMethod.DeclaringType.Name}.{conventionMethod.Name}({Format(conventionMethod.GetParameters())})" + + $" expected to have {expectedReturnType.ShortDisplayName()} return type"; } } else @@ -359,14 +363,14 @@ private string MatchConvention((MethodInfo Mutable, MethodInfo Convention) metho { if (conventionMethod == null) { - return $"No IConvention equivalent of " + - $"{mutableMethod.DeclaringType.Name}.{mutableMethod.Name}({Format(mutableMethod.GetParameters())})"; + return "No IConvention equivalent of " + + $"{mutableMethod.DeclaringType.Name}.{mutableMethod.Name}({Format(mutableMethod.GetParameters())})"; } if (conventionMethod.ReturnType.TryGetSequenceType() != expectedReturnType) { - return $"{conventionMethod.DeclaringType.Name}.{conventionMethod.Name}({Format(conventionMethod.GetParameters())})" + - $" expected to have a return type that derives from IEnumerable<{expectedReturnType.Name}>."; + return $"{conventionMethod.DeclaringType.Name}.{conventionMethod.Name}({Format(conventionMethod.GetParameters())})" + + $" expected to have a return type that derives from IEnumerable<{expectedReturnType.Name}>."; } } } @@ -404,7 +408,7 @@ private string ValidateConventionMethods(IReadOnlyList methods) foreach (var methodTuple in methodLookup) { if (!Fixture.UnmatchedMetadataMethods.Contains(methodTuple.Value) - && methodTuple.Key.StartsWith("Set", StringComparison.Ordinal)) + && methodTuple.Key.StartsWith("Set", StringComparison.Ordinal)) { var expectedName = "Get" + methodTuple.Key[3..] + "ConfigurationSource"; if (!methodLookup.TryGetValue(expectedName, out var getAspectConfigurationSource)) @@ -414,8 +418,8 @@ private string ValidateConventionMethods(IReadOnlyList methods) if (getAspectConfigurationSource.ReturnType != typeof(ConfigurationSource?)) { - return $"{type.Name}.{getAspectConfigurationSource.Name}({Format(getAspectConfigurationSource.GetParameters())})" + - $" expected to have ConfigurationSource? return type"; + return $"{type.Name}.{getAspectConfigurationSource.Name}({Format(getAspectConfigurationSource.GetParameters())})" + + " expected to have ConfigurationSource? return type"; } } } @@ -428,8 +432,8 @@ public void Convention_builder_types_have_expected_methods() { var errors = Fixture.MetadataMethods.Select(t => ValidateConventionBuilderMethods(t.ConventionBuilder)) - .Where(e => e != null) - .ToList(); + .Where(e => e != null) + .ToList(); Assert.False( errors.Count > 0, @@ -463,12 +467,12 @@ private string ValidateConventionBuilderMethods(IReadOnlyList method var expectedName = method.Name.StartsWith("HasNo", StringComparison.Ordinal) ? "CanRemove" + method.Name[5..] : "CanSet" - + (method.Name.StartsWith("Has", StringComparison.Ordinal) - || method.Name.StartsWith("Use", StringComparison.Ordinal) - ? method.Name[3..] - : method.Name.StartsWith("To", StringComparison.Ordinal) - ? method.Name[2..] - : method.Name); + + (method.Name.StartsWith("Has", StringComparison.Ordinal) + || method.Name.StartsWith("Use", StringComparison.Ordinal) + ? method.Name[3..] + : method.Name.StartsWith("To", StringComparison.Ordinal) + ? method.Name[2..] + : method.Name); if (!methodLookup.TryGetValue(expectedName, out var canSetMethod)) { return $"{declaringType.Name} expected to have a {expectedName} method"; @@ -479,8 +483,8 @@ private string ValidateConventionBuilderMethods(IReadOnlyList method if (parameters.Length > parameterIndex && parameters[parameterIndex].ParameterType != canSetMethod.GetParameters()[parameterIndex].ParameterType) { - return $"{declaringType.Name}.{canSetMethod.Name}({Format(canSetMethod.GetParameters())})" + - $" expected to have the first parameter of type {parameters[parameterIndex].ParameterType.ShortDisplayName()}"; + return $"{declaringType.Name}.{canSetMethod.Name}({Format(canSetMethod.GetParameters())})" + + $" expected to have the first parameter of type {parameters[parameterIndex].ParameterType.ShortDisplayName()}"; } } @@ -492,9 +496,9 @@ public void Readonly_metadata_methods_have_expected_name() { var errors = Fixture.MetadataMethods - .SelectMany(m => m.ReadOnly.Select(ValidateMethodName)) - .Where(e => e != null) - .ToList(); + .SelectMany(m => m.ReadOnly.Select(ValidateMethodName)) + .Where(e => e != null) + .ToList(); Assert.False( errors.Count > 0, @@ -510,8 +514,8 @@ protected string ValidateMethodName(MethodInfo method) if (name.StartsWith("Get", StringComparison.Ordinal) && !Fixture.MetadataMethodExceptions.Contains(method)) { - return $"{method.DeclaringType.ShortDisplayName()}.{name}({Format(method.GetParameters())}) expected to not have " + - $"Get prefix"; + return $"{method.DeclaringType.ShortDisplayName()}.{name}({Format(method.GetParameters())}) expected to not have " + + "Get prefix"; } } @@ -563,8 +567,8 @@ private string ValidateMutableMethod(MethodInfo mutableMethod) } else { - return $"{mutableMethod.DeclaringType.Name}.{name}({Format(parameters)}) expected to have an IMutable or " + - $"{firstParameter.ParameterType.ShortDisplayName()} return type"; + return $"{mutableMethod.DeclaringType.Name}.{name}({Format(parameters)}) expected to have an IMutable or " + + $"{firstParameter.ParameterType.ShortDisplayName()} return type"; } } @@ -576,9 +580,9 @@ public void Convention_metadata_methods_have_expected_shape() { var errors = Fixture.MetadataMethods - .SelectMany(m => m.Convention.Select(ValidateConventionMethod)) - .Where(e => e != null) - .ToList(); + .SelectMany(m => m.Convention.Select(ValidateConventionMethod)) + .Where(e => e != null) + .ToList(); Assert.False( errors.Count > 0, @@ -610,8 +614,9 @@ private string ValidateConventionMethod(MethodInfo conventionMethod) && !typeof(ITuple).IsAssignableFrom(conventionMethod.ReturnType))) && !Fixture.ConventionMetadataTypes.ContainsKey(conventionMethod.ReturnType)) { - return $"{conventionMethod.DeclaringType.ShortDisplayName()}.{name}({Format(parameters)}) expected to have an IConvention or " + - $"{firstParameter.ParameterType.ShortDisplayName()} return type"; + return + $"{conventionMethod.DeclaringType.ShortDisplayName()}.{name}({Format(parameters)}) expected to have an IConvention or " + + $"{firstParameter.ParameterType.ShortDisplayName()} return type"; } if (parameters.Length > parameterIndex @@ -626,7 +631,8 @@ private string ValidateConventionMethod(MethodInfo conventionMethod) if (lastParameter.Name != "fromDataAnnotation" || !Equals(lastParameter.DefaultValue, false)) { - return $"{conventionMethod.DeclaringType.ShortDisplayName()}.{name}({Format(parameters)}) expected to have a 'bool fromDataAnnotation = false' parameter"; + return + $"{conventionMethod.DeclaringType.ShortDisplayName()}.{name}({Format(parameters)}) expected to have a 'bool fromDataAnnotation = false' parameter"; } } @@ -643,7 +649,7 @@ public virtual void Ensure_dependency_objects_are_consistent() var dependencyServices = serviceCollection.Where( sd => sd.ServiceType.Namespace.StartsWith("Microsoft.Entity", StringComparison.Ordinal) && sd.ServiceType.Name.EndsWith("Dependencies", StringComparison.Ordinal) - && sd.ImplementationType == sd.ServiceType) + && sd.ImplementationType == sd.ServiceType) .ToList(); foreach (var service in dependencyServices) @@ -892,7 +898,9 @@ from parameter in method.GetParameters() } private static readonly HashSet _nonCancellableAsyncMethods = new HashSet(); - protected virtual HashSet NonCancellableAsyncMethods => _nonCancellableAsyncMethods; + + protected virtual HashSet NonCancellableAsyncMethods + => _nonCancellableAsyncMethods; [ConditionalFact] public virtual void Async_methods_should_have_overload_with_cancellation_token_and_end_with_async_suffix() @@ -920,8 +928,9 @@ var asyncMethodsWithoutToken var missingOverloads = (from methodWithoutToken in asyncMethodsWithoutToken where !asyncMethodsWithToken - .Any(methodWithToken => methodWithoutToken.Name == methodWithToken.Name - && methodWithoutToken.DeclaringType == methodWithToken.DeclaringType) + .Any( + methodWithToken => methodWithoutToken.Name == methodWithToken.Name + && methodWithoutToken.DeclaringType == methodWithToken.DeclaringType) && !Fixture.AsyncMethodExceptions.Contains(methodWithoutToken) // ReSharper disable once PossibleNullReferenceException select methodWithoutToken.DeclaringType.Name + "." + methodWithoutToken.Name) @@ -933,8 +942,10 @@ var missingOverloads var missingSuffixMethods = asyncMethods - .Where(method => !method.Name.EndsWith("Async", StringComparison.Ordinal) && method.DeclaringType != null - && !Fixture.AsyncMethodExceptions.Contains(method)) + .Where( + method => !method.Name.EndsWith("Async", StringComparison.Ordinal) + && method.DeclaringType != null + && !Fixture.AsyncMethodExceptions.Contains(method)) .Select(method => method.DeclaringType.Name + "." + method.Name) .ToList(); @@ -989,7 +1000,7 @@ protected ApiConsistencyFixtureBase() Initialize(); } - public abstract bool TryGetProviderOptionsDelegate (out Action configureOptions); + public abstract bool TryGetProviderOptionsDelegate(out Action configureOptions); public virtual HashSet FluentApiTypes { get; } = new HashSet(); @@ -1022,31 +1033,50 @@ protected ApiConsistencyFixtureBase() public virtual HashSet ComputedDependencyProperties { get; } = new HashSet { - typeof(ProviderConventionSetBuilderDependencies).GetProperty(nameof(ProviderConventionSetBuilderDependencies.ContextType)), + typeof(ProviderConventionSetBuilderDependencies).GetProperty( + nameof(ProviderConventionSetBuilderDependencies.ContextType)), typeof(QueryCompilationContextDependencies).GetProperty(nameof(QueryCompilationContextDependencies.ContextType)), - typeof(QueryCompilationContextDependencies).GetProperty(nameof(QueryCompilationContextDependencies.QueryTrackingBehavior)), + typeof(QueryCompilationContextDependencies).GetProperty( + nameof(QueryCompilationContextDependencies.QueryTrackingBehavior)), typeof(QueryContextDependencies).GetProperty(nameof(QueryContextDependencies.StateManager)), #pragma warning disable CS0618 // Type or member is obsolete typeof(QueryContextDependencies).GetProperty(nameof(QueryContextDependencies.QueryProvider)) #pragma warning restore CS0618 // Type or member is obsolete }; - public Dictionary MetadataTypes { get; } = new Dictionary { { typeof(IModel), (typeof(IMutableModel), typeof(IConventionModel), typeof(IConventionModelBuilder)) }, - { typeof(IAnnotatable), (typeof(IMutableAnnotatable), typeof(IConventionAnnotatable), typeof(IConventionAnnotatableBuilder)) }, + { + typeof(IAnnotatable), + (typeof(IMutableAnnotatable), typeof(IConventionAnnotatable), typeof(IConventionAnnotatableBuilder)) + }, { typeof(IAnnotation), (typeof(IAnnotation), typeof(IConventionAnnotation), null) }, - { typeof(IEntityType), (typeof(IMutableEntityType), typeof(IConventionEntityType), typeof(IConventionEntityTypeBuilder)) }, + { + typeof(IEntityType), + (typeof(IMutableEntityType), typeof(IConventionEntityType), typeof(IConventionEntityTypeBuilder)) + }, { typeof(ITypeBase), (typeof(IMutableTypeBase), typeof(IConventionTypeBase), null) }, { typeof(IKey), (typeof(IMutableKey), typeof(IConventionKey), typeof(IConventionKeyBuilder)) }, - { typeof(IForeignKey), (typeof(IMutableForeignKey), typeof(IConventionForeignKey), typeof(IConventionForeignKeyBuilder)) }, + { + typeof(IForeignKey), + (typeof(IMutableForeignKey), typeof(IConventionForeignKey), typeof(IConventionForeignKeyBuilder)) + }, { typeof(IIndex), (typeof(IMutableIndex), typeof(IConventionIndex), typeof(IConventionIndexBuilder)) }, { typeof(IProperty), (typeof(IMutableProperty), typeof(IConventionProperty), typeof(IConventionPropertyBuilder)) }, - { typeof(INavigation), (typeof(IMutableNavigation), typeof(IConventionNavigation), typeof(IConventionNavigationBuilder)) }, - { typeof(ISkipNavigation), (typeof(IMutableSkipNavigation), typeof(IConventionSkipNavigation), typeof(IConventionSkipNavigationBuilder)) }, - { typeof(IServiceProperty), (typeof(IMutableServiceProperty), typeof(IConventionServiceProperty), typeof(IConventionServicePropertyBuilder)) }, + { + typeof(INavigation), + (typeof(IMutableNavigation), typeof(IConventionNavigation), typeof(IConventionNavigationBuilder)) + }, + { + typeof(ISkipNavigation), + (typeof(IMutableSkipNavigation), typeof(IConventionSkipNavigation), typeof(IConventionSkipNavigationBuilder)) + }, + { + typeof(IServiceProperty), + (typeof(IMutableServiceProperty), typeof(IConventionServiceProperty), typeof(IConventionServicePropertyBuilder)) + }, { typeof(INavigationBase), (typeof(IMutableNavigationBase), typeof(IConventionNavigationBase), null) }, { typeof(IPropertyBase), (typeof(IMutablePropertyBase), typeof(IConventionPropertyBase), null) } }; @@ -1054,10 +1084,13 @@ protected ApiConsistencyFixtureBase() public Dictionary MutableMetadataTypes { get; } = new Dictionary(); public Dictionary ConventionMetadataTypes { get; } = new Dictionary(); - public virtual List<(Type Type, Type ReadonlyExtensions, Type MutableExtensions, Type ConventionExtensions, Type ConventionBuilderExtensions)> MetadataExtensionTypes { get; } + public virtual + List<(Type Type, Type ReadonlyExtensions, Type MutableExtensions, Type ConventionExtensions, Type + ConventionBuilderExtensions)> MetadataExtensionTypes { get; } = new List<(Type, Type, Type, Type, Type)>(); - public List<(IReadOnlyList ReadOnly, IReadOnlyList Mutable, IReadOnlyList Convention, IReadOnlyList ConventionBuilder)> + public List<(IReadOnlyList ReadOnly, IReadOnlyList Mutable, IReadOnlyList Convention, + IReadOnlyList ConventionBuilder)> MetadataMethods { get; } = new List<(IReadOnlyList, IReadOnlyList, IReadOnlyList, IReadOnlyList)>(); @@ -1079,7 +1112,8 @@ protected virtual void Initialize() .Where(m => !IsObsolete(m) && m.GetParameters().First().ParameterType == mutableType).ToArray(); var conventionMethods = extensionTypeTuple.ConventionExtensions.GetMethods(BindingFlags.Public | BindingFlags.Static) .Where(m => !IsObsolete(m) && m.GetParameters().First().ParameterType == conventionType).ToArray(); - var conventionBuilderMethods = extensionTypeTuple.ConventionBuilderExtensions?.GetMethods(BindingFlags.Public | BindingFlags.Static) + var conventionBuilderMethods = extensionTypeTuple.ConventionBuilderExtensions + ?.GetMethods(BindingFlags.Public | BindingFlags.Static) .Where(m => !IsObsolete(m) && m.GetParameters().First().ParameterType == conventionBuilderType).ToArray(); MetadataMethods.Add((readOnlyMethods, mutableMethods, conventionMethods, conventionBuilderMethods)); } diff --git a/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs b/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs index 2ac3fd52c0c..407ac3fd661 100644 --- a/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs +++ b/test/EFCore.Tests/ChangeTracking/ChangeTrackerTest.cs @@ -470,7 +470,8 @@ private class ResettableValueGenerator : ValueGenerator private int _current; private bool _generatesTemporaryValues; - public override bool GeneratesTemporaryValues => _generatesTemporaryValues; + public override bool GeneratesTemporaryValues + => _generatesTemporaryValues; public override int Next(EntityEntry entry) => Interlocked.Increment(ref _current); @@ -1164,7 +1165,8 @@ private static void RegisterEvents( private class Cat { - public Cat(int id) => Id = id; + public Cat(int id) + => Id = id; // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Local public int Id { get; private set; } @@ -1178,7 +1180,8 @@ private class Cat private class Hat { - public Hat(int id) => Id = id; + public Hat(int id) + => Id = id; // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Local public int Id { get; private set; } @@ -1191,7 +1194,8 @@ private class Hat private class Mat { - public Mat(int id) => Id = id; + public Mat(int id) + => Id = id; // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Local public int Id { get; private set; } @@ -1263,16 +1267,17 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) .Property(e => e.Id) .HasValueGenerator>(); - modelBuilder.Entity(b => - { - b.Property(e => e.Id).HasValueGenerator>(); - b.HasMany(e => e.Cats) - .WithMany(e => e.Mats) - .UsingEntity( - ts => ts.HasOne().WithMany(), - ts => ts.HasOne().WithMany()) - .HasKey(ts => new { ts.CatId, ts.MatId }); - }); + modelBuilder.Entity( + b => + { + b.Property(e => e.Id).HasValueGenerator>(); + b.HasMany(e => e.Cats) + .WithMany(e => e.Mats) + .UsingEntity( + ts => ts.HasOne().WithMany(), + ts => ts.HasOne().WithMany()) + .HasKey(ts => new { ts.CatId, ts.MatId }); + }); } } diff --git a/test/EFCore.Tests/ChangeTracking/CollectionEntryTest.cs b/test/EFCore.Tests/ChangeTracking/CollectionEntryTest.cs index f0be0230201..1ad70f33a57 100644 --- a/test/EFCore.Tests/ChangeTracking/CollectionEntryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/CollectionEntryTest.cs @@ -334,7 +334,8 @@ public void IsModified_tracks_state_of_FK_property_principal() [InlineData(EntityState.Deleted, EntityState.Deleted)] [InlineData(EntityState.Unchanged, EntityState.Deleted)] public void IsModified_can_set_fk_to_modified_principal_with_Added_or_Deleted_dependents( - EntityState principalState, EntityState dependentState) + EntityState principalState, + EntityState dependentState) { using var context = new FreezerContext(); var cherry = new Cherry(); @@ -388,7 +389,8 @@ public void IsModified_can_set_fk_to_modified_principal_with_Added_or_Deleted_de [InlineData(EntityState.Deleted, EntityState.Unchanged)] [InlineData(EntityState.Unchanged, EntityState.Unchanged)] public void IsModified_can_set_fk_to_modified_principal_with_Unchanged_dependents( - EntityState principalState, EntityState dependentState) + EntityState principalState, + EntityState dependentState) { using var context = new FreezerContext(); var cherry = new Cherry(); @@ -426,7 +428,8 @@ public void IsModified_can_set_fk_to_modified_principal_with_Unchanged_dependent [InlineData(EntityState.Deleted, EntityState.Modified)] [InlineData(EntityState.Unchanged, EntityState.Modified)] public void IsModified_can_set_fk_to_modified_principal_with_Modified_dependents( - EntityState principalState, EntityState dependentState) + EntityState principalState, + EntityState dependentState) { using var context = new FreezerContext(); var cherry = new Cherry { Id = 1 }; diff --git a/test/EFCore.Tests/ChangeTracking/InstanceFactoryTest.cs b/test/EFCore.Tests/ChangeTracking/InstanceFactoryTest.cs index dab22bbad70..4409b67be37 100644 --- a/test/EFCore.Tests/ChangeTracking/InstanceFactoryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/InstanceFactoryTest.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Query.Internal; using Microsoft.EntityFrameworkCore.Storage; using Xunit; @@ -173,7 +172,9 @@ private Parameterless() private class WithProperties { - public WithProperties(int id) => Id = id; + public WithProperties(int id) + => Id = id; + public int Id { get; set; } } @@ -183,43 +184,56 @@ public ParameterlessAndWithProperties() { } - public ParameterlessAndWithProperties(int id) => Id = id; + public ParameterlessAndWithProperties(int id) + => Id = id; public int Id { get; set; } } private class WithLazyLoader { - public WithLazyLoader(ILazyLoader lazyLoader) => LazyLoader = lazyLoader; + public WithLazyLoader(ILazyLoader lazyLoader) + => LazyLoader = lazyLoader; + public int Id { get; set; } public ILazyLoader LazyLoader { get; } } private class WithLazyLoaderDelegate { - public WithLazyLoaderDelegate(Action lazyLoader) => LazyLoader = lazyLoader; + public WithLazyLoaderDelegate(Action lazyLoader) + => LazyLoader = lazyLoader; + public int Id { get; set; } public Action LazyLoader { get; } } private class WithEntityType { - public WithEntityType(IEntityType entityType) => EntityType = entityType; + public WithEntityType(IEntityType entityType) + => EntityType = entityType; + public int Id { get; set; } public IEntityType EntityType { get; } } private class WithContext { - public WithContext(DbContext context) => Context = context; + public WithContext(DbContext context) + => Context = context; + public int Id { get; set; } public DbContext Context { get; } } private class WithServiceAndWithProperties { - public WithServiceAndWithProperties(ILazyLoader lazyLoader) => LazyLoader = lazyLoader; - public WithServiceAndWithProperties(ILazyLoader lazyLoader, int id) : this(lazyLoader) => Id = id; + public WithServiceAndWithProperties(ILazyLoader lazyLoader) + => LazyLoader = lazyLoader; + + public WithServiceAndWithProperties(ILazyLoader lazyLoader, int id) + : this(lazyLoader) + => Id = id; public ILazyLoader LazyLoader { get; } public int Id { get; set; } diff --git a/test/EFCore.Tests/ChangeTracking/Internal/ChangeDetectorTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/ChangeDetectorTest.cs index 5ca7dcbec54..37c7e332a0b 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/ChangeDetectorTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/ChangeDetectorTest.cs @@ -302,7 +302,8 @@ private class Baxter private class BaxterWithMappingContext : BaxterContext { - protected override bool UseTypeMapping => true; + protected override bool UseTypeMapping + => true; } private class ConcreteTypeMapping : CoreTypeMapping @@ -323,7 +324,8 @@ public override CoreTypeMapping Clone(ValueConverter converter) private class BaxterContext : DbContext { - protected virtual bool UseTypeMapping => false; + protected virtual bool UseTypeMapping + => false; protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder @@ -2124,7 +2126,10 @@ public Tuple, IEnumerable, IEnumerable> CollectionChange { get; set; } public override void NavigationReferenceChanged( - InternalEntityEntry entry, INavigationBase navigationBase, object oldValue, object newValue) + InternalEntityEntry entry, + INavigationBase navigationBase, + object oldValue, + object newValue) { ReferenceChange = Tuple.Create(entry, navigationBase, oldValue, newValue); @@ -2132,7 +2137,10 @@ public override void NavigationReferenceChanged( } public override void NavigationCollectionChanged( - InternalEntityEntry entry, INavigationBase navigation, IEnumerable added, IEnumerable removed) + InternalEntityEntry entry, + INavigationBase navigation, + IEnumerable added, + IEnumerable removed) { // ReSharper disable PossibleMultipleEnumeration CollectionChange = Tuple.Create(entry, navigation, added, removed); diff --git a/test/EFCore.Tests/ChangeTracking/Internal/CurrentValueComparerTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/CurrentValueComparerTest.cs index 474f3722095..74102aac845 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/CurrentValueComparerTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/CurrentValueComparerTest.cs @@ -29,7 +29,8 @@ public class CurrentValueComparerTest [InlineData(typeof(EntryCurrentValueComparer), nameof(Godzilla.NullableComparableIntStruct))] [InlineData(typeof(EntryCurrentValueComparer), nameof(Godzilla.NullableComparableBytesStruct))] [InlineData(typeof(EntryCurrentValueComparer), nameof(Godzilla.NullableGenericComparableIntStruct))] - [InlineData(typeof(EntryCurrentValueComparer), nameof(Godzilla.NullableGenericComparableBytesStruct))] + [InlineData( + typeof(EntryCurrentValueComparer), nameof(Godzilla.NullableGenericComparableBytesStruct))] [InlineData(typeof(StructuralEntryCurrentValueComparer), nameof(Godzilla.NullableStructuralComparableBytesStruct))] [InlineData(typeof(EntryCurrentValueComparer), nameof(Godzilla.NullableInt))] [InlineData(typeof(EntryCurrentValueComparer), nameof(Godzilla.NullableULong))] @@ -207,14 +208,21 @@ public void Can_sort_NullableIntStructs() public void Can_sort_NullableComparableIntStructs() => CanSortNullable( nameof(Godzilla.NullableComparableIntStruct), - i => new Godzilla { NullableComparableIntStruct = i.HasValue ? new ComparableIntStruct { Value = i.Value } : (ComparableIntStruct?)null }, + i => new Godzilla + { + NullableComparableIntStruct = i.HasValue ? new ComparableIntStruct { Value = i.Value } : (ComparableIntStruct?)null + }, g => g.NullableComparableIntStruct?.Value); [ConditionalFact] public void Can_sort_NullableGenericComparableIntStructs() => CanSortNullable( nameof(Godzilla.NullableGenericComparableIntStruct), - i => new Godzilla { NullableGenericComparableIntStruct = i.HasValue ? new GenericComparableIntStruct { Value = i.Value } : (GenericComparableIntStruct?)null }, + i => new Godzilla + { + NullableGenericComparableIntStruct = + i.HasValue ? new GenericComparableIntStruct { Value = i.Value } : (GenericComparableIntStruct?)null + }, g => g.NullableGenericComparableIntStruct?.Value); [ConditionalFact] @@ -295,21 +303,33 @@ public void Can_sort_NullableBytesStructs() public void Can_sort_NullableComparableBytesStructs() => CanSortNullable( nameof(Godzilla.NullableComparableBytesStruct), - i => new Godzilla { NullableComparableBytesStruct = i == null ? (ComparableBytesStruct?)null : new ComparableBytesStruct { Value = i } }, + i => new Godzilla + { + NullableComparableBytesStruct = i == null ? (ComparableBytesStruct?)null : new ComparableBytesStruct { Value = i } + }, g => g.NullableComparableBytesStruct?.Value); [ConditionalFact] public void Can_sort_NullableGenericComparableBytesStructs() => CanSortNullable( nameof(Godzilla.NullableGenericComparableBytesStruct), - i => new Godzilla { NullableGenericComparableBytesStruct = i == null ? (GenericComparableBytesStruct?)null : new GenericComparableBytesStruct { Value = i } }, + i => new Godzilla + { + NullableGenericComparableBytesStruct = + i == null ? (GenericComparableBytesStruct?)null : new GenericComparableBytesStruct { Value = i } + }, g => g.NullableGenericComparableBytesStruct?.Value); [ConditionalFact] public void Can_sort_NullableStructuralComparableBytesStructs() => CanSortNullable( nameof(Godzilla.NullableStructuralComparableBytesStruct), - i => new Godzilla { NullableStructuralComparableBytesStruct = i == null ? (StructuralComparableBytesStruct?)null : new StructuralComparableBytesStruct { Value = i } }, + i => new Godzilla + { + NullableStructuralComparableBytesStruct = i == null + ? (StructuralComparableBytesStruct?)null + : new StructuralComparableBytesStruct { Value = i } + }, g => g.NullableStructuralComparableBytesStruct?.Value); [ConditionalFact] @@ -623,7 +643,8 @@ public override bool Equals(object obj) || obj?.GetType() == GetType() && Equals((IntClass)obj); - public override int GetHashCode() => Value; + public override int GetHashCode() + => Value; public int Value { get; set; } } @@ -643,7 +664,8 @@ public override bool Equals(object obj) || obj?.GetType() == GetType() && Equals((ComparableIntClass)obj); - public override int GetHashCode() => Value; + public override int GetHashCode() + => Value; public int CompareTo(object other) => Value - ((ComparableIntClass)other).Value; @@ -664,7 +686,8 @@ public override bool Equals(object obj) || obj?.GetType() == GetType() && Equals((GenericComparableIntClass)obj); - public override int GetHashCode() => Value; + public override int GetHashCode() + => Value; public int CompareTo(GenericComparableIntClass other) => Value - other.Value; diff --git a/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs index 6a587bc523b..9af32ebc64e 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/FixupTest.cs @@ -159,7 +159,11 @@ public void Add_principal_then_dependent_one_to_many_FK_not_set_dependent_nav_se } private void Add_principal_and_dependent_one_to_many( - EntityState entityState, bool principalFirst, bool setFk, bool setToPrincipal, bool setToDependent) + EntityState entityState, + bool principalFirst, + bool setFk, + bool setToPrincipal, + bool setToDependent) { using var context = new FixupContext(); var principal = new Category(77); @@ -257,7 +261,10 @@ public void Add_principal_then_dependent_one_to_many_prin_uni_FK_not_set_princip } private void Add_principal_and_dependent_one_to_many_prin_uni( - EntityState entityState, bool principalFirst, bool setFk, bool setToDependent) + EntityState entityState, + bool principalFirst, + bool setFk, + bool setToDependent) { using var context = new FixupContext(); var principal = new CategoryPN { Id = 77 }; @@ -349,7 +356,10 @@ public void Add_principal_then_dependent_one_to_many_dep_uni_FK_not_set_dependen } private void Add_principal_and_dependent_one_to_many_dep_uni( - EntityState entityState, bool principalFirst, bool setFk, bool setToPrincipal) + EntityState entityState, + bool principalFirst, + bool setFk, + bool setToPrincipal) { using var context = new FixupContext(); var principal = new CategoryDN { Id = 77 }; @@ -573,7 +583,11 @@ public void Add_principal_then_dependent_one_to_one_FK_not_set_dependent_nav_set } private void Add_principal_and_dependent_one_to_one( - EntityState entityState, bool principalFirst, bool setFk, bool setToPrincipal, bool setToDependent) + EntityState entityState, + bool principalFirst, + bool setFk, + bool setToPrincipal, + bool setToDependent) { using var context = new FixupContext(); var principal = new Parent(77); @@ -671,7 +685,10 @@ public void Add_principal_then_dependent_one_to_one_prin_uni_FK_not_set_principa } private void Add_principal_and_dependent_one_to_one_prin_uni( - EntityState entityState, bool principalFirst, bool setFk, bool setToDependent) + EntityState entityState, + bool principalFirst, + bool setFk, + bool setToDependent) { using var context = new FixupContext(); var principal = new ParentPN { Id = 77 }; @@ -771,7 +788,10 @@ public void Add_principal_then_dependent_one_to_one_dep_uni_FK_not_set_dependent } private void Add_principal_and_dependent_one_to_one_dep_uni( - EntityState entityState, bool principalFirst, bool setFk, bool setToPrincipal) + EntityState entityState, + bool principalFirst, + bool setFk, + bool setToPrincipal) { using var context = new FixupContext(); var principal = new ParentDN { Id = 77 }; @@ -920,7 +940,10 @@ public void Add_dependent_but_not_principal_one_to_many_FK_not_set_dependent_nav } private void Add_dependent_but_not_principal_one_to_many( - EntityState entityState, bool setFk, bool setToPrincipal, bool setToDependent) + EntityState entityState, + bool setFk, + bool setToPrincipal, + bool setToDependent) { using var context = new FixupContext(); var principal = new Category(77); @@ -1023,7 +1046,10 @@ public void Add_principal_but_not_dependent_one_to_many_FK_not_set_dependent_nav } private void Add_principal_but_not_dependent_one_to_many( - EntityState entityState, bool setFk, bool setToPrincipal, bool setToDependent) + EntityState entityState, + bool setFk, + bool setToPrincipal, + bool setToDependent) { using var context = new FixupContext(); var principal = new Category(77); @@ -1413,7 +1439,10 @@ public void Add_dependent_but_not_principal_one_to_one_FK_not_set_dependent_nav_ } private void Add_dependent_but_not_principal_one_to_one( - EntityState entityState, bool setFk, bool setToPrincipal, bool setToDependent) + EntityState entityState, + bool setFk, + bool setToPrincipal, + bool setToDependent) { using var context = new FixupContext(); var principal = new Parent(77); @@ -1525,7 +1554,10 @@ public void Add_principal_but_not_dependent_one_to_one_FK_not_set_dependent_nav_ } private void Add_principal_but_not_dependent_one_to_one( - EntityState entityState, bool setFk, bool setToPrincipal, bool setToDependent) + EntityState entityState, + bool setFk, + bool setToPrincipal, + bool setToDependent) { using var context = new FixupContext(); var principal = new Parent(77); @@ -1947,7 +1979,11 @@ public void Replace_dependent_one_to_one_FK_not_set_dependent_nav_set(EntityStat } private void Replace_dependent_one_to_one( - EntityState oldEntityState, EntityState newEntityState, bool setFk, bool setToPrincipal, bool setToDependent, + EntityState oldEntityState, + EntityState newEntityState, + bool setFk, + bool setToPrincipal, + bool setToDependent, bool detectChanges = false) { using var context = new FixupContext(); @@ -2033,13 +2069,18 @@ public void Replace_dependent_one_to_one_prin_uni_FK_set_principal_nav_set(Entit [InlineData(EntityState.Unchanged, EntityState.Added)] [InlineData(EntityState.Unchanged, EntityState.Modified)] public void Replace_dependent_one_to_one_prin_uni_FK_not_set_principal_nav_set( - EntityState oldEntityState, EntityState newEntityState) + EntityState oldEntityState, + EntityState newEntityState) { Replace_dependent_one_to_one_prin_uni(oldEntityState, newEntityState, setFk: false, setToDependent: true, detectChanges: true); } private void Replace_dependent_one_to_one_prin_uni( - EntityState oldEntityState, EntityState newEntityState, bool setFk, bool setToDependent, bool detectChanges = false) + EntityState oldEntityState, + EntityState newEntityState, + bool setFk, + bool setToDependent, + bool detectChanges = false) { using var context = new FixupContext(); context.ChangeTracker.DeleteOrphansTiming = CascadeTiming.OnSaveChanges; @@ -2116,13 +2157,17 @@ public void Replace_dependent_one_to_one_dep_uni_FK_set_dependent_nav_set(Entity [InlineData(EntityState.Unchanged, EntityState.Added)] [InlineData(EntityState.Unchanged, EntityState.Modified)] public void Replace_dependent_one_to_one_dep_uni_FK_not_set_dependent_nav_set( - EntityState oldEntityState, EntityState newEntityState) + EntityState oldEntityState, + EntityState newEntityState) { Replace_dependent_one_to_one_dep_uni(oldEntityState, newEntityState, setFk: false, setToPrincipal: true); } private void Replace_dependent_one_to_one_dep_uni( - EntityState oldEntityState, EntityState newEntityState, bool setFk, bool setToPrincipal) + EntityState oldEntityState, + EntityState newEntityState, + bool setFk, + bool setToPrincipal) { using var context = new FixupContext(); context.ChangeTracker.DeleteOrphansTiming = CascadeTiming.OnSaveChanges; @@ -2509,25 +2554,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))) { @@ -2537,11 +2568,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 { @@ -2556,10 +2583,7 @@ public void Use_correct_entity_after_SetValues() { Id = detachedContainer.Id, Name = "C1", - Rooms = - { - attachedRoom - } + Rooms = { attachedRoom } }; context.Attach(attached); @@ -2629,17 +2653,13 @@ 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 ParentX { Id = 101, Name = "Parent1" }, + new ChildX { Id = 201, Name = "Child1" }, new ParentChildX { - ParentId = 101, ChildId = 201, SortOrder = 1 + ParentId = 101, + ChildId = 201, + SortOrder = 1 }); context.SaveChanges(); @@ -2663,10 +2683,7 @@ public void Replaced_duplicate_entities_are_used_even_with_bad_hash() 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); @@ -2762,10 +2779,7 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) .IsRequired(); modelBuilder.Entity().HasKey( - x => new - { - x.ParentId, x.ChildId - }); + x => new { x.ParentId, x.ChildId }); } } @@ -2861,12 +2875,15 @@ public Parent(int id) } // ReSharper disable once ConvertToAutoProperty - public int Id => _id; + public int Id + => _id; // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter - public Child Child => _child; + public Child Child + => _child; - public void SetChild(Child child) => _child = child; + public void SetChild(Child child) + => _child = child; } private class Child @@ -2883,17 +2900,22 @@ public Child(int id, int parentId) } // ReSharper disable once ConvertToAutoProperty - public int Id => _id; + public int Id + => _id; // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter - public int ParentId => _parentId; + public int ParentId + => _parentId; // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter - public Parent Parent => _parent; + public Parent Parent + => _parent; - public void SetParent(Parent parent) => _parent = parent; + public void SetParent(Parent parent) + => _parent = parent; - public void SetParentId(int parentId) => _parentId = parentId; + public void SetParentId(int parentId) + => _parentId = parentId; } private class ParentPN @@ -2993,10 +3015,12 @@ public Category(int id) } // ReSharper disable once ConvertToAutoProperty - public int Id => _id; + public int Id + => _id; // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter - public ICollection Products => _products; + public ICollection Products + => _products; public void AddProduct(Product product) => (_products ?? (_products = new List())).Add(product); @@ -3021,17 +3045,22 @@ public Product(int id, int categoryId) } // ReSharper disable once ConvertToAutoProperty - public int Id => _id; + public int Id + => _id; // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter - public int CategoryId => _categoryId; + public int CategoryId + => _categoryId; - public void SetCategoryId(int categoryId) => _categoryId = categoryId; + public void SetCategoryId(int categoryId) + => _categoryId = categoryId; // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter - public Category Category => _category; + public Category Category + => _category; - public void SetCategory(Category category) => _category = category; + public void SetCategory(Category category) + => _category = category; // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter public ICollection SpecialOffers @@ -3063,18 +3092,23 @@ public SpecialOffer(int id, int productId) } // ReSharper disable once ConvertToAutoProperty - public int Id => _id; + public int Id + => _id; // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter - public int ProductId => _productId; + public int ProductId + => _productId; // ReSharper disable once UnusedMember.Local - public void SetProductId(int productId) => _productId = productId; + public void SetProductId(int productId) + => _productId = productId; // ReSharper disable once ConvertToAutoPropertyWithPrivateSetter - public Product Product => _product; + public Product Product + => _product; - public void SetProduct(Product product) => _product = product; + public void SetProduct(Product product) + => _product = product; } private sealed class FixupContext : DbContext diff --git a/test/EFCore.Tests/ChangeTracking/Internal/InternalEntityEntryFactoryTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/InternalEntityEntryFactoryTest.cs index 306e2929446..980c5b77abc 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/InternalEntityEntryFactoryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/InternalEntityEntryFactoryTest.cs @@ -81,7 +81,8 @@ public void Creates_mixed_entry_when_entity_CLR_entity_type_and_shadow_propertie Assert.Same(entity, entry.Entity); } - private static IMutableModel CreateModel() => new Model(); + private static IMutableModel CreateModel() + => new Model(); private class RedHook { diff --git a/test/EFCore.Tests/ChangeTracking/Internal/InternalEntryEntrySubscriberTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/InternalEntryEntrySubscriberTest.cs index f4a0ea2cfc7..824cab87ac1 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/InternalEntryEntrySubscriberTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/InternalEntryEntrySubscriberTest.cs @@ -204,7 +204,8 @@ public void Entry_handles_clear_as_replace_with_ObservableHashSet() } private static ICollection CreateCollection( - bool ourCollection, params ChangedOnlyNotificationEntity[] items) + bool ourCollection, + params ChangedOnlyNotificationEntity[] items) => ourCollection ? (ICollection)new ObservableHashSet(items) : new ObservableCollection(items); @@ -514,12 +515,18 @@ private class TestNavigationListener : INavigationFixer = new List, IEnumerable>>(); public void NavigationReferenceChanged( - InternalEntityEntry entry, INavigationBase navigationBase, object oldValue, object newValue) + InternalEntityEntry entry, + INavigationBase navigationBase, + object oldValue, + object newValue) { } public void NavigationCollectionChanged( - InternalEntityEntry entry, INavigationBase navigationBase, IEnumerable added, IEnumerable removed) + InternalEntityEntry entry, + INavigationBase navigationBase, + IEnumerable added, + IEnumerable removed) => CollectionChanged.Add(Tuple.Create(entry, navigationBase, added, removed)); public void TrackedFromQuery(InternalEntityEntry entry) @@ -535,9 +542,12 @@ public void StateChanged(InternalEntityEntry entry, EntityState oldState, bool f } public void KeyPropertyChanged( - InternalEntityEntry entry, IProperty property, IEnumerable containingPrincipalKeys, + InternalEntityEntry entry, + IProperty property, + IEnumerable containingPrincipalKeys, IEnumerable containingForeignKeys, - object oldValue, object newValue) + object oldValue, + object newValue) { } } diff --git a/test/EFCore.Tests/ChangeTracking/Internal/NavigationFixerTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/NavigationFixerTest.cs index 7566f5e5806..cd0d85fb254 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/NavigationFixerTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/NavigationFixerTest.cs @@ -1266,7 +1266,8 @@ public IEnumerator GetEnumerator() throw new NotImplementedException(); } - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); } private class ProductPhoto diff --git a/test/EFCore.Tests/ChangeTracking/Internal/ObservableBackedBindingListTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/ObservableBackedBindingListTest.cs index 0bdc2531b1a..d9643f0aa83 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/ObservableBackedBindingListTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/ObservableBackedBindingListTest.cs @@ -545,7 +545,8 @@ public ListElement(int i) ByteArray = new[] { (byte)i, (byte)i, (byte)i, (byte)i }; } - public static implicit operator ListElement(int i) => new ListElement(i); + public static implicit operator ListElement(int i) + => new ListElement(i); public int Int { get; } public int? NullableInt { get; } diff --git a/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs index a28f92a784d..cbfe5b43024 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/OwnedFixupTest.cs @@ -47,14 +47,7 @@ public void Detaching_owner_does_not_delete_owned_entities(bool delayCascade) ThingId = Guid.NewGuid(), OwnedByThings = new List { - new OwnedByThing - { - OwnedByThingId = Guid.NewGuid() - }, - new OwnedByThing - { - OwnedByThingId = Guid.NewGuid() - } + new OwnedByThing { OwnedByThingId = Guid.NewGuid() }, new OwnedByThing { OwnedByThingId = Guid.NewGuid() } } }; @@ -451,7 +444,9 @@ public void Add_principal_with_dependent_principal_nav(EntityState entityState, [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) + EntityState entityState, + bool? useTrackGraph, + CollectionType collectionType) { using var context = new FixupContext(); var principal = new ParentPN { Id = 77 }; @@ -590,7 +585,9 @@ public void Add_principal_with_dependent_unidirectional_nav_collection( [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) + EntityState entityState, + bool? useTrackGraph, + CollectionType collectionType) { using var context = new FixupContext(); var principal = new Parent { Id = 77 }; @@ -728,7 +725,9 @@ public void Add_principal_with_dependent_both_navs_collection( [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) + EntityState entityState, + bool? useTrackGraph, + CollectionType collectionType) { using var context = new FixupContext(); var principal = new Parent { Id = 77 }; @@ -4215,7 +4214,10 @@ EntityState GetEntryState(EquatableEntitiesContext context, string role private class User { public Guid UserId { get; set; } - public IReadOnlyList Roles => _roles.AsReadOnly(); + + public IReadOnlyList Roles + => _roles.AsReadOnly(); + private readonly List _roles = new List(); public void SetRoles(IList roles) @@ -4234,7 +4236,9 @@ public void SetRoles(IList roles) private class Role : IEquatable { public string Value { get; set; } - public bool Equals(Role other) => Value == other.Value; + + public bool Equals(Role other) + => Value == other.Value; } private class EquatableEntitiesContext : DbContext @@ -4276,7 +4280,8 @@ private class Parent : IComparable public ICollection ChildCollection1 { get; set; } public ICollection ChildCollection2 { get; set; } - public int CompareTo(Parent other) => Id - other.Id; + public int CompareTo(Parent other) + => Id - other.Id; public override bool Equals(object obj) { @@ -4311,7 +4316,8 @@ private class Child : IComparable public SubChild SubChild { get; set; } public ICollection SubChildCollection { get; set; } - public int CompareTo(Child other) => StringComparer.InvariantCulture.Compare(Name, other.Name); + public int CompareTo(Child other) + => StringComparer.InvariantCulture.Compare(Name, other.Name); public override bool Equals(object obj) { @@ -4346,7 +4352,8 @@ private class SubChild : IComparable public Child Parent { get; set; } - public int CompareTo(SubChild other) => StringComparer.InvariantCulture.Compare(Name, other.Name); + public int CompareTo(SubChild other) + => StringComparer.InvariantCulture.Compare(Name, other.Name); public override bool Equals(object obj) { @@ -4382,7 +4389,8 @@ private class ParentPN : IComparable public ICollection ChildCollection1 { get; set; } public ICollection ChildCollection2 { get; set; } - public int CompareTo(ParentPN other) => Id - other.Id; + public int CompareTo(ParentPN other) + => Id - other.Id; } private class ChildPN : IComparable @@ -4393,14 +4401,16 @@ private class ChildPN : IComparable public SubChildPN SubChild { get; set; } public ICollection SubChildCollection { get; set; } - public int CompareTo(ChildPN other) => StringComparer.InvariantCulture.Compare(Name, other.Name); + public int CompareTo(ChildPN other) + => StringComparer.InvariantCulture.Compare(Name, other.Name); } private class SubChildPN : IComparable { public string Name { get; set; } - public int CompareTo(SubChildPN other) => StringComparer.InvariantCulture.Compare(Name, other.Name); + public int CompareTo(SubChildPN other) + => StringComparer.InvariantCulture.Compare(Name, other.Name); } private class FixupContext : DbContext @@ -4628,11 +4638,12 @@ protected internal override void OnModelCreating(ModelBuilder modelBuilder) }); }); - modelBuilder.Entity().OwnsMany(p => p.OwnedByThings, a => - { - a.WithOwner().HasForeignKey(e => e.ThingId); - a.HasKey(e => e.OwnedByThingId); - }); + modelBuilder.Entity().OwnsMany( + p => p.OwnedByThings, a => + { + a.WithOwner().HasForeignKey(e => e.ThingId); + a.HasKey(e => e.OwnedByThingId); + }); } protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) @@ -4664,7 +4675,7 @@ private static ICollection CreateChildCollection(CollectionType collection where T : class => collectionType switch { - CollectionType.List => (ICollection)new List { dependent }, + CollectionType.List => new List { dependent }, CollectionType.SortedSet => new SortedSet { dependent }, CollectionType.Collection => new Collection { dependent }, CollectionType.ObservableCollection => new ObservableCollection { dependent }, diff --git a/test/EFCore.Tests/ChangeTracking/Internal/PropertyValuesTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/PropertyValuesTest.cs index 461eed21b3c..263ef27892e 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/PropertyValuesTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/PropertyValuesTest.cs @@ -1,9 +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.Collections.Generic; -using System.Linq; using Xunit; namespace Microsoft.EntityFrameworkCore.ChangeTracking.Internal @@ -20,7 +18,7 @@ public void Can_safely_get_originalvalue_and_currentvalue_with_tryget() using var ctx = new CurrentValuesDb(); var entity = ctx.SimpleEntities.Add(new SimpleEntity { Name = NameValue }); ctx.SaveChanges(); - + entity.Entity.Name = NewNameValue; // Act @@ -45,7 +43,7 @@ public void Should_not_throw_error_when_property_do_not_exist() using var ctx = new CurrentValuesDb(); var entity = ctx.SimpleEntities.Add(new SimpleEntity { Name = NameValue }); ctx.SaveChanges(); - + entity.Entity.Name = NewNameValue; // Act @@ -77,7 +75,6 @@ private class SimpleEntity public string Name { get; set; } public IEnumerable RelatedEntities { get; set; } - } private class RelatedEntity @@ -87,8 +84,8 @@ private class RelatedEntity public int? SimpleEntityId { get; set; } public SimpleEntity SimpleEntity { get; set; } - - public string Name {get; set;} + + public string Name { get; set; } } } -} \ No newline at end of file +} diff --git a/test/EFCore.Tests/ChangeTracking/Internal/ShadowFixupTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/ShadowFixupTest.cs index adcd0e4b608..0d699984e05 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/ShadowFixupTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/ShadowFixupTest.cs @@ -87,7 +87,11 @@ public void Add_dependent_then_principal_one_to_many_FK_not_set_dependent_nav_se } private void Add_principal_and_dependent_one_to_many( - EntityState entityState, bool principalFirst, bool setFk, bool setToPrincipal, bool setToDependent) + EntityState entityState, + bool principalFirst, + bool setFk, + bool setToPrincipal, + bool setToDependent) { using var context = new FixupContext(); var principal = new Category(77); @@ -204,7 +208,11 @@ public void Add_dependent_then_principal_one_to_one_FK_not_set_dependent_nav_set } private void Add_principal_and_dependent_one_to_one( - EntityState entityState, bool principalFirst, bool setFk, bool setToPrincipal, bool setToDependent) + EntityState entityState, + bool principalFirst, + bool setFk, + bool setToPrincipal, + bool setToDependent) { using var context = new FixupContext(); var principal = new Parent(77); diff --git a/test/EFCore.Tests/ChangeTracking/Internal/SortableBindingListTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/SortableBindingListTest.cs index dd759d09a80..7c6a77be24a 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/SortableBindingListTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/SortableBindingListTest.cs @@ -202,7 +202,8 @@ public ListElement(int i) ByteArray = new[] { (byte)i, (byte)i, (byte)i, (byte)i }; } - public static implicit operator ListElement(int i) => new ListElement(i); + public static implicit operator ListElement(int i) + => new ListElement(i); public int Int { get; } public int? NullableInt { get; } @@ -228,8 +229,11 @@ public DerivedListElement(int i) private class ListElementComparer : IEqualityComparer { - public bool Equals(ListElement x, ListElement y) => x.Int == y.Int; - public int GetHashCode(ListElement obj) => obj.Int; + public bool Equals(ListElement x, ListElement y) + => x.Int == y.Int; + + public int GetHashCode(ListElement obj) + => obj.Int; } } } diff --git a/test/EFCore.Tests/ChangeTracking/Internal/StateManagerTest.cs b/test/EFCore.Tests/ChangeTracking/Internal/StateManagerTest.cs index 437160edca1..88b53c8d1db 100644 --- a/test/EFCore.Tests/ChangeTracking/Internal/StateManagerTest.cs +++ b/test/EFCore.Tests/ChangeTracking/Internal/StateManagerTest.cs @@ -505,12 +505,19 @@ private class TestListener : INavigationFixer public EntityState ChangingState; public EntityState ChangedState; - public void NavigationReferenceChanged(InternalEntityEntry entry, INavigationBase navigationBase, object oldValue, object newValue) + public void NavigationReferenceChanged( + InternalEntityEntry entry, + INavigationBase navigationBase, + object oldValue, + object newValue) { } public void NavigationCollectionChanged( - InternalEntityEntry entry, INavigationBase navigationBase, IEnumerable added, IEnumerable removed) + InternalEntityEntry entry, + INavigationBase navigationBase, + IEnumerable added, + IEnumerable removed) { } @@ -519,9 +526,12 @@ public void TrackedFromQuery(InternalEntityEntry entry) } public void KeyPropertyChanged( - InternalEntityEntry entry, IProperty property, IEnumerable containingPrincipalKeys, + InternalEntityEntry entry, + IProperty property, + IEnumerable containingPrincipalKeys, IEnumerable containingForeignKeys, - object oldValue, object newValue) + object oldValue, + object newValue) { } diff --git a/test/EFCore.Tests/ChangeTracking/MemberEntryTest.cs b/test/EFCore.Tests/ChangeTracking/MemberEntryTest.cs index 0f48f708eaf..633db1b3a54 100644 --- a/test/EFCore.Tests/ChangeTracking/MemberEntryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/MemberEntryTest.cs @@ -171,7 +171,7 @@ public void IsModified_tracks_state_of_FK_property_reference() public void IsModified_tracks_state_of_owned_entity() { using var context = new FreezerContext(); - var chunky = new Chunky { Chunk = new Chunk { Size = 1, Shape = "Sphere" }}; + var chunky = new Chunky { Chunk = new Chunk { Size = 1, Shape = "Sphere" } }; context.Add(chunky); var reference = context.Entry(chunky).Member(nameof(Chunky.Chunk)); @@ -222,7 +222,8 @@ public void IsModified_can_set_fk_to_modified_collection() } [Owned] - public class Chunk { + public class Chunk + { public int Size { get; set; } public string Shape { get; set; } } diff --git a/test/EFCore.Tests/ChangeTracking/ReferenceEntryTest.cs b/test/EFCore.Tests/ChangeTracking/ReferenceEntryTest.cs index 093b1e964ae..45404b6bcf8 100644 --- a/test/EFCore.Tests/ChangeTracking/ReferenceEntryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/ReferenceEntryTest.cs @@ -416,7 +416,8 @@ public void IsModified_tracks_state_of_FK_property_principal() [InlineData(EntityState.Deleted, EntityState.Deleted)] [InlineData(EntityState.Unchanged, EntityState.Deleted)] public void IsModified_can_set_fk_to_modified_principal_with_Added_or_Deleted_dependent( - EntityState principalState, EntityState dependentState) + EntityState principalState, + EntityState dependentState) { using var context = new FreezerContext(); var half = new Half(); @@ -449,7 +450,8 @@ public void IsModified_can_set_fk_to_modified_principal_with_Added_or_Deleted_de [InlineData(EntityState.Deleted, EntityState.Unchanged)] [InlineData(EntityState.Unchanged, EntityState.Unchanged)] public void IsModified_can_set_fk_to_modified_principal_with_Unchanged_dependent( - EntityState principalState, EntityState dependentState) + EntityState principalState, + EntityState dependentState) { using var context = new FreezerContext(); var half = new Half(); @@ -482,7 +484,8 @@ public void IsModified_can_set_fk_to_modified_principal_with_Unchanged_dependent [InlineData(EntityState.Deleted, EntityState.Modified)] [InlineData(EntityState.Unchanged, EntityState.Modified)] public void IsModified_can_set_fk_to_modified_principal_with_Modified_dependent( - EntityState principalState, EntityState dependentState) + EntityState principalState, + EntityState dependentState) { using var context = new FreezerContext(); var half = new Half { Id = 7 }; diff --git a/test/EFCore.Tests/ChangeTracking/SkipCollectionEntryTest.cs b/test/EFCore.Tests/ChangeTracking/SkipCollectionEntryTest.cs index 372d786fa28..d162130319e 100644 --- a/test/EFCore.Tests/ChangeTracking/SkipCollectionEntryTest.cs +++ b/test/EFCore.Tests/ChangeTracking/SkipCollectionEntryTest.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.Collections.Generic; using System.Linq; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/test/EFCore.Tests/ChangeTracking/TrackGraphTestBase.cs b/test/EFCore.Tests/ChangeTracking/TrackGraphTestBase.cs index fe779134fad..344cd1f84f8 100644 --- a/test/EFCore.Tests/ChangeTracking/TrackGraphTestBase.cs +++ b/test/EFCore.Tests/ChangeTracking/TrackGraphTestBase.cs @@ -21,12 +21,13 @@ protected override IList TrackGraph(DbContext context, object root, Acti { var traversal = new List(); - context.ChangeTracker.TrackGraph(root, node => - { - callback(node); + context.ChangeTracker.TrackGraph( + root, node => + { + callback(node); - traversal.Add(NodeString(node)); - }); + traversal.Add(NodeString(node)); + }); return traversal; } @@ -329,6 +330,7 @@ public void Can_attach_owned_dependent_with_reference_to_parent(bool useAttach, Assert.Equal(1, dependentEntry2a.Property(dependentEntry2a.Metadata.FindPrimaryKey().Properties[0].Name).CurrentValue); Assert.Equal(1, dependentEntry2b.Property(dependentEntry2b.Metadata.FindPrimaryKey().Properties[0].Name).CurrentValue); } + [ConditionalFact] public void Can_attach_parent_with_child_collection() { @@ -793,10 +795,7 @@ public void Dependents_are_detached_not_deleted_when_principal_is_detached(bool "Category:1 ---Products--> Product:2", "Category:1 ---Products--> Product:3" } - : new List - { - " -----> Category:1" - }, + : new List { " -----> Category:1" }, TrackGraph()); if (trackNewDependents || delayCascade) @@ -1433,6 +1432,5 @@ public virtual EntityState DetermineState(EntityEntry entry) ? (_updateExistingEntities ? EntityState.Modified : EntityState.Unchanged) : EntityState.Added; } - } } diff --git a/test/EFCore.Tests/DatabaseFacadeTest.cs b/test/EFCore.Tests/DatabaseFacadeTest.cs index 1eed7e653f4..5d4b3c91eeb 100644 --- a/test/EFCore.Tests/DatabaseFacadeTest.cs +++ b/test/EFCore.Tests/DatabaseFacadeTest.cs @@ -162,7 +162,8 @@ public IDbContextTransaction BeginTransaction() public Task BeginTransactionAsync(CancellationToken cancellationToken = default) => Task.FromResult(_transaction); - public void CommitTransaction() => CommitCalls++; + public void CommitTransaction() + => CommitCalls++; public Task CommitTransactionAsync(CancellationToken cancellationToken = default) { @@ -170,7 +171,8 @@ public Task CommitTransactionAsync(CancellationToken cancellationToken = default return Task.CompletedTask; } - public void RollbackTransaction() => RollbackCalls++; + public void RollbackTransaction() + => RollbackCalls++; public Task RollbackTransactionAsync(CancellationToken cancellationToken = default) { @@ -178,7 +180,8 @@ public Task RollbackTransactionAsync(CancellationToken cancellationToken = defau return Task.CompletedTask; } - public void CreateSavepoint(string name) => CreateSavepointCalls++; + public void CreateSavepoint(string name) + => CreateSavepointCalls++; public Task CreateSavepointAsync(string name, CancellationToken cancellationToken = default) { @@ -186,7 +189,8 @@ public Task CreateSavepointAsync(string name, CancellationToken cancellationToke return Task.CompletedTask; } - public void RollbackToSavepoint(string name) => RollbackSavepointCalls++; + public void RollbackToSavepoint(string name) + => RollbackSavepointCalls++; public Task RollbackToSavepointAsync(string name, CancellationToken cancellationToken = default) { @@ -194,7 +198,8 @@ public Task RollbackToSavepointAsync(string name, CancellationToken cancellation return Task.CompletedTask; } - public void ReleaseSavepoint(string name) => ReleaseSavepointCalls++; + public void ReleaseSavepoint(string name) + => ReleaseSavepointCalls++; public Task ReleaseSavepointAsync(string name, CancellationToken cancellationToken = default) { @@ -211,23 +216,42 @@ public bool SupportsSavepoints } } - public IDbContextTransaction CurrentTransaction => _transaction; + public IDbContextTransaction CurrentTransaction + => _transaction; + public Transaction EnlistedTransaction { get; } - public void EnlistTransaction(Transaction transaction) => throw new NotImplementedException(); - public void ResetState() => throw new NotImplementedException(); - public Task ResetStateAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException(); + public void EnlistTransaction(Transaction transaction) + => throw new NotImplementedException(); + + public void ResetState() + => throw new NotImplementedException(); + + public Task ResetStateAsync(CancellationToken cancellationToken = default) + => throw new NotImplementedException(); } private class FakeDbContextTransaction : IDbContextTransaction { - public void Dispose() => throw new NotImplementedException(); - public ValueTask DisposeAsync() => throw new NotImplementedException(); + public void Dispose() + => throw new NotImplementedException(); + + public ValueTask DisposeAsync() + => throw new NotImplementedException(); + public Guid TransactionId { get; } - public void Commit() => throw new NotImplementedException(); - public Task CommitAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException(); - public void Rollback() => throw new NotImplementedException(); - public Task RollbackAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException(); + + public void Commit() + => throw new NotImplementedException(); + + public Task CommitAsync(CancellationToken cancellationToken = default) + => throw new NotImplementedException(); + + public void Rollback() + => throw new NotImplementedException(); + + public Task RollbackAsync(CancellationToken cancellationToken = default) + => throw new NotImplementedException(); } [ConditionalFact] diff --git a/test/EFCore.Tests/DbContextFactoryTest.cs b/test/EFCore.Tests/DbContextFactoryTest.cs index f985b310227..eb91b39641e 100644 --- a/test/EFCore.Tests/DbContextFactoryTest.cs +++ b/test/EFCore.Tests/DbContextFactoryTest.cs @@ -128,7 +128,6 @@ public void Factory_and_options_have_the_same_lifetime(ServiceLifetime lifetime) Assert.Equal(lifetime, serviceCollection.Single(e => e.ServiceType == typeof(DbContextOptions)).Lifetime); } - [ConditionalFact] public void Default_lifetime_is_singleton() { @@ -261,7 +260,9 @@ public void Can_always_inject_singleton_and_transient_services(ServiceLifetime l private class TransientService : IDisposable { public bool IsDisposed { get; private set; } - public void Dispose() => IsDisposed = true; + + public void Dispose() + => IsDisposed = true; } private class SingletonService @@ -342,7 +343,9 @@ public void Can_inject_singleton_transient_and_scoped_services_into_scoped_facto private class ScopedService : IDisposable { public bool IsDisposed { get; private set; } - public void Dispose() => IsDisposed = true; + + public void Dispose() + => IsDisposed = true; } private class CombeMartinContext : DbContext @@ -548,9 +551,11 @@ private class WoolacombeContextFactory : IDbContextFactory { private readonly DbContextOptions _options; - public WoolacombeContextFactory(DbContextOptions options) => _options = options; + public WoolacombeContextFactory(DbContextOptions options) + => _options = options; - public WoolacombeContext CreateDbContext() => new WoolacombeContext(_options); + public WoolacombeContext CreateDbContext() + => new WoolacombeContext(_options); } private static string GetStoreName(DbContext context1) diff --git a/test/EFCore.Tests/DbContextLoggerTests.cs b/test/EFCore.Tests/DbContextLoggerTests.cs index b6e716266e8..da3c5376f8b 100644 --- a/test/EFCore.Tests/DbContextLoggerTests.cs +++ b/test/EFCore.Tests/DbContextLoggerTests.cs @@ -387,7 +387,7 @@ public async Task Log_default_UTC(bool async) var stream = new StringWriter(); var actual = await LogTest( async, stream, b => b.LogTo( - stream.WriteLine, LogLevel.Information, DbContextLoggerOptions.DefaultWithUtcTime),6, true); + stream.WriteLine, LogLevel.Information, DbContextLoggerOptions.DefaultWithUtcTime), 6, true); AssertLog( actual, @@ -439,7 +439,8 @@ private static async Task LogTest( // May fail if test happens to span midnight on a change in length; seems unlikely! var end = (utc ? 28 : DateTime.Now.ToShortDateString().Length + 13) + dateAt; normalized = normalized.Substring(0, dateAt) - + (utc ? "YYYY-MM-DDTHH:MM:SS.MMMMMMTZ" : " HH:mm:ss.fff") + normalized.Substring(end); + + (utc ? "YYYY-MM-DDTHH:MM:SS.MMMMMMTZ" : " HH:mm:ss.fff") + + normalized.Substring(end); } } diff --git a/test/EFCore.Tests/DbContextOptionsTest.cs b/test/EFCore.Tests/DbContextOptionsTest.cs index ee216903577..5221bb6e1e3 100644 --- a/test/EFCore.Tests/DbContextOptionsTest.cs +++ b/test/EFCore.Tests/DbContextOptionsTest.cs @@ -142,11 +142,14 @@ public ExtensionInfo(IDbContextOptionsExtension extension) { } - public override bool IsDatabaseProvider => false; + public override bool IsDatabaseProvider + => false; - public override long GetServiceProviderHashCode() => 0; + public override long GetServiceProviderHashCode() + => 0; - public override string LogFragment => ""; + public override string LogFragment + => ""; public override void PopulateDebugInfo(IDictionary debugInfo) { @@ -177,11 +180,14 @@ public ExtensionInfo(IDbContextOptionsExtension extension) { } - public override bool IsDatabaseProvider => true; + public override bool IsDatabaseProvider + => true; - public override long GetServiceProviderHashCode() => 0; + public override long GetServiceProviderHashCode() + => 0; - public override string LogFragment => ""; + public override string LogFragment + => ""; public override void PopulateDebugInfo(IDictionary debugInfo) { @@ -221,10 +227,17 @@ public void UseMemoryCache_on_generic_builder_returns_generic_builder() private class FakeMemoryCache : IMemoryCache { - public void Dispose() => throw new NotImplementedException(); - public bool TryGetValue(object key, out object value) => throw new NotImplementedException(); - public ICacheEntry CreateEntry(object key) => throw new NotImplementedException(); - public void Remove(object key) => throw new NotImplementedException(); + public void Dispose() + => throw new NotImplementedException(); + + public bool TryGetValue(object key, out object value) + => throw new NotImplementedException(); + + public ICacheEntry CreateEntry(object key) + => throw new NotImplementedException(); + + public void Remove(object key) + => throw new NotImplementedException(); } [ConditionalFact] @@ -239,7 +252,8 @@ public void UseInternalServiceProvider_on_generic_builder_returns_generic_builde private class FakeServiceProvider : IServiceProvider { - public object GetService(Type serviceType) => throw new NotImplementedException(); + public object GetService(Type serviceType) + => throw new NotImplementedException(); } [ConditionalFact] @@ -275,8 +289,8 @@ public void ConfigureWarnings_on_generic_builder_returns_generic_builder() Assert.Equal(WarningBehavior.Throw, warningConfiguration.DefaultBehavior); } - private DbContextOptionsBuilder GenericCheck(DbContextOptionsBuilder optionsBuilder) => - optionsBuilder; + private DbContextOptionsBuilder GenericCheck(DbContextOptionsBuilder optionsBuilder) + => optionsBuilder; [ConditionalFact] public void Generic_builder_returns_generic_options() @@ -285,7 +299,8 @@ public void Generic_builder_returns_generic_options() Assert.Same(((DbContextOptionsBuilder)builder).Options, GenericCheck(builder.Options)); } - private DbContextOptions GenericCheck(DbContextOptions options) => options; + private DbContextOptions GenericCheck(DbContextOptions options) + => options; private class UnkoolContext : DbContext { diff --git a/test/EFCore.Tests/DbContextServicesTest.cs b/test/EFCore.Tests/DbContextServicesTest.cs index 6c6044f55b0..1bc576a4e90 100644 --- a/test/EFCore.Tests/DbContextServicesTest.cs +++ b/test/EFCore.Tests/DbContextServicesTest.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -90,7 +89,7 @@ public InfoLogContext(bool useLoggerFactory, bool configureForDebug) protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseInMemoryDatabase(typeof(InfoLogContext).FullName) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)); + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)); if (_useLoggerFactory) { @@ -147,7 +146,11 @@ public MyListLogger(List<(LogLevel, EventId, string)> logMessage) private List<(LogLevel, EventId, string)> LogMessages { get; } public void Log( - LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) + LogLevel logLevel, + EventId eventId, + TState state, + Exception exception, + Func formatter) { var message = new StringBuilder(); if (formatter != null) @@ -168,11 +171,14 @@ public void Log( LogMessages?.Add((logLevel, eventId, message.ToString())); } - public bool IsEnabled(LogLevel logLevel) => true; + public bool IsEnabled(LogLevel logLevel) + => true; - public IDisposable BeginScope(object state) => throw new NotImplementedException(); + public IDisposable BeginScope(object state) + => throw new NotImplementedException(); - public IDisposable BeginScope(TState state) => null; + public IDisposable BeginScope(TState state) + => null; } } @@ -389,24 +395,37 @@ public void Can_start_with_custom_services_by_passing_in_base_service_provider() private class FakeNavigationFixer : INavigationFixer { - public void StateChanging(InternalEntityEntry entry, EntityState newState) => throw new NotImplementedException(); + public void StateChanging(InternalEntityEntry entry, EntityState newState) + => throw new NotImplementedException(); - public void StateChanged(InternalEntityEntry entry, EntityState oldState, bool fromQuery) => - throw new NotImplementedException(); + public void StateChanged(InternalEntityEntry entry, EntityState oldState, bool fromQuery) + => throw new NotImplementedException(); - public void NavigationReferenceChanged(InternalEntityEntry entry, INavigationBase navigationBase, object oldValue, object newValue) => - throw new NotImplementedException(); + public void NavigationReferenceChanged( + InternalEntityEntry entry, + INavigationBase navigationBase, + object oldValue, + object newValue) + => throw new NotImplementedException(); public void NavigationCollectionChanged( - InternalEntityEntry entry, INavigationBase navigationBase, IEnumerable added, IEnumerable removed) => - throw new NotImplementedException(); + InternalEntityEntry entry, + INavigationBase navigationBase, + IEnumerable added, + IEnumerable removed) + => throw new NotImplementedException(); public void KeyPropertyChanged( - InternalEntityEntry entry, IProperty property, IEnumerable containingPrincipalKeys, - IEnumerable containingForeignKeys, object oldValue, object newValue) => throw new NotImplementedException(); + InternalEntityEntry entry, + IProperty property, + IEnumerable containingPrincipalKeys, + IEnumerable containingForeignKeys, + object oldValue, + object newValue) + => throw new NotImplementedException(); - public void TrackedFromQuery(InternalEntityEntry entry) => - throw new NotImplementedException(); + public void TrackedFromQuery(InternalEntityEntry entry) + => throw new NotImplementedException(); } [ConditionalFact] @@ -1190,9 +1209,10 @@ public void Can_add_derived_context_with_options() public void Can_add_derived_context_with_options_and_external_services() { var appServiceProvider = new ServiceCollection() - .AddDbContext(b => b - .UseInMemoryDatabase(Guid.NewGuid().ToString()) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) + .AddDbContext( + b => b + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) .BuildServiceProvider(); ILoggerFactory loggerFactory; @@ -1421,8 +1441,8 @@ public void Can_add_derived_context_with_options_no_OnConfiguring() var appServiceProvider = new ServiceCollection() .AddDbContext( b => b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(Guid.NewGuid().ToString()) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) .BuildServiceProvider(); var singleton = new object[3]; @@ -1457,9 +1477,9 @@ public void Can_add_derived_context_with_options_and_external_services_no_OnConf { var appServiceProvider = new ServiceCollection() .AddDbContext( - b =>b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(Guid.NewGuid().ToString()) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) + b => b.EnableServiceProviderCaching(false) + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) .BuildServiceProvider(); ILoggerFactory loggerFactory; @@ -1622,8 +1642,8 @@ public void Can_add_non_derived_context_with_options() var appServiceProvider = new ServiceCollection() .AddDbContext( b => b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(Guid.NewGuid().ToString()) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) .BuildServiceProvider(); var singleton = new object[4]; @@ -1702,10 +1722,11 @@ public void Can_add_non_derived_context_controlling_internal_services_with_optio { var appServiceProvider = new ServiceCollection() .AddEntityFrameworkInMemoryDatabase() - .AddDbContext((p, b) => b - .UseInMemoryDatabase(Guid.NewGuid().ToString()) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)) - .UseInternalServiceProvider(p)) + .AddDbContext( + (p, b) => b + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)) + .UseInternalServiceProvider(p)) .BuildServiceProvider(); var singleton = new object[3]; @@ -2051,14 +2072,14 @@ public void Can_add_non_derived_context_as_singleton(bool addSingletonFirst) .AddSingleton() .AddDbContext( b => b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(Guid.NewGuid().ToString()) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) .BuildServiceProvider() : new ServiceCollection() .AddDbContext( b => b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(Guid.NewGuid().ToString()) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) .AddSingleton() .BuildServiceProvider(); @@ -2114,18 +2135,20 @@ public void Can_add_non_derived_context_as_singleton_controlling_internal_servic { serviceCollection .AddSingleton() - .AddDbContext((p, b) => b - .UseInMemoryDatabase(Guid.NewGuid().ToString()) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)) - .UseInternalServiceProvider(p)); + .AddDbContext( + (p, b) => b + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)) + .UseInternalServiceProvider(p)); } else { serviceCollection - .AddDbContext((p, b) => b - .UseInMemoryDatabase(Guid.NewGuid().ToString()) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)) - .UseInternalServiceProvider(p)) + .AddDbContext( + (p, b) => b + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)) + .UseInternalServiceProvider(p)) .AddSingleton(); } @@ -2180,14 +2203,14 @@ public void Can_add_non_derived_context_as_transient(bool addTransientFirst) .AddTransient() .AddDbContext( b => b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(Guid.NewGuid().ToString()) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) .BuildServiceProvider() : new ServiceCollection() .AddDbContext( b => b.EnableServiceProviderCaching(false) - .UseInMemoryDatabase(Guid.NewGuid().ToString()) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw))) .AddTransient() .BuildServiceProvider(); @@ -2247,18 +2270,20 @@ public void Can_add_non_derived_context_as_transient_controlling_internal_servic { serviceCollection .AddTransient() - .AddDbContext((p, b) => b - .UseInMemoryDatabase(Guid.NewGuid().ToString()) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)) - .UseInternalServiceProvider(p)); + .AddDbContext( + (p, b) => b + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)) + .UseInternalServiceProvider(p)); } else { serviceCollection - .AddDbContext((p, b) => b - .UseInMemoryDatabase(Guid.NewGuid().ToString()) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)) - .UseInternalServiceProvider(p)) + .AddDbContext( + (p, b) => b + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)) + .UseInternalServiceProvider(p)) .AddTransient(); } @@ -2312,10 +2337,11 @@ public void Can_use_logger_before_context_exists_and_after_disposed() { var appServiceProvider = new ServiceCollection() .AddEntityFrameworkInMemoryDatabase() - .AddDbContext((p, b) => b - .UseInMemoryDatabase(Guid.NewGuid().ToString()) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)) - .UseInternalServiceProvider(p)) + .AddDbContext( + (p, b) => b + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)) + .UseInternalServiceProvider(p)) .BuildServiceProvider(); Assert.NotNull(appServiceProvider.GetService>()); @@ -2378,10 +2404,11 @@ public void Can_use_memory_cache_before_context_exists_and_after_disposed() { var appServiceProvider = new ServiceCollection() .AddEntityFrameworkInMemoryDatabase() - .AddDbContext((p, b) => b - .UseInMemoryDatabase(Guid.NewGuid().ToString()) - .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)) - .UseInternalServiceProvider(p)) + .AddDbContext( + (p, b) => b + .UseInMemoryDatabase(Guid.NewGuid().ToString()) + .ConfigureWarnings(w => w.Default(WarningBehavior.Throw)) + .UseInternalServiceProvider(p)) .BuildServiceProvider(); var memoryCache = appServiceProvider.GetService(); @@ -2656,7 +2683,8 @@ protected internal override void OnConfiguring(DbContextOptionsBuilder optionsBu private class CustomParameterBindingFactory : IParameterBindingFactory { - public bool CanBind(Type parameterType, string parameterName) => false; + public bool CanBind(Type parameterType, string parameterName) + => false; public ParameterBinding Bind(IMutableEntityType entityType, Type parameterType, string parameterName) => throw new NotImplementedException(); @@ -2667,7 +2695,8 @@ public ParameterBinding Bind(IConventionEntityType entityType, Type parameterTyp private class CustomParameterBindingFactory2 : IParameterBindingFactory { - public bool CanBind(Type parameterType, string parameterName) => false; + public bool CanBind(Type parameterType, string parameterName) + => false; public ParameterBinding Bind(IMutableEntityType entityType, Type parameterType, string parameterName) => throw new NotImplementedException(); @@ -3344,7 +3373,8 @@ public WrappingLoggerFactory(ILoggerFactory loggerFactory) _loggerFactory = loggerFactory; } - public void Dispose() => _loggerFactory.Dispose(); + public void Dispose() + => _loggerFactory.Dispose(); public ILogger CreateLogger(string categoryName) { diff --git a/test/EFCore.Tests/DbContextTest.cs b/test/EFCore.Tests/DbContextTest.cs index 9af3ab6dbf5..b5348cdee7b 100644 --- a/test/EFCore.Tests/DbContextTest.cs +++ b/test/EFCore.Tests/DbContextTest.cs @@ -12,7 +12,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; @@ -817,7 +816,8 @@ public FakeServiceProvider() public bool Disposed { get; set; } - public void Dispose() => Disposed = true; + public void Dispose() + => Disposed = true; public object GetService(Type serviceType) { @@ -833,7 +833,8 @@ public class FakeServiceScopeFactory : IServiceScopeFactory { public static FakeServiceScope Scope { get; } = new FakeServiceScope(); - public IServiceScope CreateScope() => Scope; + public IServiceScope CreateScope() + => Scope; } public class FakeServiceScope : IServiceScope @@ -842,7 +843,8 @@ public class FakeServiceScope : IServiceScope public IServiceProvider ServiceProvider { get; set; } = new FakeServiceProvider(); - public void Dispose() => Disposed = true; + public void Dispose() + => Disposed = true; } } diff --git a/test/EFCore.Tests/DbContextTrackingTest.cs b/test/EFCore.Tests/DbContextTrackingTest.cs index aa7cab0fe69..da7c21236a3 100644 --- a/test/EFCore.Tests/DbContextTrackingTest.cs +++ b/test/EFCore.Tests/DbContextTrackingTest.cs @@ -46,7 +46,8 @@ public Task Can_add_existing_entities_to_context_to_be_updated_with_graph_method private static Task TrackEntitiesTest( Func> categoryAdder, - Func> productAdder, EntityState expectedState) + Func> productAdder, + EntityState expectedState) => TrackEntitiesTest( (c, e) => new ValueTask>(categoryAdder(c, e)), (c, e) => new ValueTask>(productAdder(c, e)), @@ -54,7 +55,8 @@ private static Task TrackEntitiesTest( private static async Task TrackEntitiesTest( Func>> categoryAdder, - Func>> productAdder, EntityState expectedState) + Func>> productAdder, + EntityState expectedState) { using var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider()); var relatedDependent = new Product @@ -225,7 +227,8 @@ public Task Can_add_existing_entities_with_default_value_to_context_to_be_update private static Task TrackEntitiesDefaultValueTest( Func> categoryAdder, - Func> productAdder, EntityState expectedState) + Func> productAdder, + EntityState expectedState) => TrackEntitiesDefaultValueTest( (c, e) => new ValueTask>(categoryAdder(c, e)), (c, e) => new ValueTask>(productAdder(c, e)), @@ -234,7 +237,8 @@ private static Task TrackEntitiesDefaultValueTest( // Issue #3890 private static async Task TrackEntitiesDefaultValueTest( Func>> categoryAdder, - Func>> productAdder, EntityState expectedState) + Func>> productAdder, + EntityState expectedState) { using var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider()); var category1 = new Category { Id = 0, Name = "Beverages" }; @@ -295,7 +299,8 @@ public Task Can_add_multiple_existing_entities_with_default_values_to_context_to private static Task TrackMultipleEntitiesDefaultValuesTest( Action categoryAdder, - Action productAdder, EntityState expectedState) + Action productAdder, + EntityState expectedState) => TrackMultipleEntitiesDefaultValuesTest( (c, e) => { @@ -312,7 +317,8 @@ private static Task TrackMultipleEntitiesDefaultValuesTest( // Issue #3890 private static async Task TrackMultipleEntitiesDefaultValuesTest( Func categoryAdder, - Func productAdder, EntityState expectedState) + Func productAdder, + EntityState expectedState) { using var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider()); var category1 = new Category { Id = 0, Name = "Beverages" }; @@ -409,7 +415,8 @@ public Task Can_add_existing_entities_to_context_to_be_updated_non_generic_graph private static Task TrackEntitiesTestNonGeneric( Func categoryAdder, - Func productAdder, EntityState expectedState) + Func productAdder, + EntityState expectedState) => TrackEntitiesTestNonGeneric( (c, e) => new ValueTask(categoryAdder(c, e)), (c, e) => new ValueTask(productAdder(c, e)), @@ -417,7 +424,8 @@ private static Task TrackEntitiesTestNonGeneric( private static async Task TrackEntitiesTestNonGeneric( Func> categoryAdder, - Func> productAdder, EntityState expectedState) + Func> productAdder, + EntityState expectedState) { using var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider()); var relatedDependent = new Product @@ -588,7 +596,8 @@ public Task Can_add_existing_entities_with_default_value_to_context_to_be_update private static Task TrackEntitiesDefaultValuesTestNonGeneric( Func categoryAdder, - Func productAdder, EntityState expectedState) + Func productAdder, + EntityState expectedState) => TrackEntitiesDefaultValuesTestNonGeneric( (c, e) => new ValueTask(categoryAdder(c, e)), (c, e) => new ValueTask(productAdder(c, e)), @@ -597,7 +606,8 @@ private static Task TrackEntitiesDefaultValuesTestNonGeneric( // Issue #3890 private static async Task TrackEntitiesDefaultValuesTestNonGeneric( Func> categoryAdder, - Func> productAdder, EntityState expectedState) + Func> productAdder, + EntityState expectedState) { using var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider()); var category1 = new Category { Id = 0, Name = "Beverages" }; @@ -660,7 +670,8 @@ public Task Can_add_multiple_existing_entities_with_default_values_to_context_to private static Task TrackMultipleEntitiesDefaultValueTestEnumerable( Action> categoryAdder, - Action> productAdder, EntityState expectedState) + Action> productAdder, + EntityState expectedState) => TrackMultipleEntitiesDefaultValueTestEnumerable( (c, e) => { @@ -677,7 +688,8 @@ private static Task TrackMultipleEntitiesDefaultValueTestEnumerable( // Issue #3890 private static async Task TrackMultipleEntitiesDefaultValueTestEnumerable( Func, Task> categoryAdder, - Func, Task> productAdder, EntityState expectedState) + Func, Task> productAdder, + EntityState expectedState) { using var context = new EarlyLearningCenter(InMemoryTestHelpers.Instance.CreateServiceProvider()); var category1 = new Category { Id = 0, Name = "Beverages" }; diff --git a/test/EFCore.Tests/DbSetInitializerTest.cs b/test/EFCore.Tests/DbSetInitializerTest.cs index d30fba56f35..ba290731fe0 100644 --- a/test/EFCore.Tests/DbSetInitializerTest.cs +++ b/test/EFCore.Tests/DbSetInitializerTest.cs @@ -61,9 +61,11 @@ public JustAContext(DbContextOptions options) private DbSet Two { get; set; } public DbSet Three { get; private set; } - public DbSet Four => null; + public DbSet Four + => null; - public DbSet GetTwo() => Two; + public DbSet GetTwo() + => Two; } } } diff --git a/test/EFCore.Tests/DbSetTest.cs b/test/EFCore.Tests/DbSetTest.cs index 3f0e33f6b0b..1c1f7f240ec 100644 --- a/test/EFCore.Tests/DbSetTest.cs +++ b/test/EFCore.Tests/DbSetTest.cs @@ -194,7 +194,8 @@ public Task Can_add_existing_entities_to_context_to_be_updated_graph() private static Task TrackEntitiesTest( Func, Category, EntityEntry> categoryAdder, - Func, Product, EntityEntry> productAdder, EntityState expectedState) + Func, Product, EntityEntry> productAdder, + EntityState expectedState) => TrackEntitiesTest( (c, e) => new ValueTask>(categoryAdder(c, e)), (c, e) => new ValueTask>(productAdder(c, e)), @@ -202,7 +203,8 @@ private static Task TrackEntitiesTest( private static async Task TrackEntitiesTest( Func, Category, ValueTask>> categoryAdder, - Func, Product, ValueTask>> productAdder, EntityState expectedState) + Func, Product, ValueTask>> productAdder, + EntityState expectedState) { using var context = new EarlyLearningCenter(); var category1 = new Category { Id = 1, Name = "Beverages" }; @@ -293,7 +295,8 @@ public Task Can_add_multiple_existing_entities_to_set_to_be_deleted() private static Task TrackMultipleEntitiesTest( Action categoryAdder, - Action productAdder, EntityState expectedState) + Action productAdder, + EntityState expectedState) => TrackMultipleEntitiesTest( (c, e) => { @@ -309,7 +312,8 @@ private static Task TrackMultipleEntitiesTest( private static async Task TrackMultipleEntitiesTest( Func categoryAdder, - Func productAdder, EntityState expectedState) + Func productAdder, + EntityState expectedState) { using var context = new EarlyLearningCenter(); var category1 = new Category { Id = 1, Name = "Beverages" }; @@ -434,7 +438,8 @@ public Task Can_add_multiple_existing_entities_to_set_to_be_updated_Enumerable_g private static Task TrackMultipleEntitiesTestEnumerable( Action> categoryAdder, - Action> productAdder, EntityState expectedState) + Action> productAdder, + EntityState expectedState) => TrackMultipleEntitiesTestEnumerable( (c, e) => { @@ -450,7 +455,8 @@ private static Task TrackMultipleEntitiesTestEnumerable( private static async Task TrackMultipleEntitiesTestEnumerable( Func, Task> categoryAdder, - Func, Task> productAdder, EntityState expectedState) + Func, Task> productAdder, + EntityState expectedState) { using var context = new EarlyLearningCenter(); var category1 = new Category { Id = 1, Name = "Beverages" }; diff --git a/test/EFCore.Tests/EntitySetFinderTest.cs b/test/EFCore.Tests/EntitySetFinderTest.cs index dfca1f27b90..5b184aa13a3 100644 --- a/test/EFCore.Tests/EntitySetFinderTest.cs +++ b/test/EFCore.Tests/EntitySetFinderTest.cs @@ -38,7 +38,8 @@ public class Streets : DbContext public DbSet Yous { get; set; } protected DbSet Betters { get; set; } - internal DbSet Stops => null; + internal DbSet Stops + => null; } public class The : Streets diff --git a/test/EFCore.Tests/ExceptionTest.cs b/test/EFCore.Tests/ExceptionTest.cs index 4c2e2478bdc..39240c619e9 100644 --- a/test/EFCore.Tests/ExceptionTest.cs +++ b/test/EFCore.Tests/ExceptionTest.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -156,23 +155,51 @@ public void Deserialized_DbUpdateConcurrencyException_can_be_serialized_and_dese private class FakeUpdateEntry : IUpdateEntry { - public void SetOriginalValue(IProperty property, object value) => throw new NotImplementedException(); - public void SetPropertyModified(IProperty property) => throw new NotImplementedException(); + public void SetOriginalValue(IProperty property, object value) + => throw new NotImplementedException(); + + public void SetPropertyModified(IProperty property) + => throw new NotImplementedException(); + public IEntityType EntityType { get; } public EntityState EntityState { get; set; } public IUpdateEntry SharedIdentityEntry { get; } - public bool IsModified(IProperty property) => throw new NotImplementedException(); - public bool HasTemporaryValue(IProperty property) => throw new NotImplementedException(); - public bool IsStoreGenerated(IProperty property) => throw new NotImplementedException(); - public object GetCurrentValue(IPropertyBase propertyBase) => throw new NotImplementedException(); - public object GetOriginalValue(IPropertyBase propertyBase) => throw new NotImplementedException(); - public TProperty GetCurrentValue(IPropertyBase propertyBase) => throw new NotImplementedException(); - public TProperty GetOriginalValue(IProperty property) => throw new NotImplementedException(); - public void SetStoreGeneratedValue(IProperty property, object value) => throw new NotImplementedException(); - public EntityEntry ToEntityEntry() => new EntityEntry(new FakeInternalEntityEntry()); - public object GetRelationshipSnapshotValue(IPropertyBase propertyBase) => throw new NotImplementedException(); - public object GetPreStoreGeneratedCurrentValue(IPropertyBase propertyBase) => throw new NotImplementedException(); - public bool IsConceptualNull(IProperty property) => throw new NotImplementedException(); + + public bool IsModified(IProperty property) + => throw new NotImplementedException(); + + public bool HasTemporaryValue(IProperty property) + => throw new NotImplementedException(); + + public bool IsStoreGenerated(IProperty property) + => throw new NotImplementedException(); + + public object GetCurrentValue(IPropertyBase propertyBase) + => throw new NotImplementedException(); + + public object GetOriginalValue(IPropertyBase propertyBase) + => throw new NotImplementedException(); + + public TProperty GetCurrentValue(IPropertyBase propertyBase) + => throw new NotImplementedException(); + + public TProperty GetOriginalValue(IProperty property) + => throw new NotImplementedException(); + + public void SetStoreGeneratedValue(IProperty property, object value) + => throw new NotImplementedException(); + + public EntityEntry ToEntityEntry() + => new EntityEntry(new FakeInternalEntityEntry()); + + public object GetRelationshipSnapshotValue(IPropertyBase propertyBase) + => throw new NotImplementedException(); + + public object GetPreStoreGeneratedCurrentValue(IPropertyBase propertyBase) + => throw new NotImplementedException(); + + public bool IsConceptualNull(IProperty property) + => throw new NotImplementedException(); } private class FakeInternalEntityEntry : InternalEntityEntry diff --git a/test/EFCore.Tests/Extensions/PropertyExtensionsTest.cs b/test/EFCore.Tests/Extensions/PropertyExtensionsTest.cs index 17bd1e7008f..b796953695a 100644 --- a/test/EFCore.Tests/Extensions/PropertyExtensionsTest.cs +++ b/test/EFCore.Tests/Extensions/PropertyExtensionsTest.cs @@ -292,7 +292,8 @@ private class OrderDetails public Product Product { get; set; } } - private static IMutableModel CreateModel() => new Model(); + private static IMutableModel CreateModel() + => new Model(); private IMutableModel BuildModel() { diff --git a/test/EFCore.Tests/Extensions/QueryableExtensionsTest.cs b/test/EFCore.Tests/Extensions/QueryableExtensionsTest.cs index 2f6b7ce8d91..555fdb9014f 100644 --- a/test/EFCore.Tests/Extensions/QueryableExtensionsTest.cs +++ b/test/EFCore.Tests/Extensions/QueryableExtensionsTest.cs @@ -177,10 +177,17 @@ var cancellationTokenPresent return default; } - public IQueryable CreateQuery(Expression expression) => throw new NotImplementedException(); - public IQueryable CreateQuery(Expression expression) => throw new NotImplementedException(); - public object Execute(Expression expression) => throw new NotImplementedException(); - public TResult Execute(Expression expression) => throw new NotImplementedException(); + public IQueryable CreateQuery(Expression expression) + => throw new NotImplementedException(); + + public IQueryable CreateQuery(Expression expression) + => throw new NotImplementedException(); + + public object Execute(Expression expression) + => throw new NotImplementedException(); + + public TResult Execute(Expression expression) + => throw new NotImplementedException(); } private class FakeQueryable : IQueryable @@ -190,14 +197,18 @@ public FakeQueryable(IQueryProvider provider = null) Provider = provider; } - public Type ElementType => typeof(TElement); + public Type ElementType + => typeof(TElement); public Expression Expression { get; set; } public IQueryProvider Provider { get; } - public IEnumerator GetEnumerator() => throw new NotImplementedException(); - IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException(); + public IEnumerator GetEnumerator() + => throw new NotImplementedException(); + + IEnumerator IEnumerable.GetEnumerator() + => throw new NotImplementedException(); } [ConditionalFact] @@ -303,7 +314,8 @@ public async Task Extension_methods_throw_on_non_async_source() await SourceNonAsyncEnumerableTest(() => Source().ToDictionaryAsync(e => e, e => e)); await SourceNonAsyncEnumerableTest(() => Source().ToDictionaryAsync(e => e, LegacyReferenceEqualityComparer.Instance)); await SourceNonAsyncEnumerableTest(() => Source().ToDictionaryAsync(e => e, LegacyReferenceEqualityComparer.Instance)); - await SourceNonAsyncEnumerableTest(() => Source().ToDictionaryAsync(e => e, e => e, LegacyReferenceEqualityComparer.Instance)); + await SourceNonAsyncEnumerableTest( + () => Source().ToDictionaryAsync(e => e, e => e, LegacyReferenceEqualityComparer.Instance)); await SourceNonAsyncEnumerableTest( () => Source().ToDictionaryAsync(e => e, e => e, LegacyReferenceEqualityComparer.Instance, new CancellationToken())); await SourceNonAsyncEnumerableTest(() => Source().ToListAsync()); @@ -313,12 +325,14 @@ await SourceNonAsyncEnumerableTest( Assert.Throws(() => Source().AsAsyncEnumerable()).Message); } - private static IQueryable Source() => new FakeQueryable(); + private static IQueryable Source() + => new FakeQueryable(); - private static IQueryable Source() => Source(); + private static IQueryable Source() + => Source(); - private static async Task SourceNonAsyncQueryableTest(Func test) => - Assert.Equal( + private static async Task SourceNonAsyncQueryableTest(Func test) + => Assert.Equal( CoreStrings.IQueryableProviderNotAsync, (await Assert.ThrowsAsync(test)).Message); diff --git a/test/EFCore.Tests/Infrastructure/CoreEventIdTest.cs b/test/EFCore.Tests/Infrastructure/CoreEventIdTest.cs index 99f93f190df..951975d4a57 100644 --- a/test/EFCore.Tests/Infrastructure/CoreEventIdTest.cs +++ b/test/EFCore.Tests/Infrastructure/CoreEventIdTest.cs @@ -5,11 +5,9 @@ using System.Collections.Generic; using System.Linq.Expressions; using System.Reflection; -using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -85,7 +83,8 @@ public void Every_eventId_has_a_logger_method_and_logs_when_level_enabled() private class FakeServiceProvider : IServiceProvider { - public object GetService(Type serviceType) => null; + public object GetService(Type serviceType) + => null; } private class FakeInternalEntityEntry : InternalEntityEntry @@ -106,17 +105,22 @@ public FakeNavigationBase(string name, ConfigurationSource configurationSource, DeclaringType = entityType; } - public IEntityType DeclaringEntityType => (IEntityType)DeclaringType; + public IEntityType DeclaringEntityType + => (IEntityType)DeclaringType; - public IEntityType TargetEntityType => throw new NotImplementedException(); + public IEntityType TargetEntityType + => throw new NotImplementedException(); - public INavigationBase Inverse => throw new NotImplementedException(); + public INavigationBase Inverse + => throw new NotImplementedException(); - public bool IsCollection => throw new NotImplementedException(); + public bool IsCollection + => throw new NotImplementedException(); public override TypeBase DeclaringType { get; } - public override Type ClrType => throw new NotImplementedException(); + public override Type ClrType + => throw new NotImplementedException(); public IClrCollectionAccessor GetCollectionAccessor() { diff --git a/test/EFCore.Tests/Infrastructure/DiagnosticsLoggerTest.cs b/test/EFCore.Tests/Infrastructure/DiagnosticsLoggerTest.cs index 4f4785587c5..9c0e76e102e 100644 --- a/test/EFCore.Tests/Infrastructure/DiagnosticsLoggerTest.cs +++ b/test/EFCore.Tests/Infrastructure/DiagnosticsLoggerTest.cs @@ -46,11 +46,14 @@ private void FilterTest(Func filter, params string[] expected) var loggerFactory = new ListLoggerFactory(filter); var dbLogger = new DiagnosticsLogger( - loggerFactory, new LoggingOptions(), new DiagnosticListener("Fake"), new TestLoggingDefinitions(), new NullDbContextLogger()); + loggerFactory, new LoggingOptions(), new DiagnosticListener("Fake"), new TestLoggingDefinitions(), + new NullDbContextLogger()); var sqlLogger = new DiagnosticsLogger( - loggerFactory, new LoggingOptions(), new DiagnosticListener("Fake"), new TestLoggingDefinitions(), new NullDbContextLogger()); + loggerFactory, new LoggingOptions(), new DiagnosticListener("Fake"), new TestLoggingDefinitions(), + new NullDbContextLogger()); var queryLogger = new DiagnosticsLogger( - loggerFactory, new LoggingOptions(), new DiagnosticListener("Fake"), new TestLoggingDefinitions(), new NullDbContextLogger()); + loggerFactory, new LoggingOptions(), new DiagnosticListener("Fake"), new TestLoggingDefinitions(), + new NullDbContextLogger()); var randomLogger = loggerFactory.CreateLogger("Random"); dbLogger.Logger.LogInformation(1, "DB1"); diff --git a/test/EFCore.Tests/Infrastructure/EntityFrameworkServicesBuilderTest.cs b/test/EFCore.Tests/Infrastructure/EntityFrameworkServicesBuilderTest.cs index d9a2914ced2..5e31082a51e 100644 --- a/test/EFCore.Tests/Infrastructure/EntityFrameworkServicesBuilderTest.cs +++ b/test/EFCore.Tests/Infrastructure/EntityFrameworkServicesBuilderTest.cs @@ -334,9 +334,11 @@ public void InitializeSets(DbContext context) } public DbSet CreateSet(DbContext context) - where TEntity : class => throw new NotImplementedException(); + where TEntity : class + => throw new NotImplementedException(); - public object CreateSet(DbContext context, Type type) => throw new NotImplementedException(); + public object CreateSet(DbContext context, Type type) + => throw new NotImplementedException(); } private class FakeResetableService : IResettableService @@ -345,7 +347,8 @@ public void ResetState() { } - public Task ResetStateAsync(CancellationToken cancellationToken = default) => Task.CompletedTask; + public Task ResetStateAsync(CancellationToken cancellationToken = default) + => Task.CompletedTask; } private static DbContext CreateContext(IServiceProvider serviceProvider) diff --git a/test/EFCore.Tests/Infrastructure/EventIdTestBase.cs b/test/EFCore.Tests/Infrastructure/EventIdTestBase.cs index 3e63456c1a7..e638cb6e617 100644 --- a/test/EFCore.Tests/Infrastructure/EventIdTestBase.cs +++ b/test/EFCore.Tests/Infrastructure/EventIdTestBase.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.Logging; using Xunit; @@ -92,7 +91,13 @@ public void TestEventLogging( } catch (Exception) { - Assert.True(false, "Need to add fake test factory for type " + type.DisplayName() + " in class " + eventIdType.Name + "Test"); + Assert.True( + false, + "Need to add fake test factory for type " + + type.DisplayName() + + " in class " + + eventIdType.Name + + "Test"); } } } diff --git a/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs b/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs index 3ac4b7a3d98..5f6c05ad8b3 100644 --- a/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs +++ b/test/EFCore.Tests/Infrastructure/ModelValidatorTest.cs @@ -88,9 +88,9 @@ public virtual void Detects_custom_converter_for_collection_type_without_compare var convertedProperty = CreateConvertedCollectionProperty(); VerifyWarning( - CoreResources.LogCollectionWithoutComparer( - new TestLogger()).GenerateMessage("SomeStrings", "WithCollectionConversion"), - convertedProperty.DeclaringEntityType.Model); + CoreResources.LogCollectionWithoutComparer( + new TestLogger()).GenerateMessage("SomeStrings", "WithCollectionConversion"), + convertedProperty.DeclaringEntityType.Model); } [ConditionalFact] @@ -558,7 +558,8 @@ public virtual void Passes_on_valid_many_to_many_navigations() .GetForeignKeys().Single(fk => fk.PrincipalEntityType == orderEntity); var productOrderForeignKey = orderProductEntity .GetForeignKeys().Single(fk => fk.PrincipalEntityType == productEntity); - orderProductEntity.SetPrimaryKey(new[] { orderProductForeignKey.Properties.Single(), productOrderForeignKey.Properties.Single() }); + orderProductEntity.SetPrimaryKey( + new[] { orderProductForeignKey.Properties.Single(), productOrderForeignKey.Properties.Single() }); var productsNavigation = orderEntity.AddSkipNavigation( nameof(Order.Products), null, productEntity, true, false); @@ -587,7 +588,8 @@ public virtual void Detects_missing_foreign_key_for_skip_navigations() .GetForeignKeys().Single(fk => fk.PrincipalEntityType == orderEntity); var productOrderForeignKey = orderProductEntity .GetForeignKeys().Single(fk => fk.PrincipalEntityType == productEntity); - orderProductEntity.SetPrimaryKey(new[] { orderProductForeignKey.Properties.Single(), productOrderForeignKey.Properties.Single() }); + orderProductEntity.SetPrimaryKey( + new[] { orderProductForeignKey.Properties.Single(), productOrderForeignKey.Properties.Single() }); var productsNavigation = orderEntity.AddSkipNavigation( nameof(Order.Products), null, productEntity, true, false); @@ -610,7 +612,8 @@ public virtual void Detects_missing_inverse_skip_navigations() .GetForeignKeys().Single(fk => fk.PrincipalEntityType == orderEntity); var productOrderForeignKey = orderProductEntity .GetForeignKeys().Single(fk => fk.PrincipalEntityType == productEntity); - orderProductEntity.SetPrimaryKey(new[] { orderProductForeignKey.Properties.Single(), productOrderForeignKey.Properties.Single() }); + orderProductEntity.SetPrimaryKey( + new[] { orderProductForeignKey.Properties.Single(), productOrderForeignKey.Properties.Single() }); var productsNavigation = orderEntity.AddSkipNavigation( nameof(Order.Products), null, productEntity, true, false); @@ -668,7 +671,10 @@ public virtual void Detects_weak_entity_type_without_defining_navigation() VerifyError( CoreStrings.NoDefiningNavigation( nameof(SampleEntityMinimal.ReferencedEntity), - nameof(SampleEntityMinimal) + "." + nameof(SampleEntityMinimal.ReferencedEntity) + "#" + nameof(SampleEntityMinimal) + + "." + + nameof(SampleEntityMinimal.ReferencedEntity) + + "#" + nameof(ReferencedEntityMinimal), nameof(SampleEntityMinimal)), modelBuilder.Metadata); @@ -732,7 +738,10 @@ public virtual void Detects_weak_entity_type_with_non_defining_ownership() CoreStrings.NonDefiningOwnership( nameof(SampleEntityMinimal), nameof(SampleEntityMinimal.ReferencedEntity), - nameof(SampleEntityMinimal) + "." + nameof(SampleEntityMinimal.ReferencedEntity) + "#" + nameof(SampleEntityMinimal) + + "." + + nameof(SampleEntityMinimal.ReferencedEntity) + + "#" + nameof(ReferencedEntityMinimal)), modelBuilder.Metadata); } @@ -760,9 +769,15 @@ public virtual void Detects_weak_entity_type_without_ownership() VerifyError( CoreStrings.InconsistentOwnership( - nameof(SampleEntityMinimal) + "." + nameof(SampleEntityMinimal.ReferencedEntity) + "#" + nameof(SampleEntityMinimal) + + "." + + nameof(SampleEntityMinimal.ReferencedEntity) + + "#" + nameof(ReferencedEntityMinimal), - nameof(AnotherSampleEntityMinimal) + "." + nameof(AnotherSampleEntityMinimal.ReferencedEntity) + "#" + nameof(AnotherSampleEntityMinimal) + + "." + + nameof(AnotherSampleEntityMinimal.ReferencedEntity) + + "#" + nameof(ReferencedEntityMinimal)), modelBuilder.Metadata); } diff --git a/test/EFCore.Tests/Infrastructure/ModelValidatorTestBase.cs b/test/EFCore.Tests/Infrastructure/ModelValidatorTestBase.cs index 80233098455..9e047662cf6 100644 --- a/test/EFCore.Tests/Infrastructure/ModelValidatorTestBase.cs +++ b/test/EFCore.Tests/Infrastructure/ModelValidatorTestBase.cs @@ -61,7 +61,9 @@ protected IMutableForeignKey CreateForeignKey(IMutableKey dependentKey, IMutable => CreateForeignKey(dependentKey.DeclaringEntityType, dependentKey.Properties, principalKey); protected IMutableForeignKey CreateForeignKey( - IMutableEntityType dependEntityType, IReadOnlyList dependentProperties, IMutableKey principalKey) + IMutableEntityType dependEntityType, + IReadOnlyList dependentProperties, + IMutableKey principalKey) { var foreignKey = dependEntityType.AddForeignKey(dependentProperties, principalKey, principalKey.DeclaringEntityType); foreignKey.IsUnique = true; @@ -285,7 +287,8 @@ protected virtual void VerifyLogDoesNotContain(string expectedMessage, IMutableM Assert.Empty(logEntries); } - protected virtual IModel Validate(IMutableModel model) => model.FinalizeModel(); + protected virtual IModel Validate(IMutableModel model) + => model.FinalizeModel(); protected DiagnosticsLogger CreateValidationLogger(bool sensitiveDataLoggingEnabled = false) { @@ -332,12 +335,14 @@ protected IServiceProvider CreateServiceProvider(bool sensitiveDataLoggingEnable => TestHelpers.CreateContextServices( new ServiceCollection() .AddScoped>(_ => CreateModelLogger(sensitiveDataLoggingEnabled)) - .AddScoped>(_ => CreateValidationLogger(sensitiveDataLoggingEnabled))); + .AddScoped>( + _ => CreateValidationLogger(sensitiveDataLoggingEnabled))); protected ProviderConventionSetBuilderDependencies CreateDependencies(bool sensitiveDataLoggingEnabled = false) => CreateServiceProvider(sensitiveDataLoggingEnabled).GetRequiredService(); - protected virtual TestHelpers TestHelpers => InMemoryTestHelpers.Instance; + protected virtual TestHelpers TestHelpers + => InMemoryTestHelpers.Instance; protected virtual InternalModelBuilder CreateConventionlessInternalModelBuilder() => (InternalModelBuilder)CreateConventionlessModelBuilder().GetInfrastructure(); diff --git a/test/EFCore.Tests/Metadata/Conventions/BackingFieldConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/BackingFieldConventionTest.cs index 7e912cfd1cb..32d31a2623a 100644 --- a/test/EFCore.Tests/Metadata/Conventions/BackingFieldConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/BackingFieldConventionTest.cs @@ -279,7 +279,8 @@ private void Validate(IMutableProperty property) private ProviderConventionSetBuilderDependencies CreateDependencies() => InMemoryTestHelpers.Instance.CreateContextServices().GetRequiredService(); - private static IMutableModel CreateModel() => new Model(); + private static IMutableModel CreateModel() + => new Model(); #pragma warning disable RCS1222 // Merge preprocessor directives. #pragma warning disable 649, 169 @@ -490,7 +491,8 @@ private class IndexedClass private string m_nation; private string m_Nation; - public object this[string name] => null; + public object this[string name] + => null; } #pragma warning disable RCS1222 // Merge preprocessor directives. diff --git a/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs b/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs index 97e17efacdd..17e8f8d7cef 100644 --- a/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs @@ -331,7 +331,8 @@ public EntityTypeAddedConvention(bool terminate, bool onlyWeak) } public void ProcessEntityTypeAdded( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionContext context) { Assert.Same(entityTypeBuilder, entityTypeBuilder.Metadata.Builder); if (entityTypeBuilder.Metadata.HasDefiningNavigation() == _onlyWeak) @@ -429,7 +430,10 @@ public EntityTypeIgnoredConvention(bool terminate) } public void ProcessEntityTypeIgnored( - IConventionModelBuilder modelBuilder, string name, Type type, IConventionContext context) + IConventionModelBuilder modelBuilder, + string name, + Type type, + IConventionContext context) { Assert.Null(modelBuilder.Metadata.FindEntityType(name)); Calls++; @@ -452,7 +456,9 @@ public EntityTypeRemovedConvention(bool terminate) } public void ProcessEntityTypeRemoved( - IConventionModelBuilder modelBuilder, IConventionEntityType entityType, IConventionContext context) + IConventionModelBuilder modelBuilder, + IConventionEntityType entityType, + IConventionContext context) { Assert.Null(modelBuilder.Metadata.FindEntityType(entityType.Name)); Calls++; @@ -531,7 +537,9 @@ public EntityTypeMemberIgnoredConvention(bool terminate) } public void ProcessEntityTypeMemberIgnored( - IConventionEntityTypeBuilder entityTypeBuilder, string name, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + string name, + IConventionContext context) { Assert.NotNull(entityTypeBuilder.Metadata.Builder); @@ -625,7 +633,9 @@ public EntityTypeBaseTypeChangedConvention(bool terminate) } public void ProcessEntityTypeBaseTypeChanged( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionEntityType newBaseType, IConventionEntityType oldBaseType, + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionEntityType newBaseType, + IConventionEntityType oldBaseType, IConventionContext context) { Assert.NotNull(entityTypeBuilder.Metadata.Builder); @@ -671,7 +681,7 @@ public void OnPrimaryKeyChanged_calls_conventions_in_order(bool useBuilder, bool Assert.NotNull( entityBuilder.Metadata.SetPrimaryKey( entityBuilder.Property("OrderId", ConfigurationSource.Convention).Metadata, - ConfigurationSource.Convention)); + ConfigurationSource.Convention)); } if (useScope) @@ -695,7 +705,7 @@ public void OnPrimaryKeyChanged_calls_conventions_in_order(bool useBuilder, bool Assert.NotNull( entityBuilder.Metadata.SetPrimaryKey( entityBuilder.Property("OrderId", ConfigurationSource.Convention).Metadata, - ConfigurationSource.Convention)); + ConfigurationSource.Convention)); } Assert.Equal(new string[] { null }, convention1.Calls); @@ -904,7 +914,8 @@ public ForeignKeyAddedConvention(bool terminate) } public void ProcessForeignKeyAdded( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { var fk = relationshipBuilder.Metadata; Assert.NotNull(fk.Builder); @@ -1107,7 +1118,8 @@ public ForeignKeyPrincipalEndChangedConvention(bool terminate) } public void ProcessForeignKeyPrincipalEndChanged( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { Assert.NotNull(relationshipBuilder.Metadata.Builder); @@ -1188,8 +1200,11 @@ public void ProcessForeignKeyPropertiesChanged( if (relationshipBuilder.Metadata.Properties.First().Name == "FK2") { relationshipBuilder.Metadata.SetProperties( - new[] { relationshipBuilder.Metadata.DeclaringEntityType.Builder.Property( - typeof(int), "FK3").Metadata }, + new[] + { + relationshipBuilder.Metadata.DeclaringEntityType.Builder.Property( + typeof(int), "FK3").Metadata + }, relationshipBuilder.Metadata.PrincipalKey); context.StopProcessingIfChanged(relationshipBuilder.Metadata.Properties); } @@ -1288,7 +1303,8 @@ public ForeignKeyUniquenessChangedConvention(bool terminate) } public void ProcessForeignKeyUniquenessChanged( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { Assert.NotNull(relationshipBuilder.Metadata.Builder); @@ -1388,7 +1404,8 @@ public ForeignKeyRequirednessChangedConvention(bool terminate) } public void ProcessForeignKeyRequirednessChanged( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { Assert.NotNull(relationshipBuilder.Metadata.Builder); @@ -1490,7 +1507,8 @@ public ForeignKeyDependentRequirednessChangedConvention(bool terminate) } public void ProcessForeignKeyDependentRequirednessChanged( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { Assert.NotNull(relationshipBuilder.Metadata.Builder); @@ -1591,7 +1609,8 @@ public ForeignKeyOwnershipChangedConvention(bool terminate) } public void ProcessForeignKeyOwnershipChanged( - IConventionForeignKeyBuilder relationshipBuilder, IConventionContext context) + IConventionForeignKeyBuilder relationshipBuilder, + IConventionContext context) { Assert.NotNull(relationshipBuilder.Metadata.Builder); @@ -1782,7 +1801,8 @@ public NavigationAddedConvention(bool terminate) } public void ProcessNavigationAdded( - IConventionNavigationBuilder navigationBuilder, IConventionContext context) + IConventionNavigationBuilder navigationBuilder, + IConventionContext context) { var navigation = navigationBuilder.Metadata; var foreignKey = navigation.ForeignKey; @@ -1827,7 +1847,7 @@ public void OnNavigationAnnotationChanged_calls_conventions_in_order(bool useBui var principalEntityBuilder = builder.Entity(typeof(Order), ConfigurationSource.Convention); var dependentEntityBuilder = builder.Entity(typeof(OrderDetails), ConfigurationSource.Convention); var navigation = dependentEntityBuilder.HasRelationship( - principalEntityBuilder.Metadata, OrderDetails.OrderProperty, ConfigurationSource.Convention) + principalEntityBuilder.Metadata, OrderDetails.OrderProperty, ConfigurationSource.Convention) .Metadata.DependentToPrincipal; var scope = useScope ? builder.Metadata.ConventionDispatcher.DelayConventions() : null; @@ -1989,8 +2009,11 @@ public NavigationRemovedConvention(bool terminate) } public void ProcessNavigationRemoved( - IConventionEntityTypeBuilder sourceEntityTypeBuilder, IConventionEntityTypeBuilder targetEntityTypeBuilder, - string navigationName, MemberInfo memberInfo, IConventionContext context) + IConventionEntityTypeBuilder sourceEntityTypeBuilder, + IConventionEntityTypeBuilder targetEntityTypeBuilder, + string navigationName, + MemberInfo memberInfo, + IConventionContext context) { Assert.NotNull(sourceEntityTypeBuilder.Metadata.Builder); @@ -2098,7 +2121,7 @@ public void OnSkipNavigationAnnotationChanged_calls_conventions_in_order(bool us var secondEntityBuilder = builder.Entity(typeof(Product), ConfigurationSource.Convention); var navigation = firstEntityBuilder.Metadata.AddSkipNavigation( - nameof(Order.Products), null, secondEntityBuilder.Metadata, true, false, ConfigurationSource.Convention); + nameof(Order.Products), null, secondEntityBuilder.Metadata, true, false, ConfigurationSource.Convention); var scope = useScope ? builder.Metadata.ConventionDispatcher.DelayConventions() : null; @@ -2240,8 +2263,8 @@ public void OnSkipNavigationForeignKeyChanged_calls_conventions_in_order(bool us navigation.SetForeignKey(null, ConfigurationSource.Explicit); } - Assert.Equal(new ForeignKey[] { foreignKey, null }, convention1.Calls); - Assert.Equal(new ForeignKey[] { foreignKey, null }, convention2.Calls); + Assert.Equal(new[] { foreignKey, null }, convention1.Calls); + Assert.Equal(new[] { foreignKey, null }, convention2.Calls); Assert.Empty(convention3.Calls); } @@ -2339,6 +2362,7 @@ public void OnSkipNavigationInverseChanged_calls_conventions_in_order(bool useBu Assert.Equal(new[] { nameof(Product.Orders) }, convention1.Calls); Assert.Equal(new[] { nameof(Product.Orders) }, convention2.Calls); } + Assert.Empty(convention3.Calls); } @@ -2565,7 +2589,9 @@ public KeyRemovedConvention(bool terminate) } public void ProcessKeyRemoved( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionKey key, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionKey key, + IConventionContext context) { Assert.NotNull(entityTypeBuilder.Metadata.Builder); @@ -2664,7 +2690,9 @@ public KeyAnnotationChangedConvention(bool terminate) public void ProcessKeyAnnotationChanged( IConventionKeyBuilder keyBuilder, - string name, IConventionAnnotation annotation, IConventionAnnotation oldAnnotation, + string name, + IConventionAnnotation annotation, + IConventionAnnotation oldAnnotation, IConventionContext context) { Assert.NotNull(keyBuilder.Metadata.Builder); @@ -2806,7 +2834,9 @@ public IndexRemovedConvention(bool terminate) } public void ProcessIndexRemoved( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionIndex index, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionIndex index, + IConventionContext context) { Assert.NotNull(entityTypeBuilder.Metadata.Builder); @@ -2902,7 +2932,8 @@ public IndexUniquenessChangedConvention(bool terminate) } public void ProcessIndexUniquenessChanged( - IConventionIndexBuilder indexBuilder, IConventionContext context) + IConventionIndexBuilder indexBuilder, + IConventionContext context) { Assert.NotNull(indexBuilder.Metadata.Builder); @@ -3002,7 +3033,8 @@ public void ProcessIndexAnnotationChanged( IConventionIndexBuilder indexBuilder, string name, IConventionAnnotation annotation, - IConventionAnnotation oldAnnotation, IConventionContext context) + IConventionAnnotation oldAnnotation, + IConventionContext context) { Assert.NotNull(indexBuilder.Metadata.Builder); @@ -3102,7 +3134,8 @@ public PropertyAddedConvention(bool terminate) } public void ProcessPropertyAdded( - IConventionPropertyBuilder propertyBuilder, IConventionContext context) + IConventionPropertyBuilder propertyBuilder, + IConventionContext context) { Assert.NotNull(propertyBuilder.Metadata.Builder); @@ -3240,7 +3273,8 @@ public PropertyNullabilityChangedConvention(bool terminate) } public void ProcessPropertyNullabilityChanged( - IConventionPropertyBuilder propertyBuilder, IConventionContext context) + IConventionPropertyBuilder propertyBuilder, + IConventionContext context) { Calls.Add(propertyBuilder.Metadata.IsNullable); @@ -3279,7 +3313,8 @@ public void OnPropertyFieldChanged_calls_conventions_in_order(bool useBuilder, b } else { - propertyBuilder.Metadata.SetField(nameof(Order.IntField), + propertyBuilder.Metadata.SetField( + nameof(Order.IntField), ConfigurationSource.Convention); } @@ -3300,7 +3335,8 @@ public void OnPropertyFieldChanged_calls_conventions_in_order(bool useBuilder, b } else { - propertyBuilder.Metadata.SetField(nameof(Order.IntField), + propertyBuilder.Metadata.SetField( + nameof(Order.IntField), ConfigurationSource.Convention); } @@ -3314,7 +3350,8 @@ public void OnPropertyFieldChanged_calls_conventions_in_order(bool useBuilder, b } else { - propertyBuilder.Metadata.SetFieldInfo((FieldInfo)null, + propertyBuilder.Metadata.SetFieldInfo( + null, ConfigurationSource.Convention); } @@ -3334,7 +3371,9 @@ public PropertyFieldChangedConvention(bool terminate) } public void ProcessPropertyFieldChanged( - IConventionPropertyBuilder propertyBuilder, FieldInfo newFieldInfo, FieldInfo oldFieldInfo, + IConventionPropertyBuilder propertyBuilder, + FieldInfo newFieldInfo, + FieldInfo oldFieldInfo, IConventionContext context) { Assert.NotNull(propertyBuilder.Metadata.Builder); @@ -3435,7 +3474,8 @@ public void ProcessPropertyAnnotationChanged( IConventionPropertyBuilder propertyBuilder, string name, IConventionAnnotation annotation, - IConventionAnnotation oldAnnotation, IConventionContext context) + IConventionAnnotation oldAnnotation, + IConventionContext context) { Assert.NotNull(propertyBuilder.Metadata.Builder); @@ -3466,7 +3506,7 @@ public void OnPropertyRemoved_calls_conventions_in_order(bool useScope) var entityBuilder = builder.Entity(typeof(Order), ConfigurationSource.Convention); var shadowPropertyName = "ShadowProperty"; var property = entityBuilder.Metadata.AddProperty( - shadowPropertyName, typeof(int), ConfigurationSource.Convention, ConfigurationSource.Convention); + shadowPropertyName, typeof(int), ConfigurationSource.Convention, ConfigurationSource.Convention); var scope = useScope ? builder.Metadata.ConventionDispatcher.DelayConventions() : null; diff --git a/test/EFCore.Tests/Metadata/Conventions/ConventionSetBuilderTests.cs b/test/EFCore.Tests/Metadata/Conventions/ConventionSetBuilderTests.cs index 20817600de6..5458fcf520b 100644 --- a/test/EFCore.Tests/Metadata/Conventions/ConventionSetBuilderTests.cs +++ b/test/EFCore.Tests/Metadata/Conventions/ConventionSetBuilderTests.cs @@ -35,8 +35,11 @@ public virtual IModel Can_build_a_model_with_default_conventions_without_DI_new( return model; } - protected virtual ConventionSet GetConventionSet() => InMemoryConventionSetBuilder.Build(); - protected virtual ModelBuilder GetModelBuilder() => InMemoryConventionSetBuilder.CreateModelBuilder(); + protected virtual ConventionSet GetConventionSet() + => InMemoryConventionSetBuilder.Build(); + + protected virtual ModelBuilder GetModelBuilder() + => InMemoryConventionSetBuilder.CreateModelBuilder(); [Table("ProductTable")] protected class Product diff --git a/test/EFCore.Tests/Metadata/Conventions/EntityTypeAttributeConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/EntityTypeAttributeConventionTest.cs index ea925e829fe..5e5018adb63 100644 --- a/test/EFCore.Tests/Metadata/Conventions/EntityTypeAttributeConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/EntityTypeAttributeConventionTest.cs @@ -69,7 +69,8 @@ public void OwnedAttribute_configures_entity_as_owned() modelBuilder.Entity(); Assert.Equal(2, modelBuilder.Model.GetEntityTypes().Count()); - Assert.True(modelBuilder.Model.FindEntityType(typeof(Customer)).FindNavigation(nameof(Customer.Address)).ForeignKey.IsOwnership); + Assert.True( + modelBuilder.Model.FindEntityType(typeof(Customer)).FindNavigation(nameof(Customer.Address)).ForeignKey.IsOwnership); } [ConditionalFact] diff --git a/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs index 9dbf2005808..4956b26322e 100644 --- a/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/ForeignKeyPropertyDiscoveryConventionTest.cs @@ -508,10 +508,10 @@ public void Does_not_match_principal_type_plus_PK_name_property_of_different_typ Assert.Equal( CoreResources.LogIncompatibleMatchingForeignKeyProperties( new TestLogger()).GenerateMessage( - nameof(DependentEntity) + "." + nameof(DependentEntity.SomeNav), - nameof(PrincipalEntity), - "{'PrincipalEntityPeeKay' : string}", - "{'PeeKay' : int}"), + nameof(DependentEntity) + "." + nameof(DependentEntity.SomeNav), + nameof(PrincipalEntity), + "{'PrincipalEntityPeeKay' : string}", + "{'PeeKay' : int}"), logEntry.Message); ValidateModel(); @@ -1167,19 +1167,25 @@ private ProviderConventionSetBuilderDependencies CreateDependencies() public ListLoggerFactory ListLoggerFactory { get; } = new ListLoggerFactory(l => l == DbLoggerCategory.Model.Name); - private Property PrimaryKey => PrincipalType.FindPrimaryKey().Properties.Single(); + private Property PrimaryKey + => PrincipalType.FindPrimaryKey().Properties.Single(); - private EntityType PrincipalType => _model.Entity(typeof(PrincipalEntity), ConfigurationSource.Convention).Metadata; + private EntityType PrincipalType + => _model.Entity(typeof(PrincipalEntity), ConfigurationSource.Convention).Metadata; - private EntityType DependentType => _model.Entity(typeof(DependentEntity), ConfigurationSource.Convention).Metadata; + private EntityType DependentType + => _model.Entity(typeof(DependentEntity), ConfigurationSource.Convention).Metadata; - private IReadOnlyList CompositePrimaryKey => PrincipalTypeWithCompositeKey.FindPrimaryKey().Properties; + private IReadOnlyList CompositePrimaryKey + => PrincipalTypeWithCompositeKey.FindPrimaryKey().Properties; - private EntityType PrincipalTypeWithCompositeKey => _model.Entity( - typeof(PrincipalEntityWithCompositeKey), ConfigurationSource.Convention).Metadata; + private EntityType PrincipalTypeWithCompositeKey + => _model.Entity( + typeof(PrincipalEntityWithCompositeKey), ConfigurationSource.Convention).Metadata; - private EntityType DependentTypeWithCompositeKey => _model.Entity( - typeof(DependentEntityWithCompositeKey), ConfigurationSource.Convention).Metadata; + private EntityType DependentTypeWithCompositeKey + => _model.Entity( + typeof(DependentEntityWithCompositeKey), ConfigurationSource.Convention).Metadata; private class PrincipalEntity { diff --git a/test/EFCore.Tests/Metadata/Conventions/IndexAttributeConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/IndexAttributeConventionTest.cs index f812da95a6d..6ae3de0c428 100644 --- a/test/EFCore.Tests/Metadata/Conventions/IndexAttributeConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/IndexAttributeConventionTest.cs @@ -13,6 +13,7 @@ using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; using Xunit; +using Index = Microsoft.EntityFrameworkCore.Metadata.Internal.Index; // ReSharper disable UnusedMember.Local // ReSharper disable InconsistentNaming @@ -45,7 +46,8 @@ public void IndexAttribute_overrides_configuration_from_convention() Assert.Equal("IndexOnAAndB", index.Name); Assert.True(index.IsUnique); Assert.Equal(ConfigurationSource.DataAnnotation, index.GetIsUniqueConfigurationSource()); - Assert.Collection(index.Properties, + Assert.Collection( + index.Properties, prop0 => Assert.Equal("A", prop0.Name), prop1 => Assert.Equal("B", prop1.Name)); } @@ -61,12 +63,13 @@ public void IndexAttribute_can_be_overriden_using_explicit_configuration() modelBuilder.Model.FinalizeModel(); - var index = (Metadata.Internal.Index)entityBuilder.Metadata.GetIndexes().Single(); + var index = (Index)entityBuilder.Metadata.GetIndexes().Single(); Assert.Equal(ConfigurationSource.Explicit, index.GetConfigurationSource()); Assert.Equal("IndexOnAAndB", index.Name); Assert.False(index.IsUnique); Assert.Equal(ConfigurationSource.Explicit, index.GetIsUniqueConfigurationSource()); - Assert.Collection(index.Properties, + Assert.Collection( + index.Properties, prop0 => Assert.Equal("A", prop0.Name), prop1 => Assert.Equal("B", prop1.Name)); } @@ -106,21 +109,23 @@ public void IndexAttribute_can_be_applied_more_than_once_per_entity_type() var indexes = entityBuilder.Metadata.GetIndexes(); Assert.Equal(2, indexes.Count()); - var index0 = (Metadata.Internal.Index)indexes.First(); + var index0 = (Index)indexes.First(); Assert.Equal(ConfigurationSource.DataAnnotation, index0.GetConfigurationSource()); Assert.Equal("IndexOnAAndB", index0.Name); Assert.True(index0.IsUnique); Assert.Equal(ConfigurationSource.DataAnnotation, index0.GetIsUniqueConfigurationSource()); - Assert.Collection(index0.Properties, + Assert.Collection( + index0.Properties, prop0 => Assert.Equal("A", prop0.Name), prop1 => Assert.Equal("B", prop1.Name)); - var index1 = (Metadata.Internal.Index)indexes.Skip(1).First(); + var index1 = (Index)indexes.Skip(1).First(); Assert.Equal(ConfigurationSource.DataAnnotation, index1.GetConfigurationSource()); Assert.Equal("IndexOnBAndC", index1.Name); Assert.False(index1.IsUnique); Assert.Equal(ConfigurationSource.DataAnnotation, index1.GetIsUniqueConfigurationSource()); - Assert.Collection(index1.Properties, + Assert.Collection( + index1.Properties, prop0 => Assert.Equal("B", prop0.Name), prop1 => Assert.Equal("C", prop1.Name)); } @@ -133,16 +138,18 @@ public void IndexAttribute_can_be_inherited_from_base_entity_type() modelBuilder.Model.FinalizeModel(); // assert that the base type is not part of the model - Assert.Empty(modelBuilder.Model.GetEntityTypes() - .Where(e => e.ClrType == typeof(BaseUnmappedEntityWithIndex))); + Assert.Empty( + modelBuilder.Model.GetEntityTypes() + .Where(e => e.ClrType == typeof(BaseUnmappedEntityWithIndex))); // assert that we see the index anyway - var index = (Metadata.Internal.Index)entityBuilder.Metadata.GetIndexes().Single(); + var index = (Index)entityBuilder.Metadata.GetIndexes().Single(); Assert.Equal(ConfigurationSource.DataAnnotation, index.GetConfigurationSource()); Assert.Equal("IndexOnAAndB", index.Name); Assert.True(index.IsUnique); Assert.Equal(ConfigurationSource.DataAnnotation, index.GetIsUniqueConfigurationSource()); - Assert.Collection(index.Properties, + Assert.Collection( + index.Properties, prop0 => Assert.Equal("A", prop0.Name), prop1 => Assert.Equal("B", prop1.Name)); } @@ -168,7 +175,6 @@ public virtual void IndexAttribute_with_name_and_an_ignored_property_causes_erro var modelBuilder = InMemoryTestHelpers.Instance.CreateConventionBuilder(); var entityBuilder = modelBuilder.Entity(); - Assert.Equal( CoreStrings.NamedIndexDefinedOnIgnoredProperty( "IndexOnAAndIgnoredProperty", @@ -187,9 +193,9 @@ public virtual void IndexAttribute_without_name_and_non_existent_property_causes Assert.Equal( CoreStrings.UnnamedIndexDefinedOnNonExistentProperty( - nameof(EntityUnnamedIndexWithNonExistentProperty), - "{'A', 'DoesNotExist'}", - "DoesNotExist"), + nameof(EntityUnnamedIndexWithNonExistentProperty), + "{'A', 'DoesNotExist'}", + "DoesNotExist"), Assert.Throws( () => modelBuilder.Model.FinalizeModel()).Message); } @@ -202,10 +208,10 @@ public virtual void IndexAttribute_with_name_and_non_existent_property_causes_er Assert.Equal( CoreStrings.NamedIndexDefinedOnNonExistentProperty( - "IndexOnAAndNonExistentProperty", - nameof(EntityIndexWithNonExistentProperty), - "{'A', 'DoesNotExist'}", - "DoesNotExist"), + "IndexOnAAndNonExistentProperty", + nameof(EntityIndexWithNonExistentProperty), + "{'A', 'DoesNotExist'}", + "DoesNotExist"), Assert.Throws( () => modelBuilder.Model.FinalizeModel()).Message); } @@ -232,7 +238,7 @@ public void IndexAttribute_index_replicated_to_derived_type_when_base_type_chang Assert.NotNull(childEntityBuilder.Metadata.BaseType); // The Index is replicated on the Parent type, but not on the Child. - var index = (Metadata.Internal.Index) + var index = (Index) Assert.Single(parentEntityBuilder.Metadata.GetDeclaredIndexes()); Assert.Equal(ConfigurationSource.DataAnnotation, index.GetConfigurationSource()); Assert.Equal("IndexOnGrandparentGetsReplicatedToParent", index.Name); @@ -243,7 +249,7 @@ public void IndexAttribute_index_replicated_to_derived_type_when_base_type_chang // The Child still has its own index even though // the property is defined on the Grandparent type. - var childIndex = (Metadata.Internal.Index) + var childIndex = (Index) Assert.Single(childEntityBuilder.Metadata.GetDeclaredIndexes()); Assert.Equal(ConfigurationSource.DataAnnotation, childIndex.GetConfigurationSource()); Assert.Equal("IndexOnChildUnaffectedWhenParentBaseTypeRemoved", childIndex.Name); @@ -267,12 +273,13 @@ public void IndexAttribute_index_is_created_when_missing_property_added() entityBuilder.Property("Y"); modelBuilder.Model.FinalizeModel(); - var index = (Metadata.Internal.Index) + var index = (Index) Assert.Single(entityBuilder.Metadata.GetDeclaredIndexes()); Assert.Equal(ConfigurationSource.DataAnnotation, index.GetConfigurationSource()); Assert.Equal("IndexOnShadowProperty", index.Name); - Assert.Collection(index.Properties, + Assert.Collection( + index.Properties, prop0 => Assert.Equal("X", prop0.Name), prop1 => Assert.Equal("Y", prop1.Name)); } @@ -284,12 +291,13 @@ public void IndexAttribute_index_is_created_when_index_on_private_property() var entityBuilder = modelBuilder.Entity(typeof(EntityWithIndexOnPrivateProperty)); modelBuilder.Model.FinalizeModel(); - var index = (Metadata.Internal.Index) + var index = (Index) Assert.Single(entityBuilder.Metadata.GetDeclaredIndexes()); Assert.Equal(ConfigurationSource.DataAnnotation, index.GetConfigurationSource()); Assert.Equal("IndexOnPrivateProperty", index.Name); - Assert.Collection(index.Properties, + Assert.Collection( + index.Properties, prop0 => Assert.Equal("X", prop0.Name), prop1 => Assert.Equal("Y", prop1.Name)); } @@ -311,7 +319,8 @@ private void RunConvention(InternalModelBuilder modelBuilder) CreateIndexAttributeConvention().ProcessModelFinalizing(modelBuilder, context); } - private IndexAttributeConvention CreateIndexAttributeConvention() => new IndexAttributeConvention(CreateDependencies()); + private IndexAttributeConvention CreateIndexAttributeConvention() + => new IndexAttributeConvention(CreateDependencies()); private ProviderConventionSetBuilderDependencies CreateDependencies() => InMemoryTestHelpers.Instance.CreateContextServices().GetRequiredService(); @@ -386,6 +395,7 @@ private class EntityUnnamedIndexWithIgnoredProperty { public int Id { get; set; } public int A { get; set; } + [NotMapped] public int B { get; set; } } @@ -395,6 +405,7 @@ private class EntityIndexWithIgnoredProperty { public int Id { get; set; } public int A { get; set; } + [NotMapped] public int B { get; set; } } diff --git a/test/EFCore.Tests/Metadata/Conventions/KeyDiscoveryConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/KeyDiscoveryConventionTest.cs index f3f53bd3593..a2a34463d49 100644 --- a/test/EFCore.Tests/Metadata/Conventions/KeyDiscoveryConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/KeyDiscoveryConventionTest.cs @@ -154,7 +154,8 @@ private void RunConvention(InternalPropertyBuilder propertyBuilder) CreateKeyDiscoveryConvention().ProcessPropertyAdded(propertyBuilder, context); } - private KeyDiscoveryConvention CreateKeyDiscoveryConvention() => new KeyDiscoveryConvention(CreateDependencies()); + private KeyDiscoveryConvention CreateKeyDiscoveryConvention() + => new KeyDiscoveryConvention(CreateDependencies()); private ProviderConventionSetBuilderDependencies CreateDependencies() => InMemoryTestHelpers.Instance.CreateContextServices().GetRequiredService() diff --git a/test/EFCore.Tests/Metadata/Conventions/ManyToManyJoinEntityTypeConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/ManyToManyJoinEntityTypeConventionTest.cs index b562c6e0744..ab1edbcc0ab 100644 --- a/test/EFCore.Tests/Metadata/Conventions/ManyToManyJoinEntityTypeConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/ManyToManyJoinEntityTypeConventionTest.cs @@ -73,8 +73,9 @@ public void Join_entity_type_is_not_created_when_no_inverse_skip_navigation() RunConvention(skipNavOnFirst); - Assert.Empty(manyToManyFirst.Metadata.Model.GetEntityTypes() - .Where(et => et.IsImplicitlyCreatedJoinEntityType)); + Assert.Empty( + manyToManyFirst.Metadata.Model.GetEntityTypes() + .Where(et => et.IsImplicitlyCreatedJoinEntityType)); } [ConditionalFact] @@ -101,8 +102,9 @@ public void Join_entity_type_is_not_created_when_skip_navigation_is_not_collecti RunConvention(skipNavOnFirst); - Assert.Empty(manyToManyFirst.Metadata.Model.GetEntityTypes() - .Where(et => et.IsImplicitlyCreatedJoinEntityType)); + Assert.Empty( + manyToManyFirst.Metadata.Model.GetEntityTypes() + .Where(et => et.IsImplicitlyCreatedJoinEntityType)); } [ConditionalFact] @@ -129,8 +131,9 @@ public void Join_entity_type_is_not_created_when_inverse_skip_navigation_is_not_ RunConvention(skipNavOnFirst); - Assert.Empty(manyToManyFirst.Metadata.Model.GetEntityTypes() - .Where(et => et.IsImplicitlyCreatedJoinEntityType)); + Assert.Empty( + manyToManyFirst.Metadata.Model.GetEntityTypes() + .Where(et => et.IsImplicitlyCreatedJoinEntityType)); } [ConditionalFact] @@ -164,8 +167,9 @@ public void Join_entity_type_is_not_created_when_skip_navigation_already_in_use( RunConvention(skipNavOnFirst); - Assert.Empty(manyToManyFirst.Metadata.Model.GetEntityTypes() - .Where(et => et.IsImplicitlyCreatedJoinEntityType)); + Assert.Empty( + manyToManyFirst.Metadata.Model.GetEntityTypes() + .Where(et => et.IsImplicitlyCreatedJoinEntityType)); } [ConditionalFact] @@ -199,8 +203,9 @@ public void Join_entity_type_is_not_created_when_inverse_skip_navigation_already RunConvention(skipNavOnFirst); - Assert.Empty(manyToManyFirst.Metadata.Model.GetEntityTypes() - .Where(et => et.IsImplicitlyCreatedJoinEntityType)); + Assert.Empty( + manyToManyFirst.Metadata.Model.GetEntityTypes() + .Where(et => et.IsImplicitlyCreatedJoinEntityType)); } [ConditionalFact] @@ -264,7 +269,8 @@ public void Join_entity_type_is_created() private InternalSkipNavigationBuilder RunConvention(InternalSkipNavigationBuilder skipNavBuilder) { - var context = new ConventionContext(skipNavBuilder.Metadata.DeclaringEntityType.Model.ConventionDispatcher); + var context = new ConventionContext( + skipNavBuilder.Metadata.DeclaringEntityType.Model.ConventionDispatcher); CreateManyToManyConvention().ProcessSkipNavigationAdded(skipNavBuilder, context); return context.ShouldStopProcessing() ? (InternalSkipNavigationBuilder)context.Result : skipNavBuilder; } @@ -276,7 +282,8 @@ private ProviderConventionSetBuilderDependencies CreateDependencies() => InMemoryTestHelpers.Instance.CreateContextServices().GetRequiredService() .With(CreateLogger()); - private InternalModelBuilder CreateInternalModeBuilder() => new Model().Builder; + private InternalModelBuilder CreateInternalModeBuilder() + => new Model().Builder; private class ManyToManyFirst { diff --git a/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs index c046d20467a..5f1a94fb5aa 100644 --- a/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/NavigationAttributeConventionTest.cs @@ -11,7 +11,6 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Diagnostics.Internal; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.InMemory.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; @@ -683,7 +682,8 @@ public void ForeignKeyAttribute_on_field_sets_foreign_key_properties_when_applie [ConditionalTheory] [InlineData(false)] [InlineData(true)] - public void ForeignKeyAttribute_sets_foreign_key_properties_after_inverting_when_applied_on_property_on_principal_side(bool useNavigation) + public void ForeignKeyAttribute_sets_foreign_key_properties_after_inverting_when_applied_on_property_on_principal_side( + bool useNavigation) { var dependentEntityTypeBuilder = CreateInternalEntityTypeBuilder(); var principalEntityTypeBuilder = @@ -778,7 +778,7 @@ public void ForeignKeyAttribute_throws_when_values_on_property_and_navigation_in () => useNavigation ? RunForeignKeyAttributeConvention(relationshipBuilder, navigation) : RunForeignKeyAttributeConvention(relationshipBuilder) - ).Message); + ).Message); } [ConditionalTheory] @@ -803,7 +803,7 @@ public void ForeignKeyAttribute_throws_when_defining_composite_foreign_key_using () => useNavigation ? RunForeignKeyAttributeConvention(relationshipBuilder, navigation) : RunForeignKeyAttributeConvention(relationshipBuilder) - ).Message); + ).Message); } [ConditionalTheory] @@ -828,7 +828,7 @@ public void ForeignKeyAttribute_throws_when_property_list_on_navigation_is_in_in () => useNavigation ? RunForeignKeyAttributeConvention(relationshipBuilder, navigation) : RunForeignKeyAttributeConvention(relationshipBuilder) - ).Message); + ).Message); } [ConditionalTheory] @@ -853,7 +853,7 @@ public void ForeignKeyAttribute_throws_when_same_set_of_properties_are_pointed_b () => useNavigation ? RunForeignKeyAttributeConvention(relationshipBuilder, navigation) : RunForeignKeyAttributeConvention(relationshipBuilder) - ).Message); + ).Message); } [ConditionalTheory] @@ -918,7 +918,8 @@ private InternalForeignKeyBuilder RunForeignKeyAttributeConvention(InternalForei } private InternalForeignKeyBuilder RunForeignKeyAttributeConvention( - InternalForeignKeyBuilder relationshipBuilder, Navigation navigation) + InternalForeignKeyBuilder relationshipBuilder, + Navigation navigation) { var dependencies = CreateDependencies(); var context = new ConventionContext( @@ -942,7 +943,9 @@ private void RunRequiredNavigationAttributeConvention(InternalForeignKeyBuilder .ProcessNavigationAdded(navigation.Builder, context); } - private void RunNavigationBackingFieldAttributeConvention(InternalForeignKeyBuilder relationshipBuilder, InternalNavigationBuilder navigationBuilder) + private void RunNavigationBackingFieldAttributeConvention( + InternalForeignKeyBuilder relationshipBuilder, + InternalNavigationBuilder navigationBuilder) { var dependencies = CreateDependencies(); var context = new ConventionContext( @@ -981,10 +984,10 @@ public void BackingFieldAttribute_overrides_configuration_from_convention_source typeof(PrincipalForNavWithBackingField), ConfigurationSource.Convention); var relationshipBuilder = dependentEntityTypeBuilder.HasRelationship( - principalEntityTypeBuilder.Metadata, - "PrincipalForNavWithBackingField", - "DependentForNavWithBackingField", - ConfigurationSource.Convention); + principalEntityTypeBuilder.Metadata, + "PrincipalForNavWithBackingField", + "DependentForNavWithBackingField", + ConfigurationSource.Convention); var navigationBuilder = relationshipBuilder.Metadata.DependentToPrincipal.Builder; RunNavigationBackingFieldAttributeConvention(relationshipBuilder, navigationBuilder); @@ -1001,10 +1004,10 @@ public void BackingFieldAttribute_does_not_override_configuration_from_explicit_ typeof(PrincipalForNavWithBackingField), ConfigurationSource.Convention); var relationshipBuilder = dependentEntityTypeBuilder.HasRelationship( - principalEntityTypeBuilder.Metadata, - "PrincipalForNavWithBackingField", - "DependentForNavWithBackingField", - ConfigurationSource.Convention); + principalEntityTypeBuilder.Metadata, + "PrincipalForNavWithBackingField", + "DependentForNavWithBackingField", + ConfigurationSource.Convention); var navigationBuilder = relationshipBuilder.Metadata.DependentToPrincipal.Builder; navigationBuilder.HasField("_backingFieldFromFluentApi", ConfigurationSource.Explicit); @@ -1044,7 +1047,8 @@ private InternalEntityTypeBuilder CreateInternalEntityTypeBuilder() private ModelBuilder CreateModelBuilder() { var serviceProvider = CreateServiceProvider(); - return new ModelBuilder(serviceProvider.GetService().CreateConventionSet(), + return new ModelBuilder( + serviceProvider.GetService().CreateConventionSet(), serviceProvider.GetService()); } diff --git a/test/EFCore.Tests/Metadata/Conventions/NonNullableNavigationConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/NonNullableNavigationConventionTest.cs index 0d118f34e31..86a5e78191a 100644 --- a/test/EFCore.Tests/Metadata/Conventions/NonNullableNavigationConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/NonNullableNavigationConventionTest.cs @@ -165,7 +165,8 @@ private InternalEntityTypeBuilder CreateInternalEntityTypeBuilder() private ModelBuilder CreateModelBuilder() { var serviceProvider = CreateServiceProvider(); - return new ModelBuilder(serviceProvider.GetService().CreateConventionSet(), + return new ModelBuilder( + serviceProvider.GetService().CreateConventionSet(), serviceProvider.GetService()); } diff --git a/test/EFCore.Tests/Metadata/Conventions/NonNullableReferencePropertyConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/NonNullableReferencePropertyConventionTest.cs index 072e74cd68f..3f84a7c0d8c 100644 --- a/test/EFCore.Tests/Metadata/Conventions/NonNullableReferencePropertyConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/NonNullableReferencePropertyConventionTest.cs @@ -179,6 +179,7 @@ public class BaseClass } #nullable disable - private static ModelBuilder CreateModelBuilder() => InMemoryTestHelpers.Instance.CreateConventionBuilder(); + private static ModelBuilder CreateModelBuilder() + => InMemoryTestHelpers.Instance.CreateConventionBuilder(); } } diff --git a/test/EFCore.Tests/Metadata/Conventions/PropertyAttributeConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/PropertyAttributeConventionTest.cs index 0ed48f6b2b5..01120e2dfc0 100644 --- a/test/EFCore.Tests/Metadata/Conventions/PropertyAttributeConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/PropertyAttributeConventionTest.cs @@ -716,7 +716,8 @@ private class CompositeKeyDerivedEntity : BaseEntity { } - private static ModelBuilder CreateModelBuilder() => InMemoryTestHelpers.Instance.CreateConventionBuilder(); + private static ModelBuilder CreateModelBuilder() + => InMemoryTestHelpers.Instance.CreateConventionBuilder(); private class MyContext : DbContext { diff --git a/test/EFCore.Tests/Metadata/Conventions/RelationshipDiscoveryConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/RelationshipDiscoveryConventionTest.cs index 388e030b32a..1f9fcbfcef8 100644 --- a/test/EFCore.Tests/Metadata/Conventions/RelationshipDiscoveryConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/RelationshipDiscoveryConventionTest.cs @@ -1091,7 +1091,10 @@ private class ReadOnlyCollectionNavigationEntity } private static void VerifyRelationship( - Navigation navigation, string expectedInverseName, bool unique, bool singleRelationship = true) + Navigation navigation, + string expectedInverseName, + bool unique, + bool singleRelationship = true) { IForeignKey fk = navigation.ForeignKey; Assert.Equal(expectedInverseName, navigation.Inverse?.Name); @@ -1123,7 +1126,10 @@ private static void VerifyRelationship( } private static void VerifySelfRef( - Navigation navigation, string expectedInverseName, bool unique, bool singleRelationship = true) + Navigation navigation, + string expectedInverseName, + bool unique, + bool singleRelationship = true) { IForeignKey fk = navigation.ForeignKey; Assert.Single(fk.DeclaringEntityType.Model.GetEntityTypes()); @@ -1205,7 +1211,8 @@ public TestModelChangeListener(Action[] onEntityAd } public void ProcessEntityTypeAdded( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionContext context) { foreach (var action in _onEntityAdded) { @@ -1477,7 +1484,8 @@ public IEnumerator GetEnumerator() yield return this; } - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); } public class AmbiguousCardinalityTwo : IEnumerable @@ -1498,7 +1506,8 @@ public IEnumerator GetEnumerator() yield return this; } - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); } } } diff --git a/test/EFCore.Tests/Metadata/EntityTypeExtensionsTest.cs b/test/EFCore.Tests/Metadata/EntityTypeExtensionsTest.cs index 52056779f44..97bf689f032 100644 --- a/test/EFCore.Tests/Metadata/EntityTypeExtensionsTest.cs +++ b/test/EFCore.Tests/Metadata/EntityTypeExtensionsTest.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Metadata.Internal; using Xunit; @@ -201,7 +200,8 @@ public void Setting_incompatible_discriminator_value_throws() entityType.SetDiscriminatorValue(null); } - private static IMutableModel CreateModel() => new Model(); + private static IMutableModel CreateModel() + => new Model(); private class A { diff --git a/test/EFCore.Tests/Metadata/Internal/ClrCollectionAccessorFactoryTest.cs b/test/EFCore.Tests/Metadata/Internal/ClrCollectionAccessorFactoryTest.cs index bfead8558da..488c81b65ed 100644 --- a/test/EFCore.Tests/Metadata/Internal/ClrCollectionAccessorFactoryTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ClrCollectionAccessorFactoryTest.cs @@ -34,7 +34,7 @@ public void Navigation_is_returned_if_it_implements_IClrCollectionAccessor() { var navigation = new FakeNavigation(); - var fk = new ForeignKeyTest.FakeForeignKey() { PrincipalToDependent = navigation }; + var fk = new ForeignKeyTest.FakeForeignKey { PrincipalToDependent = navigation }; navigation.ForeignKey = fk; navigation.PropertyInfo = MyEntity.AsICollectionProperty; @@ -43,9 +43,15 @@ public void Navigation_is_returned_if_it_implements_IClrCollectionAccessor() private class FakeNavigation : INavigation, IClrCollectionAccessor { - public object this[string name] => throw new NotImplementedException(); - public IAnnotation FindAnnotation(string name) => throw new NotImplementedException(); - public IEnumerable GetAnnotations() => throw new NotImplementedException(); + public object this[string name] + => throw new NotImplementedException(); + + public IAnnotation FindAnnotation(string name) + => throw new NotImplementedException(); + + public IEnumerable GetAnnotations() + => throw new NotImplementedException(); + public string Name { get; } public ITypeBase DeclaringType { get; } public Type ClrType { get; } @@ -53,11 +59,22 @@ private class FakeNavigation : INavigation, IClrCollectionAccessor public FieldInfo FieldInfo { get; } public IEntityType DeclaringEntityType { get; } public IForeignKey ForeignKey { get; set; } - public bool Add(object entity, object value, bool forMaterialization) => throw new NotImplementedException(); - public bool Contains(object entity, object value) => throw new NotImplementedException(); - public bool Remove(object entity, object value) => throw new NotImplementedException(); - public object Create() => throw new NotImplementedException(); - public object GetOrCreate(object entity, bool forMaterialization) => throw new NotImplementedException(); + + public bool Add(object entity, object value, bool forMaterialization) + => throw new NotImplementedException(); + + public bool Contains(object entity, object value) + => throw new NotImplementedException(); + + public bool Remove(object entity, object value) + => throw new NotImplementedException(); + + public object Create() + => throw new NotImplementedException(); + + public object GetOrCreate(object entity, bool forMaterialization) + => throw new NotImplementedException(); + public Type CollectionType { get; } } @@ -218,7 +235,9 @@ public void Delegate_accessor_handles_uninitialized_collections_prop_no_field_fo } private void AccessorTest( - string navigationName, Func> reader, bool initializeCollections = true) + string navigationName, + Func> reader, + bool initializeCollections = true) { var accessor = new ClrCollectionAccessorFactory().Create(CreateNavigation(navigationName)); @@ -431,7 +450,8 @@ private ProviderConventionSetBuilderDependencies CreateDependencies() private class MyEntity { - public static readonly PropertyInfo AsICollectionProperty = typeof(MyEntity).GetProperty(nameof(AsICollection), BindingFlags.NonPublic | BindingFlags.Instance); + public static readonly PropertyInfo AsICollectionProperty = typeof(MyEntity).GetProperty( + nameof(AsICollection), BindingFlags.NonPublic | BindingFlags.Instance); private ICollection _asICollection; private ICollection _asICollectionOfEntitiesWithCustomComparer; @@ -513,9 +533,11 @@ internal MyCollection AsMyCollection set => _myCollection = value; } - internal ICollection WithNoSetter => _withNoSetter; + internal ICollection WithNoSetter + => _withNoSetter; - internal ICollection NoBackingFound => _withNoBackingFieldFound; + internal ICollection NoBackingFound + => _withNoBackingFieldFound; internal ICollection WithNoGetter { @@ -560,18 +582,21 @@ internal MyUnavailableCollection AsMyUnavailableCollection internal IEnumerable AutoProp { get; set; } - internal IEnumerable ReadOnlyProp => _readOnlyProp; + internal IEnumerable ReadOnlyProp + => _readOnlyProp; internal IEnumerable ReadOnlyAutoProp { get; } - internal IEnumerable ReadOnlyFieldProp => _readOnlyFieldProp; + internal IEnumerable ReadOnlyFieldProp + => _readOnlyFieldProp; internal IEnumerable WriteOnlyProp { set => _writeOnlyProp = value; } - internal IEnumerable ReadWriteOnlyProp => _writeOnlyProp; + internal IEnumerable ReadWriteOnlyProp + => _writeOnlyProp; internal IEnumerable FullPropNoField { @@ -579,14 +604,16 @@ internal IEnumerable FullPropNoField set => _fullPropNoFieldNotFound = value; } - internal IEnumerable ReadOnlyPropNoField => _readOnlyPropNoFieldNotFound; + internal IEnumerable ReadOnlyPropNoField + => _readOnlyPropNoFieldNotFound; internal IEnumerable WriteOnlyPropNoField { set => _writeOnlyPropNoFieldNotFound = value; } - internal IEnumerable ReadWriteOnlyPropNoField => _writeOnlyPropNoFieldNotFound; + internal IEnumerable ReadWriteOnlyPropNoField + => _writeOnlyPropNoFieldNotFound; } private class MyOtherEntity @@ -643,7 +670,8 @@ public IEnumerator GetEnumerator() throw new NotImplementedException(); } - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); } } } diff --git a/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs b/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs index 0d39d6da3c8..72b0c28f748 100644 --- a/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ClrPropertyGetterFactoryTest.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Reflection; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.InMemory.Metadata.Conventions; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; @@ -24,11 +23,21 @@ public void Property_is_returned_if_it_implements_IClrPropertyGetter() private class FakeProperty : IProperty, IClrPropertyGetter { - public object GetClrValue(object entity) => throw new NotImplementedException(); - public bool HasDefaultValue(object entity) => throw new NotImplementedException(); - public object this[string name] => throw new NotImplementedException(); - public IAnnotation FindAnnotation(string name) => throw new NotImplementedException(); - public IEnumerable GetAnnotations() => throw new NotImplementedException(); + public object GetClrValue(object entity) + => throw new NotImplementedException(); + + public bool HasDefaultValue(object entity) + => throw new NotImplementedException(); + + public object this[string name] + => throw new NotImplementedException(); + + public IAnnotation FindAnnotation(string name) + => throw new NotImplementedException(); + + public IEnumerable GetAnnotations() + => throw new NotImplementedException(); + public string Name { get; } public ITypeBase DeclaringType { get; } public Type ClrType { get; } @@ -96,7 +105,8 @@ public void Delegate_getter_is_returned_for_index_property() Assert.Equal(123, new ClrPropertyGetterFactory().Create(propertyB).GetClrValue(new IndexedClass { Id = 7 })); } - private static ModelBuilder CreateModelBuilder() => InMemoryTestHelpers.Instance.CreateConventionBuilder(); + private static ModelBuilder CreateModelBuilder() + => InMemoryTestHelpers.Instance.CreateConventionBuilder(); private class Customer { @@ -106,7 +116,9 @@ private class Customer private struct Fuel { - public Fuel(double volume) => Volume = volume; + public Fuel(double volume) + => Volume = volume; + public double Volume { get; } } @@ -114,12 +126,13 @@ private class IndexedClass { private readonly Dictionary _internalValues = new Dictionary { - {"PropertyA", "ValueA" }, - {"PropertyB", 123 } + { "PropertyA", "ValueA" }, { "PropertyB", 123 } }; internal int Id { get; set; } - internal object this[string name] => _internalValues[name]; + + internal object this[string name] + => _internalValues[name]; } } } diff --git a/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs b/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs index 0de0f4a2fb0..c8327883749 100644 --- a/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ClrPropertySetterFactoryTest.cs @@ -24,10 +24,18 @@ public void Property_is_returned_if_it_implements_IClrPropertySetter() private class FakeProperty : IProperty, IClrPropertySetter { - public void SetClrValue(object instance, object value) => throw new NotImplementedException(); - public object this[string name] => throw new NotImplementedException(); - public IAnnotation FindAnnotation(string name) => throw new NotImplementedException(); - public IEnumerable GetAnnotations() => throw new NotImplementedException(); + public void SetClrValue(object instance, object value) + => throw new NotImplementedException(); + + public object this[string name] + => throw new NotImplementedException(); + + public IAnnotation FindAnnotation(string name) + => throw new NotImplementedException(); + + public IEnumerable GetAnnotations() + => throw new NotImplementedException(); + public string Name { get; } public ITypeBase DeclaringType { get; } public Type ClrType { get; } @@ -277,13 +285,15 @@ private class Customer private class ConcreteEntity2 : ConcreteEntity1 { // ReSharper disable once RedundantOverriddenMember - public override int VirtualPrivateProperty_Override => base.VirtualPrivateProperty_Override; + public override int VirtualPrivateProperty_Override + => base.VirtualPrivateProperty_Override; } private class ConcreteEntity1 : BaseEntity { // ReSharper disable once RedundantOverriddenMember - public override int VirtualPrivateProperty_Override => base.VirtualPrivateProperty_Override; + public override int VirtualPrivateProperty_Override + => base.VirtualPrivateProperty_Override; } private class BaseEntity @@ -298,8 +308,7 @@ private class IndexedClass { private readonly Dictionary _internalValues = new Dictionary { - {"PropertyA", "ValueA" }, - {"PropertyB", 123 } + { "PropertyA", "ValueA" }, { "PropertyB", 123 } }; internal int Id { get; set; } diff --git a/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs b/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs index 809a924dbe4..db65484f741 100644 --- a/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs @@ -386,11 +386,20 @@ private class SomeEntityWithFields private SomeEnum? _maybeEnum; #pragma warning restore 649, IDE0044 // Add readonly modifier - public int Id => _id; - public string Foo => _foo; - public Guid? Goo => _goo; - public SomeEnum Enum => _enum; - public SomeEnum? MaybeEnum => _maybeEnum; + public int Id + => _id; + + public string Foo + => _foo; + + public Guid? Goo + => _goo; + + public SomeEnum Enum + => _enum; + + public SomeEnum? MaybeEnum + => _maybeEnum; } private enum SomeEnum diff --git a/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.BaseType.cs b/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.BaseType.cs index 1c639061c83..519f9fae192 100644 --- a/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.BaseType.cs +++ b/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.BaseType.cs @@ -735,8 +735,10 @@ public void Setting_base_type_throws_when_parent_contains_duplicate_navigation() derivedForeignKeyProperty, specialCustomerKey, specialCustomerType); specialCustomerForeignKey.SetDependentToPrincipal(Order.CustomerProperty); - Assert.Equal(CoreStrings.DuplicatePropertiesOnBase(nameof(SpecialOrder), nameof(Order), - nameof(SpecialOrder), nameof(Order.Customer), nameof(Order), nameof(Order.Customer)), + Assert.Equal( + CoreStrings.DuplicatePropertiesOnBase( + nameof(SpecialOrder), nameof(Order), + nameof(SpecialOrder), nameof(Order.Customer), nameof(Order), nameof(Order.Customer)), Assert.Throws(() => specialOrderType.BaseType = orderType).Message); } @@ -766,7 +768,9 @@ public void Setting_base_type_throws_when_grandparent_contains_duplicate_navigat specialCustomerForeignKey.SetDependentToPrincipal(Order.CustomerProperty); verySpecialOrderType.BaseType = specialOrderType; - Assert.Equal(CoreStrings.DuplicatePropertiesOnBase(nameof(SpecialOrder), nameof(Order), + Assert.Equal( + CoreStrings.DuplicatePropertiesOnBase( + nameof(SpecialOrder), nameof(Order), nameof(VerySpecialOrder), nameof(Order.Customer), nameof(Order), nameof(Order.Customer)), Assert.Throws(() => specialOrderType.BaseType = orderType).Message); } @@ -798,7 +802,8 @@ public void Setting_base_type_throws_when_grandchild_contain_duplicate_navigatio specialCustomerForeignKey.SetDependentToPrincipal(Order.CustomerProperty); Assert.Equal( - CoreStrings.DuplicatePropertiesOnBase(nameof(VerySpecialOrder), nameof(SpecialOrder), + CoreStrings.DuplicatePropertiesOnBase( + nameof(VerySpecialOrder), nameof(SpecialOrder), nameof(VerySpecialOrder), nameof(Order.Customer), nameof(Order), nameof(Order.Customer)), Assert.Throws(() => verySpecialOrderType.BaseType = specialOrderType).Message); } @@ -1200,6 +1205,7 @@ public void Adding_an_index_throws_when_grandchild_type_has_index_on_same_proper () => orderType.AddIndex(indexProperty)).Message); } - private static IMutableModel CreateModel() => new Model(); + private static IMutableModel CreateModel() + => new Model(); } } diff --git a/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs b/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs index c475ec6f873..e2f4aa6169e 100644 --- a/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs @@ -11,7 +11,6 @@ using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; @@ -59,9 +58,15 @@ public void Use_of_custom_IEntityType_throws() private class FakeEntityType : IEntityType { - public object this[string name] => throw new NotImplementedException(); - public IAnnotation FindAnnotation(string name) => throw new NotImplementedException(); - public IEnumerable GetAnnotations() => throw new NotImplementedException(); + public object this[string name] + => throw new NotImplementedException(); + + public IAnnotation FindAnnotation(string name) + => throw new NotImplementedException(); + + public IEnumerable GetAnnotations() + => throw new NotImplementedException(); + public IModel Model { get; } public string Name { get; } public bool HasSharedClrType { get; } @@ -71,24 +76,51 @@ private class FakeEntityType : IEntityType public string DefiningNavigationName { get; } public IEntityType DefiningEntityType { get; } public LambdaExpression QueryFilter { get; } - public IKey FindPrimaryKey() => throw new NotImplementedException(); - public IKey FindKey(IReadOnlyList properties) => throw new NotImplementedException(); - public IEnumerable GetKeys() => throw new NotImplementedException(); - public IForeignKey FindForeignKey(IReadOnlyList properties, IKey principalKey, IEntityType principalEntityType) => - throw new NotImplementedException(); + public IKey FindPrimaryKey() + => throw new NotImplementedException(); + + public IKey FindKey(IReadOnlyList properties) + => throw new NotImplementedException(); + + public IEnumerable GetKeys() + => throw new NotImplementedException(); + + public IForeignKey FindForeignKey(IReadOnlyList properties, IKey principalKey, IEntityType principalEntityType) + => throw new NotImplementedException(); + + public IEnumerable GetForeignKeys() + => throw new NotImplementedException(); + + public IIndex FindIndex(IReadOnlyList properties) + => throw new NotImplementedException(); + + public IIndex FindIndex(string name) + => throw new NotImplementedException(); - public IEnumerable GetForeignKeys() => throw new NotImplementedException(); - public IIndex FindIndex(IReadOnlyList properties) => throw new NotImplementedException(); - public IIndex FindIndex(string name) => throw new NotImplementedException(); - public IEnumerable GetIndexes() => throw new NotImplementedException(); - public IProperty FindProperty(string name) => throw new NotImplementedException(); - public IEnumerable GetProperties() => throw new NotImplementedException(); - public IServiceProperty FindServiceProperty(string name) => throw new NotImplementedException(); - public IEnumerable GetServiceProperties() => throw new NotImplementedException(); - public IEnumerable> GetSeedData() => throw new NotImplementedException(); - public ISkipNavigation FindSkipNavigation([NotNull] string name) => throw new NotImplementedException(); - public IEnumerable GetSkipNavigations() => throw new NotImplementedException(); + public IEnumerable GetIndexes() + => throw new NotImplementedException(); + + public IProperty FindProperty(string name) + => throw new NotImplementedException(); + + public IEnumerable GetProperties() + => throw new NotImplementedException(); + + public IServiceProperty FindServiceProperty(string name) + => throw new NotImplementedException(); + + public IEnumerable GetServiceProperties() + => throw new NotImplementedException(); + + public IEnumerable> GetSeedData() + => throw new NotImplementedException(); + + public ISkipNavigation FindSkipNavigation([NotNull] string name) + => throw new NotImplementedException(); + + public IEnumerable GetSkipNavigations() + => throw new NotImplementedException(); } [ConditionalFact] @@ -429,10 +461,11 @@ public void Removing_a_key_throws_if_it_referenced_from_a_foreign_key_in_the_mod orderType.AddForeignKey(customerFk, customerKey, customerType); Assert.Equal( - CoreStrings.KeyInUse("{'" + Customer.IdProperty.Name + "'}", - nameof(Customer), - "{'" + Order.CustomerIdProperty.Name + "'}", - nameof(Order)), + CoreStrings.KeyInUse( + "{'" + Customer.IdProperty.Name + "'}", + nameof(Customer), + "{'" + Order.CustomerIdProperty.Name + "'}", + nameof(Order)), Assert.Throws(() => customerType.RemoveKey(customerKey.Properties)).Message); } @@ -825,8 +858,9 @@ public void Removing_a_foreign_key_throws_if_referenced_from_skip_navigation() nameof(Order.Products), null, secondEntity, true, false); navigation.SetForeignKey(foreignKey); - Assert.Equal(CoreStrings.ForeignKeyInUseSkipNavigation( - "{'" + nameof(OrderProduct.OrderId) + "'}", nameof(OrderProduct), nameof(Order.Products), nameof(Order)), + Assert.Equal( + CoreStrings.ForeignKeyInUseSkipNavigation( + "{'" + nameof(OrderProduct.OrderId) + "'}", nameof(OrderProduct), nameof(Order.Products), nameof(Order)), Assert.Throws(() => joinEntity.RemoveForeignKey(foreignKey)).Message); } @@ -1221,11 +1255,13 @@ public void Can_add_and_remove_skip_navigation() Assert.Equal(new[] { relatedNavigation }, customerForeignKey.GetReferencingSkipNavigations()); Assert.Equal(new[] { productsNavigation }, orderProductForeignKey.GetReferencingSkipNavigations()); - Assert.Equal(CoreStrings.SkipNavigationWrongType(nameof(Order.Products), nameof(Customer), nameof(Order)), + Assert.Equal( + CoreStrings.SkipNavigationWrongType(nameof(Order.Products), nameof(Customer), nameof(Order)), Assert.Throws(() => customerEntity.RemoveSkipNavigation(productsNavigation)).Message); - Assert.Equal(CoreStrings.EntityTypeInUseByReferencingSkipNavigation( - nameof(Product), nameof(Order.Products), nameof(Order)), + Assert.Equal( + CoreStrings.EntityTypeInUseByReferencingSkipNavigation( + nameof(Product), nameof(Order.Products), nameof(Order)), Assert.Throws(() => model.RemoveEntityType(productEntity)).Message); orderEntity.RemoveSkipNavigation(productsNavigation); @@ -1252,9 +1288,10 @@ public void Adding_skip_navigation_with_a_name_that_conflicts_with_another_skip_ Assert.Equal( CoreStrings.ConflictingPropertyOrNavigation(nameof(Order.Products), typeof(Order).Name, typeof(Order).Name), - Assert.Throws(() => - orderEntity.AddSkipNavigation( - nameof(Order.Products), null, productEntity, true, false)).Message); + Assert.Throws( + () => + orderEntity.AddSkipNavigation( + nameof(Order.Products), null, productEntity, true, false)).Message); } [ConditionalFact] @@ -1277,9 +1314,10 @@ public void Adding_skip_navigation_with_a_name_that_conflicts_with_a_navigation_ Assert.Equal( CoreStrings.ConflictingPropertyOrNavigation(nameof(Order.Products), typeof(Order).Name, typeof(Order).Name), - Assert.Throws(() => - orderEntity.AddSkipNavigation( - nameof(Order.Products), null, productEntity, true, false)).Message); + Assert.Throws( + () => + orderEntity.AddSkipNavigation( + nameof(Order.Products), null, productEntity, true, false)).Message); } [ConditionalFact] @@ -1299,9 +1337,10 @@ public void Adding_skip_navigation_with_a_name_that_conflicts_with_a_property_th Assert.Equal( CoreStrings.ConflictingPropertyOrNavigation(nameof(Order.Products), typeof(Order).Name, typeof(Order).Name), - Assert.Throws(() => - orderEntity.AddSkipNavigation( - nameof(Order.Products), null, productEntity, true, false)).Message); + Assert.Throws( + () => + orderEntity.AddSkipNavigation( + nameof(Order.Products), null, productEntity, true, false)).Message); } [ConditionalFact] @@ -1321,9 +1360,10 @@ public void Adding_skip_navigation_with_a_name_that_conflicts_with_a_service_pro Assert.Equal( CoreStrings.ConflictingPropertyOrNavigation(nameof(Order.Products), typeof(Order).Name, typeof(Order).Name), - Assert.Throws(() => - orderEntity.AddSkipNavigation( - nameof(Order.Products), null, productEntity, true, false)).Message); + Assert.Throws( + () => + orderEntity.AddSkipNavigation( + nameof(Order.Products), null, productEntity, true, false)).Message); } [ConditionalFact] @@ -1441,9 +1481,10 @@ public void Adding_skip_navigation_with_a_mismatched_memberinfo_throws() Assert.Equal( CoreStrings.PropertyWrongName(nameof(Order.Products), typeof(Order).Name, nameof(Order.RelatedOrder)), - Assert.Throws(() => - orderEntity.AddSkipNavigation( - nameof(Order.Products), Order.RelatedOrderProperty, productEntity, true, false)).Message); + Assert.Throws( + () => + orderEntity.AddSkipNavigation( + nameof(Order.Products), Order.RelatedOrderProperty, productEntity, true, false)).Message); } [ConditionalFact] @@ -2968,9 +3009,11 @@ public void Collections_dont_have_relationship_indexes_when_full_notifications_w private readonly IMutableModel _model = BuildModel(); - private IMutableEntityType DependentType => _model.FindEntityType(typeof(DependentEntity)); + private IMutableEntityType DependentType + => _model.FindEntityType(typeof(DependentEntity)); - private IMutableEntityType PrincipalType => _model.FindEntityType(typeof(PrincipalEntity)); + private IMutableEntityType PrincipalType + => _model.FindEntityType(typeof(PrincipalEntity)); private class PrincipalEntity { @@ -3054,7 +3097,9 @@ private class Customer : BaseType public Guid Unique { get; set; } public string Name { get; set; } public string Mane { get; set; } - public object this[string name] => null; + + public object this[string name] + => null; public ICollection Orders { get; set; } public ICollection MoreOrders { get; set; } diff --git a/test/EFCore.Tests/Metadata/Internal/ForeignKeyTest.cs b/test/EFCore.Tests/Metadata/Internal/ForeignKeyTest.cs index 90d3456a659..b00463cc769 100644 --- a/test/EFCore.Tests/Metadata/Internal/ForeignKeyTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ForeignKeyTest.cs @@ -25,9 +25,15 @@ public void Use_of_custom_IForeignKey_throws() public class FakeForeignKey : IForeignKey { - public object this[string name] => throw new NotImplementedException(); - public IAnnotation FindAnnotation(string name) => throw new NotImplementedException(); - public IEnumerable GetAnnotations() => throw new NotImplementedException(); + public object this[string name] + => throw new NotImplementedException(); + + public IAnnotation FindAnnotation(string name) + => throw new NotImplementedException(); + + public IEnumerable GetAnnotations() + => throw new NotImplementedException(); + public IEntityType DeclaringEntityType { get; } public IReadOnlyList Properties { get; } public IEntityType PrincipalEntityType { get; } @@ -39,7 +45,6 @@ public class FakeForeignKey : IForeignKey public bool IsRequiredDependent { get; } public bool IsOwnership { get; } public DeleteBehavior DeleteBehavior { get; } - } [ConditionalFact] @@ -246,7 +251,7 @@ public void Setting_IsRequired_to_false_will_not_configure_FK_properties_as_null public void IsRequiredDependent_throws_for_incompatible_uniqueness() { var foreignKey = CreateOneToManyFK(); - + Assert.Equal( CoreStrings.NonUniqueRequiredDependentForeignKey( "{'Id'}", @@ -378,8 +383,9 @@ public void Throws_when_setting_navigation_to_dependent_on_wrong_FK() nameof(OneToManyDependent), foreignKey2.Properties.Format(), foreignKey1.Properties.Format()), - Assert.Throws(() - => foreignKey2.SetDependentToPrincipal(OneToManyDependent.DeceptionProperty)).Message); + Assert.Throws( + () + => foreignKey2.SetDependentToPrincipal(OneToManyDependent.DeceptionProperty)).Message); } [ConditionalFact] @@ -809,6 +815,7 @@ public void Finding_targets_throws_for_entity_types_not_in_the_relationship() Assert.Throws(() => fk.FindNavigationsToInHierarchy(unrelatedType)).Message); } - private static IMutableModel CreateModel() => new Model(); + private static IMutableModel CreateModel() + => new Model(); } } diff --git a/test/EFCore.Tests/Metadata/Internal/IndexTest.cs b/test/EFCore.Tests/Metadata/Internal/IndexTest.cs index 57bec0512ba..e4503bad437 100644 --- a/test/EFCore.Tests/Metadata/Internal/IndexTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/IndexTest.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.Linq; using System.Reflection; using Xunit; @@ -38,7 +37,8 @@ public void Can_set_unique() Assert.True(index.IsUnique); } - private static IMutableModel CreateModel() => new Model(); + private static IMutableModel CreateModel() + => new Model(); private class Customer { diff --git a/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs index 384a4b8d9bc..afff5816855 100644 --- a/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs @@ -644,12 +644,14 @@ public void Named_index_returns_same_instance_for_clr_properties() var modelBuilder = CreateModelBuilder(); var entityBuilder = modelBuilder.Entity(typeof(Order), ConfigurationSource.Explicit); - var indexBuilder = entityBuilder.HasIndex(new[] { Order.IdProperty, Order.CustomerIdProperty }, "TestIndex", ConfigurationSource.Explicit); + var indexBuilder = entityBuilder.HasIndex( + new[] { Order.IdProperty, Order.CustomerIdProperty }, "TestIndex", ConfigurationSource.Explicit); Assert.NotNull(indexBuilder); Assert.Same( indexBuilder, - entityBuilder.HasIndex(new[] { Order.IdProperty.Name, Order.CustomerIdProperty.Name }, "TestIndex", ConfigurationSource.DataAnnotation)); + entityBuilder.HasIndex( + new[] { Order.IdProperty.Name, Order.CustomerIdProperty.Name }, "TestIndex", ConfigurationSource.DataAnnotation)); } [ConditionalFact] @@ -663,7 +665,8 @@ public void Named_index_returns_same_instance_for_property_names() Assert.NotNull(indexBuilder); Assert.Same( - indexBuilder, entityBuilder.HasIndex(new[] { Order.IdProperty, Order.CustomerIdProperty }, "TestIndex", ConfigurationSource.Explicit)); + indexBuilder, + entityBuilder.HasIndex(new[] { Order.IdProperty, Order.CustomerIdProperty }, "TestIndex", ConfigurationSource.Explicit)); } [ConditionalFact] @@ -695,7 +698,8 @@ public void Named_index_throws_if_try_to_create_a_new_different_index_with_same_ CoreStrings.DuplicateNamedIndex("NamedIndex", "{'CustomerId', 'Id'}", typeof(Order).Name, typeof(Order).Name), Assert.Throws( () => entityBuilder - .HasIndex(new[] { Order.CustomerIdProperty, Order.IdProperty }, "NamedIndex", ConfigurationSource.Explicit)).Message); + .HasIndex( + new[] { Order.CustomerIdProperty, Order.IdProperty }, "NamedIndex", ConfigurationSource.Explicit)).Message); } [ConditionalFact] @@ -1841,8 +1845,9 @@ public void Can_reuniquify_temporary_properties_avoiding_unmapped_clr_properties } [ConditionalTheory] - [MemberData(nameof(DataGenerator.GetCombinations), - new object[] { new Type[] { typeof(ConfigurationSource), typeof(ConfigurationSource) } }, + [MemberData( + nameof(DataGenerator.GetCombinations), + new object[] { new[] { typeof(ConfigurationSource), typeof(ConfigurationSource) } }, MemberType = typeof(DataGenerator))] public void Can_ignore_property_in_hierarchy(ConfigurationSource ignoreSource, ConfigurationSource addSource) { @@ -2208,8 +2213,9 @@ public void Navigation_returns_same_value() } [ConditionalTheory] - [MemberData(nameof(DataGenerator.GetCombinations), - new object[] { new Type[] { typeof(ConfigurationSource), typeof(ConfigurationSource) } }, + [MemberData( + nameof(DataGenerator.GetCombinations), + new object[] { new[] { typeof(ConfigurationSource), typeof(ConfigurationSource) } }, MemberType = typeof(DataGenerator))] public void Can_ignore_navigation_in_hierarchy(ConfigurationSource ignoreSource, ConfigurationSource addSource) { @@ -2293,8 +2299,9 @@ public void Relationship_does_not_return_same_instance_if_no_navigations() } [ConditionalTheory] - [MemberData(nameof(DataGenerator.GetCombinations), - new object[] { new Type[] { typeof(ConfigurationSource), typeof(ConfigurationSource) } }, + [MemberData( + nameof(DataGenerator.GetCombinations), + new object[] { new[] { typeof(ConfigurationSource), typeof(ConfigurationSource) } }, MemberType = typeof(DataGenerator))] public void Can_ignore_skip_navigation_in_hierarchy(ConfigurationSource ignoreSource, ConfigurationSource addSource) { @@ -2335,8 +2342,12 @@ private void VerifyIgnoreSkipNavigation( nameof(Order.Products)); [ConditionalTheory] - [MemberData(nameof(DataGenerator.GetCombinations), new object[] { new Type[] { - typeof(ConfigurationSource), typeof(ConfigurationSource), typeof(MemberType), typeof(MemberType), typeof(bool) } }, + [MemberData( + nameof(DataGenerator.GetCombinations), + new object[] + { + new[] { typeof(ConfigurationSource), typeof(ConfigurationSource), typeof(MemberType), typeof(MemberType), typeof(bool) } + }, MemberType = typeof(DataGenerator))] public void Can_override_members_in_hierarchy( ConfigurationSource firstSource, @@ -2377,9 +2388,10 @@ private void VerifyOverrideMembers( || secondSource != ConfigurationSource.Explicit || firstMemberType == secondMemberType) { - Assert.Equal((!setBaseFirst && firstEntityTypeBuilder != secondEntityTypeBuilder) - || firstMemberType == secondMemberType - || secondSource.Overrides(firstSource), + Assert.Equal( + (!setBaseFirst && firstEntityTypeBuilder != secondEntityTypeBuilder) + || firstMemberType == secondMemberType + || secondSource.Overrides(firstSource), ConfigureMember(secondEntityTypeBuilder, secondMemberType, secondSource)); } else @@ -2392,10 +2404,12 @@ private void VerifyOverrideMembers( } else { - message = CoreStrings.ConflictingPropertyOrNavigation(nameof(Order.Products), nameof(SpecialOrder), firstEntityTypeBuilder.Metadata.DisplayName()); + message = CoreStrings.ConflictingPropertyOrNavigation( + nameof(Order.Products), nameof(SpecialOrder), firstEntityTypeBuilder.Metadata.DisplayName()); } - Assert.Equal(message, + Assert.Equal( + message, Assert.Throws( () => ConfigureMember(secondEntityTypeBuilder, secondMemberType, secondSource)).Message); @@ -2415,15 +2429,19 @@ private void VerifyOverrideMembers( { if (firstType == typeof(Order)) { - Assert.Equal(CoreStrings.DuplicatePropertiesOnBase(nameof(SpecialOrder), nameof(Order), - nameof(SpecialOrder), nameof(Order.Products), nameof(Order), nameof(Order.Products)), + Assert.Equal( + CoreStrings.DuplicatePropertiesOnBase( + nameof(SpecialOrder), nameof(Order), + nameof(SpecialOrder), nameof(Order.Products), nameof(Order), nameof(Order.Products)), Assert.Throws( () => ConfigureOrdersHierarchy(modelBuilder)).Message); } else { - Assert.Equal(CoreStrings.DuplicatePropertiesOnBase(nameof(ExtraSpecialOrder), nameof(SpecialOrder), - nameof(ExtraSpecialOrder), nameof(Order.Products), nameof(SpecialOrder), nameof(Order.Products)), + Assert.Equal( + CoreStrings.DuplicatePropertiesOnBase( + nameof(ExtraSpecialOrder), nameof(SpecialOrder), + nameof(ExtraSpecialOrder), nameof(Order.Products), nameof(SpecialOrder), nameof(Order.Products)), Assert.Throws( () => ConfigureOrdersHierarchy(modelBuilder)).Message); } @@ -2434,9 +2452,9 @@ private void VerifyOverrideMembers( var leastDerivedType = firstEntityTypeBuilder.Metadata.LeastDerivedType(secondEntityTypeBuilder.Metadata); var shouldSecondWin = secondSource.Overrides(firstSource) - && (secondSource != firstSource - || setBaseFirst - || secondEntityTypeBuilder.Metadata == leastDerivedType); + && (secondSource != firstSource + || setBaseFirst + || secondEntityTypeBuilder.Metadata == leastDerivedType); var expectedDeclaringType = firstMemberType == secondMemberType ? leastDerivedType @@ -2467,15 +2485,17 @@ private bool ConfigureMember( return entityTypeBuilder.ServiceProperty(Order.ProductsProperty, configurationSource) != null; case MemberType.Navigation: return entityTypeBuilder.HasRelationship( - entityTypeBuilder.ModelBuilder.Entity(typeof(Product), ConfigurationSource.Explicit).Metadata, - Order.ProductsProperty, - null, - configurationSource) != null; + entityTypeBuilder.ModelBuilder.Entity(typeof(Product), ConfigurationSource.Explicit).Metadata, + Order.ProductsProperty, + null, + configurationSource) + != null; case MemberType.SkipNavigation: return entityTypeBuilder.HasSkipNavigation( - MemberIdentity.Create(Order.ProductsProperty), - entityTypeBuilder.ModelBuilder.Entity(typeof(Product), ConfigurationSource.Explicit).Metadata, - configurationSource) != null; + MemberIdentity.Create(Order.ProductsProperty), + entityTypeBuilder.ModelBuilder.Entity(typeof(Product), ConfigurationSource.Explicit).Metadata, + configurationSource) + != null; } return false; @@ -2486,13 +2506,17 @@ private void AssertDeclaringType( EntityType expectedDeclaringType, MemberType memberType) { - Assert.Same(memberType == MemberType.Property ? expectedDeclaringType : null, + Assert.Same( + memberType == MemberType.Property ? expectedDeclaringType : null, GetDeclaringType(entityTypeBuilder, MemberType.Property)); - Assert.Same(memberType == MemberType.ServiceProperty ? expectedDeclaringType : null, + Assert.Same( + memberType == MemberType.ServiceProperty ? expectedDeclaringType : null, GetDeclaringType(entityTypeBuilder, MemberType.ServiceProperty)); - Assert.Same(memberType == MemberType.Navigation ? expectedDeclaringType : null, + Assert.Same( + memberType == MemberType.Navigation ? expectedDeclaringType : null, GetDeclaringType(entityTypeBuilder, MemberType.Navigation)); - Assert.Same(memberType == MemberType.SkipNavigation ? expectedDeclaringType : null, + Assert.Same( + memberType == MemberType.SkipNavigation ? expectedDeclaringType : null, GetDeclaringType(entityTypeBuilder, MemberType.SkipNavigation)); } @@ -2810,10 +2834,13 @@ public void Cannot_set_base_type_for_relationship_with_explicit_conflicting_inco Assert.Null(derivedDependentEntityBuilder.Metadata.BaseType); Assert.Single(derivedDependentEntityBuilder.Metadata.GetDeclaredNavigations()); - Assert.Equal(CoreStrings.DuplicatePropertiesOnBase(nameof(SpecialOrder), nameof(Order), - nameof(SpecialOrder), nameof(Order.Customer), nameof(Order), nameof(Order.Customer)), + Assert.Equal( + CoreStrings.DuplicatePropertiesOnBase( + nameof(SpecialOrder), nameof(Order), + nameof(SpecialOrder), nameof(Order.Customer), nameof(Order), nameof(Order.Customer)), Assert.Throws( - () => derivedDependentEntityBuilder.HasBaseType(dependentEntityBuilder.Metadata, ConfigurationSource.Explicit)).Message); + () => derivedDependentEntityBuilder.HasBaseType(dependentEntityBuilder.Metadata, ConfigurationSource.Explicit)) + .Message); } [ConditionalFact] @@ -3208,7 +3235,8 @@ public void DiscriminatorValue_throws_if_base_cannot_be_set() => discriminatorBuilder.HasValue(nonDerivedTypeBuilder.Metadata, "1")).Message); } - private InternalModelBuilder CreateModelBuilder() => new InternalModelBuilder(new Model()); + private InternalModelBuilder CreateModelBuilder() + => new InternalModelBuilder(new Model()); public enum MemberType { @@ -3244,7 +3272,8 @@ public IEnumerator GetEnumerator() yield return this; } - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); public string Specialty { get; set; } } @@ -3325,7 +3354,8 @@ private class IndexedClass { public static readonly string IndexerPropertyName = "Indexer"; - public object this[string name] => null; + public object this[string name] + => null; } } } diff --git a/test/EFCore.Tests/Metadata/Internal/InternalForeignKeyBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalForeignKeyBuilderTest.cs index 34764013bd9..fd775b443bc 100644 --- a/test/EFCore.Tests/Metadata/Internal/InternalForeignKeyBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/InternalForeignKeyBuilderTest.cs @@ -967,7 +967,8 @@ public void Navigation_to_dependent_does_not_change_uniqueness_for_relationship_ Assert.Equal("Orders", foreignKeyBuilder.Metadata.PrincipalToDependent.Name); } - private InternalModelBuilder CreateInternalModelBuilder() => new InternalModelBuilder(new Model()); + private InternalModelBuilder CreateInternalModelBuilder() + => new InternalModelBuilder(new Model()); private class Order { @@ -992,7 +993,8 @@ public IEnumerator GetEnumerator() yield return this; } - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); public string Specialty { get; set; } } diff --git a/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs index 6de3dc6e53b..96e9299877e 100644 --- a/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs @@ -379,7 +379,7 @@ public void Can_remove_implicitly_created_join_entity_type() var leftFK = joinEntityTypeBuilder .HasRelationship( manyToManyLeft.Metadata.Name, - new List() { "ManyToManyLeft_Id" }, + new List { "ManyToManyLeft_Id" }, manyToManyLeftPK.Metadata, ConfigurationSource.Convention) .IsUnique(false, ConfigurationSource.Convention) @@ -387,7 +387,7 @@ public void Can_remove_implicitly_created_join_entity_type() var rightFK = joinEntityTypeBuilder .HasRelationship( manyToManyRight.Metadata.Name, - new List() { "ManyToManyRight_Id" }, + new List { "ManyToManyRight_Id" }, manyToManyRightPK.Metadata, ConfigurationSource.Convention) .IsUnique(false, ConfigurationSource.Convention) @@ -403,8 +403,9 @@ public void Can_remove_implicitly_created_join_entity_type() Assert.NotNull(joinEntityType); Assert.NotNull(modelBuilder.RemoveImplicitJoinEntity(joinEntityType)); - Assert.Empty(model.GetEntityTypes() - .Where(e => e.IsImplicitlyCreatedJoinEntityType)); + Assert.Empty( + model.GetEntityTypes() + .Where(e => e.IsImplicitlyCreatedJoinEntityType)); var leftSkipNav = manyToManyLeft.Metadata.FindDeclaredSkipNavigation(nameof(ManyToManyLeft.Rights)); var rightSkipNav = manyToManyRight.Metadata.FindDeclaredSkipNavigation(nameof(ManyToManyRight.Lefts)); @@ -424,7 +425,8 @@ public void Cannot_remove_manually_created_join_entity_type() var manyToManyJoin = modelBuilder.Entity(typeof(ManyToManyJoin), ConfigurationSource.Convention); var manyToManyLeftPK = manyToManyLeft.PrimaryKey(new[] { nameof(ManyToManyLeft.Id) }, ConfigurationSource.Convention); var manyToManyRightPK = manyToManyRight.PrimaryKey(new[] { nameof(ManyToManyRight.Id) }, ConfigurationSource.Convention); - manyToManyJoin.PrimaryKey(new[] { nameof(ManyToManyJoin.LeftId), nameof(ManyToManyJoin.RightId) }, ConfigurationSource.Convention); + manyToManyJoin.PrimaryKey( + new[] { nameof(ManyToManyJoin.LeftId), nameof(ManyToManyJoin.RightId) }, ConfigurationSource.Convention); var skipNavOnLeft = manyToManyLeft.HasSkipNavigation( new MemberIdentity(typeof(ManyToManyLeft).GetProperty(nameof(ManyToManyLeft.Rights))), @@ -489,14 +491,17 @@ public void Can_add_shared_type() Assert.Equal( CoreStrings.ClashingMismatchedSharedType("SpecialDetails", nameof(Product)), - Assert.Throws(() => modelBuilder.SharedTypeEntity(sharedTypeName, typeof(Details), ConfigurationSource.Explicit)).Message); + Assert.Throws( + () => modelBuilder.SharedTypeEntity(sharedTypeName, typeof(Details), ConfigurationSource.Explicit)).Message); Assert.NotNull(modelBuilder.Entity(typeof(Customer), ConfigurationSource.Explicit)); Assert.Equal( CoreStrings.ClashingNonSharedType(typeof(Customer).DisplayName(), typeof(Customer).DisplayName()), - Assert.Throws(() => - modelBuilder.SharedTypeEntity(typeof(Customer).DisplayName(), typeof(Customer), ConfigurationSource.Explicit)).Message); + Assert.Throws( + () => + modelBuilder.SharedTypeEntity(typeof(Customer).DisplayName(), typeof(Customer), ConfigurationSource.Explicit)) + .Message); } private static void Cleanup(InternalModelBuilder modelBuilder) diff --git a/test/EFCore.Tests/Metadata/Internal/InternalNavigationBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalNavigationBuilderTest.cs index 5f5246d4600..2fcd57ba6c5 100644 --- a/test/EFCore.Tests/Metadata/Internal/InternalNavigationBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/InternalNavigationBuilderTest.cs @@ -102,15 +102,18 @@ public void Can_only_override_lower_or_equal_source_PropertyAccessMode() Assert.Equal(ConfigurationSource.DataAnnotation, metadata.GetPropertyAccessModeConfigurationSource()); Assert.True(builder.CanSetPropertyAccessMode(PropertyAccessMode.PreferProperty, ConfigurationSource.Convention)); - Assert.False(builder.CanSetPropertyAccessMode(PropertyAccessMode.PreferFieldDuringConstruction, ConfigurationSource.Convention)); + Assert.False( + builder.CanSetPropertyAccessMode(PropertyAccessMode.PreferFieldDuringConstruction, ConfigurationSource.Convention)); Assert.NotNull(builder.UsePropertyAccessMode(PropertyAccessMode.PreferProperty, ConfigurationSource.Convention)); Assert.Null(builder.UsePropertyAccessMode(PropertyAccessMode.PreferFieldDuringConstruction, ConfigurationSource.Convention)); Assert.Equal(PropertyAccessMode.PreferProperty, metadata.GetPropertyAccessMode()); Assert.Equal(ConfigurationSource.DataAnnotation, metadata.GetPropertyAccessModeConfigurationSource()); - Assert.True(builder.CanSetPropertyAccessMode(PropertyAccessMode.PreferFieldDuringConstruction, ConfigurationSource.DataAnnotation)); - Assert.NotNull(builder.UsePropertyAccessMode(PropertyAccessMode.PreferFieldDuringConstruction, ConfigurationSource.DataAnnotation)); + Assert.True( + builder.CanSetPropertyAccessMode(PropertyAccessMode.PreferFieldDuringConstruction, ConfigurationSource.DataAnnotation)); + Assert.NotNull( + builder.UsePropertyAccessMode(PropertyAccessMode.PreferFieldDuringConstruction, ConfigurationSource.DataAnnotation)); Assert.Equal(PropertyAccessMode.PreferFieldDuringConstruction, metadata.GetPropertyAccessMode()); Assert.Equal(ConfigurationSource.DataAnnotation, metadata.GetPropertyAccessModeConfigurationSource()); @@ -172,7 +175,8 @@ public void Configuring_IsRequired_on_to_dependent_nonUnique_throws() public void Can_configure_IsRequired_on_to_principal_nonUnique() { var builder = CreateInternalNavigationBuilder() - .Metadata.ForeignKey.Builder.HasNavigation(nameof(OrderDetails.Order), pointsToPrincipal: true, ConfigurationSource.Explicit) + .Metadata.ForeignKey.Builder.HasNavigation( + nameof(OrderDetails.Order), pointsToPrincipal: true, ConfigurationSource.Explicit) .Metadata.DependentToPrincipal.Builder; builder.IsRequired(true, ConfigurationSource.Explicit); @@ -184,7 +188,8 @@ public void Can_configure_IsRequired_on_to_dependent_unique() { var foreignKey = CreateInternalNavigationBuilder() .Metadata.ForeignKey; - foreignKey = foreignKey.Builder.HasNavigations(nameof(OrderDetails.Order), nameof(Order.SingleDetails), ConfigurationSource.Explicit) + foreignKey = foreignKey.Builder.HasNavigations( + nameof(OrderDetails.Order), nameof(Order.SingleDetails), ConfigurationSource.Explicit) .Metadata; foreignKey.PrincipalToDependent.Builder.IsRequired(true, ConfigurationSource.Explicit); @@ -197,7 +202,8 @@ public void Can_configure_IsRequired_on_to_principal_unique() { var foreignKey = CreateInternalNavigationBuilder() .Metadata.ForeignKey; - foreignKey = foreignKey.Builder.HasNavigations(nameof(OrderDetails.Order), nameof(Order.SingleDetails), ConfigurationSource.Explicit) + foreignKey = foreignKey.Builder.HasNavigations( + nameof(OrderDetails.Order), nameof(Order.SingleDetails), ConfigurationSource.Explicit) .Metadata; foreignKey.PrincipalToDependent.Builder.IsRequired(true, ConfigurationSource.Explicit); @@ -212,7 +218,8 @@ private InternalNavigationBuilder CreateInternalNavigationBuilder() var orderEntityBuilder = modelBuilder.Entity(typeof(Order), ConfigurationSource.Convention); var detailsEntityBuilder = modelBuilder.Entity(typeof(OrderDetails), ConfigurationSource.Convention); orderEntityBuilder - .HasRelationship(detailsEntityBuilder.Metadata, nameof(Order.Details), ConfigurationSource.DataAnnotation, targetIsPrincipal: false) + .HasRelationship( + detailsEntityBuilder.Metadata, nameof(Order.Details), ConfigurationSource.DataAnnotation, targetIsPrincipal: false) .IsUnique(false, ConfigurationSource.Convention); var navigation = (Navigation)orderEntityBuilder.Navigation(nameof(Order.Details)); @@ -223,6 +230,7 @@ protected class Order { public static readonly FieldInfo DetailsField = typeof(Order) .GetField(nameof(_details), BindingFlags.Instance | BindingFlags.NonPublic); + public static readonly FieldInfo OtherDetailsField = typeof(Order) .GetField(nameof(_otherDetails), BindingFlags.Instance | BindingFlags.NonPublic); diff --git a/test/EFCore.Tests/Metadata/Internal/InternalPropertyBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalPropertyBuilderTest.cs index 3ec14dafa49..9767372f231 100644 --- a/test/EFCore.Tests/Metadata/Internal/InternalPropertyBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/InternalPropertyBuilderTest.cs @@ -208,7 +208,8 @@ public void Can_only_override_lower_or_equal_source_CustomValueGenerator_factory [ConditionalFact] public void Can_only_override_existing_CustomValueGenerator_factory_explicitly() { - ValueGenerator factory(IProperty p, IEntityType e) => new CustomValueGenerator1(); + ValueGenerator factory(IProperty p, IEntityType e) + => new CustomValueGenerator1(); var metadata = CreateProperty(); metadata.SetValueGeneratorFactory(factory); @@ -299,7 +300,8 @@ public override string Next(EntityEntry entry) throw new NotImplementedException(); } - public override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; } private class CustomValueGenerator2 : ValueGenerator @@ -309,7 +311,8 @@ public override string Next(EntityEntry entry) throw new NotImplementedException(); } - public override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; } [ConditionalFact] @@ -464,7 +467,8 @@ private InternalPropertyBuilder CreateInternalPropertyBuilder() return entityBuilder.Property(Customer.NameProperty, ConfigurationSource.Convention); } - private Property CreateProperty() => CreateInternalPropertyBuilder().Metadata; + private Property CreateProperty() + => CreateInternalPropertyBuilder().Metadata; private class Customer { diff --git a/test/EFCore.Tests/Metadata/Internal/InternalSkipNavigationBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalSkipNavigationBuilderTest.cs index bd8dd6300ba..f3c8c98eb2e 100644 --- a/test/EFCore.Tests/Metadata/Internal/InternalSkipNavigationBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/InternalSkipNavigationBuilderTest.cs @@ -100,15 +100,18 @@ public void Can_only_override_lower_or_equal_source_PropertyAccessMode() Assert.Equal(ConfigurationSource.DataAnnotation, metadata.GetPropertyAccessModeConfigurationSource()); Assert.True(builder.CanSetPropertyAccessMode(PropertyAccessMode.PreferProperty, ConfigurationSource.Convention)); - Assert.False(builder.CanSetPropertyAccessMode(PropertyAccessMode.PreferFieldDuringConstruction, ConfigurationSource.Convention)); + Assert.False( + builder.CanSetPropertyAccessMode(PropertyAccessMode.PreferFieldDuringConstruction, ConfigurationSource.Convention)); Assert.NotNull(builder.UsePropertyAccessMode(PropertyAccessMode.PreferProperty, ConfigurationSource.Convention)); Assert.Null(builder.UsePropertyAccessMode(PropertyAccessMode.PreferFieldDuringConstruction, ConfigurationSource.Convention)); Assert.Equal(PropertyAccessMode.PreferProperty, metadata.GetPropertyAccessMode()); Assert.Equal(ConfigurationSource.DataAnnotation, metadata.GetPropertyAccessModeConfigurationSource()); - Assert.True(builder.CanSetPropertyAccessMode(PropertyAccessMode.PreferFieldDuringConstruction, ConfigurationSource.DataAnnotation)); - Assert.NotNull(builder.UsePropertyAccessMode(PropertyAccessMode.PreferFieldDuringConstruction, ConfigurationSource.DataAnnotation)); + Assert.True( + builder.CanSetPropertyAccessMode(PropertyAccessMode.PreferFieldDuringConstruction, ConfigurationSource.DataAnnotation)); + Assert.NotNull( + builder.UsePropertyAccessMode(PropertyAccessMode.PreferFieldDuringConstruction, ConfigurationSource.DataAnnotation)); Assert.Equal(PropertyAccessMode.PreferFieldDuringConstruction, metadata.GetPropertyAccessMode()); Assert.Equal(ConfigurationSource.DataAnnotation, metadata.GetPropertyAccessModeConfigurationSource()); @@ -172,8 +175,8 @@ public void Can_only_override_lower_or_equal_source_Inverse() // the skip navigation is pointing to the automatically-generated // join entity type and so is its inverse var inverse = (SkipNavigation)metadata.TargetEntityType.Builder.HasSkipNavigation( - Product.OrdersProperty, - metadata.DeclaringEntityType) + Product.OrdersProperty, + metadata.DeclaringEntityType) .Metadata; Assert.NotNull(metadata.Inverse); @@ -260,8 +263,10 @@ private InternalSkipNavigationBuilder CreateInternalSkipNavigationBuilder() protected class Order { public static readonly PropertyInfo ProductsProperty = typeof(Order).GetProperty(nameof(Products)); + public static readonly FieldInfo ProductsField = typeof(Order) .GetField(nameof(_products), BindingFlags.Instance | BindingFlags.NonPublic); + public static readonly FieldInfo OtherProductsField = typeof(Order) .GetField(nameof(_otherProducts), BindingFlags.Instance | BindingFlags.NonPublic); diff --git a/test/EFCore.Tests/Metadata/Internal/KeyTest.cs b/test/EFCore.Tests/Metadata/Internal/KeyTest.cs index f1192bc9888..22282188dae 100644 --- a/test/EFCore.Tests/Metadata/Internal/KeyTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/KeyTest.cs @@ -25,9 +25,15 @@ public void Use_of_custom_IKey_throws() private class FakeKey : IKey { - public object this[string name] => throw new NotImplementedException(); - public IAnnotation FindAnnotation(string name) => throw new NotImplementedException(); - public IEnumerable GetAnnotations() => throw new NotImplementedException(); + public object this[string name] + => throw new NotImplementedException(); + + public IAnnotation FindAnnotation(string name) + => throw new NotImplementedException(); + + public IEnumerable GetAnnotations() + => throw new NotImplementedException(); + public IReadOnlyList Properties { get; } public IEntityType DeclaringEntityType { get; } } @@ -61,7 +67,8 @@ public void Validates_properties_from_same_entity() () => entityType1.AddKey(new[] { property1, property2 })).Message); } - private static IMutableModel CreateModel() => new Model(); + private static IMutableModel CreateModel() + => new Model(); private class Customer { diff --git a/test/EFCore.Tests/Metadata/Internal/ModelTest.cs b/test/EFCore.Tests/Metadata/Internal/ModelTest.cs index 18c72e387e8..c38eb15131e 100644 --- a/test/EFCore.Tests/Metadata/Internal/ModelTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/ModelTest.cs @@ -7,7 +7,6 @@ using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Xunit; // ReSharper disable UnusedAutoPropertyAccessor.Local @@ -28,14 +27,23 @@ public void Use_of_custom_IModel_throws() private class FakeModel : IModel { - public object this[string name] => throw new NotImplementedException(); - public IAnnotation FindAnnotation(string name) => throw new NotImplementedException(); - public IEnumerable GetAnnotations() => throw new NotImplementedException(); - public IEnumerable GetEntityTypes() => throw new NotImplementedException(); - public IEntityType FindEntityType(string name) => throw new NotImplementedException(); - - public IEntityType FindEntityType(string name, string definingNavigationName, IEntityType definingEntityType) => - throw new NotImplementedException(); + public object this[string name] + => throw new NotImplementedException(); + + public IAnnotation FindAnnotation(string name) + => throw new NotImplementedException(); + + public IEnumerable GetAnnotations() + => throw new NotImplementedException(); + + public IEnumerable GetEntityTypes() + => throw new NotImplementedException(); + + public IEntityType FindEntityType(string name) + => throw new NotImplementedException(); + + public IEntityType FindEntityType(string name, string definingNavigationName, IEntityType definingEntityType) + => throw new NotImplementedException(); } [ConditionalFact] @@ -167,8 +175,15 @@ public void Can_add_weak_entity_types() Assert.Throws(() => model.AddEntityType(typeof(Order))).Message); Assert.Equal( CoreStrings.ClashingNonWeakEntityType( - nameof(Customer) + "." + nameof(Customer.Orders) + "#" - + nameof(Order) + "." + nameof(Order.Customer) + "#" + nameof(Customer)), + nameof(Customer) + + "." + + nameof(Customer.Orders) + + "#" + + nameof(Order) + + "." + + nameof(Order.Customer) + + "#" + + nameof(Customer)), Assert.Throws( () => model.AddEntityType(typeof(Customer), nameof(Order.Customer), dependentOrderType)).Message); @@ -293,7 +308,8 @@ public void Can_get_referencing_foreign_keys() Assert.Same(foreignKey, entityType1.GetReferencingForeignKeys().Single()); } - private static IMutableModel CreateModel() => new Model(); + private static IMutableModel CreateModel() + => new Model(); private class Customer { diff --git a/test/EFCore.Tests/Metadata/Internal/NavigationTest.cs b/test/EFCore.Tests/Metadata/Internal/NavigationTest.cs index ae7f300c409..c3bdd042451 100644 --- a/test/EFCore.Tests/Metadata/Internal/NavigationTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/NavigationTest.cs @@ -24,9 +24,15 @@ public void Use_of_custom_INavigation_throws() private class FakeNavigation : INavigation { - public object this[string name] => throw new NotImplementedException(); - public IAnnotation FindAnnotation(string name) => throw new NotImplementedException(); - public IEnumerable GetAnnotations() => throw new NotImplementedException(); + public object this[string name] + => throw new NotImplementedException(); + + public IAnnotation FindAnnotation(string name) + => throw new NotImplementedException(); + + public IEnumerable GetAnnotations() + => throw new NotImplementedException(); + public string Name { get; } public ITypeBase DeclaringType { get; } public Type ClrType { get; } diff --git a/test/EFCore.Tests/Metadata/Internal/PropertyAccessorsFactoryTest.cs b/test/EFCore.Tests/Metadata/Internal/PropertyAccessorsFactoryTest.cs index e13c1fe600c..1070e5c5419 100644 --- a/test/EFCore.Tests/Metadata/Internal/PropertyAccessorsFactoryTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/PropertyAccessorsFactoryTest.cs @@ -72,7 +72,8 @@ private class IndexedClass internal int Id { get; set; } - public object this[string name] => _internalValues[name]; + public object this[string name] + => _internalValues[name]; } private class NonIndexedClass diff --git a/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs b/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs index 88e0febd174..a8956cc071d 100644 --- a/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs @@ -6,7 +6,6 @@ using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.InMemory.Metadata.Conventions; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -744,7 +743,8 @@ private static IMutableProperty CreateProperty(string fieldName, string } private static IMutableNavigation CreateReferenceNavigation( - string fieldName, string navigationName = Reference) + string fieldName, + string navigationName = Reference) where TEntity : class { var model = CreateModelBuilder(); @@ -761,7 +761,8 @@ private static IMutableNavigation CreateReferenceNavigation( } private static IMutableNavigation CreateCollectionNavigation( - string fieldName, string navigationName = Collection) + string fieldName, + string navigationName = Collection) where TEntity : class { var model = CreateModelBuilder(); @@ -777,10 +778,15 @@ private static IMutableNavigation CreateCollectionNavigation( return navigation; } - private static ModelBuilder CreateModelBuilder() => InMemoryTestHelpers.Instance.CreateConventionBuilder(); + private static ModelBuilder CreateModelBuilder() + => InMemoryTestHelpers.Instance.CreateConventionBuilder(); private void MemberInfoTest( - IMutableProperty property, PropertyAccessMode? accessMode, string forConstruction, string forSet, string forGet) + IMutableProperty property, + PropertyAccessMode? accessMode, + string forConstruction, + string forSet, + string forGet) { property.SetPropertyAccessMode(accessMode); @@ -788,7 +794,11 @@ private void MemberInfoTest( } private void MemberInfoTest( - IMutableNavigation navigation, PropertyAccessMode? accessMode, string forConstruction, string forSet, string forGet) + IMutableNavigation navigation, + PropertyAccessMode? accessMode, + string forConstruction, + string forSet, + string forGet) { navigation.SetPropertyAccessMode(accessMode); @@ -796,7 +806,11 @@ private void MemberInfoTest( } private void MemberInfoTestCommon( - IPropertyBase propertyBase, PropertyAccessMode? accessMode, string forConstruction, string forSet, string forGet) + IPropertyBase propertyBase, + PropertyAccessMode? accessMode, + string forConstruction, + string forSet, + string forGet) { string failMessage = null; try @@ -1023,9 +1037,14 @@ public ReadOnlyProp(int id, ReadOnlyProp reference, IEnumerable co _collection = collection; } - public int Foo => _foo; - public ReadOnlyProp Reference => _reference; - public IEnumerable Collection => _collection; + public int Foo + => _foo; + + public ReadOnlyProp Reference + => _reference; + + public IEnumerable Collection + => _collection; } private class ReadOnlyAutoProp @@ -1065,9 +1084,15 @@ public ReadOnlyFieldProp(int id, ReadOnlyFieldProp reference, IEnumerable _foo; - public ReadOnlyFieldProp Reference => _reference; - public IEnumerable Collection => _collection; + + public int Foo + => _foo; + + public ReadOnlyFieldProp Reference + => _reference; + + public IEnumerable Collection + => _collection; } private class WriteOnlyProp @@ -1163,9 +1188,15 @@ public ReadOnlyPropNoField(int id, ReadOnlyPropNoField notFoundRef, IEnumerable< } public int Id { get; set; } - public int Foo => _notFound; - public ReadOnlyPropNoField Reference => _notFoundRef; - public IEnumerable Collection => _notFoundColl; + + public int Foo + => _notFound; + + public ReadOnlyPropNoField Reference + => _notFoundRef; + + public IEnumerable Collection + => _notFoundColl; } private class WriteOnlyPropNoField @@ -1194,9 +1225,14 @@ public IEnumerable Collection private class PrivateSetterInBase : PrivateSetterBase { - public override int Foo => _foo; - public override PrivateSetterInBase Reference => _reference; - public override IEnumerable Collection => _collection; + public override int Foo + => _foo; + + public override PrivateSetterInBase Reference + => _reference; + + public override IEnumerable Collection + => _collection; } private class PrivateSetterBase diff --git a/test/EFCore.Tests/Metadata/Internal/PropertyTest.cs b/test/EFCore.Tests/Metadata/Internal/PropertyTest.cs index e6da89f3af5..1c489943b40 100644 --- a/test/EFCore.Tests/Metadata/Internal/PropertyTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/PropertyTest.cs @@ -6,7 +6,6 @@ using System.Reflection; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Xunit; // ReSharper disable UnassignedGetOnlyAutoProperty @@ -40,9 +39,15 @@ public void Use_of_custom_IPropertyBase_throws() private class FakeProperty : IProperty { - public object this[string name] => throw new NotImplementedException(); - public IAnnotation FindAnnotation(string name) => throw new NotImplementedException(); - public IEnumerable GetAnnotations() => throw new NotImplementedException(); + public object this[string name] + => throw new NotImplementedException(); + + public IAnnotation FindAnnotation(string name) + => throw new NotImplementedException(); + + public IEnumerable GetAnnotations() + => throw new NotImplementedException(); + public string Name { get; } public ITypeBase DeclaringType { get; } public Type ClrType { get; } @@ -195,7 +200,8 @@ public void Can_mark_property_as_concurrency_token() Assert.False(property.IsConcurrencyToken); } - private static IMutableModel CreateModel() => new Model(); + private static IMutableModel CreateModel() + => new Model(); private class Entity { diff --git a/test/EFCore.Tests/Metadata/Internal/SkipNavigationTest.cs b/test/EFCore.Tests/Metadata/Internal/SkipNavigationTest.cs index e5de3e6a099..ab3b51fe572 100644 --- a/test/EFCore.Tests/Metadata/Internal/SkipNavigationTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/SkipNavigationTest.cs @@ -69,7 +69,6 @@ public void Can_set_foreign_key() Assert.Null(navigation.GetForeignKeyConfigurationSource()); } - [ConditionalFact] public void Setting_foreign_key_to_skip_navigation_with_wrong_dependent_throws() { @@ -136,10 +135,11 @@ public void Setting_foreign_key_with_wrong_inverse_throws() productsNavigation.SetInverse(ordersNavigation); - Assert.Equal(CoreStrings.SkipInverseMismatchedForeignKey( - "{'" + orderProductFkProperty.Name + "'}", - nameof(Order.Products), nameof(OrderProduct), - nameof(Product.Orders), nameof(Product)), + Assert.Equal( + CoreStrings.SkipInverseMismatchedForeignKey( + "{'" + orderProductFkProperty.Name + "'}", + nameof(Order.Products), nameof(OrderProduct), + nameof(Product.Orders), nameof(Product)), Assert.Throws(() => productsNavigation.SetForeignKey(orderProductForeignKey)).Message); } @@ -177,7 +177,8 @@ public void Can_set_inverse() Assert.Equal(ConfigurationSource.Explicit, ((IConventionSkipNavigation)productsNavigation).GetInverseConfigurationSource()); Assert.Equal(ConfigurationSource.Explicit, ((IConventionSkipNavigation)ordersNavigation).GetInverseConfigurationSource()); - Assert.Equal(CoreStrings.SkipNavigationInUseBySkipNavigation(nameof(Order.Products), nameof(Product.Orders), nameof(Product)), + Assert.Equal( + CoreStrings.SkipNavigationInUseBySkipNavigation(nameof(Order.Products), nameof(Product.Orders), nameof(Product)), Assert.Throws(() => orderEntity.RemoveSkipNavigation(productsNavigation)).Message); productsNavigation.SetInverse(null); @@ -211,7 +212,8 @@ public void Setting_inverse_targetting_wrong_type_throws() var ordersNavigation = orderProductEntity.AddSkipNavigation(nameof(OrderProduct.Product), null, productEntity, false, true); ordersNavigation.SetForeignKey(productOrderForeignKey); - Assert.Equal(CoreStrings.SkipNavigationWrongInverse( + Assert.Equal( + CoreStrings.SkipNavigationWrongInverse( nameof(OrderProduct.Product), nameof(OrderProduct), nameof(Order.Products), nameof(Product)), Assert.Throws(() => productsNavigation.SetInverse(ordersNavigation)).Message); } @@ -240,12 +242,14 @@ public void Setting_inverse_with_wrong_join_type_throws() var ordersNavigation = productEntity.AddSkipNavigation(nameof(Product.Orders), null, orderEntity, true, false); ordersNavigation.SetForeignKey(productOrderForeignKey); - Assert.Equal(CoreStrings.SkipInverseMismatchedJoinType( + Assert.Equal( + CoreStrings.SkipInverseMismatchedJoinType( nameof(Product.Orders), nameof(Product), nameof(Order.Products), nameof(OrderProduct)), Assert.Throws(() => productsNavigation.SetInverse(ordersNavigation)).Message); } - private static IMutableModel CreateModel() => new Model(); + private static IMutableModel CreateModel() + => new Model(); private class Order { diff --git a/test/EFCore.Tests/Metadata/MetadataBuilderTest.cs b/test/EFCore.Tests/Metadata/MetadataBuilderTest.cs index 827cb68c12b..7fef69d7c57 100644 --- a/test/EFCore.Tests/Metadata/MetadataBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/MetadataBuilderTest.cs @@ -460,7 +460,8 @@ public static EntityTypeBuilder EntityBuilderExtension(this EntityTypeBuilder bu } public static EntityTypeBuilder GenericEntityBuilderExtension( - this EntityTypeBuilder builder, string value) + this EntityTypeBuilder builder, + string value) where TEntity : class { builder.HasAnnotation("Annotation", value + ".Annotation"); @@ -535,7 +536,8 @@ public static EntityTypeBuilder SharedNameExtension(this EntityTypeBuilder build } public static EntityTypeBuilder SharedNameExtension( - this EntityTypeBuilder builder, string value) + this EntityTypeBuilder builder, + string value) where TEntity : class { builder.HasAnnotation("Annotation", value + ".Annotation"); diff --git a/test/EFCore.Tests/Metadata/NavigationExtensionsTest.cs b/test/EFCore.Tests/Metadata/NavigationExtensionsTest.cs index 57509d1ea20..fad8d497a79 100644 --- a/test/EFCore.Tests/Metadata/NavigationExtensionsTest.cs +++ b/test/EFCore.Tests/Metadata/NavigationExtensionsTest.cs @@ -103,8 +103,10 @@ private class Product } private static IModel BuildModel( - bool createProducts = true, bool createCategory = true, - bool createFeaturedProductCategory = true, bool createFeaturedProduct = true) + bool createProducts = true, + bool createCategory = true, + bool createFeaturedProductCategory = true, + bool createFeaturedProduct = true) { var builder = InMemoryTestHelpers.Instance.CreateConventionBuilder(); var model = builder.Model; diff --git a/test/EFCore.Tests/ModelBuilding/ManyToManyTestBase.cs b/test/EFCore.Tests/ModelBuilding/ManyToManyTestBase.cs index 4e397615e92..f4f2405bef7 100644 --- a/test/EFCore.Tests/ModelBuilding/ManyToManyTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/ManyToManyTestBase.cs @@ -71,26 +71,28 @@ public virtual void Finds_existing_navigations_and_uses_associated_FK_with_field .HasMany(p => p.Dependents) .WithMany(d => d.ManyToManyPrincipals) .UsingEntity( - jwf => jwf.HasOne(j => j.DependentWithField) + jwf => jwf.HasOne(j => j.DependentWithField) .WithMany(), - jwf => jwf.HasOne(j => j.ManyToManyPrincipalWithField) + jwf => jwf.HasOne(j => j.ManyToManyPrincipalWithField) .WithMany()) .HasKey(j => new { j.DependentWithFieldId, j.ManyToManyPrincipalWithFieldId }); - modelBuilder.Entity(e => - { - e.Property(p => p.Id); - e.Property(p => p.Name); - e.HasKey(p => p.Id); - }); - modelBuilder.Entity(e => - { - e.Property(d => d.DependentWithFieldId); - e.Property(d => d.AnotherOneToManyPrincipalId); - e.Ignore(d => d.OneToManyPrincipal); - e.Ignore(d => d.OneToOnePrincipal); - e.HasKey(d => d.DependentWithFieldId); - }); + modelBuilder.Entity( + e => + { + e.Property(p => p.Id); + e.Property(p => p.Name); + e.HasKey(p => p.Id); + }); + modelBuilder.Entity( + e => + { + e.Property(d => d.DependentWithFieldId); + e.Property(d => d.AnotherOneToManyPrincipalId); + e.Ignore(d => d.OneToManyPrincipal); + e.Ignore(d => d.OneToOnePrincipal); + e.HasKey(d => d.DependentWithFieldId); + }); var principalEntityType = model.FindEntityType(typeof(ManyToManyPrincipalWithField)); var dependentEntityType = model.FindEntityType(typeof(DependentWithField)); @@ -110,9 +112,9 @@ public virtual void Finds_existing_navigations_and_uses_associated_FK_with_field .HasMany(p => p.Dependents) .WithMany(d => d.ManyToManyPrincipals) .UsingEntity( - jwf => jwf.HasOne(j => j.DependentWithField) + jwf => jwf.HasOne(j => j.DependentWithField) .WithMany(), - jwf => jwf.HasOne(j => j.ManyToManyPrincipalWithField) + jwf => jwf.HasOne(j => j.ManyToManyPrincipalWithField) .WithMany()); model = modelBuilder.FinalizeModel(); @@ -160,9 +162,11 @@ public virtual void Join_type_is_automatically_configured_by_convention() var key = joinEntityType.FindPrimaryKey(); Assert.Equal( - new[] { + new[] + { nameof(ImplicitManyToManyB.As) + nameof(ImplicitManyToManyA.Id), - nameof(ImplicitManyToManyA.Bs) + nameof(ImplicitManyToManyB.Id) }, + nameof(ImplicitManyToManyA.Bs) + nameof(ImplicitManyToManyB.Id) + }, key.Properties.Select(p => p.Name)); Assert.DoesNotContain(joinEntityType.GetProperties(), p => !p.IsIndexerProperty()); @@ -178,8 +182,9 @@ public virtual void Join_type_is_not_automatically_configured_when_navigations_a var hob = model.FindEntityType(typeof(Hob)); var nob = model.FindEntityType(typeof(Nob)); - Assert.Empty(model.GetEntityTypes() - .Where(et => ((EntityType)et).IsImplicitlyCreatedJoinEntityType)); + Assert.Empty( + model.GetEntityTypes() + .Where(et => ((EntityType)et).IsImplicitlyCreatedJoinEntityType)); Assert.Empty(hob.GetSkipNavigations()); Assert.Empty(nob.GetSkipNavigations()); @@ -301,8 +306,8 @@ public virtual void Throws_for_many_to_many_with_only_one_navigation_configured( nameof(NavDependent)), Assert.Throws( () => modelBuilder.Entity() - .HasMany(/* leaving empty causes the exception */) - .WithMany(d => d.ManyToManyPrincipals)).Message); + .HasMany( /* leaving empty causes the exception */) + .WithMany(d => d.ManyToManyPrincipals)).Message); } [ConditionalFact] @@ -347,7 +352,8 @@ public virtual void Skip_navigation_field_can_be_set_via_attribute() var model = modelBuilder.FinalizeModel(); - Assert.Equal("_randomField", model.FindEntityType(typeof(ManyToManyNavPrincipal)).FindSkipNavigation("Dependents").GetFieldName()); + Assert.Equal( + "_randomField", model.FindEntityType(typeof(ManyToManyNavPrincipal)).FindSkipNavigation("Dependents").GetFieldName()); } [ConditionalFact] @@ -361,9 +367,10 @@ public virtual void IsRequired_throws() Assert.Equal( CoreStrings.RequiredSkipNavigation(nameof(ManyToManyNavPrincipal), nameof(ManyToManyNavPrincipal.Dependents)), - Assert.Throws(() => modelBuilder.Entity() - .Navigation(p => p.Dependents) - .IsRequired()).Message); + Assert.Throws( + () => modelBuilder.Entity() + .Navigation(p => p.Dependents) + .IsRequired()).Message); } [ConditionalFact] @@ -495,8 +502,9 @@ public virtual void Unconfigured_many_to_many_navigations_throw() modelBuilder.Entity(); Assert.Equal( - CoreStrings.NavigationNotAdded(typeof(AmbiguousManyToManyImplicitLeft).DisplayName(fullName: false), "Navigation1", - typeof(List).DisplayName(fullName: false)), + CoreStrings.NavigationNotAdded( + typeof(AmbiguousManyToManyImplicitLeft).DisplayName(fullName: false), "Navigation1", + typeof(List).DisplayName(fullName: false)), Assert.Throws(() => modelBuilder.FinalizeModel()).Message); } } diff --git a/test/EFCore.Tests/ModelBuilding/ManyToOneTestBase.cs b/test/EFCore.Tests/ModelBuilding/ManyToOneTestBase.cs index a2078a53c58..4fac3d28b05 100644 --- a/test/EFCore.Tests/ModelBuilding/ManyToOneTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/ManyToOneTestBase.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.Generic; using System.Linq; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; @@ -58,22 +57,24 @@ public virtual void Finds_existing_navigations_and_uses_associated_FK_with_field var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; - modelBuilder.Entity(e => - { - e.Property(p => p.Id); - e.Property(p => p.AlternateKey); - e.Property(p => p.Name); - e.HasKey(p => p.Id); - }); - modelBuilder.Entity(e => - { - e.Property(d => d.DependentWithFieldId); - e.Property(d => d.OneToManyPrincipalId); - e.Property(d => d.AnotherOneToManyPrincipalId); - e.Ignore(d => d.ManyToManyPrincipals); - e.Ignore(d => d.OneToOnePrincipal); - e.HasKey(d => d.DependentWithFieldId); - }); + modelBuilder.Entity( + e => + { + e.Property(p => p.Id); + e.Property(p => p.AlternateKey); + e.Property(p => p.Name); + e.HasKey(p => p.Id); + }); + modelBuilder.Entity( + e => + { + e.Property(d => d.DependentWithFieldId); + e.Property(d => d.OneToManyPrincipalId); + e.Property(d => d.AnotherOneToManyPrincipalId); + e.Ignore(d => d.ManyToManyPrincipals); + e.Ignore(d => d.OneToOnePrincipal); + e.HasKey(d => d.DependentWithFieldId); + }); modelBuilder.Entity() .HasMany(p => p.Dependents) diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilder.Other.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilder.Other.cs index 5b9781931f4..4cf1296b409 100644 --- a/test/EFCore.Tests/ModelBuilding/ModelBuilder.Other.cs +++ b/test/EFCore.Tests/ModelBuilding/ModelBuilder.Other.cs @@ -345,7 +345,8 @@ protected virtual void RunThroughDifferPipeline(DbContext context) protected class TestModelCacheKeyFactory : IModelCacheKeyFactory { - public object Create(DbContext context) => new object(); + public object Create(DbContext context) + => new object(); } protected class OneDee diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericRelationshipStringTest.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericRelationshipStringTest.cs index b5ce65e9a69..f8d8d553e76 100644 --- a/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericRelationshipStringTest.cs +++ b/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericRelationshipStringTest.cs @@ -77,7 +77,8 @@ public override TestModelBuilder Ignore() return this; } - public override string GetDisplayName(Type entityType) => entityType.FullName; + public override string GetDisplayName(Type entityType) + => entityType.FullName; } private class GenericStringTestEntityTypeBuilder : GenericTestEntityTypeBuilder diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericTest.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericTest.cs index ae0c7032741..336d9ed50ba 100644 --- a/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericTest.cs +++ b/test/EFCore.Tests/ModelBuilding/ModelBuilderGenericTest.cs @@ -40,7 +40,8 @@ private class TestConvention : IEntityTypeAddedConvention public bool Applied { get; private set; } public void ProcessEntityTypeAdded( - IConventionEntityTypeBuilder entityTypeBuilder, IConventionContext context) + IConventionEntityTypeBuilder entityTypeBuilder, + IConventionContext context) { Applied = true; } @@ -166,7 +167,9 @@ public GenericTestEntityTypeBuilder(EntityTypeBuilder entityTypeBuilder } protected EntityTypeBuilder EntityTypeBuilder { get; } - public override IMutableEntityType Metadata => EntityTypeBuilder.Metadata; + + public override IMutableEntityType Metadata + => EntityTypeBuilder.Metadata; protected virtual TestEntityTypeBuilder Wrap(EntityTypeBuilder entityTypeBuilder) => new GenericTestEntityTypeBuilder(entityTypeBuilder); @@ -225,10 +228,12 @@ public override TestIndexBuilder HasIndex(params string[] propertyNames => new GenericTestIndexBuilder(EntityTypeBuilder.HasIndex(propertyNames)); public override TestOwnedNavigationBuilder OwnsOne(string navigationName) - => new GenericTestOwnedNavigationBuilder(EntityTypeBuilder.OwnsOne(navigationName)); + => new GenericTestOwnedNavigationBuilder( + EntityTypeBuilder.OwnsOne(navigationName)); public override TestOwnedNavigationBuilder OwnsOne( - string entityTypeName, string navigationName) + string entityTypeName, + string navigationName) => new GenericTestOwnedNavigationBuilder( EntityTypeBuilder.OwnsOne(entityTypeName, navigationName)); @@ -241,7 +246,8 @@ public override TestEntityTypeBuilder OwnsOne( r => buildAction(new GenericTestOwnedNavigationBuilder(r)))); public override TestEntityTypeBuilder OwnsOne( - string entityTypeName, string navigationName, + string entityTypeName, + string navigationName, Action> buildAction) => Wrap( EntityTypeBuilder.OwnsOne( @@ -253,9 +259,11 @@ public override TestOwnedNavigationBuilder OwnsOne new GenericTestOwnedNavigationBuilder(EntityTypeBuilder.OwnsOne(navigationExpression)); public override TestOwnedNavigationBuilder OwnsOne( - string entityTypeName, Expression> navigationExpression) - => new GenericTestOwnedNavigationBuilder(EntityTypeBuilder.OwnsOne( - entityTypeName, navigationExpression)); + string entityTypeName, + Expression> navigationExpression) + => new GenericTestOwnedNavigationBuilder( + EntityTypeBuilder.OwnsOne( + entityTypeName, navigationExpression)); public override TestEntityTypeBuilder OwnsOne( Expression> navigationExpression, @@ -266,7 +274,8 @@ public override TestEntityTypeBuilder OwnsOne( r => buildAction(new GenericTestOwnedNavigationBuilder(r)))); public override TestEntityTypeBuilder OwnsOne( - string entityTypeName, Expression> navigationExpression, + string entityTypeName, + Expression> navigationExpression, Action> buildAction) => Wrap( EntityTypeBuilder.OwnsOne( @@ -276,10 +285,13 @@ public override TestEntityTypeBuilder OwnsOne( public override TestOwnedNavigationBuilder OwnsMany(string navigationName) => new GenericTestOwnedNavigationBuilder( EntityTypeBuilder.OwnsMany(navigationName)); + public override TestOwnedNavigationBuilder OwnsMany( - string entityTypeName, string navigationName) + string entityTypeName, + string navigationName) => new GenericTestOwnedNavigationBuilder( EntityTypeBuilder.OwnsMany(entityTypeName, navigationName)); + public override TestEntityTypeBuilder OwnsMany( string navigationName, Action> buildAction) @@ -289,7 +301,8 @@ public override TestEntityTypeBuilder OwnsMany( r => buildAction(new GenericTestOwnedNavigationBuilder(r)))); public override TestEntityTypeBuilder OwnsMany( - string entityTypeName, string navigationName, + string entityTypeName, + string navigationName, Action> buildAction) => Wrap( EntityTypeBuilder.OwnsMany( @@ -302,7 +315,8 @@ public override TestOwnedNavigationBuilder OwnsMany OwnsMany( - string entityTypeName, Expression>> navigationExpression) + string entityTypeName, + Expression>> navigationExpression) => new GenericTestOwnedNavigationBuilder( EntityTypeBuilder.OwnsMany(entityTypeName, navigationExpression)); @@ -315,7 +329,8 @@ public override TestEntityTypeBuilder OwnsMany( r => buildAction(new GenericTestOwnedNavigationBuilder(r)))); public override TestEntityTypeBuilder OwnsMany( - string entityTypeName, Expression>> navigationExpression, + string entityTypeName, + Expression>> navigationExpression, Action> buildAction) => Wrap( EntityTypeBuilder.OwnsMany( @@ -369,7 +384,8 @@ public override TestDiscriminatorBuilder HasDiscriminator HasNoDiscriminator() => Wrap(EntityTypeBuilder.HasNoDiscriminator()); - public EntityTypeBuilder Instance => EntityTypeBuilder; + public EntityTypeBuilder Instance + => EntityTypeBuilder; } protected class GenericTestDiscriminatorBuilder : TestDiscriminatorBuilder @@ -411,7 +427,8 @@ public GenericTestOwnedEntityTypeBuilder(OwnedEntityTypeBuilder ownedEn protected OwnedEntityTypeBuilder OwnedEntityTypeBuilder { get; } - public OwnedEntityTypeBuilder Instance => OwnedEntityTypeBuilder; + public OwnedEntityTypeBuilder Instance + => OwnedEntityTypeBuilder; } protected class GenericTestPropertyBuilder : TestPropertyBuilder, IInfrastructure> @@ -423,7 +440,8 @@ public GenericTestPropertyBuilder(PropertyBuilder propertyBuilder) private PropertyBuilder PropertyBuilder { get; } - public override IMutableProperty Metadata => PropertyBuilder.Metadata; + public override IMutableProperty Metadata + => PropertyBuilder.Metadata; public override TestPropertyBuilder HasAnnotation(string annotation, object value) => new GenericTestPropertyBuilder(PropertyBuilder.HasAnnotation(annotation, value)); @@ -490,7 +508,8 @@ public override TestPropertyBuilder HasConversion(ValueCon public override TestPropertyBuilder HasConversion(ValueConverter converter) => new GenericTestPropertyBuilder(PropertyBuilder.HasConversion(converter)); - PropertyBuilder IInfrastructure>.Instance => PropertyBuilder; + PropertyBuilder IInfrastructure>.Instance + => PropertyBuilder; } protected class GenericTestKeyBuilder : TestKeyBuilder, IInfrastructure> @@ -502,12 +521,14 @@ public GenericTestKeyBuilder(KeyBuilder keyBuilder) private KeyBuilder KeyBuilder { get; } - public override IMutableKey Metadata => KeyBuilder.Metadata; + public override IMutableKey Metadata + => KeyBuilder.Metadata; public override TestKeyBuilder HasAnnotation(string annotation, object value) => new GenericTestKeyBuilder(KeyBuilder.HasAnnotation(annotation, value)); - KeyBuilder IInfrastructure>.Instance => KeyBuilder; + KeyBuilder IInfrastructure>.Instance + => KeyBuilder; } public class GenericTestIndexBuilder : TestIndexBuilder, IInfrastructure> @@ -518,7 +539,9 @@ public GenericTestIndexBuilder(IndexBuilder indexBuilder) } private IndexBuilder IndexBuilder { get; } - public override IMutableIndex Metadata => IndexBuilder.Metadata; + + public override IMutableIndex Metadata + => IndexBuilder.Metadata; public override TestIndexBuilder HasAnnotation(string annotation, object value) => new GenericTestIndexBuilder(IndexBuilder.HasAnnotation(annotation, value)); @@ -526,7 +549,8 @@ public override TestIndexBuilder HasAnnotation(string annotation, objec public override TestIndexBuilder IsUnique(bool isUnique = true) => new GenericTestIndexBuilder(IndexBuilder.IsUnique(isUnique)); - IndexBuilder IInfrastructure>.Instance => IndexBuilder; + IndexBuilder IInfrastructure>.Instance + => IndexBuilder; } protected class GenericTestNavigationBuilder : TestNavigationBuilder @@ -631,7 +655,8 @@ public GenericTestReferenceCollectionBuilder(ReferenceCollectionBuilder ReferenceCollectionBuilder { get; } - public override IMutableForeignKey Metadata => ReferenceCollectionBuilder.Metadata; + public override IMutableForeignKey Metadata + => ReferenceCollectionBuilder.Metadata; protected virtual GenericTestReferenceCollectionBuilder Wrap( ReferenceCollectionBuilder referenceCollectionBuilder) @@ -673,7 +698,8 @@ public GenericTestReferenceReferenceBuilder(ReferenceReferenceBuilder ReferenceReferenceBuilder { get; } - public override IMutableForeignKey Metadata => ReferenceReferenceBuilder.Metadata; + public override IMutableForeignKey Metadata + => ReferenceReferenceBuilder.Metadata; protected virtual GenericTestReferenceReferenceBuilder Wrap( ReferenceReferenceBuilder referenceReferenceBuilder) @@ -710,7 +736,8 @@ protected class GenericTestCollectionCollectionBuilder collectionCollectionBuilder) + public GenericTestCollectionCollectionBuilder( + CollectionCollectionBuilder collectionCollectionBuilder) { CollectionCollectionBuilder = collectionCollectionBuilder; } @@ -722,11 +749,12 @@ public override TestEntityTypeBuilder UsingEntity( TestReferenceCollectionBuilder> configureRight, Func, TestReferenceCollectionBuilder> configureLeft) - => new GenericTestEntityTypeBuilder(CollectionCollectionBuilder.UsingEntity( - l => ((GenericTestReferenceCollectionBuilder)configureRight( - new GenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, - r => ((GenericTestReferenceCollectionBuilder)configureLeft( - new GenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder)); + => new GenericTestEntityTypeBuilder( + CollectionCollectionBuilder.UsingEntity( + l => ((GenericTestReferenceCollectionBuilder)configureRight( + new GenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, + r => ((GenericTestReferenceCollectionBuilder)configureLeft( + new GenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder)); public override TestEntityTypeBuilder UsingEntity( string joinEntityName, @@ -734,12 +762,13 @@ public override TestEntityTypeBuilder UsingEntity( TestReferenceCollectionBuilder> configureRight, Func, TestReferenceCollectionBuilder> configureLeft) - => new GenericTestEntityTypeBuilder(CollectionCollectionBuilder.UsingEntity( - joinEntityName, - l => ((GenericTestReferenceCollectionBuilder)configureRight( - new GenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, - r => ((GenericTestReferenceCollectionBuilder)configureLeft( - new GenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder)); + => new GenericTestEntityTypeBuilder( + CollectionCollectionBuilder.UsingEntity( + joinEntityName, + l => ((GenericTestReferenceCollectionBuilder)configureRight( + new GenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, + r => ((GenericTestReferenceCollectionBuilder)configureLeft( + new GenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder)); public override TestEntityTypeBuilder UsingEntity( Func, @@ -748,12 +777,13 @@ public override TestEntityTypeBuilder UsingEntity( TestReferenceCollectionBuilder> configureLeft, Action> configureJoin) where TJoinEntity : class - => new GenericTestEntityTypeBuilder(CollectionCollectionBuilder.UsingEntity( - l => ((GenericTestReferenceCollectionBuilder)configureRight( - new GenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, - r => ((GenericTestReferenceCollectionBuilder)configureLeft( - new GenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder, - e => configureJoin(new GenericTestEntityTypeBuilder(e)))); + => new GenericTestEntityTypeBuilder( + CollectionCollectionBuilder.UsingEntity( + l => ((GenericTestReferenceCollectionBuilder)configureRight( + new GenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, + r => ((GenericTestReferenceCollectionBuilder)configureLeft( + new GenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder, + e => configureJoin(new GenericTestEntityTypeBuilder(e)))); public override TestEntityTypeBuilder UsingEntity( string joinEntityName, @@ -763,13 +793,14 @@ public override TestEntityTypeBuilder UsingEntity( TestReferenceCollectionBuilder> configureLeft, Action> configureJoin) where TJoinEntity : class - => new GenericTestEntityTypeBuilder(CollectionCollectionBuilder.UsingEntity( - joinEntityName, - l => ((GenericTestReferenceCollectionBuilder)configureRight( - new GenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, - r => ((GenericTestReferenceCollectionBuilder)configureLeft( - new GenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder, - e => configureJoin(new GenericTestEntityTypeBuilder(e)))); + => new GenericTestEntityTypeBuilder( + CollectionCollectionBuilder.UsingEntity( + joinEntityName, + l => ((GenericTestReferenceCollectionBuilder)configureRight( + new GenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, + r => ((GenericTestReferenceCollectionBuilder)configureLeft( + new GenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder, + e => configureJoin(new GenericTestEntityTypeBuilder(e)))); } protected class GenericTestOwnershipBuilder @@ -784,7 +815,8 @@ public GenericTestOwnershipBuilder(OwnershipBuilder o protected OwnershipBuilder OwnershipBuilder { get; } - public override IMutableForeignKey Metadata => OwnershipBuilder.Metadata; + public override IMutableForeignKey Metadata + => OwnershipBuilder.Metadata; protected virtual GenericTestOwnershipBuilder Wrap( OwnershipBuilder ownershipBuilder) @@ -828,8 +860,11 @@ public GenericTestOwnedNavigationBuilder(OwnedNavigationBuilder OwnedNavigationBuilder { get; } - public override IMutableForeignKey Metadata => OwnedNavigationBuilder.Metadata; - public override IMutableEntityType OwnedEntityType => OwnedNavigationBuilder.OwnedEntityType; + public override IMutableForeignKey Metadata + => OwnedNavigationBuilder.Metadata; + + public override IMutableEntityType OwnedEntityType + => OwnedNavigationBuilder.OwnedEntityType; protected virtual GenericTestOwnedNavigationBuilder Wrap( OwnedNavigationBuilder ownershipBuilder) @@ -838,7 +873,8 @@ protected virtual GenericTestOwnedNavigationBuilder new GenericTestOwnedNavigationBuilder(ownershipBuilder); public override TestOwnedNavigationBuilder HasAnnotation( - string annotation, object value) + string annotation, + object value) => Wrap(OwnedNavigationBuilder.HasAnnotation(annotation, value)); public override TestKeyBuilder HasKey(Expression> keyExpression) @@ -894,7 +930,8 @@ public override TestOwnedNavigationBuilder Wrap(OwnedNavigationBuilder.OwnsOne(navigationExpression)); public override TestOwnedNavigationBuilder OwnsOne( - string entityTypeName, Expression> navigationExpression) + string entityTypeName, + Expression> navigationExpression) => Wrap(OwnedNavigationBuilder.OwnsOne(entityTypeName, navigationExpression)); public override TestOwnedNavigationBuilder OwnsOne( @@ -903,7 +940,8 @@ public override TestOwnedNavigationBuilder OwnsOne Wrap(OwnedNavigationBuilder.OwnsOne(navigationExpression, r => buildAction(Wrap(r)))); public override TestOwnedNavigationBuilder OwnsOne( - string entityTypeName, Expression> navigationExpression, + string entityTypeName, + Expression> navigationExpression, Action> buildAction) => Wrap(OwnedNavigationBuilder.OwnsOne(entityTypeName, navigationExpression, r => buildAction(Wrap(r)))); @@ -912,7 +950,8 @@ public override TestOwnedNavigationBuilder Wrap(OwnedNavigationBuilder.OwnsMany(navigationExpression)); public override TestOwnedNavigationBuilder OwnsMany( - string entityTypeName, Expression>> navigationExpression) + string entityTypeName, + Expression>> navigationExpression) => Wrap(OwnedNavigationBuilder.OwnsMany(entityTypeName, navigationExpression)); public override TestOwnedNavigationBuilder OwnsMany( @@ -921,7 +960,8 @@ public override TestOwnedNavigationBuilder OwnsMany Wrap(OwnedNavigationBuilder.OwnsMany(navigationExpression, r => buildAction(Wrap(r)))); public override TestOwnedNavigationBuilder OwnsMany( - string entityTypeName, Expression>> navigationExpression, + string entityTypeName, + Expression>> navigationExpression, Action> buildAction) => Wrap(OwnedNavigationBuilder.OwnsMany(entityTypeName, navigationExpression, r => buildAction(Wrap(r)))); diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs index 31db6988ebb..e87b1e69164 100644 --- a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs +++ b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericStringTest.cs @@ -115,7 +115,8 @@ public override TestModelBuilder Ignore() return this; } - public override string GetDisplayName(Type entityType) => entityType.FullName; + public override string GetDisplayName(Type entityType) + => entityType.FullName; } private class NonGenericStringTestEntityTypeBuilder : NonGenericTestEntityTypeBuilder @@ -237,17 +238,21 @@ public NonGenericStringTestReferenceReferenceBuilder(ReferenceReferenceBuilder r } public NonGenericStringTestReferenceReferenceBuilder HasForeignKey( - string dependentEntityTypeName, params string[] foreignKeyPropertyNames) + string dependentEntityTypeName, + params string[] foreignKeyPropertyNames) => new NonGenericStringTestReferenceReferenceBuilder( ReferenceReferenceBuilder.HasForeignKey(dependentEntityTypeName, foreignKeyPropertyNames)); public NonGenericStringTestReferenceReferenceBuilder HasPrincipalKey( - string principalEntityTypeName, params string[] keyPropertyNames) + string principalEntityTypeName, + params string[] keyPropertyNames) => new NonGenericStringTestReferenceReferenceBuilder (ReferenceReferenceBuilder.HasPrincipalKey(principalEntityTypeName, keyPropertyNames)); private ReferenceReferenceBuilder ReferenceReferenceBuilder { get; } - public IMutableForeignKey Metadata => ReferenceReferenceBuilder.Metadata; + + public IMutableForeignKey Metadata + => ReferenceReferenceBuilder.Metadata; } private class NonGenericStringTestReferenceCollectionBuilder @@ -258,7 +263,9 @@ public NonGenericStringTestReferenceCollectionBuilder(ReferenceCollectionBuilder } private ReferenceCollectionBuilder ReferenceCollectionBuilder { get; } - public IMutableForeignKey Metadata => ReferenceCollectionBuilder.Metadata; + + public IMutableForeignKey Metadata + => ReferenceCollectionBuilder.Metadata; } private class NonGenericStringTestOwnedNavigationBuilder diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericTest.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericTest.cs index fefd69e8ac7..e6659c09d77 100644 --- a/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericTest.cs +++ b/test/EFCore.Tests/ModelBuilding/ModelBuilderNonGenericTest.cs @@ -114,7 +114,9 @@ public NonGenericTestEntityTypeBuilder(EntityTypeBuilder entityTypeBuilder) } protected EntityTypeBuilder EntityTypeBuilder { get; } - public override IMutableEntityType Metadata => EntityTypeBuilder.Metadata; + + public override IMutableEntityType Metadata + => EntityTypeBuilder.Metadata; protected virtual NonGenericTestEntityTypeBuilder Wrap(EntityTypeBuilder entityTypeBuilder) => new NonGenericTestEntityTypeBuilder(entityTypeBuilder); @@ -186,9 +188,11 @@ public override TestOwnedNavigationBuilder OwnsOne OwnsOne( - string entityTypeName, string navigationName) + string entityTypeName, + string navigationName) => new NonGenericTestOwnedNavigationBuilder( EntityTypeBuilder.OwnsOne(entityTypeName, typeof(TRelatedEntity), navigationName)); + public override TestEntityTypeBuilder OwnsOne( string navigationName, Action> buildAction) @@ -197,6 +201,7 @@ public override TestEntityTypeBuilder OwnsOne( typeof(TRelatedEntity), navigationName, r => buildAction(new NonGenericTestOwnedNavigationBuilder(r)))); + public override TestEntityTypeBuilder OwnsOne( string entityTypeName, string navigationName, @@ -217,7 +222,8 @@ public override TestOwnedNavigationBuilder OwnsOne> navigationExpression) => new NonGenericTestOwnedNavigationBuilder( - EntityTypeBuilder.OwnsOne(entityTypeName, typeof(TRelatedEntity), navigationExpression.GetMemberAccess().GetSimpleMemberName())); + EntityTypeBuilder.OwnsOne( + entityTypeName, typeof(TRelatedEntity), navigationExpression.GetMemberAccess().GetSimpleMemberName())); public override TestEntityTypeBuilder OwnsOne( Expression> navigationExpression, @@ -242,6 +248,7 @@ public override TestEntityTypeBuilder OwnsOne( public override TestOwnedNavigationBuilder OwnsMany(string navigationName) => new NonGenericTestOwnedNavigationBuilder( EntityTypeBuilder.OwnsMany(typeof(TRelatedEntity), navigationName)); + public override TestEntityTypeBuilder OwnsMany( string navigationName, Action> buildAction) @@ -252,9 +259,11 @@ public override TestEntityTypeBuilder OwnsMany( r => buildAction(new NonGenericTestOwnedNavigationBuilder(r)))); public override TestOwnedNavigationBuilder OwnsMany( - string entityTypeName, string navigationName) + string entityTypeName, + string navigationName) => new NonGenericTestOwnedNavigationBuilder( EntityTypeBuilder.OwnsMany(entityTypeName, typeof(TRelatedEntity), navigationName)); + public override TestEntityTypeBuilder OwnsMany( string entityTypeName, string navigationName, @@ -275,7 +284,8 @@ public override TestOwnedNavigationBuilder OwnsMany>> navigationExpression) => new NonGenericTestOwnedNavigationBuilder( - EntityTypeBuilder.OwnsMany(entityTypeName, typeof(TRelatedEntity), navigationExpression.GetMemberAccess().GetSimpleMemberName())); + EntityTypeBuilder.OwnsMany( + entityTypeName, typeof(TRelatedEntity), navigationExpression.GetMemberAccess().GetSimpleMemberName())); public override TestEntityTypeBuilder OwnsMany( Expression>> navigationExpression, @@ -365,7 +375,8 @@ public override TestDiscriminatorBuilder HasDiscriminator HasNoDiscriminator() => Wrap(EntityTypeBuilder.HasNoDiscriminator()); - public EntityTypeBuilder Instance => EntityTypeBuilder; + public EntityTypeBuilder Instance + => EntityTypeBuilder; } protected class NonGenericTestDiscriminatorBuilder : TestDiscriminatorBuilder @@ -407,7 +418,8 @@ public NonGenericTestOwnedEntityTypeBuilder(OwnedEntityTypeBuilder ownedEntityTy protected OwnedEntityTypeBuilder OwnedEntityTypeBuilder { get; } - public OwnedEntityTypeBuilder Instance => OwnedEntityTypeBuilder; + public OwnedEntityTypeBuilder Instance + => OwnedEntityTypeBuilder; } protected class NonGenericTestPropertyBuilder : TestPropertyBuilder, IInfrastructure @@ -419,7 +431,8 @@ public NonGenericTestPropertyBuilder(PropertyBuilder propertyBuilder) private PropertyBuilder PropertyBuilder { get; } - public override IMutableProperty Metadata => PropertyBuilder.Metadata; + public override IMutableProperty Metadata + => PropertyBuilder.Metadata; public override TestPropertyBuilder HasAnnotation(string annotation, object value) => new NonGenericTestPropertyBuilder(PropertyBuilder.HasAnnotation(annotation, value)); @@ -485,7 +498,8 @@ public override TestPropertyBuilder HasConversion(ValueConver public override TestPropertyBuilder HasConversion(ValueConverter converter) => new NonGenericTestPropertyBuilder(PropertyBuilder.HasConversion(converter)); - PropertyBuilder IInfrastructure.Instance => PropertyBuilder; + PropertyBuilder IInfrastructure.Instance + => PropertyBuilder; } protected class NonGenericTestNavigationBuilder : TestNavigationBuilder @@ -522,12 +536,14 @@ public NonGenericTestKeyBuilder(KeyBuilder keyBuilder) private KeyBuilder KeyBuilder { get; } - public override IMutableKey Metadata => KeyBuilder.Metadata; + public override IMutableKey Metadata + => KeyBuilder.Metadata; public override TestKeyBuilder HasAnnotation(string annotation, object value) => new NonGenericTestKeyBuilder(KeyBuilder.HasAnnotation(annotation, value)); - KeyBuilder IInfrastructure.Instance => KeyBuilder; + KeyBuilder IInfrastructure.Instance + => KeyBuilder; } public class NonGenericTestIndexBuilder : TestIndexBuilder, IInfrastructure @@ -538,7 +554,9 @@ public NonGenericTestIndexBuilder(IndexBuilder indexBuilder) } private IndexBuilder IndexBuilder { get; } - public override IMutableIndex Metadata => IndexBuilder.Metadata; + + public override IMutableIndex Metadata + => IndexBuilder.Metadata; public override TestIndexBuilder HasAnnotation(string annotation, object value) => new NonGenericTestIndexBuilder(IndexBuilder.HasAnnotation(annotation, value)); @@ -546,7 +564,8 @@ public override TestIndexBuilder HasAnnotation(string annotation, objec public override TestIndexBuilder IsUnique(bool isUnique = true) => new NonGenericTestIndexBuilder(IndexBuilder.IsUnique(isUnique)); - IndexBuilder IInfrastructure.Instance => IndexBuilder; + IndexBuilder IInfrastructure.Instance + => IndexBuilder; } protected class @@ -628,7 +647,8 @@ public NonGenericTestReferenceCollectionBuilder(ReferenceCollectionBuilder refer public ReferenceCollectionBuilder ReferenceCollectionBuilder { get; } - public override IMutableForeignKey Metadata => ReferenceCollectionBuilder.Metadata; + public override IMutableForeignKey Metadata + => ReferenceCollectionBuilder.Metadata; public override TestReferenceCollectionBuilder HasForeignKey( Expression> foreignKeyExpression) @@ -674,7 +694,8 @@ public NonGenericTestReferenceReferenceBuilder(ReferenceReferenceBuilder referen protected ReferenceReferenceBuilder ReferenceReferenceBuilder { get; } - public override IMutableForeignKey Metadata => ReferenceReferenceBuilder.Metadata; + public override IMutableForeignKey Metadata + => ReferenceReferenceBuilder.Metadata; protected virtual NonGenericTestReferenceReferenceBuilder Wrap( ReferenceReferenceBuilder referenceReferenceBuilder) @@ -685,14 +706,16 @@ public override TestReferenceReferenceBuilder HasAnnota public override TestReferenceReferenceBuilder HasForeignKey( Expression> foreignKeyExpression) - => Wrap(ReferenceReferenceBuilder.HasForeignKey( - typeof(TDependentEntity), - foreignKeyExpression.GetMemberAccessList().Select(p => p.GetSimpleMemberName()).ToArray())); + => Wrap( + ReferenceReferenceBuilder.HasForeignKey( + typeof(TDependentEntity), + foreignKeyExpression.GetMemberAccessList().Select(p => p.GetSimpleMemberName()).ToArray())); public override TestReferenceReferenceBuilder HasPrincipalKey( Expression> keyExpression) - => Wrap(ReferenceReferenceBuilder.HasPrincipalKey( - typeof(TPrincipalEntity), keyExpression.GetMemberAccessList().Select(p => p.GetSimpleMemberName()).ToArray())); + => Wrap( + ReferenceReferenceBuilder.HasPrincipalKey( + typeof(TPrincipalEntity), keyExpression.GetMemberAccessList().Select(p => p.GetSimpleMemberName()).ToArray())); public override TestReferenceReferenceBuilder HasForeignKey( params string[] foreignKeyPropertyNames) @@ -726,12 +749,13 @@ public override TestEntityTypeBuilder UsingEntity( TestReferenceCollectionBuilder> configureRight, Func, TestReferenceCollectionBuilder> configureLeft) - => new NonGenericTestEntityTypeBuilder(CollectionCollectionBuilder.UsingEntity( - typeof(TJoinEntity), - l => ((NonGenericTestReferenceCollectionBuilder)configureRight( - new NonGenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, - r => ((NonGenericTestReferenceCollectionBuilder)configureLeft( - new NonGenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder)); + => new NonGenericTestEntityTypeBuilder( + CollectionCollectionBuilder.UsingEntity( + typeof(TJoinEntity), + l => ((NonGenericTestReferenceCollectionBuilder)configureRight( + new NonGenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, + r => ((NonGenericTestReferenceCollectionBuilder)configureLeft( + new NonGenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder)); public override TestEntityTypeBuilder UsingEntity( string joinEntityName, @@ -739,13 +763,14 @@ public override TestEntityTypeBuilder UsingEntity( TestReferenceCollectionBuilder> configureRight, Func, TestReferenceCollectionBuilder> configureLeft) - => new NonGenericTestEntityTypeBuilder(CollectionCollectionBuilder.UsingEntity( - joinEntityName, - typeof(TJoinEntity), - l => ((NonGenericTestReferenceCollectionBuilder)configureRight( - new NonGenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, - r => ((NonGenericTestReferenceCollectionBuilder)configureLeft( - new NonGenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder)); + => new NonGenericTestEntityTypeBuilder( + CollectionCollectionBuilder.UsingEntity( + joinEntityName, + typeof(TJoinEntity), + l => ((NonGenericTestReferenceCollectionBuilder)configureRight( + new NonGenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, + r => ((NonGenericTestReferenceCollectionBuilder)configureLeft( + new NonGenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder)); public override TestEntityTypeBuilder UsingEntity( Func, @@ -754,13 +779,14 @@ public override TestEntityTypeBuilder UsingEntity( TestReferenceCollectionBuilder> configureLeft, Action> configureJoin) where TJoinEntity : class - => new NonGenericTestEntityTypeBuilder(CollectionCollectionBuilder.UsingEntity( - typeof(TJoinEntity), - l => ((NonGenericTestReferenceCollectionBuilder)configureRight( - new NonGenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, - r => ((NonGenericTestReferenceCollectionBuilder)configureLeft( - new NonGenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder, - e => configureJoin(new NonGenericTestEntityTypeBuilder(e)))); + => new NonGenericTestEntityTypeBuilder( + CollectionCollectionBuilder.UsingEntity( + typeof(TJoinEntity), + l => ((NonGenericTestReferenceCollectionBuilder)configureRight( + new NonGenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, + r => ((NonGenericTestReferenceCollectionBuilder)configureLeft( + new NonGenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder, + e => configureJoin(new NonGenericTestEntityTypeBuilder(e)))); public override TestEntityTypeBuilder UsingEntity( string joinEntityName, @@ -770,14 +796,15 @@ public override TestEntityTypeBuilder UsingEntity( TestReferenceCollectionBuilder> configureLeft, Action> configureJoin) where TJoinEntity : class - => new NonGenericTestEntityTypeBuilder(CollectionCollectionBuilder.UsingEntity( - joinEntityName, - typeof(TJoinEntity), - l => ((NonGenericTestReferenceCollectionBuilder)configureRight( - new NonGenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, - r => ((NonGenericTestReferenceCollectionBuilder)configureLeft( - new NonGenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder, - e => configureJoin(new NonGenericTestEntityTypeBuilder(e)))); + => new NonGenericTestEntityTypeBuilder( + CollectionCollectionBuilder.UsingEntity( + joinEntityName, + typeof(TJoinEntity), + l => ((NonGenericTestReferenceCollectionBuilder)configureRight( + new NonGenericTestEntityTypeBuilder(l))).ReferenceCollectionBuilder, + r => ((NonGenericTestReferenceCollectionBuilder)configureLeft( + new NonGenericTestEntityTypeBuilder(r))).ReferenceCollectionBuilder, + e => configureJoin(new NonGenericTestEntityTypeBuilder(e)))); } protected class NonGenericTestOwnershipBuilder @@ -792,7 +819,8 @@ public NonGenericTestOwnershipBuilder(OwnershipBuilder ownershipBuilder) protected OwnershipBuilder OwnershipBuilder { get; } - public override IMutableForeignKey Metadata => OwnershipBuilder.Metadata; + public override IMutableForeignKey Metadata + => OwnershipBuilder.Metadata; protected virtual NonGenericTestOwnershipBuilder Wrap( OwnershipBuilder ownershipBuilder) @@ -823,7 +851,8 @@ public override TestOwnershipBuilder HasPrincipalKey( OwnershipBuilder.HasPrincipalKey( keyExpression.GetMemberAccessList().Select(p => p.GetSimpleMemberName()).ToArray())); - OwnershipBuilder IInfrastructure.Instance => OwnershipBuilder; + OwnershipBuilder IInfrastructure.Instance + => OwnershipBuilder; } protected class NonGenericTestOwnedNavigationBuilder @@ -838,8 +867,11 @@ public NonGenericTestOwnedNavigationBuilder(OwnedNavigationBuilder ownedNavigati protected OwnedNavigationBuilder OwnedNavigationBuilder { get; } - public override IMutableForeignKey Metadata => OwnedNavigationBuilder.Metadata; - public override IMutableEntityType OwnedEntityType => OwnedNavigationBuilder.OwnedEntityType; + public override IMutableForeignKey Metadata + => OwnedNavigationBuilder.Metadata; + + public override IMutableEntityType OwnedEntityType + => OwnedNavigationBuilder.OwnedEntityType; protected virtual NonGenericTestOwnedNavigationBuilder Wrap( OwnedNavigationBuilder ownedNavigationBuilder) @@ -848,7 +880,8 @@ protected virtual NonGenericTestOwnedNavigationBuilder new NonGenericTestOwnedNavigationBuilder(ownedNavigationBuilder); public override TestOwnedNavigationBuilder HasAnnotation( - string annotation, object value) + string annotation, + object value) => Wrap(OwnedNavigationBuilder.HasAnnotation(annotation, value)); public override TestKeyBuilder HasKey(Expression> keyExpression) @@ -1013,7 +1046,8 @@ public override DataBuilder HasData(IEnumerable data) return new DataBuilder(); } - OwnedNavigationBuilder IInfrastructure.Instance => OwnedNavigationBuilder; + OwnedNavigationBuilder IInfrastructure.Instance + => OwnedNavigationBuilder; } } } diff --git a/test/EFCore.Tests/ModelBuilding/ModelBuilderTestBase.cs b/test/EFCore.Tests/ModelBuilding/ModelBuilderTestBase.cs index 022c52a9a9d..0b01b574ffc 100644 --- a/test/EFCore.Tests/ModelBuilding/ModelBuilderTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/ModelBuilderTestBase.cs @@ -134,7 +134,9 @@ protected TestModelBuilder(TestHelpers testHelpers) ModelBuilder = testHelpers.CreateConventionBuilder(modelLogger, validationLogger); } - public virtual IMutableModel Model => ModelBuilder.Model; + public virtual IMutableModel Model + => ModelBuilder.Model; + public ModelBuilder ModelBuilder { get; } public ListLoggerFactory ValidationLoggerFactory { get; } public ListLoggerFactory ModelLoggerFactory { get; } @@ -163,9 +165,11 @@ public abstract TestModelBuilder SharedTypeEntity(string name, Action() where TEntity : class; - public virtual IModel FinalizeModel() => ModelBuilder.FinalizeModel(); + public virtual IModel FinalizeModel() + => ModelBuilder.FinalizeModel(); - public virtual string GetDisplayName(Type entityType) => entityType.Name; + public virtual string GetDisplayName(Type entityType) + => entityType.Name; public virtual TestModelBuilder UsePropertyAccessMode(PropertyAccessMode propertyAccessMode) { @@ -199,11 +203,11 @@ public abstract TestPropertyBuilder Property( public abstract TestNavigationBuilder Navigation( Expression> navigationExpression) - where TNavigation : class; + where TNavigation : class; public abstract TestNavigationBuilder Navigation( Expression>> navigationExpression) - where TNavigation : class; + where TNavigation : class; public abstract TestEntityTypeBuilder Ignore( Expression> propertyExpression); @@ -215,16 +219,20 @@ public abstract TestEntityTypeBuilder Ignore( public abstract TestOwnedNavigationBuilder OwnsOne(string navigationName) where TRelatedEntity : class; + public abstract TestOwnedNavigationBuilder OwnsOne( - string entityTypeName, string navigationName) + string entityTypeName, + string navigationName) where TRelatedEntity : class; + public abstract TestEntityTypeBuilder OwnsOne( string navigationName, Action> buildAction) where TRelatedEntity : class; public abstract TestEntityTypeBuilder OwnsOne( - string entityTypeName, string navigationName, + string entityTypeName, + string navigationName, Action> buildAction) where TRelatedEntity : class; @@ -233,7 +241,8 @@ public abstract TestOwnedNavigationBuilder OwnsOne OwnsOne( - string entityTypeName, Expression> navigationExpression) + string entityTypeName, + Expression> navigationExpression) where TRelatedEntity : class; public abstract TestEntityTypeBuilder OwnsOne( @@ -242,22 +251,27 @@ public abstract TestEntityTypeBuilder OwnsOne( where TRelatedEntity : class; public abstract TestEntityTypeBuilder OwnsOne( - string entityTypeName, Expression> navigationExpression, + string entityTypeName, + Expression> navigationExpression, Action> buildAction) where TRelatedEntity : class; public abstract TestOwnedNavigationBuilder OwnsMany(string navigationName) where TRelatedEntity : class; + public abstract TestOwnedNavigationBuilder OwnsMany( - string entityTypeName, string navigationName) + string entityTypeName, + string navigationName) where TRelatedEntity : class; + public abstract TestEntityTypeBuilder OwnsMany( string navigationName, Action> buildAction) where TRelatedEntity : class; public abstract TestEntityTypeBuilder OwnsMany( - string entityTypeName, string navigationName, + string entityTypeName, + string navigationName, Action> buildAction) where TRelatedEntity : class; @@ -266,7 +280,8 @@ public abstract TestOwnedNavigationBuilder OwnsMany OwnsMany( - string entityTypeName, Expression>> navigationExpression) + string entityTypeName, + Expression>> navigationExpression) where TRelatedEntity : class; public abstract TestEntityTypeBuilder OwnsMany( @@ -275,7 +290,8 @@ public abstract TestEntityTypeBuilder OwnsMany( where TRelatedEntity : class; public abstract TestEntityTypeBuilder OwnsMany( - string entityTypeName, Expression>> navigationExpression, + string entityTypeName, + Expression>> navigationExpression, Action> buildAction) where TRelatedEntity : class; @@ -443,7 +459,8 @@ public abstract TestReferenceCollectionBuilder HasPrinc params string[] keyPropertyNames); public abstract TestReferenceCollectionBuilder HasAnnotation( - string annotation, object value); + string annotation, + object value); public abstract TestReferenceCollectionBuilder IsRequired(bool isRequired = true); @@ -457,7 +474,8 @@ public abstract class TestReferenceReferenceBuilder public abstract IMutableForeignKey Metadata { get; } public abstract TestReferenceReferenceBuilder HasAnnotation( - string annotation, object value); + string annotation, + object value); public abstract TestReferenceReferenceBuilder HasForeignKey( Expression> foreignKeyExpression) @@ -524,7 +542,8 @@ public abstract class TestOwnershipBuilder public abstract IMutableForeignKey Metadata { get; } public abstract TestOwnershipBuilder HasAnnotation( - string annotation, object value); + string annotation, + object value); public abstract TestOwnershipBuilder HasForeignKey( params string[] foreignKeyPropertyNames); @@ -547,7 +566,8 @@ public abstract class TestOwnedNavigationBuilder public abstract IMutableEntityType OwnedEntityType { get; } public abstract TestOwnedNavigationBuilder HasAnnotation( - string annotation, object value); + string annotation, + object value); public abstract TestKeyBuilder HasKey(Expression> keyExpression); public abstract TestKeyBuilder HasKey(params string[] propertyNames); @@ -560,11 +580,11 @@ public abstract TestPropertyBuilder Property( public abstract TestNavigationBuilder Navigation( Expression> navigationExpression) - where TNavigation : class; + where TNavigation : class; public abstract TestNavigationBuilder Navigation( Expression>> navigationExpression) - where TNavigation : class; + where TNavigation : class; public abstract TestOwnedNavigationBuilder Ignore(string propertyName); @@ -575,6 +595,7 @@ public abstract TestOwnedNavigationBuilder Ignore( public abstract TestIndexBuilder HasIndex(Expression> indexExpression); public abstract TestOwnershipBuilder WithOwner(string ownerReference); + public abstract TestOwnershipBuilder WithOwner( Expression> referenceExpression = null); @@ -583,7 +604,8 @@ public abstract TestOwnedNavigationBuilder where TNewRelatedEntity : class; public abstract TestOwnedNavigationBuilder OwnsOne( - string entityTypeName, Expression> navigationExpression) + string entityTypeName, + Expression> navigationExpression) where TNewRelatedEntity : class; public abstract TestOwnedNavigationBuilder OwnsOne( @@ -592,7 +614,8 @@ public abstract TestOwnedNavigationBuilder OwnsOne OwnsOne( - string entityTypeName, Expression> navigationExpression, + string entityTypeName, + Expression> navigationExpression, Action> buildAction) where TNewRelatedEntity : class; @@ -601,7 +624,8 @@ public abstract TestOwnedNavigationBuilder OwnsMany( - string entityTypeName, Expression>> navigationExpression) + string entityTypeName, + Expression>> navigationExpression) where TNewDependentEntity : class; public abstract TestOwnedNavigationBuilder OwnsMany( @@ -610,7 +634,8 @@ public abstract TestOwnedNavigationBuilder OwnsMany OwnsMany( - string entityTypeName, Expression>> navigationExpression, + string entityTypeName, + Expression>> navigationExpression, Action> buildAction) where TNewDependentEntity : class; diff --git a/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs b/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs index 025bc6fda2c..97899ca39fd 100644 --- a/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/NonRelationshipTestBase.cs @@ -1008,7 +1008,8 @@ public override int Next(EntityEntry entry) throw new NotImplementedException(); } - public override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; } [ConditionalFact] @@ -1226,12 +1227,14 @@ public virtual void Can_ignore_explicit_interface_implementation_property() var modelBuilder = CreateModelBuilder(); modelBuilder.Entity().Ignore(e => ((IEntityBase)e).Target); - Assert.DoesNotContain(nameof(IEntityBase.Target), + Assert.DoesNotContain( + nameof(IEntityBase.Target), modelBuilder.Model.FindEntityType(typeof(EntityBase)).GetProperties().Select(p => p.Name)); modelBuilder.Entity().Property(e => ((IEntityBase)e).Target); - Assert.Contains(nameof(IEntityBase.Target), + Assert.Contains( + nameof(IEntityBase.Target), modelBuilder.Model.FindEntityType(typeof(EntityBase)).GetProperties().Select(p => p.Name)); } @@ -1382,7 +1385,7 @@ public virtual void Can_ignore_a_field_on_a_keyless_entity_with_fields() modelBuilder.Entity() .HasNoKey() .Ignore(e => e.FirstName) - .Property(e => e.LastName); + .Property(e => e.LastName); var entity = modelBuilder.Model.FindEntityType(typeof(KeylessEntityWithFields)); var property = Assert.Single(entity.GetProperties()); @@ -1445,8 +1448,9 @@ public virtual void Private_property_is_not_discovered_by_convention() modelBuilder.FinalizeModel(); - Assert.Empty(modelBuilder.Model.FindEntityType(typeof(Gamma)).GetProperties() - .Where(p => p.Name == "PrivateProperty")); + Assert.Empty( + modelBuilder.Model.FindEntityType(typeof(Gamma)).GetProperties() + .Where(p => p.Name == "PrivateProperty")); } [ConditionalFact] diff --git a/test/EFCore.Tests/ModelBuilding/OneToManyTestBase.cs b/test/EFCore.Tests/ModelBuilding/OneToManyTestBase.cs index 85b18eb1623..73b6b743041 100644 --- a/test/EFCore.Tests/ModelBuilding/OneToManyTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/OneToManyTestBase.cs @@ -62,14 +62,16 @@ public virtual void Finds_existing_navigations_and_uses_associated_FK_with_field var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; - modelBuilder.Entity(e => + modelBuilder.Entity( + e => { e.Property(p => p.Id); e.Property(p => p.AlternateKey); e.Property(p => p.Name); e.HasKey(p => p.Id); }); - modelBuilder.Entity(e => + modelBuilder.Entity( + e => { e.Property(d => d.DependentWithFieldId); e.Property(d => d.OneToManyPrincipalId); @@ -2527,9 +2529,9 @@ public virtual void Attempt_to_configure_Navigation_property_which_is_actually_a CoreStrings.CanOnlyConfigureExistingNavigations("Name", "NavDependent"), Assert.Throws( () => modelBuilder.Entity() - .Navigation(e => e.Name) - .UsePropertyAccessMode(PropertyAccessMode.Property) - ).Message); + .Navigation(e => e.Name) + .UsePropertyAccessMode(PropertyAccessMode.Property) + ).Message); } [ConditionalFact] diff --git a/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs b/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs index 01b45213a35..89f8d8f2120 100644 --- a/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/OneToOneTestBase.cs @@ -58,20 +58,22 @@ public virtual void Finds_existing_navigations_and_uses_associated_FK_with_field var modelBuilder = CreateModelBuilder(); var model = modelBuilder.Model; - modelBuilder.Entity(e => - { - e.Property(p => p.Id); - e.Property(p => p.Name); - e.HasKey(p => p.Id); - }); - modelBuilder.Entity(e => - { - e.Property(d => d.DependentWithFieldId); - e.Property(d => d.OneToOnePrincipalId); - e.Ignore(d => d.ManyToManyPrincipals); - e.Ignore(d => d.OneToManyPrincipal); - e.HasKey(d => d.DependentWithFieldId); - }); + modelBuilder.Entity( + e => + { + e.Property(p => p.Id); + e.Property(p => p.Name); + e.HasKey(p => p.Id); + }); + modelBuilder.Entity( + e => + { + e.Property(d => d.DependentWithFieldId); + e.Property(d => d.OneToOnePrincipalId); + e.Ignore(d => d.ManyToManyPrincipals); + e.Ignore(d => d.OneToManyPrincipal); + e.HasKey(d => d.DependentWithFieldId); + }); modelBuilder.Entity() .HasOne(d => d.OneToOnePrincipal) @@ -3415,14 +3417,17 @@ public virtual void Throws_if_ambiguous_FK_made_required() .HasOne(e => e.Nob).WithOne(e => e.Hob) .IsRequired(); - Assert.Contains(modelBuilder.ModelLoggerFactory.Log, l => l.Level == LogLevel.Warning - && l.Message == CoreResources.LogAmbiguousEndRequired(new TestLogger()) - .GenerateMessage("{'NobId11', 'NobId21'}", typeof(Hob).Name)); + Assert.Contains( + modelBuilder.ModelLoggerFactory.Log, l => l.Level == LogLevel.Warning + && l.Message + == CoreResources.LogAmbiguousEndRequired(new TestLogger()) + .GenerateMessage("{'NobId11', 'NobId21'}", typeof(Hob).Name)); Assert.Equal( CoreStrings.AmbiguousEndRequiredInverted("{'NobId11', 'NobId21'}", typeof(Hob).Name, typeof(Nob).Name), - Assert.Throws(() => - foreignKeyBuilder.HasForeignKey()).Message); + Assert.Throws( + () => + foreignKeyBuilder.HasForeignKey()).Message); } [ConditionalFact] @@ -4027,7 +4032,6 @@ public virtual void Assert.Equal(OneToOnePrincipalEntity.EntityMatchingProperty.Name, fk.Properties.Single().Name); } - [ConditionalFact] public virtual void Multiple_self_referencing_navigations_throw_as_ambiguous() { diff --git a/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs b/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs index 1b7ddcaa18d..34c47792442 100644 --- a/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs +++ b/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs @@ -73,13 +73,14 @@ public virtual void Can_configure_one_to_one_owned_type_with_fields() var modelBuilder = CreateModelBuilder(); modelBuilder.Owned(); - modelBuilder.Entity(e => - { - e.Property(p => p.Id); - e.Property(p => p.AlternateKey); - e.Property(p => p.Description); - e.HasKey(p => p.Id); - }); + modelBuilder.Entity( + e => + { + e.Property(p => p.Id); + e.Property(p => p.AlternateKey); + e.Property(p => p.Description); + e.HasKey(p => p.Id); + }); modelBuilder.Entity() .OwnsOne( @@ -118,13 +119,14 @@ public virtual void Can_configure_one_to_many_owned_type_with_fields() var modelBuilder = CreateModelBuilder(); modelBuilder.Owned(); - modelBuilder.Entity(e => - { - e.Property(p => p.Id); - e.Property(p => p.AlternateKey); - e.Property(p => p.Description); - e.HasKey(p => p.Id); - }); + modelBuilder.Entity( + e => + { + e.Property(p => p.Id); + e.Property(p => p.AlternateKey); + e.Property(p => p.Description); + e.HasKey(p => p.Id); + }); modelBuilder.Entity() .OwnsMany( @@ -281,14 +283,14 @@ public virtual void Changing_ownership_uniqueness_throws() nameof(Customer)), Assert.Throws( () => modelBuilder - .Entity() - .OwnsOne( - c => c.Details, - r => - { - r.HasOne(d => d.Customer) - .WithMany(); - })).Message); + .Entity() + .OwnsOne( + c => c.Details, + r => + { + r.HasOne(d => d.Customer) + .WithMany(); + })).Message); } [ConditionalFact] @@ -495,7 +497,8 @@ public virtual void Can_configure_one_to_one_relationship_from_an_owned_type_col Assert.Equal("CustomerId", ownership2.Properties.Single().Name); var foreignKey = model.FindEntityType(typeof(SpecialCustomer)).GetReferencingForeignKeys() - .Single(fk => fk.DeclaringEntityType.ClrType == typeof(Order) + .Single( + fk => fk.DeclaringEntityType.ClrType == typeof(Order) && fk.PrincipalToDependent == null); Assert.Same(ownership1.DeclaringEntityType, foreignKey.DeclaringEntityType); Assert.Null(foreignKey.PrincipalToDependent); @@ -567,7 +570,7 @@ public virtual void Can_configure_owned_type_from_an_owned_type_collection(HasDa ownedNavigationBuilder.HasData(new List { new OrderDetails { OrderId = -1 } }); break; case HasDataOverload.Enumerable | HasDataOverload.Generic: - ownedNavigationBuilder.HasData(new List() { new OrderDetails { OrderId = -1 } }); + ownedNavigationBuilder.HasData(new List { new OrderDetails { OrderId = -1 } }); break; default: Assert.True(false, $"Unexpected HasData overload specification {hasDataOverload}"); @@ -606,12 +609,13 @@ public virtual void Can_chain_owned_type_collection_configurations() ob.HasKey(o => o.OrderId); ob.HasData( new Order { OrderId = -2, CustomerId = -1 }); - ob.OwnsMany(o => o.Products, pb => - { - pb.WithOwner(p => p.Order); - pb.Ignore(p => p.Categories); - pb.HasKey(p => p.Id); - }); + ob.OwnsMany( + o => o.Products, pb => + { + pb.WithOwner(p => p.Order); + pb.Ignore(p => p.Categories); + pb.HasKey(p => p.Id); + }); }); var model = modelBuilder.FinalizeModel(); @@ -647,11 +651,12 @@ public virtual void Can_configure_owned_type_collection_without_explicit_key() { r.Ignore(o => o.OrderCombination); r.Ignore(o => o.Details); - r.OwnsMany(o => o.Products, pb => - { - pb.WithOwner(p => p.Order); - pb.Ignore(p => p.Categories); - }); + r.OwnsMany( + o => o.Products, pb => + { + pb.WithOwner(p => p.Order); + pb.Ignore(p => p.Categories); + }); }); var model = modelBuilder.FinalizeModel(); @@ -693,12 +698,13 @@ public virtual void Can_configure_owned_type_collection_without_explicit_key_or_ r.Ignore(o => o.OrderCombination); r.Ignore(o => o.Details); r.Ignore(o => o.OrderId); - r.OwnsMany(o => o.Products, pb => - { - pb.WithOwner(p => p.Order); - pb.Ignore(p => p.Categories); - pb.Ignore(p => p.Id); - }); + r.OwnsMany( + o => o.Products, pb => + { + pb.WithOwner(p => p.Order); + pb.Ignore(p => p.Categories); + pb.Ignore(p => p.Id); + }); }); var model = modelBuilder.FinalizeModel(); @@ -1492,9 +1498,9 @@ public virtual void Attempt_to_create_OwnsMany_on_a_reference_throws() typeof(OneToOneNavPrincipalOwner).Name), Assert.Throws( () => modelBuilder - .Entity() - .OwnsMany("OwnedDependent")).Message - ); + .Entity() + .OwnsMany("OwnedDependent")).Message + ); } [ConditionalFact] @@ -1509,8 +1515,8 @@ public virtual void Attempt_to_create_OwnsOne_on_a_collection_throws() typeof(OneToManyNavPrincipalOwner).Name), Assert.Throws( () => modelBuilder - .Entity() - .OwnsOne("OwnedDependents")).Message); + .Entity() + .OwnsOne("OwnedDependents")).Message); } [ConditionalFact] @@ -1521,18 +1527,21 @@ public virtual void Shared_type_can_be_used_as_owned_type() modelBuilder.Entity( b => { - b.OwnsOne>("Shared1", e => e.Reference, sb => - { - sb.IndexerProperty("Value"); - }); + b.OwnsOne( + "Shared1", e => e.Reference, sb => + { + sb.IndexerProperty("Value"); + }); b.OwnsMany("Shared2", e => e.Collection).IndexerProperty("IsDeleted"); - b.OwnsOne(e => e.OwnedNavigation, + b.OwnsOne( + e => e.OwnedNavigation, o => { - o.OwnsOne>("Shared3", e => e.Reference, sb => - { - sb.IndexerProperty("NestedValue"); - }); + o.OwnsOne( + "Shared3", e => e.Reference, sb => + { + sb.IndexerProperty("NestedValue"); + }); o.OwnsMany("Shared4", e => e.Collection).IndexerProperty("NestedLong"); }); }); @@ -1543,10 +1552,26 @@ public virtual void Shared_type_can_be_used_as_owned_type() model.GetEntityTypes().OrderBy(e => e.Name), t => { Assert.Equal(typeof(NestedOwnerOfSharedType), t.ClrType); }, t => { Assert.Equal(typeof(OwnerOfSharedType), t.ClrType); }, - t => { Assert.Equal("Shared1", t.Name); Assert.NotNull(t.FindProperty("Value")); }, - t => { Assert.Equal("Shared2", t.Name); Assert.NotNull(t.FindProperty("IsDeleted")); }, - t => { Assert.Equal("Shared3", t.Name); Assert.NotNull(t.FindProperty("NestedValue")); }, - t => { Assert.Equal("Shared4", t.Name); Assert.NotNull(t.FindProperty("NestedLong")); }); + t => + { + Assert.Equal("Shared1", t.Name); + Assert.NotNull(t.FindProperty("Value")); + }, + t => + { + Assert.Equal("Shared2", t.Name); + Assert.NotNull(t.FindProperty("IsDeleted")); + }, + t => + { + Assert.Equal("Shared3", t.Name); + Assert.NotNull(t.FindProperty("NestedValue")); + }, + t => + { + Assert.Equal("Shared4", t.Name); + Assert.NotNull(t.FindProperty("NestedLong")); + }); } [ConditionalFact] @@ -1560,10 +1585,12 @@ public virtual void Shared_type_used_as_owned_type_throws_for_same_name() b.OwnsOne("Shared1", e => e.Reference); b.OwnsOne("Shared1", e => e.Reference); - Assert.Equal(CoreStrings.ClashingNamedOwnedType( - "Shared1", nameof(OwnerOfSharedType), nameof(OwnerOfSharedType.Collection)), - Assert.Throws(() => - b.OwnsMany("Shared1", e => e.Collection)).Message); + Assert.Equal( + CoreStrings.ClashingNamedOwnedType( + "Shared1", nameof(OwnerOfSharedType), nameof(OwnerOfSharedType.Collection)), + Assert.Throws( + () => + b.OwnsMany("Shared1", e => e.Collection)).Message); }); } diff --git a/test/EFCore.Tests/ModelBuilding/TestModel.cs b/test/EFCore.Tests/ModelBuilding/TestModel.cs index 3267bc92202..0941082bac8 100644 --- a/test/EFCore.Tests/ModelBuilding/TestModel.cs +++ b/test/EFCore.Tests/ModelBuilding/TestModel.cs @@ -145,6 +145,7 @@ protected class Order : INotifyPropertyChanged public OrderDetails Details { get; set; } public ICollection Products { get; set; } public event PropertyChangedEventHandler PropertyChanged; + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { if (PropertyChanged == null) @@ -816,6 +817,7 @@ protected class IndexedClass private string _optional; public int Id { get; set; } + public object this[string name] { get @@ -856,6 +858,7 @@ protected class IndexedClassByDictionary private readonly Dictionary _indexerData = new Dictionary(); public int Id { get; set; } + public object this[string name] { get => _indexerData[name]; @@ -1040,7 +1043,6 @@ protected class OneToOneOwnedWithField public int OneToOneOwnerId; public OneToOneOwnerWithField OneToOneOwner { get; set; } - } protected class ImplicitManyToManyA @@ -1051,7 +1053,6 @@ protected class ImplicitManyToManyA public List Bs { get; set; } } - protected class ImplicitManyToManyB { public int Id { get; set; } @@ -1100,6 +1101,7 @@ protected class AmbiguousInversePropertyLeftDerived : AmbiguousInversePropertyLe protected class AmbiguousInversePropertyRight { public int Id { get; set; } + [InverseProperty("BaseRights")] public List BaseLefts { get; set; } } diff --git a/test/EFCore.Tests/ModelSourceTest.cs b/test/EFCore.Tests/ModelSourceTest.cs index 2cde5d581d9..e7f995ce205 100644 --- a/test/EFCore.Tests/ModelSourceTest.cs +++ b/test/EFCore.Tests/ModelSourceTest.cs @@ -27,6 +27,7 @@ public class ModelSourceTest { private readonly IConventionSetBuilder _nullConventionSetBuilder = new NullConventionSetBuilder(); + private readonly ModelDependencies _testModelDependencies = new ModelDependencies(new TestLogger()); @@ -184,7 +185,8 @@ public ConcreteModelSource(IDbSetFinder setFinder) private class NullConventionSetBuilder : IConventionSetBuilder { - public ConventionSet CreateConventionSet() => new ConventionSet(); + public ConventionSet CreateConventionSet() + => new ConventionSet(); } } } diff --git a/test/EFCore.Tests/Query/ExpressionEqualityComparerTest.cs b/test/EFCore.Tests/Query/ExpressionEqualityComparerTest.cs index 36cf1a412d8..0a8735507ef 100644 --- a/test/EFCore.Tests/Query/ExpressionEqualityComparerTest.cs +++ b/test/EFCore.Tests/Query/ExpressionEqualityComparerTest.cs @@ -109,7 +109,8 @@ private class Node private class Indexable { - public int this[int index] => 0; + public int this[int index] + => 0; } } } diff --git a/test/EFCore.Tests/Query/ExpressionPrinterTest.cs b/test/EFCore.Tests/Query/ExpressionPrinterTest.cs index 04a94f63bc3..cb212c5109a 100644 --- a/test/EFCore.Tests/Query/ExpressionPrinterTest.cs +++ b/test/EFCore.Tests/Query/ExpressionPrinterTest.cs @@ -165,7 +165,7 @@ public void Complex_MethodCall_printed_correctly() { Assert.Equal( "\"Foobar\"" -+ @".Substring( + + @".Substring( startIndex: 0, length: 4)", _expressionPrinter.Print( diff --git a/test/EFCore.Tests/ServiceProviderCacheTest.cs b/test/EFCore.Tests/ServiceProviderCacheTest.cs index 9102e657a82..66ee55b2978 100644 --- a/test/EFCore.Tests/ServiceProviderCacheTest.cs +++ b/test/EFCore.Tests/ServiceProviderCacheTest.cs @@ -247,11 +247,14 @@ public ExtensionInfo(IDbContextOptionsExtension extension) { } - public override bool IsDatabaseProvider => false; + public override bool IsDatabaseProvider + => false; - public override long GetServiceProviderHashCode() => 0; + public override long GetServiceProviderHashCode() + => 0; - public override string LogFragment => ""; + public override string LogFragment + => ""; public override void PopulateDebugInfo(IDictionary debugInfo) { @@ -282,11 +285,14 @@ public ExtensionInfo(IDbContextOptionsExtension extension) { } - public override bool IsDatabaseProvider => false; + public override bool IsDatabaseProvider + => false; - public override long GetServiceProviderHashCode() => 0; + public override long GetServiceProviderHashCode() + => 0; - public override string LogFragment => ""; + public override string LogFragment + => ""; public override void PopulateDebugInfo(IDictionary debugInfo) { diff --git a/test/EFCore.Tests/Storage/ExecutionStrategyTest.cs b/test/EFCore.Tests/Storage/ExecutionStrategyTest.cs index 89db90ef49f..2cd963eb980 100644 --- a/test/EFCore.Tests/Storage/ExecutionStrategyTest.cs +++ b/test/EFCore.Tests/Storage/ExecutionStrategyTest.cs @@ -19,9 +19,11 @@ public class ExecutionStrategyTest : IDisposable { private readonly DbContext Context; - public ExecutionStrategyTest() => Context = CreateContext(); + public ExecutionStrategyTest() + => Context = CreateContext(); - public void Dispose() => Context.Dispose(); + public void Dispose() + => Context.Dispose(); private TestExecutionStrategy CreateFailOnRetryStrategy() => new TestExecutionStrategy( diff --git a/test/EFCore.Tests/Storage/IPAddressToBytesConverterTest.cs b/test/EFCore.Tests/Storage/IPAddressToBytesConverterTest.cs index 6c390cd78d9..0c658721905 100644 --- a/test/EFCore.Tests/Storage/IPAddressToBytesConverterTest.cs +++ b/test/EFCore.Tests/Storage/IPAddressToBytesConverterTest.cs @@ -94,7 +94,7 @@ public void Can_convert_bytes_to_ipaddress_ipv4_object(string ipv4) var bytes = ip.GetAddressBytes(); Assert.Equal(ip, converter(bytes)); - + Assert.Null(converter(null)); } diff --git a/test/EFCore.Tests/Storage/IPAddressToStringConverterTest.cs b/test/EFCore.Tests/Storage/IPAddressToStringConverterTest.cs index 9724c08b589..d420525333b 100644 --- a/test/EFCore.Tests/Storage/IPAddressToStringConverterTest.cs +++ b/test/EFCore.Tests/Storage/IPAddressToStringConverterTest.cs @@ -31,7 +31,7 @@ public void Can_convert_ipaddress_ipv4_to_String(string ipv4) [InlineData("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")] [InlineData("27ff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")] [InlineData("2001:db8::f:ffff")] - [InlineData("2001:db8::1")] + [InlineData("2001:db8::1")] [InlineData("2001:db8::")] public void Can_convert_ipaddress_ipv6_to_String(string ipv6) { diff --git a/test/EFCore.Tests/Storage/NumberToBytesConverterTest.cs b/test/EFCore.Tests/Storage/NumberToBytesConverterTest.cs index d91cc6ff074..ccb8274c7a8 100644 --- a/test/EFCore.Tests/Storage/NumberToBytesConverterTest.cs +++ b/test/EFCore.Tests/Storage/NumberToBytesConverterTest.cs @@ -428,19 +428,19 @@ public void Can_convert_bytes_to_nullable_decimal() var converter = _nullableDecimalToBytesConverter.ConvertFromProviderExpression.Compile(); Assert.Equal( - (decimal?)decimal.MaxValue, + decimal.MaxValue, converter(new byte[] { 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF })); Assert.Equal( - (decimal?)long.MaxValue, + long.MaxValue, converter(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF })); Assert.Equal( - (decimal?)int.MaxValue, + int.MaxValue, converter(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xFF })); Assert.Equal( - (decimal?)short.MaxValue, + short.MaxValue, converter(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF })); Assert.Equal( - (decimal?)decimal.MinValue, + decimal.MinValue, converter(new byte[] { 0x80, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF })); Assert.Equal( (decimal?)0.000000001, diff --git a/test/EFCore.Tests/Storage/PhysicalAddressToBytesConverterTest.cs b/test/EFCore.Tests/Storage/PhysicalAddressToBytesConverterTest.cs index 0f3e259db7f..8943fcfbb19 100644 --- a/test/EFCore.Tests/Storage/PhysicalAddressToBytesConverterTest.cs +++ b/test/EFCore.Tests/Storage/PhysicalAddressToBytesConverterTest.cs @@ -50,8 +50,8 @@ public void Can_convert_bytes_to_physical_address_object(string address) Assert.Null(converter(null)); } - public static IEnumerable Data => - new List + public static IEnumerable Data + => new List { new object[] { "1D-4E-55-D6-92-73-D6" }, new object[] { "24-80-B7-38-4A-68-D6" }, diff --git a/test/EFCore.Tests/Storage/PhysicalAddressToStringConverterTest.cs b/test/EFCore.Tests/Storage/PhysicalAddressToStringConverterTest.cs index 27d97149fe7..b62c34de22d 100644 --- a/test/EFCore.Tests/Storage/PhysicalAddressToStringConverterTest.cs +++ b/test/EFCore.Tests/Storage/PhysicalAddressToStringConverterTest.cs @@ -22,15 +22,15 @@ public void Can_convert_physical_address_to_String(string physicalAddress) { var converter = _physicalAddressToString.ConvertToProviderExpression.Compile(); - var alphaNumerics = new Regex("[^a-zA-Z0-9]"); + var alphaNumerics = new Regex("[^a-zA-Z0-9]"); Assert.Equal( - alphaNumerics.Replace(physicalAddress,""), + alphaNumerics.Replace(physicalAddress, ""), converter(PhysicalAddress.Parse(physicalAddress))); Assert.Null(converter(null)); } - + [ConditionalTheory] [MemberData(nameof(Data))] public void Can_convert_String_to_physical_address(string physicalAddress) @@ -54,17 +54,18 @@ public void Can_convert_bytes_to_physical_address(byte[] bytesPhysicalAddressInv var converter = new PhysicalAddressToStringConverter().ConvertFromProviderExpression.Compile(); var physicalAddress = Encoding.UTF8.GetString(bytesPhysicalAddressInvalid); - var exception = Assert.Throws(() => - { - converter(physicalAddress); - }); + var exception = Assert.Throws( + () => + { + converter(physicalAddress); + }); Assert.Null(converter(null)); Assert.Equal($"An invalid physical address was specified: '{physicalAddress}'.", exception.Message); } - public static IEnumerable Data => - new List + public static IEnumerable Data + => new List { new object[] { "1D-4E-55-D6-92-73-D6" }, new object[] { "24-80-B7-38-4A-68-D6" }, diff --git a/test/EFCore.Tests/Storage/ValueComparerTest.cs b/test/EFCore.Tests/Storage/ValueComparerTest.cs index d3c2ff36594..241e1833148 100644 --- a/test/EFCore.Tests/Storage/ValueComparerTest.cs +++ b/test/EFCore.Tests/Storage/ValueComparerTest.cs @@ -121,12 +121,14 @@ private struct JustAStructWithEquality public int A { get; set; } public string B { get; set; } - private bool Equals(JustAStructWithEquality other) => A == other.A; + private bool Equals(JustAStructWithEquality other) + => A == other.A; public override bool Equals(object obj) => obj is JustAStructWithEquality o && Equals(o); - public override int GetHashCode() => A; + public override int GetHashCode() + => A; } [ConditionalFact] @@ -185,7 +187,8 @@ private sealed class JustAClassWithEquality { public int A { get; set; } - private bool Equals(JustAClassWithEquality other) => A == other.A; + private bool Equals(JustAClassWithEquality other) + => A == other.A; public override bool Equals(object obj) => !(obj is null) @@ -193,7 +196,8 @@ public override bool Equals(object obj) || obj is JustAClassWithEquality o && Equals(o)); - public override int GetHashCode() => A; + public override int GetHashCode() + => A; } [ConditionalFact] diff --git a/test/EFCore.Tests/TestUtilities/FakeStateManager.cs b/test/EFCore.Tests/TestUtilities/FakeStateManager.cs index 7ed7264f695..600502acf91 100644 --- a/test/EFCore.Tests/TestUtilities/FakeStateManager.cs +++ b/test/EFCore.Tests/TestUtilities/FakeStateManager.cs @@ -28,7 +28,8 @@ public void ResetState() { } - public Task ResetStateAsync(CancellationToken cancellationToken = default) => Task.CompletedTask; + public Task ResetStateAsync(CancellationToken cancellationToken = default) + => Task.CompletedTask; public void Unsubscribe() { @@ -46,7 +47,8 @@ public int SaveChanges(bool acceptAllChangesOnSuccess) return Task.FromResult(1); } - public IEnumerable Entries => InternalEntries ?? Enumerable.Empty(); + public IEnumerable Entries + => InternalEntries ?? Enumerable.Empty(); public IEnumerable GetEntriesForState( bool added = false, @@ -64,96 +66,143 @@ public int GetCountForState( public int ChangedCount { get; set; } - public int Count => throw new NotImplementedException(); + public int Count + => throw new NotImplementedException(); public IDiagnosticsLogger UpdateLogger { get; } - public void Clear() => throw new NotImplementedException(); + public void Clear() + => throw new NotImplementedException(); - public bool SavingChanges => throw new NotImplementedException(); + public bool SavingChanges + => throw new NotImplementedException(); public IEnumerable GetNonDeletedEntities() where TEntity : class => throw new NotImplementedException(); - public IEntityFinder CreateEntityFinder(IEntityType entityType) => throw new NotImplementedException(); - public void UpdateIdentityMap(InternalEntityEntry entry, IKey principalKey) => throw new NotImplementedException(); - public void UpdateDependentMap(InternalEntityEntry entry, IForeignKey foreignKey) => throw new NotImplementedException(); + public IEntityFinder CreateEntityFinder(IEntityType entityType) + => throw new NotImplementedException(); + + public void UpdateIdentityMap(InternalEntityEntry entry, IKey principalKey) + => throw new NotImplementedException(); - public IEnumerable GetDependents(IUpdateEntry principalEntry, IForeignKey foreignKey) => - throw new NotImplementedException(); + public void UpdateDependentMap(InternalEntityEntry entry, IForeignKey foreignKey) + => throw new NotImplementedException(); + + public IEnumerable GetDependents(IUpdateEntry principalEntry, IForeignKey foreignKey) + => throw new NotImplementedException(); public IEnumerable GetDependentsUsingRelationshipSnapshot( - IUpdateEntry principalEntry, IForeignKey foreignKey) => throw new NotImplementedException(); + IUpdateEntry principalEntry, + IForeignKey foreignKey) + => throw new NotImplementedException(); - public IEnumerable GetDependentsFromNavigation(IUpdateEntry principalEntry, IForeignKey foreignKey) => - throw new NotImplementedException(); + public IEnumerable GetDependentsFromNavigation(IUpdateEntry principalEntry, IForeignKey foreignKey) + => throw new NotImplementedException(); + + public IList GetEntriesToSave(bool cascadeChanges) + => Enumerable.Empty().ToList(); + + public virtual void AcceptAllChanges() + => throw new NotImplementedException(); - public IList GetEntriesToSave(bool cascadeChanges) => Enumerable.Empty().ToList(); - public virtual void AcceptAllChanges() => throw new NotImplementedException(); public StateManagerDependencies Dependencies { get; } public CascadeTiming DeleteOrphansTiming { get; set; } public CascadeTiming CascadeDeleteTiming { get; set; } - public InternalEntityEntry GetOrCreateEntry(object entity) => throw new NotImplementedException(); - public InternalEntityEntry GetOrCreateEntry(object entity, IEntityType entityType) => throw new NotImplementedException(); - public InternalEntityEntry CreateEntry(IDictionary values, IEntityType entityType) => - throw new NotImplementedException(); + public InternalEntityEntry GetOrCreateEntry(object entity) + => throw new NotImplementedException(); + + public InternalEntityEntry GetOrCreateEntry(object entity, IEntityType entityType) + => throw new NotImplementedException(); + + public InternalEntityEntry CreateEntry(IDictionary values, IEntityType entityType) + => throw new NotImplementedException(); public InternalEntityEntry StartTrackingFromQuery( - IEntityType baseEntityType, object entity, in ValueBuffer valueBuffer) => - throw new NotImplementedException(); + IEntityType baseEntityType, + object entity, + in ValueBuffer valueBuffer) + => throw new NotImplementedException(); - public void BeginTrackingQuery() => throw new NotImplementedException(); - public InternalEntityEntry TryGetEntry(IKey key, object[] keyValues) => throw new NotImplementedException(); + public void BeginTrackingQuery() + => throw new NotImplementedException(); - public InternalEntityEntry TryGetEntry(IKey key, in ValueBuffer valueBuffer, bool throwOnNullKey) => - throw new NotImplementedException(); + public InternalEntityEntry TryGetEntry(IKey key, object[] keyValues) + => throw new NotImplementedException(); - public InternalEntityEntry TryGetEntry(object entity, bool throwOnNonUniqueness = true) => throw new NotImplementedException(); + public InternalEntityEntry TryGetEntry(IKey key, in ValueBuffer valueBuffer, bool throwOnNullKey) + => 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(); + public IInternalEntityEntryNotifier InternalEntityEntryNotifier + => throw new NotImplementedException(); + + public void StateChanging(InternalEntityEntry entry, EntityState newState) + => throw new NotImplementedException(); + + public IValueGenerationManager ValueGenerationManager + => throw new NotImplementedException(); + public IEntityMaterializerSource EntityMaterializerSource { get; } - public InternalEntityEntry StartTracking(InternalEntityEntry entry) => throw new NotImplementedException(); - public void StopTracking(InternalEntityEntry entry, EntityState oldState) => throw new NotImplementedException(); + + public InternalEntityEntry StartTracking(InternalEntityEntry entry) + => throw new NotImplementedException(); + + public void StopTracking(InternalEntityEntry entry, EntityState oldState) + => throw new NotImplementedException(); public void RecordReferencedUntrackedEntity( - object referencedEntity, INavigationBase navigation, InternalEntityEntry referencedFromEntry) => - throw new NotImplementedException(); + object referencedEntity, + INavigationBase navigation, + InternalEntityEntry referencedFromEntry) + => throw new NotImplementedException(); - public IEnumerable> GetRecordedReferrers(object referencedEntity, bool clear) => - throw new NotImplementedException(); + public IEnumerable> GetRecordedReferrers(object referencedEntity, bool clear) + => throw new NotImplementedException(); - public InternalEntityEntry FindPrincipal(InternalEntityEntry entityEntry, IForeignKey foreignKey) => - throw new NotImplementedException(); + public InternalEntityEntry FindPrincipal(InternalEntityEntry entityEntry, IForeignKey foreignKey) + => throw new NotImplementedException(); - public InternalEntityEntry FindPrincipalUsingPreStoreGeneratedValues(InternalEntityEntry entityEntry, IForeignKey foreignKey) => - throw new NotImplementedException(); + public InternalEntityEntry FindPrincipalUsingPreStoreGeneratedValues(InternalEntityEntry entityEntry, IForeignKey foreignKey) + => throw new NotImplementedException(); - public InternalEntityEntry FindPrincipalUsingRelationshipSnapshot(InternalEntityEntry entityEntry, IForeignKey foreignKey) => - throw new NotImplementedException(); + 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 IModel Model => throw new NotImplementedException(); public event EventHandler Tracked; - public void OnTracked(InternalEntityEntry internalEntityEntry, bool fromQuery) => Tracked?.Invoke(null, null); + + public void OnTracked(InternalEntityEntry internalEntityEntry, bool fromQuery) + => Tracked?.Invoke(null, null); + public event EventHandler StateChanged; - public void OnStateChanged(InternalEntityEntry internalEntityEntry, EntityState oldState) => StateChanged?.Invoke(null, null); + + 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 CascadeChanges(bool force) + => 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/TestUtilities/MockAssembly.cs b/test/EFCore.Tests/TestUtilities/MockAssembly.cs index 8623ad22cd0..2c08133061e 100644 --- a/test/EFCore.Tests/TestUtilities/MockAssembly.cs +++ b/test/EFCore.Tests/TestUtilities/MockAssembly.cs @@ -43,21 +43,41 @@ public MockMethodInfo(Type declaringType) public override Type DeclaringType { get; } - public override ICustomAttributeProvider ReturnTypeCustomAttributes => throw new NotImplementedException(); - public override RuntimeMethodHandle MethodHandle => throw new NotImplementedException(); - public override MethodAttributes Attributes => throw new NotImplementedException(); - public override string Name => throw new NotImplementedException(); - public override Type ReflectedType => throw new NotImplementedException(); - public override MethodInfo GetBaseDefinition() => throw new NotImplementedException(); - public override object[] GetCustomAttributes(bool inherit) => throw new NotImplementedException(); - public override object[] GetCustomAttributes(Type attributeType, bool inherit) => throw new NotImplementedException(); - public override MethodImplAttributes GetMethodImplementationFlags() => throw new NotImplementedException(); - public override ParameterInfo[] GetParameters() => throw new NotImplementedException(); - - public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) => - throw new NotImplementedException(); - - public override bool IsDefined(Type attributeType, bool inherit) => throw new NotImplementedException(); + public override ICustomAttributeProvider ReturnTypeCustomAttributes + => throw new NotImplementedException(); + + public override RuntimeMethodHandle MethodHandle + => throw new NotImplementedException(); + + public override MethodAttributes Attributes + => throw new NotImplementedException(); + + public override string Name + => throw new NotImplementedException(); + + public override Type ReflectedType + => throw new NotImplementedException(); + + public override MethodInfo GetBaseDefinition() + => throw new NotImplementedException(); + + public override object[] GetCustomAttributes(bool inherit) + => throw new NotImplementedException(); + + public override object[] GetCustomAttributes(Type attributeType, bool inherit) + => throw new NotImplementedException(); + + public override MethodImplAttributes GetMethodImplementationFlags() + => throw new NotImplementedException(); + + public override ParameterInfo[] GetParameters() + => throw new NotImplementedException(); + + public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) + => throw new NotImplementedException(); + + public override bool IsDefined(Type attributeType, bool inherit) + => throw new NotImplementedException(); } } } diff --git a/test/EFCore.Tests/TestUtilities/TestInMemoryTransactionManager.cs b/test/EFCore.Tests/TestUtilities/TestInMemoryTransactionManager.cs index 94e98de7f0f..ba1b4f561c3 100644 --- a/test/EFCore.Tests/TestUtilities/TestInMemoryTransactionManager.cs +++ b/test/EFCore.Tests/TestUtilities/TestInMemoryTransactionManager.cs @@ -22,26 +22,32 @@ public TestInMemoryTransactionManager( { } - public override IDbContextTransaction CurrentTransaction => _currentTransaction; + public override IDbContextTransaction CurrentTransaction + => _currentTransaction; - public override Transaction EnlistedTransaction => _enlistedTransaction; + public override Transaction EnlistedTransaction + => _enlistedTransaction; - public override IDbContextTransaction BeginTransaction() => _currentTransaction = new TestInMemoryTransaction(this); + public override IDbContextTransaction BeginTransaction() + => _currentTransaction = new TestInMemoryTransaction(this); public override Task BeginTransactionAsync(CancellationToken cancellationToken = default) => Task.FromResult(_currentTransaction = new TestInMemoryTransaction(this)); - public override void CommitTransaction() => CurrentTransaction.Commit(); + public override void CommitTransaction() + => CurrentTransaction.Commit(); public override Task CommitTransactionAsync(CancellationToken cancellationToken = default) => CurrentTransaction.CommitAsync(cancellationToken); - public override void RollbackTransaction() => CurrentTransaction.Rollback(); + public override void RollbackTransaction() + => CurrentTransaction.Rollback(); public override Task RollbackTransactionAsync(CancellationToken cancellationToken = default) => CurrentTransaction.RollbackAsync(cancellationToken); - public override void EnlistTransaction(Transaction transaction) => _enlistedTransaction = transaction; + public override void EnlistTransaction(Transaction transaction) + => _enlistedTransaction = transaction; private class TestInMemoryTransaction : IDbContextTransaction { diff --git a/test/EFCore.Tests/Utilities/MultigraphTest.cs b/test/EFCore.Tests/Utilities/MultigraphTest.cs index 71db7ceac75..7889f3468c5 100644 --- a/test/EFCore.Tests/Utilities/MultigraphTest.cs +++ b/test/EFCore.Tests/Utilities/MultigraphTest.cs @@ -21,14 +21,16 @@ private class Vertex { public int Id { get; set; } - public override string ToString() => Id.ToString(); + public override string ToString() + => Id.ToString(); } private class Edge { public int Id { get; set; } - public override string ToString() => Id.ToString(); + public override string ToString() + => Id.ToString(); } private class A @@ -86,7 +88,8 @@ public void Populate(params IEntityType[] entityTypes) } } - protected override string ToString(IEntityType vertex) => vertex.DisplayName(); + protected override string ToString(IEntityType vertex) + => vertex.DisplayName(); } #endregion @@ -775,6 +778,7 @@ public void BatchingTopologicalSort_sorts_leafy_cycle() Assert.Throws(() => graph.BatchingTopologicalSort()).Message); } - private static IMutableModel CreateModel() => new Model(); + private static IMutableModel CreateModel() + => new Model(); } } diff --git a/test/EFCore.Tests/Utilities/PropertyInfoExtensionsTest.cs b/test/EFCore.Tests/Utilities/PropertyInfoExtensionsTest.cs index fd048baac28..3c8df248093 100644 --- a/test/EFCore.Tests/Utilities/PropertyInfoExtensionsTest.cs +++ b/test/EFCore.Tests/Utilities/PropertyInfoExtensionsTest.cs @@ -37,7 +37,8 @@ public class KitKat internal static int And { private get; set; } internal static int Chocolate { get; private set; } - protected internal static int With => 0; + protected internal static int With + => 0; public static int No { @@ -50,7 +51,8 @@ public static int No internal int May { private get; set; } protected internal int Contain { get; private set; } - public int TreeNuts => 0; + public int TreeNuts + => 0; public int Just { diff --git a/test/EFCore.Tests/Utilities/TypeExtensionsTest.cs b/test/EFCore.Tests/Utilities/TypeExtensionsTest.cs index f6e910616fa..780683f85a7 100644 --- a/test/EFCore.Tests/Utilities/TypeExtensionsTest.cs +++ b/test/EFCore.Tests/Utilities/TypeExtensionsTest.cs @@ -7,7 +7,6 @@ using System.Collections.ObjectModel; using System.Linq; using System.Reflection; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; @@ -170,7 +169,8 @@ public class TindersticksII public virtual int VertrauenII { get; protected set; } public virtual int TalkToMe { protected get; set; } - public virtual int NoMoreAffairs => 1995; + public virtual int NoMoreAffairs + => 1995; public virtual int Singing { @@ -192,7 +192,8 @@ public class TindersticksIIVinyl : TindersticksII private int MySister { get; set; } protected override int TinyTears { get; set; } - public override int SnowyInFSharpMinor => 1995; + public override int SnowyInFSharpMinor + => 1995; public override int Seaweed { @@ -202,7 +203,8 @@ public override int Seaweed public override int VertrauenII { get; protected set; } public override int TalkToMe { protected get; set; } - public override int NoMoreAffairs => 1995; + public override int NoMoreAffairs + => 1995; public override int Singing { @@ -222,7 +224,8 @@ public class TindersticksIICd : TindersticksIIVinyl private int MySister { get; set; } protected override int TinyTears { get; set; } - public override int SnowyInFSharpMinor => 1995; + public override int SnowyInFSharpMinor + => 1995; public override int Seaweed { @@ -232,7 +235,8 @@ public override int Seaweed public override int VertrauenII { get; protected set; } public override int TalkToMe { protected get; set; } - public override int NoMoreAffairs => 1995; + public override int NoMoreAffairs + => 1995; public override int Singing { diff --git a/test/EFCore.Tests/Utilities/TypeNameHelperTest.cs b/test/EFCore.Tests/Utilities/TypeNameHelperTest.cs index 4c7f74e2834..4e5b0aae603 100644 --- a/test/EFCore.Tests/Utilities/TypeNameHelperTest.cs +++ b/test/EFCore.Tests/Utilities/TypeNameHelperTest.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Xunit; // ReSharper disable InconsistentNaming diff --git a/test/EFCore.Tests/ValueGeneration/ValueGeneratorSelectorTest.cs b/test/EFCore.Tests/ValueGeneration/ValueGeneratorSelectorTest.cs index 3c9116fcb5a..383143fcea5 100644 --- a/test/EFCore.Tests/ValueGeneration/ValueGeneratorSelectorTest.cs +++ b/test/EFCore.Tests/ValueGeneration/ValueGeneratorSelectorTest.cs @@ -139,7 +139,8 @@ public override int Next(EntityEntry entry) throw new NotImplementedException(); } - public override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; } } }