diff --git a/Directory.Build.props b/Directory.Build.props index f21f2831b..c27355bf6 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ 9.0.0-preview.1 - preview + latest true latest NU5105 diff --git a/src/EFCore.PG.NTS/Infrastructure/Internal/NpgsqlNetTopologySuiteOptionsExtension.cs b/src/EFCore.PG.NTS/Infrastructure/Internal/NpgsqlNetTopologySuiteOptionsExtension.cs index 9de048388..3d0205650 100644 --- a/src/EFCore.PG.NTS/Infrastructure/Internal/NpgsqlNetTopologySuiteOptionsExtension.cs +++ b/src/EFCore.PG.NTS/Infrastructure/Internal/NpgsqlNetTopologySuiteOptionsExtension.cs @@ -109,15 +109,10 @@ public virtual void Validate(IDbContextOptions options) } } - private sealed class ExtensionInfo : DbContextOptionsExtensionInfo + private sealed class ExtensionInfo(IDbContextOptionsExtension extension) : DbContextOptionsExtensionInfo(extension) { private string? _logFragment; - public ExtensionInfo(IDbContextOptionsExtension extension) - : base(extension) - { - } - private new NpgsqlNetTopologySuiteOptionsExtension Extension => (NpgsqlNetTopologySuiteOptionsExtension)base.Extension; diff --git a/src/EFCore.PG.NodaTime/Infrastructure/Internal/NpgsqlNodaTimeOptionsExtension.cs b/src/EFCore.PG.NodaTime/Infrastructure/Internal/NpgsqlNodaTimeOptionsExtension.cs index 732411214..0c070cf11 100644 --- a/src/EFCore.PG.NodaTime/Infrastructure/Internal/NpgsqlNodaTimeOptionsExtension.cs +++ b/src/EFCore.PG.NodaTime/Infrastructure/Internal/NpgsqlNodaTimeOptionsExtension.cs @@ -55,13 +55,8 @@ public virtual void Validate(IDbContextOptions options) } } - private sealed class ExtensionInfo : DbContextOptionsExtensionInfo + private sealed class ExtensionInfo(IDbContextOptionsExtension extension) : DbContextOptionsExtensionInfo(extension) { - public ExtensionInfo(IDbContextOptionsExtension extension) - : base(extension) - { - } - private new NpgsqlNodaTimeOptionsExtension Extension => (NpgsqlNodaTimeOptionsExtension)base.Extension; diff --git a/src/EFCore.PG.NodaTime/Storage/Internal/DateTimeZoneMapping.cs b/src/EFCore.PG.NodaTime/Storage/Internal/DateTimeZoneMapping.cs index 6dc203ffd..0959d6ef9 100644 --- a/src/EFCore.PG.NodaTime/Storage/Internal/DateTimeZoneMapping.cs +++ b/src/EFCore.PG.NodaTime/Storage/Internal/DateTimeZoneMapping.cs @@ -55,23 +55,11 @@ public override Expression GenerateCodeLiteral(object value) typeof(IDateTimeZoneProvider).GetMethod(nameof(IDateTimeZoneProvider.GetZoneOrNull), new[] { typeof(string) })!, Expression.Constant(((DateTimeZone)value).Id)); - private sealed class DateTimeZoneConverter : ValueConverter - { - public DateTimeZoneConverter() - : base( - tz => tz.Id, - id => DateTimeZoneProviders.Tzdb[id]) - { - } - } + private sealed class DateTimeZoneConverter() : ValueConverter( + tz => tz.Id, + id => DateTimeZoneProviders.Tzdb[id]); - private sealed class DateTimeZoneComparer : ValueComparer - { - public DateTimeZoneComparer() - : base( - (tz1, tz2) => tz1 == null ? tz2 == null : tz2 != null && tz1.Id == tz2.Id, - tz => tz.GetHashCode()) - { - } - } + private sealed class DateTimeZoneComparer() : ValueComparer( + (tz1, tz2) => tz1 == null ? tz2 == null : tz2 != null && tz1.Id == tz2.Id, + tz => tz.GetHashCode()); } diff --git a/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs b/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs index 7ba3f5fec..0d4fd224e 100644 --- a/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs +++ b/src/EFCore.PG/Infrastructure/Internal/NpgsqlOptionsExtension.cs @@ -333,16 +333,11 @@ public override void ApplyServices(IServiceCollection services) public override DbContextOptionsExtensionInfo Info => _info ??= new ExtensionInfo(this); - private sealed class ExtensionInfo : RelationalExtensionInfo + private sealed class ExtensionInfo(IDbContextOptionsExtension extension) : RelationalExtensionInfo(extension) { private int? _serviceProviderHash; private string? _logFragment; - public ExtensionInfo(IDbContextOptionsExtension extension) - : base(extension) - { - } - private new NpgsqlOptionsExtension Extension => (NpgsqlOptionsExtension)base.Extension; diff --git a/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs b/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs index 35b9504f9..2442078b9 100644 --- a/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs +++ b/src/EFCore.PG/Migrations/NpgsqlMigrationsSqlGenerator.cs @@ -2217,22 +2217,13 @@ private static IndexColumn[] GetIndexColumns(CreateIndexOperation operation) return columns; } - private readonly struct IndexColumn + private readonly struct IndexColumn(string name, string? @operator, string? collation, bool isDescending, NullSortOrder nullSortOrder) { - public IndexColumn(string name, string? @operator, string? collation, bool isDescending, NullSortOrder nullSortOrder) - { - Name = name; - Operator = @operator; - Collation = collation; - IsDescending = isDescending; - NullSortOrder = nullSortOrder; - } - - public string Name { get; } - public string? Operator { get; } - public string? Collation { get; } - public bool IsDescending { get; } - public NullSortOrder NullSortOrder { get; } + public string Name { get; } = name; + public string? Operator { get; } = @operator; + public string? Collation { get; } = collation; + public bool IsDescending { get; } = isDescending; + public NullSortOrder NullSortOrder { get; } = nullSortOrder; } #endregion diff --git a/src/EFCore.PG/Query/Internal/NpgsqlCompiledQueryCacheKeyGenerator.cs b/src/EFCore.PG/Query/Internal/NpgsqlCompiledQueryCacheKeyGenerator.cs index c8d826357..2b5731698 100644 --- a/src/EFCore.PG/Query/Internal/NpgsqlCompiledQueryCacheKeyGenerator.cs +++ b/src/EFCore.PG/Query/Internal/NpgsqlCompiledQueryCacheKeyGenerator.cs @@ -34,18 +34,12 @@ public override object GenerateCacheKey(Expression query, bool async) GenerateCacheKeyCore(query, async), RelationalDependencies.ContextOptions.FindExtension()?.ReverseNullOrdering ?? false); - private struct NpgsqlCompiledQueryCacheKey + private struct NpgsqlCompiledQueryCacheKey( + RelationalCompiledQueryCacheKey relationalCompiledQueryCacheKey, + bool reverseNullOrdering) { - private readonly RelationalCompiledQueryCacheKey _relationalCompiledQueryCacheKey; - private readonly bool _reverseNullOrdering; - - public NpgsqlCompiledQueryCacheKey( - RelationalCompiledQueryCacheKey relationalCompiledQueryCacheKey, - bool reverseNullOrdering) - { - _relationalCompiledQueryCacheKey = relationalCompiledQueryCacheKey; - _reverseNullOrdering = reverseNullOrdering; - } + private readonly RelationalCompiledQueryCacheKey _relationalCompiledQueryCacheKey = relationalCompiledQueryCacheKey; + private readonly bool _reverseNullOrdering = reverseNullOrdering; public override bool Equals(object? obj) => !(obj is null) diff --git a/src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs b/src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs index 737813673..b71d138c3 100644 --- a/src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs +++ b/src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs @@ -1516,16 +1516,10 @@ private void GenerateList( } } - private sealed class OuterReferenceFindingExpressionVisitor : ExpressionVisitor + private sealed class OuterReferenceFindingExpressionVisitor(TableExpression mainTable) : ExpressionVisitor { - private readonly TableExpression _mainTable; private bool _containsReference; - public OuterReferenceFindingExpressionVisitor(TableExpression mainTable) - { - _mainTable = mainTable; - } - public bool ContainsReferenceToMainTable(SqlExpression sqlExpression) { _containsReference = false; @@ -1544,7 +1538,7 @@ public bool ContainsReferenceToMainTable(SqlExpression sqlExpression) } if (expression is ColumnExpression columnExpression - && columnExpression.Table == _mainTable) + && columnExpression.Table == mainTable) { _containsReference = true; diff --git a/src/EFCore.PG/Query/Internal/NpgsqlQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.PG/Query/Internal/NpgsqlQueryableMethodTranslatingExpressionVisitor.cs index d4d8cd7b0..4cde6c0cd 100644 --- a/src/EFCore.PG/Query/Internal/NpgsqlQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.PG/Query/Internal/NpgsqlQueryableMethodTranslatingExpressionVisitor.cs @@ -1258,16 +1258,10 @@ private SqlExpression GetArray(TableExpressionBase tableExpression) } } - private sealed class OuterReferenceFindingExpressionVisitor : ExpressionVisitor + private sealed class OuterReferenceFindingExpressionVisitor(TableExpression mainTable) : ExpressionVisitor { - private readonly TableExpression _mainTable; private bool _containsReference; - public OuterReferenceFindingExpressionVisitor(TableExpression mainTable) - { - _mainTable = mainTable; - } - public bool ContainsReferenceToMainTable(TableExpressionBase tableExpression) { _containsReference = false; @@ -1286,7 +1280,7 @@ public bool ContainsReferenceToMainTable(TableExpressionBase tableExpression) } if (expression is ColumnExpression columnExpression - && columnExpression.Table == _mainTable) + && columnExpression.Table == mainTable) { _containsReference = true; diff --git a/src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs b/src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs index 44580c911..68bf6b898 100644 --- a/src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs +++ b/src/EFCore.PG/Scaffolding/Internal/NpgsqlDatabaseModelFactory.cs @@ -1297,14 +1297,9 @@ private static SequenceInfo ReadSequenceInfo(DbDataRecord record, Version postgr }; } - private sealed class SequenceInfo + private sealed class SequenceInfo(string storeType) { - public SequenceInfo(string storeType) - { - StoreType = storeType; - } - - public string StoreType { get; } + public string StoreType { get; } = storeType; public long? StartValue { get; set; } public long? MinValue { get; set; } public long? MaxValue { get; set; } diff --git a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlHstoreTypeMapping.cs b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlHstoreTypeMapping.cs index d48c3e121..3d6eef2f0 100644 --- a/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlHstoreTypeMapping.cs +++ b/src/EFCore.PG/Storage/Internal/Mapping/NpgsqlHstoreTypeMapping.cs @@ -109,16 +109,11 @@ protected override string GenerateNonNullSqlLiteral(object value) $"CLR type must be {nameof(Dictionary)} or {nameof(ImmutableDictionary)}"); } - private sealed class HstoreMutableComparer : ValueComparer> + private sealed class HstoreMutableComparer() : ValueComparer>( + (a, b) => Compare(a, b), + o => o.GetHashCode(), + o => new Dictionary(o)) { - public HstoreMutableComparer() - : base( - (a, b) => Compare(a, b), - o => o.GetHashCode(), - o => new Dictionary(o)) - { - } - private static bool Compare(Dictionary? a, Dictionary? b) { if (a is null) diff --git a/src/Shared/CodeAnnotations.cs b/src/Shared/CodeAnnotations.cs index 417866a62..32ec3e251 100644 --- a/src/Shared/CodeAnnotations.cs +++ b/src/Shared/CodeAnnotations.cs @@ -91,14 +91,9 @@ public StringFormatMethodAttribute(string formatParameterName) [AttributeUsage( AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)] -internal sealed class ValueProviderAttribute : Attribute +internal sealed class ValueProviderAttribute(string name) : Attribute { - public ValueProviderAttribute(string name) - { - Name = name; - } - - public string Name { get; } + public string Name { get; } = name; } /// @@ -164,9 +159,7 @@ public ValueRangeAttribute(ulong value) | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Delegate)] -internal sealed class NonNegativeValueAttribute : Attribute -{ -} +internal sealed class NonNegativeValueAttribute : Attribute; /// /// Indicates that the function argument should be a string literal and match one @@ -180,9 +173,7 @@ internal sealed class NonNegativeValueAttribute : Attribute /// } /// [AttributeUsage(AttributeTargets.Parameter)] -internal sealed class InvokerParameterNameAttribute : Attribute -{ -} +internal sealed class InvokerParameterNameAttribute : Attribute; /// /// Describes dependency between method input and output. @@ -229,22 +220,16 @@ internal sealed class InvokerParameterNameAttribute : Attribute /// /// [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] -internal sealed class ContractAnnotationAttribute : Attribute +internal sealed class ContractAnnotationAttribute(string contract, bool forceFullStates) : Attribute { public ContractAnnotationAttribute(string contract) : this(contract, false) { } - public ContractAnnotationAttribute(string contract, bool forceFullStates) - { - Contract = contract; - ForceFullStates = forceFullStates; - } + public string Contract { get; } = contract; - public string Contract { get; } - - public bool ForceFullStates { get; } + public bool ForceFullStates { get; } = forceFullStates; } /// @@ -257,19 +242,14 @@ public ContractAnnotationAttribute(string contract, bool forceFullStates) /// } /// [AttributeUsage(AttributeTargets.All)] -internal sealed class LocalizationRequiredAttribute : Attribute +internal sealed class LocalizationRequiredAttribute(bool required) : Attribute { public LocalizationRequiredAttribute() : this(true) { } - public LocalizationRequiredAttribute(bool required) - { - Required = required; - } - - public bool Required { get; } + public bool Required { get; } = required; } /// @@ -293,9 +273,7 @@ public LocalizationRequiredAttribute(bool required) /// } /// [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)] -internal sealed class CannotApplyEqualityOperatorAttribute : Attribute -{ -} +internal sealed class CannotApplyEqualityOperatorAttribute : Attribute; /// /// When applied to a target attribute, specifies a requirement for any type marked @@ -310,14 +288,9 @@ internal sealed class CannotApplyEqualityOperatorAttribute : Attribute /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] [BaseTypeRequired(typeof(Attribute))] -internal sealed class BaseTypeRequiredAttribute : Attribute +internal sealed class BaseTypeRequiredAttribute(Type baseType) : Attribute { - public BaseTypeRequiredAttribute(Type baseType) - { - BaseType = baseType; - } - - public Type BaseType { get; } + public Type BaseType { get; } = baseType; } /// @@ -325,7 +298,8 @@ public BaseTypeRequiredAttribute(Type baseType) /// so this symbol will not be reported as unused (as well as by other usage inspections). /// [AttributeUsage(AttributeTargets.All)] -internal sealed class UsedImplicitlyAttribute : Attribute +internal sealed class UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) + : Attribute { public UsedImplicitlyAttribute() : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) @@ -342,15 +316,9 @@ public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags) { } - public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) - { - UseKindFlags = useKindFlags; - TargetFlags = targetFlags; - } - - public ImplicitUseKindFlags UseKindFlags { get; } + public ImplicitUseKindFlags UseKindFlags { get; } = useKindFlags; - public ImplicitUseTargetFlags TargetFlags { get; } + public ImplicitUseTargetFlags TargetFlags { get; } = targetFlags; } /// @@ -360,7 +328,8 @@ public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTar /// is used implicitly. /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter | AttributeTargets.Parameter)] -internal sealed class MeansImplicitUseAttribute : Attribute +internal sealed class MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) + : Attribute { public MeansImplicitUseAttribute() : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) @@ -377,15 +346,9 @@ public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags) { } - public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) - { - UseKindFlags = useKindFlags; - TargetFlags = targetFlags; - } - - [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; } + [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; } = useKindFlags; - [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; } + [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; } = targetFlags; } /// @@ -450,14 +413,10 @@ internal enum ImplicitUseTargetFlags /// } /// [AttributeUsage(AttributeTargets.Parameter)] -internal sealed class NoEnumerationAttribute : Attribute -{ -} +internal sealed class NoEnumerationAttribute : Attribute; /// /// Indicates that the marked parameter is a regular expression pattern. /// [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] -internal sealed class RegexPatternAttribute : Attribute -{ -} \ No newline at end of file +internal sealed class RegexPatternAttribute : Attribute; \ No newline at end of file diff --git a/test/EFCore.PG.FunctionalTests/BatchingTest.cs b/test/EFCore.PG.FunctionalTests/BatchingTest.cs index 2ae6bafb5..a8cd3516f 100644 --- a/test/EFCore.PG.FunctionalTests/BatchingTest.cs +++ b/test/EFCore.PG.FunctionalTests/BatchingTest.cs @@ -7,14 +7,9 @@ // ReSharper disable InconsistentNaming namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class BatchingTest : IClassFixture +public class BatchingTest(BatchingTest.BatchingTestFixture fixture) : IClassFixture { - public BatchingTest(BatchingTestFixture fixture) - { - Fixture = fixture; - } - - protected BatchingTestFixture Fixture { get; } + protected BatchingTestFixture Fixture { get; } = fixture; [Theory] [InlineData(true, true, true)] @@ -201,13 +196,8 @@ private void ExecuteWithStrategyInTransaction( protected void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); - private class BloggingContext : PoolableDbContext + private class BloggingContext(DbContextOptions options) : PoolableDbContext(options) { - public BloggingContext(DbContextOptions options) - : base(options) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity( diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesNpgsqlTest.cs index bfe7cf2a0..58acbafea 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesNpgsqlTest.cs @@ -3,14 +3,11 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Update; -public class ComplexTypeBulkUpdatesNpgsqlTest : ComplexTypeBulkUpdatesTestBase< - ComplexTypeBulkUpdatesNpgsqlTest.ComplexTypeBulkUpdatesNpgsqlFixture> +public class ComplexTypeBulkUpdatesNpgsqlTest( + ComplexTypeBulkUpdatesNpgsqlTest.ComplexTypeBulkUpdatesNpgsqlFixture fixture, + ITestOutputHelper testOutputHelper) + : ComplexTypeBulkUpdatesTestBase(fixture, testOutputHelper) { - public ComplexTypeBulkUpdatesNpgsqlTest(ComplexTypeBulkUpdatesNpgsqlFixture fixture, ITestOutputHelper testOutputHelper) - : base(fixture, testOutputHelper) - { - } - public override async Task Delete_entity_type_with_complex_type(bool async) { await base.Delete_entity_type_with_complex_type(async); diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs index 5c1bda899..bf9f677e6 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs @@ -170,13 +170,8 @@ await AssertUpdate( rowsAffectedCount: 1); } - protected class Context3001 : DbContext + protected class Context3001(DbContextOptions options) : DbContext(options) { - public Context3001(DbContextOptions options) - : base(options) - { - } - public DbSet EntitiesWithPrimitiveCollection { get; set; } } diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs index 098e57b2e..8bbb02ee0 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs @@ -3,15 +3,11 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.BulkUpdates; -public class NorthwindBulkUpdatesNpgsqlTest : NorthwindBulkUpdatesTestBase> +public class NorthwindBulkUpdatesNpgsqlTest( + NorthwindBulkUpdatesNpgsqlFixture fixture, + ITestOutputHelper testOutputHelper) + : NorthwindBulkUpdatesTestBase>(fixture, testOutputHelper) { - public NorthwindBulkUpdatesNpgsqlTest( - NorthwindBulkUpdatesNpgsqlFixture fixture, - ITestOutputHelper testOutputHelper) - : base(fixture, testOutputHelper) - { - } - public override async Task Delete_Where_TagWith(bool async) { await base.Delete_Where_TagWith(async); diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesNpgsqlTest.cs index 1d19a430f..79a758d0c 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesNpgsqlTest.cs @@ -2,16 +2,11 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.BulkUpdates; -public class TPCFiltersInheritanceBulkUpdatesNpgsqlTest - : TPCFiltersInheritanceBulkUpdatesTestBase +public class TPCFiltersInheritanceBulkUpdatesNpgsqlTest( + TPCFiltersInheritanceBulkUpdatesNpgsqlFixture fixture, + ITestOutputHelper testOutputHelper) + : TPCFiltersInheritanceBulkUpdatesTestBase(fixture, testOutputHelper) { - public TPCFiltersInheritanceBulkUpdatesNpgsqlTest( - TPCFiltersInheritanceBulkUpdatesNpgsqlFixture fixture, - ITestOutputHelper testOutputHelper) - : base(fixture, testOutputHelper) - { - } - public override async Task Delete_where_hierarchy(bool async) { await base.Delete_where_hierarchy(async); diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesNpgsqlTest.cs index 90f2a52d9..6b68719e9 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesNpgsqlTest.cs @@ -2,16 +2,11 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.BulkUpdates; -public class TPCInheritanceBulkUpdatesNpgsqlTest - : TPCInheritanceBulkUpdatesTestBase +public class TPCInheritanceBulkUpdatesNpgsqlTest( + TPCInheritanceBulkUpdatesNpgsqlFixture fixture, + ITestOutputHelper testOutputHelper) + : TPCInheritanceBulkUpdatesTestBase(fixture, testOutputHelper) { - public TPCInheritanceBulkUpdatesNpgsqlTest( - TPCInheritanceBulkUpdatesNpgsqlFixture fixture, - ITestOutputHelper testOutputHelper) - : base(fixture, testOutputHelper) - { - } - public override async Task Delete_where_hierarchy(bool async) { await base.Delete_where_hierarchy(async); diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesNpgsqlTest.cs index b0590845f..9e9a1477e 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesNpgsqlTest.cs @@ -2,16 +2,11 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.BulkUpdates; -public class TPTFiltersInheritanceBulkUpdatesSqlServerTest - : TPTFiltersInheritanceBulkUpdatesTestBase +public class TPTFiltersInheritanceBulkUpdatesSqlServerTest( + TPTFiltersInheritanceBulkUpdatesNpgsqlFixture fixture, + ITestOutputHelper testOutputHelper) + : TPTFiltersInheritanceBulkUpdatesTestBase(fixture, testOutputHelper) { - public TPTFiltersInheritanceBulkUpdatesSqlServerTest( - TPTFiltersInheritanceBulkUpdatesNpgsqlFixture fixture, - ITestOutputHelper testOutputHelper) - : base(fixture, testOutputHelper) - { - } - public override async Task Delete_where_hierarchy(bool async) { await base.Delete_where_hierarchy(async); diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesNpgsqlTest.cs index 503c0ae55..d2e87b654 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesNpgsqlTest.cs @@ -2,15 +2,11 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.BulkUpdates; -public class TPTInheritanceBulkUpdatesNpgsqlTest : TPTInheritanceBulkUpdatesTestBase +public class TPTInheritanceBulkUpdatesNpgsqlTest( + TPTInheritanceBulkUpdatesNpgsqlFixture fixture, + ITestOutputHelper testOutputHelper) + : TPTInheritanceBulkUpdatesTestBase(fixture, testOutputHelper) { - public TPTInheritanceBulkUpdatesNpgsqlTest( - TPTInheritanceBulkUpdatesNpgsqlFixture fixture, - ITestOutputHelper testOutputHelper) - : base(fixture, testOutputHelper) - { - } - public override async Task Delete_where_hierarchy(bool async) { await base.Delete_where_hierarchy(async); diff --git a/test/EFCore.PG.FunctionalTests/CommandInterceptionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/CommandInterceptionNpgsqlTest.cs index ced8872ae..26799628e 100644 --- a/test/EFCore.PG.FunctionalTests/CommandInterceptionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/CommandInterceptionNpgsqlTest.cs @@ -4,13 +4,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public abstract class CommandInterceptionNpgsqlTestBase : CommandInterceptionTestBase +public abstract class CommandInterceptionNpgsqlTestBase(CommandInterceptionNpgsqlTestBase.InterceptionNpgsqlFixtureBase fixture) + : CommandInterceptionTestBase(fixture) { - public CommandInterceptionNpgsqlTestBase(InterceptionNpgsqlFixtureBase fixture) - : base(fixture) - { - } - public abstract class InterceptionNpgsqlFixtureBase : InterceptionFixtureBase { protected override string StoreName @@ -25,14 +21,9 @@ protected override IServiceCollection InjectInterceptors( => base.InjectInterceptors(serviceCollection.AddEntityFrameworkNpgsql(), injectedInterceptors); } - public class CommandInterceptionNpgsqlTest - : CommandInterceptionNpgsqlTestBase, IClassFixture + public class CommandInterceptionNpgsqlTest(CommandInterceptionNpgsqlTest.InterceptionNpgsqlFixture fixture) + : CommandInterceptionNpgsqlTestBase(fixture), IClassFixture { - public CommandInterceptionNpgsqlTest(InterceptionNpgsqlFixture fixture) - : base(fixture) - { - } - public class InterceptionNpgsqlFixture : InterceptionNpgsqlFixtureBase { protected override bool ShouldSubscribeToDiagnosticListener @@ -47,14 +38,10 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build } } - public class CommandInterceptionWithDiagnosticsNpgsqlTest - : CommandInterceptionNpgsqlTestBase, IClassFixture + public class CommandInterceptionWithDiagnosticsNpgsqlTest( + CommandInterceptionWithDiagnosticsNpgsqlTest.InterceptionNpgsqlFixture fixture) + : CommandInterceptionNpgsqlTestBase(fixture), IClassFixture { - public CommandInterceptionWithDiagnosticsNpgsqlTest(InterceptionNpgsqlFixture fixture) - : base(fixture) - { - } - public class InterceptionNpgsqlFixture : InterceptionNpgsqlFixtureBase { protected override bool ShouldSubscribeToDiagnosticListener diff --git a/test/EFCore.PG.FunctionalTests/CompositeKeyEndToEndTest.cs b/test/EFCore.PG.FunctionalTests/CompositeKeyEndToEndTest.cs index 6e66276b3..3770aaf73 100644 --- a/test/EFCore.PG.FunctionalTests/CompositeKeyEndToEndTest.cs +++ b/test/EFCore.PG.FunctionalTests/CompositeKeyEndToEndTest.cs @@ -2,13 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class CompositeKeyEndToEndNpgsqlTest : CompositeKeyEndToEndTestBase +public class CompositeKeyEndToEndNpgsqlTest(CompositeKeyEndToEndNpgsqlTest.CompositeKeyEndToEndNpgsqlFixture fixture) + : CompositeKeyEndToEndTestBase(fixture) { - public CompositeKeyEndToEndNpgsqlTest(CompositeKeyEndToEndNpgsqlFixture fixture) - : base(fixture) - { - } - public class CompositeKeyEndToEndNpgsqlFixture : CompositeKeyEndToEndFixtureBase { protected override ITestStoreFactory TestStoreFactory diff --git a/test/EFCore.PG.FunctionalTests/ComputedColumnTest.cs b/test/EFCore.PG.FunctionalTests/ComputedColumnTest.cs index 4565752b1..17340262f 100644 --- a/test/EFCore.PG.FunctionalTests/ComputedColumnTest.cs +++ b/test/EFCore.PG.FunctionalTests/ComputedColumnTest.cs @@ -47,16 +47,10 @@ public void Can_use_computed_columns_with_null_values() Assert.Null(entity.P5); } - private class Context : DbContext + private class Context(IServiceProvider serviceProvider, string databaseName) : DbContext { - private readonly IServiceProvider _serviceProvider; - private readonly string _databaseName; - - public Context(IServiceProvider serviceProvider, string databaseName) - { - _serviceProvider = serviceProvider; - _databaseName = databaseName; - } + private readonly IServiceProvider _serviceProvider = serviceProvider; + private readonly string _databaseName = databaseName; public DbSet Entities { get; set; } @@ -103,23 +97,14 @@ public class EnumItem public FlagEnum? CalculatedFlagEnum { get; set; } } - private class NullableContext : DbContext + private class NullableContext(IServiceProvider serviceProvider, string databaseName) : DbContext { - private readonly IServiceProvider _serviceProvider; - private readonly string _databaseName; - - public NullableContext(IServiceProvider serviceProvider, string databaseName) - { - _serviceProvider = serviceProvider; - _databaseName = databaseName; - } - public DbSet EnumItems { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseNpgsql(NpgsqlTestStore.CreateConnectionString(_databaseName), b => b.ApplyConfiguration()) - .UseInternalServiceProvider(_serviceProvider); + .UseNpgsql(NpgsqlTestStore.CreateConnectionString(databaseName), b => b.ApplyConfiguration()) + .UseInternalServiceProvider(serviceProvider); protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.Entity() @@ -143,12 +128,7 @@ public void Can_use_computed_columns_with_nullable_enum() Assert.Equal(FlagEnum.AValue | FlagEnum.BValue, entity.CalculatedFlagEnum); } - public ComputedColumnTest() - { - TestStore = NpgsqlTestStore.CreateInitialized("ComputedColumnTest"); - } - - protected NpgsqlTestStore TestStore { get; } + protected NpgsqlTestStore TestStore { get; } = NpgsqlTestStore.CreateInitialized("ComputedColumnTest"); public virtual void Dispose() => TestStore.Dispose(); diff --git a/test/EFCore.PG.FunctionalTests/ConferencePlannerNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/ConferencePlannerNpgsqlTest.cs index 4a9611f0a..c7619c547 100644 --- a/test/EFCore.PG.FunctionalTests/ConferencePlannerNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/ConferencePlannerNpgsqlTest.cs @@ -4,13 +4,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class ConferencePlannerNpgsqlTest : ConferencePlannerTestBase +public class ConferencePlannerNpgsqlTest(ConferencePlannerNpgsqlTest.ConferencePlannerNpgsqlFixture fixture) + : ConferencePlannerTestBase(fixture) { - public ConferencePlannerNpgsqlTest(ConferencePlannerNpgsqlFixture fixture) - : base(fixture) - { - } - // Overridden to use UTC DateTimeOffsets public override async Task SessionsController_Post() => await ExecuteWithStrategyInTransactionAsync( diff --git a/test/EFCore.PG.FunctionalTests/ConnectionInterceptionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/ConnectionInterceptionNpgsqlTest.cs index e8c47ed71..2d8f44e13 100644 --- a/test/EFCore.PG.FunctionalTests/ConnectionInterceptionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/ConnectionInterceptionNpgsqlTest.cs @@ -4,13 +4,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public abstract class ConnectionInterceptionNpgsqlTestBase : ConnectionInterceptionTestBase +public abstract class ConnectionInterceptionNpgsqlTestBase(ConnectionInterceptionNpgsqlTestBase.InterceptionNpgsqlFixtureBase fixture) + : ConnectionInterceptionTestBase(fixture) { - protected ConnectionInterceptionNpgsqlTestBase(InterceptionNpgsqlFixtureBase fixture) - : base(fixture) - { - } - [ConditionalTheory(Skip = "#2368")] public override Task Intercept_connection_creation_passively(bool async) => base.Intercept_connection_creation_passively(async); @@ -79,14 +75,9 @@ protected override DbCommand CreateDbCommand() => throw new NotImplementedException(); } - public class ConnectionInterceptionNpgsqlTest - : ConnectionInterceptionNpgsqlTestBase, IClassFixture + public class ConnectionInterceptionNpgsqlTest(ConnectionInterceptionNpgsqlTest.InterceptionNpgsqlFixture fixture) + : ConnectionInterceptionNpgsqlTestBase(fixture), IClassFixture { - public ConnectionInterceptionNpgsqlTest(InterceptionNpgsqlFixture fixture) - : base(fixture) - { - } - public class InterceptionNpgsqlFixture : InterceptionNpgsqlFixtureBase { protected override bool ShouldSubscribeToDiagnosticListener @@ -94,14 +85,11 @@ protected override bool ShouldSubscribeToDiagnosticListener } } - public class ConnectionInterceptionWithDiagnosticsNpgsqlTest - : ConnectionInterceptionNpgsqlTestBase, IClassFixture + public class ConnectionInterceptionWithDiagnosticsNpgsqlTest( + ConnectionInterceptionWithDiagnosticsNpgsqlTest.InterceptionNpgsqlFixture fixture) + : ConnectionInterceptionNpgsqlTestBase(fixture), + IClassFixture { - public ConnectionInterceptionWithDiagnosticsNpgsqlTest(InterceptionNpgsqlFixture fixture) - : base(fixture) - { - } - public class InterceptionNpgsqlFixture : InterceptionNpgsqlFixtureBase { protected override bool ShouldSubscribeToDiagnosticListener diff --git a/test/EFCore.PG.FunctionalTests/ConnectionSpecificationTest.cs b/test/EFCore.PG.FunctionalTests/ConnectionSpecificationTest.cs index 539d70731..152082d8b 100644 --- a/test/EFCore.PG.FunctionalTests/ConnectionSpecificationTest.cs +++ b/test/EFCore.PG.FunctionalTests/ConnectionSpecificationTest.cs @@ -56,21 +56,14 @@ public void Can_specify_connection_in_OnConfiguring_with_default_service_provide Assert.True(context.Customers.Any()); } - private class ConnectionInOnConfiguringContext : NorthwindContextBase + private class ConnectionInOnConfiguringContext(NpgsqlConnection connection) : NorthwindContextBase { - private readonly NpgsqlConnection _connection; - - public ConnectionInOnConfiguringContext(NpgsqlConnection connection) - { - _connection = connection; - } - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - => optionsBuilder.UseNpgsql(_connection, b => b.ApplyConfiguration()); + => optionsBuilder.UseNpgsql(connection, b => b.ApplyConfiguration()); public override void Dispose() { - _connection.Dispose(); + connection.Dispose(); base.Dispose(); } } @@ -108,9 +101,7 @@ public void Throws_if_no_config_without_UseNpgsql() } // ReSharper disable once ClassNeverInstantiated.Local - private class NoUseNpgsqlContext : NorthwindContextBase - { - } + private class NoUseNpgsqlContext : NorthwindContextBase; [Fact] public void Can_depend_on_DbContextOptions() @@ -137,30 +128,21 @@ public void Can_depend_on_DbContextOptions_with_default_service_provider() Assert.True(context.Customers.Any()); } - private class OptionsContext : NorthwindContextBase + private class OptionsContext(DbContextOptions options, NpgsqlConnection connection) + : NorthwindContextBase(options) { - private readonly NpgsqlConnection _connection; - private readonly DbContextOptions _options; - - public OptionsContext(DbContextOptions options, NpgsqlConnection connection) - : base(options) - { - _options = options; - _connection = connection; - } - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - Assert.Same(_options, optionsBuilder.Options); + Assert.Same(options, optionsBuilder.Options); - optionsBuilder.UseNpgsql(_connection, b => b.ApplyConfiguration()); + optionsBuilder.UseNpgsql(connection, b => b.ApplyConfiguration()); - Assert.NotSame(_options, optionsBuilder.Options); + Assert.NotSame(options, optionsBuilder.Options); } public override void Dispose() { - _connection.Dispose(); + connection.Dispose(); base.Dispose(); } } @@ -187,15 +169,9 @@ public void Can_depend_on_non_generic_options_when_only_one_context_with_default Assert.True(context.Customers.Any()); } - private class NonGenericOptionsContext : NorthwindContextBase + private class NonGenericOptionsContext(DbContextOptions options) : NorthwindContextBase(options) { - private readonly DbContextOptions _options; - - public NonGenericOptionsContext(DbContextOptions options) - : base(options) - { - _options = options; - } + private readonly DbContextOptions _options = options; protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { @@ -301,13 +277,7 @@ public void Can_create_admin_connection_with_connection() adminConnection.Open(); } - private class GeneralOptionsContext : NorthwindContextBase - { - public GeneralOptionsContext(DbContextOptions options) - : base(options) - { - } - } + private class GeneralOptionsContext(DbContextOptions options) : NorthwindContextBase(options); #endregion } diff --git a/test/EFCore.PG.FunctionalTests/CustomConvertersNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/CustomConvertersNpgsqlTest.cs index 085f560c4..10f0cc9d9 100644 --- a/test/EFCore.PG.FunctionalTests/CustomConvertersNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/CustomConvertersNpgsqlTest.cs @@ -2,13 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class CustomConvertersNpgsqlTest : CustomConvertersTestBase +public class CustomConvertersNpgsqlTest(CustomConvertersNpgsqlTest.CustomConvertersNpgsqlFixture fixture) + : CustomConvertersTestBase(fixture) { - public CustomConvertersNpgsqlTest(CustomConvertersNpgsqlFixture fixture) - : base(fixture) - { - } - // Disabled: PostgreSQL is case-sensitive public override void Can_insert_and_read_back_with_case_insensitive_string_key() { } diff --git a/test/EFCore.PG.FunctionalTests/DataAnnotationNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/DataAnnotationNpgsqlTest.cs index cc2b9f362..634a16cf2 100644 --- a/test/EFCore.PG.FunctionalTests/DataAnnotationNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/DataAnnotationNpgsqlTest.cs @@ -2,13 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class DataAnnotationNpgsqlTest : DataAnnotationRelationalTestBase +public class DataAnnotationNpgsqlTest(DataAnnotationNpgsqlTest.DataAnnotationNpgsqlFixture fixture) + : DataAnnotationRelationalTestBase(fixture) { - public DataAnnotationNpgsqlTest(DataAnnotationNpgsqlFixture fixture) - : base(fixture) - { - } - protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.PG.FunctionalTests/DataBindingNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/DataBindingNpgsqlTest.cs index 308ef08e7..9e53df97a 100644 --- a/test/EFCore.PG.FunctionalTests/DataBindingNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/DataBindingNpgsqlTest.cs @@ -1,9 +1,3 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class DataBindingNpgsqlTest : DataBindingTestBase -{ - public DataBindingNpgsqlTest(F1BytesNpgsqlFixture fixture) - : base(fixture) - { - } -} +public class DataBindingNpgsqlTest(F1BytesNpgsqlFixture fixture) : DataBindingTestBase(fixture); diff --git a/test/EFCore.PG.FunctionalTests/DefaultValuesTest.cs b/test/EFCore.PG.FunctionalTests/DefaultValuesTest.cs index b3677ed03..611655a01 100644 --- a/test/EFCore.PG.FunctionalTests/DefaultValuesTest.cs +++ b/test/EFCore.PG.FunctionalTests/DefaultValuesTest.cs @@ -43,16 +43,10 @@ public void Dispose() context.Database.EnsureDeleted(); } - private class ChipsContext : DbContext + private class ChipsContext(IServiceProvider serviceProvider, string databaseName) : DbContext { - private readonly IServiceProvider _serviceProvider; - private readonly string _databaseName; - - public ChipsContext(IServiceProvider serviceProvider, string databaseName) - { - _serviceProvider = serviceProvider; - _databaseName = databaseName; - } + private readonly IServiceProvider _serviceProvider = serviceProvider; + private readonly string _databaseName = databaseName; // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Chips { get; set; } diff --git a/test/EFCore.PG.FunctionalTests/DesignTimeNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/DesignTimeNpgsqlTest.cs index 88e113ac7..3bfffa890 100644 --- a/test/EFCore.PG.FunctionalTests/DesignTimeNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/DesignTimeNpgsqlTest.cs @@ -3,13 +3,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class DesignTimeNpgsqlTest : DesignTimeTestBase +public class DesignTimeNpgsqlTest(DesignTimeNpgsqlTest.DesignTimeNpgsqlFixture fixture) + : DesignTimeTestBase(fixture) { - public DesignTimeNpgsqlTest(DesignTimeNpgsqlFixture fixture) - : base(fixture) - { - } - protected override Assembly ProviderAssembly => typeof(NpgsqlDesignTimeServices).Assembly; diff --git a/test/EFCore.PG.FunctionalTests/EntitySplittingNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/EntitySplittingNpgsqlTest.cs index dccba770b..8552d88f9 100644 --- a/test/EFCore.PG.FunctionalTests/EntitySplittingNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/EntitySplittingNpgsqlTest.cs @@ -2,13 +2,8 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class EntitySplittingNpgsqlTest : EntitySplittingTestBase +public class EntitySplittingNpgsqlTest(ITestOutputHelper testOutputHelper) : EntitySplittingTestBase(testOutputHelper) { - public EntitySplittingNpgsqlTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) - { - } - protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; } diff --git a/test/EFCore.PG.FunctionalTests/ExecutionStrategyTest.cs b/test/EFCore.PG.FunctionalTests/ExecutionStrategyTest.cs index 1d82ef469..f66ac9433 100644 --- a/test/EFCore.PG.FunctionalTests/ExecutionStrategyTest.cs +++ b/test/EFCore.PG.FunctionalTests/ExecutionStrategyTest.cs @@ -607,13 +607,8 @@ public void Verification_is_retried_using_same_retry_limit() } } - protected class ExecutionStrategyContext : DbContext + protected class ExecutionStrategyContext(DbContextOptions options) : DbContext(options) { - public ExecutionStrategyContext(DbContextOptions options) - : base(options) - { - } - public DbSet Products { get; set; } } diff --git a/test/EFCore.PG.FunctionalTests/ExistingConnectionTest.cs b/test/EFCore.PG.FunctionalTests/ExistingConnectionTest.cs index cebec6272..2ef271f86 100644 --- a/test/EFCore.PG.FunctionalTests/ExistingConnectionTest.cs +++ b/test/EFCore.PG.FunctionalTests/ExistingConnectionTest.cs @@ -67,16 +67,10 @@ private static async Task Can_use_an_existing_closed_connection_test(bool openCo } } - private class NorthwindContext : DbContext + private class NorthwindContext(IServiceProvider serviceProvider, NpgsqlConnection connection) : DbContext { - private readonly IServiceProvider _serviceProvider; - private readonly NpgsqlConnection _connection; - - public NorthwindContext(IServiceProvider serviceProvider, NpgsqlConnection connection) - { - _serviceProvider = serviceProvider; - _connection = connection; - } + private readonly IServiceProvider _serviceProvider = serviceProvider; + private readonly NpgsqlConnection _connection = connection; // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Customers { get; set; } diff --git a/test/EFCore.PG.FunctionalTests/F1NpgsqlFixture.cs b/test/EFCore.PG.FunctionalTests/F1NpgsqlFixture.cs index 193474eed..91be0a0e5 100644 --- a/test/EFCore.PG.FunctionalTests/F1NpgsqlFixture.cs +++ b/test/EFCore.PG.FunctionalTests/F1NpgsqlFixture.cs @@ -21,16 +21,10 @@ protected override void BuildModelExternal(ModelBuilder modelBuilder) }); } - private class BytesToUIntConverter : ValueConverter - { - public BytesToUIntConverter() - : base( - bytes => BitConverter.ToUInt32(bytes), - num => BitConverter.GetBytes(num), - mappingHints: null) - { - } - } + private class BytesToUIntConverter() : ValueConverter( + bytes => BitConverter.ToUInt32(bytes), + num => BitConverter.GetBytes(num), + mappingHints: null); } public class F1NpgsqlFixture : F1NpgsqlFixtureBase diff --git a/test/EFCore.PG.FunctionalTests/FieldMappingNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/FieldMappingNpgsqlTest.cs index dd19464ba..c725a2f93 100644 --- a/test/EFCore.PG.FunctionalTests/FieldMappingNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/FieldMappingNpgsqlTest.cs @@ -2,14 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class FieldMappingNpgsqlTest - : FieldMappingTestBase +public class FieldMappingNpgsqlTest(FieldMappingNpgsqlTest.FieldMappingNpgsqlFixture fixture) + : FieldMappingTestBase(fixture) { - public FieldMappingNpgsqlTest(FieldMappingNpgsqlFixture fixture) - : base(fixture) - { - } - protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.PG.FunctionalTests/FindNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/FindNpgsqlTest.cs index 071c2e844..a76837511 100644 --- a/test/EFCore.PG.FunctionalTests/FindNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/FindNpgsqlTest.cs @@ -10,33 +10,18 @@ protected FindNpgsqlTest(FindNpgsqlFixture fixture) fixture.TestSqlLoggerFactory.Clear(); } - public class FindNpgsqlTestSet : FindNpgsqlTest + public class FindNpgsqlTestSet(FindNpgsqlFixture fixture) : FindNpgsqlTest(fixture) { - public FindNpgsqlTestSet(FindNpgsqlFixture fixture) - : base(fixture) - { - } - protected override TestFinder Finder { get; } = new FindViaSetFinder(); } - public class FindNpgsqlTestContext : FindNpgsqlTest + public class FindNpgsqlTestContext(FindNpgsqlFixture fixture) : FindNpgsqlTest(fixture) { - public FindNpgsqlTestContext(FindNpgsqlFixture fixture) - : base(fixture) - { - } - protected override TestFinder Finder { get; } = new FindViaContextFinder(); } - public class FindNpgsqlTestNonGeneric : FindNpgsqlTest + public class FindNpgsqlTestNonGeneric(FindNpgsqlFixture fixture) : FindNpgsqlTest(fixture) { - public FindNpgsqlTestNonGeneric(FindNpgsqlFixture fixture) - : base(fixture) - { - } - protected override TestFinder Finder { get; } = new FindViaNonGenericContextFinder(); } diff --git a/test/EFCore.PG.FunctionalTests/KeysWithConvertersNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/KeysWithConvertersNpgsqlTest.cs index 1bc6bf9af..e83af54b8 100644 --- a/test/EFCore.PG.FunctionalTests/KeysWithConvertersNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/KeysWithConvertersNpgsqlTest.cs @@ -2,14 +2,10 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class KeysWithConvertersNpgsqlTest : KeysWithConvertersTestBase< - KeysWithConvertersNpgsqlTest.KeysWithConvertersNpgsqlFixture> +public class KeysWithConvertersNpgsqlTest(KeysWithConvertersNpgsqlTest.KeysWithConvertersNpgsqlFixture fixture) + : KeysWithConvertersTestBase< + KeysWithConvertersNpgsqlTest.KeysWithConvertersNpgsqlFixture>(fixture) { - public KeysWithConvertersNpgsqlTest(KeysWithConvertersNpgsqlFixture fixture) - : base(fixture) - { - } - public class KeysWithConvertersNpgsqlFixture : KeysWithConvertersFixtureBase { protected override ITestStoreFactory TestStoreFactory diff --git a/test/EFCore.PG.FunctionalTests/ManyToManyFieldsLoadNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/ManyToManyFieldsLoadNpgsqlTest.cs index 9f4b69706..7edbcc6ab 100644 --- a/test/EFCore.PG.FunctionalTests/ManyToManyFieldsLoadNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/ManyToManyFieldsLoadNpgsqlTest.cs @@ -3,14 +3,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class ManyToManyFieldsLoadNpgsqlTest - : ManyToManyFieldsLoadTestBase +public class ManyToManyFieldsLoadNpgsqlTest(ManyToManyFieldsLoadNpgsqlTest.ManyToManyFieldsLoadNpgsqlFixture fixture) + : ManyToManyFieldsLoadTestBase(fixture) { - public ManyToManyFieldsLoadNpgsqlTest(ManyToManyFieldsLoadNpgsqlFixture fixture) - : base(fixture) - { - } - public class ManyToManyFieldsLoadNpgsqlFixture : ManyToManyFieldsLoadFixtureBase { public TestSqlLoggerFactory TestSqlLoggerFactory diff --git a/test/EFCore.PG.FunctionalTests/ManyToManyLoadNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/ManyToManyLoadNpgsqlTest.cs index 0d7eaddd4..eaa5fea6a 100644 --- a/test/EFCore.PG.FunctionalTests/ManyToManyLoadNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/ManyToManyLoadNpgsqlTest.cs @@ -3,13 +3,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class ManyToManyLoadNpgsqlTest : ManyToManyLoadTestBase +public class ManyToManyLoadNpgsqlTest(ManyToManyLoadNpgsqlTest.ManyToManyLoadNpgsqlFixture fixture) + : ManyToManyLoadTestBase(fixture) { - public ManyToManyLoadNpgsqlTest(ManyToManyLoadNpgsqlFixture fixture) - : base(fixture) - { - } - public class ManyToManyLoadNpgsqlFixture : ManyToManyLoadFixtureBase { public TestSqlLoggerFactory TestSqlLoggerFactory diff --git a/test/EFCore.PG.FunctionalTests/ManyToManyTrackingNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/ManyToManyTrackingNpgsqlTest.cs index 3ef930e16..b7a906ffd 100644 --- a/test/EFCore.PG.FunctionalTests/ManyToManyTrackingNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/ManyToManyTrackingNpgsqlTest.cs @@ -3,14 +3,10 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class ManyToManyTrackingNpgsqlTest : ManyToManyTrackingRelationalTestBase< - ManyToManyTrackingNpgsqlTest.ManyToManyTrackingNpgsqlFixture> +public class ManyToManyTrackingNpgsqlTest(ManyToManyTrackingNpgsqlTest.ManyToManyTrackingNpgsqlFixture fixture) + : ManyToManyTrackingRelationalTestBase< + ManyToManyTrackingNpgsqlTest.ManyToManyTrackingNpgsqlFixture>(fixture) { - public ManyToManyTrackingNpgsqlTest(ManyToManyTrackingNpgsqlFixture fixture) - : base(fixture) - { - } - protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.PG.FunctionalTests/MaterializationInterceptionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/MaterializationInterceptionNpgsqlTest.cs index dc8e30903..b571ed37c 100644 --- a/test/EFCore.PG.FunctionalTests/MaterializationInterceptionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/MaterializationInterceptionNpgsqlTest.cs @@ -6,22 +6,12 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class MaterializationInterceptionNpgsqlTest : - MaterializationInterceptionTestBase, - IClassFixture +public class MaterializationInterceptionNpgsqlTest(MaterializationInterceptionNpgsqlTest.MaterializationInterceptionNpgsqlFixture fixture) + : MaterializationInterceptionTestBase(fixture), + IClassFixture { - public MaterializationInterceptionNpgsqlTest(MaterializationInterceptionNpgsqlFixture fixture) - : base(fixture) + public class SqlServerLibraryContext(DbContextOptions options) : LibraryContext(options) { - } - - public class SqlServerLibraryContext : LibraryContext - { - public SqlServerLibraryContext(DbContextOptions options) - : base(options) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); diff --git a/test/EFCore.PG.FunctionalTests/Migrations/MigrationsInfrastructureNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Migrations/MigrationsInfrastructureNpgsqlTest.cs index 6336588d7..43139f7bb 100644 --- a/test/EFCore.PG.FunctionalTests/Migrations/MigrationsInfrastructureNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Migrations/MigrationsInfrastructureNpgsqlTest.cs @@ -4,14 +4,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Migrations { - public class MigrationsInfrastructureNpgsqlTest - : MigrationsInfrastructureTestBase + public class MigrationsInfrastructureNpgsqlTest(MigrationsInfrastructureNpgsqlTest.MigrationsInfrastructureNpgsqlFixture fixture) + : MigrationsInfrastructureTestBase(fixture) { - public MigrationsInfrastructureNpgsqlTest(MigrationsInfrastructureNpgsqlFixture fixture) - : base(fixture) - { - } - public override void Can_get_active_provider() { base.Can_get_active_provider(); @@ -34,13 +29,8 @@ public async Task Empty_Migration_Creates_Database() Assert.True(creator.Exists()); } - private class BloggingContext : DbContext + private class BloggingContext(DbContextOptions options) : DbContext(options) { - public BloggingContext(DbContextOptions options) - : base(options) - { - } - // ReSharper disable once UnusedMember.Local public DbSet Blogs { get; set; } diff --git a/test/EFCore.PG.FunctionalTests/Migrations/NpgsqlMigrationsSqlGeneratorTest.cs b/test/EFCore.PG.FunctionalTests/Migrations/NpgsqlMigrationsSqlGeneratorTest.cs index 19bb19b2f..a9e96d2c5 100644 --- a/test/EFCore.PG.FunctionalTests/Migrations/NpgsqlMigrationsSqlGeneratorTest.cs +++ b/test/EFCore.PG.FunctionalTests/Migrations/NpgsqlMigrationsSqlGeneratorTest.cs @@ -7,7 +7,13 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Migrations; -public class NpgsqlMigrationsSqlGeneratorTest : MigrationsSqlGeneratorTestBase +public class NpgsqlMigrationsSqlGeneratorTest() : MigrationsSqlGeneratorTestBase( + NpgsqlTestHelpers.Instance, + new ServiceCollection().AddEntityFrameworkNpgsqlNetTopologySuite(), + NpgsqlTestHelpers.Instance.AddProviderOptions( + ((IRelationalDbContextOptionsBuilderInfrastructure) + new NpgsqlDbContextOptionsBuilder(new DbContextOptionsBuilder()).UseNetTopologySuite()) + .OptionsBuilder).Options) { #region Database @@ -613,17 +619,6 @@ public override void InsertDataOperation_throws_for_unsupported_column_types() #pragma warning restore 618 - public NpgsqlMigrationsSqlGeneratorTest() - : base( - NpgsqlTestHelpers.Instance, - new ServiceCollection().AddEntityFrameworkNpgsqlNetTopologySuite(), - NpgsqlTestHelpers.Instance.AddProviderOptions( - ((IRelationalDbContextOptionsBuilderInfrastructure) - new NpgsqlDbContextOptionsBuilder(new DbContextOptionsBuilder()).UseNetTopologySuite()) - .OptionsBuilder).Options) - { - } - protected override string GetGeometryCollectionStoreType() => "GEOMETRY(GEOMETRYCOLLECTION)"; } diff --git a/test/EFCore.PG.FunctionalTests/MonsterFixupChangedChangingNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/MonsterFixupChangedChangingNpgsqlTest.cs index 7f7272073..433677564 100644 --- a/test/EFCore.PG.FunctionalTests/MonsterFixupChangedChangingNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/MonsterFixupChangedChangingNpgsqlTest.cs @@ -2,14 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class MonsterFixupChangedChangingNpgsqlTest : - MonsterFixupTestBase +public class MonsterFixupChangedChangingNpgsqlTest(MonsterFixupChangedChangingNpgsqlTest.MonsterFixupChangedChangingNpgsqlFixture fixture) + : MonsterFixupTestBase(fixture) { - public MonsterFixupChangedChangingNpgsqlTest(MonsterFixupChangedChangingNpgsqlFixture fixture) - : base(fixture) - { - } - public class MonsterFixupChangedChangingNpgsqlFixture : MonsterFixupChangedChangingFixtureBase { protected override ITestStoreFactory TestStoreFactory diff --git a/test/EFCore.PG.FunctionalTests/MusicStoreNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/MusicStoreNpgsqlTest.cs index a9c448cd9..45ca33212 100644 --- a/test/EFCore.PG.FunctionalTests/MusicStoreNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/MusicStoreNpgsqlTest.cs @@ -3,13 +3,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class MusicStoreNpgsqlTest : MusicStoreTestBase +public class MusicStoreNpgsqlTest(MusicStoreNpgsqlTest.MusicStoreNpgsqlFixture fixture) + : MusicStoreTestBase(fixture) { - public MusicStoreNpgsqlTest(MusicStoreNpgsqlFixture fixture) - : base(fixture) - { - } - public class MusicStoreNpgsqlFixture : MusicStoreFixtureBase { protected override ITestStoreFactory TestStoreFactory diff --git a/test/EFCore.PG.FunctionalTests/NotificationEntitiesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/NotificationEntitiesNpgsqlTest.cs index 326a7d58b..5adf93326 100644 --- a/test/EFCore.PG.FunctionalTests/NotificationEntitiesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/NotificationEntitiesNpgsqlTest.cs @@ -2,14 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class NotificationEntitiesNpgsqlTest - : NotificationEntitiesTestBase +public class NotificationEntitiesNpgsqlTest(NotificationEntitiesNpgsqlTest.NotificationEntitiesNpgsqlFixture fixture) + : NotificationEntitiesTestBase(fixture) { - public NotificationEntitiesNpgsqlTest(NotificationEntitiesNpgsqlFixture fixture) - : base(fixture) - { - } - public class NotificationEntitiesNpgsqlFixture : NotificationEntitiesFixtureBase { protected override string StoreName { get; } = "NotificationEntities"; diff --git a/test/EFCore.PG.FunctionalTests/NpgsqlApiConsistencyTest.cs b/test/EFCore.PG.FunctionalTests/NpgsqlApiConsistencyTest.cs index 7aff5b4ca..c5c596b2c 100644 --- a/test/EFCore.PG.FunctionalTests/NpgsqlApiConsistencyTest.cs +++ b/test/EFCore.PG.FunctionalTests/NpgsqlApiConsistencyTest.cs @@ -3,13 +3,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class NpgsqlApiConsistencyTest : ApiConsistencyTestBase +public class NpgsqlApiConsistencyTest(NpgsqlApiConsistencyTest.NpgsqlApiConsistencyFixture fixture) + : ApiConsistencyTestBase(fixture) { - public NpgsqlApiConsistencyTest(NpgsqlApiConsistencyFixture fixture) - : base(fixture) - { - } - protected override void AddServices(ServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkNpgsql(); diff --git a/test/EFCore.PG.FunctionalTests/NpgsqlDatabaseCreatorTest.cs b/test/EFCore.PG.FunctionalTests/NpgsqlDatabaseCreatorTest.cs index 3e2e54569..0a2ff9dcb 100644 --- a/test/EFCore.PG.FunctionalTests/NpgsqlDatabaseCreatorTest.cs +++ b/test/EFCore.PG.FunctionalTests/NpgsqlDatabaseCreatorTest.cs @@ -571,13 +571,9 @@ protected static IExecutionStrategy GetExecutionStrategy(NpgsqlTestStore testSto => new BloggingContext(testStore).GetService().Create(); // ReSharper disable once ClassNeverInstantiated.Local - private class TestNpgsqlExecutionStrategyFactory : NpgsqlExecutionStrategyFactory + private class TestNpgsqlExecutionStrategyFactory(ExecutionStrategyDependencies dependencies) + : NpgsqlExecutionStrategyFactory(dependencies) { - public TestNpgsqlExecutionStrategyFactory(ExecutionStrategyDependencies dependencies) - : base(dependencies) - { - } - protected override IExecutionStrategy CreateDefaultStrategy(ExecutionStrategyDependencies dependencies) => new NonRetryingExecutionStrategy(dependencies); } @@ -589,24 +585,17 @@ private static IServiceProvider CreateServiceProvider() .AddScoped() .BuildServiceProvider(); - protected class BloggingContext : DbContext + protected class BloggingContext(string connectionString) : DbContext { - private readonly string _connectionString; - public BloggingContext(NpgsqlTestStore testStore) : this(testStore.ConnectionString) { } - public BloggingContext(string connectionString) - { - _connectionString = connectionString; - } - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .UseNpgsql( - _connectionString, b => b + connectionString, b => b .ApplyConfiguration() .SetPostgresVersion(TestEnvironment.PostgresVersion)) .UseInternalServiceProvider(CreateServiceProvider()); @@ -641,16 +630,12 @@ public class Blog public byte[] AndRow { get; set; } } - public class TestDatabaseCreator : NpgsqlDatabaseCreator + public class TestDatabaseCreator( + RelationalDatabaseCreatorDependencies dependencies, + INpgsqlRelationalConnection connection, + IRawSqlCommandBuilder rawSqlCommandBuilder) + : NpgsqlDatabaseCreator(dependencies, connection, rawSqlCommandBuilder) { - public TestDatabaseCreator( - RelationalDatabaseCreatorDependencies dependencies, - INpgsqlRelationalConnection connection, - IRawSqlCommandBuilder rawSqlCommandBuilder) - : base(dependencies, connection, rawSqlCommandBuilder) - { - } - public bool HasTablesBase() => HasTables(); diff --git a/test/EFCore.PG.FunctionalTests/NpgsqlServiceCollectionExtensionsTest.cs b/test/EFCore.PG.FunctionalTests/NpgsqlServiceCollectionExtensionsTest.cs index efbc1e333..47173ca15 100644 --- a/test/EFCore.PG.FunctionalTests/NpgsqlServiceCollectionExtensionsTest.cs +++ b/test/EFCore.PG.FunctionalTests/NpgsqlServiceCollectionExtensionsTest.cs @@ -2,10 +2,4 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class NpgsqlServiceCollectionExtensionsTest : RelationalServiceCollectionExtensionsTestBase -{ - public NpgsqlServiceCollectionExtensionsTest() - : base(NpgsqlTestHelpers.Instance) - { - } -} +public class NpgsqlServiceCollectionExtensionsTest() : RelationalServiceCollectionExtensionsTestBase(NpgsqlTestHelpers.Instance); diff --git a/test/EFCore.PG.FunctionalTests/NpgsqlValueGenerationScenariosTest.cs b/test/EFCore.PG.FunctionalTests/NpgsqlValueGenerationScenariosTest.cs index b7de014d9..6f663d7d9 100644 --- a/test/EFCore.PG.FunctionalTests/NpgsqlValueGenerationScenariosTest.cs +++ b/test/EFCore.PG.FunctionalTests/NpgsqlValueGenerationScenariosTest.cs @@ -30,13 +30,7 @@ public void Insert_with_sequence_id() } } - public class BlogContextSequence : ContextBase - { - public BlogContextSequence(string databaseName) - : base(databaseName) - { - } - } + public class BlogContextSequence(string databaseName) : ContextBase(databaseName); [Fact] public void Insert_with_sequence_HiLo() @@ -61,13 +55,8 @@ public void Insert_with_sequence_HiLo() } } - public class BlogContextHiLo : ContextBase + public class BlogContextHiLo(string databaseName) : ContextBase(databaseName) { - public BlogContextHiLo(string databaseName) - : base(databaseName) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); @@ -117,13 +106,8 @@ public void Insert_with_default_value_from_sequence() } } - public class BlogContextDefaultValue : ContextBase + public class BlogContextDefaultValue(string databaseName) : ContextBase(databaseName) { - public BlogContextDefaultValue(string databaseName) - : base(databaseName) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); @@ -140,13 +124,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) } } - public class BlogContextDefaultValueNoMigrations : ContextBase + public class BlogContextDefaultValueNoMigrations(string databaseName) : ContextBase(databaseName) { - public BlogContextDefaultValueNoMigrations(string databaseName) - : base(databaseName) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); @@ -187,13 +166,8 @@ public void Insert_with_key_default_value_from_sequence() } } - public class BlogContextKeyColumnWithDefaultValue : ContextBase + public class BlogContextKeyColumnWithDefaultValue(string databaseName) : ContextBase(databaseName) { - public BlogContextKeyColumnWithDefaultValue(string databaseName) - : base(databaseName) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); @@ -233,13 +207,8 @@ public void Insert_uint_to_Identity_column_using_value_converter() } } - public class BlogContextUIntToIdentityUsingValueConverter : ContextBase + public class BlogContextUIntToIdentityUsingValueConverter(string databaseName) : ContextBase(databaseName) { - public BlogContextUIntToIdentityUsingValueConverter(string databaseName) - : base(databaseName) - { - } - public DbSet UnsignedBlogs { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) @@ -282,13 +251,8 @@ public void Insert_string_to_Identity_column_using_value_converter() } } - public class BlogContextStringToIdentityUsingValueConverter : ContextBase + public class BlogContextStringToIdentityUsingValueConverter(string databaseName) : ContextBase(databaseName) { - public BlogContextStringToIdentityUsingValueConverter(string databaseName) - : base(databaseName) - { - } - public DbSet StringyBlogs { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) @@ -332,13 +296,8 @@ public void Insert_with_explicit_non_default_keys() } } - public class BlogContextNoKeyGeneration : ContextBase + public class BlogContextNoKeyGeneration(string databaseName) : ContextBase(databaseName) { - public BlogContextNoKeyGeneration(string databaseName) - : base(databaseName) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); @@ -373,13 +332,8 @@ public void Insert_with_explicit_with_default_keys() } } - public class BlogContextNoKeyGenerationNullableKey : ContextBase + public class BlogContextNoKeyGenerationNullableKey(string databaseName) : ContextBase(databaseName) { - public BlogContextNoKeyGenerationNullableKey(string databaseName) - : base(databaseName) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); @@ -431,13 +385,8 @@ public void Insert_with_non_key_default_value() } } - public class BlogContextNonKeyDefaultValue : ContextBase + public class BlogContextNonKeyDefaultValue(string databaseName) : ContextBase(databaseName) { - public BlogContextNonKeyDefaultValue(string databaseName) - : base(databaseName) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); @@ -490,13 +439,8 @@ public void Insert_with_non_key_default_value_readonly() } } - public class BlogContextNonKeyReadOnlyDefaultValue : ContextBase + public class BlogContextNonKeyReadOnlyDefaultValue(string databaseName) : ContextBase(databaseName) { - public BlogContextNonKeyReadOnlyDefaultValue(string databaseName) - : base(databaseName) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); @@ -533,13 +477,8 @@ public void Insert_with_serial_non_id() } } - public class BlogContextSequenceNonId : ContextBase + public class BlogContextSequenceNonId(string databaseName) : ContextBase(databaseName) { - public BlogContextSequenceNonId(string databaseName) - : base(databaseName) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); @@ -574,13 +513,7 @@ public void Insert_with_client_generated_GUID_key() } } - public class BlogContext : ContextBase - { - public BlogContext(string databaseName) - : base(databaseName) - { - } - } + public class BlogContext(string databaseName) : ContextBase(databaseName); [Fact] public void Insert_with_server_generated_GUID_key() @@ -617,13 +550,8 @@ public void Insert_with_server_generated_GUID_key() } } - public class BlogContextServerGuidKey : ContextBase + public class BlogContextServerGuidKey(string databaseName) : ContextBase(databaseName) { - public BlogContextServerGuidKey(string databaseName) - : base(databaseName) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.HasPostgresExtension("uuid-ossp"); @@ -676,15 +604,8 @@ public class ConcurrentBlog public byte[] Timestamp { get; set; } } - public abstract class ContextBase : DbContext + public abstract class ContextBase(string databaseName) : DbContext { - private readonly string _databaseName; - - protected ContextBase(string databaseName) - { - _databaseName = databaseName; - } - public DbSet Blogs { get; set; } public DbSet NullableKeyBlogs { get; set; } public DbSet FullNameBlogs { get; set; } @@ -695,7 +616,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder .EnableServiceProviderCaching(false) .UseNpgsql( - NpgsqlTestStore.CreateConnectionString(_databaseName), + NpgsqlTestStore.CreateConnectionString(databaseName), b => b.ApplyConfiguration()); protected override void OnModelCreating(ModelBuilder modelBuilder) diff --git a/test/EFCore.PG.FunctionalTests/OptimisticConcurrencyNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/OptimisticConcurrencyNpgsqlTest.cs index fbccf7ceb..e68095f3c 100644 --- a/test/EFCore.PG.FunctionalTests/OptimisticConcurrencyNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/OptimisticConcurrencyNpgsqlTest.cs @@ -2,32 +2,16 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class OptimisticConcurrencyBytesNpgsqlTest : OptimisticConcurrencyNpgsqlTestBase -{ - public OptimisticConcurrencyBytesNpgsqlTest(F1BytesNpgsqlFixture fixture) - : base(fixture) - { - } -} +public class OptimisticConcurrencyBytesNpgsqlTest(F1BytesNpgsqlFixture fixture) + : OptimisticConcurrencyNpgsqlTestBase(fixture); // uint maps directly to xid, which is the PG type of the xmin column that we use as a row version. -public class OptimisticConcurrencyNpgsqlTest : OptimisticConcurrencyNpgsqlTestBase -{ - public OptimisticConcurrencyNpgsqlTest(F1NpgsqlFixture fixture) - : base(fixture) - { - } -} +public class OptimisticConcurrencyNpgsqlTest(F1NpgsqlFixture fixture) : OptimisticConcurrencyNpgsqlTestBase(fixture); -public abstract class OptimisticConcurrencyNpgsqlTestBase - : OptimisticConcurrencyRelationalTestBase +public abstract class OptimisticConcurrencyNpgsqlTestBase(TFixture fixture) + : OptimisticConcurrencyRelationalTestBase(fixture) where TFixture : F1RelationalFixture, new() { - protected OptimisticConcurrencyNpgsqlTestBase(TFixture fixture) - : base(fixture) - { - } - [ConditionalFact] public async Task Modifying_concurrency_token_only_is_noop() { diff --git a/test/EFCore.PG.FunctionalTests/OverzealousInitializationNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/OverzealousInitializationNpgsqlTest.cs index 51650b7bd..103eea732 100644 --- a/test/EFCore.PG.FunctionalTests/OverzealousInitializationNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/OverzealousInitializationNpgsqlTest.cs @@ -2,14 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class OverzealousInitializationNpgsqlTest - : OverzealousInitializationTestBase +public class OverzealousInitializationNpgsqlTest(OverzealousInitializationNpgsqlTest.OverzealousInitializationNpgsqlFixture fixture) + : OverzealousInitializationTestBase(fixture) { - public OverzealousInitializationNpgsqlTest(OverzealousInitializationNpgsqlFixture fixture) - : base(fixture) - { - } - public class OverzealousInitializationNpgsqlFixture : OverzealousInitializationFixtureBase { protected override ITestStoreFactory TestStoreFactory diff --git a/test/EFCore.PG.FunctionalTests/PropertyValuesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/PropertyValuesNpgsqlTest.cs index 7473cba9d..2f9d6bfed 100644 --- a/test/EFCore.PG.FunctionalTests/PropertyValuesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/PropertyValuesNpgsqlTest.cs @@ -2,13 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class PropertyValuesNpgsqlTest : PropertyValuesTestBase +public class PropertyValuesNpgsqlTest(PropertyValuesNpgsqlTest.PropertyValuesNpgsqlFixture fixture) + : PropertyValuesTestBase(fixture) { - public PropertyValuesNpgsqlTest(PropertyValuesNpgsqlFixture fixture) - : base(fixture) - { - } - public class PropertyValuesNpgsqlFixture : PropertyValuesFixtureBase { protected override string StoreName { get; } = "PropertyValues"; diff --git a/test/EFCore.PG.FunctionalTests/Query/ArrayArrayQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/ArrayArrayQueryTest.cs index 5703c1eeb..629e474f5 100644 --- a/test/EFCore.PG.FunctionalTests/Query/ArrayArrayQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/ArrayArrayQueryTest.cs @@ -2,13 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; -public class ArrayArrayQueryTest : ArrayQueryTest +public class ArrayArrayQueryTest(ArrayArrayQueryTest.ArrayArrayQueryFixture fixture, ITestOutputHelper testOutputHelper) + : ArrayQueryTest(fixture, testOutputHelper) { - public ArrayArrayQueryTest(ArrayArrayQueryFixture fixture, ITestOutputHelper testOutputHelper) - : base(fixture, testOutputHelper) - { - } - #region Indexers public override async Task Index_with_constant(bool async) diff --git a/test/EFCore.PG.FunctionalTests/Query/BigIntegerQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/BigIntegerQueryTest.cs index e48fcd9bd..44b42b2b9 100644 --- a/test/EFCore.PG.FunctionalTests/Query/BigIntegerQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/BigIntegerQueryTest.cs @@ -128,15 +128,10 @@ await AssertQuery( private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - public class BigIntegerQueryContext : PoolableDbContext + public class BigIntegerQueryContext(DbContextOptions options) : PoolableDbContext(options) { public DbSet Entities { get; set; } - public BigIntegerQueryContext(DbContextOptions options) - : base(options) - { - } - public static void Seed(BigIntegerQueryContext context) { context.Entities.AddRange(BigIntegerData.CreateEntities()); @@ -198,12 +193,7 @@ public IReadOnlyDictionary EntityAsserters protected class BigIntegerData : ISetSource { - public IReadOnlyList Entities { get; } - - public BigIntegerData() - { - Entities = CreateEntities(); - } + public IReadOnlyList Entities { get; } = CreateEntities(); public IQueryable Set() where TEntity : class diff --git a/test/EFCore.PG.FunctionalTests/Query/CitextQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/CitextQueryTest.cs index 088c43ec9..20d48e02e 100644 --- a/test/EFCore.PG.FunctionalTests/Query/CitextQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/CitextQueryTest.cs @@ -294,15 +294,10 @@ protected CitextQueryContext CreateContext() private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - public class CitextQueryContext : PoolableDbContext + public class CitextQueryContext(DbContextOptions options) : PoolableDbContext(options) { public DbSet SomeEntities { get; set; } - public CitextQueryContext(DbContextOptions options) - : base(options) - { - } - public static void Seed(CitextQueryContext context) { context.SomeEntities.AddRange( diff --git a/test/EFCore.PG.FunctionalTests/Query/CompatibilityQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/CompatibilityQueryNpgsqlTest.cs index ccf797ecd..19f73cf39 100644 --- a/test/EFCore.PG.FunctionalTests/Query/CompatibilityQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/CompatibilityQueryNpgsqlTest.cs @@ -95,15 +95,10 @@ public class CompatibilityTestEntity public int SomeInt { get; set; } } - public class CompatibilityContext : DbContext + public class CompatibilityContext(DbContextOptions options) : DbContext(options) { public DbSet TestEntities { get; set; } - public CompatibilityContext(DbContextOptions options) - : base(options) - { - } - public static void Seed(CompatibilityContext context) { context.TestEntities.AddRange( diff --git a/test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs index b68ebbb89..5676f51a1 100644 --- a/test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs @@ -217,16 +217,11 @@ protected EnumContext CreateContext() private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - public class EnumContext : PoolableDbContext + public class EnumContext(DbContextOptions options) : PoolableDbContext(options) { // ReSharper disable once UnusedAutoPropertyAccessor.Global public DbSet SomeEntities { get; set; } - public EnumContext(DbContextOptions options) - : base(options) - { - } - protected override void OnModelCreating(ModelBuilder builder) => builder .HasPostgresEnum("mapped_enum", new[] { "happy", "sad" }) diff --git a/test/EFCore.PG.FunctionalTests/Query/FieldsOnlyLoadNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/FieldsOnlyLoadNpgsqlTest.cs index 76b581831..9e75660b0 100644 --- a/test/EFCore.PG.FunctionalTests/Query/FieldsOnlyLoadNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/FieldsOnlyLoadNpgsqlTest.cs @@ -2,13 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; -public class FieldsOnlyLoadNpgsqlTest : FieldsOnlyLoadTestBase +public class FieldsOnlyLoadNpgsqlTest(FieldsOnlyLoadNpgsqlTest.FieldsOnlyLoadNpgsqlFixture fixture) + : FieldsOnlyLoadTestBase(fixture) { - public FieldsOnlyLoadNpgsqlTest(FieldsOnlyLoadNpgsqlFixture fixture) - : base(fixture) - { - } - public class FieldsOnlyLoadNpgsqlFixture : FieldsOnlyLoadFixtureBase { protected override ITestStoreFactory TestStoreFactory diff --git a/test/EFCore.PG.FunctionalTests/Query/FromSqlQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/FromSqlQueryNpgsqlTest.cs index c94935591..06fd4c016 100644 --- a/test/EFCore.PG.FunctionalTests/Query/FromSqlQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/FromSqlQueryNpgsqlTest.cs @@ -3,13 +3,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; -public class FromSqlQueryNpgsqlTest : FromSqlQueryTestBase> +public class FromSqlQueryNpgsqlTest(NorthwindQueryNpgsqlFixture fixture) + : FromSqlQueryTestBase>(fixture) { - public FromSqlQueryNpgsqlTest(NorthwindQueryNpgsqlFixture fixture) - : base(fixture) - { - } - [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFramework/issues/{6563,20364}")] public override Task Bad_data_error_handling_invalid_cast(bool async) => base.Bad_data_error_handling_invalid_cast(async); diff --git a/test/EFCore.PG.FunctionalTests/Query/InheritanceRelationshipsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/InheritanceRelationshipsQueryNpgsqlTest.cs index 2df5c0cb7..6fbb0e034 100644 --- a/test/EFCore.PG.FunctionalTests/Query/InheritanceRelationshipsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/InheritanceRelationshipsQueryNpgsqlTest.cs @@ -1,11 +1,7 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; -public class InheritanceRelationshipsQueryNpgsqlTest : InheritanceRelationshipsQueryTestBase +public class InheritanceRelationshipsQueryNpgsqlTest(InheritanceRelationshipsQueryNpgsqlFixture fixture) + : InheritanceRelationshipsQueryTestBase(fixture) { - public InheritanceRelationshipsQueryNpgsqlTest(InheritanceRelationshipsQueryNpgsqlFixture fixture) - : base(fixture) - { - } - protected override void ClearLog() { } } diff --git a/test/EFCore.PG.FunctionalTests/Query/JsonDomQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/JsonDomQueryTest.cs index a0f3e9980..b8bc094a2 100644 --- a/test/EFCore.PG.FunctionalTests/Query/JsonDomQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/JsonDomQueryTest.cs @@ -593,16 +593,11 @@ protected JsonDomQueryContext CreateContext() private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - public class JsonDomQueryContext : PoolableDbContext + public class JsonDomQueryContext(DbContextOptions options) : PoolableDbContext(options) { public DbSet JsonbEntities { get; set; } public DbSet JsonEntities { get; set; } - public JsonDomQueryContext(DbContextOptions options) - : base(options) - { - } - public static void Seed(JsonDomQueryContext context) { var (customer1, customer2, customer3) = (CreateCustomer1(), CreateCustomer2(), CreateCustomer3()); diff --git a/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs index f804c6040..3bb952e3e 100644 --- a/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs @@ -704,16 +704,11 @@ protected JsonPocoQueryContext CreateContext() private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - public class JsonPocoQueryContext : PoolableDbContext + public class JsonPocoQueryContext(DbContextOptions options) : PoolableDbContext(options) { public DbSet JsonbEntities { get; set; } public DbSet JsonEntities { get; set; } - public JsonPocoQueryContext(DbContextOptions options) - : base(options) - { - } - public static void Seed(JsonPocoQueryContext context) { context.JsonbEntities.AddRange( diff --git a/test/EFCore.PG.FunctionalTests/Query/JsonQueryAdHocNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/JsonQueryAdHocNpgsqlTest.cs index 5a9004d92..c44c70060 100644 --- a/test/EFCore.PG.FunctionalTests/Query/JsonQueryAdHocNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/JsonQueryAdHocNpgsqlTest.cs @@ -81,13 +81,8 @@ LIMIT 2 } } - protected class TypesDbContext : DbContext + protected class TypesDbContext(DbContextOptions options) : DbContext(options) { - public TypesDbContext(DbContextOptions options) - : base(options) - { - } - public DbSet Entities { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) @@ -387,13 +382,9 @@ private void SeedEnumLegacyValues(MyContextEnumLegacyValues ctx) 'e1') """); - private class MyContextEnumLegacyValues : DbContext + private class MyContextEnumLegacyValues(DbContextOptions options) : DbContext( + (new DbContextOptionsBuilder(options)).ConfigureWarnings(b => b.Log(CoreEventId.StringEnumValueInJson)).Options) { - public MyContextEnumLegacyValues(DbContextOptions options) - : base((new DbContextOptionsBuilder(options)).ConfigureWarnings(b => b.Log(CoreEventId.StringEnumValueInJson)).Options) - { - } - // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Entities { get; set; } diff --git a/test/EFCore.PG.FunctionalTests/Query/JsonStringQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/JsonStringQueryTest.cs index 5f3d7bc0e..403b2be92 100644 --- a/test/EFCore.PG.FunctionalTests/Query/JsonStringQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/JsonStringQueryTest.cs @@ -247,15 +247,10 @@ protected JsonStringQueryContext CreateContext() private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - public class JsonStringQueryContext : PoolableDbContext + public class JsonStringQueryContext(DbContextOptions options) : PoolableDbContext(options) { public DbSet JsonEntities { get; set; } - public JsonStringQueryContext(DbContextOptions options) - : base(options) - { - } - public static void Seed(JsonStringQueryContext context) { const string customer1 = @" diff --git a/test/EFCore.PG.FunctionalTests/Query/LTreeQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/LTreeQueryTest.cs index 1e0777b51..67a8ecc95 100644 --- a/test/EFCore.PG.FunctionalTests/Query/LTreeQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/LTreeQueryTest.cs @@ -502,15 +502,10 @@ protected LTreeQueryContext CreateContext() private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - public class LTreeQueryContext : PoolableDbContext + public class LTreeQueryContext(DbContextOptions options) : PoolableDbContext(options) { public DbSet LTreeEntities { get; set; } - public LTreeQueryContext(DbContextOptions options) - : base(options) - { - } - public static void Seed(LTreeQueryContext context) { var ltreeEntities = new LTreeEntity[] diff --git a/test/EFCore.PG.FunctionalTests/Query/LegacyTimestampQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/LegacyTimestampQueryTest.cs index cb13429ec..02ec1ffab 100644 --- a/test/EFCore.PG.FunctionalTests/Query/LegacyTimestampQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/LegacyTimestampQueryTest.cs @@ -79,14 +79,9 @@ private TimestampQueryContext CreateContext() private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - public class TimestampQueryContext : PoolableDbContext + public class TimestampQueryContext(DbContextOptions options) : PoolableDbContext(options) { public DbSet Entities { get; set; } - - public TimestampQueryContext(DbContextOptions options) - : base(options) - { - } } public class Entity @@ -149,9 +144,7 @@ protected override void Seed(TimestampQueryContext context) } [CollectionDefinition("LegacyTimestampQueryTest", DisableParallelization = true)] - public class EventSourceTestCollection - { - } + public class EventSourceTestCollection; } #endif diff --git a/test/EFCore.PG.FunctionalTests/Query/MultirangeQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/MultirangeQueryNpgsqlTest.cs index 0c6ad1b1c..f88be7e10 100644 --- a/test/EFCore.PG.FunctionalTests/Query/MultirangeQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/MultirangeQueryNpgsqlTest.cs @@ -749,15 +749,10 @@ public class MultirangeTestEntity private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - public class MultirangeContext : PoolableDbContext + public class MultirangeContext(DbContextOptions options) : PoolableDbContext(options) { public DbSet TestEntities { get; set; } - public MultirangeContext(DbContextOptions options) - : base(options) - { - } - public static void Seed(MultirangeContext context) { context.TestEntities.AddRange( diff --git a/test/EFCore.PG.FunctionalTests/Query/NavigationTest.cs b/test/EFCore.PG.FunctionalTests/Query/NavigationTest.cs index d5f412c76..bb9e565e5 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NavigationTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NavigationTest.cs @@ -2,12 +2,12 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; -public class NavigationTest : IClassFixture +public class NavigationTest(NavigationTestFixture fixture) : IClassFixture { [Fact] public void Duplicate_entries_are_not_created_for_navigations_to_principal() { - using var context = _fixture.CreateContext(); + using var context = fixture.CreateContext(); context.ConfigAction = modelBuilder => { @@ -31,7 +31,7 @@ public void Duplicate_entries_are_not_created_for_navigations_to_principal() [Fact] public void Duplicate_entries_are_not_created_for_navigations_to_dependant() { - using var context = _fixture.CreateContext(); + using var context = fixture.CreateContext(); context.ConfigAction = modelBuilder => { @@ -51,13 +51,6 @@ public void Duplicate_entries_are_not_created_for_navigations_to_dependant() "ForeignKey: GoTPerson {'SiblingReverseId'} -> GoTPerson {'Id'} ClientSetNull ToDependent: Siblings ToPrincipal: SiblingReverse", entityType.GetForeignKeys().Skip(1).First().ToString()); } - - private readonly NavigationTestFixture _fixture; - - public NavigationTest(NavigationTestFixture fixture) - { - _fixture = fixture; - } } public class GoTPerson @@ -71,13 +64,8 @@ public class GoTPerson public GoTPerson SiblingReverse { get; set; } } -public class GoTContext : DbContext +public class GoTContext(DbContextOptions options) : DbContext(options) { - public GoTContext(DbContextOptions options) - : base(options) - { - } - public DbSet People { get; set; } public Func ConfigAction { get; set; } diff --git a/test/EFCore.PG.FunctionalTests/Query/NullKeysNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NullKeysNpgsqlTest.cs index 8c465a89b..5a7e3dadf 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NullKeysNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NullKeysNpgsqlTest.cs @@ -2,13 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; -public class NullKeysNpgsqlTest : NullKeysTestBase +public class NullKeysNpgsqlTest(NullKeysNpgsqlTest.NullKeysNpgsqlFixture fixture) + : NullKeysTestBase(fixture) { - public NullKeysNpgsqlTest(NullKeysNpgsqlFixture fixture) - : base(fixture) - { - } - public class NullKeysNpgsqlFixture : NullKeysFixtureBase { protected override string StoreName { get; } = "StringsContext"; diff --git a/test/EFCore.PG.FunctionalTests/Query/OwnedQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/OwnedQueryNpgsqlTest.cs index e5a0429a7..fd15a3621 100644 --- a/test/EFCore.PG.FunctionalTests/Query/OwnedQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/OwnedQueryNpgsqlTest.cs @@ -2,13 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; -public class OwnedQueryNpgsqlTest : OwnedQueryRelationalTestBase +public class OwnedQueryNpgsqlTest(OwnedQueryNpgsqlTest.OwnedQueryNpgsqlFixture fixture) + : OwnedQueryRelationalTestBase(fixture) { - public OwnedQueryNpgsqlTest(OwnedQueryNpgsqlFixture fixture) - : base(fixture) - { - } - public class OwnedQueryNpgsqlFixture : RelationalOwnedQueryFixture { protected override ITestStoreFactory TestStoreFactory diff --git a/test/EFCore.PG.FunctionalTests/Query/QueryBugTest.cs b/test/EFCore.PG.FunctionalTests/Query/QueryBugTest.cs index 861b233b8..8b626b5c9 100644 --- a/test/EFCore.PG.FunctionalTests/Query/QueryBugTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/QueryBugTest.cs @@ -41,13 +41,8 @@ public class Bug920Entity public Bug920Enum Enum { get; set; } } - private class Bug920Context : DbContext + private class Bug920Context(DbContextOptions options) : DbContext(options) { - public Bug920Context(DbContextOptions options) - : base(options) - { - } - public DbSet Entities { get; set; } } diff --git a/test/EFCore.PG.FunctionalTests/Query/QueryNoClientEvalNpgsqlFixture.cs b/test/EFCore.PG.FunctionalTests/Query/QueryNoClientEvalNpgsqlFixture.cs index ddfec4bfe..1e31adfbd 100644 --- a/test/EFCore.PG.FunctionalTests/Query/QueryNoClientEvalNpgsqlFixture.cs +++ b/test/EFCore.PG.FunctionalTests/Query/QueryNoClientEvalNpgsqlFixture.cs @@ -1,5 +1,3 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; -public class QueryNoClientEvalNpgsqlFixture : NorthwindQueryNpgsqlFixture -{ -} +public class QueryNoClientEvalNpgsqlFixture : NorthwindQueryNpgsqlFixture; diff --git a/test/EFCore.PG.FunctionalTests/Query/QueryNoClientEvalNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/QueryNoClientEvalNpgsqlTest.cs index 15816405a..d33862cdc 100644 --- a/test/EFCore.PG.FunctionalTests/Query/QueryNoClientEvalNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/QueryNoClientEvalNpgsqlTest.cs @@ -1,9 +1,4 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; -public class QueryNoClientEvalNpgsqlTest : QueryNoClientEvalTestBase -{ - public QueryNoClientEvalNpgsqlTest(QueryNoClientEvalNpgsqlFixture fixture) - : base(fixture) - { - } -} +public class QueryNoClientEvalNpgsqlTest(QueryNoClientEvalNpgsqlFixture fixture) + : QueryNoClientEvalTestBase(fixture); diff --git a/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs index 3e7000cf9..880ade010 100644 --- a/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs @@ -654,15 +654,10 @@ public class RangeTestEntity public NpgsqlRange UserDefinedRangeWithSchema { get; set; } } - public class RangeContext : PoolableDbContext + public class RangeContext(DbContextOptions options) : PoolableDbContext(options) { public DbSet RangeTestEntities { get; set; } - public RangeContext(DbContextOptions options) - : base(options) - { - } - protected override void OnModelCreating(ModelBuilder builder) => builder.HasPostgresRange("doublerange", "double precision") .HasPostgresRange("test", "Schema_Range", "real"); diff --git a/test/EFCore.PG.FunctionalTests/Query/SqlExecutorNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/SqlExecutorNpgsqlTest.cs index 7bd5ec4d1..fac71b515 100644 --- a/test/EFCore.PG.FunctionalTests/Query/SqlExecutorNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/SqlExecutorNpgsqlTest.cs @@ -2,13 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; -public class SqlExecutorNpgsqlTest : SqlExecutorTestBase> +public class SqlExecutorNpgsqlTest(NorthwindQueryNpgsqlFixture fixture) + : SqlExecutorTestBase>(fixture) { - public SqlExecutorNpgsqlTest(NorthwindQueryNpgsqlFixture fixture) - : base(fixture) - { - } - protected override DbParameter CreateDbParameter(string name, object value) => new NpgsqlParameter { ParameterName = name, Value = value }; diff --git a/test/EFCore.PG.FunctionalTests/Query/TPCFiltersInheritanceQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/TPCFiltersInheritanceQueryNpgsqlTest.cs index bb7821813..ac1e24fcb 100644 --- a/test/EFCore.PG.FunctionalTests/Query/TPCFiltersInheritanceQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/TPCFiltersInheritanceQueryNpgsqlTest.cs @@ -1,9 +1,4 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; -public class TPCFiltersInheritanceQueryNpgsqlTest : TPCFiltersInheritanceQueryTestBase -{ - public TPCFiltersInheritanceQueryNpgsqlTest(TPCFiltersInheritanceQueryNpgsqlFixture fixture) - : base(fixture) - { - } -} +public class TPCFiltersInheritanceQueryNpgsqlTest(TPCFiltersInheritanceQueryNpgsqlFixture fixture) + : TPCFiltersInheritanceQueryTestBase(fixture); diff --git a/test/EFCore.PG.FunctionalTests/Query/TPCInheritanceQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/TPCInheritanceQueryNpgsqlTest.cs index 3ce9b2085..6804a75a8 100644 --- a/test/EFCore.PG.FunctionalTests/Query/TPCInheritanceQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/TPCInheritanceQueryNpgsqlTest.cs @@ -1,12 +1,8 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; -public class TPCInheritanceQueryNpgsqlTest : TPCInheritanceQueryTestBase +public class TPCInheritanceQueryNpgsqlTest(TPCInheritanceQueryNpgsqlFixture fixture, ITestOutputHelper testOutputHelper) + : TPCInheritanceQueryTestBase(fixture, testOutputHelper) { - public TPCInheritanceQueryNpgsqlTest(TPCInheritanceQueryNpgsqlFixture fixture, ITestOutputHelper testOutputHelper) - : base(fixture, testOutputHelper) - { - } - protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); } diff --git a/test/EFCore.PG.FunctionalTests/Query/TPHInheritanceQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/TPHInheritanceQueryNpgsqlTest.cs index 066e3e549..1eb085607 100644 --- a/test/EFCore.PG.FunctionalTests/Query/TPHInheritanceQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/TPHInheritanceQueryNpgsqlTest.cs @@ -1,9 +1,4 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; -public class TPHInheritanceQueryNpgsqlTest : TPHInheritanceQueryTestBase -{ - public TPHInheritanceQueryNpgsqlTest(TPHInheritanceQueryNpgsqlFixture fixture, ITestOutputHelper testOutputHelper) - : base(fixture, testOutputHelper) - { - } -} +public class TPHInheritanceQueryNpgsqlTest(TPHInheritanceQueryNpgsqlFixture fixture, ITestOutputHelper testOutputHelper) + : TPHInheritanceQueryTestBase(fixture, testOutputHelper); diff --git a/test/EFCore.PG.FunctionalTests/Query/TPTInheritanceQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/TPTInheritanceQueryNpgsqlTest.cs index 5359e75f7..8ddc46103 100644 --- a/test/EFCore.PG.FunctionalTests/Query/TPTInheritanceQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/TPTInheritanceQueryNpgsqlTest.cs @@ -1,10 +1,4 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; -public class TPTInheritanceQueryNpgsqlTest : TPTInheritanceQueryTestBase -{ - // ReSharper disable once UnusedParameter.Local - public TPTInheritanceQueryNpgsqlTest(TPTInheritanceQueryNpgsqlFixture fixture, ITestOutputHelper testOutputHelper) - : base(fixture, testOutputHelper) - { - } -} +public class TPTInheritanceQueryNpgsqlTest(TPTInheritanceQueryNpgsqlFixture fixture, ITestOutputHelper testOutputHelper) + : TPTInheritanceQueryTestBase(fixture, testOutputHelper); diff --git a/test/EFCore.PG.FunctionalTests/Query/TimestampQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/TimestampQueryTest.cs index 28ab41a48..b30d4e609 100644 --- a/test/EFCore.PG.FunctionalTests/Query/TimestampQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/TimestampQueryTest.cs @@ -825,15 +825,10 @@ private TimestampQueryContext CreateContext() private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - public class TimestampQueryContext : PoolableDbContext + public class TimestampQueryContext(DbContextOptions options) : PoolableDbContext(options) { public DbSet Entities { get; set; } - public TimestampQueryContext(DbContextOptions options) - : base(options) - { - } - public static void Seed(TimestampQueryContext context) { context.Entities.AddRange(TimestampData.CreateEntities()); @@ -926,12 +921,7 @@ public IReadOnlyDictionary EntityAsserters protected class TimestampData : ISetSource { - public IReadOnlyList Entities { get; } - - public TimestampData() - { - Entities = CreateEntities(); - } + public IReadOnlyList Entities { get; } = CreateEntities(); public IQueryable Set() where TEntity : class diff --git a/test/EFCore.PG.FunctionalTests/Query/UdfDbFunctionNpgsqlTests.cs b/test/EFCore.PG.FunctionalTests/Query/UdfDbFunctionNpgsqlTests.cs index fc1144d10..ec24c062d 100644 --- a/test/EFCore.PG.FunctionalTests/Query/UdfDbFunctionNpgsqlTests.cs +++ b/test/EFCore.PG.FunctionalTests/Query/UdfDbFunctionNpgsqlTests.cs @@ -588,13 +588,8 @@ LIMIT 2 public override void Scalar_Function_with_nullable_value_return_type_throws() {} #endif - protected class NpgsqlUDFSqlContext : UDFSqlContext + protected class NpgsqlUDFSqlContext(DbContextOptions options) : UDFSqlContext(options) { - public NpgsqlUDFSqlContext(DbContextOptions options) - : base(options) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); diff --git a/test/EFCore.PG.FunctionalTests/Query/WarningsNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/WarningsNpgsqlTest.cs index 3211f7d17..2e10b22e0 100644 --- a/test/EFCore.PG.FunctionalTests/Query/WarningsNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/WarningsNpgsqlTest.cs @@ -1,9 +1,3 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query; -public class WarningsNpgsqlTest : WarningsTestBase -{ - public WarningsNpgsqlTest(QueryNoClientEvalNpgsqlFixture fixture) - : base(fixture) - { - } -} +public class WarningsNpgsqlTest(QueryNoClientEvalNpgsqlFixture fixture) : WarningsTestBase(fixture); diff --git a/test/EFCore.PG.FunctionalTests/QueryExpressionInterceptionNpgsqlTestBase.cs b/test/EFCore.PG.FunctionalTests/QueryExpressionInterceptionNpgsqlTestBase.cs index 320f4b63b..8ce7a886d 100644 --- a/test/EFCore.PG.FunctionalTests/QueryExpressionInterceptionNpgsqlTestBase.cs +++ b/test/EFCore.PG.FunctionalTests/QueryExpressionInterceptionNpgsqlTestBase.cs @@ -4,13 +4,10 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public abstract class QueryExpressionInterceptionNpgsqlTestBase : QueryExpressionInterceptionTestBase +public abstract class QueryExpressionInterceptionNpgsqlTestBase( + QueryExpressionInterceptionNpgsqlTestBase.InterceptionNpgsqlFixtureBase fixture) + : QueryExpressionInterceptionTestBase(fixture) { - protected QueryExpressionInterceptionNpgsqlTestBase(InterceptionNpgsqlFixtureBase fixture) - : base(fixture) - { - } - public abstract class InterceptionNpgsqlFixtureBase : InterceptionFixtureBase { protected override ITestStoreFactory TestStoreFactory @@ -29,14 +26,9 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build } } - public class QueryExpressionInterceptionNpgsqlTest - : QueryExpressionInterceptionNpgsqlTestBase, IClassFixture + public class QueryExpressionInterceptionNpgsqlTest(QueryExpressionInterceptionNpgsqlTest.InterceptionNpgsqlFixture fixture) + : QueryExpressionInterceptionNpgsqlTestBase(fixture), IClassFixture { - public QueryExpressionInterceptionNpgsqlTest(InterceptionNpgsqlFixture fixture) - : base(fixture) - { - } - public class InterceptionNpgsqlFixture : InterceptionNpgsqlFixtureBase { protected override string StoreName @@ -47,15 +39,11 @@ protected override bool ShouldSubscribeToDiagnosticListener } } - public class QueryExpressionInterceptionWithDiagnosticsNpgsqlTest - : QueryExpressionInterceptionNpgsqlTestBase, + public class QueryExpressionInterceptionWithDiagnosticsNpgsqlTest( + QueryExpressionInterceptionWithDiagnosticsNpgsqlTest.InterceptionNpgsqlFixture fixture) + : QueryExpressionInterceptionNpgsqlTestBase(fixture), IClassFixture { - public QueryExpressionInterceptionWithDiagnosticsNpgsqlTest(InterceptionNpgsqlFixture fixture) - : base(fixture) - { - } - public class InterceptionNpgsqlFixture : InterceptionNpgsqlFixtureBase { protected override string StoreName diff --git a/test/EFCore.PG.FunctionalTests/SaveChangesInterceptionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/SaveChangesInterceptionNpgsqlTest.cs index b0ff63af5..c62c896b9 100644 --- a/test/EFCore.PG.FunctionalTests/SaveChangesInterceptionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/SaveChangesInterceptionNpgsqlTest.cs @@ -4,13 +4,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public abstract class SaveChangesInterceptionNpgsqlTestBase : SaveChangesInterceptionTestBase +public abstract class SaveChangesInterceptionNpgsqlTestBase(SaveChangesInterceptionNpgsqlTestBase.InterceptionNpgsqlFixtureBase fixture) + : SaveChangesInterceptionTestBase(fixture) { - protected SaveChangesInterceptionNpgsqlTestBase(InterceptionNpgsqlFixtureBase fixture) - : base(fixture) - { - } - public abstract class InterceptionNpgsqlFixtureBase : InterceptionFixtureBase { protected override ITestStoreFactory TestStoreFactory @@ -29,14 +25,9 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build } } - public class SaveChangesInterceptionNpgsqlTest - : SaveChangesInterceptionNpgsqlTestBase, IClassFixture + public class SaveChangesInterceptionNpgsqlTest(SaveChangesInterceptionNpgsqlTest.InterceptionNpgsqlFixture fixture) + : SaveChangesInterceptionNpgsqlTestBase(fixture), IClassFixture { - public SaveChangesInterceptionNpgsqlTest(InterceptionNpgsqlFixture fixture) - : base(fixture) - { - } - public class InterceptionNpgsqlFixture : InterceptionNpgsqlFixtureBase { protected override string StoreName @@ -54,15 +45,11 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build } } - public class SaveChangesInterceptionWithDiagnosticsNpgsqlTest - : SaveChangesInterceptionNpgsqlTestBase, + public class SaveChangesInterceptionWithDiagnosticsNpgsqlTest( + SaveChangesInterceptionWithDiagnosticsNpgsqlTest.InterceptionNpgsqlFixture fixture) + : SaveChangesInterceptionNpgsqlTestBase(fixture), IClassFixture { - public SaveChangesInterceptionWithDiagnosticsNpgsqlTest(InterceptionNpgsqlFixture fixture) - : base(fixture) - { - } - public class InterceptionNpgsqlFixture : InterceptionNpgsqlFixtureBase { protected override string StoreName diff --git a/test/EFCore.PG.FunctionalTests/SeedingNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/SeedingNpgsqlTest.cs index 8844da5a8..90df831ea 100644 --- a/test/EFCore.PG.FunctionalTests/SeedingNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/SeedingNpgsqlTest.cs @@ -10,13 +10,8 @@ protected override TestStore TestStore protected override SeedingContext CreateContextWithEmptyDatabase(string testId) => new SeedingNpgsqlContext(testId); - protected class SeedingNpgsqlContext : SeedingContext + protected class SeedingNpgsqlContext(string testId) : SeedingContext(testId) { - public SeedingNpgsqlContext(string testId) - : base(testId) - { - } - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseNpgsql(NpgsqlTestStore.CreateConnectionString($"Seeds{TestId}")); } diff --git a/test/EFCore.PG.FunctionalTests/SequenceEndToEndTest.cs b/test/EFCore.PG.FunctionalTests/SequenceEndToEndTest.cs index 51d9e76a3..9b4d29b8a 100644 --- a/test/EFCore.PG.FunctionalTests/SequenceEndToEndTest.cs +++ b/test/EFCore.PG.FunctionalTests/SequenceEndToEndTest.cs @@ -263,23 +263,14 @@ private static void AddEntitiesWithIds(IServiceProvider serviceProvider, int idO context.SaveChanges(); } - private class BronieContext : DbContext + private class BronieContext(IServiceProvider serviceProvider, string databaseName) : DbContext { - private readonly IServiceProvider _serviceProvider; - private readonly string _databaseName; - - public BronieContext(IServiceProvider serviceProvider, string databaseName) - { - _serviceProvider = serviceProvider; - _databaseName = databaseName; - } - public DbSet Pegasuses { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseInternalServiceProvider(_serviceProvider) - .UseNpgsql(NpgsqlTestStore.CreateConnectionString(_databaseName), b => b.ApplyConfiguration()); + .UseInternalServiceProvider(serviceProvider) + .UseNpgsql(NpgsqlTestStore.CreateConnectionString(databaseName), b => b.ApplyConfiguration()); protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.Entity( @@ -366,32 +357,22 @@ private static void AddEntitiesNullable(IServiceProvider serviceProvider, string context.SaveChanges(); } - private class NullableBronieContext : DbContext + private class NullableBronieContext(IServiceProvider serviceProvider, string databaseName, bool useSequence) + : DbContext { - private readonly IServiceProvider _serviceProvider; - private readonly string _databaseName; - private readonly bool _useSequence; - - public NullableBronieContext(IServiceProvider serviceProvider, string databaseName, bool useSequence) - { - _serviceProvider = serviceProvider; - _databaseName = databaseName; - _useSequence = useSequence; - } - public DbSet Unicons { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder - .UseInternalServiceProvider(_serviceProvider) - .UseNpgsql(NpgsqlTestStore.CreateConnectionString(_databaseName), b => b.ApplyConfiguration()); + .UseInternalServiceProvider(serviceProvider) + .UseNpgsql(NpgsqlTestStore.CreateConnectionString(databaseName), b => b.ApplyConfiguration()); protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.Entity( b => { b.HasKey(e => e.Identifier); - if (_useSequence) + if (useSequence) { b.Property(e => e.Identifier).UseHiLo(); } @@ -408,12 +389,7 @@ private class Unicon public string Name { get; set; } } - public SequenceEndToEndTest() - { - TestStore = NpgsqlTestStore.CreateInitialized("SequenceEndToEndTest"); - } - - protected NpgsqlTestStore TestStore { get; } + protected NpgsqlTestStore TestStore { get; } = NpgsqlTestStore.CreateInitialized("SequenceEndToEndTest"); public void Dispose() => TestStore.Dispose(); diff --git a/test/EFCore.PG.FunctionalTests/SerializationNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/SerializationNpgsqlTest.cs index 8fb43e9e4..c0f16c72e 100644 --- a/test/EFCore.PG.FunctionalTests/SerializationNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/SerializationNpgsqlTest.cs @@ -1,9 +1,3 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class SerializationNpgsqlTest : SerializationTestBase -{ - public SerializationNpgsqlTest(F1BytesNpgsqlFixture fixture) - : base(fixture) - { - } -} +public class SerializationNpgsqlTest(F1BytesNpgsqlFixture fixture) : SerializationTestBase(fixture); diff --git a/test/EFCore.PG.FunctionalTests/SpatialNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/SpatialNpgsqlTest.cs index 17772cfb0..8f610757f 100644 --- a/test/EFCore.PG.FunctionalTests/SpatialNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/SpatialNpgsqlTest.cs @@ -3,13 +3,8 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; [RequiresPostgis] -public class SpatialNpgsqlTest : SpatialTestBase +public class SpatialNpgsqlTest(SpatialNpgsqlFixture fixture) : SpatialTestBase(fixture) { - public SpatialNpgsqlTest(SpatialNpgsqlFixture fixture) - : base(fixture) - { - } - protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); } diff --git a/test/EFCore.PG.FunctionalTests/StoreGeneratedFixupNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/StoreGeneratedFixupNpgsqlTest.cs index 1b967b6e2..1133cb7f3 100644 --- a/test/EFCore.PG.FunctionalTests/StoreGeneratedFixupNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/StoreGeneratedFixupNpgsqlTest.cs @@ -2,14 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class StoreGeneratedFixupNpgsqlTest : StoreGeneratedFixupRelationalTestBase< - StoreGeneratedFixupNpgsqlTest.StoreGeneratedFixupNpgsqlFixture> +public class StoreGeneratedFixupNpgsqlTest(StoreGeneratedFixupNpgsqlTest.StoreGeneratedFixupNpgsqlFixture fixture) + : StoreGeneratedFixupRelationalTestBase(fixture) { - public StoreGeneratedFixupNpgsqlTest(StoreGeneratedFixupNpgsqlFixture fixture) - : base(fixture) - { - } - [Fact] public void Temp_values_are_replaced_on_save() => ExecuteWithStrategyInTransaction( diff --git a/test/EFCore.PG.FunctionalTests/StoreGeneratedNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/StoreGeneratedNpgsqlTest.cs index 4765fe20e..bef3d8b23 100644 --- a/test/EFCore.PG.FunctionalTests/StoreGeneratedNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/StoreGeneratedNpgsqlTest.cs @@ -2,14 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class StoreGeneratedNpgsqlTest - : StoreGeneratedTestBase +public class StoreGeneratedNpgsqlTest(StoreGeneratedNpgsqlTest.StoreGeneratedNpgsqlFixture fixture) + : StoreGeneratedTestBase(fixture) { - public StoreGeneratedNpgsqlTest(StoreGeneratedNpgsqlFixture fixture) - : base(fixture) - { - } - protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.PG.FunctionalTests/SystemColumnTest.cs b/test/EFCore.PG.FunctionalTests/SystemColumnTest.cs index 44f5c3500..cd7150436 100644 --- a/test/EFCore.PG.FunctionalTests/SystemColumnTest.cs +++ b/test/EFCore.PG.FunctionalTests/SystemColumnTest.cs @@ -30,13 +30,8 @@ public void Xmin() Assert.NotEqual(firstVersion, secondVersion); } - public class SystemColumnContext : PoolableDbContext + public class SystemColumnContext(DbContextOptions options) : PoolableDbContext(options) { - public SystemColumnContext(DbContextOptions options) - : base(options) - { - } - // ReSharper disable once UnusedAutoPropertyAccessor.Local public DbSet Entities { get; set; } diff --git a/test/EFCore.PG.FunctionalTests/TPTTableSplittingNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/TPTTableSplittingNpgsqlTest.cs index 941ce5c47..c89e21ae6 100644 --- a/test/EFCore.PG.FunctionalTests/TPTTableSplittingNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/TPTTableSplittingNpgsqlTest.cs @@ -2,13 +2,8 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class TPTTableSplittingNpgsqlTest : TPTTableSplittingTestBase +public class TPTTableSplittingNpgsqlTest(ITestOutputHelper testOutputHelper) : TPTTableSplittingTestBase(testOutputHelper) { - public TPTTableSplittingNpgsqlTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) - { - } - public override Task Can_insert_dependent_with_just_one_parent() // This scenario is not valid for TPT => Task.CompletedTask; diff --git a/test/EFCore.PG.FunctionalTests/TableSplittingNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/TableSplittingNpgsqlTest.cs index 74c511879..d47776766 100644 --- a/test/EFCore.PG.FunctionalTests/TableSplittingNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/TableSplittingNpgsqlTest.cs @@ -4,13 +4,8 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; [MinimumPostgresVersion(12, 0)] // Test suite uses computed columns -public class TableSplittingNpgsqlTest : TableSplittingTestBase +public class TableSplittingNpgsqlTest(ITestOutputHelper testOutputHelper) : TableSplittingTestBase(testOutputHelper) { - public TableSplittingNpgsqlTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) - { - } - protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; diff --git a/test/EFCore.PG.FunctionalTests/TestModels/Array/ArrayQueryContext.cs b/test/EFCore.PG.FunctionalTests/TestModels/Array/ArrayQueryContext.cs index 5b8cb32b0..ea7ef0197 100644 --- a/test/EFCore.PG.FunctionalTests/TestModels/Array/ArrayQueryContext.cs +++ b/test/EFCore.PG.FunctionalTests/TestModels/Array/ArrayQueryContext.cs @@ -1,15 +1,10 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.TestModels.Array; -public class ArrayQueryContext : PoolableDbContext +public class ArrayQueryContext(DbContextOptions options) : PoolableDbContext(options) { public DbSet SomeEntities { get; set; } public DbSet SomeEntityContainers { get; set; } - public ArrayQueryContext(DbContextOptions options) - : base(options) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) => modelBuilder.Entity( e => diff --git a/test/EFCore.PG.FunctionalTests/TestModels/Array/ArrayQueryData.cs b/test/EFCore.PG.FunctionalTests/TestModels/Array/ArrayQueryData.cs index 7b056188e..55dd61c1c 100644 --- a/test/EFCore.PG.FunctionalTests/TestModels/Array/ArrayQueryData.cs +++ b/test/EFCore.PG.FunctionalTests/TestModels/Array/ArrayQueryData.cs @@ -2,13 +2,8 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.TestModels.Array; public class ArrayQueryData : ISetSource { - public IReadOnlyList ArrayEntities { get; } - public IReadOnlyList ContainerEntities { get; } - - public ArrayQueryData() - { - (ArrayEntities, ContainerEntities) = (CreateArrayEntities(), CreateContainerEntities()); - } + public IReadOnlyList ArrayEntities { get; } = CreateArrayEntities(); + public IReadOnlyList ContainerEntities { get; } = CreateContainerEntities(); public IQueryable Set() where TEntity : class diff --git a/test/EFCore.PG.FunctionalTests/TestModels/Northwind/NorthwindNpgsqlContext.cs b/test/EFCore.PG.FunctionalTests/TestModels/Northwind/NorthwindNpgsqlContext.cs index b0a47a54f..fd80fe107 100644 --- a/test/EFCore.PG.FunctionalTests/TestModels/Northwind/NorthwindNpgsqlContext.cs +++ b/test/EFCore.PG.FunctionalTests/TestModels/Northwind/NorthwindNpgsqlContext.cs @@ -2,13 +2,8 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.TestModels.Northwind; -public class NorthwindNpgsqlContext : NorthwindRelationalContext +public class NorthwindNpgsqlContext(DbContextOptions options) : NorthwindRelationalContext(options) { - public NorthwindNpgsqlContext(DbContextOptions options) - : base(options) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); diff --git a/test/EFCore.PG.FunctionalTests/TestUtilities/MinimumPostgresVersionAttribute.cs b/test/EFCore.PG.FunctionalTests/TestUtilities/MinimumPostgresVersionAttribute.cs index e7d1f56f7..86e224e7d 100644 --- a/test/EFCore.PG.FunctionalTests/TestUtilities/MinimumPostgresVersionAttribute.cs +++ b/test/EFCore.PG.FunctionalTests/TestUtilities/MinimumPostgresVersionAttribute.cs @@ -1,14 +1,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities; [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)] -public sealed class MinimumPostgresVersionAttribute : Attribute, ITestCondition +public sealed class MinimumPostgresVersionAttribute(int major, int minor) : Attribute, ITestCondition { - private readonly Version _version; - - public MinimumPostgresVersionAttribute(int major, int minor) - { - _version = new Version(major, minor); - } + private readonly Version _version = new(major, minor); public ValueTask IsMetAsync() => new(TestEnvironment.PostgresVersion >= _version); diff --git a/test/EFCore.PG.FunctionalTests/TestUtilities/NpgsqlDatabaseCleaner.cs b/test/EFCore.PG.FunctionalTests/TestUtilities/NpgsqlDatabaseCleaner.cs index f4f5c2071..d75de6be2 100644 --- a/test/EFCore.PG.FunctionalTests/TestUtilities/NpgsqlDatabaseCleaner.cs +++ b/test/EFCore.PG.FunctionalTests/TestUtilities/NpgsqlDatabaseCleaner.cs @@ -9,12 +9,7 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities; public class NpgsqlDatabaseCleaner : RelationalDatabaseCleaner { - private readonly NpgsqlSqlGenerationHelper _sqlGenerationHelper; - - public NpgsqlDatabaseCleaner() - { - _sqlGenerationHelper = new NpgsqlSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()); - } + private readonly NpgsqlSqlGenerationHelper _sqlGenerationHelper = new(new RelationalSqlGenerationHelperDependencies()); protected override IDatabaseModelFactory CreateDatabaseModelFactory(ILoggerFactory loggerFactory) => new NpgsqlDatabaseModelFactory( diff --git a/test/EFCore.PG.FunctionalTests/TestUtilities/TestNpgsqlConnection.cs b/test/EFCore.PG.FunctionalTests/TestUtilities/TestNpgsqlConnection.cs index 5a2a46057..15ef578c7 100644 --- a/test/EFCore.PG.FunctionalTests/TestUtilities/TestNpgsqlConnection.cs +++ b/test/EFCore.PG.FunctionalTests/TestUtilities/TestNpgsqlConnection.cs @@ -4,13 +4,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities; -public class TestNpgsqlConnection : NpgsqlRelationalConnection +public class TestNpgsqlConnection(RelationalConnectionDependencies dependencies, DbDataSource dataSource = null) + : NpgsqlRelationalConnection(dependencies, dataSource) { - public TestNpgsqlConnection(RelationalConnectionDependencies dependencies, DbDataSource dataSource = null) - : base(dependencies, dataSource) - { - } - public string ErrorCode { get; set; } = "XX000"; public Queue OpenFailures { get; } = new(); public int OpenCount { get; set; } diff --git a/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs b/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs index 1746cd7dd..35e7dd1a4 100644 --- a/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs +++ b/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs @@ -2,32 +2,20 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities; -public class TestRelationalCommandBuilderFactory : IRelationalCommandBuilderFactory +public class TestRelationalCommandBuilderFactory(RelationalCommandBuilderDependencies dependencies) : IRelationalCommandBuilderFactory { - public TestRelationalCommandBuilderFactory( - RelationalCommandBuilderDependencies dependencies) - { - Dependencies = dependencies; - } - - public RelationalCommandBuilderDependencies Dependencies { get; } + public RelationalCommandBuilderDependencies Dependencies { get; } = dependencies; public virtual IRelationalCommandBuilder Create() => new TestRelationalCommandBuilder(Dependencies); - private class TestRelationalCommandBuilder : IRelationalCommandBuilder + private class TestRelationalCommandBuilder(RelationalCommandBuilderDependencies dependencies) : IRelationalCommandBuilder { private readonly List _parameters = new(); - public TestRelationalCommandBuilder( - RelationalCommandBuilderDependencies dependencies) - { - Dependencies = dependencies; - } - public IndentedStringBuilder Instance { get; } = new(); - public RelationalCommandBuilderDependencies Dependencies { get; } + public RelationalCommandBuilderDependencies Dependencies { get; } = dependencies; public IReadOnlyList Parameters => _parameters; @@ -88,17 +76,13 @@ public int CommandTextLength => Instance.Length; } - private class TestRelationalCommand : IRelationalCommand + private class TestRelationalCommand( + RelationalCommandBuilderDependencies dependencies, + string commandText, + IReadOnlyList parameters) + : IRelationalCommand { - private readonly RelationalCommand _realRelationalCommand; - - public TestRelationalCommand( - RelationalCommandBuilderDependencies dependencies, - string commandText, - IReadOnlyList parameters) - { - _realRelationalCommand = new RelationalCommand(dependencies, commandText, parameters); - } + private readonly RelationalCommand _realRelationalCommand = new(dependencies, commandText, parameters); public string CommandText => _realRelationalCommand.CommandText; diff --git a/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalTransaction.cs b/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalTransaction.cs index 9cfe34475..89cfb1b93 100644 --- a/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalTransaction.cs +++ b/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalTransaction.cs @@ -2,14 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities; -public class TestRelationalTransactionFactory : IRelationalTransactionFactory +public class TestRelationalTransactionFactory(RelationalTransactionFactoryDependencies dependencies) : IRelationalTransactionFactory { - public TestRelationalTransactionFactory(RelationalTransactionFactoryDependencies dependencies) - { - Dependencies = dependencies; - } - - protected virtual RelationalTransactionFactoryDependencies Dependencies { get; } + protected virtual RelationalTransactionFactoryDependencies Dependencies { get; } = dependencies; public RelationalTransaction Create( IRelationalConnection connection, @@ -20,20 +15,15 @@ public RelationalTransaction Create( => new TestRelationalTransaction(connection, transaction, logger, transactionOwned, Dependencies.SqlGenerationHelper); } -public class TestRelationalTransaction : RelationalTransaction +public class TestRelationalTransaction( + IRelationalConnection connection, + DbTransaction transaction, + IDiagnosticsLogger logger, + bool transactionOwned, + ISqlGenerationHelper sqlGenerationHelper) + : RelationalTransaction(connection, transaction, new Guid(), logger, transactionOwned, sqlGenerationHelper) { - private readonly TestNpgsqlConnection _testConnection; - - public TestRelationalTransaction( - IRelationalConnection connection, - DbTransaction transaction, - IDiagnosticsLogger logger, - bool transactionOwned, - ISqlGenerationHelper sqlGenerationHelper) - : base(connection, transaction, new Guid(), logger, transactionOwned, sqlGenerationHelper) - { - _testConnection = (TestNpgsqlConnection)connection; - } + private readonly TestNpgsqlConnection _testConnection = (TestNpgsqlConnection)connection; public override void Commit() { diff --git a/test/EFCore.PG.FunctionalTests/TransactionInterceptionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/TransactionInterceptionNpgsqlTest.cs index 05b57061c..7fe19ba50 100644 --- a/test/EFCore.PG.FunctionalTests/TransactionInterceptionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/TransactionInterceptionNpgsqlTest.cs @@ -2,13 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public abstract class TransactionInterceptionNpgsqlTestBase : TransactionInterceptionTestBase +public abstract class TransactionInterceptionNpgsqlTestBase(TransactionInterceptionNpgsqlTestBase.InterceptionNpgsqlFixtureBase fixture) + : TransactionInterceptionTestBase(fixture) { - protected TransactionInterceptionNpgsqlTestBase(InterceptionNpgsqlFixtureBase fixture) - : base(fixture) - { - } - public abstract class InterceptionNpgsqlFixtureBase : InterceptionFixtureBase { protected override string StoreName @@ -23,14 +19,9 @@ protected override IServiceCollection InjectInterceptors( => base.InjectInterceptors(serviceCollection.AddEntityFrameworkNpgsql(), injectedInterceptors); } - public class TransactionInterceptionNpgsqlTest - : TransactionInterceptionNpgsqlTestBase, IClassFixture + public class TransactionInterceptionNpgsqlTest(TransactionInterceptionNpgsqlTest.InterceptionNpgsqlFixture fixture) + : TransactionInterceptionNpgsqlTestBase(fixture), IClassFixture { - public TransactionInterceptionNpgsqlTest(InterceptionNpgsqlFixture fixture) - : base(fixture) - { - } - public class InterceptionNpgsqlFixture : InterceptionNpgsqlFixtureBase { protected override bool ShouldSubscribeToDiagnosticListener @@ -38,14 +29,11 @@ protected override bool ShouldSubscribeToDiagnosticListener } } - public class TransactionInterceptionWithDiagnosticsNpgsqlTest - : TransactionInterceptionNpgsqlTestBase, IClassFixture + public class TransactionInterceptionWithDiagnosticsNpgsqlTest( + TransactionInterceptionWithDiagnosticsNpgsqlTest.InterceptionNpgsqlFixture fixture) + : TransactionInterceptionNpgsqlTestBase(fixture), + IClassFixture { - public TransactionInterceptionWithDiagnosticsNpgsqlTest(InterceptionNpgsqlFixture fixture) - : base(fixture) - { - } - public class InterceptionNpgsqlFixture : InterceptionNpgsqlFixtureBase { protected override bool ShouldSubscribeToDiagnosticListener diff --git a/test/EFCore.PG.FunctionalTests/TransactionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/TransactionNpgsqlTest.cs index a80111f5b..0eb3c9bc3 100644 --- a/test/EFCore.PG.FunctionalTests/TransactionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/TransactionNpgsqlTest.cs @@ -4,13 +4,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class TransactionNpgsqlTest : TransactionTestBase +public class TransactionNpgsqlTest(TransactionNpgsqlTest.TransactionNpgsqlFixture fixture) + : TransactionTestBase(fixture) { - public TransactionNpgsqlTest(TransactionNpgsqlFixture fixture) - : base(fixture) - { - } - public override Task SaveChanges_can_be_used_with_AutoTransactionBehavior_Never(bool async) // Npgsql batches the inserts, creating an implicit transaction which fails the test // (see https://github.com/npgsql/npgsql/issues/1307) diff --git a/test/EFCore.PG.FunctionalTests/TwoDatabasesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/TwoDatabasesNpgsqlTest.cs index 96ced3bd3..9a6ab976a 100644 --- a/test/EFCore.PG.FunctionalTests/TwoDatabasesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/TwoDatabasesNpgsqlTest.cs @@ -2,13 +2,8 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class TwoDatabasesNpgsqlTest : TwoDatabasesTestBase, IClassFixture +public class TwoDatabasesNpgsqlTest(NpgsqlFixture fixture) : TwoDatabasesTestBase(fixture), IClassFixture { - public TwoDatabasesNpgsqlTest(NpgsqlFixture fixture) - : base(fixture) - { - } - protected new NpgsqlFixture Fixture => (NpgsqlFixture)base.Fixture; diff --git a/test/EFCore.PG.FunctionalTests/ValueConvertersEndToEndNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/ValueConvertersEndToEndNpgsqlTest.cs index 51734f48a..5cebb5470 100644 --- a/test/EFCore.PG.FunctionalTests/ValueConvertersEndToEndNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/ValueConvertersEndToEndNpgsqlTest.cs @@ -2,14 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class ValueConvertersEndToEndNpgsqlTest - : ValueConvertersEndToEndTestBase +public class ValueConvertersEndToEndNpgsqlTest(ValueConvertersEndToEndNpgsqlTest.ValueConvertersEndToEndNpgsqlFixture fixture) + : ValueConvertersEndToEndTestBase(fixture) { - public ValueConvertersEndToEndNpgsqlTest(ValueConvertersEndToEndNpgsqlFixture fixture) - : base(fixture) - { - } - [ConditionalTheory(Skip = "DateTime and DateTimeOffset, https://github.com/dotnet/efcore/issues/26068")] public override void Can_insert_and_read_back_with_conversions(int[] valueOrder) => base.Can_insert_and_read_back_with_conversions(valueOrder); @@ -211,14 +206,9 @@ public class ValueConvertedArrayEntity public IntWrapper[] Values { get; set; } = null!; } - public class IntWrapper : IEquatable + public class IntWrapper(int value) : IEquatable { - public int Value { get; } - - public IntWrapper(int value) - { - Value = value; - } + public int Value { get; } = value; public bool Equals(IntWrapper? other) => other is not null && Value == other.Value; diff --git a/test/EFCore.PG.FunctionalTests/WithConstructorsNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/WithConstructorsNpgsqlTest.cs index d82eec61b..e1337b284 100644 --- a/test/EFCore.PG.FunctionalTests/WithConstructorsNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/WithConstructorsNpgsqlTest.cs @@ -2,13 +2,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class WithConstructorsNpgsqlTest : WithConstructorsTestBase +public class WithConstructorsNpgsqlTest(WithConstructorsNpgsqlTest.WithConstructorsNpgsqlFixture fixture) + : WithConstructorsTestBase(fixture) { - public WithConstructorsNpgsqlTest(WithConstructorsNpgsqlFixture fixture) - : base(fixture) - { - } - protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); diff --git a/test/EFCore.PG.NodaTime.FunctionalTests/LegacyNpgsqlNodaTimeTypeMappingTest.cs b/test/EFCore.PG.NodaTime.FunctionalTests/LegacyNpgsqlNodaTimeTypeMappingTest.cs index 4c25a7e8f..080a54bf3 100644 --- a/test/EFCore.PG.NodaTime.FunctionalTests/LegacyNpgsqlNodaTimeTypeMappingTest.cs +++ b/test/EFCore.PG.NodaTime.FunctionalTests/LegacyNpgsqlNodaTimeTypeMappingTest.cs @@ -98,9 +98,7 @@ public void Dispose() } [CollectionDefinition("LegacyNodaTimeTest", DisableParallelization = true)] - public class EventSourceTestCollection - { - } + public class EventSourceTestCollection; } #endif diff --git a/test/EFCore.PG.NodaTime.FunctionalTests/NodaTimeQueryNpgsqlTest.cs b/test/EFCore.PG.NodaTime.FunctionalTests/NodaTimeQueryNpgsqlTest.cs index 16ec9a4cf..dabd1dba4 100644 --- a/test/EFCore.PG.NodaTime.FunctionalTests/NodaTimeQueryNpgsqlTest.cs +++ b/test/EFCore.PG.NodaTime.FunctionalTests/NodaTimeQueryNpgsqlTest.cs @@ -1854,13 +1854,8 @@ private NodaTimeContext CreateContext() private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - public class NodaTimeContext : PoolableDbContext + public class NodaTimeContext(DbContextOptions options) : PoolableDbContext(options) { - public NodaTimeContext(DbContextOptions options) - : base(options) - { - } - // ReSharper disable once MemberHidesStaticFromOuterClass // ReSharper disable once UnusedAutoPropertyAccessor.Global public DbSet NodaTimeTypes { get; set; } @@ -1983,12 +1978,7 @@ public IReadOnlyDictionary EntityAsserters private class NodaTimeData : ISetSource { - private IReadOnlyList NodaTimeTypes { get; } - - public NodaTimeData() - { - NodaTimeTypes = CreateNodaTimeTypes(); - } + private IReadOnlyList NodaTimeTypes { get; } = CreateNodaTimeTypes(); public IQueryable Set() where TEntity : class diff --git a/test/EFCore.PG.Tests/Metadata/NpgsqlMetadataBuilderExtensionsTest.cs b/test/EFCore.PG.Tests/Metadata/NpgsqlMetadataBuilderExtensionsTest.cs index 9e8288852..287bbcd18 100644 --- a/test/EFCore.PG.Tests/Metadata/NpgsqlMetadataBuilderExtensionsTest.cs +++ b/test/EFCore.PG.Tests/Metadata/NpgsqlMetadataBuilderExtensionsTest.cs @@ -138,7 +138,5 @@ public void Can_access_relationship() a => a.Name.StartsWith(RelationalAnnotationNames.Prefix, StringComparison.Ordinal))); } - private class Splot - { - } + private class Splot; } diff --git a/test/EFCore.PG.Tests/Migrations/NpgsqlHistoryRepositoryTest.cs b/test/EFCore.PG.Tests/Migrations/NpgsqlHistoryRepositoryTest.cs index 38cee7e59..f7a4c5571 100644 --- a/test/EFCore.PG.Tests/Migrations/NpgsqlHistoryRepositoryTest.cs +++ b/test/EFCore.PG.Tests/Migrations/NpgsqlHistoryRepositoryTest.cs @@ -157,13 +157,8 @@ private static IHistoryRepository CreateHistoryRepository(string schema = null) .Options) .GetService(); - private class TestDbContext : DbContext + private class TestDbContext(DbContextOptions options) : DbContext(options) { - public TestDbContext(DbContextOptions options) - : base(options) - { - } - public DbSet Blogs { get; set; } [DbFunction("TableFunction")] diff --git a/test/EFCore.PG.Tests/NpgsqlDatabaseFacadeTest.cs b/test/EFCore.PG.Tests/NpgsqlDatabaseFacadeTest.cs index db82de596..e8e29ad87 100644 --- a/test/EFCore.PG.Tests/NpgsqlDatabaseFacadeTest.cs +++ b/test/EFCore.PG.Tests/NpgsqlDatabaseFacadeTest.cs @@ -141,13 +141,8 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) } } - private class ProviderOnModelContext : ProviderContext + private class ProviderOnModelContext(DbContextOptions options) : ProviderContext(options) { - public ProviderOnModelContext(DbContextOptions options) - : base(options) - { - } - protected override void OnModelCreating(ModelBuilder modelBuilder) => IsNpgsqlSet = Database.IsNpgsql(); } @@ -162,13 +157,8 @@ public ProviderConstructorContext(DbContextOptions options) } } - private class ProviderUseInOnConfiguringContext : ProviderContext + private class ProviderUseInOnConfiguringContext(DbContextOptions options) : ProviderContext(options) { - public ProviderUseInOnConfiguringContext(DbContextOptions options) - : base(options) - { - } - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => IsNpgsqlSet = Database.IsNpgsql(); } diff --git a/test/EFCore.PG.Tests/NpgsqlDbContextOptionsExtensionsTest.cs b/test/EFCore.PG.Tests/NpgsqlDbContextOptionsExtensionsTest.cs index 2b4cfb7aa..516229e48 100644 --- a/test/EFCore.PG.Tests/NpgsqlDbContextOptionsExtensionsTest.cs +++ b/test/EFCore.PG.Tests/NpgsqlDbContextOptionsExtensionsTest.cs @@ -116,11 +116,5 @@ public void Service_collection_extension_method_can_configure_sqlserver_options( } } - private class ApplicationDbContext : DbContext - { - public ApplicationDbContext(DbContextOptions options) - : base(options) - { - } - } + private class ApplicationDbContext(DbContextOptions options) : DbContext(options); } diff --git a/test/EFCore.PG.Tests/NpgsqlNetTopologySuiteApiConsistencyTest.cs b/test/EFCore.PG.Tests/NpgsqlNetTopologySuiteApiConsistencyTest.cs index 5febe0b86..5f52f567d 100644 --- a/test/EFCore.PG.Tests/NpgsqlNetTopologySuiteApiConsistencyTest.cs +++ b/test/EFCore.PG.Tests/NpgsqlNetTopologySuiteApiConsistencyTest.cs @@ -1,13 +1,9 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class NpgsqlNetTopologySuiteApiConsistencyTest : ApiConsistencyTestBase< - NpgsqlNetTopologySuiteApiConsistencyTest.NpgsqlNetTopologySuiteApiConsistencyFixture> +public class NpgsqlNetTopologySuiteApiConsistencyTest( + NpgsqlNetTopologySuiteApiConsistencyTest.NpgsqlNetTopologySuiteApiConsistencyFixture fixture) + : ApiConsistencyTestBase(fixture) { - public NpgsqlNetTopologySuiteApiConsistencyTest(NpgsqlNetTopologySuiteApiConsistencyFixture fixture) - : base(fixture) - { - } - protected override void AddServices(ServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkNpgsqlNetTopologySuite(); diff --git a/test/EFCore.PG.Tests/NpgsqlNodaTimeApiConsistencyTest.cs b/test/EFCore.PG.Tests/NpgsqlNodaTimeApiConsistencyTest.cs index 9a76028f4..ff79bc1ce 100644 --- a/test/EFCore.PG.Tests/NpgsqlNodaTimeApiConsistencyTest.cs +++ b/test/EFCore.PG.Tests/NpgsqlNodaTimeApiConsistencyTest.cs @@ -1,12 +1,8 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL; -public class NpgsqlNodaTimeApiConsistencyTest : ApiConsistencyTestBase +public class NpgsqlNodaTimeApiConsistencyTest(NpgsqlNodaTimeApiConsistencyTest.NpgsqlNodaTimeApiConsistencyFixture fixture) + : ApiConsistencyTestBase(fixture) { - public NpgsqlNodaTimeApiConsistencyTest(NpgsqlNodaTimeApiConsistencyFixture fixture) - : base(fixture) - { - } - protected override void AddServices(ServiceCollection serviceCollection) => serviceCollection.AddEntityFrameworkNpgsqlNodaTime(); diff --git a/test/EFCore.PG.Tests/Storage/LegacyNpgsqlTypeMappingTest.cs b/test/EFCore.PG.Tests/Storage/LegacyNpgsqlTypeMappingTest.cs index 4c880d6ba..64400b9c4 100644 --- a/test/EFCore.PG.Tests/Storage/LegacyNpgsqlTypeMappingTest.cs +++ b/test/EFCore.PG.Tests/Storage/LegacyNpgsqlTypeMappingTest.cs @@ -76,8 +76,6 @@ public void Dispose() } [CollectionDefinition("LegacyDateTimeTest", DisableParallelization = true)] -public class EventSourceTestCollection -{ -} +public class EventSourceTestCollection; #endif diff --git a/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs b/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs index cafb9d493..a1dca3a49 100644 --- a/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs +++ b/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs @@ -353,13 +353,9 @@ protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters p } } - private class DummyType - { - } + private class DummyType; - private class UnknownType - { - } + private class UnknownType; protected IModel CreateEmptyModel() => CreateModelBuilder().Model.FinalizeModel(); diff --git a/test/EFCore.PG.Tests/TestUtilities/FakeProvider/FakeRelationalOptionsExtension.cs b/test/EFCore.PG.Tests/TestUtilities/FakeProvider/FakeRelationalOptionsExtension.cs index edf36f126..61b17e88e 100644 --- a/test/EFCore.PG.Tests/TestUtilities/FakeProvider/FakeRelationalOptionsExtension.cs +++ b/test/EFCore.PG.Tests/TestUtilities/FakeProvider/FakeRelationalOptionsExtension.cs @@ -32,13 +32,8 @@ public static IServiceCollection AddEntityFrameworkRelationalDatabase(IServiceCo return serviceCollection; } - private sealed class ExtensionInfo : RelationalExtensionInfo + private sealed class ExtensionInfo(IDbContextOptionsExtension extension) : RelationalExtensionInfo(extension) { - public ExtensionInfo(IDbContextOptionsExtension extension) - : base(extension) - { - } - public override void PopulateDebugInfo(IDictionary debugInfo) { } diff --git a/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchFactoryTest.cs b/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchFactoryTest.cs index fd1b15b1a..86fadf80f 100644 --- a/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchFactoryTest.cs +++ b/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchFactoryTest.cs @@ -82,9 +82,7 @@ public void MaxBatchSize_is_optional() Assert.True(batch.TryAddCommand(CreateModificationCommand("T1", null, false))); } - private class FakeDbContext : DbContext - { - } + private class FakeDbContext : DbContext; private static INonTrackedModificationCommand CreateModificationCommand( string name, diff --git a/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchTest.cs b/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchTest.cs index 1fcd77b26..c242266e0 100644 --- a/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchTest.cs +++ b/test/EFCore.PG.Tests/Update/NpgsqlModificationCommandBatchTest.cs @@ -46,9 +46,7 @@ public void AddCommand_returns_false_when_max_batch_size_is_reached() CreateModificationCommand("T1", null, false))); } - private class FakeDbContext : DbContext - { - } + private class FakeDbContext : DbContext; private static INonTrackedModificationCommand CreateModificationCommand( string name,