From 2fab5fbfd1de1a5abc947d2b178db33512e71e01 Mon Sep 17 00:00:00 2001 From: Bart Koelman Date: Fri, 23 Jul 2021 11:54:45 +0200 Subject: [PATCH] Updated dependencies to .NET 5 with EF Core 5 (#1022) --- .config/dotnet-tools.json | 4 +- Directory.Build.props | 10 ++--- JsonApiDotNetCore.sln.DotSettings | 2 + README.md | 4 +- ...nkBuilderGetNamespaceFromPathBenchmarks.cs | 2 +- benchmarks/Query/QueryParserBenchmarks.cs | 4 +- .../JsonApiDeserializerBenchmarks.cs | 2 +- .../JsonApiSerializerBenchmarks.cs | 4 +- .../ReportsExample/Services/ReportService.cs | 2 +- .../Processors/SetRelationshipProcessor.cs | 2 +- .../InverseNavigationResolver.cs | 2 +- .../JsonApiApplicationBuilder.cs | 2 +- .../Configuration/JsonApiOptions.cs | 4 +- .../Configuration/JsonApiValidationFilter.cs | 2 +- .../Configuration/PageNumber.cs | 2 +- .../ResourceDescriptorAssemblyCache.cs | 6 +-- .../Configuration/ResourceGraphBuilder.cs | 6 +-- .../ServiceCollectionExtensions.cs | 2 +- .../Configuration/ServiceDiscoveryFacade.cs | 10 ++--- .../DisableQueryStringAttribute.cs | 2 +- .../Controllers/BaseJsonApiController.cs | 2 +- .../BaseJsonApiOperationsController.cs | 2 +- .../Errors/JsonApiException.cs | 2 +- ...sourcesInRelationshipsNotFoundException.cs | 2 +- .../JsonApiDotNetCore.csproj | 4 +- .../Middleware/FixedQueryFeature.cs | 11 +++++- .../Middleware/JsonApiMiddleware.cs | 6 ++- .../Middleware/JsonApiRoutingConvention.cs | 6 +-- src/JsonApiDotNetCore/ObjectExtensions.cs | 2 +- .../Expressions/IncludeChainConverter.cs | 4 +- .../Queries/Expressions/IncludeExpression.cs | 4 +- .../Queries/Internal/Parsing/IncludeParser.cs | 2 +- .../Internal/Parsing/QueryTokenizer.cs | 6 +-- .../Queries/Internal/QueryLayerComposer.cs | 4 +- .../QueryableBuilding/IncludeClauseBuilder.cs | 2 +- .../LambdaParameterNameFactory.cs | 2 +- .../QueryableBuilding/SelectClauseBuilder.cs | 2 +- .../QueryableBuilding/WhereClauseBuilder.cs | 2 +- .../FilterQueryStringParameterReader.cs | 9 ++--- .../Internal/LegacyFilterNotationConverter.cs | 2 +- .../PaginationQueryStringParameterReader.cs | 6 +-- .../Internal/RequestQueryStringAccessor.cs | 2 +- ...ourceDefinitionQueryableParameterReader.cs | 2 +- .../SortQueryStringParameterReader.cs | 2 +- ...parseFieldSetQueryStringParameterReader.cs | 2 +- .../EntityFrameworkCoreRepository.cs | 6 +-- .../PlaceholderResourceCollector.cs | 2 +- .../Annotations/HasManyThroughAttribute.cs | 2 +- .../Resources/IdentifiableComparer.cs | 2 +- .../Resources/OperationContainer.cs | 2 +- .../Serialization/BaseDeserializer.cs | 2 +- .../Serialization/Building/LinkBuilder.cs | 12 +++--- .../Serialization/Building/MetaBuilder.cs | 2 +- .../ResourceIdentifierObjectComparer.cs | 2 +- .../Building/ResourceObjectBuilder.cs | 4 +- .../ResourceObjectBuilderSettingsProvider.cs | 2 +- .../Building/ResponseResourceObjectBuilder.cs | 2 +- .../Client/Internal/RequestSerializer.cs | 2 +- .../Serialization/JsonApiReader.cs | 2 + .../Serialization/Objects/Error.cs | 6 +-- .../Serialization/RequestDeserializer.cs | 6 +-- .../Services/JsonApiResourceService.cs | 2 +- .../ServiceDiscoveryFacadeTests.cs | 2 +- .../Archiving/ArchiveTests.cs | 2 +- .../Archiving/TelevisionFakers.cs | 8 ++-- ...micConstrainedOperationsControllerTests.cs | 4 +- .../Creating/AtomicCreateResourceTests.cs | 4 +- ...reateResourceWithClientGeneratedIdTests.cs | 2 +- ...eateResourceWithToManyRelationshipTests.cs | 2 +- ...reateResourceWithToOneRelationshipTests.cs | 2 +- .../Deleting/AtomicDeleteResourceTests.cs | 2 +- .../Links/AtomicAbsoluteLinksTests.cs | 4 +- .../LocalIds/AtomicLocalIdTests.cs | 2 +- .../Meta/AtomicResourceMetaTests.cs | 2 +- .../Meta/AtomicResponseMetaTests.cs | 2 +- .../Mixed/AtomicSerializationTests.cs | 2 +- .../AtomicModelStateValidationTests.cs | 8 ++-- .../AtomicOperations/OperationsFakers.cs | 14 +++---- .../QueryStrings/AtomicQueryStringTests.cs | 2 +- .../MusicTrackReleaseDefinition.cs | 2 +- ...micSerializationResourceDefinitionTests.cs | 6 +-- ...icSparseFieldSetResourceDefinitionTests.cs | 2 +- .../Transactions/AtomicRollbackTests.cs | 2 +- .../AtomicAddToToManyRelationshipTests.cs | 6 +-- ...AtomicRemoveFromToManyRelationshipTests.cs | 8 ++-- .../AtomicReplaceToManyRelationshipTests.cs | 8 ++-- .../AtomicUpdateToOneRelationshipTests.cs | 14 +++---- .../AtomicReplaceToManyRelationshipTests.cs | 8 ++-- .../Resources/AtomicUpdateResourceTests.cs | 4 +- .../AtomicUpdateToOneRelationshipTests.cs | 14 +++---- .../CompositeKeys/CompositeKeyTests.cs | 14 +++---- .../ContentTypeHeaderTests.cs | 4 +- .../CustomRoutes/CustomRouteFakers.cs | 4 +- .../CustomRoutes/CustomRouteTests.cs | 2 +- .../EagerLoading/EagerLoadingFakers.cs | 12 +++--- .../EagerLoading/EagerLoadingTests.cs | 2 +- .../HostingInIIS/HostingFakers.cs | 4 +- .../HostingInIIS/HostingTests.cs | 2 +- .../IdObfuscation/IdObfuscationTests.cs | 6 +-- .../IdObfuscation/ObfuscatedIdentifiable.cs | 2 +- .../ObfuscatedIdentifiableController.cs | 2 +- .../IdObfuscation/ObfuscationFakers.cs | 4 +- .../ModelState/ModelStateValidationTests.cs | 14 +++---- .../RequestBody/WorkflowDefinition.cs | 37 +++++++++---------- .../Links/AbsoluteLinksWithNamespaceTests.cs | 4 +- .../AbsoluteLinksWithoutNamespaceTests.cs | 4 +- .../Links/LinkInclusionTests.cs | 2 +- .../IntegrationTests/Links/LinksFakers.cs | 6 +-- .../Links/RelativeLinksWithNamespaceTests.cs | 4 +- .../RelativeLinksWithoutNamespaceTests.cs | 4 +- .../IntegrationTests/Logging/AuditFakers.cs | 2 +- .../IntegrationTests/Logging/LoggingTests.cs | 4 +- .../Meta/ResourceMetaTests.cs | 2 +- .../IntegrationTests/Meta/SupportFakers.cs | 4 +- .../Meta/TopLevelCountTests.cs | 2 +- .../Microservices/DomainFakers.cs | 4 +- .../FireForgetTests.User.cs | 8 ++-- .../FireAndForgetDelivery/FireForgetTests.cs | 2 +- .../Microservices/Messages/OutgoingMessage.cs | 2 +- .../Microservices/MessagingGroupDefinition.cs | 2 +- .../Microservices/MessagingUserDefinition.cs | 2 +- .../OutboxTests.User.cs | 8 ++-- .../TransactionalOutboxPattern/OutboxTests.cs | 4 +- .../MultiTenancy/MultiTenancyFakers.cs | 4 +- .../MultiTenancy/MultiTenancyTests.cs | 14 +++---- .../MultiTenancy/RouteTenantProvider.cs | 7 +++- .../NamingConventions/KebabCasingTests.cs | 2 +- .../NamingConventions/SwimmingFakers.cs | 6 +-- .../NonJsonApiControllerTests.cs | 12 +++--- .../Filtering/FilterDepthTests.cs | 10 ++--- .../Filtering/FilterOperatorTests.cs | 14 +++---- .../QueryStrings/Filtering/FilterTests.cs | 2 +- .../QueryStrings/Includes/IncludeTests.cs | 6 +-- .../PaginationWithTotalCountTests.cs | 14 +++---- .../PaginationWithoutTotalCountTests.cs | 2 +- .../Pagination/RangeValidationTests.cs | 2 +- .../QueryStrings/QueryStringFakers.cs | 16 ++++---- .../SerializerDefaultValueHandlingTests.cs | 2 +- .../SerializerNullValueHandlingTests.cs | 2 +- .../QueryStrings/Sorting/SortTests.cs | 14 +++---- .../SparseFieldSets/ResourceCaptureStore.cs | 2 +- .../SparseFieldSets/SparseFieldSetTests.cs | 4 +- .../ReadWrite/Creating/CreateResourceTests.cs | 2 +- ...reateResourceWithClientGeneratedIdTests.cs | 2 +- ...eateResourceWithToManyRelationshipTests.cs | 2 +- ...reateResourceWithToOneRelationshipTests.cs | 2 +- .../ReadWrite/Deleting/DeleteResourceTests.cs | 2 +- .../Fetching/FetchRelationshipTests.cs | 6 +-- .../ReadWrite/Fetching/FetchResourceTests.cs | 6 +-- .../ReadWrite/ReadWriteFakers.cs | 10 ++--- .../AddToToManyRelationshipTests.cs | 14 +++---- .../RemoveFromToManyRelationshipTests.cs | 8 ++-- .../ReplaceToManyRelationshipTests.cs | 12 +++--- .../UpdateToOneRelationshipTests.cs | 10 ++--- .../ReplaceToManyRelationshipTests.cs | 12 +++--- .../Updating/Resources/UpdateResourceTests.cs | 8 ++-- .../Resources/UpdateToOneRelationshipTests.cs | 10 ++--- .../DefaultBehaviorFakers.cs | 6 +-- .../DefaultBehaviorTests.cs | 2 +- .../PostOffice.cs | 2 +- .../ResourceInjectionTests.cs | 2 +- .../Reading/MoonDefinition.cs | 2 +- .../Reading/ResourceDefinitionReadTests.cs | 2 +- .../Reading/UniverseFakers.cs | 6 +-- .../ResourceDefinitionSerializationTests.cs | 4 +- .../Serialization/SerializationFakers.cs | 4 +- .../ResourceInheritance/InheritanceTests.cs | 4 +- .../HttpReadOnlyTests.cs | 2 +- .../NoHttpDeleteTests.cs | 2 +- .../RestrictedControllers/NoHttpPatchTests.cs | 2 +- .../RestrictedControllers/NoHttpPostTests.cs | 2 +- .../RestrictionFakers.cs | 8 ++-- .../Serialization/ETagTests.cs | 12 +++--- .../IntegrationTests/Serialization/Meeting.cs | 2 +- .../Serialization/SerializationFakers.cs | 4 +- .../Serialization/SerializationTests.cs | 2 +- .../SoftDeletion/SoftDeletionFakers.cs | 4 +- .../SoftDeletion/SoftDeletionTests.cs | 14 +++---- .../ZeroKeys/EmptyGuidAsKeyTests.cs | 12 +++--- .../ZeroKeys/ZeroAsKeyTests.cs | 12 +++--- .../ZeroKeys/ZeroKeyFakers.cs | 6 +-- .../UnitTests/Links/LinkInclusionTests.cs | 11 +++--- .../BaseIntegrationTestContext.cs | 2 +- .../TestBuildingBlocks/DbContextExtensions.cs | 5 +++ test/TestBuildingBlocks/FakeLoggerFactory.cs | 2 +- test/TestBuildingBlocks/FakerContainer.cs | 2 +- test/TestBuildingBlocks/FrozenSystemClock.cs | 2 +- .../HttpResponseMessageExtensions.cs | 2 +- test/TestBuildingBlocks/IntegrationTest.cs | 2 +- .../IntegrationTestConfiguration.cs | 2 +- .../ObjectAssertionsExtensions.cs | 2 +- .../Middleware/JsonApiMiddlewareTests.cs | 14 +++---- .../Middleware/JsonApiRequestTests.cs | 2 +- .../UnitTests/Models/RelationshipDataTests.cs | 2 +- .../Client/RequestSerializerTests.cs | 6 +-- .../Client/ResponseDeserializerTests.cs | 32 ++++++++-------- .../Common/BaseDocumentParserTests.cs | 4 +- .../Common/ResourceObjectBuilderTests.cs | 2 +- .../Serialization/DeserializerTestsSetup.cs | 4 +- .../Serialization/SerializerTestsSetup.cs | 2 +- .../Server/RequestDeserializerTests.cs | 4 +- .../ResponseResourceObjectBuilderTests.cs | 4 +- .../Server/ResponseSerializerTests.cs | 2 +- test/UnitTests/TestScopedServiceProvider.cs | 2 +- 204 files changed, 512 insertions(+), 498 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 60cd78544c..1c7cf727cb 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "jetbrains.resharper.globaltools": { - "version": "2021.1.3", + "version": "2021.1.4", "commands": [ "jb" ] @@ -21,7 +21,7 @@ ] }, "dotnet-reportgenerator-globaltool": { - "version": "4.8.9", + "version": "4.8.12", "commands": [ "reportgenerator" ] diff --git a/Directory.Build.props b/Directory.Build.props index 49eb522e60..dbd5c5ab26 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,9 +1,9 @@ - netcoreapp3.1 - 3.1.* - 3.1.* - 3.1.* + net5.0 + 5.0.* + 5.0.* + 5.0.* $(MSBuildThisFileDirectory)CodingGuidelines.ruleset @@ -22,7 +22,7 @@ 33.0.2 - 3.0.3 + 3.1.0 5.10.3 4.16.1 2.4.* diff --git a/JsonApiDotNetCore.sln.DotSettings b/JsonApiDotNetCore.sln.DotSettings index d22ebc6887..a6443a0787 100644 --- a/JsonApiDotNetCore.sln.DotSettings +++ b/JsonApiDotNetCore.sln.DotSettings @@ -56,6 +56,8 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$, $NAME$); DO_NOT_SHOW HINT SUGGESTION + WARNING + WARNING SUGGESTION WARNING SUGGESTION diff --git a/README.md b/README.md index 49847f8429..fc007961bd 100644 --- a/README.md +++ b/README.md @@ -90,8 +90,8 @@ See also our [versioning policy](./VERSIONING_POLICY.md). | .NET Version | EF Core Version | JsonApiDotNetCore Version | | ----------------- | --------------- | ------------------------- | | .NET Core 2.x | 2.x | v3.x | -| .NET Core 3.1 | 3.1, 5 | v4 | -| .NET 5 | 5 | v4 | +| .NET Core 3.1 | 3.1, 5 | v4.x | +| .NET 5 | 5 | v4.x, v5.x | ## Contributing diff --git a/benchmarks/LinkBuilder/LinkBuilderGetNamespaceFromPathBenchmarks.cs b/benchmarks/LinkBuilder/LinkBuilderGetNamespaceFromPathBenchmarks.cs index b3dbef6232..c7110bf73e 100644 --- a/benchmarks/LinkBuilder/LinkBuilderGetNamespaceFromPathBenchmarks.cs +++ b/benchmarks/LinkBuilder/LinkBuilderGetNamespaceFromPathBenchmarks.cs @@ -67,7 +67,7 @@ private static void GetNamespaceFromPathUsingReadOnlySpan(string path, string re if (isAtEnd || hasDelimiterAfterSegment) { - _ = pathSpan.Slice(0, index).ToString(); + _ = pathSpan[..index].ToString(); } } } diff --git a/benchmarks/Query/QueryParserBenchmarks.cs b/benchmarks/Query/QueryParserBenchmarks.cs index 553d9fa7ba..fd791f5d8a 100644 --- a/benchmarks/Query/QueryParserBenchmarks.cs +++ b/benchmarks/Query/QueryParserBenchmarks.cs @@ -20,8 +20,8 @@ namespace Benchmarks.Query [MemoryDiagnoser] public class QueryParserBenchmarks { - private readonly DependencyFactory _dependencyFactory = new DependencyFactory(); - private readonly FakeRequestQueryStringAccessor _queryStringAccessor = new FakeRequestQueryStringAccessor(); + private readonly DependencyFactory _dependencyFactory = new(); + private readonly FakeRequestQueryStringAccessor _queryStringAccessor = new(); private readonly QueryStringReader _queryStringReaderForSort; private readonly QueryStringReader _queryStringReaderForAll; diff --git a/benchmarks/Serialization/JsonApiDeserializerBenchmarks.cs b/benchmarks/Serialization/JsonApiDeserializerBenchmarks.cs index f4dbd5a829..467603226e 100644 --- a/benchmarks/Serialization/JsonApiDeserializerBenchmarks.cs +++ b/benchmarks/Serialization/JsonApiDeserializerBenchmarks.cs @@ -29,7 +29,7 @@ public class JsonApiDeserializerBenchmarks } }); - private readonly DependencyFactory _dependencyFactory = new DependencyFactory(); + private readonly DependencyFactory _dependencyFactory = new(); private readonly IJsonApiDeserializer _jsonApiDeserializer; public JsonApiDeserializerBenchmarks() diff --git a/benchmarks/Serialization/JsonApiSerializerBenchmarks.cs b/benchmarks/Serialization/JsonApiSerializerBenchmarks.cs index 3d9cefc600..ffbebc2cfc 100644 --- a/benchmarks/Serialization/JsonApiSerializerBenchmarks.cs +++ b/benchmarks/Serialization/JsonApiSerializerBenchmarks.cs @@ -15,13 +15,13 @@ namespace Benchmarks.Serialization [MarkdownExporter] public class JsonApiSerializerBenchmarks { - private static readonly BenchmarkResource Content = new BenchmarkResource + private static readonly BenchmarkResource Content = new() { Id = 123, Name = Guid.NewGuid().ToString() }; - private readonly DependencyFactory _dependencyFactory = new DependencyFactory(); + private readonly DependencyFactory _dependencyFactory = new(); private readonly IJsonApiSerializer _jsonApiSerializer; public JsonApiSerializerBenchmarks() diff --git a/src/Examples/ReportsExample/Services/ReportService.cs b/src/Examples/ReportsExample/Services/ReportService.cs index cd9447bd3f..b0655d38e1 100644 --- a/src/Examples/ReportsExample/Services/ReportService.cs +++ b/src/Examples/ReportsExample/Services/ReportService.cs @@ -31,7 +31,7 @@ private IReadOnlyCollection GetReports() { return new List { - new Report + new() { Title = "Status Report", Statistics = new ReportStatistics diff --git a/src/JsonApiDotNetCore/AtomicOperations/Processors/SetRelationshipProcessor.cs b/src/JsonApiDotNetCore/AtomicOperations/Processors/SetRelationshipProcessor.cs index a69eabcc57..8147435de6 100644 --- a/src/JsonApiDotNetCore/AtomicOperations/Processors/SetRelationshipProcessor.cs +++ b/src/JsonApiDotNetCore/AtomicOperations/Processors/SetRelationshipProcessor.cs @@ -14,7 +14,7 @@ namespace JsonApiDotNetCore.AtomicOperations.Processors public class SetRelationshipProcessor : ISetRelationshipProcessor where TResource : class, IIdentifiable { - private readonly CollectionConverter _collectionConverter = new CollectionConverter(); + private readonly CollectionConverter _collectionConverter = new(); private readonly ISetRelationshipService _service; public SetRelationshipProcessor(ISetRelationshipService service) diff --git a/src/JsonApiDotNetCore/Configuration/InverseNavigationResolver.cs b/src/JsonApiDotNetCore/Configuration/InverseNavigationResolver.cs index 5675a1b023..749abfde2d 100644 --- a/src/JsonApiDotNetCore/Configuration/InverseNavigationResolver.cs +++ b/src/JsonApiDotNetCore/Configuration/InverseNavigationResolver.cs @@ -52,7 +52,7 @@ private void ResolveRelationships(IReadOnlyCollection rel { if (!(relationship is HasManyThroughAttribute)) { - INavigation inverseNavigation = entityType.FindNavigation(relationship.Property.Name)?.FindInverse(); + INavigation inverseNavigation = entityType.FindNavigation(relationship.Property.Name)?.Inverse; relationship.InverseNavigationProperty = inverseNavigation?.PropertyInfo; } } diff --git a/src/JsonApiDotNetCore/Configuration/JsonApiApplicationBuilder.cs b/src/JsonApiDotNetCore/Configuration/JsonApiApplicationBuilder.cs index 24fb1b33c8..1efd2c13ee 100644 --- a/src/JsonApiDotNetCore/Configuration/JsonApiApplicationBuilder.cs +++ b/src/JsonApiDotNetCore/Configuration/JsonApiApplicationBuilder.cs @@ -30,7 +30,7 @@ namespace JsonApiDotNetCore.Configuration /// internal sealed class JsonApiApplicationBuilder : IJsonApiApplicationBuilder, IDisposable { - private readonly JsonApiOptions _options = new JsonApiOptions(); + private readonly JsonApiOptions _options = new(); private readonly IServiceCollection _services; private readonly IMvcCoreBuilder _mvcBuilder; private readonly ResourceGraphBuilder _resourceGraphBuilder; diff --git a/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs b/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs index bc9b1db2ac..b898b9e205 100644 --- a/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs +++ b/src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs @@ -44,7 +44,7 @@ public sealed class JsonApiOptions : IJsonApiOptions public bool IncludeTotalResourceCount { get; set; } /// - public PageSize DefaultPageSize { get; set; } = new PageSize(10); + public PageSize DefaultPageSize { get; set; } = new(10); /// public PageSize MaximumPageSize { get; set; } @@ -80,7 +80,7 @@ public sealed class JsonApiOptions : IJsonApiOptions public IsolationLevel? TransactionIsolationLevel { get; set; } /// - public JsonSerializerSettings SerializerSettings { get; } = new JsonSerializerSettings + public JsonSerializerSettings SerializerSettings { get; } = new() { ContractResolver = new DefaultContractResolver { diff --git a/src/JsonApiDotNetCore/Configuration/JsonApiValidationFilter.cs b/src/JsonApiDotNetCore/Configuration/JsonApiValidationFilter.cs index f4f9d5e1a7..7ccc306716 100644 --- a/src/JsonApiDotNetCore/Configuration/JsonApiValidationFilter.cs +++ b/src/JsonApiDotNetCore/Configuration/JsonApiValidationFilter.cs @@ -41,7 +41,7 @@ public bool ShouldValidateEntry(ValidationEntry entry, ValidationEntry parentEnt var httpContextAccessor = _serviceProvider.GetRequiredService(); - if (httpContextAccessor.HttpContext.Request.Method == HttpMethods.Patch || request.OperationKind == OperationKind.UpdateResource) + if (httpContextAccessor.HttpContext!.Request.Method == HttpMethods.Patch || request.OperationKind == OperationKind.UpdateResource) { var targetedFields = _serviceProvider.GetRequiredService(); return IsFieldTargeted(entry, targetedFields); diff --git a/src/JsonApiDotNetCore/Configuration/PageNumber.cs b/src/JsonApiDotNetCore/Configuration/PageNumber.cs index 81561aefcb..9f094a1423 100644 --- a/src/JsonApiDotNetCore/Configuration/PageNumber.cs +++ b/src/JsonApiDotNetCore/Configuration/PageNumber.cs @@ -6,7 +6,7 @@ namespace JsonApiDotNetCore.Configuration [PublicAPI] public sealed class PageNumber : IEquatable { - public static readonly PageNumber ValueOne = new PageNumber(1); + public static readonly PageNumber ValueOne = new(1); public int OneBasedValue { get; } diff --git a/src/JsonApiDotNetCore/Configuration/ResourceDescriptorAssemblyCache.cs b/src/JsonApiDotNetCore/Configuration/ResourceDescriptorAssemblyCache.cs index ed919c044d..3eaa0d828d 100644 --- a/src/JsonApiDotNetCore/Configuration/ResourceDescriptorAssemblyCache.cs +++ b/src/JsonApiDotNetCore/Configuration/ResourceDescriptorAssemblyCache.cs @@ -10,10 +10,8 @@ namespace JsonApiDotNetCore.Configuration /// internal sealed class ResourceDescriptorAssemblyCache { - private readonly TypeLocator _typeLocator = new TypeLocator(); - - private readonly Dictionary> _resourceDescriptorsPerAssembly = - new Dictionary>(); + private readonly TypeLocator _typeLocator = new(); + private readonly Dictionary> _resourceDescriptorsPerAssembly = new(); public void RegisterAssembly(Assembly assembly) { diff --git a/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs b/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs index 0451c83643..6b757d82c5 100644 --- a/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs +++ b/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs @@ -18,8 +18,8 @@ public class ResourceGraphBuilder { private readonly IJsonApiOptions _options; private readonly ILogger _logger; - private readonly List _resources = new List(); - private readonly TypeLocator _typeLocator = new TypeLocator(); + private readonly List _resources = new(); + private readonly TypeLocator _typeLocator = new(); public ResourceGraphBuilder(IJsonApiOptions options, ILoggerFactory loggerFactory) { @@ -126,7 +126,7 @@ public ResourceGraphBuilder Add(Type resourceType, Type idType = null, string pu private ResourceContext CreateResourceContext(string publicName, Type resourceType, Type idType) { - return new ResourceContext + return new() { PublicName = publicName, ResourceType = resourceType, diff --git a/src/JsonApiDotNetCore/Configuration/ServiceCollectionExtensions.cs b/src/JsonApiDotNetCore/Configuration/ServiceCollectionExtensions.cs index 815b44bd96..b05fde176e 100644 --- a/src/JsonApiDotNetCore/Configuration/ServiceCollectionExtensions.cs +++ b/src/JsonApiDotNetCore/Configuration/ServiceCollectionExtensions.cs @@ -17,7 +17,7 @@ namespace JsonApiDotNetCore.Configuration [PublicAPI] public static class ServiceCollectionExtensions { - private static readonly TypeLocator TypeLocator = new TypeLocator(); + private static readonly TypeLocator TypeLocator = new(); /// /// Configures JsonApiDotNetCore by registering resources manually. diff --git a/src/JsonApiDotNetCore/Configuration/ServiceDiscoveryFacade.cs b/src/JsonApiDotNetCore/Configuration/ServiceDiscoveryFacade.cs index 33198b051c..bc4cd6b4d0 100644 --- a/src/JsonApiDotNetCore/Configuration/ServiceDiscoveryFacade.cs +++ b/src/JsonApiDotNetCore/Configuration/ServiceDiscoveryFacade.cs @@ -17,7 +17,7 @@ namespace JsonApiDotNetCore.Configuration [PublicAPI] public class ServiceDiscoveryFacade { - internal static readonly HashSet ServiceInterfaces = new HashSet + internal static readonly HashSet ServiceInterfaces = new() { typeof(IResourceService<>), typeof(IResourceService<,>), @@ -47,7 +47,7 @@ public class ServiceDiscoveryFacade typeof(IRemoveFromRelationshipService<,>) }; - internal static readonly HashSet RepositoryInterfaces = new HashSet + internal static readonly HashSet RepositoryInterfaces = new() { typeof(IResourceRepository<>), typeof(IResourceRepository<,>), @@ -57,7 +57,7 @@ public class ServiceDiscoveryFacade typeof(IResourceReadRepository<,>) }; - internal static readonly HashSet ResourceDefinitionInterfaces = new HashSet + internal static readonly HashSet ResourceDefinitionInterfaces = new() { typeof(IResourceDefinition<>), typeof(IResourceDefinition<,>) @@ -67,8 +67,8 @@ public class ServiceDiscoveryFacade private readonly IServiceCollection _services; private readonly ResourceGraphBuilder _resourceGraphBuilder; private readonly IJsonApiOptions _options; - private readonly ResourceDescriptorAssemblyCache _assemblyCache = new ResourceDescriptorAssemblyCache(); - private readonly TypeLocator _typeLocator = new TypeLocator(); + private readonly ResourceDescriptorAssemblyCache _assemblyCache = new(); + private readonly TypeLocator _typeLocator = new(); public ServiceDiscoveryFacade(IServiceCollection services, ResourceGraphBuilder resourceGraphBuilder, IJsonApiOptions options, ILoggerFactory loggerFactory) diff --git a/src/JsonApiDotNetCore/Controllers/Annotations/DisableQueryStringAttribute.cs b/src/JsonApiDotNetCore/Controllers/Annotations/DisableQueryStringAttribute.cs index 4bf10ec976..acb62b44d8 100644 --- a/src/JsonApiDotNetCore/Controllers/Annotations/DisableQueryStringAttribute.cs +++ b/src/JsonApiDotNetCore/Controllers/Annotations/DisableQueryStringAttribute.cs @@ -21,7 +21,7 @@ namespace JsonApiDotNetCore.Controllers.Annotations [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface)] public sealed class DisableQueryStringAttribute : Attribute { - public static readonly DisableQueryStringAttribute Empty = new DisableQueryStringAttribute(StandardQueryStringParameters.None); + public static readonly DisableQueryStringAttribute Empty = new(StandardQueryStringParameters.None); public IReadOnlyCollection ParameterNames { get; } /// diff --git a/src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs b/src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs index 978fe828f5..1386ee76a3 100644 --- a/src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs +++ b/src/JsonApiDotNetCore/Controllers/BaseJsonApiController.cs @@ -271,7 +271,7 @@ public virtual async Task PatchAsync(TId id, [FromBody] TResource } TResource updated = await _update.UpdateAsync(id, resource, cancellationToken); - return updated == null ? (IActionResult)NoContent() : Ok(updated); + return updated == null ? NoContent() : Ok(updated); } /// diff --git a/src/JsonApiDotNetCore/Controllers/BaseJsonApiOperationsController.cs b/src/JsonApiDotNetCore/Controllers/BaseJsonApiOperationsController.cs index 5da8b2b4f5..3c648dd7b9 100644 --- a/src/JsonApiDotNetCore/Controllers/BaseJsonApiOperationsController.cs +++ b/src/JsonApiDotNetCore/Controllers/BaseJsonApiOperationsController.cs @@ -121,7 +121,7 @@ public virtual async Task PostOperationsAsync([FromBody] IList results = await _processor.ProcessAsync(operations, cancellationToken); - return results.Any(result => result != null) ? (IActionResult)Ok(results) : NoContent(); + return results.Any(result => result != null) ? Ok(results) : NoContent(); } protected virtual void ValidateClientGeneratedIds(IEnumerable operations) diff --git a/src/JsonApiDotNetCore/Errors/JsonApiException.cs b/src/JsonApiDotNetCore/Errors/JsonApiException.cs index 93ba6fe6cb..6ad1a2021c 100644 --- a/src/JsonApiDotNetCore/Errors/JsonApiException.cs +++ b/src/JsonApiDotNetCore/Errors/JsonApiException.cs @@ -13,7 +13,7 @@ namespace JsonApiDotNetCore.Errors [PublicAPI] public class JsonApiException : Exception { - private static readonly JsonSerializerSettings ErrorSerializerSettings = new JsonSerializerSettings + private static readonly JsonSerializerSettings ErrorSerializerSettings = new() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.Indented diff --git a/src/JsonApiDotNetCore/Errors/ResourcesInRelationshipsNotFoundException.cs b/src/JsonApiDotNetCore/Errors/ResourcesInRelationshipsNotFoundException.cs index 94503ab343..d749bca5fa 100644 --- a/src/JsonApiDotNetCore/Errors/ResourcesInRelationshipsNotFoundException.cs +++ b/src/JsonApiDotNetCore/Errors/ResourcesInRelationshipsNotFoundException.cs @@ -19,7 +19,7 @@ public ResourcesInRelationshipsNotFoundException(IEnumerable - - + + diff --git a/src/JsonApiDotNetCore/Middleware/FixedQueryFeature.cs b/src/JsonApiDotNetCore/Middleware/FixedQueryFeature.cs index 9ce2da0489..6bd345d99d 100644 --- a/src/JsonApiDotNetCore/Middleware/FixedQueryFeature.cs +++ b/src/JsonApiDotNetCore/Middleware/FixedQueryFeature.cs @@ -27,7 +27,7 @@ public IQueryCollection Query { get { - if (_features.Collection == null) + if (IsFeatureCollectionNull()) { return _parsedValues ??= QueryCollection.Empty; } @@ -49,7 +49,7 @@ public IQueryCollection Query { _parsedValues = value; - if (_features.Collection != null) + if (!IsFeatureCollectionNull()) { if (value == null) { @@ -77,5 +77,12 @@ public FixedQueryFeature(IFeatureCollection features) _features.Initalize(features); } + + private bool IsFeatureCollectionNull() + { + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + // Justification: This code was copied from the ASP.NET sources. A struct instance can be created without calling one of its constructors. + return _features.Collection == null; + } } } diff --git a/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs b/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs index 6d55598a81..7bb694879e 100644 --- a/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs +++ b/src/JsonApiDotNetCore/Middleware/JsonApiMiddleware.cs @@ -125,6 +125,8 @@ private static async Task ValidateContentTypeHeaderAsync(string allowedCon { string contentType = httpContext.Request.ContentType; + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + // Justification: Workaround for https://github.com/dotnet/aspnetcore/issues/32097 (fixed in .NET 6) if (contentType != null && contentType != allowedContentType) { await FlushResponseAsync(httpContext.Response, serializerSettings, new Error(HttpStatusCode.UnsupportedMediaType) @@ -280,9 +282,9 @@ private static string GetCustomRoute(string resourceName, string apiNamespace, H if (resourceName != null) { Endpoint endpoint = httpContext.GetEndpoint(); - var routeAttribute = endpoint.Metadata.GetMetadata(); + var routeAttribute = endpoint?.Metadata.GetMetadata(); - if (routeAttribute != null) + if (routeAttribute != null && httpContext.Request.Path.Value != null) { List trimmedComponents = httpContext.Request.Path.Value.Trim('/').Split('/').ToList(); int resourceNameIndex = trimmedComponents.FindIndex(component => component == resourceName); diff --git a/src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs b/src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs index 1259aa08e5..156510298d 100644 --- a/src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs +++ b/src/JsonApiDotNetCore/Middleware/JsonApiRoutingConvention.cs @@ -33,9 +33,9 @@ public class JsonApiRoutingConvention : IJsonApiRoutingConvention { private readonly IJsonApiOptions _options; private readonly IResourceContextProvider _resourceContextProvider; - private readonly Dictionary _registeredControllerNameByTemplate = new Dictionary(); - private readonly Dictionary _resourceContextPerControllerTypeMap = new Dictionary(); - private readonly Dictionary _controllerPerResourceContextMap = new Dictionary(); + private readonly Dictionary _registeredControllerNameByTemplate = new(); + private readonly Dictionary _resourceContextPerControllerTypeMap = new(); + private readonly Dictionary _controllerPerResourceContextMap = new(); public JsonApiRoutingConvention(IJsonApiOptions options, IResourceContextProvider resourceContextProvider) { diff --git a/src/JsonApiDotNetCore/ObjectExtensions.cs b/src/JsonApiDotNetCore/ObjectExtensions.cs index b1bb1eb4a7..e7351f5527 100644 --- a/src/JsonApiDotNetCore/ObjectExtensions.cs +++ b/src/JsonApiDotNetCore/ObjectExtensions.cs @@ -21,7 +21,7 @@ public static T[] AsArray(this T element) public static List AsList(this T element) { - return new List + return new() { element }; diff --git a/src/JsonApiDotNetCore/Queries/Expressions/IncludeChainConverter.cs b/src/JsonApiDotNetCore/Queries/Expressions/IncludeChainConverter.cs index d3fde6d0cf..d2b3417b99 100644 --- a/src/JsonApiDotNetCore/Queries/Expressions/IncludeChainConverter.cs +++ b/src/JsonApiDotNetCore/Queries/Expressions/IncludeChainConverter.cs @@ -100,9 +100,9 @@ private static void ConvertChainToElement(ResourceFieldChainExpression chain, Mu private sealed class IncludeToChainsConverter : QueryExpressionVisitor { - private readonly Stack _parentRelationshipStack = new Stack(); + private readonly Stack _parentRelationshipStack = new(); - public List Chains { get; } = new List(); + public List Chains { get; } = new(); public override object VisitInclude(IncludeExpression expression, object argument) { diff --git a/src/JsonApiDotNetCore/Queries/Expressions/IncludeExpression.cs b/src/JsonApiDotNetCore/Queries/Expressions/IncludeExpression.cs index 9b72d050e7..54054db8ec 100644 --- a/src/JsonApiDotNetCore/Queries/Expressions/IncludeExpression.cs +++ b/src/JsonApiDotNetCore/Queries/Expressions/IncludeExpression.cs @@ -11,9 +11,9 @@ namespace JsonApiDotNetCore.Queries.Expressions [PublicAPI] public class IncludeExpression : QueryExpression { - private static readonly IncludeChainConverter IncludeChainConverter = new IncludeChainConverter(); + private static readonly IncludeChainConverter IncludeChainConverter = new(); - public static readonly IncludeExpression Empty = new IncludeExpression(); + public static readonly IncludeExpression Empty = new(); public IReadOnlyCollection Elements { get; } diff --git a/src/JsonApiDotNetCore/Queries/Internal/Parsing/IncludeParser.cs b/src/JsonApiDotNetCore/Queries/Internal/Parsing/IncludeParser.cs index e2cc83ceba..30f0a0b819 100644 --- a/src/JsonApiDotNetCore/Queries/Internal/Parsing/IncludeParser.cs +++ b/src/JsonApiDotNetCore/Queries/Internal/Parsing/IncludeParser.cs @@ -11,7 +11,7 @@ namespace JsonApiDotNetCore.Queries.Internal.Parsing [PublicAPI] public class IncludeParser : QueryExpressionParser { - private static readonly IncludeChainConverter IncludeChainConverter = new IncludeChainConverter(); + private static readonly IncludeChainConverter IncludeChainConverter = new(); private readonly Action _validateSingleRelationshipCallback; private ResourceContext _resourceContextInScope; diff --git a/src/JsonApiDotNetCore/Queries/Internal/Parsing/QueryTokenizer.cs b/src/JsonApiDotNetCore/Queries/Internal/Parsing/QueryTokenizer.cs index 04feabd60d..3f49b6c7fe 100644 --- a/src/JsonApiDotNetCore/Queries/Internal/Parsing/QueryTokenizer.cs +++ b/src/JsonApiDotNetCore/Queries/Internal/Parsing/QueryTokenizer.cs @@ -21,7 +21,7 @@ public sealed class QueryTokenizer }); private readonly string _source; - private readonly StringBuilder _textBuffer = new StringBuilder(); + private readonly StringBuilder _textBuffer = new(); private int _offset; private bool _isInQuotedSection; @@ -119,12 +119,12 @@ private bool IsMinusInsideText(TokenKind kind) private char? PeekChar() { - return _offset + 1 < _source.Length ? (char?)_source[_offset + 1] : null; + return _offset + 1 < _source.Length ? _source[_offset + 1] : null; } private static TokenKind? TryGetSingleCharacterTokenKind(char ch) { - return SingleCharacterToTokenKinds.ContainsKey(ch) ? (TokenKind?)SingleCharacterToTokenKinds[ch] : null; + return SingleCharacterToTokenKinds.ContainsKey(ch) ? SingleCharacterToTokenKinds[ch] : null; } private Token ProduceTokenFromTextBuffer(bool isQuotedText) diff --git a/src/JsonApiDotNetCore/Queries/Internal/QueryLayerComposer.cs b/src/JsonApiDotNetCore/Queries/Internal/QueryLayerComposer.cs index 981ea9d71d..070faee6f2 100644 --- a/src/JsonApiDotNetCore/Queries/Internal/QueryLayerComposer.cs +++ b/src/JsonApiDotNetCore/Queries/Internal/QueryLayerComposer.cs @@ -13,7 +13,7 @@ namespace JsonApiDotNetCore.Queries.Internal [PublicAPI] public class QueryLayerComposer : IQueryLayerComposer { - private readonly CollectionConverter _collectionConverter = new CollectionConverter(); + private readonly CollectionConverter _collectionConverter = new(); private readonly IEnumerable _constraintProviders; private readonly IResourceContextProvider _resourceContextProvider; private readonly IResourceDefinitionAccessor _resourceDefinitionAccessor; @@ -409,7 +409,7 @@ public QueryLayer ComposeForHasMany(HasManyAttribute hasManyRelationship, T Filter = leftFilter, Projection = new Dictionary { - [hasManyRelationship] = new QueryLayer(rightResourceContext) + [hasManyRelationship] = new(rightResourceContext) { Filter = rightFilter, Projection = new Dictionary diff --git a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/IncludeClauseBuilder.cs b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/IncludeClauseBuilder.cs index ef3b23ad84..fdcec72778 100644 --- a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/IncludeClauseBuilder.cs +++ b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/IncludeClauseBuilder.cs @@ -15,7 +15,7 @@ namespace JsonApiDotNetCore.Queries.Internal.QueryableBuilding [PublicAPI] public class IncludeClauseBuilder : QueryClauseBuilder { - private static readonly IncludeChainConverter IncludeChainConverter = new IncludeChainConverter(); + private static readonly IncludeChainConverter IncludeChainConverter = new(); private readonly Expression _source; private readonly ResourceContext _resourceContext; diff --git a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaParameterNameFactory.cs b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaParameterNameFactory.cs index 6309c8ac54..c1050a9d8a 100644 --- a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaParameterNameFactory.cs +++ b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/LambdaParameterNameFactory.cs @@ -10,7 +10,7 @@ namespace JsonApiDotNetCore.Queries.Internal.QueryableBuilding [PublicAPI] public sealed class LambdaParameterNameFactory { - private readonly HashSet _namesInScope = new HashSet(); + private readonly HashSet _namesInScope = new(); public LambdaParameterNameScope Create(string typeName) { diff --git a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/SelectClauseBuilder.cs b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/SelectClauseBuilder.cs index 42bf327fdb..a9c229425c 100644 --- a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/SelectClauseBuilder.cs +++ b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/SelectClauseBuilder.cs @@ -21,7 +21,7 @@ namespace JsonApiDotNetCore.Queries.Internal.QueryableBuilding [PublicAPI] public class SelectClauseBuilder : QueryClauseBuilder { - private static readonly CollectionConverter CollectionConverter = new CollectionConverter(); + private static readonly CollectionConverter CollectionConverter = new(); private static readonly ConstantExpression NullConstant = Expression.Constant(null); private readonly Expression _source; diff --git a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/WhereClauseBuilder.cs b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/WhereClauseBuilder.cs index 191e911cf9..42fcfe8e23 100644 --- a/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/WhereClauseBuilder.cs +++ b/src/JsonApiDotNetCore/Queries/Internal/QueryableBuilding/WhereClauseBuilder.cs @@ -18,7 +18,7 @@ namespace JsonApiDotNetCore.Queries.Internal.QueryableBuilding [PublicAPI] public class WhereClauseBuilder : QueryClauseBuilder { - private static readonly CollectionConverter CollectionConverter = new CollectionConverter(); + private static readonly CollectionConverter CollectionConverter = new(); private static readonly ConstantExpression NullConstant = Expression.Constant(null); private readonly Expression _source; diff --git a/src/JsonApiDotNetCore/QueryStrings/Internal/FilterQueryStringParameterReader.cs b/src/JsonApiDotNetCore/QueryStrings/Internal/FilterQueryStringParameterReader.cs index bcfce7fcd5..a7732f108a 100644 --- a/src/JsonApiDotNetCore/QueryStrings/Internal/FilterQueryStringParameterReader.cs +++ b/src/JsonApiDotNetCore/QueryStrings/Internal/FilterQueryStringParameterReader.cs @@ -18,16 +18,13 @@ namespace JsonApiDotNetCore.QueryStrings.Internal [PublicAPI] public class FilterQueryStringParameterReader : QueryStringParameterReader, IFilterQueryStringParameterReader { - private static readonly LegacyFilterNotationConverter LegacyConverter = new LegacyFilterNotationConverter(); + private static readonly LegacyFilterNotationConverter LegacyConverter = new(); private readonly IJsonApiOptions _options; private readonly QueryStringParameterScopeParser _scopeParser; private readonly FilterParser _filterParser; - - private readonly List _filtersInGlobalScope = new List(); - - private readonly Dictionary> _filtersPerScope = - new Dictionary>(); + private readonly List _filtersInGlobalScope = new(); + private readonly Dictionary> _filtersPerScope = new(); private string _lastParameterName; diff --git a/src/JsonApiDotNetCore/QueryStrings/Internal/LegacyFilterNotationConverter.cs b/src/JsonApiDotNetCore/QueryStrings/Internal/LegacyFilterNotationConverter.cs index 6be267289d..e65e52a8fd 100644 --- a/src/JsonApiDotNetCore/QueryStrings/Internal/LegacyFilterNotationConverter.cs +++ b/src/JsonApiDotNetCore/QueryStrings/Internal/LegacyFilterNotationConverter.cs @@ -17,7 +17,7 @@ public sealed class LegacyFilterNotationConverter private const string InPrefix = "in:"; private const string NotInPrefix = "nin:"; - private static readonly Dictionary PrefixConversionTable = new Dictionary + private static readonly Dictionary PrefixConversionTable = new() { ["eq:"] = Keywords.Equals, ["lt:"] = Keywords.LessThan, diff --git a/src/JsonApiDotNetCore/QueryStrings/Internal/PaginationQueryStringParameterReader.cs b/src/JsonApiDotNetCore/QueryStrings/Internal/PaginationQueryStringParameterReader.cs index c9b9813a5c..c8d61fc7ba 100644 --- a/src/JsonApiDotNetCore/QueryStrings/Internal/PaginationQueryStringParameterReader.cs +++ b/src/JsonApiDotNetCore/QueryStrings/Internal/PaginationQueryStringParameterReader.cs @@ -144,10 +144,8 @@ public virtual IReadOnlyCollection GetConstraints() private sealed class PaginationContext { - private readonly MutablePaginationEntry _globalScope = new MutablePaginationEntry(); - - private readonly Dictionary _nestedScopes = - new Dictionary(); + private readonly MutablePaginationEntry _globalScope = new(); + private readonly Dictionary _nestedScopes = new(); public MutablePaginationEntry ResolveEntryInScope(ResourceFieldChainExpression scope) { diff --git a/src/JsonApiDotNetCore/QueryStrings/Internal/RequestQueryStringAccessor.cs b/src/JsonApiDotNetCore/QueryStrings/Internal/RequestQueryStringAccessor.cs index d53d01b054..fef422d2ac 100644 --- a/src/JsonApiDotNetCore/QueryStrings/Internal/RequestQueryStringAccessor.cs +++ b/src/JsonApiDotNetCore/QueryStrings/Internal/RequestQueryStringAccessor.cs @@ -7,7 +7,7 @@ internal sealed class RequestQueryStringAccessor : IRequestQueryStringAccessor { private readonly IHttpContextAccessor _httpContextAccessor; - public IQueryCollection Query => _httpContextAccessor.HttpContext.Request.Query; + public IQueryCollection Query => _httpContextAccessor.HttpContext!.Request.Query; public RequestQueryStringAccessor(IHttpContextAccessor httpContextAccessor) { diff --git a/src/JsonApiDotNetCore/QueryStrings/Internal/ResourceDefinitionQueryableParameterReader.cs b/src/JsonApiDotNetCore/QueryStrings/Internal/ResourceDefinitionQueryableParameterReader.cs index d5eb7a4110..5a3e1cab3c 100644 --- a/src/JsonApiDotNetCore/QueryStrings/Internal/ResourceDefinitionQueryableParameterReader.cs +++ b/src/JsonApiDotNetCore/QueryStrings/Internal/ResourceDefinitionQueryableParameterReader.cs @@ -17,7 +17,7 @@ public class ResourceDefinitionQueryableParameterReader : IResourceDefinitionQue { private readonly IJsonApiRequest _request; private readonly IResourceDefinitionAccessor _resourceDefinitionAccessor; - private readonly List _constraints = new List(); + private readonly List _constraints = new(); public ResourceDefinitionQueryableParameterReader(IJsonApiRequest request, IResourceDefinitionAccessor resourceDefinitionAccessor) { diff --git a/src/JsonApiDotNetCore/QueryStrings/Internal/SortQueryStringParameterReader.cs b/src/JsonApiDotNetCore/QueryStrings/Internal/SortQueryStringParameterReader.cs index 058fa6817c..e06b8431e1 100644 --- a/src/JsonApiDotNetCore/QueryStrings/Internal/SortQueryStringParameterReader.cs +++ b/src/JsonApiDotNetCore/QueryStrings/Internal/SortQueryStringParameterReader.cs @@ -18,7 +18,7 @@ public class SortQueryStringParameterReader : QueryStringParameterReader, ISortQ { private readonly QueryStringParameterScopeParser _scopeParser; private readonly SortParser _sortParser; - private readonly List _constraints = new List(); + private readonly List _constraints = new(); private string _lastParameterName; public SortQueryStringParameterReader(IJsonApiRequest request, IResourceContextProvider resourceContextProvider) diff --git a/src/JsonApiDotNetCore/QueryStrings/Internal/SparseFieldSetQueryStringParameterReader.cs b/src/JsonApiDotNetCore/QueryStrings/Internal/SparseFieldSetQueryStringParameterReader.cs index f9e804797c..1355689bcd 100644 --- a/src/JsonApiDotNetCore/QueryStrings/Internal/SparseFieldSetQueryStringParameterReader.cs +++ b/src/JsonApiDotNetCore/QueryStrings/Internal/SparseFieldSetQueryStringParameterReader.cs @@ -20,7 +20,7 @@ public class SparseFieldSetQueryStringParameterReader : QueryStringParameterRead { private readonly SparseFieldTypeParser _sparseFieldTypeParser; private readonly SparseFieldSetParser _sparseFieldSetParser; - private readonly Dictionary _sparseFieldTable = new Dictionary(); + private readonly Dictionary _sparseFieldTable = new(); private string _lastParameterName; /// diff --git a/src/JsonApiDotNetCore/Repositories/EntityFrameworkCoreRepository.cs b/src/JsonApiDotNetCore/Repositories/EntityFrameworkCoreRepository.cs index 397eea4a5b..47ff3f9766 100644 --- a/src/JsonApiDotNetCore/Repositories/EntityFrameworkCoreRepository.cs +++ b/src/JsonApiDotNetCore/Repositories/EntityFrameworkCoreRepository.cs @@ -28,7 +28,7 @@ namespace JsonApiDotNetCore.Repositories public class EntityFrameworkCoreRepository : IResourceRepository, IRepositorySupportsTransaction where TResource : class, IIdentifiable { - private readonly CollectionConverter _collectionConverter = new CollectionConverter(); + private readonly CollectionConverter _collectionConverter = new(); private readonly ITargetedFields _targetedFields; private readonly DbContext _dbContext; private readonly IResourceGraph _resourceGraph; @@ -374,7 +374,7 @@ private bool HasForeignKeyAtLeftSide(RelationshipAttribute relationship) if (relationship is HasOneAttribute) { INavigation navigation = TryGetNavigation(relationship); - return navigation?.IsDependentToPrincipal() ?? false; + return navigation?.IsOnDependent ?? false; } return false; @@ -499,7 +499,7 @@ private object EnsureRelationshipValueToAssignIsTracked(object rightValue, Type IIdentifiable[] rightResourcesTracked = rightResources.Select(collector.CaptureExisting).ToArray(); return rightValue is IEnumerable - ? (object)_collectionConverter.CopyToTypedCollection(rightResourcesTracked, relationshipPropertyType) + ? _collectionConverter.CopyToTypedCollection(rightResourcesTracked, relationshipPropertyType) : rightResourcesTracked.Single(); } diff --git a/src/JsonApiDotNetCore/Repositories/PlaceholderResourceCollector.cs b/src/JsonApiDotNetCore/Repositories/PlaceholderResourceCollector.cs index 51efa96aae..ed8c7d4a49 100644 --- a/src/JsonApiDotNetCore/Repositories/PlaceholderResourceCollector.cs +++ b/src/JsonApiDotNetCore/Repositories/PlaceholderResourceCollector.cs @@ -16,7 +16,7 @@ public sealed class PlaceholderResourceCollector : IDisposable { private readonly IResourceFactory _resourceFactory; private readonly DbContext _dbContext; - private readonly List _resources = new List(); + private readonly List _resources = new(); public PlaceholderResourceCollector(IResourceFactory resourceFactory, DbContext dbContext) { diff --git a/src/JsonApiDotNetCore/Resources/Annotations/HasManyThroughAttribute.cs b/src/JsonApiDotNetCore/Resources/Annotations/HasManyThroughAttribute.cs index cfe180c761..1ad1a86379 100644 --- a/src/JsonApiDotNetCore/Resources/Annotations/HasManyThroughAttribute.cs +++ b/src/JsonApiDotNetCore/Resources/Annotations/HasManyThroughAttribute.cs @@ -45,7 +45,7 @@ namespace JsonApiDotNetCore.Resources.Annotations [AttributeUsage(AttributeTargets.Property)] public sealed class HasManyThroughAttribute : HasManyAttribute { - private static readonly CollectionConverter CollectionConverter = new CollectionConverter(); + private static readonly CollectionConverter CollectionConverter = new(); /// /// The name of the join property on the parent resource. In the example described above, this would be "ArticleTags". diff --git a/src/JsonApiDotNetCore/Resources/IdentifiableComparer.cs b/src/JsonApiDotNetCore/Resources/IdentifiableComparer.cs index 332995b294..5cffe890c2 100644 --- a/src/JsonApiDotNetCore/Resources/IdentifiableComparer.cs +++ b/src/JsonApiDotNetCore/Resources/IdentifiableComparer.cs @@ -11,7 +11,7 @@ namespace JsonApiDotNetCore.Resources [PublicAPI] public sealed class IdentifiableComparer : IEqualityComparer { - public static readonly IdentifiableComparer Instance = new IdentifiableComparer(); + public static readonly IdentifiableComparer Instance = new(); private IdentifiableComparer() { diff --git a/src/JsonApiDotNetCore/Resources/OperationContainer.cs b/src/JsonApiDotNetCore/Resources/OperationContainer.cs index da2f64776c..122556d816 100644 --- a/src/JsonApiDotNetCore/Resources/OperationContainer.cs +++ b/src/JsonApiDotNetCore/Resources/OperationContainer.cs @@ -11,7 +11,7 @@ namespace JsonApiDotNetCore.Resources [PublicAPI] public sealed class OperationContainer { - private static readonly CollectionConverter CollectionConverter = new CollectionConverter(); + private static readonly CollectionConverter CollectionConverter = new(); public OperationKind Kind { get; } public IIdentifiable Resource { get; } diff --git a/src/JsonApiDotNetCore/Serialization/BaseDeserializer.cs b/src/JsonApiDotNetCore/Serialization/BaseDeserializer.cs index 6d7bccfe47..8cf2653f9e 100644 --- a/src/JsonApiDotNetCore/Serialization/BaseDeserializer.cs +++ b/src/JsonApiDotNetCore/Serialization/BaseDeserializer.cs @@ -22,7 +22,7 @@ namespace JsonApiDotNetCore.Serialization [PublicAPI] public abstract class BaseDeserializer { - private protected static readonly CollectionConverter CollectionConverter = new CollectionConverter(); + private protected static readonly CollectionConverter CollectionConverter = new(); protected IResourceContextProvider ResourceContextProvider { get; } protected IResourceFactory ResourceFactory { get; } diff --git a/src/JsonApiDotNetCore/Serialization/Building/LinkBuilder.cs b/src/JsonApiDotNetCore/Serialization/Building/LinkBuilder.cs index ea29bfa4d1..542923368c 100644 --- a/src/JsonApiDotNetCore/Serialization/Building/LinkBuilder.cs +++ b/src/JsonApiDotNetCore/Serialization/Building/LinkBuilder.cs @@ -102,8 +102,8 @@ private bool ShouldIncludeTopLevelLink(LinkTypes linkType, ResourceContext resou private string GetLinkForTopLevelSelf() { return _options.UseRelativeLinks - ? _httpContextAccessor.HttpContext.Request.GetEncodedPathAndQuery() - : _httpContextAccessor.HttpContext.Request.GetEncodedUrl(); + ? _httpContextAccessor.HttpContext!.Request.GetEncodedPathAndQuery() + : _httpContextAccessor.HttpContext!.Request.GetEncodedUrl(); } private void SetPaginationInTopLevelLinks(ResourceContext requestContext, TopLevelLinks links) @@ -133,7 +133,7 @@ private void SetPaginationInTopLevelLinks(ResourceContext requestContext, TopLev private string CalculatePageSizeValue(PageSize topPageSize, ResourceContext requestContext) { - string pageSizeParameterValue = _httpContextAccessor.HttpContext.Request.Query[PageSizeParameterName]; + string pageSizeParameterValue = _httpContextAccessor.HttpContext!.Request.Query[PageSizeParameterName]; PageSize newTopPageSize = Equals(topPageSize, _options.DefaultPageSize) ? null : topPageSize; return ChangeTopPageSize(pageSizeParameterValue, newTopPageSize, requestContext); @@ -188,7 +188,7 @@ private string GetLinkForPagination(int pageOffset, string pageSizeValue) { string queryStringValue = GetQueryStringInPaginationLink(pageOffset, pageSizeValue); - var builder = new UriBuilder(_httpContextAccessor.HttpContext.Request.GetEncodedUrl()) + var builder = new UriBuilder(_httpContextAccessor.HttpContext!.Request.GetEncodedUrl()) { Query = queryStringValue }; @@ -200,7 +200,7 @@ private string GetLinkForPagination(int pageOffset, string pageSizeValue) private string GetQueryStringInPaginationLink(int pageOffset, string pageSizeValue) { IDictionary parameters = - _httpContextAccessor.HttpContext.Request.Query.ToDictionary(pair => pair.Key, pair => pair.Value.ToString()); + _httpContextAccessor.HttpContext!.Request.Query.ToDictionary(pair => pair.Key, pair => pair.Value.ToString()); if (pageSizeValue == null) { @@ -311,7 +311,7 @@ private IDictionary GetRouteValues(string primaryId, string rela // By default, we copy all route parameters from the *current* endpoint, which helps in case all endpoints have the same // set of non-standard parameters. There is no way we can know which non-standard parameters a *different* endpoint needs, // so users must override RenderLinkForAction to supply them, if applicable. - RouteValueDictionary routeValues = _httpContextAccessor.HttpContext.Request.RouteValues; + RouteValueDictionary routeValues = _httpContextAccessor.HttpContext!.Request.RouteValues; routeValues["id"] = primaryId; routeValues["relationshipName"] = relationshipName; diff --git a/src/JsonApiDotNetCore/Serialization/Building/MetaBuilder.cs b/src/JsonApiDotNetCore/Serialization/Building/MetaBuilder.cs index 6d35b8385b..23ac2d0989 100644 --- a/src/JsonApiDotNetCore/Serialization/Building/MetaBuilder.cs +++ b/src/JsonApiDotNetCore/Serialization/Building/MetaBuilder.cs @@ -14,7 +14,7 @@ public class MetaBuilder : IMetaBuilder private readonly IJsonApiOptions _options; private readonly IResponseMeta _responseMeta; - private Dictionary _meta = new Dictionary(); + private Dictionary _meta = new(); public MetaBuilder(IPaginationContext paginationContext, IJsonApiOptions options, IResponseMeta responseMeta) { diff --git a/src/JsonApiDotNetCore/Serialization/Building/ResourceIdentifierObjectComparer.cs b/src/JsonApiDotNetCore/Serialization/Building/ResourceIdentifierObjectComparer.cs index b23828581d..65760804c2 100644 --- a/src/JsonApiDotNetCore/Serialization/Building/ResourceIdentifierObjectComparer.cs +++ b/src/JsonApiDotNetCore/Serialization/Building/ResourceIdentifierObjectComparer.cs @@ -6,7 +6,7 @@ namespace JsonApiDotNetCore.Serialization.Building { internal sealed class ResourceIdentifierObjectComparer : IEqualityComparer { - public static readonly ResourceIdentifierObjectComparer Instance = new ResourceIdentifierObjectComparer(); + public static readonly ResourceIdentifierObjectComparer Instance = new(); private ResourceIdentifierObjectComparer() { diff --git a/src/JsonApiDotNetCore/Serialization/Building/ResourceObjectBuilder.cs b/src/JsonApiDotNetCore/Serialization/Building/ResourceObjectBuilder.cs index 3f9e0b3a8e..d6633910ba 100644 --- a/src/JsonApiDotNetCore/Serialization/Building/ResourceObjectBuilder.cs +++ b/src/JsonApiDotNetCore/Serialization/Building/ResourceObjectBuilder.cs @@ -14,7 +14,7 @@ namespace JsonApiDotNetCore.Serialization.Building [PublicAPI] public class ResourceObjectBuilder : IResourceObjectBuilder { - private static readonly CollectionConverter CollectionConverter = new CollectionConverter(); + private static readonly CollectionConverter CollectionConverter = new(); private readonly ResourceObjectBuilderSettings _settings; protected IResourceContextProvider ResourceContextProvider { get; } @@ -88,7 +88,7 @@ protected object GetRelatedResourceLinkage(RelationshipAttribute relationship, I ArgumentGuard.NotNull(resource, nameof(resource)); return relationship is HasOneAttribute hasOne - ? (object)GetRelatedResourceLinkageForHasOne(hasOne, resource) + ? GetRelatedResourceLinkageForHasOne(hasOne, resource) : GetRelatedResourceLinkageForHasMany((HasManyAttribute)relationship, resource); } diff --git a/src/JsonApiDotNetCore/Serialization/Building/ResourceObjectBuilderSettingsProvider.cs b/src/JsonApiDotNetCore/Serialization/Building/ResourceObjectBuilderSettingsProvider.cs index d28a7591eb..04a5128aed 100644 --- a/src/JsonApiDotNetCore/Serialization/Building/ResourceObjectBuilderSettingsProvider.cs +++ b/src/JsonApiDotNetCore/Serialization/Building/ResourceObjectBuilderSettingsProvider.cs @@ -24,7 +24,7 @@ public ResourceObjectBuilderSettingsProvider(IDefaultsQueryStringParameterReader /// public ResourceObjectBuilderSettings Get() { - return new ResourceObjectBuilderSettings(_nullsReader.SerializerNullValueHandling, _defaultsReader.SerializerDefaultValueHandling); + return new(_nullsReader.SerializerNullValueHandling, _defaultsReader.SerializerDefaultValueHandling); } } } diff --git a/src/JsonApiDotNetCore/Serialization/Building/ResponseResourceObjectBuilder.cs b/src/JsonApiDotNetCore/Serialization/Building/ResponseResourceObjectBuilder.cs index 62e36f1e37..02aebcdc2e 100644 --- a/src/JsonApiDotNetCore/Serialization/Building/ResponseResourceObjectBuilder.cs +++ b/src/JsonApiDotNetCore/Serialization/Building/ResponseResourceObjectBuilder.cs @@ -14,7 +14,7 @@ namespace JsonApiDotNetCore.Serialization.Building [PublicAPI] public class ResponseResourceObjectBuilder : ResourceObjectBuilder { - private static readonly IncludeChainConverter IncludeChainConverter = new IncludeChainConverter(); + private static readonly IncludeChainConverter IncludeChainConverter = new(); private readonly ILinkBuilder _linkBuilder; private readonly IIncludedResourceObjectBuilder _includedBuilder; diff --git a/src/JsonApiDotNetCore/Serialization/Client/Internal/RequestSerializer.cs b/src/JsonApiDotNetCore/Serialization/Client/Internal/RequestSerializer.cs index 73f0964a9f..8faf12c933 100644 --- a/src/JsonApiDotNetCore/Serialization/Client/Internal/RequestSerializer.cs +++ b/src/JsonApiDotNetCore/Serialization/Client/Internal/RequestSerializer.cs @@ -18,7 +18,7 @@ namespace JsonApiDotNetCore.Serialization.Client.Internal public class RequestSerializer : BaseSerializer, IRequestSerializer { private readonly IResourceGraph _resourceGraph; - private readonly JsonSerializerSettings _jsonSerializerSettings = new JsonSerializerSettings(); + private readonly JsonSerializerSettings _jsonSerializerSettings = new(); private Type _currentTargetedResource; /// diff --git a/src/JsonApiDotNetCore/Serialization/JsonApiReader.cs b/src/JsonApiDotNetCore/Serialization/JsonApiReader.cs index bcf0e5bcaa..1841da6987 100644 --- a/src/JsonApiDotNetCore/Serialization/JsonApiReader.cs +++ b/src/JsonApiDotNetCore/Serialization/JsonApiReader.cs @@ -81,6 +81,8 @@ public async Task ReadAsync(InputFormatterContext context) ValidateRequestBody(model, body, context.HttpContext.Request); } + // ReSharper disable once AssignNullToNotNullAttribute + // Justification: According to JSON:API we must return 200 OK without a body in some cases. return await InputFormatterResult.SuccessAsync(model); } diff --git a/src/JsonApiDotNetCore/Serialization/Objects/Error.cs b/src/JsonApiDotNetCore/Serialization/Objects/Error.cs index b33f79bba8..f3afb594e8 100644 --- a/src/JsonApiDotNetCore/Serialization/Objects/Error.cs +++ b/src/JsonApiDotNetCore/Serialization/Objects/Error.cs @@ -23,7 +23,7 @@ public sealed class Error /// A link that leads to further details about this particular occurrence of the problem. /// [JsonProperty] - public ErrorLinks Links { get; set; } = new ErrorLinks(); + public ErrorLinks Links { get; set; } = new(); /// /// The HTTP status code applicable to this problem. @@ -61,13 +61,13 @@ public string Status /// An object containing references to the source of the error. /// [JsonProperty] - public ErrorSource Source { get; set; } = new ErrorSource(); + public ErrorSource Source { get; set; } = new(); /// /// An object containing non-standard meta-information (key/value pairs) about the error. /// [JsonProperty] - public ErrorMeta Meta { get; set; } = new ErrorMeta(); + public ErrorMeta Meta { get; set; } = new(); public Error(HttpStatusCode statusCode) { diff --git a/src/JsonApiDotNetCore/Serialization/RequestDeserializer.cs b/src/JsonApiDotNetCore/Serialization/RequestDeserializer.cs index d013736ce7..d7ea3aabc1 100644 --- a/src/JsonApiDotNetCore/Serialization/RequestDeserializer.cs +++ b/src/JsonApiDotNetCore/Serialization/RequestDeserializer.cs @@ -146,7 +146,7 @@ private OperationKind GetOperationKind(AtomicOperationObject operation) { case AtomicOperationCode.Add: { - if (operation.Ref != null && operation.Ref.Relationship == null) + if (operation.Ref is { Relationship: null }) { throw new JsonApiSerializationException("The 'ref.relationship' element is required.", null, atomicOperationIndex: AtomicOperationIndex); @@ -523,14 +523,14 @@ private bool IsCreatingResource() { return _request.Kind == EndpointKind.AtomicOperations ? _request.OperationKind == OperationKind.CreateResource - : _request.Kind == EndpointKind.Primary && _httpContextAccessor.HttpContext.Request.Method == HttpMethod.Post.Method; + : _request.Kind == EndpointKind.Primary && _httpContextAccessor.HttpContext!.Request.Method == HttpMethod.Post.Method; } private bool IsUpdatingResource() { return _request.Kind == EndpointKind.AtomicOperations ? _request.OperationKind == OperationKind.UpdateResource - : _request.Kind == EndpointKind.Primary && _httpContextAccessor.HttpContext.Request.Method == HttpMethod.Patch.Method; + : _request.Kind == EndpointKind.Primary && _httpContextAccessor.HttpContext!.Request.Method == HttpMethod.Patch.Method; } } } diff --git a/src/JsonApiDotNetCore/Services/JsonApiResourceService.cs b/src/JsonApiDotNetCore/Services/JsonApiResourceService.cs index 8500557c1b..5a8c4efe91 100644 --- a/src/JsonApiDotNetCore/Services/JsonApiResourceService.cs +++ b/src/JsonApiDotNetCore/Services/JsonApiResourceService.cs @@ -23,7 +23,7 @@ namespace JsonApiDotNetCore.Services public class JsonApiResourceService : IResourceService where TResource : class, IIdentifiable { - private readonly CollectionConverter _collectionConverter = new CollectionConverter(); + private readonly CollectionConverter _collectionConverter = new(); private readonly IResourceRepositoryAccessor _repositoryAccessor; private readonly IQueryLayerComposer _queryLayerComposer; private readonly IPaginationContext _paginationContext; diff --git a/test/DiscoveryTests/ServiceDiscoveryFacadeTests.cs b/test/DiscoveryTests/ServiceDiscoveryFacadeTests.cs index dcadd46ce2..6f8f45151d 100644 --- a/test/DiscoveryTests/ServiceDiscoveryFacadeTests.cs +++ b/test/DiscoveryTests/ServiceDiscoveryFacadeTests.cs @@ -19,7 +19,7 @@ public sealed class ServiceDiscoveryFacadeTests { private static readonly NullLoggerFactory LoggerFactory = NullLoggerFactory.Instance; private readonly IServiceCollection _services = new ServiceCollection(); - private readonly JsonApiOptions _options = new JsonApiOptions(); + private readonly JsonApiOptions _options = new(); private readonly ResourceGraphBuilder _resourceGraphBuilder; public ServiceDiscoveryFacadeTests() diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Archiving/ArchiveTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Archiving/ArchiveTests.cs index b7700f5ffd..cb1fe6f8b2 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Archiving/ArchiveTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Archiving/ArchiveTests.cs @@ -16,7 +16,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.Archiving public sealed class ArchiveTests : IClassFixture, TelevisionDbContext>> { private readonly ExampleIntegrationTestContext, TelevisionDbContext> _testContext; - private readonly TelevisionFakers _fakers = new TelevisionFakers(); + private readonly TelevisionFakers _fakers = new(); public ArchiveTests(ExampleIntegrationTestContext, TelevisionDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Archiving/TelevisionFakers.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Archiving/TelevisionFakers.cs index 288c75bdbf..aa51ac4c11 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Archiving/TelevisionFakers.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Archiving/TelevisionFakers.cs @@ -9,24 +9,24 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.Archiving { internal sealed class TelevisionFakers : FakerContainer { - private readonly Lazy> _lazyTelevisionNetworkFaker = new Lazy>(() => + private readonly Lazy> _lazyTelevisionNetworkFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(network => network.Name, faker => faker.Company.CompanyName())); - private readonly Lazy> _lazyTelevisionStationFaker = new Lazy>(() => + private readonly Lazy> _lazyTelevisionStationFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(station => station.Name, faker => faker.Company.CompanyName())); - private readonly Lazy> _lazyTelevisionBroadcastFaker = new Lazy>(() => + private readonly Lazy> _lazyTelevisionBroadcastFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(broadcast => broadcast.Title, faker => faker.Lorem.Sentence()) .RuleFor(broadcast => broadcast.AiredAt, faker => faker.Date.PastOffset()) .RuleFor(broadcast => broadcast.ArchivedAt, faker => faker.Date.RecentOffset())); - private readonly Lazy> _lazyBroadcastCommentFaker = new Lazy>(() => + private readonly Lazy> _lazyBroadcastCommentFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(comment => comment.Text, faker => faker.Lorem.Paragraph()) diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Controllers/AtomicConstrainedOperationsControllerTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Controllers/AtomicConstrainedOperationsControllerTests.cs index 243e07294d..4fa22a0900 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Controllers/AtomicConstrainedOperationsControllerTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Controllers/AtomicConstrainedOperationsControllerTests.cs @@ -13,7 +13,7 @@ public sealed class AtomicConstrainedOperationsControllerTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicConstrainedOperationsControllerTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { @@ -168,7 +168,7 @@ public async Task Cannot_add_to_ToMany_relationship_for_matching_resource_type() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingTrack, existingPerformer); + dbContext.AddInRange(existingTrack, existingPerformer); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs index ae864c878a..71fb5bce14 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs @@ -18,7 +18,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.AtomicOperations.Creati public sealed class AtomicCreateResourceTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicCreateResourceTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { @@ -720,7 +720,7 @@ public async Task Can_create_resource_with_attributes_and_multiple_relationship_ await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingLyric, existingCompany, existingPerformer); + dbContext.AddInRange(existingLyric, existingCompany, existingPerformer); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs index 3e40fa3094..cf0a53bf70 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs @@ -17,7 +17,7 @@ public sealed class AtomicCreateResourceWithClientGeneratedIdTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicCreateResourceWithClientGeneratedIdTests( ExampleIntegrationTestContext, OperationsDbContext> testContext) diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToManyRelationshipTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToManyRelationshipTests.cs index 3f910178ae..4273f2e10e 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToManyRelationshipTests.cs @@ -17,7 +17,7 @@ public sealed class AtomicCreateResourceWithToManyRelationshipTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicCreateResourceWithToManyRelationshipTests( ExampleIntegrationTestContext, OperationsDbContext> testContext) diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs index 659f2abf28..0af833382f 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs @@ -19,7 +19,7 @@ public sealed class AtomicCreateResourceWithToOneRelationshipTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicCreateResourceWithToOneRelationshipTests( ExampleIntegrationTestContext, OperationsDbContext> testContext) diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Deleting/AtomicDeleteResourceTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Deleting/AtomicDeleteResourceTests.cs index 360a39de53..116d8491fb 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Deleting/AtomicDeleteResourceTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Deleting/AtomicDeleteResourceTests.cs @@ -17,7 +17,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.AtomicOperations.Deleti public sealed class AtomicDeleteResourceTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicDeleteResourceTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Links/AtomicAbsoluteLinksTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Links/AtomicAbsoluteLinksTests.cs index d8dc20a58d..97af626686 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Links/AtomicAbsoluteLinksTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Links/AtomicAbsoluteLinksTests.cs @@ -17,7 +17,7 @@ public sealed class AtomicAbsoluteLinksTests : IClassFixture, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicAbsoluteLinksTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { @@ -44,7 +44,7 @@ public async Task Update_resource_with_side_effects_returns_absolute_links() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingLanguage, existingCompany); + dbContext.AddInRange(existingLanguage, existingCompany); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/LocalIds/AtomicLocalIdTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/LocalIds/AtomicLocalIdTests.cs index 0481b4c253..8d44db11eb 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/LocalIds/AtomicLocalIdTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/LocalIds/AtomicLocalIdTests.cs @@ -16,7 +16,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.AtomicOperations.LocalI public sealed class AtomicLocalIdTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicLocalIdTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Meta/AtomicResourceMetaTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Meta/AtomicResourceMetaTests.cs index bae079ffcb..d18a713ba7 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Meta/AtomicResourceMetaTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Meta/AtomicResourceMetaTests.cs @@ -16,7 +16,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.AtomicOperations.Meta public sealed class AtomicResourceMetaTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicResourceMetaTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Meta/AtomicResponseMetaTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Meta/AtomicResponseMetaTests.cs index facb8dc4a9..c784b63e36 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Meta/AtomicResponseMetaTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Meta/AtomicResponseMetaTests.cs @@ -18,7 +18,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.AtomicOperations.Meta public sealed class AtomicResponseMetaTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicResponseMetaTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Mixed/AtomicSerializationTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Mixed/AtomicSerializationTests.cs index c9127a1158..39806aee32 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Mixed/AtomicSerializationTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Mixed/AtomicSerializationTests.cs @@ -15,7 +15,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.AtomicOperations.Mixed public sealed class AtomicSerializationTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicSerializationTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/ModelStateValidation/AtomicModelStateValidationTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/ModelStateValidation/AtomicModelStateValidationTests.cs index a86bef8595..e24be429e1 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/ModelStateValidation/AtomicModelStateValidationTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/ModelStateValidation/AtomicModelStateValidationTests.cs @@ -15,7 +15,7 @@ public sealed class AtomicModelStateValidationTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicModelStateValidationTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { @@ -264,7 +264,7 @@ public async Task Can_update_resource_with_annotated_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingPlaylist, existingTrack); + dbContext.AddInRange(existingPlaylist, existingTrack); await dbContext.SaveChangesAsync(); }); @@ -335,7 +335,7 @@ public async Task Can_update_ToOne_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingTrack, existingCompany); + dbContext.AddInRange(existingTrack, existingCompany); await dbContext.SaveChangesAsync(); }); @@ -389,7 +389,7 @@ public async Task Can_update_ToMany_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingPlaylist, existingTrack); + dbContext.AddInRange(existingPlaylist, existingTrack); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/OperationsFakers.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/OperationsFakers.cs index 546cb84b03..7589a07792 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/OperationsFakers.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/OperationsFakers.cs @@ -13,18 +13,18 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.AtomicOperations internal sealed class OperationsFakers : FakerContainer { private static readonly Lazy> LazyLanguageIsoCodes = - new Lazy>(() => CultureInfo + new(() => CultureInfo .GetCultures(CultureTypes.NeutralCultures) .Where(culture => !string.IsNullOrEmpty(culture.Name)) .Select(culture => culture.Name) .ToArray()); - private readonly Lazy> _lazyPlaylistFaker = new Lazy>(() => + private readonly Lazy> _lazyPlaylistFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(playlist => playlist.Name, faker => faker.Lorem.Sentence())); - private readonly Lazy> _lazyMusicTrackFaker = new Lazy>(() => + private readonly Lazy> _lazyMusicTrackFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(musicTrack => musicTrack.Title, faker => faker.Lorem.Word()) @@ -32,24 +32,24 @@ internal sealed class OperationsFakers : FakerContainer .RuleFor(musicTrack => musicTrack.Genre, faker => faker.Lorem.Word()) .RuleFor(musicTrack => musicTrack.ReleasedAt, faker => faker.Date.PastOffset())); - private readonly Lazy> _lazyLyricFaker = new Lazy>(() => + private readonly Lazy> _lazyLyricFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(lyric => lyric.Text, faker => faker.Lorem.Text()) .RuleFor(lyric => lyric.Format, "LRC")); - private readonly Lazy> _lazyTextLanguageFaker = new Lazy>(() => + private readonly Lazy> _lazyTextLanguageFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(textLanguage => textLanguage.IsoCode, faker => faker.PickRandom(LazyLanguageIsoCodes.Value))); - private readonly Lazy> _lazyPerformerFaker = new Lazy>(() => + private readonly Lazy> _lazyPerformerFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(performer => performer.ArtistName, faker => faker.Name.FullName()) .RuleFor(performer => performer.BornAt, faker => faker.Date.PastOffset())); - private readonly Lazy> _lazyRecordCompanyFaker = new Lazy>(() => + private readonly Lazy> _lazyRecordCompanyFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(recordCompany => recordCompany.Name, faker => faker.Company.CompanyName()) diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/QueryStrings/AtomicQueryStringTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/QueryStrings/AtomicQueryStringTests.cs index 63e0d007e8..9cdfccf3b6 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/QueryStrings/AtomicQueryStringTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/QueryStrings/AtomicQueryStringTests.cs @@ -21,7 +21,7 @@ public sealed class AtomicQueryStringTests : IClassFixture, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicQueryStringTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/QueryStrings/MusicTrackReleaseDefinition.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/QueryStrings/MusicTrackReleaseDefinition.cs index 857f68ef25..ac3c4b12a3 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/QueryStrings/MusicTrackReleaseDefinition.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/QueryStrings/MusicTrackReleaseDefinition.cs @@ -24,7 +24,7 @@ public MusicTrackReleaseDefinition(IResourceGraph resourceGraph, ISystemClock sy public override QueryStringParameterHandlers OnRegisterQueryableHandlersForQueryStringParameters() { - return new QueryStringParameterHandlers + return new() { ["isRecentlyReleased"] = FilterOnRecentlyReleased }; diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/ResourceDefinitions/Serialization/AtomicSerializationResourceDefinitionTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/ResourceDefinitions/Serialization/AtomicSerializationResourceDefinitionTests.cs index c0e2408d63..a2cc6a5347 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/ResourceDefinitions/Serialization/AtomicSerializationResourceDefinitionTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/ResourceDefinitions/Serialization/AtomicSerializationResourceDefinitionTests.cs @@ -19,7 +19,7 @@ public sealed class AtomicSerializationResourceDefinitionTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicSerializationResourceDefinitionTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { @@ -278,7 +278,7 @@ public async Task Skips_on_update_resource_with_ToOne_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingTrack, existingCompany); + dbContext.AddInRange(existingTrack, existingCompany); await dbContext.SaveChangesAsync(); }); @@ -337,7 +337,7 @@ public async Task Skips_on_update_ToOne_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingTrack, existingCompany); + dbContext.AddInRange(existingTrack, existingCompany); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/ResourceDefinitions/SparseFieldSets/AtomicSparseFieldSetResourceDefinitionTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/ResourceDefinitions/SparseFieldSets/AtomicSparseFieldSetResourceDefinitionTests.cs index db9c793038..0888a25726 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/ResourceDefinitions/SparseFieldSets/AtomicSparseFieldSetResourceDefinitionTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/ResourceDefinitions/SparseFieldSets/AtomicSparseFieldSetResourceDefinitionTests.cs @@ -18,7 +18,7 @@ public sealed class AtomicSparseFieldSetResourceDefinitionTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicSparseFieldSetResourceDefinitionTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Transactions/AtomicRollbackTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Transactions/AtomicRollbackTests.cs index 2f01f4aaa2..e02fc62fc4 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Transactions/AtomicRollbackTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Transactions/AtomicRollbackTests.cs @@ -16,7 +16,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.AtomicOperations.Transa public sealed class AtomicRollbackTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicRollbackTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicAddToToManyRelationshipTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicAddToToManyRelationshipTests.cs index 98d15f5459..1ee2823561 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicAddToToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicAddToToManyRelationshipTests.cs @@ -18,7 +18,7 @@ public sealed class AtomicAddToToManyRelationshipTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicAddToToManyRelationshipTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { @@ -36,7 +36,7 @@ public async Task Cannot_add_to_HasOne_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingTrack, existingCompany); + dbContext.AddInRange(existingTrack, existingCompany); await dbContext.SaveChangesAsync(); }); @@ -166,7 +166,7 @@ public async Task Can_add_to_HasManyThrough_relationship() existingPlaylist.PlaylistMusicTracks = new List { - new PlaylistMusicTrack + new() { MusicTrack = _fakers.MusicTrack.Generate() } diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicRemoveFromToManyRelationshipTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicRemoveFromToManyRelationshipTests.cs index f09d85cf36..9fddd90b69 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicRemoveFromToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicRemoveFromToManyRelationshipTests.cs @@ -18,7 +18,7 @@ public sealed class AtomicRemoveFromToManyRelationshipTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicRemoveFromToManyRelationshipTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { @@ -165,15 +165,15 @@ public async Task Can_remove_from_HasManyThrough_relationship() existingPlaylist.PlaylistMusicTracks = new List { - new PlaylistMusicTrack + new() { MusicTrack = _fakers.MusicTrack.Generate() }, - new PlaylistMusicTrack + new() { MusicTrack = _fakers.MusicTrack.Generate() }, - new PlaylistMusicTrack + new() { MusicTrack = _fakers.MusicTrack.Generate() } diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicReplaceToManyRelationshipTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicReplaceToManyRelationshipTests.cs index 17606bd01d..a4fab39fd5 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicReplaceToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicReplaceToManyRelationshipTests.cs @@ -18,7 +18,7 @@ public sealed class AtomicReplaceToManyRelationshipTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicReplaceToManyRelationshipTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { @@ -88,11 +88,11 @@ public async Task Can_clear_HasManyThrough_relationship() existingPlaylist.PlaylistMusicTracks = new List { - new PlaylistMusicTrack + new() { MusicTrack = _fakers.MusicTrack.Generate() }, - new PlaylistMusicTrack + new() { MusicTrack = _fakers.MusicTrack.Generate() } @@ -231,7 +231,7 @@ public async Task Can_replace_HasManyThrough_relationship() existingPlaylist.PlaylistMusicTracks = new List { - new PlaylistMusicTrack + new() { MusicTrack = _fakers.MusicTrack.Generate() } diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicUpdateToOneRelationshipTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicUpdateToOneRelationshipTests.cs index a8bec2eaae..953602b425 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicUpdateToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicUpdateToOneRelationshipTests.cs @@ -17,7 +17,7 @@ public sealed class AtomicUpdateToOneRelationshipTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicUpdateToOneRelationshipTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { @@ -194,7 +194,7 @@ public async Task Can_create_OneToOne_relationship_from_principal_side() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingLyric, existingTrack); + dbContext.AddInRange(existingLyric, existingTrack); await dbContext.SaveChangesAsync(); }); @@ -247,7 +247,7 @@ public async Task Can_create_OneToOne_relationship_from_dependent_side() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingTrack, existingLyric); + dbContext.AddInRange(existingTrack, existingLyric); await dbContext.SaveChangesAsync(); }); @@ -300,7 +300,7 @@ public async Task Can_create_ManyToOne_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingTrack, existingCompany); + dbContext.AddInRange(existingTrack, existingCompany); await dbContext.SaveChangesAsync(); }); @@ -356,7 +356,7 @@ public async Task Can_replace_OneToOne_relationship_from_principal_side() await _testContext.RunOnDatabaseAsync(async dbContext => { await dbContext.ClearTableAsync(); - dbContext.AddRange(existingLyric, existingTrack); + dbContext.AddInRange(existingLyric, existingTrack); await dbContext.SaveChangesAsync(); }); @@ -415,7 +415,7 @@ public async Task Can_replace_OneToOne_relationship_from_dependent_side() await _testContext.RunOnDatabaseAsync(async dbContext => { await dbContext.ClearTableAsync(); - dbContext.AddRange(existingTrack, existingLyric); + dbContext.AddInRange(existingTrack, existingLyric); await dbContext.SaveChangesAsync(); }); @@ -474,7 +474,7 @@ public async Task Can_replace_ManyToOne_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { await dbContext.ClearTableAsync(); - dbContext.AddRange(existingTrack, existingCompany); + dbContext.AddInRange(existingTrack, existingCompany); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicReplaceToManyRelationshipTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicReplaceToManyRelationshipTests.cs index 004b3e777f..a2f7b4c0ba 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicReplaceToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicReplaceToManyRelationshipTests.cs @@ -18,7 +18,7 @@ public sealed class AtomicReplaceToManyRelationshipTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicReplaceToManyRelationshipTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { @@ -93,11 +93,11 @@ public async Task Can_clear_HasManyThrough_relationship() existingPlaylist.PlaylistMusicTracks = new List { - new PlaylistMusicTrack + new() { MusicTrack = _fakers.MusicTrack.Generate() }, - new PlaylistMusicTrack + new() { MusicTrack = _fakers.MusicTrack.Generate() } @@ -246,7 +246,7 @@ public async Task Can_replace_HasManyThrough_relationship() existingPlaylist.PlaylistMusicTracks = new List { - new PlaylistMusicTrack + new() { MusicTrack = _fakers.MusicTrack.Generate() } diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs index 3a69931019..5ee958edb6 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs @@ -18,7 +18,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.AtomicOperations.Updati public sealed class AtomicUpdateResourceTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicUpdateResourceTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { @@ -1511,7 +1511,7 @@ public async Task Can_update_resource_with_attributes_and_multiple_relationship_ await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingTrack, existingLyric, existingCompany, existingPerformer); + dbContext.AddInRange(existingTrack, existingLyric, existingCompany, existingPerformer); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateToOneRelationshipTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateToOneRelationshipTests.cs index 0460f5e2e5..b40dd4a25f 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateToOneRelationshipTests.cs @@ -17,7 +17,7 @@ public sealed class AtomicUpdateToOneRelationshipTests : IClassFixture, OperationsDbContext>> { private readonly ExampleIntegrationTestContext, OperationsDbContext> _testContext; - private readonly OperationsFakers _fakers = new OperationsFakers(); + private readonly OperationsFakers _fakers = new(); public AtomicUpdateToOneRelationshipTests(ExampleIntegrationTestContext, OperationsDbContext> testContext) { @@ -209,7 +209,7 @@ public async Task Can_create_OneToOne_relationship_from_principal_side() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingLyric, existingTrack); + dbContext.AddInRange(existingLyric, existingTrack); await dbContext.SaveChangesAsync(); }); @@ -267,7 +267,7 @@ public async Task Can_create_OneToOne_relationship_from_dependent_side() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingTrack, existingLyric); + dbContext.AddInRange(existingTrack, existingLyric); await dbContext.SaveChangesAsync(); }); @@ -325,7 +325,7 @@ public async Task Can_create_ManyToOne_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingTrack, existingCompany); + dbContext.AddInRange(existingTrack, existingCompany); await dbContext.SaveChangesAsync(); }); @@ -386,7 +386,7 @@ public async Task Can_replace_OneToOne_relationship_from_principal_side() await _testContext.RunOnDatabaseAsync(async dbContext => { await dbContext.ClearTableAsync(); - dbContext.AddRange(existingLyric, existingTrack); + dbContext.AddInRange(existingLyric, existingTrack); await dbContext.SaveChangesAsync(); }); @@ -450,7 +450,7 @@ public async Task Can_replace_OneToOne_relationship_from_dependent_side() await _testContext.RunOnDatabaseAsync(async dbContext => { await dbContext.ClearTableAsync(); - dbContext.AddRange(existingTrack, existingLyric); + dbContext.AddInRange(existingTrack, existingLyric); await dbContext.SaveChangesAsync(); }); @@ -514,7 +514,7 @@ public async Task Can_replace_ManyToOne_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { await dbContext.ClearTableAsync(); - dbContext.AddRange(existingTrack, existingCompany); + dbContext.AddInRange(existingTrack, existingCompany); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/CompositeKeys/CompositeKeyTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/CompositeKeys/CompositeKeyTests.cs index c541f86a39..3aa9f082fa 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/CompositeKeys/CompositeKeyTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/CompositeKeys/CompositeKeyTests.cs @@ -210,7 +210,7 @@ public async Task Can_create_OneToOne_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { await dbContext.ClearTableAsync(); - dbContext.AddRange(existingCar, existingEngine); + dbContext.AddInRange(existingCar, existingEngine); await dbContext.SaveChangesAsync(); }); @@ -317,12 +317,12 @@ public async Task Can_remove_from_OneToMany_relationship() Address = "Dam 1, 1012JS Amsterdam, the Netherlands", Inventory = new HashSet { - new Car + new() { RegionId = 123, LicensePlate = "AA-BB-11" }, - new Car + new() { RegionId = 456, LicensePlate = "CC-DD-22" @@ -387,7 +387,7 @@ public async Task Can_add_to_OneToMany_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { await dbContext.ClearTableAsync(); - dbContext.AddRange(existingDealership, existingCar); + dbContext.AddInRange(existingDealership, existingCar); await dbContext.SaveChangesAsync(); }); @@ -432,12 +432,12 @@ public async Task Can_replace_OneToMany_relationship() Address = "Dam 1, 1012JS Amsterdam, the Netherlands", Inventory = new HashSet { - new Car + new() { RegionId = 123, LicensePlate = "AA-BB-11" }, - new Car + new() { RegionId = 456, LicensePlate = "CC-DD-22" @@ -454,7 +454,7 @@ public async Task Can_replace_OneToMany_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { await dbContext.ClearTableAsync(); - dbContext.AddRange(existingDealership, existingCar); + dbContext.AddInRange(existingDealership, existingCar); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/ContentNegotiation/ContentTypeHeaderTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/ContentNegotiation/ContentTypeHeaderTests.cs index 8a2a831eca..3f899dc5a5 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/ContentNegotiation/ContentTypeHeaderTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/ContentNegotiation/ContentTypeHeaderTests.cs @@ -34,7 +34,7 @@ public async Task Returns_JsonApi_ContentType_header() // Assert httpResponse.Should().HaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ToString().Should().Be(HeaderConstants.MediaType); + httpResponse.Content.Headers.ContentType.Should().NotBeNull().And.Subject.ToString().Should().Be(HeaderConstants.MediaType); } [Fact] @@ -67,7 +67,7 @@ public async Task Returns_JsonApi_ContentType_header_with_AtomicOperations_exten // Assert httpResponse.Should().HaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ToString().Should().Be(HeaderConstants.AtomicOperationsMediaType); + httpResponse.Content.Headers.ContentType.Should().NotBeNull().And.Subject.ToString().Should().Be(HeaderConstants.AtomicOperationsMediaType); } [Fact] diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/CustomRoutes/CustomRouteFakers.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/CustomRoutes/CustomRouteFakers.cs index 9bd81abec4..1788cab630 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/CustomRoutes/CustomRouteFakers.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/CustomRoutes/CustomRouteFakers.cs @@ -9,14 +9,14 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.CustomRoutes { internal sealed class CustomRouteFakers : FakerContainer { - private readonly Lazy> _lazyTownFaker = new Lazy>(() => + private readonly Lazy> _lazyTownFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(town => town.Name, faker => faker.Address.City()) .RuleFor(town => town.Latitude, faker => faker.Address.Latitude()) .RuleFor(town => town.Longitude, faker => faker.Address.Longitude())); - private readonly Lazy> _lazyCivilianFaker = new Lazy>(() => + private readonly Lazy> _lazyCivilianFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(civilian => civilian.Name, faker => faker.Person.FullName)); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/CustomRoutes/CustomRouteTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/CustomRoutes/CustomRouteTests.cs index d974d38503..a2e5fa3e0c 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/CustomRoutes/CustomRouteTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/CustomRoutes/CustomRouteTests.cs @@ -16,7 +16,7 @@ public sealed class CustomRouteTests : IClassFixture, CustomRouteDbContext> _testContext; - private readonly CustomRouteFakers _fakers = new CustomRouteFakers(); + private readonly CustomRouteFakers _fakers = new(); public CustomRouteTests(ExampleIntegrationTestContext, CustomRouteDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/EagerLoading/EagerLoadingFakers.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/EagerLoading/EagerLoadingFakers.cs index bb41ba2449..3ef189ddce 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/EagerLoading/EagerLoadingFakers.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/EagerLoading/EagerLoadingFakers.cs @@ -9,33 +9,33 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.EagerLoading { internal sealed class EagerLoadingFakers : FakerContainer { - private readonly Lazy> _lazyStateFaker = new Lazy>(() => + private readonly Lazy> _lazyStateFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(state => state.Name, faker => faker.Address.City())); - private readonly Lazy> _lazyCityFaker = new Lazy>(() => + private readonly Lazy> _lazyCityFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(city => city.Name, faker => faker.Address.City())); - private readonly Lazy> _lazyStreetFaker = new Lazy>(() => + private readonly Lazy> _lazyStreetFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(street => street.Name, faker => faker.Address.StreetName())); - private readonly Lazy> _lazyBuildingFaker = new Lazy>(() => + private readonly Lazy> _lazyBuildingFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(building => building.Number, faker => faker.Address.BuildingNumber())); - private readonly Lazy> _lazyWindowFaker = new Lazy>(() => + private readonly Lazy> _lazyWindowFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(window => window.HeightInCentimeters, faker => faker.Random.Number(30, 199)) .RuleFor(window => window.WidthInCentimeters, faker => faker.Random.Number(30, 199))); - private readonly Lazy> _lazyDoorFaker = new Lazy>(() => + private readonly Lazy> _lazyDoorFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(door => door.Color, faker => faker.Commerce.Color())); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/EagerLoading/EagerLoadingTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/EagerLoading/EagerLoadingTests.cs index 317c114978..3b3ebe81b8 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/EagerLoading/EagerLoadingTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/EagerLoading/EagerLoadingTests.cs @@ -14,7 +14,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.EagerLoading public sealed class EagerLoadingTests : IClassFixture, EagerLoadingDbContext>> { private readonly ExampleIntegrationTestContext, EagerLoadingDbContext> _testContext; - private readonly EagerLoadingFakers _fakers = new EagerLoadingFakers(); + private readonly EagerLoadingFakers _fakers = new(); public EagerLoadingTests(ExampleIntegrationTestContext, EagerLoadingDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/HostingInIIS/HostingFakers.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/HostingInIIS/HostingFakers.cs index b67b79ab6e..0ba493b035 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/HostingInIIS/HostingFakers.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/HostingInIIS/HostingFakers.cs @@ -9,12 +9,12 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.HostingInIIS { internal sealed class HostingFakers : FakerContainer { - private readonly Lazy> _lazyArtGalleryFaker = new Lazy>(() => + private readonly Lazy> _lazyArtGalleryFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(artGallery => artGallery.Theme, faker => faker.Lorem.Word())); - private readonly Lazy> _lazyPaintingFaker = new Lazy>(() => + private readonly Lazy> _lazyPaintingFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(painting => painting.Title, faker => faker.Lorem.Sentence())); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/HostingInIIS/HostingTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/HostingInIIS/HostingTests.cs index d3ea6b1054..49419bd748 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/HostingInIIS/HostingTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/HostingInIIS/HostingTests.cs @@ -14,7 +14,7 @@ public sealed class HostingTests : IClassFixture, HostingDbContext> _testContext; - private readonly HostingFakers _fakers = new HostingFakers(); + private readonly HostingFakers _fakers = new(); public HostingTests(ExampleIntegrationTestContext, HostingDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/IdObfuscationTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/IdObfuscationTests.cs index f6703e7272..6789af5ffe 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/IdObfuscationTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/IdObfuscationTests.cs @@ -14,7 +14,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.IdObfuscation public sealed class IdObfuscationTests : IClassFixture, ObfuscationDbContext>> { private readonly ExampleIntegrationTestContext, ObfuscationDbContext> _testContext; - private readonly ObfuscationFakers _fakers = new ObfuscationFakers(); + private readonly ObfuscationFakers _fakers = new(); public IdObfuscationTests(ExampleIntegrationTestContext, ObfuscationDbContext> testContext) { @@ -277,7 +277,7 @@ public async Task Can_update_resource_with_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingAccount, existingCard); + dbContext.AddInRange(existingAccount, existingCard); await dbContext.SaveChangesAsync(); }); @@ -341,7 +341,7 @@ public async Task Can_add_to_ToMany_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingAccount, existingDebitCard); + dbContext.AddInRange(existingAccount, existingDebitCard); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiable.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiable.cs index e0e728a938..95214b2a14 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiable.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiable.cs @@ -4,7 +4,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.IdObfuscation { public abstract class ObfuscatedIdentifiable : Identifiable { - private static readonly HexadecimalCodec Codec = new HexadecimalCodec(); + private static readonly HexadecimalCodec Codec = new(); protected override string GetStringId(int value) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiableController.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiableController.cs index ab4a02a70f..d1e44519f9 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiableController.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiableController.cs @@ -13,7 +13,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.IdObfuscation public abstract class ObfuscatedIdentifiableController : BaseJsonApiController where TResource : class, IIdentifiable { - private readonly HexadecimalCodec _codec = new HexadecimalCodec(); + private readonly HexadecimalCodec _codec = new(); protected ObfuscatedIdentifiableController(IJsonApiOptions options, ILoggerFactory loggerFactory, IResourceService resourceService) : base(options, loggerFactory, resourceService) diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/ObfuscationFakers.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/ObfuscationFakers.cs index ed064f2956..7d4033aca8 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/ObfuscationFakers.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/IdObfuscation/ObfuscationFakers.cs @@ -9,12 +9,12 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.IdObfuscation { internal sealed class ObfuscationFakers : FakerContainer { - private readonly Lazy> _lazyBankAccountFaker = new Lazy>(() => + private readonly Lazy> _lazyBankAccountFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(bankAccount => bankAccount.Iban, faker => faker.Finance.Iban())); - private readonly Lazy> _lazyDebitCardFaker = new Lazy>(() => + private readonly Lazy> _lazyDebitCardFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(debitCard => debitCard.OwnerName, faker => faker.Name.FullName()) diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/InputValidation/ModelState/ModelStateValidationTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/InputValidation/ModelState/ModelStateValidationTests.cs index a59f88d766..b74bc5fc01 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/InputValidation/ModelState/ModelStateValidationTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/InputValidation/ModelState/ModelStateValidationTests.cs @@ -305,7 +305,7 @@ public async Task Can_add_to_annotated_ToMany_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(directory, file); + dbContext.AddInRange(directory, file); await dbContext.SaveChangesAsync(); }); @@ -580,7 +580,7 @@ public async Task Can_update_resource_with_annotated_relationships() IsCaseSensitive = false, Subdirectories = new List { - new SystemDirectory + new() { Name = "C#", IsCaseSensitive = false @@ -588,7 +588,7 @@ public async Task Can_update_resource_with_annotated_relationships() }, Files = new List { - new SystemFile + new() { FileName = "readme.txt" } @@ -851,11 +851,11 @@ public async Task Can_replace_annotated_ToMany_relationship() IsCaseSensitive = true, Files = new List { - new SystemFile + new() { FileName = "Main.cs" }, - new SystemFile + new() { FileName = "Program.cs" } @@ -907,7 +907,7 @@ public async Task Can_remove_from_annotated_ToMany_relationship() IsCaseSensitive = true, Files = new List { - new SystemFile + new() { FileName = "Main.cs", SizeInBytes = 100 @@ -917,7 +917,7 @@ public async Task Can_remove_from_annotated_ToMany_relationship() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(directory); + dbContext.AddInRange(directory); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/InputValidation/RequestBody/WorkflowDefinition.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/InputValidation/RequestBody/WorkflowDefinition.cs index 7c0b59c53b..7139b92865 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/InputValidation/RequestBody/WorkflowDefinition.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/InputValidation/RequestBody/WorkflowDefinition.cs @@ -15,26 +15,25 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.InputValidation.Request [UsedImplicitly(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)] public sealed class WorkflowDefinition : JsonApiResourceDefinition { - private static readonly Dictionary> StageTransitionTable = - new Dictionary> + private static readonly Dictionary> StageTransitionTable = new() + { + [WorkflowStage.Created] = new[] { - [WorkflowStage.Created] = new[] - { - WorkflowStage.InProgress - }, - [WorkflowStage.InProgress] = new[] - { - WorkflowStage.OnHold, - WorkflowStage.Succeeded, - WorkflowStage.Failed, - WorkflowStage.Canceled - }, - [WorkflowStage.OnHold] = new[] - { - WorkflowStage.InProgress, - WorkflowStage.Canceled - } - }; + WorkflowStage.InProgress + }, + [WorkflowStage.InProgress] = new[] + { + WorkflowStage.OnHold, + WorkflowStage.Succeeded, + WorkflowStage.Failed, + WorkflowStage.Canceled + }, + [WorkflowStage.OnHold] = new[] + { + WorkflowStage.InProgress, + WorkflowStage.Canceled + } + }; private WorkflowStage _previousStage; diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/AbsoluteLinksWithNamespaceTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/AbsoluteLinksWithNamespaceTests.cs index c54d868a17..9593eb4af5 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/AbsoluteLinksWithNamespaceTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/AbsoluteLinksWithNamespaceTests.cs @@ -19,7 +19,7 @@ public sealed class AbsoluteLinksWithNamespaceTests private const string HostPrefix = "http://localhost"; private readonly ExampleIntegrationTestContext, LinksDbContext> _testContext; - private readonly LinksFakers _fakers = new LinksFakers(); + private readonly LinksFakers _fakers = new(); public AbsoluteLinksWithNamespaceTests(ExampleIntegrationTestContext, LinksDbContext> testContext) { @@ -324,7 +324,7 @@ public async Task Update_resource_with_side_effects_and_include_returns_absolute await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingPhoto, existingAlbum); + dbContext.AddInRange(existingPhoto, existingAlbum); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/AbsoluteLinksWithoutNamespaceTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/AbsoluteLinksWithoutNamespaceTests.cs index db26b78f09..28e1256bea 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/AbsoluteLinksWithoutNamespaceTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/AbsoluteLinksWithoutNamespaceTests.cs @@ -19,7 +19,7 @@ public sealed class AbsoluteLinksWithoutNamespaceTests private const string HostPrefix = "http://localhost"; private readonly ExampleIntegrationTestContext, LinksDbContext> _testContext; - private readonly LinksFakers _fakers = new LinksFakers(); + private readonly LinksFakers _fakers = new(); public AbsoluteLinksWithoutNamespaceTests(ExampleIntegrationTestContext, LinksDbContext> testContext) { @@ -324,7 +324,7 @@ public async Task Update_resource_with_side_effects_and_include_returns_absolute await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingPhoto, existingAlbum); + dbContext.AddInRange(existingPhoto, existingAlbum); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/LinkInclusionTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/LinkInclusionTests.cs index b47697dad7..9ab7903b38 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/LinkInclusionTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/LinkInclusionTests.cs @@ -12,7 +12,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.Links public sealed class LinkInclusionTests : IClassFixture, LinksDbContext>> { private readonly ExampleIntegrationTestContext, LinksDbContext> _testContext; - private readonly LinksFakers _fakers = new LinksFakers(); + private readonly LinksFakers _fakers = new(); public LinkInclusionTests(ExampleIntegrationTestContext, LinksDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/LinksFakers.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/LinksFakers.cs index bd6ee4acb3..9673037189 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/LinksFakers.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/LinksFakers.cs @@ -9,17 +9,17 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.Links { internal sealed class LinksFakers : FakerContainer { - private readonly Lazy> _lazyPhotoAlbumFaker = new Lazy>(() => + private readonly Lazy> _lazyPhotoAlbumFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(photoAlbum => photoAlbum.Name, faker => faker.Lorem.Sentence())); - private readonly Lazy> _lazyPhotoFaker = new Lazy>(() => + private readonly Lazy> _lazyPhotoFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(photo => photo.Url, faker => faker.Image.PlaceImgUrl())); - private readonly Lazy> _lazyPhotoLocationFaker = new Lazy>(() => + private readonly Lazy> _lazyPhotoLocationFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(photoLocation => photoLocation.PlaceName, faker => faker.Address.FullAddress()) diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/RelativeLinksWithNamespaceTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/RelativeLinksWithNamespaceTests.cs index e77685caec..d8f732c7f8 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/RelativeLinksWithNamespaceTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/RelativeLinksWithNamespaceTests.cs @@ -17,7 +17,7 @@ public sealed class RelativeLinksWithNamespaceTests : IClassFixture, LinksDbContext>> { private readonly ExampleIntegrationTestContext, LinksDbContext> _testContext; - private readonly LinksFakers _fakers = new LinksFakers(); + private readonly LinksFakers _fakers = new(); public RelativeLinksWithNamespaceTests(ExampleIntegrationTestContext, LinksDbContext> testContext) { @@ -322,7 +322,7 @@ public async Task Update_resource_with_side_effects_and_include_returns_relative await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingPhoto, existingAlbum); + dbContext.AddInRange(existingPhoto, existingAlbum); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/RelativeLinksWithoutNamespaceTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/RelativeLinksWithoutNamespaceTests.cs index 4d03d34dd7..efc1015511 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/RelativeLinksWithoutNamespaceTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Links/RelativeLinksWithoutNamespaceTests.cs @@ -17,7 +17,7 @@ public sealed class RelativeLinksWithoutNamespaceTests : IClassFixture, LinksDbContext>> { private readonly ExampleIntegrationTestContext, LinksDbContext> _testContext; - private readonly LinksFakers _fakers = new LinksFakers(); + private readonly LinksFakers _fakers = new(); public RelativeLinksWithoutNamespaceTests(ExampleIntegrationTestContext, LinksDbContext> testContext) { @@ -322,7 +322,7 @@ public async Task Update_resource_with_side_effects_and_include_returns_relative await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingPhoto, existingAlbum); + dbContext.AddInRange(existingPhoto, existingAlbum); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Logging/AuditFakers.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Logging/AuditFakers.cs index 702411dddd..60e1534d69 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Logging/AuditFakers.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Logging/AuditFakers.cs @@ -9,7 +9,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.Logging { internal sealed class AuditFakers : FakerContainer { - private readonly Lazy> _lazyAuditEntryFaker = new Lazy>(() => + private readonly Lazy> _lazyAuditEntryFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(auditEntry => auditEntry.UserName, faker => faker.Internet.UserName()) diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Logging/LoggingTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Logging/LoggingTests.cs index cc9ab85ce4..c4c176a7c5 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Logging/LoggingTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Logging/LoggingTests.cs @@ -14,7 +14,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.Logging public sealed class LoggingTests : IClassFixture, AuditDbContext>> { private readonly ExampleIntegrationTestContext, AuditDbContext> _testContext; - private readonly AuditFakers _fakers = new AuditFakers(); + private readonly AuditFakers _fakers = new(); public LoggingTests(ExampleIntegrationTestContext, AuditDbContext> testContext) { @@ -31,7 +31,7 @@ public LoggingTests(ExampleIntegrationTestContext true); + options.AddFilter((_, _) => true); }); testContext.ConfigureServicesBeforeStartup(services => diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Meta/ResourceMetaTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Meta/ResourceMetaTests.cs index f968dc1840..d16ce19692 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Meta/ResourceMetaTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Meta/ResourceMetaTests.cs @@ -15,7 +15,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.Meta public sealed class ResourceMetaTests : IClassFixture, SupportDbContext>> { private readonly ExampleIntegrationTestContext, SupportDbContext> _testContext; - private readonly SupportFakers _fakers = new SupportFakers(); + private readonly SupportFakers _fakers = new(); public ResourceMetaTests(ExampleIntegrationTestContext, SupportDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Meta/SupportFakers.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Meta/SupportFakers.cs index 797696c8f6..f5db588f99 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Meta/SupportFakers.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Meta/SupportFakers.cs @@ -9,12 +9,12 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.Meta { internal sealed class SupportFakers : FakerContainer { - private readonly Lazy> _lazyProductFamilyFaker = new Lazy>(() => + private readonly Lazy> _lazyProductFamilyFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(productFamily => productFamily.Name, faker => faker.Commerce.ProductName())); - private readonly Lazy> _lazySupportTicketFaker = new Lazy>(() => + private readonly Lazy> _lazySupportTicketFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(supportTicket => supportTicket.Description, faker => faker.Lorem.Paragraph())); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Meta/TopLevelCountTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Meta/TopLevelCountTests.cs index 176a526774..cb073b498d 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Meta/TopLevelCountTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Meta/TopLevelCountTests.cs @@ -15,7 +15,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.Meta public sealed class TopLevelCountTests : IClassFixture, SupportDbContext>> { private readonly ExampleIntegrationTestContext, SupportDbContext> _testContext; - private readonly SupportFakers _fakers = new SupportFakers(); + private readonly SupportFakers _fakers = new(); public TopLevelCountTests(ExampleIntegrationTestContext, SupportDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/DomainFakers.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/DomainFakers.cs index 9e69ec8689..33519f267d 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/DomainFakers.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/DomainFakers.cs @@ -9,13 +9,13 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.Microservices { internal sealed class DomainFakers : FakerContainer { - private readonly Lazy> _lazyDomainUserFaker = new Lazy>(() => + private readonly Lazy> _lazyDomainUserFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(domainUser => domainUser.LoginName, faker => faker.Person.UserName) .RuleFor(domainUser => domainUser.DisplayName, faker => faker.Person.FullName)); - private readonly Lazy> _lazyDomainGroupFaker = new Lazy>(() => + private readonly Lazy> _lazyDomainGroupFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(domainGroup => domainGroup.Name, faker => faker.Commerce.Department())); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.User.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.User.cs index bbbfc12da8..1f2c376ac4 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.User.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.User.cs @@ -283,7 +283,7 @@ public async Task Update_user_add_to_group_sends_messages() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingUser, existingGroup); + dbContext.AddInRange(existingUser, existingGroup); await dbContext.SaveChangesAsync(); }); @@ -357,7 +357,7 @@ public async Task Update_user_move_to_group_sends_messages() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingUser, existingGroup); + dbContext.AddInRange(existingUser, existingGroup); await dbContext.SaveChangesAsync(); }); @@ -553,7 +553,7 @@ public async Task Assign_group_to_user_sends_messages() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingUser, existingGroup); + dbContext.AddInRange(existingUser, existingGroup); await dbContext.SaveChangesAsync(); }); @@ -605,7 +605,7 @@ public async Task Replace_group_for_user_sends_messages() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingUser, existingGroup); + dbContext.AddInRange(existingUser, existingGroup); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.cs index b36fae4173..8d1fce0cae 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.cs @@ -15,7 +15,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.Microservices.FireAndFo public sealed partial class FireForgetTests : IClassFixture, FireForgetDbContext>> { private readonly ExampleIntegrationTestContext, FireForgetDbContext> _testContext; - private readonly DomainFakers _fakers = new DomainFakers(); + private readonly DomainFakers _fakers = new(); public FireForgetTests(ExampleIntegrationTestContext, FireForgetDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/Messages/OutgoingMessage.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/Messages/OutgoingMessage.cs index 68837f0d12..f001514efc 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/Messages/OutgoingMessage.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/Messages/OutgoingMessage.cs @@ -22,7 +22,7 @@ public T GetContentAs() public static OutgoingMessage CreateFromContent(IMessageContent content) { - return new OutgoingMessage + return new() { Type = content.GetType().Name, FormatVersion = content.FormatVersion, diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/MessagingGroupDefinition.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/MessagingGroupDefinition.cs index cac44d1c03..bac42f8d6f 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/MessagingGroupDefinition.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/MessagingGroupDefinition.cs @@ -17,7 +17,7 @@ public abstract class MessagingGroupDefinition : JsonApiResourceDefinition _userSet; private readonly DbSet _groupSet; private readonly ResourceDefinitionHitCounter _hitCounter; - private readonly List _pendingMessages = new List(); + private readonly List _pendingMessages = new(); private string _beforeGroupName; diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/MessagingUserDefinition.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/MessagingUserDefinition.cs index 2e48d9e3d7..d7294f3884 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/MessagingUserDefinition.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/MessagingUserDefinition.cs @@ -15,7 +15,7 @@ public abstract class MessagingUserDefinition : JsonApiResourceDefinition _userSet; private readonly ResourceDefinitionHitCounter _hitCounter; - private readonly List _pendingMessages = new List(); + private readonly List _pendingMessages = new(); private string _beforeLoginName; private string _beforeDisplayName; diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.User.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.User.cs index d392a4fb32..a4868a9c87 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.User.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.User.cs @@ -302,7 +302,7 @@ public async Task Update_user_add_to_group_writes_to_outbox() await _testContext.RunOnDatabaseAsync(async dbContext => { await dbContext.ClearTableAsync(); - dbContext.AddRange(existingUser, existingGroup); + dbContext.AddInRange(existingUser, existingGroup); await dbContext.SaveChangesAsync(); }); @@ -379,7 +379,7 @@ public async Task Update_user_move_to_group_writes_to_outbox() await _testContext.RunOnDatabaseAsync(async dbContext => { await dbContext.ClearTableAsync(); - dbContext.AddRange(existingUser, existingGroup); + dbContext.AddInRange(existingUser, existingGroup); await dbContext.SaveChangesAsync(); }); @@ -587,7 +587,7 @@ public async Task Assign_group_to_user_writes_to_outbox() await _testContext.RunOnDatabaseAsync(async dbContext => { await dbContext.ClearTableAsync(); - dbContext.AddRange(existingUser, existingGroup); + dbContext.AddInRange(existingUser, existingGroup); await dbContext.SaveChangesAsync(); }); @@ -642,7 +642,7 @@ public async Task Replace_group_for_user_writes_to_outbox() await _testContext.RunOnDatabaseAsync(async dbContext => { await dbContext.ClearTableAsync(); - dbContext.AddRange(existingUser, existingGroup); + dbContext.AddInRange(existingUser, existingGroup); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.cs index 875af7adf9..ff2517423d 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.cs @@ -21,7 +21,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.Microservices.Transacti public sealed partial class OutboxTests : IClassFixture, OutboxDbContext>> { private readonly ExampleIntegrationTestContext, OutboxDbContext> _testContext; - private readonly DomainFakers _fakers = new DomainFakers(); + private readonly DomainFakers _fakers = new(); public OutboxTests(ExampleIntegrationTestContext, OutboxDbContext> testContext) { @@ -57,7 +57,7 @@ public async Task Does_not_add_to_outbox_on_write_error() await _testContext.RunOnDatabaseAsync(async dbContext => { await dbContext.ClearTableAsync(); - dbContext.AddRange(existingGroup, existingUser); + dbContext.AddInRange(existingGroup, existingUser); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/MultiTenancy/MultiTenancyFakers.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/MultiTenancy/MultiTenancyFakers.cs index 6f1e0cf57b..2ebc6570f3 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/MultiTenancy/MultiTenancyFakers.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/MultiTenancy/MultiTenancyFakers.cs @@ -9,12 +9,12 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.MultiTenancy { internal sealed class MultiTenancyFakers : FakerContainer { - private readonly Lazy> _lazyWebShopFaker = new Lazy>(() => + private readonly Lazy> _lazyWebShopFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(webShop => webShop.Url, faker => faker.Internet.Url())); - private readonly Lazy> _lazyWebProductFaker = new Lazy>(() => + private readonly Lazy> _lazyWebProductFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(webProduct => webProduct.Name, faker => faker.Commerce.ProductName()) diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/MultiTenancy/MultiTenancyTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/MultiTenancy/MultiTenancyTests.cs index 190b15d019..fc9f15c3ce 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/MultiTenancy/MultiTenancyTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/MultiTenancy/MultiTenancyTests.cs @@ -21,7 +21,7 @@ public sealed class MultiTenancyTests : IClassFixture, MultiTenancyDbContext> _testContext; - private readonly MultiTenancyFakers _fakers = new MultiTenancyFakers(); + private readonly MultiTenancyFakers _fakers = new(); public MultiTenancyTests(ExampleIntegrationTestContext, MultiTenancyDbContext> testContext) { @@ -546,7 +546,7 @@ public async Task Cannot_update_resource_with_HasMany_relationship_to_other_tena await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingShop, existingProduct); + dbContext.AddInRange(existingShop, existingProduct); await dbContext.SaveChangesAsync(); }); @@ -602,7 +602,7 @@ public async Task Cannot_update_resource_with_HasOne_relationship_to_other_tenan await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingProduct, existingShop); + dbContext.AddInRange(existingProduct, existingShop); await dbContext.SaveChangesAsync(); }); @@ -690,7 +690,7 @@ public async Task Cannot_update_HasMany_relationship_to_other_tenant() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingShop, existingProduct); + dbContext.AddInRange(existingShop, existingProduct); await dbContext.SaveChangesAsync(); }); @@ -770,7 +770,7 @@ public async Task Cannot_update_HasOne_relationship_to_other_tenant() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingProduct, existingShop); + dbContext.AddInRange(existingProduct, existingShop); await dbContext.SaveChangesAsync(); }); @@ -812,7 +812,7 @@ public async Task Cannot_add_to_ToMany_relationship_for_other_parent_tenant() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingShop, existingProduct); + dbContext.AddInRange(existingShop, existingProduct); await dbContext.SaveChangesAsync(); }); @@ -856,7 +856,7 @@ public async Task Cannot_add_to_ToMany_relationship_with_other_tenant() await _testContext.RunOnDatabaseAsync(async dbContext => { - dbContext.AddRange(existingShop, existingProduct); + dbContext.AddInRange(existingShop, existingProduct); await dbContext.SaveChangesAsync(); }); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/MultiTenancy/RouteTenantProvider.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/MultiTenancy/RouteTenantProvider.cs index 56c806530f..d02cd3037d 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/MultiTenancy/RouteTenantProvider.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/MultiTenancy/RouteTenantProvider.cs @@ -19,8 +19,13 @@ public Guid TenantId { get { + if (_httpContextAccessor.HttpContext == null) + { + throw new InvalidOperationException(); + } + string countryCode = (string)_httpContextAccessor.HttpContext.Request.RouteValues["countryCode"]; - return TenantRegistry.ContainsKey(countryCode) ? TenantRegistry[countryCode] : Guid.Empty; + return countryCode != null && TenantRegistry.ContainsKey(countryCode) ? TenantRegistry[countryCode] : Guid.Empty; } } diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/NamingConventions/KebabCasingTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/NamingConventions/KebabCasingTests.cs index 9d9bd9feb1..3b7a75b5f2 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/NamingConventions/KebabCasingTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/NamingConventions/KebabCasingTests.cs @@ -12,7 +12,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.NamingConventions public sealed class KebabCasingTests : IClassFixture, SwimmingDbContext>> { private readonly ExampleIntegrationTestContext, SwimmingDbContext> _testContext; - private readonly SwimmingFakers _fakers = new SwimmingFakers(); + private readonly SwimmingFakers _fakers = new(); public KebabCasingTests(ExampleIntegrationTestContext, SwimmingDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/NamingConventions/SwimmingFakers.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/NamingConventions/SwimmingFakers.cs index 13debc6ca7..f976bc0e74 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/NamingConventions/SwimmingFakers.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/NamingConventions/SwimmingFakers.cs @@ -9,17 +9,17 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.NamingConventions { internal sealed class SwimmingFakers : FakerContainer { - private readonly Lazy> _lazySwimmingPoolFaker = new Lazy>(() => + private readonly Lazy> _lazySwimmingPoolFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(swimmingPool => swimmingPool.IsIndoor, faker => faker.Random.Bool())); - private readonly Lazy> _lazyWaterSlideFaker = new Lazy>(() => + private readonly Lazy> _lazyWaterSlideFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(waterSlide => waterSlide.LengthInMeters, faker => faker.Random.Decimal(3, 100))); - private readonly Lazy> _lazyDivingBoardFaker = new Lazy>(() => + private readonly Lazy> _lazyDivingBoardFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(divingBoard => divingBoard.HeightInMeters, faker => faker.Random.Decimal(1, 15))); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/NonJsonApiControllers/NonJsonApiControllerTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/NonJsonApiControllers/NonJsonApiControllerTests.cs index 19934d7fc3..dcb3efaae3 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/NonJsonApiControllers/NonJsonApiControllerTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/NonJsonApiControllers/NonJsonApiControllerTests.cs @@ -32,7 +32,7 @@ public async Task Get_skips_middleware_and_formatters() // Assert httpResponse.Should().HaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ToString().Should().Be("application/json; charset=utf-8"); + httpResponse.Content.Headers.ContentType.Should().NotBeNull().And.Subject.ToString().Should().Be("application/json; charset=utf-8"); string responseText = await httpResponse.Content.ReadAsStringAsync(); responseText.Should().Be("[\"Welcome!\"]"); @@ -60,7 +60,7 @@ public async Task Post_skips_middleware_and_formatters() // Assert httpResponse.Should().HaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ToString().Should().Be("text/plain; charset=utf-8"); + httpResponse.Content.Headers.ContentType.Should().NotBeNull().And.Subject.ToString().Should().Be("text/plain; charset=utf-8"); string responseText = await httpResponse.Content.ReadAsStringAsync(); responseText.Should().Be("Hello, Jack"); @@ -79,7 +79,7 @@ public async Task Post_skips_error_handler() // Assert httpResponse.Should().HaveStatusCode(HttpStatusCode.BadRequest); - httpResponse.Content.Headers.ContentType.ToString().Should().Be("text/plain; charset=utf-8"); + httpResponse.Content.Headers.ContentType.Should().NotBeNull().And.Subject.ToString().Should().Be("text/plain; charset=utf-8"); string responseText = await httpResponse.Content.ReadAsStringAsync(); responseText.Should().Be("Please send your name."); @@ -107,7 +107,7 @@ public async Task Put_skips_middleware_and_formatters() // Assert httpResponse.Should().HaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ToString().Should().Be("text/plain; charset=utf-8"); + httpResponse.Content.Headers.ContentType.Should().NotBeNull().And.Subject.ToString().Should().Be("text/plain; charset=utf-8"); string responseText = await httpResponse.Content.ReadAsStringAsync(); responseText.Should().Be("Hi, Jane"); @@ -126,7 +126,7 @@ public async Task Patch_skips_middleware_and_formatters() // Assert httpResponse.Should().HaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ToString().Should().Be("text/plain; charset=utf-8"); + httpResponse.Content.Headers.ContentType.Should().NotBeNull().And.Subject.ToString().Should().Be("text/plain; charset=utf-8"); string responseText = await httpResponse.Content.ReadAsStringAsync(); responseText.Should().Be("Good day, Janice"); @@ -145,7 +145,7 @@ public async Task Delete_skips_middleware_and_formatters() // Assert httpResponse.Should().HaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ToString().Should().Be("text/plain; charset=utf-8"); + httpResponse.Content.Headers.ContentType.Should().NotBeNull().And.Subject.ToString().Should().Be("text/plain; charset=utf-8"); string responseText = await httpResponse.Content.ReadAsStringAsync(); responseText.Should().Be("Bye."); diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Filtering/FilterDepthTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Filtering/FilterDepthTests.cs index f7aa2c00a4..72a9d68f2b 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Filtering/FilterDepthTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Filtering/FilterDepthTests.cs @@ -17,7 +17,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.QueryStrings.Filtering public sealed class FilterDepthTests : IClassFixture, QueryStringDbContext>> { private readonly ExampleIntegrationTestContext, QueryStringDbContext> _testContext; - private readonly QueryStringFakers _fakers = new QueryStringFakers(); + private readonly QueryStringFakers _fakers = new(); public FilterDepthTests(ExampleIntegrationTestContext, QueryStringDbContext> testContext) { @@ -241,7 +241,7 @@ public async Task Can_filter_on_HasManyThrough_relationship() posts[1].BlogPostLabels = new HashSet { - new BlogPostLabel + new() { Label = _fakers.Label.Generate() } @@ -276,7 +276,7 @@ public async Task Can_filter_on_HasManyThrough_relationship_with_nested_conditio blogs[1].Posts[0].BlogPostLabels = new HashSet { - new BlogPostLabel + new() { Label = new Label { @@ -372,7 +372,7 @@ public async Task Can_filter_in_scope_of_HasManyThrough_relationship() posts[0].BlogPostLabels = new HashSet { - new BlogPostLabel + new() { Label = _fakers.Label.Generate() } @@ -380,7 +380,7 @@ public async Task Can_filter_in_scope_of_HasManyThrough_relationship() posts[1].BlogPostLabels = new HashSet { - new BlogPostLabel + new() { Label = _fakers.Label.Generate() } diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Filtering/FilterOperatorTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Filtering/FilterOperatorTests.cs index 0a4f6d5283..29e3f3b465 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Filtering/FilterOperatorTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Filtering/FilterOperatorTests.cs @@ -466,7 +466,7 @@ public async Task Can_filter_on_has() { Children = new List { - new FilterableResource() + new() } }; @@ -495,21 +495,21 @@ public async Task Can_filter_on_has_with_nested_condition() // Arrange var resources = new List { - new FilterableResource + new() { Children = new List { - new FilterableResource + new() { SomeBoolean = false } } }, - new FilterableResource + new() { Children = new List { - new FilterableResource + new() { SomeBoolean = true } @@ -544,8 +544,8 @@ public async Task Can_filter_on_count() { Children = new List { - new FilterableResource(), - new FilterableResource() + new(), + new() } }; diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Filtering/FilterTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Filtering/FilterTests.cs index c2437b3084..1d208f241f 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Filtering/FilterTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Filtering/FilterTests.cs @@ -15,7 +15,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.QueryStrings.Filtering public sealed class FilterTests : IClassFixture, QueryStringDbContext>> { private readonly ExampleIntegrationTestContext, QueryStringDbContext> _testContext; - private readonly QueryStringFakers _fakers = new QueryStringFakers(); + private readonly QueryStringFakers _fakers = new(); public FilterTests(ExampleIntegrationTestContext, QueryStringDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Includes/IncludeTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Includes/IncludeTests.cs index c7981f3ea7..ee88f540f3 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Includes/IncludeTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Includes/IncludeTests.cs @@ -16,7 +16,7 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.QueryStrings.Includes public sealed class IncludeTests : IClassFixture, QueryStringDbContext>> { private readonly ExampleIntegrationTestContext, QueryStringDbContext> _testContext; - private readonly QueryStringFakers _fakers = new QueryStringFakers(); + private readonly QueryStringFakers _fakers = new(); public IncludeTests(ExampleIntegrationTestContext, QueryStringDbContext> testContext) { @@ -234,7 +234,7 @@ public async Task Can_include_HasManyThrough_relationship() post.BlogPostLabels = new HashSet { - new BlogPostLabel + new() { Label = _fakers.Label.Generate() } @@ -272,7 +272,7 @@ public async Task Can_include_HasManyThrough_relationship_in_secondary_resource( post.BlogPostLabels = new HashSet { - new BlogPostLabel + new() { Label = _fakers.Label.Generate() } diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Pagination/PaginationWithTotalCountTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Pagination/PaginationWithTotalCountTests.cs index 338bd2d843..1287bd8138 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Pagination/PaginationWithTotalCountTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Pagination/PaginationWithTotalCountTests.cs @@ -20,7 +20,7 @@ public sealed class PaginationWithTotalCountTests private const int DefaultPageSize = 5; private readonly ExampleIntegrationTestContext, QueryStringDbContext> _testContext; - private readonly QueryStringFakers _fakers = new QueryStringFakers(); + private readonly QueryStringFakers _fakers = new(); public PaginationWithTotalCountTests(ExampleIntegrationTestContext, QueryStringDbContext> testContext) { @@ -274,11 +274,11 @@ public async Task Can_paginate_in_scope_of_HasManyThrough_relationship() posts[0].BlogPostLabels = new HashSet { - new BlogPostLabel + new() { Label = _fakers.Label.Generate() }, - new BlogPostLabel + new() { Label = _fakers.Label.Generate() } @@ -286,11 +286,11 @@ public async Task Can_paginate_in_scope_of_HasManyThrough_relationship() posts[1].BlogPostLabels = new HashSet { - new BlogPostLabel + new() { Label = _fakers.Label.Generate() }, - new BlogPostLabel + new() { Label = _fakers.Label.Generate() } @@ -338,11 +338,11 @@ public async Task Can_paginate_HasManyThrough_relationship_on_relationship_endpo post.BlogPostLabels = new HashSet { - new BlogPostLabel + new() { Label = _fakers.Label.Generate() }, - new BlogPostLabel + new() { Label = _fakers.Label.Generate() } diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Pagination/PaginationWithoutTotalCountTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Pagination/PaginationWithoutTotalCountTests.cs index 7a2b94dbee..bbca95dec7 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Pagination/PaginationWithoutTotalCountTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Pagination/PaginationWithoutTotalCountTests.cs @@ -19,7 +19,7 @@ public sealed class PaginationWithoutTotalCountTests private const int DefaultPageSize = 5; private readonly ExampleIntegrationTestContext, QueryStringDbContext> _testContext; - private readonly QueryStringFakers _fakers = new QueryStringFakers(); + private readonly QueryStringFakers _fakers = new(); public PaginationWithoutTotalCountTests(ExampleIntegrationTestContext, QueryStringDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Pagination/RangeValidationTests.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Pagination/RangeValidationTests.cs index 8e31b58d15..5847d3ffc4 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Pagination/RangeValidationTests.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/Pagination/RangeValidationTests.cs @@ -16,7 +16,7 @@ public sealed class RangeValidationTests : IClassFixture, QueryStringDbContext> _testContext; - private readonly QueryStringFakers _fakers = new QueryStringFakers(); + private readonly QueryStringFakers _fakers = new(); public RangeValidationTests(ExampleIntegrationTestContext, QueryStringDbContext> testContext) { diff --git a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/QueryStringFakers.cs b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/QueryStringFakers.cs index 32591440c7..8817b66f1c 100644 --- a/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/QueryStringFakers.cs +++ b/test/JsonApiDotNetCoreExampleTests/IntegrationTests/QueryStrings/QueryStringFakers.cs @@ -9,31 +9,31 @@ namespace JsonApiDotNetCoreExampleTests.IntegrationTests.QueryStrings { internal sealed class QueryStringFakers : FakerContainer { - private readonly Lazy> _lazyBlogFaker = new Lazy>(() => + private readonly Lazy> _lazyBlogFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(blog => blog.Title, faker => faker.Lorem.Word()) .RuleFor(blog => blog.PlatformName, faker => faker.Company.CompanyName())); - private readonly Lazy> _lazyBlogPostFaker = new Lazy>(() => + private readonly Lazy> _lazyBlogPostFaker = new(() => new Faker() .UseSeed(GetFakerSeed()) .RuleFor(blogPost => blogPost.Caption, faker => faker.Lorem.Sentence()) .RuleFor(blogPost => blogPost.Url, faker => faker.Internet.Url())); - private readonly Lazy> _lazyLabelFaker = new Lazy>(() => + private readonly Lazy> _lazyLabelFaker = new(() => new Faker